• 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 /
avatar image
0
Question by SkandYxyz · Jan 02, 2016 at 05:05 PM · shader

Shader vprog texture error on sm2

I want to run my Shader Forge water shader on mobile (Galaxy S3 SM2) and get this error:

GLES20: vprog textures are used, but not supported. GLSL link error: L0100 GLSL allows exactly two attatched shaders per programm

What causes this error? I wrote a mail to the shader forge developer but he don't know. Would be realy great to solve this. Here is my shader:

 // Shader created with Shader Forge v1.26 
 // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
 // Note: Manually altering this data may prevent you from opening it in Shader Forge
 /*SF_DATA;ver:1.26;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:3,bdst:7,dpts:2,wrdp:False,dith:0,rfrpo:True,rfrpn:Refraction,coma:15,ufog:False,aust:False,igpj:True,qofs:0,qpre:2,rntp:2,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False;n:type:ShaderForge.SFN_Final,id:3138,x:32719,y:32712,varname:node_3138,prsc:2|diff-6094-RGB,spec-8913-OUT,normal-2805-OUT,emission-4314-RGB,alpha-3458-OUT,refract-9101-OUT,voffset-7868-OUT;n:type:ShaderForge.SFN_Cubemap,id:4314,x:32047,y:32714,ptovrint:False,ptlb:Reflection,ptin:_Reflection,varname:node_4314,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,pvfc:0|DIR-2125-OUT;n:type:ShaderForge.SFN_ViewReflectionVector,id:2125,x:31868,y:32714,varname:node_2125,prsc:2;n:type:ShaderForge.SFN_ValueProperty,id:3458,x:32497,y:32877,ptovrint:False,ptlb:Opacity,ptin:_Opacity,varname:node_3458,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:0.8;n:type:ShaderForge.SFN_Tex2d,id:9630,x:32133,y:33205,varname:node_9630,prsc:2,ntxv:2,isnm:False|UVIN-1299-UVOUT,TEX-738-TEX;n:type:ShaderForge.SFN_TexCoord,id:1299,x:31924,y:33205,varname:node_1299,prsc:2,uv:0;n:type:ShaderForge.SFN_Slider,id:8913,x:32340,y:32753,ptovrint:False,ptlb:Metallic,ptin:_Metallic,varname:node_8913,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Tex2d,id:6094,x:32340,y:32572,ptovrint:False,ptlb:Base Texture,ptin:_BaseTexture,varname:node_6094,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:2,isnm:False|UVIN-1299-UVOUT;n:type:ShaderForge.SFN_Vector1,id:2735,x:34850,y:32380,cmnt:Sample Distance,varname:node_2735,prsc:2,v1:1;n:type:ShaderForge.SFN_Divide,id:9063,x:34557,y:32373,cmnt:U Step,varname:node_9063,prsc:2|A-2735-OUT,B-8196-X;n:type:ShaderForge.SFN_Divide,id:9957,x:34566,y:32609,cmnt:V Step,varname:node_9957,prsc:2|A-2735-OUT,B-8196-Y;n:type:ShaderForge.SFN_Vector4Property,id:8196,x:34867,y:32616,ptovrint:False,ptlb:Vec 4,ptin:_Vec4,varname:node_8196,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:255,v2:255,v3:0,v4:0;n:type:ShaderForge.SFN_TexCoord,id:9664,x:34884,y:33012,varname:node_9664,prsc:2,uv:0;n:type:ShaderForge.SFN_Add,id:861,x:34242,y:32272,cmnt:Positive U,varname:node_861,prsc:2|A-9664-U,B-9063-OUT;n:type:ShaderForge.SFN_Add,id:4946,x:34247,y:32834,cmnt:Positive V,varname:node_4946,prsc:2|A-9664-V,B-9957-OUT;n:type:ShaderForge.SFN_Subtract,id:8032,x:34247,y:32603,cmnt:Negative U,varname:node_8032,prsc:2|A-9664-U,B-9063-OUT;n:type:ShaderForge.SFN_Subtract,id:4279,x:34247,y:33037,cmnt:Negative V,varname:node_4279,prsc:2|A-9664-V,B-9957-OUT;n:type:ShaderForge.SFN_Append,id:1260,x:34022,y:32376,cmnt:Positive U,varname:node_1260,prsc:2|A-861-OUT,B-9664-V;n:type:ShaderForge.SFN_Append,id:1843,x:34022,y:32589,cmnt:Negative U,varname:node_1843,prsc:2|A-8032-OUT,B-9664-V;n:type:ShaderForge.SFN_Append,id:7228,x:34027,y:32854,cmnt:Positive V,varname:node_7228,prsc:2|A-9664-U,B-4946-OUT;n:type:ShaderForge.SFN_Append,id:9611,x:34027,y:33037,cmnt:Negative V,varname:node_9611,prsc:2|A-9664-U,B-4279-OUT;n:type:ShaderForge.SFN_Tex2d,id:3918,x:33830,y:32326,cmnt:Positive U,varname:node_3918,prsc:2,ntxv:0,isnm:False|UVIN-1260-OUT,TEX-738-TEX;n:type:ShaderForge.SFN_Tex2d,id:3397,x:33830,y:32514,cmnt:Negative U,varname:node_3397,prsc:2,ntxv:0,isnm:False|UVIN-1843-OUT,TEX-738-TEX;n:type:ShaderForge.SFN_Tex2d,id:1132,x:33830,y:32704,cmnt:Positive V,varname:node_1132,prsc:2,ntxv:0,isnm:False|UVIN-7228-OUT,TEX-738-TEX;n:type:ShaderForge.SFN_Tex2d,id:8354,x:33830,y:32894,cmnt:Negative V,varname:node_8354,prsc:2,ntxv:0,isnm:False|UVIN-9611-OUT,TEX-738-TEX;n:type:ShaderForge.SFN_Tex2d,id:8222,x:33830,y:33111,cmnt:Centre UV,varname:node_8222,prsc:2,ntxv:0,isnm:False|UVIN-9664-UVOUT,TEX-738-TEX;n:type:ShaderForge.SFN_ValueProperty,id:443,x:33420,y:32753,ptovrint:False,ptlb:,ptin:_,varname:node_443,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:32;n:type:ShaderForge.SFN_Multiply,id:908,x:33414,y:32331,varname:node_908,prsc:2|A-5462-OUT,B-443-OUT;n:type:ShaderForge.SFN_Multiply,id:6568,x:33414,y:32540,varname:node_6568,prsc:2|A-1793-OUT,B-443-OUT;n:type:ShaderForge.SFN_Multiply,id:2167,x:33420,y:32869,varname:node_2167,prsc:2|A-911-OUT,B-443-OUT;n:type:ShaderForge.SFN_Multiply,id:4278,x:33420,y:33064,varname:node_4278,prsc:2|A-2866-OUT,B-443-OUT;n:type:ShaderForge.SFN_Vector2,id:264,x:33261,y:32455,varname:node_264,prsc:2,v1:1,v2:0;n:type:ShaderForge.SFN_Vector2,id:6566,x:33261,y:32670,varname:node_6566,prsc:2,v1:-1,v2:0;n:type:ShaderForge.SFN_Vector2,id:5571,x:33261,y:32812,varname:node_5571,prsc:2,v1:0,v2:1;n:type:ShaderForge.SFN_Vector2,id:4631,x:33261,y:33011,varname:node_4631,prsc:2,v1:0,v2:-1;n:type:ShaderForge.SFN_Append,id:6827,x:33094,y:32437,varname:node_6827,prsc:2|A-264-OUT,B-908-OUT;n:type:ShaderForge.SFN_Append,id:8750,x:33094,y:32610,varname:node_8750,prsc:2|A-6566-OUT,B-6568-OUT;n:type:ShaderForge.SFN_Append,id:2652,x:33094,y:32778,varname:node_2652,prsc:2|A-5571-OUT,B-2167-OUT;n:type:ShaderForge.SFN_Append,id:2819,x:33092,y:32926,varname:node_2819,prsc:2|A-4631-OUT,B-4278-OUT;n:type:ShaderForge.SFN_Cross,id:7564,x:32941,y:32541,varname:node_7564,prsc:2|A-6827-OUT,B-2819-OUT;n:type:ShaderForge.SFN_Cross,id:4111,x:32941,y:32705,varname:node_4111,prsc:2|A-2819-OUT,B-8750-OUT;n:type:ShaderForge.SFN_Cross,id:5970,x:32943,y:32874,varname:node_5970,prsc:2|A-8750-OUT,B-2652-OUT;n:type:ShaderForge.SFN_Cross,id:5918,x:32945,y:33042,varname:node_5918,prsc:2|A-2652-OUT,B-6827-OUT;n:type:ShaderForge.SFN_Add,id:3606,x:33451,y:31879,varname:node_3606,prsc:2|A-7564-OUT,B-4111-OUT,C-5970-OUT,D-5918-OUT;n:type:ShaderForge.SFN_Vector1,id:5903,x:33464,y:32056,varname:node_5903,prsc:2,v1:-4;n:type:ShaderForge.SFN_Divide,id:21,x:33251,y:31879,varname:node_21,prsc:2|A-3606-OUT,B-5903-OUT;n:type:ShaderForge.SFN_Normalize,id:2805,x:33015,y:31879,varname:node_2805,prsc:2|IN-21-OUT;n:type:ShaderForge.SFN_Tex2dAsset,id:738,x:32133,y:33402,ptovrint:False,ptlb:Heightmap,ptin:_Heightmap,varname:node_738,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Subtract,id:5462,x:33627,y:32333,varname:node_5462,prsc:2|A-3918-R,B-8222-R;n:type:ShaderForge.SFN_Subtract,id:1793,x:33622,y:32530,varname:node_1793,prsc:2|A-3397-R,B-8222-R;n:type:ShaderForge.SFN_Subtract,id:911,x:33622,y:32732,varname:node_911,prsc:2|A-1132-R,B-8222-R;n:type:ShaderForge.SFN_Subtract,id:2866,x:33622,y:32910,varname:node_2866,prsc:2|A-8354-R,B-8222-R;n:type:ShaderForge.SFN_Slider,id:9006,x:32383,y:33501,ptovrint:False,ptlb:Wave Scale,ptin:_WaveScale,varname:node_9006,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:10;n:type:ShaderForge.SFN_Multiply,id:1440,x:32366,y:33205,varname:node_1440,prsc:2|A-9630-R,B-9006-OUT;n:type:ShaderForge.SFN_Append,id:7868,x:32582,y:33205,varname:node_7868,prsc:2|A-79-OUT,B-79-OUT,C-1440-OUT;n:type:ShaderForge.SFN_Vector1,id:79,x:32582,y:33368,varname:node_79,prsc:2,v1:0;n:type:ShaderForge.SFN_Append,id:8071,x:32221,y:32952,varname:node_8071,prsc:2|A-2971-R,B-2971-G;n:type:ShaderForge.SFN_ComponentMask,id:2971,x:32025,y:32952,varname:node_2971,prsc:2,cc1:0,cc2:1,cc3:2,cc4:-1|IN-2805-OUT;n:type:ShaderForge.SFN_Divide,id:9101,x:32418,y:32952,varname:node_9101,prsc:2|A-8071-OUT,B-1701-OUT;n:type:ShaderForge.SFN_Slider,id:1701,x:32133,y:33119,ptovrint:False,ptlb:Refraction,ptin:_Refraction,varname:node_1701,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:1,cur:10,max:50;proporder:4314-3458-8913-6094-738-8196-443-9006-1701;pass:END;sub:END;*/
 
 Shader "Shader Forge/Water" {
     Properties {
         _Reflection ("Reflection", Cube) = "_Skybox" {}
         _Opacity ("Opacity", Float ) = 0.8
         _Metallic ("Metallic", Range(0, 1)) = 0
         _BaseTexture ("Base Texture", 2D) = "black" {}
         _Heightmap ("Heightmap", 2D) = "white" {}
         _Vec4 ("Vec 4", Vector) = (255,255,0,0)
         _ ("", Float ) = 32
         _WaveScale ("Wave Scale", Range(0, 10)) = 1
         _Refraction ("Refraction", Range(1, 50)) = 10
         [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
     }
     SubShader {
         Tags {
             "IgnoreProjector"="True"
             "Queue"="AlphaTest"
             "RenderType"="Transparent"
         }
         GrabPass{ }
         Pass {
             Name "FORWARD"
             Tags {
                 "LightMode"="ForwardBase"
             }
             Blend SrcAlpha OneMinusSrcAlpha
             ZWrite Off
             
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #define UNITY_PASS_FORWARDBASE
             #include "UnityCG.cginc"
             #include "UnityPBSLighting.cginc"
             #include "UnityStandardBRDF.cginc"
             #pragma multi_compile_fwdbase
             #pragma exclude_renderers metal d3d11_9x xbox360 xboxone ps3 ps4 psp2 
             #pragma target 3.0
             #pragma glsl
             uniform sampler2D _GrabTexture;
             uniform samplerCUBE _Reflection;
             uniform float _Opacity;
             uniform float _Metallic;
             uniform sampler2D _BaseTexture; uniform float4 _BaseTexture_ST;
             uniform float4 _Vec4;
             uniform float _;
             uniform sampler2D _Heightmap; uniform float4 _Heightmap_ST;
             uniform float _WaveScale;
             uniform float _Refraction;
             struct VertexInput {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float4 tangent : TANGENT;
                 float2 texcoord0 : TEXCOORD0;
             };
             struct VertexOutput {
                 float4 pos : SV_POSITION;
                 float2 uv0 : TEXCOORD0;
                 float4 posWorld : TEXCOORD1;
                 float3 normalDir : TEXCOORD2;
                 float3 tangentDir : TEXCOORD3;
                 float3 bitangentDir : TEXCOORD4;
                 float4 screenPos : TEXCOORD5;
             };
             VertexOutput vert (VertexInput v) {
                 VertexOutput o = (VertexOutput)0;
                 o.uv0 = v.texcoord0;
                 o.normalDir = UnityObjectToWorldNormal(v.normal);
                 o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
                 o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
                 float node_79 = 0.0;
                 float4 node_9630 = tex2Dlod(_Heightmap,float4(TRANSFORM_TEX(o.uv0, _Heightmap),0.0,0));
                 v.vertex.xyz += float3(node_79,node_79,(node_9630.r*_WaveScale));
                 o.posWorld = mul(_Object2World, v.vertex);
                 float3 lightColor = _LightColor0.rgb;
                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
                 o.screenPos = o.pos;
                 return o;
             }
             float4 frag(VertexOutput i) : COLOR {
                 #if UNITY_UV_STARTS_AT_TOP
                     float grabSign = -_ProjectionParams.x;
                 #else
                     float grabSign = _ProjectionParams.x;
                 #endif
                 i.normalDir = normalize(i.normalDir);
                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
                 i.screenPos.y *= _ProjectionParams.x;
                 float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
                 float node_2735 = 1.0; // Sample Distance
                 float node_9063 = (node_2735/_Vec4.r); // U Step
                 float2 node_1260 = float2((i.uv0.r+node_9063),i.uv0.g); // Positive U
                 float4 node_3918 = tex2D(_Heightmap,TRANSFORM_TEX(node_1260, _Heightmap)); // Positive U
                 float4 node_8222 = tex2D(_Heightmap,TRANSFORM_TEX(i.uv0, _Heightmap)); // Centre UV
                 float3 node_6827 = float3(float2(1,0),((node_3918.r-node_8222.r)*_));
                 float node_9957 = (node_2735/_Vec4.g); // V Step
                 float2 node_9611 = float2(i.uv0.r,(i.uv0.g-node_9957)); // Negative V
                 float4 node_8354 = tex2D(_Heightmap,TRANSFORM_TEX(node_9611, _Heightmap)); // Negative V
                 float3 node_2819 = float3(float2(0,-1),((node_8354.r-node_8222.r)*_));
                 float2 node_1843 = float2((i.uv0.r-node_9063),i.uv0.g); // Negative U
                 float4 node_3397 = tex2D(_Heightmap,TRANSFORM_TEX(node_1843, _Heightmap)); // Negative U
                 float3 node_8750 = float3(float2(-1,0),((node_3397.r-node_8222.r)*_));
                 float2 node_7228 = float2(i.uv0.r,(i.uv0.g+node_9957)); // Positive V
                 float4 node_1132 = tex2D(_Heightmap,TRANSFORM_TEX(node_7228, _Heightmap)); // Positive V
                 float3 node_2652 = float3(float2(0,1),((node_1132.r-node_8222.r)*_));
                 float3 node_2805 = normalize(((cross(node_6827,node_2819)+cross(node_2819,node_8750)+cross(node_8750,node_2652)+cross(node_2652,node_6827))/(-4.0)));
                 float3 normalLocal = node_2805;
                 float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
                 float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
                 float3 node_2971 = node_2805.rgb;
                 float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (float2(node_2971.r,node_2971.g)/_Refraction);
                 float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
                 float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
                 float3 lightColor = _LightColor0.rgb;
                 float3 halfDirection = normalize(viewDirection+lightDirection);
 ////// Lighting:
                 float attenuation = 1;
                 float3 attenColor = attenuation * _LightColor0.xyz;
                 float Pi = 3.141592654;
                 float InvPi = 0.31830988618;
 ///////// Gloss:
                 float gloss = 0.5;
                 float specPow = exp2( gloss * 10.0+1.0);
 /////// GI Data:
                 UnityLight light;
                 #ifdef LIGHTMAP_OFF
                     light.color = lightColor;
                     light.dir = lightDirection;
                     light.ndotl = LambertTerm (normalDirection, light.dir);
                 #else
                     light.color = half3(0.f, 0.f, 0.f);
                     light.ndotl = 0.0f;
                     light.dir = half3(0.f, 0.f, 0.f);
                 #endif
                 UnityGIInput d;
                 d.light = light;
                 d.worldPos = i.posWorld.xyz;
                 d.worldViewDir = viewDirection;
                 d.atten = attenuation;
                 Unity_GlossyEnvironmentData ugls_en_data;
                 ugls_en_data.roughness = 1.0 - gloss;
                 ugls_en_data.reflUVW = viewReflectDirection;
                 UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
                 lightDirection = gi.light.dir;
                 lightColor = gi.light.color;
 ////// Specular:
                 float NdotL = max(0, dot( normalDirection, lightDirection ));
                 float LdotH = max(0.0,dot(lightDirection, halfDirection));
                 float4 _BaseTexture_var = tex2D(_BaseTexture,TRANSFORM_TEX(i.uv0, _BaseTexture));
                 float3 diffuseColor = _BaseTexture_var.rgb; // Need this for specular when using metallic
                 float specularMonochrome;
                 float3 specularColor;
                 diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, _Metallic, specularColor, specularMonochrome );
                 specularMonochrome = 1-specularMonochrome;
                 float NdotV = max(0.0,dot( normalDirection, viewDirection ));
                 float NdotH = max(0.0,dot( normalDirection, halfDirection ));
                 float VdotH = max(0.0,dot( viewDirection, halfDirection ));
                 float visTerm = SmithBeckmannVisibilityTerm( NdotL, NdotV, 1.0-gloss );
                 float normTerm = max(0.0, NDFBlinnPhongNormalizedTerm(NdotH, RoughnessToSpecPower(1.0-gloss)));
                 float specularPBL = max(0, (NdotL*visTerm*normTerm) * (UNITY_PI / 4) );
                 float3 directSpecular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(halfDirection,normalDirection)),specPow)*specularPBL*lightColor*FresnelTerm(specularColor, LdotH);
                 float3 specular = directSpecular;
 /////// Diffuse:
                 NdotL = max(0.0,dot( normalDirection, lightDirection ));
                 half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
                 float3 directDiffuse = ((1 +(fd90 - 1)*pow((1.00001-NdotL), 5)) * (1 + (fd90 - 1)*pow((1.00001-NdotV), 5)) * NdotL) * attenColor;
                 float3 indirectDiffuse = float3(0,0,0);
                 indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light
                 float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
 ////// Emissive:
                 float3 emissive = texCUBE(_Reflection,viewReflectDirection).rgb;
 /// Final Color:
                 float3 finalColor = diffuse + specular + emissive;
                 return fixed4(lerp(sceneColor.rgb, finalColor,_Opacity),1);
             }
             ENDCG
         }
         Pass {
             Name "FORWARD_DELTA"
             Tags {
                 "LightMode"="ForwardAdd"
             }
             Blend One One
             ZWrite Off
             
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #define UNITY_PASS_FORWARDADD
             #include "UnityCG.cginc"
             #include "AutoLight.cginc"
             #include "UnityPBSLighting.cginc"
             #include "UnityStandardBRDF.cginc"
             #pragma multi_compile_fwdadd
             #pragma exclude_renderers metal d3d11_9x xbox360 xboxone ps3 ps4 psp2 
             #pragma target 3.0
             #pragma glsl
             uniform sampler2D _GrabTexture;
             uniform samplerCUBE _Reflection;
             uniform float _Opacity;
             uniform float _Metallic;
             uniform sampler2D _BaseTexture; uniform float4 _BaseTexture_ST;
             uniform float4 _Vec4;
             uniform float _;
             uniform sampler2D _Heightmap; uniform float4 _Heightmap_ST;
             uniform float _WaveScale;
             uniform float _Refraction;
             struct VertexInput {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float4 tangent : TANGENT;
                 float2 texcoord0 : TEXCOORD0;
             };
             struct VertexOutput {
                 float4 pos : SV_POSITION;
                 float2 uv0 : TEXCOORD0;
                 float4 posWorld : TEXCOORD1;
                 float3 normalDir : TEXCOORD2;
                 float3 tangentDir : TEXCOORD3;
                 float3 bitangentDir : TEXCOORD4;
                 float4 screenPos : TEXCOORD5;
                 LIGHTING_COORDS(6,7)
             };
             VertexOutput vert (VertexInput v) {
                 VertexOutput o = (VertexOutput)0;
                 o.uv0 = v.texcoord0;
                 o.normalDir = UnityObjectToWorldNormal(v.normal);
                 o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
                 o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
                 float node_79 = 0.0;
                 float4 node_9630 = tex2Dlod(_Heightmap,float4(TRANSFORM_TEX(o.uv0, _Heightmap),0.0,0));
                 v.vertex.xyz += float3(node_79,node_79,(node_9630.r*_WaveScale));
                 o.posWorld = mul(_Object2World, v.vertex);
                 float3 lightColor = _LightColor0.rgb;
                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
                 o.screenPos = o.pos;
                 TRANSFER_VERTEX_TO_FRAGMENT(o)
                 return o;
             }
             float4 frag(VertexOutput i) : COLOR {
                 #if UNITY_UV_STARTS_AT_TOP
                     float grabSign = -_ProjectionParams.x;
                 #else
                     float grabSign = _ProjectionParams.x;
                 #endif
                 i.normalDir = normalize(i.normalDir);
                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
                 i.screenPos.y *= _ProjectionParams.x;
                 float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
                 float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
                 float node_2735 = 1.0; // Sample Distance
                 float node_9063 = (node_2735/_Vec4.r); // U Step
                 float2 node_1260 = float2((i.uv0.r+node_9063),i.uv0.g); // Positive U
                 float4 node_3918 = tex2D(_Heightmap,TRANSFORM_TEX(node_1260, _Heightmap)); // Positive U
                 float4 node_8222 = tex2D(_Heightmap,TRANSFORM_TEX(i.uv0, _Heightmap)); // Centre UV
                 float3 node_6827 = float3(float2(1,0),((node_3918.r-node_8222.r)*_));
                 float node_9957 = (node_2735/_Vec4.g); // V Step
                 float2 node_9611 = float2(i.uv0.r,(i.uv0.g-node_9957)); // Negative V
                 float4 node_8354 = tex2D(_Heightmap,TRANSFORM_TEX(node_9611, _Heightmap)); // Negative V
                 float3 node_2819 = float3(float2(0,-1),((node_8354.r-node_8222.r)*_));
                 float2 node_1843 = float2((i.uv0.r-node_9063),i.uv0.g); // Negative U
                 float4 node_3397 = tex2D(_Heightmap,TRANSFORM_TEX(node_1843, _Heightmap)); // Negative U
                 float3 node_8750 = float3(float2(-1,0),((node_3397.r-node_8222.r)*_));
                 float2 node_7228 = float2(i.uv0.r,(i.uv0.g+node_9957)); // Positive V
                 float4 node_1132 = tex2D(_Heightmap,TRANSFORM_TEX(node_7228, _Heightmap)); // Positive V
                 float3 node_2652 = float3(float2(0,1),((node_1132.r-node_8222.r)*_));
                 float3 node_2805 = normalize(((cross(node_6827,node_2819)+cross(node_2819,node_8750)+cross(node_8750,node_2652)+cross(node_2652,node_6827))/(-4.0)));
                 float3 normalLocal = node_2805;
                 float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
                 float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
                 float3 node_2971 = node_2805.rgb;
                 float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (float2(node_2971.r,node_2971.g)/_Refraction);
                 float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
                 float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
                 float3 lightColor = _LightColor0.rgb;
                 float3 halfDirection = normalize(viewDirection+lightDirection);
 ////// Lighting:
                 float attenuation = LIGHT_ATTENUATION(i);
                 float3 attenColor = attenuation * _LightColor0.xyz;
                 float Pi = 3.141592654;
                 float InvPi = 0.31830988618;
 ///////// Gloss:
                 float gloss = 0.5;
                 float specPow = exp2( gloss * 10.0+1.0);
 ////// Specular:
                 float NdotL = max(0, dot( normalDirection, lightDirection ));
                 float LdotH = max(0.0,dot(lightDirection, halfDirection));
                 float4 _BaseTexture_var = tex2D(_BaseTexture,TRANSFORM_TEX(i.uv0, _BaseTexture));
                 float3 diffuseColor = _BaseTexture_var.rgb; // Need this for specular when using metallic
                 float specularMonochrome;
                 float3 specularColor;
                 diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, _Metallic, specularColor, specularMonochrome );
                 specularMonochrome = 1-specularMonochrome;
                 float NdotV = max(0.0,dot( normalDirection, viewDirection ));
                 float NdotH = max(0.0,dot( normalDirection, halfDirection ));
                 float VdotH = max(0.0,dot( viewDirection, halfDirection ));
                 float visTerm = SmithBeckmannVisibilityTerm( NdotL, NdotV, 1.0-gloss );
                 float normTerm = max(0.0, NDFBlinnPhongNormalizedTerm(NdotH, RoughnessToSpecPower(1.0-gloss)));
                 float specularPBL = max(0, (NdotL*visTerm*normTerm) * (UNITY_PI / 4) );
                 float3 directSpecular = attenColor * pow(max(0,dot(halfDirection,normalDirection)),specPow)*specularPBL*lightColor*FresnelTerm(specularColor, LdotH);
                 float3 specular = directSpecular;
 /////// Diffuse:
                 NdotL = max(0.0,dot( normalDirection, lightDirection ));
                 half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
                 float3 directDiffuse = ((1 +(fd90 - 1)*pow((1.00001-NdotL), 5)) * (1 + (fd90 - 1)*pow((1.00001-NdotV), 5)) * NdotL) * attenColor;
                 float3 diffuse = directDiffuse * diffuseColor;
 /// Final Color:
                 float3 finalColor = diffuse + specular;
                 return fixed4(finalColor * _Opacity,0);
             }
             ENDCG
         }
         Pass {
             Name "ShadowCaster"
             Tags {
                 "LightMode"="ShadowCaster"
             }
             Offset 1, 1
             
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #define UNITY_PASS_SHADOWCASTER
             #include "UnityCG.cginc"
             #include "Lighting.cginc"
             #include "UnityPBSLighting.cginc"
             #include "UnityStandardBRDF.cginc"
             #pragma fragmentoption ARB_precision_hint_fastest
             #pragma multi_compile_shadowcaster
             #pragma exclude_renderers metal d3d11_9x xbox360 xboxone ps3 ps4 psp2 
             #pragma target 3.0
             #pragma glsl
             uniform sampler2D _Heightmap; uniform float4 _Heightmap_ST;
             uniform float _WaveScale;
             struct VertexInput {
                 float4 vertex : POSITION;
                 float2 texcoord0 : TEXCOORD0;
             };
             struct VertexOutput {
                 V2F_SHADOW_CASTER;
                 float2 uv0 : TEXCOORD1;
             };
             VertexOutput vert (VertexInput v) {
                 VertexOutput o = (VertexOutput)0;
                 o.uv0 = v.texcoord0;
                 float node_79 = 0.0;
                 float4 node_9630 = tex2Dlod(_Heightmap,float4(TRANSFORM_TEX(o.uv0, _Heightmap),0.0,0));
                 v.vertex.xyz += float3(node_79,node_79,(node_9630.r*_WaveScale));
                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
                 TRANSFER_SHADOW_CASTER(o)
                 return o;
             }
             float4 frag(VertexOutput i) : COLOR {
                 SHADOW_CASTER_FRAGMENT(i)
             }
             ENDCG
         }
     }
     FallBack "Diffuse"
     CustomEditor "ShaderForgeMaterialInspector"
 }

Thank you very much.

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

40 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to force the compilation of a shader in Unity? 5 Answers

Particles are rendering in front of trees... 1 Answer

Oculus rendeing bug 0 Answers

Shader: _LightColor0 and _WorldSpaceLightPos0 are not updating 1 Answer

Glass Shader with Strumpy Shader Editor 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