Skip to content

Commit

Permalink
Finished metallic support. Can now blend between two probes.
Browse files Browse the repository at this point in the history
  • Loading branch information
morerokk committed Apr 1, 2019
1 parent ba25f5a commit 22c70e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
28 changes: 23 additions & 5 deletions NoeNoe Shaders/NoeNoe Toon Shader/NoeNoeToonEdits.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,31 @@ float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float roughness = 1 - (metallicTex.a * _Glossiness);

float3 reflectedDir = reflect(-i.viewDir, normalize(i.normalDir));
float4 reflectionData = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflectedDir, roughness * UNITY_SPECCUBE_LOD_STEPS);
float3 reflectionColor = DecodeHDR(reflectionData, unity_SpecCube0_HDR);

reflectionColor *= Diffuse;
float3 reflectionColor;

//Sample second probe if available.
float interpolator = unity_SpecCube0_BoxMin.w;
UNITY_BRANCH
if(interpolator < 0.99999)
{
//Probe 1
float4 reflectionData0 = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflectedDir, roughness * UNITY_SPECCUBE_LOD_STEPS);
float3 reflectionColor0 = DecodeHDR(reflectionData0, unity_SpecCube0_HDR);

//Probe 2
float4 reflectionData1 = UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(unity_SpecCube1, unity_SpecCube0, reflectedDir, roughness * UNITY_SPECCUBE_LOD_STEPS);
float3 reflectionColor1 = DecodeHDR(reflectionData1, unity_SpecCube1_HDR);

reflectionColor = lerp(reflectionColor1, reflectionColor0, interpolator);
}
else
{
float4 reflectionData = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflectedDir, roughness * UNITY_SPECCUBE_LOD_STEPS);
reflectionColor = DecodeHDR(reflectionData, unity_SpecCube0_HDR);
}

//Lit reflections
//Diffuse = lerp(Diffuse, reflectionColor, metallic);
reflectionColor *= Diffuse;
#endif

float node_424 = 0.5;
Expand Down
2 changes: 1 addition & 1 deletion NoeNoe Shaders/readme_rokk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ A premade skin-colored toon ramp is included ("toon_skin_hq"). You can use toon

You should set the texture mode to "Clamp" in Unity on the toon ramp texture, to avoid very ugly artifacts.

Experimental Metallic support has been added. You can use the same metallic maps as in Standard (Red is Metallic, Alpha is Smoothness). Smoothness doesn't do anything by itself, lower smoothness only blurs the reflections on the Metallic. Reflections work the same way as Standard, but blending between multiple probes is not yet supported. This will come in the next version.
Experimental Metallic support has been added. You can use the same metallic maps as in Standard (Red is Metallic, Alpha is Smoothness). Smoothness doesn't do anything by itself, lower smoothness only blurs the reflections on the Metallic. Reflections work the same way as Standard.

0 comments on commit 22c70e6

Please sign in to comment.