mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-12 05:53:51 -04:00
parent
c4a4d29a07
commit
ae4b60349e
@ -81,7 +81,7 @@ void mainBlockDrop() {
|
|||||||
reflectivity = reflectivity*fixedCubeMapLookup(reflect(direction, faceNormal)).x;
|
reflectivity = reflectivity*fixedCubeMapLookup(reflect(direction, faceNormal)).x;
|
||||||
reflectivity = reflectivity*(1 - fresnelReflection) + fresnelReflection;
|
reflectivity = reflectivity*(1 - fresnelReflection) + fresnelReflection;
|
||||||
|
|
||||||
vec3 pixelLight = max(vec3(normalVariation), texture(emissionSampler, textureCoords).r*4); // TODO: light*normalVariation
|
vec3 pixelLight = ambientLight*max(vec3(normalVariation), texture(emissionSampler, textureCoords).r*4);
|
||||||
fragColor = texture(texture_sampler, textureCoords)*vec4(pixelLight, 1);
|
fragColor = texture(texture_sampler, textureCoords)*vec4(pixelLight, 1);
|
||||||
fragColor.rgb += reflectivity*pixelLight;
|
fragColor.rgb += reflectivity*pixelLight;
|
||||||
|
|
||||||
|
@ -681,10 +681,11 @@ pub const ItemDropRenderer = struct { // MARK: ItemDropRenderer
|
|||||||
if(itemDrops.list.items(.itemStack)[i].item) |item| {
|
if(itemDrops.list.items(.itemStack)[i].item) |item| {
|
||||||
var pos = itemDrops.list.items(.pos)[i];
|
var pos = itemDrops.list.items(.pos)[i];
|
||||||
const rot = itemDrops.list.items(.rot)[i];
|
const rot = itemDrops.list.items(.rot)[i];
|
||||||
const light: u32 = 0xffffffff; // TODO: Get this light value from the mesh_storage.
|
const blockPos: Vec3i = @intFromFloat(@floor(pos));
|
||||||
|
const light: [6]u8 = main.renderer.mesh_storage.getLight(blockPos[0], blockPos[1], blockPos[2]) orelse .{0} ** 6;
|
||||||
c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&@max(
|
c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&@max(
|
||||||
ambientLight*@as(Vec3f, @splat(@as(f32, @floatFromInt(light >> 24))/255)),
|
ambientLight*@as(Vec3f, @as(Vec3f, @floatFromInt(Vec3i{light[0], light[1], light[2]}))/@as(Vec3f, @splat(255))),
|
||||||
Vec3f{light >> 16 & 255, light >> 8 & 255, light & 255}/@as(Vec3f, @splat(255)),
|
@as(Vec3f, @floatFromInt(Vec3i{light[3], light[4], light[5]}))/@as(Vec3f, @splat(255)),
|
||||||
)));
|
)));
|
||||||
pos -= playerPos;
|
pos -= playerPos;
|
||||||
|
|
||||||
|
@ -175,6 +175,21 @@ pub fn getBlock(x: i32, y: i32, z: i32) ?blocks.Block {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getLight(wx: i32, wy: i32, wz: i32) ?[6]u8 {
|
||||||
|
const node = getNodePointer(.{.wx = wx, .wy = wy, .wz = wz, .voxelSize = 1});
|
||||||
|
node.mutex.lock();
|
||||||
|
defer node.mutex.unlock();
|
||||||
|
const mesh = node.mesh orelse return null;
|
||||||
|
const x = (wx >> mesh.chunk.voxelSizeShift) & chunk.chunkMask;
|
||||||
|
const y = (wy >> mesh.chunk.voxelSizeShift) & chunk.chunkMask;
|
||||||
|
const z = (wz >> mesh.chunk.voxelSizeShift) & chunk.chunkMask;
|
||||||
|
mesh.lightingData[0].lock.lockRead();
|
||||||
|
defer mesh.lightingData[0].lock.unlockRead();
|
||||||
|
mesh.lightingData[1].lock.lockRead();
|
||||||
|
defer mesh.lightingData[1].lock.unlockRead();
|
||||||
|
return mesh.lightingData[1].getValue(x, y, z) ++ mesh.lightingData[0].getValue(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn getBlockFromAnyLod(x: i32, y: i32, z: i32) blocks.Block {
|
pub fn getBlockFromAnyLod(x: i32, y: i32, z: i32) blocks.Block {
|
||||||
var lod: u5 = 0;
|
var lod: u5 = 0;
|
||||||
while(lod < settings.highestLod) : (lod += 1) {
|
while(lod < settings.highestLod) : (lod += 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user