Skip to content

Commit

Permalink
Visualize both albedo and normal maps at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelarius committed Mar 26, 2024
1 parent c72a96a commit 5c5236b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/pt/hybrid_renderer_debug_pass.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ fn vsMain(in: VertexInput) -> VertexOutput {

@fragment
fn fsMain(in: VertexOutput) -> @location(0) vec4f {
let n = textureSample(gbufferNormal, textureSampler, in.texCoord);
return vec4(vec3(0.5) * (n.xyz + vec3(1f)), 1.0);
// NOTE: textureSample can't be called from non-uniform control flow
// TODO: replace with textureLoad calls which can be called from non-uniform control flow and get rid of the sampler
let c = in.texCoord;
let a = textureSample(gbufferAlbedo, textureSampler, c);
let n = textureSample(gbufferNormal, textureSampler, c);
if (c.x < 0.5) {
return a;
} else {
return vec4(vec3(0.5) * (n.xyz + vec3(1f)), 1.0);
}
}
12 changes: 10 additions & 2 deletions src/pt/shader_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,16 @@ fn vsMain(in: VertexInput) -> VertexOutput {
@fragment
fn fsMain(in: VertexOutput) -> @location(0) vec4f {
let n = textureSample(gbufferNormal, textureSampler, in.texCoord);
return vec4(vec3(0.5) * (n.xyz + vec3(1f)), 1.0);
// NOTE: textureSample can't be called from non-uniform control flow
// TODO: replace with textureLoad calls which can be called from non-uniform control flow and get rid of the sampler
let c = in.texCoord;
let a = textureSample(gbufferAlbedo, textureSampler, c);
let n = textureSample(gbufferNormal, textureSampler, c);
if (c.x < 0.5) {
return a;
} else {
return vec4(vec3(0.5) * (n.xyz + vec3(1f)), 1.0);
}
}
)";

Expand Down

0 comments on commit 5c5236b

Please sign in to comment.