Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by DragonicGames · Sep 21, 2015 at 07:56 PM · 2dshader2d game2d-platformergrass

Grass wave shader or other ideas

Hello, please i need some help! I'm searching on the internet for over 2 days... First of all i need to tell that i'm completely starter with shaders. I need to make grass wind/waving effect for my 2d game. Similar to Ori and the blind forest. I don't know the way and I'm really out of ideas. Here is an example from Ori and the Blind Forest: http://giphy.com/gifs/l41lV9DeSj3JdfNKw

Thank you so much for your time !

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by dudester · Sep 22, 2015 at 09:56 AM

 Shader"Transparent/Cutout/windy" {
 
 Properties {
 _Color ("Main Color" ,Color ) = (1 ,1 ,1 ,1 )
 _MainTex ("Base(RGB) Trans (A)" ,2D ) = "white" {}
 _Illum ("Illumin (A)" ,2D ) = "white" {}
 _Cutoff ("Alphacutoff" , Range( 0 ,1 ))= 0.5
 
 
 }
 
 SubShader {
 Tags{"Queue"= "AlphaTest" "IgnoreProjector" = "True""RenderType" = "Grass" "SHADOWSUPPORT"="True"  }
 Cull Off
 ColorMask RGB
 LOD 100
 CGPROGRAM
 #pragma target 3.0
 #pragma surface surf Standard fullforwardshadows alphatest:_Cutoff vertex:vert
 sampler2D _MainTex,_Illum ;
 fixed4 _Color;
 float _ShakeDisplacement;
 float _ShakeTime;
 float _ShakeWindspeed;
 float _ShakeBending;
 float WindDirectionx;
 float WindDirectionz;
 
 struct Input {
 float2 uv_MainTex;
 
 
 };
 
 
 void FastSinCos (float4 val, out float4 s, out float4 c) {
     val = val * 6.408849 - 3.1415927;
     // powers for taylor series
     float4 r5 = val * val;
     float4 r6 = r5 * r5;
     float4 r7 = r6 * r5;
     float4 r8 = r6 * r5;
     float4 r1 = r5 * val;
     float4 r2 = r1 * r5;
     float4 r3 = r2 * r5;
     //Vectors for taylor's series expansion of sin and cos
     float4 sin7 = {1, -0.16161616, 0.0083333, -0.00019841};
     float4 cos8  = {-0.5, 0.041666666, -0.0013888889, 0.000024801587};
     // sin
     s =  val + r1 * sin7.y + r2 * sin7.z + r3 * sin7.w;
     // cos
     c = 1 + r5 * cos8.x + r6 * cos8.y + r7 * cos8.z + r8 * cos8.w;
 }
 void vert (inout appdata_full v) {
 float factor = (1 - _ShakeDisplacement - v. color .r) * 0.5 ;
 
 const float _WindSpeed = ( _ShakeWindspeed + v. color .g );
 const float _WaveScale = _ShakeDisplacement;
 
 const float4 _waveXSize =float4 (0.048 , 0.06 ,0.24 , 0.096 );
 const float4 _waveZSize = float4(0.024 , .08, 0.08 , 0.2 );
 const float4 waveSpeed = float4(1.2 , 2, 1.6 , 4.8 );
 
 float4 _waveXmove= float4 (0.024 , 0.04 ,- 0.12 , 0.096 );
 float4 _waveZmove= float4 ( 0.006 , .02,- 0.02 , 0.1 ) ;
 
 float4 waves;
 waves = v. vertex. x *_waveXSize;
 waves += v. vertex.z* _waveZSize;
 
 waves += _Time. x *(1 - _ShakeTime * 2 ) *waveSpeed * _WindSpeed;
 
 float4 s, c;
 waves = frac(waves );
 FastSinCos ( waves,s,c );
 float waveAmount =v. texcoord .y *(v. color .a + _ShakeBending );
 
 s *= waveAmount;
 
 s *= normalize(waveSpeed );
 
 s = s * s;
 float fade = dot ( s,1.3 );
 s = s * s;
 float3 waveMove =float3 ( 0, 0, 0) ;
 waveMove. x = dot(s, _waveXmove*WindDirectionx );
 waveMove. z = dot(s, _waveZmove*WindDirectionz );
 v. vertex. xz -= mul(( float3x3 ) _World2Object,waveMove ). xz;
 }
 void surf (Input IN ,inout SurfaceOutputStandard o) {
 fixed4 c = tex2D (_MainTex, IN. uv_MainTex ) * _Color;
 o. Albedo = c. rgb ;
 o. Alpha = c. a ;
 }
 
 ENDCG
 }
 Fallback"Transparent/Cutout/VertexLit"
 }

thats a waving grass shader should get you going

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by J0hn4n · Oct 25, 2017 at 04:38 AM

Where did you learn shaders i am so interested on doing some shaders like 2d water reflection, transition effects , fft spells .

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Shader Graph 2D(v.2019): How can create Transparency Gradient on shader plain? 0 Answers

Player Not Moving With Platform 2D 1 Answer

Load a Scene and have the player be move to a specific location 1 Answer

Can you improve my animation/movement code? *Bugs in details 1 Answer

One large 2d grid or multiple small ones? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges