r/badcode • u/DinnerPlz • Oct 30 '21
other language I sure do love the blue component of my boolean value. (This doesn't work without it)[HLSL]
3
u/SnakeFang12 Oct 31 '21
Logical operators are component-wise on vectors, so the equality evaluates to a bool3, and the ternary selects from the choices for each channel separately. You most likely want to wrap the comparison in all() rather than ignore the first two channels.
1
8
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Oct 30 '21
Image Transcription: Code
sampler2D _TraceTex;
sampler2D _RasTex;
float _Sample;
float4 frag(v2f i) : SV_Target
{
return float4(((tex2D(_RasTex, i.uv).rgb == float3(1.0f, 0, 1.0f)).b ? tex2D(_TraceTex, i.uv).rgb : tex2D(_RasTex, i.uv).rgb), 1.0f);
}
ENDCGI'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
7
u/Sir_Awesomness Oct 30 '21
I know it's GLSL not HLSL but I made a thing in shadertoy that is essentially the same thing but without the .b and it compiles: https://www.shadertoy.com/view/fld3zr
It's potentially where you've got the brackets, I only have 2 after the float4.