mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-09 03:59:53 -04:00
Make it possible to draw larger quads (although all of them are drawn at a 1×1 size at the moment).
more progress towards #133
This commit is contained in:
parent
0cc05368cc
commit
b1bd04f1bc
@ -85,8 +85,8 @@ vec3 unpack15BitLight(uint val) {
|
||||
}
|
||||
|
||||
vec3 readLightValue() {
|
||||
uint x = uint(lightPosition.x);
|
||||
uint y = uint(lightPosition.y);
|
||||
uint x = clamp(uint(lightPosition.x), 0, lightArea.x - 1);
|
||||
uint y = clamp(uint(lightPosition.y), 0, lightArea.y - 1);
|
||||
uint light00 = lightData[lightBufferIndex + (x*lightArea.y + y)];
|
||||
uint light01 = lightData[lightBufferIndex + (x*lightArea.y + y + 1)];
|
||||
uint light10 = lightData[lightBufferIndex + ((x + 1)*lightArea.y + y)];
|
||||
|
@ -98,10 +98,14 @@ void main() {
|
||||
vec3 modelPosition = vec3(chunks[chunkID].position.xyz - playerPositionInteger) - playerPositionFraction;
|
||||
int encodedPosition = faceData[faceID].encodedPosition;
|
||||
int textureAndQuad = faceData[faceID].textureAndQuad;
|
||||
uvec2 quadSize = uvec2(
|
||||
encodedPosition >> 15 & 31,
|
||||
encodedPosition >> 20 & 31
|
||||
);
|
||||
lightBufferIndex = (transparent ? chunks[chunkID].lightStartTransparent : chunks[chunkID].lightStartOpaque) + faceData[faceID].lightBufferIndex;
|
||||
lightArea = uvec2(2, 2);
|
||||
lightArea = quadSize + uvec2(1, 1);
|
||||
lightPosition = vec2(vertexID >> 1, vertexID & 1);
|
||||
isBackFace = encodedPosition>>19 & 1;
|
||||
isBackFace = encodedPosition>>31 & 1;
|
||||
ditherSeed = encodedPosition & 15;
|
||||
|
||||
textureIndex = textureAndQuad & 65535;
|
||||
@ -120,7 +124,17 @@ void main() {
|
||||
|
||||
normal = quads[quadIndex].normal;
|
||||
|
||||
position += quads[quadIndex].corners[vertexID];
|
||||
vec3 cornerPosition = quads[quadIndex].corners[0];
|
||||
vec2 uvCornerPosition = quads[quadIndex].cornerUV[0];
|
||||
if((vertexID & 2) != 0) {
|
||||
cornerPosition += (quads[quadIndex].corners[2] - quads[quadIndex].corners[0])*quadSize.x;
|
||||
uvCornerPosition += (quads[quadIndex].cornerUV[2] - quads[quadIndex].cornerUV[0])*quadSize.x;
|
||||
}
|
||||
if((vertexID & 1) != 0) {
|
||||
cornerPosition += (quads[quadIndex].corners[vertexID] - quads[quadIndex].corners[vertexID & 2])*quadSize.y;
|
||||
uvCornerPosition += (quads[quadIndex].cornerUV[vertexID] - quads[quadIndex].cornerUV[vertexID & 2])*quadSize.y;
|
||||
}
|
||||
position += cornerPosition;
|
||||
position *= voxelSize;
|
||||
position += modelPosition;
|
||||
|
||||
@ -129,5 +143,5 @@ void main() {
|
||||
vec4 mvPos = viewMatrix*vec4(position, 1);
|
||||
gl_Position = projectionMatrix*mvPos;
|
||||
mvVertexPos = mvPos.xyz;
|
||||
uv = quads[quadIndex].cornerUV[vertexID]*voxelSize;
|
||||
uv = uvCornerPosition*voxelSize;
|
||||
}
|
@ -244,9 +244,10 @@ pub const FaceData = extern struct {
|
||||
x: u5,
|
||||
y: u5,
|
||||
z: u5,
|
||||
padding: u4 = 0,
|
||||
xSize: u5,
|
||||
ySize: u5,
|
||||
padding: u6 = 0,
|
||||
isBackFace: bool,
|
||||
padding2: u12 = 0,
|
||||
},
|
||||
blockAndQuad: packed struct(u32) {
|
||||
texture: u16,
|
||||
@ -256,7 +257,7 @@ pub const FaceData = extern struct {
|
||||
|
||||
pub inline fn init(texture: u16, quadIndex: u16, x: i32, y: i32, z: i32, comptime backFace: bool) FaceData {
|
||||
return FaceData {
|
||||
.position = .{.x = @intCast(x), .y = @intCast(y), .z = @intCast(z), .isBackFace = backFace},
|
||||
.position = .{.x = @intCast(x), .y = @intCast(y), .z = @intCast(z), .xSize = 1, .ySize = 1, .isBackFace = backFace},
|
||||
.blockAndQuad = .{.texture = texture, .quadIndex = quadIndex},
|
||||
.lightBufferIndex = undefined,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user