From a557986f2320d4210dd8516ca7abb9c24336f46d Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Sat, 17 Aug 2024 16:00:59 +0100 Subject: [PATCH] refactor: rename sRGB2Lin to SkyrimGamma2Lin, etc. --- .../DynamicCubemaps/DynamicCubemaps.hlsli | 4 +-- .../DynamicCubemaps/InferCubemapCS.hlsl | 6 ++-- .../DynamicCubemaps/SpecularIrradianceCS.hlsl | 8 ++--- .../DynamicCubemaps/UpdateCubemapCS.hlsl | 4 +-- .../ScreenSpaceGI/radianceDisocc.cs.hlsl | 2 +- .../SubsurfaceScattering/SeparableSSS.hlsli | 4 +-- .../SubsurfaceScattering/SeparableSSSCS.hlsl | 2 +- .../WetnessEffects/WetnessEffects.hlsli | 2 +- package/Shaders/AmbientCompositeCS.hlsl | 14 ++++----- package/Shaders/Common/Color.hlsli | 4 +-- package/Shaders/DeferredCompositeCS.hlsl | 16 +++++----- package/Shaders/Lighting.hlsl | 30 +++++++++---------- package/Shaders/RunGrass.hlsl | 10 +++---- 13 files changed, 53 insertions(+), 53 deletions(-) diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli index 7db9c0671..2fcd9de0f 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli @@ -25,7 +25,7 @@ float3 GetDynamicCubemapSpecularIrradiance(float2 uv, float3 N, float3 VN, float float3 specularIrradiance = specularTexture.SampleLevel(SampColorSampler, R, level).xyz; specularIrradiance *= horizon; - specularIrradiance = sRGB2Lin(specularIrradiance); + specularIrradiance = SkyrimGamma2Lin(specularIrradiance); return specularIrradiance; } @@ -53,7 +53,7 @@ float3 GetDynamicCubemap(float2 uv, float3 N, float3 VN, float3 V, float roughne return horizon * ((F0 + S) * specularBRDF.x + specularBRDF.y); # else float3 specularIrradiance = specularTexture.SampleLevel(SampColorSampler, R, level).xyz; - specularIrradiance = sRGB2Lin(specularIrradiance); + specularIrradiance = SkyrimGamma2Lin(specularIrradiance); return specularIrradiance * ((F0 + S) * specularBRDF.x + specularBRDF.y); # endif diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl index 0fdb04157..548fc54e0 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl @@ -90,11 +90,11 @@ float3 GetSamplingVector(uint3 ThreadID, in RWTexture2DArray OutputTextu } #if defined(REFLECTIONS) - color.rgb = lerp(color.rgb, sRGB2Lin(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0)), saturate(mipLevel / 8.0)); + color.rgb = lerp(color.rgb, SkyrimGamma2Lin(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0)), saturate(mipLevel / 8.0)); #else - color.rgb = lerp(color.rgb, color.rgb * sRGB2Lin(DefaultCubemap.SampleLevel(LinearSampler, uv, 0).x) * 2, saturate(mipLevel / 8.0)); + color.rgb = lerp(color.rgb, color.rgb * SkyrimGamma2Lin(DefaultCubemap.SampleLevel(LinearSampler, uv, 0).x) * 2, saturate(mipLevel / 8.0)); #endif - color.rgb = Lin2sRGB(color.rgb); + color.rgb = Lin2SkyrimGamma(color.rgb); EnvInferredTexture[ThreadID] = max(0, color); } diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/SpecularIrradianceCS.hlsl b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/SpecularIrradianceCS.hlsl index 07a68b2b2..6b6bf084d 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/SpecularIrradianceCS.hlsl +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/SpecularIrradianceCS.hlsl @@ -118,12 +118,12 @@ float3 tangentToWorld(const float3 v, const float3 N, const float3 S, const floa return S * v.x + T * v.y + N * v.z; } -float3 sRGB2Lin(float3 color) +float3 SkyrimGamma2Lin(float3 color) { return color > 0.04045 ? pow(color / 1.055 + 0.055 / 1.055, 2.4) : color / 12.92; } -float3 Lin2sRGB(float3 color) +float3 Lin2SkyrimGamma(float3 color) { return color > 0.0031308 ? 1.055 * pow(color, 1.0 / 2.4) - 0.055 : 12.92 * color; } @@ -181,11 +181,11 @@ float3 Lin2sRGB(float3 color) // Mip level to sample from. float mipLevel = max(0.5 * log2(ws / wt) + 1.0, 0.0); - color += sRGB2Lin(inputTexture.SampleLevel(linear_wrap_sampler, Li, mipLevel).rgb) * cosLi; + color += SkyrimGamma2Lin(inputTexture.SampleLevel(linear_wrap_sampler, Li, mipLevel).rgb) * cosLi; weight += cosLi; } } color /= weight; - outputTexture[ThreadID] = float4(Lin2sRGB(color), 1.0); + outputTexture[ThreadID] = float4(Lin2SkyrimGamma(color), 1.0); } diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/UpdateCubemapCS.hlsl b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/UpdateCubemapCS.hlsl index e47cf9e78..2d945c42d 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/UpdateCubemapCS.hlsl +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/UpdateCubemapCS.hlsl @@ -59,7 +59,7 @@ cbuffer UpdateData : register(b1) bool IsSaturated(float value) { return value == saturate(value); } bool IsSaturated(float2 value) { return IsSaturated(value.x) && IsSaturated(value.y); } -float3 sRGB2Lin(float3 color) +float3 SkyrimGamma2Lin(float3 color) { return color > 0.04045 ? pow(color / 1.055 + 0.055 / 1.055, 2.4) : color / 12.92; } @@ -172,7 +172,7 @@ float smoothbumpstep(float edge0, float edge1, float x) if (linearDepth > 16.5) { // Ignore objects which are too close float3 color = ColorTexture.SampleLevel(LinearSampler, uv, 0); - float4 output = float4(sRGB2Lin(color), 1.0); + float4 output = float4(SkyrimGamma2Lin(color), 1.0); float lerpFactor = 1.0 / 64.0; half4 positionCS = half4(2 * half2(uv.x, -uv.y + 1) - 1, depth, 1); diff --git a/features/Screen Space GI/Shaders/ScreenSpaceGI/radianceDisocc.cs.hlsl b/features/Screen Space GI/Shaders/ScreenSpaceGI/radianceDisocc.cs.hlsl index e415741c9..429a3b5c7 100644 --- a/features/Screen Space GI/Shaders/ScreenSpaceGI/radianceDisocc.cs.hlsl +++ b/features/Screen Space GI/Shaders/ScreenSpaceGI/radianceDisocc.cs.hlsl @@ -131,7 +131,7 @@ void readHistory( half3 radiance = 0; #ifdef GI - radiance = sRGB2Lin(FULLRES_LOAD(srcDiffuse, pixCoord, uv * frameScale, samplerLinearClamp).rgb * GIStrength); + radiance = SkyrimGamma2Lin(FULLRES_LOAD(srcDiffuse, pixCoord, uv * frameScale, samplerLinearClamp).rgb * GIStrength); # ifdef GI_BOUNCE radiance += prev_ambient.rgb * GIBounceFade; # endif diff --git a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli index 4df504257..1cd9d1085 100644 --- a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli +++ b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli @@ -100,7 +100,7 @@ float4 SSSSBlurCS( float4 colorM = ColorTexture[DTid.xy]; #if defined(HORIZONTAL) - colorM.rgb = sRGB2Lin(colorM.rgb); + colorM.rgb = SkyrimGamma2Lin(colorM.rgb); #endif if (sssAmount == 0) @@ -157,7 +157,7 @@ float4 SSSSBlurCS( float3 color = ColorTexture[coords].rgb; #if defined(HORIZONTAL) - color.rgb = sRGB2Lin(color.rgb); + color.rgb = SkyrimGamma2Lin(color.rgb); #endif float depth = DepthTexture[coords].r; diff --git a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl index 71668c8ac..a0cfc1fc6 100644 --- a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl +++ b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl @@ -39,7 +39,7 @@ cbuffer PerFrameSSS : register(b1) bool humanProfile = MaskTexture[DTid.xy].y == sssAmount; float4 color = SSSSBlurCS(DTid.xy, texCoord, float2(0.0, 1.0), sssAmount, humanProfile); - color.rgb = Lin2sRGB(color.rgb); + color.rgb = Lin2SkyrimGamma(color.rgb); SSSRW[DTid.xy] = float4(color.rgb, 1.0); #endif diff --git a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli index 5bfe30074..854df2d30 100644 --- a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli +++ b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli @@ -144,7 +144,7 @@ float3 GetWetnessAmbientSpecular(float2 uv, float3 N, float3 VN, float3 V, float float3 specularIrradiance = 1.0; # else float level = roughness * 7.0; - float3 specularIrradiance = sRGB2Lin(specularTexture.SampleLevel(SampColorSampler, R, level)); + float3 specularIrradiance = SkyrimGamma2Lin(specularTexture.SampleLevel(SampColorSampler, R, level)); # endif #else float3 specularIrradiance = 1.0; diff --git a/package/Shaders/AmbientCompositeCS.hlsl b/package/Shaders/AmbientCompositeCS.hlsl index 946785500..057c08cd1 100644 --- a/package/Shaders/AmbientCompositeCS.hlsl +++ b/package/Shaders/AmbientCompositeCS.hlsl @@ -51,11 +51,11 @@ RWTexture2D DiffuseAmbientRW : register(u1); half3 directionalAmbientColor = mul(DirectionalAmbient, half4(normalWS, 1.0)); - half3 linAlbedo = sRGB2Lin(albedo); - half3 linDirectionalAmbientColor = sRGB2Lin(directionalAmbientColor); - half3 linDiffuseColor = sRGB2Lin(diffuseColor); + half3 linAlbedo = SkyrimGamma2Lin(albedo); + half3 linDirectionalAmbientColor = SkyrimGamma2Lin(directionalAmbientColor); + half3 linDiffuseColor = SkyrimGamma2Lin(diffuseColor); - half3 linAmbient = lerp(sRGB2Lin(albedo * directionalAmbientColor), linAlbedo * linDirectionalAmbientColor, pbrWeight); + half3 linAmbient = lerp(SkyrimGamma2Lin(albedo * directionalAmbientColor), linAlbedo * linDirectionalAmbientColor, pbrWeight); half visibility = 1.0; #if defined(SKYLIGHTING) @@ -90,10 +90,10 @@ RWTexture2D DiffuseAmbientRW : register(u1); #endif linAmbient *= visibility; - diffuseColor = Lin2sRGB(linDiffuseColor); - directionalAmbientColor = Lin2sRGB(linDirectionalAmbientColor * visibility); + diffuseColor = Lin2SkyrimGamma(linDiffuseColor); + directionalAmbientColor = Lin2SkyrimGamma(linDirectionalAmbientColor * visibility); - diffuseColor = lerp(diffuseColor + directionalAmbientColor * albedo, Lin2sRGB(linDiffuseColor + linAmbient), pbrWeight); + diffuseColor = lerp(diffuseColor + directionalAmbientColor * albedo, Lin2SkyrimGamma(linDiffuseColor + linAmbient), pbrWeight); MainRW[dispatchID.xy] = diffuseColor; }; \ No newline at end of file diff --git a/package/Shaders/Common/Color.hlsli b/package/Shaders/Common/Color.hlsli index 070aaeee7..f054cafe7 100644 --- a/package/Shaders/Common/Color.hlsli +++ b/package/Shaders/Common/Color.hlsli @@ -15,12 +15,12 @@ float RGBToLuminance2(float3 color) return dot(color, float3(0.299, 0.587, 0.114)); } -float3 sRGB2Lin(float3 color) +float3 SkyrimGamma2Lin(float3 color) { return pow(abs(color), 1.5); } -float3 Lin2sRGB(float3 color) +float3 Lin2SkyrimGamma(float3 color) { return pow(abs(color), 1.0 / 1.5); } \ No newline at end of file diff --git a/package/Shaders/DeferredCompositeCS.hlsl b/package/Shaders/DeferredCompositeCS.hlsl index 897f13635..ae3de1813 100644 --- a/package/Shaders/DeferredCompositeCS.hlsl +++ b/package/Shaders/DeferredCompositeCS.hlsl @@ -60,7 +60,7 @@ Texture2D SpecularSSGITexture : register(t10); half glossiness = normalGlossiness.z; - half3 color = lerp(diffuseColor + specularColor, Lin2sRGB(sRGB2Lin(diffuseColor) + sRGB2Lin(specularColor)), pbrWeight); + half3 color = lerp(diffuseColor + specularColor, Lin2SkyrimGamma(SkyrimGamma2Lin(diffuseColor) + SkyrimGamma2Lin(specularColor)), pbrWeight); #if defined(DYNAMIC_CUBEMAPS) @@ -73,7 +73,7 @@ Texture2D SpecularSSGITexture : register(t10); normalWS = lerp(normalWS, float3(0, 0, 1), wetnessMask); - color = sRGB2Lin(color); + color = SkyrimGamma2Lin(color); half depth = DepthTexture[dispatchID.xy]; @@ -89,12 +89,12 @@ Texture2D SpecularSSGITexture : register(t10); half roughness = 1.0 - glossiness; half level = roughness * 7.0; - half3 directionalAmbientColor = sRGB2Lin(mul(DirectionalAmbient, half4(R, 1.0))); + half3 directionalAmbientColor = SkyrimGamma2Lin(mul(DirectionalAmbient, half4(R, 1.0))); half3 finalIrradiance = 0; # if defined(INTERIOR) half3 specularIrradiance = EnvTexture.SampleLevel(LinearSampler, R, level).xyz; - specularIrradiance = sRGB2Lin(specularIrradiance); + specularIrradiance = SkyrimGamma2Lin(specularIrradiance); finalIrradiance += specularIrradiance; # elif defined(SKYLIGHTING) @@ -114,19 +114,19 @@ Texture2D SpecularSSGITexture : register(t10); if (skylightingSpecular < 1.0) { specularIrradiance = EnvTexture.SampleLevel(LinearSampler, R, level).xyz; - specularIrradiance = sRGB2Lin(specularIrradiance); + specularIrradiance = SkyrimGamma2Lin(specularIrradiance); } half3 specularIrradianceReflections = 1.0; if (skylightingSpecular > 0.0) { specularIrradianceReflections = EnvReflectionsTexture.SampleLevel(LinearSampler, R, level).xyz; - specularIrradianceReflections = sRGB2Lin(specularIrradianceReflections); + specularIrradianceReflections = SkyrimGamma2Lin(specularIrradianceReflections); } finalIrradiance = finalIrradiance * skylightingSpecular + lerp(specularIrradiance, specularIrradianceReflections, skylightingSpecular); # else half3 specularIrradianceReflections = EnvReflectionsTexture.SampleLevel(LinearSampler, R, level).xyz; - specularIrradianceReflections = sRGB2Lin(specularIrradianceReflections); + specularIrradianceReflections = SkyrimGamma2Lin(specularIrradianceReflections); finalIrradiance += specularIrradianceReflections; # endif @@ -138,7 +138,7 @@ Texture2D SpecularSSGITexture : register(t10); color += reflectance * finalIrradiance; - color = Lin2sRGB(color); + color = Lin2SkyrimGamma(color); } #endif diff --git a/package/Shaders/Lighting.hlsl b/package/Shaders/Lighting.hlsl index 393ea878d..80f7e061d 100644 --- a/package/Shaders/Lighting.hlsl +++ b/package/Shaders/Lighting.hlsl @@ -1614,7 +1614,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace float3 screenSpaceNormal = normalize(WorldToView(worldSpaceNormal, false, eyeIndex)); # if defined(TRUE_PBR) - baseColor.xyz = pow(baseColor.xyz, 1 / 1.5); + baseColor.xyz = Lin2SkyrimGamma(baseColor.xyz); PBR::SurfaceProperties pbrSurfaceProperties = PBR::InitSurfaceProperties(); @@ -1998,7 +1998,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # if defined(WETNESS_EFFECTS) if (waterRoughnessSpecular < 1.0) - wetnessSpecular += GetWetnessSpecular(wetnessNormal, normalizedDirLightDirectionWS, worldSpaceViewDirection, sRGB2Lin(dirLightColor * dirDetailShadow), waterRoughnessSpecular); + wetnessSpecular += GetWetnessSpecular(wetnessNormal, normalizedDirLightDirectionWS, worldSpaceViewDirection, SkyrimGamma2Lin(dirLightColor * dirDetailShadow), waterRoughnessSpecular); # endif # endif @@ -2207,7 +2207,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # if defined(WETNESS_EFFECTS) if (waterRoughnessSpecular < 1.0) - wetnessSpecular += GetWetnessSpecular(wetnessNormal, normalizedLightDirection, worldSpaceViewDirection, sRGB2Lin(lightColor), waterRoughnessSpecular); + wetnessSpecular += GetWetnessSpecular(wetnessNormal, normalizedLightDirection, worldSpaceViewDirection, SkyrimGamma2Lin(lightColor), waterRoughnessSpecular); # endif } # endif @@ -2261,11 +2261,11 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace float skylightingDiffuse = shFuncProductIntegral(skylightingSH, shEvaluateCosineLobe(skylightingSettings.DirectionalDiffuse ? worldSpaceNormal : float3(0, 0, 1))) / shPI; skylightingDiffuse = Skylighting::mixDiffuse(skylightingSettings, skylightingDiffuse); # if !defined(TRUE_PBR) - directionalAmbientColor = sRGB2Lin(directionalAmbientColor); + directionalAmbientColor = SkyrimGamma2Lin(directionalAmbientColor); # endif directionalAmbientColor *= skylightingDiffuse; # if !defined(TRUE_PBR) - directionalAmbientColor = Lin2sRGB(directionalAmbientColor); + directionalAmbientColor = Lin2SkyrimGamma(directionalAmbientColor); # endif # endif @@ -2296,7 +2296,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace dynamicCubemap = true; envColorBase = TexEnvSampler.SampleLevel(SampEnvSampler, float3(1.0, 0.0, 0.0), 0); if (envColorBase.a < 1.0) { - F0 = sRGB2Lin(envColorBase.rgb) + sRGB2Lin(baseColor.rgb); + F0 = SkyrimGamma2Lin(envColorBase.rgb) + SkyrimGamma2Lin(baseColor.rgb); envRoughness = envColorBase.a; } else { F0 = 1.0; @@ -2307,7 +2307,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # if defined(CREATOR) if (cubemapCreatorSettings.Enabled) { dynamicCubemap = true; - F0 = sRGB2Lin(cubemapCreatorSettings.CubemapColor.rgb) + sRGB2Lin(baseColor.xyz); + F0 = SkyrimGamma2Lin(cubemapCreatorSettings.CubemapColor.rgb) + SkyrimGamma2Lin(baseColor.xyz); envRoughness = cubemapCreatorSettings.CubemapColor.a; } # endif @@ -2316,7 +2316,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # if defined(EMAT) envRoughness = lerp(envRoughness, 1.0 - complexMaterialColor.y, (float)complexMaterial); envRoughness *= envRoughness; - F0 = lerp(F0, sRGB2Lin(complexSpecular), (float)complexMaterial); + F0 = lerp(F0, SkyrimGamma2Lin(complexSpecular), (float)complexMaterial); # endif envColor = GetDynamicCubemap(screenUV, worldSpaceNormal, worldSpaceVertexNormal, worldSpaceViewDirection, envRoughness, F0, diffuseColor, viewPosition.z) * envMask; @@ -2445,7 +2445,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # else diffuseColor = 1.0; # endif - specularColor = sRGB2Lin(specularColor); + specularColor = SkyrimGamma2Lin(specularColor); } # endif @@ -2462,7 +2462,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # endif # if defined(DYNAMIC_CUBEMAPS) if (dynamicCubemap) - specularColor = Lin2sRGB(specularColor); + specularColor = Lin2SkyrimGamma(specularColor); # endif # endif @@ -2475,7 +2475,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace color.xyz += specularColor; # endif - color.xyz = sRGB2Lin(color.xyz); + color.xyz = SkyrimGamma2Lin(color.xyz); # endif # if defined(WETNESS_EFFECTS) && !defined(TRUE_PBR) @@ -2486,7 +2486,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace color.xyz += specularColorPBR; # endif - color.xyz = Lin2sRGB(color.xyz); + color.xyz = Lin2SkyrimGamma(color.xyz); # if defined(LOD_LAND_BLEND) && defined(TRUE_PBR) { @@ -2497,7 +2497,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # if defined(DEFERRED) specularColorPBR = lerp(specularColorPBR, 0, lodLandBlendFactor); - indirectDiffuseLobeWeight = lerp(indirectDiffuseLobeWeight, sRGB2Lin(input.Color.xyz * lodLandColor * lodLandFadeFactor), lodLandBlendFactor); + indirectDiffuseLobeWeight = lerp(indirectDiffuseLobeWeight, SkyrimGamma2Lin(input.Color.xyz * lodLandColor * lodLandFadeFactor), lodLandBlendFactor); indirectSpecularLobeWeight = lerp(indirectSpecularLobeWeight, 0, lodLandBlendFactor); pbrGlossiness = lerp(pbrGlossiness, 0, lodLandBlendFactor); # endif @@ -2638,13 +2638,13 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace float3 outputSpecular = specularColor.xyz; # if defined(TRUE_PBR) - outputSpecular = Lin2sRGB(specularColorPBR.xyz); + outputSpecular = Lin2SkyrimGamma(specularColorPBR.xyz); # endif psout.Specular = float4(outputSpecular, psout.Diffuse.w); float3 outputAlbedo = baseColor.xyz * vertexColor; # if defined(TRUE_PBR) - outputAlbedo = Lin2sRGB(indirectDiffuseLobeWeight); + outputAlbedo = Lin2SkyrimGamma(indirectDiffuseLobeWeight); # endif psout.Albedo = float4(outputAlbedo, psout.Diffuse.w); diff --git a/package/Shaders/RunGrass.hlsl b/package/Shaders/RunGrass.hlsl index 24a1627f1..224ab0676 100644 --- a/package/Shaders/RunGrass.hlsl +++ b/package/Shaders/RunGrass.hlsl @@ -630,8 +630,8 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace diffuseColor.xyz += transmissionColor; specularColor.xyz += specularColorPBR; - specularColor.xyz = Lin2sRGB(specularColor.xyz); - diffuseColor.xyz = Lin2sRGB(diffuseColor.xyz); + specularColor.xyz = Lin2SkyrimGamma(specularColor.xyz); + diffuseColor.xyz = Lin2SkyrimGamma(diffuseColor.xyz); # else # if !defined(SSGI) @@ -648,9 +648,9 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace float skylighting = shFuncProductIntegral(skylightingSH, shEvaluateCosineLobe(skylightingSettings.DirectionalDiffuse ? normal : float3(0, 0, 1))) / shPI; skylighting = Skylighting::mixDiffuse(skylightingSettings, skylighting); - directionalAmbientColor = sRGB2Lin(directionalAmbientColor); + directionalAmbientColor = SkyrimGamma2Lin(directionalAmbientColor); directionalAmbientColor *= skylighting; - directionalAmbientColor = Lin2sRGB(directionalAmbientColor); + directionalAmbientColor = Lin2SkyrimGamma(directionalAmbientColor); # endif // SKYLIGHTING diffuseColor += directionalAmbientColor; @@ -681,7 +681,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace float3 normalVS = normalize(WorldToView(normal, false, eyeIndex)); # if defined(TRUE_PBR) - psout.Albedo = float4(Lin2sRGB(indirectDiffuseLobeWeight), 1); + psout.Albedo = float4(Lin2SkyrimGamma(indirectDiffuseLobeWeight), 1); psout.NormalGlossiness = float4(EncodeNormal(normalVS), 1 - pbrSurfaceProperties.Roughness, 1); psout.Reflectance = float4(indirectSpecularLobeWeight, 1); psout.Parameters = float4(0, 0, 1, 1);