Skip to content

Commit

Permalink
ensure testPattern() always has a return condition
Browse files Browse the repository at this point in the history
The function is already guarded by a conditional in the shader, so we don't need to worry about pc_testpattern being <1.

This was tripping up D3D compilers via librashader.
  • Loading branch information
hizzlekizzle authored Sep 17, 2024
1 parent 5ab3c76 commit 33876b3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ntsc/shaders/patchy-ntsc/patchy-color.slang
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,7 @@ vec3 nesFullPalette(vec2 pos) {
}

vec3 testPattern(vec2 pos) {
if(global.pc_testpattern < 1.5) {
return smpteBars(pos);
} else if(global.pc_testpattern < 2.5) {
if(global.pc_testpattern < 2.5) {
return colorRamps(pos);
} else if(global.pc_testpattern < 3.5) {
return hsvSpectrum(pos, false);
Expand All @@ -1070,6 +1068,7 @@ vec3 testPattern(vec2 pos) {
} else if(global.pc_testpattern < 5.5) {
return nesFullPalette(pos);
}
else return smpteBars(pos);
}

// These two sRGB functions are taken from shaders_slang/include/colorspace-tools.h
Expand Down

2 comments on commit 33876b3

@Patchy68k
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to fix this yet, but this change accidentally caused the smpteBars pattern to get replaced with the colorRamps pattern. What you should've done instead is change the final "else if(global.pc_testpattern < 5.5)" to just "else".

Regardless, the patchy-color shader is outdated. When I get some spare time soon, I'm going to be updating both this and patchy-ntsc, and I'll try harder to keep the code reasonably clean and version-controlled so that we don't keep having problems like this.

@hizzlekizzle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, thanks

Please sign in to comment.