diff --git a/package/Shaders/RunGrass.hlsl b/package/Shaders/RunGrass.hlsl index 847d8393e6..c0e82d5ca8 100644 --- a/package/Shaders/RunGrass.hlsl +++ b/package/Shaders/RunGrass.hlsl @@ -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) @@ -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) @@ -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(); @@ -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(); @@ -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; - diffuseColor += max(0, sss * subsurfaceColor * SharedData::grassLightingSettings.SubsurfaceScatteringAmount); directionalAmbientColor *= albedo; @@ -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)