Skip to content

Commit f6bda07

Browse files
committed
Filter background envmap
1 parent 96d7fda commit f6bda07

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed
952 Bytes
Binary file not shown.
952 Bytes
Binary file not shown.

base/shaders/raytrace/src/raytrace_brute.hlsl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,22 @@ void miss(inout RayPayload payload) {
301301
float2 tex_coord = frac(equirect(WorldRayDirection(), constant_buffer.params.y));
302302
uint2 size;
303303
mytexture_env.GetDimensions(size.x, size.y);
304-
float3 texenv = mytexture_env.Load(uint3(tex_coord * size, 0)).rgb * abs(constant_buffer.params.x);
304+
uint2 itex = tex_coord * size;
305+
306+
#ifdef _FULL
307+
// Use .Sample() instead..
308+
itex = clamp(itex, uint2(0, 0), size - uint2(2, 2));
309+
float2 f = frac(tex_coord * size);
310+
float3 t00 = mytexture_env.Load(int3(itex, 0)).rgb;
311+
float3 t10 = mytexture_env.Load(int3(itex + uint2(1, 0), 0)).rgb;
312+
float3 t01 = mytexture_env.Load(int3(itex + uint2(0, 1), 0)).rgb;
313+
float3 t11 = mytexture_env.Load(int3(itex + uint2(1, 1), 0)).rgb;
314+
float3 texenv = lerp(lerp(t00, t10, f.x), lerp(t01, t11, f.x), f.y);
315+
#else
316+
float3 texenv = mytexture_env.Load(uint3(tex_coord * size, 0)).rgb;
317+
#endif
318+
319+
texenv *= abs(constant_buffer.params.x);
320+
305321
payload.color = float4(payload.color.rgb * texenv.rgb, -1);
306322
}

0 commit comments

Comments
 (0)