diff --git a/shaders/gbuffers_entities.fsh b/shaders/gbuffers_entities.fsh index 292eef0..1bf926d 100644 --- a/shaders/gbuffers_entities.fsh +++ b/shaders/gbuffers_entities.fsh @@ -2,11 +2,14 @@ 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; } diff --git a/shaders/gbuffers_entities.vsh b/shaders/gbuffers_entities.vsh index 465bec4..ed1ccfc 100644 --- a/shaders/gbuffers_entities.vsh +++ b/shaders/gbuffers_entities.vsh @@ -2,24 +2,25 @@ varying vec2 texcoord; varying vec4 color; +varying vec2 lmcoord; uniform mat4 gbufferModelView, gbufferModelViewInverse; uniform float viewWidth, viewHeight; #define pixelSize 2 // [1 2 4 8 16] -//#define vWarp // whether or not to warp vertices +#define vWarp 0 // psx vertex warp [0 1 2 4 8 16 32] void main() { texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; + lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; color = gl_Color; #ifdef vWarp - vec2 screen = vec2(viewWidth / pixelSize, viewHeight / pixelSize); + float mod = pixelSize * vWarp; + vec2 screen = vec2(viewWidth / mod, viewHeight / mod); vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex; - vec2 nearest = round(position.xy * screen) / screen; + vec2 nearest = round(position.xy / position.w * 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(); diff --git a/shaders/gbuffers_terrain.fsh b/shaders/gbuffers_terrain.fsh index 292eef0..1bf926d 100644 --- a/shaders/gbuffers_terrain.fsh +++ b/shaders/gbuffers_terrain.fsh @@ -2,11 +2,14 @@ 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; } diff --git a/shaders/gbuffers_terrain.vsh b/shaders/gbuffers_terrain.vsh index 465bec4..0129250 100644 --- a/shaders/gbuffers_terrain.vsh +++ b/shaders/gbuffers_terrain.vsh @@ -2,24 +2,25 @@ varying vec2 texcoord; varying vec4 color; +varying vec2 lmcoord; uniform mat4 gbufferModelView, gbufferModelViewInverse; uniform float viewWidth, viewHeight; #define pixelSize 2 // [1 2 4 8 16] -//#define vWarp // whether or not to warp vertices +#define vWarp 0 // psx vertex warp [0 1 2 4 8 16 32] void main() { texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; + lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; color = gl_Color; - #ifdef vWarp - vec2 screen = vec2(viewWidth / pixelSize, viewHeight / pixelSize); + #if vWarp > 0 + float mod = pixelSize * vWarp; + vec2 screen = vec2(viewWidth / mod, viewHeight / mod); vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex; - vec2 nearest = round(position.xy * screen) / screen; + vec2 nearest = round(position.xy / position.w * 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(); diff --git a/shaders/lang/en_US.lang b/shaders/lang/en_US.lang index ad61535..1f990ef 100644 --- a/shaders/lang/en_US.lang +++ b/shaders/lang/en_US.lang @@ -19,6 +19,13 @@ option.valSteps=Value Depth screen.PSX=PSX option.vWarp=Vertex Warping option.vWarp.comment=Emulates screen-space vertex snapping responsible for vertex wobble on the PSX +value.vWarp.0=Off +value.vWarp.1=Minimal (1x) +value.vWarp.2=Low (2x) +value.vWarp.4=Medium (4x) +value.vWarp.8=High (8x) +value.vWarp.16=Extreme (16x) +value.vWarp.32=Silly (32x) option.tWarp=Affine Textures option.tWarp.comment=Emulates affine texture mapping responsible for warping textures on the PSX diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 52eb3d6..97ec62a 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -1,4 +1,4 @@ -sliders=pixelSize hueSteps satSteps valSteps rgbSteps +sliders=pixelSize hueSteps satSteps valSteps rgbSteps vWarp screen=pixelSize [COLOR] [PSX]