dfranx/SHADERed

Changing the "y" of a "float2" inside of a struct changes the "x" too (2D HLSL)

AFatNiBBa opened this issue · 0 comments

When writing this code in the Lite version i get the following output:

uniform float2 iResolution;

struct Box {
    float2 location;
};

float circle(float r, float2 pixel) {
    return float(length(pixel) < r);
}

float4 main(float4 pixel: SV_POSITION): SV_TARGET {
    float2 uv = pixel.xy / iResolution - .5;

    Box box;
    box.location.y = .25; // ← LINE THAT DOES THE SHIFTING
    float g = circle(.125, uv - box.location);

    return float4(circle(.01, uv), g, 0, 1);
}


But when running the same code in the non web version i get this result:

When I do this:

box.location.y = .25;

It is like if I was also doing this:

box.location.x = .25;

If i set the x back to 0 manually, it works again.

If i write the same shader but I set the x instead of the y it works perfectly!

I also noticed that the pixel inspector shows two colors for the same pixel:


The fact that two colors are shown makes me think it's not a bug, am I missing something?