Seperated out the projection matrix from vanilla terrain projection

This commit is contained in:
mcrcortex
2024-02-06 15:12:37 +10:00
parent af1800226d
commit e197e07c94
15 changed files with 61 additions and 42 deletions

View File

@@ -1,3 +1,4 @@
#line 1
struct Frustum {
vec4 planes[6];
};

View File

@@ -1,11 +1,12 @@
#line 1
//TODO: FIXME: this isnt actually correct cause depending on the face (i think) it could be 1/64 th of a position off
// but im going to assume that since we are dealing with huge render distances, this shouldent matter that much
float extractFaceIndentation(uint faceData) {
return float((faceData>>16)&63)/63;
return float((faceData>>16)&63)/63f;
}
vec4 extractFaceSizes(uint faceData) {
return (vec4(faceData&0xF, (faceData>>4)&0xF, (faceData>>8)&0xF, (faceData>>12)&0xF)/16)+vec4(0,1f/16,0,1f/16);
return (vec4(faceData&0xF, (faceData>>4)&0xF, (faceData>>8)&0xF, (faceData>>12)&0xF)/16f)+vec4(0f,1f/16f,0f,1f/16f);
}
uint faceHasAlphaCuttout(uint faceData) {

View File

@@ -1,3 +1,4 @@
#line 1
#ifdef GL_ARB_gpu_shader_int64
#define Quad uint64_t

View File

@@ -23,18 +23,18 @@ ivec3 extractRelativeLodPos() {
}
vec4 uint2vec4RGBA(uint colour) {
return vec4((uvec4(colour)>>uvec4(24,16,8,0))&uvec4(0xFF))/255;
return vec4((uvec4(colour)>>uvec4(24,16,8,0))&uvec4(0xFF))/255f;
}
//Gets the face offset with respect to the face direction (e.g. some will be + some will be -)
float getDepthOffset(uint faceData, uint face) {
float offset = extractFaceIndentation(faceData);
return offset * (1-((int(face)&1)*2));
return offset * (1f-((int(face)&1)*2f));
}
vec2 getFaceSizeOffset(uint faceData, uint corner) {
vec4 faceOffsetsSizes = extractFaceSizes(faceData);
return mix(faceOffsetsSizes.xz, -(1-faceOffsetsSizes.yw), bvec2(((corner>>1)&1)==1, (corner&1)==1));
return mix(faceOffsetsSizes.xz, -(1f-faceOffsetsSizes.yw), bvec2(((corner>>1)&1)==1, (corner&1)==1));
}
//TODO: add a mechanism so that some quads can ignore backface culling

View File

@@ -1,3 +1,4 @@
#line 1
uint extractDetail(SectionMeta section) {
return section.posA>>28;
}