hi guys i have this simple shader wherein i want to displace the vertices but i get the error "" on line 23.Cud somebody point out wat i'm doing wrong? Shader "Underwater Effect" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RfGB)", 2D) = "white" {} } Pass { CGPROGRAM #pragma vertex vert #include "UnityCG.cginc" #include "AutoLight.cginc" uniform float4 _MainTex_ST; vert (appdata_base v) { float Waviness = 5.0f; v.vertex.x += Mathf.Sin(Time.time + v.vertex.y * 0.1f) * Waviness; } ENDCG } Fallback "Diffuse" } another side question.. do i need uniform float4 _MainTex_ST;? wat is that for?i actually copied my code from another shader and went on removing unwanted stuff.the above variable was not getting used even in that shader but with a lot of things happening behind the curtains in shaderlab i didnt want to remove this 1
Have you read the responses in your other topic? Really, you need to read the shaderlab docs. That code's not even Cg; there's no way it will come close to working. --Eric
Your shader like this gives 5 errors (no SubShader block, and the rest in Cg code). Here is how it should be (I removed Properties block as well, you said you want minimal shader): Code (csharp): Shader "Underwater Effect" { SubShader { Pass { CGPROGRAM #pragma vertex vert #include "UnityCG.cginc" float4 vert (appdata_base v) : POSITION { float Waviness = 5.0f; v.vertex.x += sin(_Time.y + v.vertex.y * 0.1f) * Waviness; return mul(glstate.matrix.mvp, v.vertex); } ENDCG } } } Basically, like someone replied in another thread, inside of shaders you don't have access to .NET calls (so no Time.time or Mathf.Sin there). Cg has a built-in function to calculate sine ("sin"). Time value can either be passed manually from your script, or you can use _Time built-in variable. If you don't use it in the shader, then you don't need it. Variables ending with _ST are used by built-in Unity shaders to apply texture's tiling offset values. As your shader does not use textures, there's no tiling&offset to apply.
Thx dude that helped.Although not including the subshader part was my bad.i do have it in place.thx again
hey i lost track of that post for some reason and i checked it only after reading this 1.i apologize for that well i did search for shaderlab docs but cudnt find 1 proper 1.do have any link where i cud find 1?i know cg but using it along with shaderlab has me confused and i feel like u cud combine the features for more powerful shaders.but yeah a shaderlab doc will definitely help as i'm totally new to it. Thx