Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AFatNiBBa opened this issue Apr 29, 2023 · 0 comments

Comments

@AFatNiBBa
Copy link

AFatNiBBa commented Apr 29, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant