Skip to content

Commit

Permalink
fix a2c for undefined behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
z3y committed Jan 5, 2024
1 parent 61246e1 commit a76a59c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions ShaderLibrary/ForwardLighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace CustomLighting
void ApplyAlphaClip(inout SurfaceDescription surfaceDescription)
{
#if defined(_ALPHATEST_ON) && defined(ALPHATOCOVERAGE_ON)
clip(surfaceDescription.Alpha - 0.2);
surfaceDescription.Alpha = (surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold) / max(fwidth(surfaceDescription.Alpha), surfaceDescription.AlphaClipSharpness) + 0.5f;
#endif

Expand Down
5 changes: 5 additions & 0 deletions Shaders/Lit Crossfade.litshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "Packages/com.z3y.shaders/Shaders/Lit.litshader"

DEFINES_START
#pragma multi_compile LOD_FADE_CROSSFADE
DEFINES_END
21 changes: 21 additions & 0 deletions Shaders/Lit Crossfade.litshader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Shaders/Lit/ShaderLibrary/Common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ float3 ditherNoiseFuncHigh(float2 p)
uniform half _CutoutSharpness;
void AACutout(inout half alpha, half cutoff)
{
clip(alpha - 0.2);
alpha = (alpha - cutoff) / max(fwidth(alpha), _CutoutSharpness) + 0.5;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.z3y.shaders",
"description": "A Standard Shader and Surface Shaders replacement for Unity for Built-In pipeline and forward rendering (VRChat)",
"version": "3.2.12",
"version": "3.2.13",
"unity": "2019.4",
"displayName": "z3y - Shaders",
"hideInEditor": false,
Expand Down

0 comments on commit a76a59c

Please sign in to comment.