OpenGL: Add texSize uniform
Jeffrey Pfau jeffrey@endrift.com
Wed, 25 May 2016 21:25:09 -0700
7 files changed,
15 insertions(+),
7 deletions(-)
M
CHANGES
→
CHANGES
@@ -43,6 +43,7 @@ - Libretro: Disable logging game errors, BIOS calls and stubs in release builds
- ARM7: Support forcing Thumb mode via MSR - ARM7: Flush prefetch cache when loading CPSR via MSR - Qt: Canonicalize file paths when loading games + - OpenGL: Add texSize uniform 0.4.0: (2016-02-02) Features:
M
res/shaders/agb001.shader/agb001.fs
→
res/shaders/agb001.shader/agb001.fs
@@ -1,5 +1,6 @@
varying vec2 texCoord; uniform sampler2D tex; +uniform vec2 texSize; void main() { vec4 color = texture2D(tex, texCoord);@@ -14,8 +15,8 @@ arrayY[1] = vec3(1.0, 1.0, 1.0);
arrayY[2] = vec3(1.0, 1.0, 1.0); arrayY[3] = vec3(0.8, 0.8, 0.8); color.rgb = pow(color.rgb * vec3(0.8, 0.8, 0.8), vec3(1.8, 1.8, 1.8)) + vec3(0.16, 0.16, 0.16); - color.rgb *= arrayX[int(mod(texCoord.s * 960.0, 4.0))]; - color.rgb *= arrayY[int(mod(texCoord.t * 640.0, 4.0))]; + color.rgb *= arrayX[int(mod(texCoord.s * texSize.x * 4.0, 4.0))]; + color.rgb *= arrayY[int(mod(texCoord.t * texSize.y * 4.0, 4.0))]; color.a = 0.5; gl_FragColor = color; }
M
res/shaders/ags001.shader/ags001.fs
→
res/shaders/ags001.shader/ags001.fs
@@ -1,5 +1,6 @@
varying vec2 texCoord; uniform sampler2D tex; +uniform vec2 texSize; void main() { vec4 color = texture2D(tex, texCoord);@@ -14,8 +15,8 @@ arrayY[1] = vec3(1.0, 1.0, 1.0);
arrayY[2] = vec3(1.0, 1.0, 1.0); arrayY[3] = vec3(0.9, 0.9, 0.9); color.rgb = pow(color.rgb, vec3(1.6, 1.6, 1.6)); - color.rgb *= arrayX[int(mod(texCoord.s * 960.0, 4.0))]; - color.rgb *= arrayY[int(mod(texCoord.t * 640.0, 4.0))]; + color.rgb *= arrayX[int(mod(texCoord.s * texSize.x * 4.0, 4.0))]; + color.rgb *= arrayY[int(mod(texCoord.t * texSize.y * 4.0, 4.0))]; color.a = 0.8; gl_FragColor = color; }
M
res/shaders/xbr.shader/xbr.fs
→
res/shaders/xbr.shader/xbr.fs
@@ -98,7 +98,7 @@ varying vec4 TEX5;
varying vec4 TEX6; varying vec4 TEX7; -const vec2 TextureSize = vec2(240.0, 160.0); +uniform vec2 texSize; void main() {@@ -110,7 +110,7 @@ vec4 fx, fx_left, fx_up, finalfx, fx3_left, fx3_up; // inequations of straight lines.
vec3 res1, res2, pix1, pix2; float blend1, blend2; - vec2 fp = fract(texCoord * TextureSize); + vec2 fp = fract(texCoord * texSize); vec3 A1 = COMPAT_TEXTURE(tex, TEX1.xw).rgb; vec3 B1 = COMPAT_TEXTURE(tex, TEX1.yw).rgb;
M
res/shaders/xbr.shader/xbr.vs
→
res/shaders/xbr.shader/xbr.vs
@@ -34,12 +34,14 @@ varying vec4 TEX6;
varying vec4 TEX7; attribute vec4 position; +uniform vec2 texSize; + /* VERTEX_SHADER */ void main() { gl_Position = position; - vec2 ps = vec2(1.0/240.0, 1.0/160.0); + vec2 ps = vec2(1.0) / texSize; float dx = ps.x; float dy = ps.y;
M
src/platform/opengl/gles2.c
→
src/platform/opengl/gles2.c
@@ -230,6 +230,7 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shader->filter ? GL_LINEAR : GL_NEAREST); glUseProgram(shader->program); glUniform1i(shader->texLocation, 0); + glUniform2f(shader->texSizeLocation, context->d.width, context->d.height); glVertexAttribPointer(shader->positionLocation, 2, GL_FLOAT, GL_FALSE, 0, _vertices); glEnableVertexAttribArray(shader->positionLocation); size_t u;@@ -399,6 +400,7 @@ mLOG(OPENGL, ERROR, "%s\n", log);
} shader->texLocation = glGetUniformLocation(shader->program, "tex"); + shader->texSizeLocation = glGetUniformLocation(shader->program, "texSize"); shader->positionLocation = glGetAttribLocation(shader->program, "position"); size_t i; for (i = 0; i < shader->nUniforms; ++i) {
M
src/platform/opengl/gles2.h
→
src/platform/opengl/gles2.h
@@ -62,6 +62,7 @@ GLuint fragmentShader;
GLuint vertexShader; GLuint program; GLuint texLocation; + GLuint texSizeLocation; GLuint positionLocation; struct mGLES2Uniform* uniforms;