Hello,
I have a game that I initially developed for Windows. I am now trying to port it to Android.
Pretty much nothing works. I’ve got the game to run, sort of, but none of the shaders behave as expected. However, now I’m encountering behavior which I think should be literally impossible so I am here to ask for help.
I have a texture which has a lot of green (0, 255, 0) color. My pixel shader is supposed to find these green parts and replace them with a certain color. This works great on Windows and allows me to easily re-color models.
float4 baseColor = tex2D(carTextureSampler, PSIn.TexCoords); if (baseColor.r <= 0.05 && baseColor.g >= 0.95 && baseColor.b <= 0.05) { baseColor = CarColor; }
The code samples the texture, checks if the color is close to neon green, and then replaces it with “CarColor” if so.
On Windows the behavior is as expected. On Android, ALL colors are replaced with CarColor. It’s as if the condition is always true no matter what.
Now take a look at this code:
float4 baseColor = tex2D(carTextureSampler, PSIn.TexCoords); if (baseColor.r == -0.05 && baseColor.g == 999999.95 && baseColor.b == -0.05) { baseColor = CarColor; baseColor = float4(0, 0, 1, 1); }
This condition is clearly impossible. I am checking if the channels have these impossible values, and if so, setting the color to blue (0, 0, 1) to debug. Somehow, all of the pixels are set to blue! This condition is still passing even though it should be impossible.
What is going on here? I don’t understand why my shaders aren’t working. I especially don’t understand how anything like this could possibly be happening.
Any help would be appreciated.