Skip to content

Commit

Permalink
Emissive blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
macbury committed Aug 26, 2015
1 parent 628f4a5 commit 16cbd45
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/assets/db/blocks/020_glow_stone.block
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
shadeAO: false,
envAO: false,
transparent: false,
emission: 1.0f,
textures: {
all: "glow_stone"
}
Expand Down
2 changes: 1 addition & 1 deletion core/assets/graphics/shaders/ps-bloom.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ varying vec2 v_texCoords;
void main() {
vec4 sum = vec4(0.0);

float blurSize = 0.004f;
float blurSize = 0.002f;
/*
sum += texture2D(u_downSampledMainTexture, vec2(v_texCoords.x, v_texCoords.y - 4.0*blurSize)) * 0.05;
sum += texture2D(u_downSampledMainTexture, vec2(v_texCoords.x, v_texCoords.y - 3.0*blurSize)) * 0.09;
Expand Down
4 changes: 2 additions & 2 deletions core/assets/graphics/shaders/terrain.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ varying float v_transparent;
varying vec2 v_uvStart;
varying vec2 v_uvMul;
varying vec4 v_positionInLightSpace;

varying float v_emission;
void main() {
discardIfClipped(v_position);

Expand All @@ -22,7 +22,7 @@ void main() {

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

vec4 diffuse = lighting * texture;
vec4 diffuse = (lighting * texture) + texture * v_emission;

#ifdef normalsDebugFlag
diffuse.rgb = v_normal;
Expand Down
3 changes: 2 additions & 1 deletion core/assets/graphics/shaders/terrain.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ varying vec2 v_uvStart;
varying vec2 v_uvMul;

varying float v_transparent;
varying float v_emission;
varying vec4 v_positionInLightSpace;

void main() {
v_normal = normalize(u_normalMatrix * a_normal);
float ao = a_material.r;
float emission = a_material.g;
v_emission = a_material.g;
float waviness = a_material.a;
v_transparent = a_material.b;

Expand Down
2 changes: 1 addition & 1 deletion core/src/macbury/forge/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Config {
public enum RenderDebug {
Textured, Wireframe, Normals, Lighting
}
public int bloomTextureSize = 512;
public int bloomTextureSize = 256;
public int resolutionWidth = 1360;
public int resolutionHeight = 768;
public boolean fullscreen = false;
Expand Down
5 changes: 4 additions & 1 deletion core/src/macbury/forge/blocks/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public Side faceToSide(Side alginTo) {
* Is a liquid block
*/
public boolean liquid = false;

/**
* Is emit light...
*/
public float emission = 0.0f;
/**
* Is block solid and collidable
*/
Expand Down
5 changes: 5 additions & 0 deletions core/src/macbury/forge/graphics/mesh/MeshVertexInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static VertexAttribute[] voxelAttributes() {
return vertexAttributes;
}

public MeshVertexInfo emission(float emission) {
this.material.setEmission(emission);
return this;
}

public static enum AttributeType {
Position(VertexAttributes.Usage.Position, 3,ShaderProgram.POSITION_ATTRIBUTE),
Normal(VertexAttributes.Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE),
Expand Down
3 changes: 2 additions & 1 deletion core/src/macbury/forge/graphics/mesh/VoxelsAssembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void vertexTranslationFromShape(Vector3i origin, Vector3i voxelSca
}

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

vertexTranslationFromShape(
voxelDef.position,
Expand Down Expand Up @@ -108,6 +108,7 @@ private MeshVertexInfo vertex(VoxelDef voxelDef, BlockShapePart part, int index,
vert.material.setWaviness(part.waviness[index]);
}


return vert;
}

Expand Down

0 comments on commit 16cbd45

Please sign in to comment.