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.
This commit is contained in:
IntegratedQuantum 2023-12-01 19:45:51 +01:00
parent 91a52e6dae
commit 77716b4679
18 changed files with 10 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -79,10 +79,9 @@ void main() {
uint textureIndex = textureData[blockType].textureIndices[faceNormal]; uint textureIndex = textureData[blockType].textureIndices[faceNormal];
float normalVariation = normalVariations[faceNormal]; float normalVariation = normalVariations[faceNormal];
vec3 textureCoords = vec3(getTextureCoordsNormal(startPosition/16, faceNormal), textureIndex); 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; if(!passDitherTest(fragColor.a)) discard;
fragColor.a = 1; fragColor.a = 1;
fragColor.rgb += texture(emissionSampler, textureCoords).rgb;
} }

View File

@ -139,7 +139,8 @@ void main() {
float fogDistance = calculateFogDistance(dist, textureData[blockType].fogDensity*densityAdjustment); float fogDistance = calculateFogDistance(dist, textureData[blockType].fogDensity*densityAdjustment);
float airFogDistance = calculateFogDistance(dist, fog.density*densityAdjustment); float airFogDistance = calculateFogDistance(dist, fog.density*densityAdjustment);
vec3 fogColor = unpackColor(textureData[blockType].fogColor); 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) { if(isBackFace == 0) {
textureColor.rgb *= textureColor.a; textureColor.rgb *= textureColor.a;
blendColor.rgb = unpackColor(textureData[blockType].absorption); blendColor.rgb = unpackColor(textureData[blockType].absorption);
@ -149,7 +150,7 @@ void main() {
// TODO: Change this when it rains. // TODO: Change this when it rains.
// TODO: Normal mapping. // TODO: Normal mapping.
// TODO: Allow textures to contribute to this term. // 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; textureColor.rgb += texture(emissionSampler, textureCoords).rgb;
blendColor.rgb *= 1 - textureColor.a; blendColor.rgb *= 1 - textureColor.a;
textureColor.a = 1; textureColor.a = 1;

View File

@ -959,17 +959,17 @@ pub const meshing = struct {
const oldBlock = self.chunk.blocks[getIndex(x, y, z)]; const oldBlock = self.chunk.blocks[getIndex(x, y, z)];
for(Neighbors.iterable) |neighbor| { for(Neighbors.iterable) |neighbor| {
var neighborMesh = self; 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 nx = x + Neighbors.relX[neighbor];
var ny = y + Neighbors.relY[neighbor]; var ny = y + Neighbors.relY[neighbor];
var nz = z + Neighbors.relZ[neighbor]; var nz = z + Neighbors.relZ[neighbor];
if(nx & chunkMask != nx or ny & chunkMask != ny or nz & chunkMask != nz) { // Outside this chunk. 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; 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; nx &= chunkMask;
ny &= chunkMask; ny &= chunkMask;
nz &= chunkMask; nz &= chunkMask;