Move towards pixel upscaling filter

This commit is contained in:
2025-11-25 11:04:06 +00:00
parent f5a972d9e2
commit c0cfadbdd3
13 changed files with 107 additions and 49 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
in vec4 vTexPosRot;
in vec2 vPos;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=1) out vec3 fPos;
layout (location=2) out vec4 normal;
layout (binding=40) uniform sampler2DArray diffuseSampler;
layout (binding=41) uniform sampler2DArray normalSampler;
@@ -15,9 +15,9 @@ void main()
vec3 vTexPos = vTexPosRot.xyz;
float rot = vTexPosRot.w;
fCol = vec4(texture(diffuseSampler,vTexPos));
fPos = vec4(vPos,0,1);
fPos = vec3(vPos,0);
vec4 bn = vec4(texture(normalSampler,vTexPos) - 0.5);
vec3 nmap1 = vec3(rotateV2(rot,bn.xy), bn.z);
normal = vec4(-nmap1 ,0);
normal = vec4(-nmap1.xyz ,0);
//normal = vec4(0,0,-1 ,0);
}
+12 -3
View File
@@ -13,13 +13,22 @@ void main() {
// if (dist > rad) {
// discard;
// }
float t = texture(normals, vTexPos).w;
vec3 norm = texture(normals, vTexPos).xyz;
float y1 = dot(norm, distVec);
float y1 = dot(normalize(norm), normalize(distVec));
float y2 = float(y1 > 0 ? 1 : 0);
float x = 1 - (pow(dist / rad,4));
//float y2x = y2;
float y4 = float(y1 > 0 && y1 < 0.5 ? 0.5 : y2);
float y5 = max(0,y1);
//float y4 = smoothstep(-1,1,y1);
//float y4 = 0.25*pow(y1+1,2);
float y3 = float(t > 0
? y2
: (t == 0 ? y4 : y4));
//float x = 1 - (dist / rad);
//float x = 1;
//float x = (dist > rad ? 0 : 1);
vec3 c = y2* x * lumRad.rgb;
float x = 1 - (pow(dist / rad,4));
vec3 c = y3* x * lumRad.rgb;
fColor = vec4(c, 0);
}
+2 -2
View File
@@ -1,6 +1,6 @@
#version 450 core
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=1) out vec3 fPos;
layout (location=2) out vec4 fNorm;
in vec3 vTexCoords;
in vec4 vPos;
@@ -12,7 +12,7 @@ vec2 rotateV2 (float a, vec2 v)
void main()
{
fCol = texture(diffuseSampler,vTexCoords);
fPos = vPos;
fPos = vPos.xyz;
vec4 basenorm = texture(normalSampler,vTexCoords) - 0.5;
vec2 n1 = rotateV2(vAng,vec2(basenorm.x,basenorm.z));
fNorm = vec4(-vec3(n1,basenorm.y),0);
+3 -2
View File
@@ -4,10 +4,11 @@ in vec4 vPos;
in vec4 vNorm;
layout (location=0) out vec4 fCol;
layout (location=1) out vec3 fPos;
layout (location=2) out vec3 fNorm;
layout (location=2) out vec4 fNorm;
void main()
{
fCol = vCol;
fPos = vPos.xyz;
fNorm = vNorm.xyz;
//fNorm = vec4(vNorm.xyz,1);
fNorm = vNorm;
}
+21
View File
@@ -0,0 +1,21 @@
#version 450 core
in vec2 vTexPos;
out vec4 fColor;
layout (location = 0) uniform vec2 screensize;
layout(binding = 0) uniform sampler2D screenTexture;
float xoff = 2 / screensize.x;
float yoff = 2 / screensize.y;
vec3 f (float x, float y)
{ return texture(screenTexture, vTexPos + vec2(x*xoff,y*yoff)).xyz;
}
void main()
{
vec3 tl = f(-1, 1);
vec3 tt = f( 0, 1);
vec3 tr = f( 1, 1);
vec3 mr = f( 1, 0);
vec3 br = f( 1,-1);
if (tl == tt && tt == tr && tr == mr && mr == br)
{ fColor = vec4(tl,1);}
else {fColor = texture(screenTexture, vTexPos); }
}
+7
View File
@@ -0,0 +1,7 @@
#version 450 core
layout (std140, binding = 2) uniform PosTex { vec4 posTex[3]; };
out vec2 vTexPos;
void main() {
gl_Position = vec4(posTex[gl_VertexID].xy,0,1);
vTexPos = posTex[gl_VertexID].zw ;
}
-16
View File
@@ -1,16 +0,0 @@
#version 450 core
in vec3 vTexPos;
in vec3 vPos;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=2) out vec4 normal;
//layout (binding=0) uniform sampler2DArray tilesetSampler;
layout (binding=1) uniform sampler2D normalSampler;
void main()
{
//fCol = texture(tilesetSampler, vec3(0.3,0.1,0) + vTexPos);
fCol = vec4(0.2,0.3,0.6,1);
//fCol = vec4(0.6,0.4,0.3,1);
fPos = vec4(vPos,1);
normal = vec4(vec3(0.5) - texture(normalSampler,2*vTexPos.xy).xyz,0);
}
-12
View File
@@ -1,12 +0,0 @@
#version 450 core
layout (location = 0) in vec3 pos;
layout (location = 1) in vec3 texPos;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec3 vTexPos;
out vec3 vPos;
void main()
{
gl_Position = theMat * vec4(pos,1.0) ;
vTexPos = texPos;
vPos = pos;
}