Textures almost working, fixed up the mesher being a dumbass
This commit is contained in:
@@ -29,6 +29,8 @@ struct DrawCommand {
|
||||
uint baseInstance;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform sampler2D blockModelAtlas;
|
||||
|
||||
#ifndef Quad
|
||||
#define Quad ivec2
|
||||
#endif
|
||||
@@ -65,3 +67,5 @@ vec4 getLighting(uint index) {
|
||||
arr = arr & uvec4(0xFF);
|
||||
return vec4(arr)*vec4(1.0f/255.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#version 460 core
|
||||
layout(location = 0) in flat vec4 colour;
|
||||
layout(binding = 0) uniform sampler2D blockModelAtlas;
|
||||
layout(location = 0) in vec2 uv;
|
||||
layout(location = 0) out vec4 outColour;
|
||||
void main() {
|
||||
//TODO: randomly discard the fragment with respect to the alpha value
|
||||
vec2 uv = mod(uv, vec2(1));
|
||||
|
||||
outColour = colour;
|
||||
outColour = texture(blockModelAtlas, uv);
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#import <zenith:lod/gl46/quad_format.glsl>
|
||||
#import <zenith:lod/gl46/bindings.glsl>
|
||||
|
||||
layout(location = 0) out flat vec4 colour;
|
||||
layout(location = 0) out vec2 uv;
|
||||
|
||||
uint extractLodLevel() {
|
||||
return uint(gl_BaseInstance)>>29;
|
||||
@@ -41,7 +41,8 @@ void main() {
|
||||
cornerIdx ^= 1;
|
||||
}
|
||||
|
||||
ivec2 size = extractSize(quad) * ivec2((cornerIdx>>1)&1, cornerIdx&1) * (1<<lodLevel);
|
||||
ivec2 sizePreLod = extractSize(quad) * ivec2((cornerIdx>>1)&1, cornerIdx&1);
|
||||
ivec2 size = sizePreLod * (1<<lodLevel);
|
||||
|
||||
vec3 pos = corner;
|
||||
|
||||
@@ -63,19 +64,8 @@ void main() {
|
||||
|
||||
uint stateId = extractStateId(quad);
|
||||
uint biomeId = extractBiomeId(quad);
|
||||
BlockModel stateInfo = modelData[stateId];
|
||||
colour = uint2vec4RGBA(stateInfo.faceColours[face]);
|
||||
|
||||
colour *= getLighting(extractLightId(quad));
|
||||
|
||||
//Apply face tint
|
||||
if (face == 0) {
|
||||
colour.xyz *= vec3(0.75, 0.75, 0.75);
|
||||
} else if (face != 1) {
|
||||
colour.xyz *= vec3((float(face-2)/4)*0.6 + 0.4);
|
||||
}
|
||||
|
||||
|
||||
uv = vec2(sizePreLod);
|
||||
}
|
||||
//gl_Position = MVP * vec4(vec3(((cornerIdx)&1)+10,10,((cornerIdx>>1)&1)+10),1);
|
||||
//uint i = uint(quad>>32);
|
||||
|
||||
Reference in New Issue
Block a user