Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion assets/cubyz/shaders/chunks/chunk_vertex.vert
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ layout(std430, binding = 6) buffer _chunks
ChunkData chunks[];
};

vec3 square(vec3 x) {
return x*x;
}

void main() {
int faceID = gl_VertexID >> 2;
int vertexID = gl_VertexID & 3;
Expand All @@ -81,7 +85,7 @@ void main() {
fullLight >> 5 & 31u,
fullLight >> 0 & 31u
);
light = max(sunLight*ambientLight, blockLight)/31;
light = min(sqrt(square(sunLight*ambientLight) + square(blockLight)), vec3(31))/31;
isBackFace = encodedPositionAndLightIndex>>15 & 1;

textureIndex = textureAndQuad & 65535;
Expand Down
6 changes: 5 additions & 1 deletion assets/cubyz/shaders/entity_vertex.vert
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ layout(std430, binding = 11) buffer _quads
QuadInfo quads[];
};

vec3 square(vec3 x) {
return x*x;
}

vec3 calcLight(uint fullLight) {
vec3 sunLight = vec3(
fullLight >> 25 & 31u,
Expand All @@ -34,7 +38,7 @@ vec3 calcLight(uint fullLight) {
fullLight >> 5 & 31u,
fullLight >> 0 & 31u
);
return max(sunLight*ambientLight, blockLight)/31;
return min(sqrt(square(sunLight*ambientLight) + square(blockLight)), vec3(31))/31;
}

void main() {
Expand Down
6 changes: 5 additions & 1 deletion assets/cubyz/shaders/particles/particles.vert
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const vec3 facePositions[4] = vec3[4]
vec3(0.5f, 0.5f, 0.0f)
);

vec3 square(vec3 x) {
return x*x;
}

void main() {
int particleID = gl_VertexID >> 2;
int vertexID = gl_VertexID & 3;
Expand All @@ -62,7 +66,7 @@ void main() {
fullLight >> 5 & 31u,
fullLight >> 0 & 31u
);
light = max(sunLight*ambientLight, blockLight)/31;
light = min(sqrt(square(sunLight*ambientLight) + square(blockLight)), vec3(31))/31;

float rotation = particle.rotation;
vec3 faceVertPos = facePositions[vertexID];
Expand Down
7 changes: 3 additions & 4 deletions src/itemdrop.zig
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,9 @@ pub const ItemDropRenderer = struct { // MARK: ItemDropRenderer
}

fn bindLightUniform(light: [6]u8, ambientLight: Vec3f) void {
c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&@max(
ambientLight*@as(Vec3f, @as(Vec3f, @floatFromInt(Vec3i{light[0], light[1], light[2]}))/@as(Vec3f, @splat(255))),
@as(Vec3f, @floatFromInt(Vec3i{light[3], light[4], light[5]}))/@as(Vec3f, @splat(255)),
)));
const sunLight: Vec3f = ambientLight*@as(Vec3f, @floatFromInt(Vec3i{light[0], light[1], light[2]}))/@as(Vec3f, @splat(255));
const blockLight: Vec3f = @as(Vec3f, @floatFromInt(Vec3i{light[3], light[4], light[5]}))/@as(Vec3f, @splat(255));
c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&@min(@sqrt(sunLight*sunLight + blockLight*blockLight), @as(Vec3f, @splat(1)))));
}

fn bindModelUniforms(modelIndex: u31, blockType: u16) void {
Expand Down