diff --git a/gradle.properties b/gradle.properties index 00ff7068..c699ccb7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ loader_version=0.14.21 fabric_version=0.84.0+1.20.1 # Mod Properties -mod_version=0.1.12-alpha +mod_version=0.1.13-alpha maven_group=me.cortex archives_base_name=nvidium # Dependencies diff --git a/src/main/java/me/cortex/nvidium/sodiumCompat/SodiumResultCompatibility.java b/src/main/java/me/cortex/nvidium/sodiumCompat/SodiumResultCompatibility.java index aa2a1781..f357c24d 100644 --- a/src/main/java/me/cortex/nvidium/sodiumCompat/SodiumResultCompatibility.java +++ b/src/main/java/me/cortex/nvidium/sodiumCompat/SodiumResultCompatibility.java @@ -57,7 +57,7 @@ public static void uploadChunkGeometry(long uploadBuffer, short[] outOffsets, Ch //Update the meta bits of the model format dst = uploadBuffer + offset * 4L * formatSize; for (int j = 0; j < (segment.elementCount()/6)*4; j++) { - short flags = (short) 0b01;//No alpha, Yes mipping + short flags = (short) 0b100;//Yes mipping, No alpha cut MemoryUtil.memPutShort(dst+ (long) j *formatSize+ 6L, flags);//Note: the 6 here is the offset into the vertex format } @@ -100,7 +100,7 @@ public static void uploadChunkGeometry(long uploadBuffer, short[] outOffsets, Ch //Update the meta bits of the model format dst = uploadBuffer + offset * 4L * formatSize; for (int j = 0; j < (segment.elementCount()/6)*4; j++) { - short flags = (short) 0b10;//alpha, No mipping + short flags = (short) 0b001;//No mipping, 0.1 alpha cut MemoryUtil.memPutShort(dst+ (long) j *formatSize+ 6L, flags);//Note: the 6 here is the offset into the vertex format } @@ -143,7 +143,7 @@ public static void uploadChunkGeometry(long uploadBuffer, short[] outOffsets, Ch //Update the meta bits of the model format dst = uploadBuffer + offset * 4L * formatSize; for (int j = 0; j < (segment.elementCount()/6)*4; j++) { - short flags = (short) 0b11;//alpha, Yes mipping + short flags = (short) 0b110;//mipping, 0.5 cut MemoryUtil.memPutShort(dst+ (long) j *formatSize+ 6L, flags);//Note: the 6 here is the offset into the vertex format } @@ -193,7 +193,7 @@ public static void uploadChunkGeometry(long uploadBuffer, short[] outOffsets, Ch //Update the meta bits of the model format dst = uploadBuffer + translucent * 4L * formatSize; for (int j = 0; j < (segment.elementCount()/6)*4; j++) { - short flags = (short) 0b00;//No alpha, No mipping + short flags = (short) 0b000;//No mipping, No alpha cut MemoryUtil.memPutShort(dst+ (long) j *formatSize+ 6L, flags);//Note: the 6 here is the offset into the vertex format } diff --git a/src/main/resources/assets/nvidium/shaders/terrain/frag.frag b/src/main/resources/assets/nvidium/shaders/terrain/frag.frag index ba7963d7..6a7b5f18 100644 --- a/src/main/resources/assets/nvidium/shaders/terrain/frag.frag +++ b/src/main/resources/assets/nvidium/shaders/terrain/frag.frag @@ -16,8 +16,7 @@ layout(location = 0) out vec4 colour; layout(location = 1) in Interpolants { vec4 tint; vec4 addin; - vec3 uv_bias; - flat bool hasAlpha; + vec4 uv_bias_cutoff; }; @@ -29,8 +28,8 @@ void main() { //uint uid = gl_PrimitiveID*132471+123571; //colour = vec4(float((uid>>0)&7)/7, float((uid>>3)&7)/7, float((uid>>6)&7)/7, 1.0); //colour = vec4(1.0,1.0,0,1); - colour = texture(tex_diffuse, uv_bias.xy, uv_bias.z); - if (colour.a < 0.05f && hasAlpha) discard; + colour = texture(tex_diffuse, uv_bias_cutoff.xy, uv_bias_cutoff.z); + if (colour.a < uv_bias_cutoff.w) discard; colour *= tint; colour += addin; //colour = vec4(1.0,(uv_bias.z/-8.1f)+0.001f,0,1); diff --git a/src/main/resources/assets/nvidium/shaders/terrain/mesh.glsl b/src/main/resources/assets/nvidium/shaders/terrain/mesh.glsl index 10829a6a..f23dc8ae 100644 --- a/src/main/resources/assets/nvidium/shaders/terrain/mesh.glsl +++ b/src/main/resources/assets/nvidium/shaders/terrain/mesh.glsl @@ -26,8 +26,7 @@ taskNV in Task { layout(location=1) out Interpolants { vec4 tint; vec4 addin; - vec3 uv_bias; - flat bool hasAlpha; + vec4 uv_bias_cutoff; } OUT[]; vec3 decodeVertex(Vertex v) { @@ -58,20 +57,17 @@ void main() { vec3 posB = decodeVertex(B)+originAndBaseData.xyz; gl_MeshVerticesNV[(gl_LocalInvocationID.x<<1)].gl_Position = MVP*vec4(posA,1.0); gl_MeshVerticesNV[(gl_LocalInvocationID.x<<1)|1].gl_Position = MVP*vec4(posB,1.0); - //TODO: see if ternary or array is faster + bool isA = (gl_LocalInvocationID.x&1)==0; gl_PrimitiveIndicesNV[primId] = (isA?0:2)+idxBase; gl_PrimitiveIndicesNV[primId+1] = (isA?1:3)+idxBase; gl_PrimitiveIndicesNV[primId+2] = (isA?2:0)+idxBase; - bool hasMipping = (A.d&int16_t(1))!=int16_t(0); - bool hasAlpha = (A.d&int16_t(2))!=int16_t(0); - - OUT[(gl_LocalInvocationID.x<<1)|0].hasAlpha = hasAlpha; - OUT[(gl_LocalInvocationID.x<<1)|1].hasAlpha = hasAlpha; + bool hasMipping = (A.d&int16_t(4))!=int16_t(0); + float alphaCutoff = (float[](0.0f, 0.1f,0.5f))[(A.d&int16_t(3))]; - OUT[(gl_LocalInvocationID.x<<1)|0].uv_bias = vec3(vec2(A.g,A.h)*(1f/65536), hasMipping?0.0f:-8.0f); - OUT[(gl_LocalInvocationID.x<<1)|1].uv_bias = vec3(vec2(B.g,B.h)*(1f/65536), hasMipping?0.0f:-8.0f); + OUT[(gl_LocalInvocationID.x<<1)|0].uv_bias_cutoff = vec4(vec2(A.g,A.h)*(1f/65536), hasMipping?0.0f:-8.0f, alphaCutoff); + OUT[(gl_LocalInvocationID.x<<1)|1].uv_bias_cutoff = vec4(vec2(B.g,B.h)*(1f/65536), hasMipping?0.0f:-8.0f, alphaCutoff); vec4 tintA = vec4(A.e&int16_t(0xFF),(A.e>>8)&int16_t(0xFF),A.f&int16_t(0xFF),(A.f>>8)&int16_t(0xFF))/255;