add resolution uniform for pp, 16bit uses this for reducing screen resolution (wtf?)

This commit is contained in:
degasus 2013-03-07 17:35:27 +01:00
parent 12e84f918a
commit 1c125f0fb4
3 changed files with 68 additions and 105 deletions

View File

@ -1,109 +1,61 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec2 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
//Change this number to increase the pixel size.
int pixelSize = 3;
float pixelSize = 3;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
int val = uv0[0];
int val2 = uv0[1];
val = val % pixelSize;
val2 = val2 % pixelSize;
if(val == 0 && val2 == 0 ){
if (c0.r < 0.1 && c0.r >= 0)
red = 0.1;
if (c0.r < 0.20 && c0.r >= 0.1)
red = 0.20;
if (c0.r <0.40 && c0.r >= 0.20)
red = 0.40;
if (c0.r <0.60 && c0.r >= 0.40)
red = 0.60;
if (c0.r <0.80 && c0.r >= 0.60)
red = 0.80;
if (c0.r >= 0.80)
red = 1;
if (c0.b < 0.1 && c0.b >= 0)
blue = 0.1;
if (c0.b < 0.20 && c0.b >= 0.1)
blue = 0.20;
if (c0.b <0.40 && c0.b >= 0.20)
blue = 0.40;
if (c0.b <0.60 && c0.b >= 0.40)
blue = 0.60;
if (c0.b <0.80 && c0.b >= 0.60)
blue = 0.80;
if (c0.b >= 0.80)
blue = 1;
if (c0.g < 0.1 && c0.g >= 0)
green = 0.1;
if (c0.g < 0.20 && c0.g >= 0.1)
green = 0.20;
if (c0.g <0.40 && c0.g >= 0.20)
green = 0.40;
if (c0.g <0.60 && c0.g >= 0.40)
green = 0.60;
if (c0.g <0.80 && c0.g >= 0.60)
green = 0.80;
if (c0.g >= 0.80)
green = 1;
}
else{
float4 c1 = texRECT(samp0, uv0-float2(val, val2)).rgba;
if (c1.r < 0.1 && c1.r >= 0)
red = 0.1;
if (c1.r < 0.20 && c1.r >= 0.1)
red = 0.20;
if (c1.r <0.40 && c1.r >= 0.20)
red = 0.40;
if (c1.r <0.60 && c1.r >= 0.40)
red = 0.60;
if (c1.r <0.80 && c1.r >= 0.60)
red = 0.80;
if (c1.r >= 0.80)
red = 1;
if (c1.b < 0.1 && c1.b >= 0)
blue = 0.1;
if (c1.b < 0.20 && c1.b >= 0.1)
blue = 0.20;
if (c1.b <0.40 && c1.b >= 0.20)
blue = 0.40;
if (c1.b <0.60 && c1.b >= 0.40)
blue = 0.60;
if (c1.b <0.80 && c1.b >= 0.60)
blue = 0.80;
if (c1.b >= 0.80)
blue = 1;
if (c1.g < 0.1 && c1.g >= 0)
green = 0.1;
if (c1.g < 0.20 && c1.g >= 0.1)
green = 0.20;
if (c1.g <0.40 && c1.g >= 0.20)
green = 0.40;
if (c1.g <0.60 && c1.g >= 0.40)
green = 0.60;
if (c1.g <0.80 && c1.g >= 0.60)
green = 0.80;
if (c1.g >= 0.80)
green = 1;
}
ocol0 = float4(red, green, blue, c0.a);
vec2 pos = round(uv0 * resolution / pixelSize) * resolution / pixelSize;
vec4 c0 = texture(samp9, uv0);
if (c0.r < 0.1)
red = 0.1;
else if (c0.r < 0.20)
red = 0.20;
else if (c0.r < 0.40)
red = 0.40;
else if (c0.r < 0.60)
red = 0.60;
else if (c0.r < 0.80)
red = 0.80;
else
red = 1.0;
if (c0.b < 0.1)
blue = 0.1;
else if (c0.b < 0.20)
blue = 0.20;
else if (c0.b < 0.40)
blue = 0.40;
else if (c0.b < 0.60)
blue = 0.60;
else if (c0.b < 0.80)
blue = 0.80;
else
blue = 1.0;
if (c0.g < 0.1)
green = 0.1;
else if (c0.g < 0.20)
green = 0.20;
else if (c0.g < 0.40)
green = 0.40;
else if (c0.g < 0.60)
green = 0.60;
else if (c0.g < 0.80)
green = 0.80;
else
green = 1.0;
ocol0 = vec4(red, green, blue, c0.a);
}

View File

@ -1,11 +1,14 @@
//dummy shader:
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.r, c0.g, c0.b, c0.a);
ocol0 = texture(samp9, uv0);
}
/*
And now that's over with, the contents of this readme file!
For best results, turn Wordwrap formatting on...

View File

@ -40,7 +40,9 @@ static GLuint s_texture;
static GLuint s_vao;
static GLuint s_vbo;
static char* s_vertex_shader =
static GLuint s_uniform_resolution;
static char s_vertex_shader[] =
"in vec2 rawpos;\n"
"in vec2 tex0;\n"
"out vec2 uv0;\n"
@ -113,6 +115,9 @@ void BlitToScreen()
glBindVertexArray(s_vao);
s_shader.Bind();
glUniform2f(s_uniform_resolution, (float)s_width, (float)s_height);
glActiveTexture(GL_TEXTURE0+9);
glBindTexture(GL_TEXTURE_2D, s_texture);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -168,6 +173,9 @@ void ApplyShader()
return;
}
// read uniform locations
s_uniform_resolution = glGetUniformLocation(s_shader.glprogid, "resolution");
// successful
s_enable = true;
}