Skip to content
Merged
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
22 changes: 7 additions & 15 deletions package/Shaders/RunGrass.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,10 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
float screenNoise = Random::InterleavedGradientNoise(input.HPosition.xy, SharedData::FrameCount);

// Swaps direction of the backfaces otherwise they seem to get lit from the wrong direction.
if (!(Permutation::ExtraShaderDescriptor & Permutation::ExtraFlags::GrassSphereNormal)) {
if (!(Permutation::ExtraShaderDescriptor & Permutation::ExtraFlags::GrassSphereNormal))
if (!frontFace)
normal = -normal;

normal.z = max(0.0, normal.z);
normal = normalize(float3(normal.xy, max(0, normal.z)));
}

float3x3 tbn = 0;

# if !defined(TRUE_PBR)
Expand Down Expand Up @@ -631,7 +627,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
lightsDiffuseColor += dirLightColor * dirDetailedShadow * saturate(dirLightAngle) * Color::VanillaNormalization();
}

float3 vertexColor = input.VertexColor.xyz;
float3 vertexColor = Color::ColorToLinear(input.VertexColor.xyz);

# if defined(SKYLIGHTING)
# if defined(VR)
Expand All @@ -643,10 +639,9 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
float skylightingDiffuse = Skylighting::GetVertexSkylightingDiffuse(positionMSSkylight, normal, vertexAO);
# endif // SKYLIGHTING

float3 albedo = max(0, baseColor.xyz * Color::ColorToLinear(vertexColor));
float3 albedo = baseColor.xyz * vertexColor;

float3 subsurfaceColor = lerp(dot(albedo, 1.0 / 3.0), albedo, 2.0) * saturate(input.VertexNormal.w * 10.0);
float3 sss = dirLightColor * dirDetailedShadow * saturate(-dirLightAngle) * Color::VanillaNormalization();
float3 subsurfaceColor = dirLightColor * dirDetailedShadow * saturate(-dirLightAngle) * Color::VanillaNormalization();

if (complex)
lightsSpecularColor += dirDetailedShadow * GrassLighting::GetLightSpecularInput(SharedData::DirLightDirection.xyz, viewDirection, normal, dirLightColor, SharedData::grassLightingSettings.Glossiness) * Color::VanillaNormalization();
Expand Down Expand Up @@ -715,7 +710,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
lightDiffuseColor = lightColor * saturate(lightAngle);
}

sss += lightColor * saturate(-lightAngle);
subsurfaceColor += lightColor * saturate(-lightAngle) * Color::VanillaNormalization();

lightsDiffuseColor += lightDiffuseColor * Color::VanillaNormalization();

Expand Down Expand Up @@ -752,9 +747,8 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
# endif

diffuseColor += directionalAmbientColor;

diffuseColor += subsurfaceColor * albedo * SharedData::grassLightingSettings.SubsurfaceScatteringAmount;
diffuseColor *= albedo;
Comment thread
doodlum marked this conversation as resolved.
diffuseColor += max(0, sss * subsurfaceColor * SharedData::grassLightingSettings.SubsurfaceScatteringAmount);

directionalAmbientColor *= albedo;

Expand Down Expand Up @@ -902,9 +896,7 @@ PS_OUTPUT main(PS_INPUT input)
float3 ddy = ddy_coarse(input.WorldPosition);
float3 normal = -normalize(cross(ddx, ddy));

normal = normalize(float3(normal.xy, max(0, normal.z)));

float3 vertexColor = input.VertexColor.xyz;
float3 vertexColor = Color::ColorToLinear(input.VertexColor.xyz);

# if defined(SKYLIGHTING)
# if defined(VR)
Expand Down
Loading