Skip to content

Commit

Permalink
Update to 2021.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiliMilk committed May 28, 2022
1 parent da5f273 commit 066da2c
Show file tree
Hide file tree
Showing 71 changed files with 1,378 additions and 1,776 deletions.
148 changes: 79 additions & 69 deletions Assets/ChiliMilkToonShader/Editor/ToonShaderGUI.cs

Large diffs are not rendered by default.

23 changes: 6 additions & 17 deletions Assets/ChiliMilkToonShader/Include/ToonForwardPass.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ struct Varyings
float4 shadowCoord : TEXCOORD7;
#endif

#ifdef _SDFSHADOWMAP
half2 LdotFL : TEXCOORD8;
#endif
float4 positionCS : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
Expand Down Expand Up @@ -82,15 +79,6 @@ void InitializeInputDataToon(Varyings input, half3 normalTS, out InputDataToon i
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV);

#if defined(_RECEIVE_HAIRSHADOWMASK) && defined(_HAIRSHADOWMASK)
inputData.depth = input.positionCS.z/input.positionCS.w;
#endif

#ifdef _SDFSHADOWMAP
inputData.LdotFL = input.LdotFL;
inputData.uv = input.uv;
#endif

}

Varyings ToonForwardPassVertex(Attributes input)
Expand Down Expand Up @@ -128,10 +116,7 @@ Varyings ToonForwardPassVertex(Attributes input)
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif

#ifdef _SDFSHADOWMAP
output.LdotFL = LightDotObjectFL();
#endif

output.positionCS = vertexInput.positionCS;

return output;
Expand All @@ -141,13 +126,17 @@ half4 ToonForwardPassFragment(Varyings input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);

SurfaceDataToon surfaceData;
InitializeSurfaceDataToon(input.uv, surfaceData);

InputDataToon inputData;
InitializeInputDataToon(input, surfaceData.normalTS, inputData);

ToonData toonData;
InitializeToonData(input.uv, inputData.normalizedScreenSpaceUV, surfaceData.albedo, surfaceData.occlusion, input.positionCS.z / input.positionCS.w, toonData);

half4 color = FragmentLitToon(inputData, surfaceData);
half4 color = FragmentLitToon(inputData, surfaceData, toonData);
color.rgb = MixFog(color.rgb, inputData.fogCoord);
return color;
}
Expand Down
5 changes: 3 additions & 2 deletions Assets/ChiliMilkToonShader/Include/ToonFunction.hlsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef TOON_FUNCTION_INCLUDED
#define TOON_FUNCTION_INCLUDED

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

//https://github.com/Jason-Ma-233/JasonMaToonRenderPipeline
//Get Smooth Outline NormalWS
float3 GetSmoothedWorldNormal(float2 uv7, float3x3 t_tbn)
Expand Down Expand Up @@ -36,8 +38,7 @@ half DiffuseRadianceToon(half value,half step,half feather)
//Use to Toon Specular , Rim Light
inline half StepFeatherToon(half Term,half maxTerm,half step,half feather)
{
return saturate((Term/maxTerm-step)/feather)*maxTerm;
return saturate((Term * saturate(rcp(maxTerm)) - step + feather) / feather) * maxTerm;
}


#endif
Loading

0 comments on commit 066da2c

Please sign in to comment.