Skip to content

Commit

Permalink
Filter background envmap
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Jan 10, 2025
1 parent 96d7fda commit f6bda07
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Binary file modified base/shaders/raytrace/raytrace_brute_forge_full.spirv
Binary file not shown.
Binary file modified base/shaders/raytrace/raytrace_brute_full.spirv
Binary file not shown.
18 changes: 17 additions & 1 deletion base/shaders/raytrace/src/raytrace_brute.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ void miss(inout RayPayload payload) {
float2 tex_coord = frac(equirect(WorldRayDirection(), constant_buffer.params.y));
uint2 size;
mytexture_env.GetDimensions(size.x, size.y);
float3 texenv = mytexture_env.Load(uint3(tex_coord * size, 0)).rgb * abs(constant_buffer.params.x);
uint2 itex = tex_coord * size;

#ifdef _FULL
// Use .Sample() instead..
itex = clamp(itex, uint2(0, 0), size - uint2(2, 2));
float2 f = frac(tex_coord * size);
float3 t00 = mytexture_env.Load(int3(itex, 0)).rgb;
float3 t10 = mytexture_env.Load(int3(itex + uint2(1, 0), 0)).rgb;
float3 t01 = mytexture_env.Load(int3(itex + uint2(0, 1), 0)).rgb;
float3 t11 = mytexture_env.Load(int3(itex + uint2(1, 1), 0)).rgb;
float3 texenv = lerp(lerp(t00, t10, f.x), lerp(t01, t11, f.x), f.y);
#else
float3 texenv = mytexture_env.Load(uint3(tex_coord * size, 0)).rgb;
#endif

texenv *= abs(constant_buffer.params.x);

payload.color = float4(payload.color.rgb * texenv.rgb, -1);
}

0 comments on commit f6bda07

Please sign in to comment.