finished game-engine-terrain-generation #2

Merged
sebastian merged 9 commits from game-engine-terrain-generation into game-engine 2023-10-05 14:00:29 +02:00
5 changed files with 21 additions and 1 deletions
Showing only changes of commit db7c533206 - Show all commits

BIN
client/res/hexagon.blend Normal file

Binary file not shown.

View File

@ -44,6 +44,7 @@ public class TerrainRenderer {
GL20.glEnableVertexAttribArray(2);
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, terrainTile.getModel().getModelTexture().getTextureID());
shader.loadTerrainColor(terrainTile.getColor());
}
private void unbindTexturedModel() {

View File

@ -4,6 +4,7 @@ import core.engine.entity.Camera;
import core.engine.entity.Light;
import utils.MatrixGraphicUtils;
import utils.vectors.Matrix4f;
import utils.vectors.Vector3f;
public class TerrainShader extends ShaderProgram{
private static final String VERTEX_FILE = "src/main/java/core/engine/shader/terrainVertexShader.glsl";
@ -14,6 +15,7 @@ public class TerrainShader extends ShaderProgram{
private int location_viewMatrix;
private int location_lightPosition;
private int location_lightColor;
private int location_terrainColor;
public TerrainShader() {
super(VERTEX_FILE, FRAGMENT_FILE);
}
@ -25,6 +27,7 @@ public class TerrainShader extends ShaderProgram{
this.location_viewMatrix = super.getUniformLocation("viewMatrix");
this.location_lightColor = super.getUniformLocation("lightColor");
this.location_lightPosition = super.getUniformLocation("lightPosition");
this.location_terrainColor = super.getUniformLocation("terrainColor");
}
@Override
@ -51,4 +54,8 @@ public class TerrainShader extends ShaderProgram{
super.loadVector(location_lightPosition, light.getPosition());
super.loadVector(location_lightColor, light.getColor());
}
public void loadTerrainColor(Vector3f color) {
super.loadVector(location_terrainColor, color);
}
}

View File

@ -8,6 +8,7 @@ out vec4 out_Color;
uniform sampler2D textureSampler;
uniform vec3 lightColor;
uniform vec3 terrainColor;
void main(void) {
vec3 unitNormal = normalize(surfaceNormal);
@ -17,5 +18,5 @@ void main(void) {
float brightness = max(nDotl, 0.2);
vec3 diffusde = brightness * lightColor;
out_Color = texture(textureSampler, pass_textureCoords);
out_Color = /*vec4(diffusde, 1.0) **/ vec4(terrainColor, 1);
}

View File

@ -13,6 +13,8 @@ public class TerrainTile {
private float rotX, rotY, rotZ;
private float scale;
private Vector3f color;
public TerrainTile(TexturedModel model, Vector3f position, float rotX, float rotY, float rotZ, float scale) {
this.model = model;
this.position = position;
@ -20,6 +22,7 @@ public class TerrainTile {
this.rotY = rotY;
this.rotZ = rotZ;
this.scale = scale;
this.color = new Vector3f((float) Math.random(), (float) Math.random(), (float) Math.random());
}
public TexturedModel getModel() {
@ -69,4 +72,12 @@ public class TerrainTile {
public void setScale(float scale) {
this.scale = scale;
}
public Vector3f getColor() {
return color;
}
public void setColor(Vector3f color) {
this.color = color;
}
}