added vertex warp shader and general cleanup

This commit is contained in:
Valerie Wolfe 2024-04-08 19:20:45 -04:00
parent 1d3eca7d6b
commit bb003d49af
8 changed files with 86 additions and 6 deletions

View file

@ -117,7 +117,6 @@ void main() {
newcoord = (floor(newcoord * view) + offset) / view;
#endif
vec3 color = texture2D(gcolor, newcoord).rgb;
//gl_FragData[0] = vec4(vec3(color), 1.0);
float mask;
//vec3 ogRGB = texture2D(gcolor, texcoord).rgb;

View file

@ -0,0 +1,12 @@
#version 120
varying vec2 texcoord;
varying vec4 color;
uniform sampler2D texture;
void main() {
vec4 final = texture2D(texture, texcoord) * color;
gl_FragData[0] = final;
}

View file

@ -0,0 +1,28 @@
#version 120
varying vec2 texcoord;
varying vec4 color;
uniform mat4 gbufferModelView, gbufferModelViewInverse;
uniform float viewWidth, viewHeight;
#define pixelSize 2 // [1 2 4 8 16]
//#define vWarp // whether or not to warp vertices
void main() {
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
#ifdef vWarp
vec2 screen = vec2(viewWidth / pixelSize, viewHeight / pixelSize);
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vec2 nearest = round(position.xy * screen) / screen;
position.xy = nearest;
//vec3 nearest = round(position.xyz * 100) / 100;
//position.xyz = nearest;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#else
gl_Position = ftransform();
#endif
}

View file

@ -0,0 +1,12 @@
#version 120
varying vec2 texcoord;
varying vec4 color;
uniform sampler2D texture;
void main() {
vec4 final = texture2D(texture, texcoord) * color;
gl_FragData[0] = final;
}

View file

@ -0,0 +1,28 @@
#version 120
varying vec2 texcoord;
varying vec4 color;
uniform mat4 gbufferModelView, gbufferModelViewInverse;
uniform float viewWidth, viewHeight;
#define pixelSize 2 // [1 2 4 8 16]
//#define vWarp // whether or not to warp vertices
void main() {
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
#ifdef vWarp
vec2 screen = vec2(viewWidth / pixelSize, viewHeight / pixelSize);
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vec2 nearest = round(position.xy * screen) / screen;
position.xy = nearest;
//vec3 nearest = round(position.xyz * 100) / 100;
//position.xyz = nearest;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#else
gl_Position = ftransform();
#endif
}

View file

@ -15,5 +15,6 @@ option.valSteps=Value Depth
screen.PSX=PSX
option.vWarp=Vertex Warping
option.tWarp=Texture Warping
option.tWarp=Affine Textures
option.tWarp.comment=Emulates affine texture mapping responsible for warping textures on the PSX

View file

@ -1,7 +1,7 @@
sliders=pixelSize hueSteps satSteps valSteps rgbSteps
screen=pixelSize [COLOR] [PSX]
screen=pixelSize <empty> [COLOR] [PSX]
screen.COLOR=RGB rgbSteps pixelSize hueSteps satSteps valSteps
screen.PSX=<empty>
screen.COLOR=RGB rgbSteps hueSteps satSteps valSteps
screen.PSX=vWarp