Change how emission textures work. Also fixed a bug in block placing.
Emission now work as a base light, rather than adding to the ambient light. This makes them produce the same light strength and bloom regardless of the environment.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 587 B After Width: | Height: | Size: 4.6 KiB |
@ -79,10 +79,9 @@ void main() {
|
||||
uint textureIndex = textureData[blockType].textureIndices[faceNormal];
|
||||
float normalVariation = normalVariations[faceNormal];
|
||||
vec3 textureCoords = vec3(getTextureCoordsNormal(startPosition/16, faceNormal), textureIndex);
|
||||
fragColor = texture(texture_sampler, textureCoords)*vec4(light*normalVariation, 1);
|
||||
vec3 pixelLight = max(light*normalVariation, texture(emissionSampler, textureCoords).r*4);
|
||||
fragColor = texture(texture_sampler, textureCoords)*vec4(pixelLight, 1);
|
||||
|
||||
if(!passDitherTest(fragColor.a)) discard;
|
||||
fragColor.a = 1;
|
||||
|
||||
fragColor.rgb += texture(emissionSampler, textureCoords).rgb;
|
||||
}
|
||||
|
@ -139,7 +139,8 @@ void main() {
|
||||
float fogDistance = calculateFogDistance(dist, textureData[blockType].fogDensity*densityAdjustment);
|
||||
float airFogDistance = calculateFogDistance(dist, fog.density*densityAdjustment);
|
||||
vec3 fogColor = unpackColor(textureData[blockType].fogColor);
|
||||
vec4 textureColor = texture(texture_sampler, textureCoords)*vec4(light*normalVariation, 1);
|
||||
vec3 pixelLight = max(light*normalVariation, texture(emissionSampler, textureCoords).r*4);
|
||||
vec4 textureColor = texture(texture_sampler, textureCoords)*vec4(pixelLight, 1);
|
||||
if(isBackFace == 0) {
|
||||
textureColor.rgb *= textureColor.a;
|
||||
blendColor.rgb = unpackColor(textureData[blockType].absorption);
|
||||
@ -149,7 +150,7 @@ void main() {
|
||||
// TODO: Change this when it rains.
|
||||
// TODO: Normal mapping.
|
||||
// TODO: Allow textures to contribute to this term.
|
||||
textureColor.rgb += (textureData[blockType].reflectivity*fixedCubeMapLookup(reflect(direction, normals[faceNormal])).xyz)*light*normalVariation;
|
||||
textureColor.rgb += (textureData[blockType].reflectivity*fixedCubeMapLookup(reflect(direction, normals[faceNormal])).xyz)*pixelLight;
|
||||
textureColor.rgb += texture(emissionSampler, textureCoords).rgb;
|
||||
blendColor.rgb *= 1 - textureColor.a;
|
||||
textureColor.a = 1;
|
||||
|
@ -959,17 +959,17 @@ pub const meshing = struct {
|
||||
const oldBlock = self.chunk.blocks[getIndex(x, y, z)];
|
||||
for(Neighbors.iterable) |neighbor| {
|
||||
var neighborMesh = self;
|
||||
if(neighborMesh != self) {
|
||||
self.mutex.unlock();
|
||||
deadlockFreeDoubleLock(&self.mutex, &neighborMesh.mutex);
|
||||
}
|
||||
defer if(neighborMesh != self) neighborMesh.mutex.unlock();
|
||||
var nx = x + Neighbors.relX[neighbor];
|
||||
var ny = y + Neighbors.relY[neighbor];
|
||||
var nz = z + Neighbors.relZ[neighbor];
|
||||
if(nx & chunkMask != nx or ny & chunkMask != ny or nz & chunkMask != nz) { // Outside this chunk.
|
||||
neighborMesh = renderer.RenderStructure.getNeighborFromRenderThread(self.pos, self.pos.voxelSize, neighbor) orelse continue;
|
||||
}
|
||||
if(neighborMesh != self) {
|
||||
self.mutex.unlock();
|
||||
deadlockFreeDoubleLock(&self.mutex, &neighborMesh.mutex);
|
||||
}
|
||||
defer if(neighborMesh != self) neighborMesh.mutex.unlock();
|
||||
nx &= chunkMask;
|
||||
ny &= chunkMask;
|
||||
nz &= chunkMask;
|
||||
|