2024-04-08 19:20:45 -04:00
|
|
|
#version 120
|
|
|
|
|
2024-04-11 12:04:33 -04:00
|
|
|
#define pixelSize 2 // [1 2 4 8 16]
|
|
|
|
#define vWarp 0 // psx vertex warp [0 1 2 4 8 16 32]
|
|
|
|
//#define tWarp // psx texture warp
|
|
|
|
|
2024-04-08 19:20:45 -04:00
|
|
|
varying vec2 texcoord;
|
|
|
|
varying vec4 color;
|
2024-04-09 22:34:45 -04:00
|
|
|
varying vec2 lmcoord;
|
2024-04-08 19:20:45 -04:00
|
|
|
|
|
|
|
uniform mat4 gbufferModelView, gbufferModelViewInverse;
|
|
|
|
uniform float viewWidth, viewHeight;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
2024-04-09 22:34:45 -04:00
|
|
|
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
2024-04-08 19:20:45 -04:00
|
|
|
color = gl_Color;
|
|
|
|
|
2024-04-09 22:34:45 -04:00
|
|
|
#if vWarp > 0
|
|
|
|
float mod = pixelSize * vWarp;
|
|
|
|
vec2 screen = vec2(viewWidth / mod, viewHeight / mod);
|
2024-04-08 19:20:45 -04:00
|
|
|
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
|
2024-04-09 22:34:45 -04:00
|
|
|
vec2 nearest = round(position.xy / position.w * screen) / screen;
|
2024-04-08 19:20:45 -04:00
|
|
|
position.xy = nearest;
|
|
|
|
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
|
|
|
|
#else
|
|
|
|
gl_Position = ftransform();
|
|
|
|
#endif
|
2024-04-11 12:04:33 -04:00
|
|
|
|
|
|
|
#ifdef tWarp
|
2024-04-11 12:08:47 -04:00
|
|
|
gl_Position /= abs(gl_Position.w);
|
2024-04-11 12:04:33 -04:00
|
|
|
#endif
|
2024-04-08 19:20:45 -04:00
|
|
|
}
|
|
|
|
|