// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' // Shader created with Shader Forge v1.33 // 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.33;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:2,spmd:1,trmd:1,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:True,rprd:True,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:0,bdst:0,dpts:2,wrdp:False,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:False,aust:True,igpj:True,qofs:0,qpre:3,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:33092,y:32650,varname:node_3138,prsc:2|diff-5326-OUT,spec-2014-OUT,gloss-9583-OUT,alpha-7241-A;n:type:ShaderForge.SFN_Color,id:7241,x:31892,y:32636,ptovrint:False,ptlb:Specular,ptin:_Specular,varname:_Specular,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Multiply,id:2014,x:32273,y:32850,varname:node_2014,prsc:2|A-7241-RGB,B-9893-RGB;n:type:ShaderForge.SFN_Tex2d,id:9893,x:31960,y:32931,ptovrint:False,ptlb:Mask,ptin:_Mask,varname:_Mask,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Slider,id:9583,x:32087,y:32585,ptovrint:False,ptlb:Gloss,ptin:_Gloss,varname:_Gloss,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.8888889,max:1;n:type:ShaderForge.SFN_Vector1,id:5326,x:32447,y:32512,varname:node_5326,prsc:2,v1:0;proporder:7241-9893-9583;pass:END;sub:END;*/ Shader "Fog Volume/Room Floor Reflection" { Properties { _Specular ("Specular", Color) = (1,1,1,1) _Mask ("Mask", 2D) = "white" {} _Gloss ("Gloss", Range(0, 1)) = 0.8888889 [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 } SubShader { Tags { "IgnoreProjector"="True" "Queue"="Transparent" "RenderType"="Transparent" } Pass { Name "FORWARD" Tags { "LightMode"="ForwardBase" } Blend One One ZWrite Off CGPROGRAM #pragma vertex vert #pragma fragment frag // #define UNITY_PASS_FORWARDBASE #define _GLOSSYENV 1 #include "UnityCG.cginc" #include "UnityPBSLighting.cginc" #include "UnityStandardBRDF.cginc" #pragma multi_compile_fwdbase #pragma only_renderers d3d9 d3d11 glcore gles gles3 metal #pragma target 3.0 uniform float4 _Specular; uniform sampler2D _Mask; uniform float4 _Mask_ST; uniform float _Gloss; struct VertexInput { float4 vertex : POSITION; float3 normal : NORMAL; float2 texcoord0 : TEXCOORD0; }; struct VertexOutput { float4 pos : SV_POSITION; float2 uv0 : TEXCOORD0; float4 posWorld : TEXCOORD1; float3 normalDir : TEXCOORD2; }; VertexOutput vert (VertexInput v) { VertexOutput o = (VertexOutput)0; o.uv0 = v.texcoord0; o.normalDir = UnityObjectToWorldNormal(v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); float3 lightColor = _LightColor0.rgb; o.pos = UnityObjectToClipPos(v.vertex ); return o; } float4 frag(VertexOutput i) : COLOR { i.normalDir = normalize(i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 normalDirection = i.normalDir; float3 viewReflectDirection = reflect( -viewDirection, normalDirection ); float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz); float3 lightColor = _LightColor0.rgb; ////// Lighting: float attenuation = 1; float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = _Gloss; 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; #if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION d.boxMin[0] = unity_SpecCube0_BoxMin; d.boxMin[1] = unity_SpecCube1_BoxMin; #endif #if UNITY_SPECCUBE_BOX_PROJECTION d.boxMax[0] = unity_SpecCube0_BoxMax; d.boxMax[1] = unity_SpecCube1_BoxMax; d.probePosition[0] = unity_SpecCube0_ProbePosition; d.probePosition[1] = unity_SpecCube1_ProbePosition; #endif d.probeHDR[0] = unity_SpecCube0_HDR; d.probeHDR[1] = unity_SpecCube1_HDR; 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 = saturate(dot( normalDirection, lightDirection )); float4 _Mask_var = tex2D(_Mask,TRANSFORM_TEX(i.uv0, _Mask)); float3 specularColor = (_Specular.rgb*_Mask_var.rgb); float3 directSpecular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(reflect(-lightDirection, normalDirection),viewDirection)),specPow)*specularColor; float3 indirectSpecular = (gi.indirect.specular)*specularColor; float3 specular = (directSpecular + indirectSpecular); /////// Diffuse: NdotL = max(0.0,dot( normalDirection, lightDirection )); float3 directDiffuse = max( 0.0, NdotL) * attenColor; float3 indirectDiffuse = float3(0,0,0); indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light float node_5326 = 0.0; float3 diffuseColor = float3(node_5326,node_5326,node_5326); float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor; /// Final Color: float3 finalColor = diffuse * _Specular.a + specular; return fixed4(finalColor,_Specular.a); } ENDCG } Pass { Name "FORWARD_DELTA" Tags { "LightMode"="ForwardAdd" } Blend One One ZWrite Off CGPROGRAM #pragma vertex vert #pragma fragment frag //#define UNITY_PASS_FORWARDADD #define _GLOSSYENV 1 #include "UnityCG.cginc" #include "AutoLight.cginc" #include "UnityPBSLighting.cginc" #include "UnityStandardBRDF.cginc" #pragma multi_compile_fwdadd #pragma only_renderers d3d9 d3d11 glcore gles gles3 metal #pragma target 3.0 uniform float4 _Specular; uniform sampler2D _Mask; uniform float4 _Mask_ST; uniform float _Gloss; struct VertexInput { float4 vertex : POSITION; float3 normal : NORMAL; float2 texcoord0 : TEXCOORD0; }; struct VertexOutput { float4 pos : SV_POSITION; float2 uv0 : TEXCOORD0; float4 posWorld : TEXCOORD1; float3 normalDir : TEXCOORD2; LIGHTING_COORDS(3,4) }; VertexOutput vert (VertexInput v) { VertexOutput o = (VertexOutput)0; o.uv0 = v.texcoord0; o.normalDir = UnityObjectToWorldNormal(v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); float3 lightColor = _LightColor0.rgb; o.pos = UnityObjectToClipPos(v.vertex ); TRANSFER_VERTEX_TO_FRAGMENT(o) return o; } float4 frag(VertexOutput i) : COLOR { i.normalDir = normalize(i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 normalDirection = i.normalDir; float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w)); float3 lightColor = _LightColor0.rgb; ////// Lighting: float attenuation = LIGHT_ATTENUATION(i); float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = _Gloss; float specPow = exp2( gloss * 10.0+1.0); ////// Specular: float NdotL = saturate(dot( normalDirection, lightDirection )); float4 _Mask_var = tex2D(_Mask,TRANSFORM_TEX(i.uv0, _Mask)); float3 specularColor = (_Specular.rgb*_Mask_var.rgb); float3 directSpecular = attenColor * pow(max(0,dot(reflect(-lightDirection, normalDirection),viewDirection)),specPow)*specularColor; float3 specular = directSpecular; /////// Diffuse: NdotL = max(0.0,dot( normalDirection, lightDirection )); float3 directDiffuse = max( 0.0, NdotL) * attenColor; float node_5326 = 0.0; float3 diffuseColor = float3(node_5326,node_5326,node_5326); float3 diffuse = directDiffuse * diffuseColor; /// Final Color: float3 finalColor = diffuse * _Specular.a + specular; return fixed4(finalColor,0); } ENDCG } } FallBack "Diffuse" CustomEditor "ShaderForgeMaterialInspector" }