A
AlexM
Guest
Hi developer fellows!
I am looking for a way to get Texture Coordinates in the frag shader that are based on Pixels and not on 0..1 values.
For the Scenario:
I am using the vertex shader to create two triangles and then draw a sprite in the frag shader. I now simply want the first 10 Pixels along the x-axis to be treated in another way then the rest.
It is easily done with UV Coordinates ranging from 0..1, but my problem is that I need the exact pixel number starting from the beginning of the sprite.
something like:
My next idea was to calculate it using: length * v_vTexcoord.x = Pixel Number. But when the UV Coord are not 0..1 as it is mostly the case, this also fails.
I tried gl_FragCoord but that seems to related to viewport size and not to the texture.
Is there maybe and hidden gl_ variable the would give the pixel coords instead of UV coords?
Or is it maybe possible to get the min and max UV value of the texture coords into the frag shader?
Thank you!
Best Regards
Alex
I am looking for a way to get Texture Coordinates in the frag shader that are based on Pixels and not on 0..1 values.
For the Scenario:
I am using the vertex shader to create two triangles and then draw a sprite in the frag shader. I now simply want the first 10 Pixels along the x-axis to be treated in another way then the rest.
It is easily done with UV Coordinates ranging from 0..1, but my problem is that I need the exact pixel number starting from the beginning of the sprite.
something like:
Code:
if (v_vPixelCoord.x >= 10.0)
{
// do shader stuff
}
I tried gl_FragCoord but that seems to related to viewport size and not to the texture.
Is there maybe and hidden gl_ variable the would give the pixel coords instead of UV coords?
Or is it maybe possible to get the min and max UV value of the texture coords into the frag shader?
Thank you!
Best Regards
Alex