// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject' // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' Shader "Unlit/ShaderTest2" { Properties { _Diffuse("Diffuse",Color) = (1,1,1,1) _Specular("Specular",Color) = (1,1,1,1) _Gloss("Gloss",Range(8,256)) = 20 _Texture("Texture",2D) = ""{} } SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct v2f { float2 uv : TEXCOORD1; half3 worldRefl : TEXCOORD0; float4 pos : SV_POSITION; }; sampler2D _Texture; float4 _Texture_ST; v2f vert (float4 vertex : POSITION, float3 normal : NORMAL,float2 uv :TEXCOORD1) { v2f o; o.pos = UnityObjectToClipPos(vertex); // compute world space position of the vertex float3 worldPos = mul(unity_ObjectToWorld, vertex).xyz; // compute world space view direction float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos)); // world space normal float3 worldNormal = UnityObjectToWorldNormal(normal); // world space reflection vector o.worldRefl = reflect(-worldViewDir, worldNormal); o.uv = TRANSFORM_TEX(uv,_Texture); return o; } fixed4 frag (v2f i) : SV_Target { // sample the default reflection cubemap, using the reflection vector half4 skyData = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, i.worldRefl); // decode cubemap data into actual color half3 skyColor = DecodeHDR (skyData, unity_SpecCube0_HDR); // output it! fixed4 c = 0; c.rgb = skyColor; c *= tex2D(_Texture,i.uv); return c; } ENDCG } } }