Skip to content

Commit 16cbd45

Browse files
committed
Emissive blocks
1 parent 628f4a5 commit 16cbd45

File tree

8 files changed

+18
-7
lines changed

8 files changed

+18
-7
lines changed

core/assets/db/blocks/020_glow_stone.block

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
shadeAO: false,
44
envAO: false,
55
transparent: false,
6+
emission: 1.0f,
67
textures: {
78
all: "glow_stone"
89
}

core/assets/graphics/shaders/ps-bloom.frag.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ varying vec2 v_texCoords;
22
void main() {
33
vec4 sum = vec4(0.0);
44

5-
float blurSize = 0.004f;
5+
float blurSize = 0.002f;
66
/*
77
sum += texture2D(u_downSampledMainTexture, vec2(v_texCoords.x, v_texCoords.y - 4.0*blurSize)) * 0.05;
88
sum += texture2D(u_downSampledMainTexture, vec2(v_texCoords.x, v_texCoords.y - 3.0*blurSize)) * 0.09;

core/assets/graphics/shaders/terrain.frag.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ varying float v_transparent;
66
varying vec2 v_uvStart;
77
varying vec2 v_uvMul;
88
varying vec4 v_positionInLightSpace;
9-
9+
varying float v_emission;
1010
void main() {
1111
discardIfClipped(v_position);
1212

@@ -22,7 +22,7 @@ void main() {
2222

2323
vec4 lighting = u_ambientLight + (1.0f - shadow) * v_lightDiffuse;
2424

25-
vec4 diffuse = lighting * texture;
25+
vec4 diffuse = (lighting * texture) + texture * v_emission;
2626

2727
#ifdef normalsDebugFlag
2828
diffuse.rgb = v_normal;

core/assets/graphics/shaders/terrain.vert.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ varying vec2 v_uvStart;
1313
varying vec2 v_uvMul;
1414

1515
varying float v_transparent;
16+
varying float v_emission;
1617
varying vec4 v_positionInLightSpace;
1718

1819
void main() {
1920
v_normal = normalize(u_normalMatrix * a_normal);
2021
float ao = a_material.r;
21-
float emission = a_material.g;
22+
v_emission = a_material.g;
2223
float waviness = a_material.a;
2324
v_transparent = a_material.b;
2425

core/src/macbury/forge/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Config {
1717
public enum RenderDebug {
1818
Textured, Wireframe, Normals, Lighting
1919
}
20-
public int bloomTextureSize = 512;
20+
public int bloomTextureSize = 256;
2121
public int resolutionWidth = 1360;
2222
public int resolutionHeight = 768;
2323
public boolean fullscreen = false;

core/src/macbury/forge/blocks/Block.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public Side faceToSide(Side alginTo) {
7171
* Is a liquid block
7272
*/
7373
public boolean liquid = false;
74-
74+
/**
75+
* Is emit light...
76+
*/
77+
public float emission = 0.0f;
7578
/**
7679
* Is block solid and collidable
7780
*/

core/src/macbury/forge/graphics/mesh/MeshVertexInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public static VertexAttribute[] voxelAttributes() {
4545
return vertexAttributes;
4646
}
4747

48+
public MeshVertexInfo emission(float emission) {
49+
this.material.setEmission(emission);
50+
return this;
51+
}
52+
4853
public static enum AttributeType {
4954
Position(VertexAttributes.Usage.Position, 3,ShaderProgram.POSITION_ATTRIBUTE),
5055
Normal(VertexAttributes.Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE),

core/src/macbury/forge/graphics/mesh/VoxelsAssembler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void vertexTranslationFromShape(Vector3i origin, Vector3i voxelSca
4545
}
4646

4747
private MeshVertexInfo vertex(VoxelDef voxelDef, BlockShapePart part, int index, TextureAtlas.AtlasRegion sideRegion, AbstractGreedyAlgorithm.GreedyQuad terrainPart) {
48-
MeshVertexInfo vert = this.vertex().ao(voxelDef.ao).transparent(voxelDef.block.transparent);
48+
MeshVertexInfo vert = this.vertex().ao(voxelDef.ao).transparent(voxelDef.block.transparent).emission(voxelDef.block.emission);
4949

5050
vertexTranslationFromShape(
5151
voxelDef.position,
@@ -108,6 +108,7 @@ private MeshVertexInfo vertex(VoxelDef voxelDef, BlockShapePart part, int index,
108108
vert.material.setWaviness(part.waviness[index]);
109109
}
110110

111+
111112
return vert;
112113
}
113114

0 commit comments

Comments
 (0)