From c46fc08988814329b1c6a72ac7c9fa2e62363a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Mon, 9 May 2022 11:14:28 +0200 Subject: [PATCH] planar reflection shader fix --- WickedEngine/shaders/objectHF.hlsli | 2 +- WickedEngine/shaders/surfaceHF.hlsli | 3 +++ WickedEngine/shaders/visibility_shadeCS.hlsl | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WickedEngine/shaders/objectHF.hlsli b/WickedEngine/shaders/objectHF.hlsli index d17191c66..d744dcb3a 100644 --- a/WickedEngine/shaders/objectHF.hlsli +++ b/WickedEngine/shaders/objectHF.hlsli @@ -350,7 +350,7 @@ inline float3 PlanarReflection(in Surface surface, in float2 bumpColor) float4 reflectionUV = mul(GetCamera().reflection_view_projection, float4(surface.P, 1)); reflectionUV.xy /= reflectionUV.w; reflectionUV.xy = clipspace_to_uv(reflectionUV.xy); - return bindless_textures[GetCamera().texture_reflection_index].SampleLevel(sampler_linear_clamp, reflectionUV.xy + bumpColor * GetMaterial().normalMapStrength, 0).rgb; + return bindless_textures[GetCamera().texture_reflection_index].SampleLevel(sampler_linear_clamp, reflectionUV.xy + bumpColor, 0).rgb; } return 0; } diff --git a/WickedEngine/shaders/surfaceHF.hlsli b/WickedEngine/shaders/surfaceHF.hlsli index c528d6160..c633210e2 100644 --- a/WickedEngine/shaders/surfaceHF.hlsli +++ b/WickedEngine/shaders/surfaceHF.hlsli @@ -70,6 +70,7 @@ struct Surface RayCone raycone; float hit_depth; float3 gi; + float3 bumpColor; // These will be computed when calling Update(): float roughnessBRDF; // roughness input for BRDF functions @@ -110,6 +111,7 @@ struct Surface facenormal = 0; flags = 0; gi = 0; + bumpColor = 0; sheen.color = 0; sheen.roughness = 0; @@ -372,6 +374,7 @@ struct Surface const float3 normalMap = float3(tex.SampleLevel(sam, uv, lod).rg, 1) * 2 - 1; #endif // SURFACE_LOAD_QUAD_DERIVATIVES N = normalize(lerp(N, mul(normalMap, TBN), material.normalMapStrength)); + bumpColor = normalMap * material.normalMapStrength; } #ifdef ANISOTROPIC diff --git a/WickedEngine/shaders/visibility_shadeCS.hlsl b/WickedEngine/shaders/visibility_shadeCS.hlsl index fe162b5a4..9afde7651 100644 --- a/WickedEngine/shaders/visibility_shadeCS.hlsl +++ b/WickedEngine/shaders/visibility_shadeCS.hlsl @@ -59,7 +59,7 @@ void main(uint DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint #ifdef PLANARREFLECTION - lighting.indirect.specular += PlanarReflection(surface, surface.N.xz) * surface.F; + lighting.indirect.specular += PlanarReflection(surface, surface.bumpColor.rg) * surface.F; #endif TiledLighting(surface, lighting);