Compare commits

..

No commits in common. "6339df4ed59092c4ff23a4a5e70f4a9d81b392d5" and "3c272fcba53a59c0af2396a78772b49fecae3272" have entirely different histories.

7 changed files with 26 additions and 50 deletions

View file

@ -1,4 +1,8 @@
#version 120 #version 120
#include "/module/empty.vert" varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
}

View file

@ -1,4 +1,15 @@
#version 120 #version 120
#include "/module/empty.frag" varying vec2 texcoord;
varying vec4 color;
varying vec2 lmcoord;
uniform sampler2D texture;
uniform sampler2D lightmap;
void main() {
vec4 final = texture2D(texture, texcoord) * color;
final *= texture2D(lightmap, lmcoord);
gl_FragData[0] = final;
}

View file

@ -1,6 +1,8 @@
#version 120 #version 120
#define pixelSize 2 // [1 2 4 8 16] #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
varying vec2 texcoord; varying vec2 texcoord;
varying vec4 color; varying vec4 color;
@ -9,22 +11,24 @@ varying vec2 lmcoord;
uniform mat4 gbufferModelView, gbufferModelViewInverse; uniform mat4 gbufferModelView, gbufferModelViewInverse;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
#include "/module/vertex_warp.vert"
#include "/module/texture_warp.vert"
void main() { void main() {
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
color = gl_Color; color = gl_Color;
#if vWarp > 0 #if vWarp > 0
vertex_warp(); float mod = pixelSize * vWarp;
vec2 screen = vec2(viewWidth / mod, viewHeight / mod);
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vec2 nearest = round(position.xy / position.w * screen) / screen;
position.xy = nearest;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#else #else
gl_Position = ftransform(); gl_Position = ftransform();
#endif #endif
#ifdef tWarp #ifdef tWarp
texture_warp(); gl_Position /= abs(gl_Position.w);
#endif #endif
} }

View file

@ -1,15 +0,0 @@
// "empty" fragment shader
varying vec2 texcoord;
varying vec4 color;
varying vec2 lmcoord;
uniform sampler2D texture;
uniform sampler2D lightmap;
void main() {
vec4 final = texture2D(texture, texcoord) * color;
final *= texture2D(lightmap, lmcoord);
gl_FragData[0] = final;
}

View file

@ -1,9 +0,0 @@
// "empty" vertex shader
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
}

View file

@ -1,7 +0,0 @@
//#define tWarp // psx texture warp
void texture_warp() {
gl_Position /= abs(gl_Position.w);
}

View file

@ -1,12 +0,0 @@
#define vWarp 0 // psx vertex warp [0 1 2 4 8 16 32]
vec4 vertex_warp() {
float mod = pixelSize * vWarp;
vec2 screen = vec2(viewWidth / mod, viewHeight / mod);
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vec2 nearest = round(position.xy / position.w * screen) / screen;
position.xy = nearest;
return (gl_ProjectionMatrix * gbufferModelView * position);
}