Skip to content

Commit

Permalink
Moved textureSample for uniform control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
wayne-wu committed Oct 25, 2022
1 parent 716a55a commit 4ae9079
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/shaders/background.render.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ const ambientFactor = 0.2;
@fragment
fn fs_platform(in : VertexOutput) -> @location(0) vec4<f32> {

var albedo = vec4<f32>(1.0, 1.0, 1.0, 1.0);

if (scene.gridOn > 0.99){
albedo = textureSample(myTexture, mySampler, in.fragUV) + 1.4;
}

var visibility : f32 = 1.0;
if(scene.shadowOn > 0.99) {
visibility = 0.0;
Expand All @@ -80,11 +86,6 @@ fn fs_platform(in : VertexOutput) -> @location(0) vec4<f32> {
if (in.fragUV.x == -1.0){
return vec4<f32>(0.9, 0.9, 0.9, 1.0);
}
var albedo = vec4<f32>(1.0, 1.0, 1.0, 1.0);

if (scene.gridOn > 0.99){
albedo = textureSample(myTexture, mySampler, in.fragUV) + 1.4;
}

return 0.2*albedo + 0.8*vec4<f32>(lightingTerm * albedo.xyz, 1.0);;
}
Expand Down

0 comments on commit 4ae9079

Please sign in to comment.