Affine Texture Mapping in shader (PS1-style graphics)

OK I did it!

I followed this lovely tutorial. => WebGL 3D Perspective Correct Texture Mapping

All you have to do is divide the gl_Position by the w value.

varying vec2 _uv;
void main()
{
_uv = uv;
vec4 modelViewPosition = modelViewMatrix * vec4(position, 1.0);
gl_Position = projectionMatrix * modelViewPosition;
//this line makes all the difference
gl_Position /= gl_Position.w ;
}

I’m not super sure yet why this does the job…

EDIT: actually the tutorial explains why this is perfectly - lol i’m stupid. Good day everyone! :slight_smile: