Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable shadow cookie support and fix sharp line in normal mapped shell materials #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Assets/Fur/Shaders/Shell/Lit.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Varyings
float4 positionCS : SV_POSITION;
float3 positionWS : TEXCOORD0;
float3 normalWS : TEXCOORD1;
float3 tangentWS : TEXCOORD2;
float4 tangentWS : TANGENT;
float2 uv : TEXCOORD4;
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 5);
float4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light
Expand Down Expand Up @@ -52,7 +52,7 @@ void AppendShellVertex(inout TriangleStream<Varyings> stream, Attributes input,
output.positionCS = TransformWorldToHClip(output.positionWS);
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
output.normalWS = normalInput.normalWS;
output.tangentWS = normalInput.tangentWS;
output.tangentWS = float4(normalInput.tangentWS, input.tangentOS.w);
output.layer = (float)index / _ShellAmount;

float3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
Expand Down Expand Up @@ -94,10 +94,10 @@ float4 frag(Varyings input) : SV_Target
float3 normalTS = UnpackNormalScale(
SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, furUv),
_NormalScale);
float3 bitangent = SafeNormalize(viewDirWS.y * cross(input.normalWS, input.tangentWS));
float3 bitangent = SafeNormalize(input.tangentWS.w * cross(input.normalWS, input.tangentWS));
float3 normalWS = SafeNormalize(TransformTangentToWorld(
normalTS,
float3x3(input.tangentWS, bitangent, input.normalWS)));
float3x3(input.tangentWS.xyz, bitangent, input.normalWS)));

SurfaceData surfaceData = (SurfaceData)0;
InitializeStandardLitSurfaceData(input.uv, surfaceData);
Expand Down
3 changes: 2 additions & 1 deletion Assets/Fur/Shaders/Shell/Lit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ SubShader
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION

#pragma multi_compile_fragment _ _LIGHT_COOKIES

// Unity のキーワード
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
Expand Down