Began work on post processing

This commit is contained in:
mcrcortex
2024-01-30 20:55:46 +10:00
parent 80bd0d7c67
commit a3f043a577
16 changed files with 224 additions and 123 deletions

View File

@@ -13,7 +13,7 @@ layout(location = 0) out vec4 outColour;
void main() {
vec2 uv = mod(uv, vec2(1))*(1f/(vec2(3,2)*256f));
vec4 colour = texture(blockModelAtlas, uv + baseUV);
if (discardAlpha == 1 && colour.a == 0.0f) {
if (discardAlpha == 1 && colour.a <= 0.001f) {
discard;
}
outColour = colour * colourTinting;

View File

@@ -0,0 +1,12 @@
#version 330 core
uniform sampler2D text;
out vec4 colour;
in vec2 UV;
void main() {
colour = texture(text, UV.xy);
if (colour.a == 0.0) {
discard;
}
}

View File

@@ -0,0 +1,7 @@
#version 330 core
out vec2 UV;
void main() {
gl_Position = vec4(vec2(gl_VertexID&1, (gl_VertexID>>1)&1) * 4 - 1, 0.99999999999f, 1);
UV = gl_Position.xy*0.5+0.5;
}

View File

@@ -0,0 +1,6 @@
#version 330 core
out vec4 colour;
in vec2 UV;
void main() {
colour = vec4(1,0,1,1);
}

View File

@@ -1,8 +0,0 @@
#version 460 core
layout(location = 0) in flat vec4 colour;
layout(location = 0) out vec4 outColour;
void main() {
//TODO: randomly discard the fragment with respect to the alpha value
outColour = colour;
}

View File

@@ -1,18 +0,0 @@
#version 460 core
layout(location = 0) out flat vec4 colour;
layout(binding = 0, std140) uniform SceneUniform {
mat4 MVP;
ivec3 baseSectionPos;
int _pad1;
};
void main() {
int cornerIdx = gl_VertexID&3;
gl_Position = MVP * vec4(vec3(cornerIdx&1,((cornerIdx>>1)&1),0),1);
colour = vec4(float((uint(gl_VertexID)>>2)&7)/7,float((uint(gl_VertexID)>>5)&7)/7,float((uint(gl_VertexID)>>8)&7)/7,1);
}

View File

@@ -1,28 +0,0 @@
//Contains the definision of a ray and step functions
struct Ray {
ivec3 pos;
vec3 innerPos;
vec3 dir;
vec3 invDir;
};
Ray ray;
void setup(vec3 origin, vec3 direction) {
ray.pos = ivec3(origin);
ray.innerPos = origin - ray.pos;
direction *= inversesqrt(direction);
ray.dir = direction;
ray.invDir = 1/direction;
}
void step(ivec3 aabb) {
//TODO:check for innerPos>=1 and step into that voxel
vec3 t2f = (aabb - ray.innerPos) * ray.invDir;
float mint2f = min(t2f.x, min(t2f.y, t2f.z));
bvec3 msk = lessThanEqual(t2f.xyz, vec3(mint2f));
vec3 newIP = mint2f * ray.dir + ray.innerPos;
ivec3 offset = min(aabb-1, ivec3(newIP));
ray.pos += offset + ivec3(msk);
ray.innerPos = mix(vec3(0), newIP - offset, not(msk));
}

View File

@@ -1,8 +0,0 @@
struct Voxel {
};
//TODO: add tlas and blas voxel fetching (rings and all)
void getVoxel() {
}

View File

@@ -1,2 +0,0 @@
//Glue code between ray stepper and voxel storage
// its the primary ray tracer