Proper texture tiling for terrain meshes
This commit is contained in:
parent
c295a18a22
commit
26064dc198
@ -2,8 +2,8 @@
|
|||||||
"gameplayGenerateWorld" : false,
|
"gameplayGenerateWorld" : false,
|
||||||
"gameplayPhysicsCellRadius" : 2,
|
"gameplayPhysicsCellRadius" : 2,
|
||||||
|
|
||||||
"displayWidth" : 2560,
|
"displayWidth" : 1920,
|
||||||
"displayHeight" : 1600,
|
"displayHeight" : 1080,
|
||||||
|
|
||||||
"graphicsFOV" : 90.0,
|
"graphicsFOV" : 90.0,
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ void main(){
|
|||||||
//}
|
//}
|
||||||
//result += CalcSpotLight(spotLight, norm, FragPos, viewDir);
|
//result += CalcSpotLight(spotLight, norm, FragPos, viewDir);
|
||||||
|
|
||||||
FragColor = vec4(result, texture(material.diffuse, TexCoord).a);//texture(ourTexture, TexCoord);//vec4(result, 1.0);
|
FragColor = vec4(result, 1);//texture(ourTexture, TexCoord);//vec4(result, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculates the color when using a directional light.
|
// calculates the color when using a directional light.
|
||||||
@ -233,5 +233,5 @@ vec3 blendedTextureColor(vec2 texPos, vec4 tex1, vec4 tex2, vec4 tex3, vec4 tex4
|
|||||||
// float percentTex2 = (texPos.x - 0) * (texPos.y - 1);
|
// float percentTex2 = (texPos.x - 0) * (texPos.y - 1);
|
||||||
// float percentTex3 = (texPos.x - 1) * (texPos.y - 0);
|
// float percentTex3 = (texPos.x - 1) * (texPos.y - 0);
|
||||||
// float percentTex4 = (texPos.x - 0) * (texPos.y - 0);
|
// float percentTex4 = (texPos.x - 0) * (texPos.y - 0);
|
||||||
return vec3(0,0,0);//mix(mix(tex1,tex2,texPos.x),mix(tex3,tex4,texPos.x),texPos.y).rgb;
|
return mix(mix(tex1,tex2,texPos.x),mix(tex3,tex4,texPos.x),texPos.y).rgb;
|
||||||
}
|
}
|
||||||
@ -10,9 +10,11 @@ import electrosphere.game.collision.collidable.Collidable;
|
|||||||
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
|
import electrosphere.renderer.Mesh;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
import electrosphere.renderer.ModelUtils;
|
import electrosphere.renderer.ModelUtils;
|
||||||
import electrosphere.renderer.ShaderProgram;
|
import electrosphere.renderer.ShaderProgram;
|
||||||
|
import electrosphere.renderer.texture.Texture;
|
||||||
import electrosphere.util.Utilities;
|
import electrosphere.util.Utilities;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
@ -35,7 +37,17 @@ public class DrawCell {
|
|||||||
|
|
||||||
CollisionObject physicsObject;
|
CollisionObject physicsObject;
|
||||||
|
|
||||||
|
static Texture groundTextureOne;
|
||||||
|
static Texture groundTextureTwo;
|
||||||
|
static Texture groundTextureThree;
|
||||||
|
static Texture groundTextureFour;
|
||||||
|
|
||||||
|
static {
|
||||||
|
groundTextureOne = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
|
groundTextureTwo = new Texture("/Textures/wheat1.png");
|
||||||
|
groundTextureThree = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
|
groundTextureFour = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DrawCell(){
|
DrawCell(){
|
||||||
@ -52,12 +64,7 @@ public class DrawCell {
|
|||||||
* ITS NOT EVEN UP TO DATE!
|
* ITS NOT EVEN UP TO DATE!
|
||||||
* 06/13/2021
|
* 06/13/2021
|
||||||
*
|
*
|
||||||
* @param drawArray
|
* //@param drawArray
|
||||||
* @param drawWidth
|
|
||||||
* @param cellX
|
|
||||||
* @param cellY
|
|
||||||
* @param cellWidth
|
|
||||||
* @param program
|
|
||||||
*/
|
*/
|
||||||
public static DrawCell generateTerrainCell(
|
public static DrawCell generateTerrainCell(
|
||||||
int cellX,
|
int cellX,
|
||||||
@ -84,6 +91,12 @@ public class DrawCell {
|
|||||||
Globals.entityManager.deregisterEntity(modelEntity);
|
Globals.entityManager.deregisterEntity(modelEntity);
|
||||||
}
|
}
|
||||||
Model terrainModel = ModelUtils.createTerrainModelPrecomputedShader(heightmap, program, stride);
|
Model terrainModel = ModelUtils.createTerrainModelPrecomputedShader(heightmap, program, stride);
|
||||||
|
Mesh terrainMesh = terrainModel.meshes.get(0);
|
||||||
|
terrainMesh.useTextureList = true;
|
||||||
|
terrainMesh.textureList.add(groundTextureOne);
|
||||||
|
terrainMesh.textureList.add(groundTextureTwo);
|
||||||
|
terrainMesh.textureList.add(groundTextureThree);
|
||||||
|
terrainMesh.textureList.add(groundTextureFour);
|
||||||
String terrainModelPath = Globals.assetManager.registerModel(terrainModel);
|
String terrainModelPath = Globals.assetManager.registerModel(terrainModel);
|
||||||
modelEntity = EntityUtils.spawnDrawableEntity(terrainModelPath);
|
modelEntity = EntityUtils.spawnDrawableEntity(terrainModelPath);
|
||||||
modelEntity.putData(EntityDataStrings.TERRAIN_IS_TERRAIN, true);
|
modelEntity.putData(EntityDataStrings.TERRAIN_IS_TERRAIN, true);
|
||||||
|
|||||||
@ -94,7 +94,7 @@ public class DrawCellManager {
|
|||||||
cellX = discreteX;
|
cellX = discreteX;
|
||||||
cellY = discreteY;
|
cellY = discreteY;
|
||||||
|
|
||||||
program = Globals.defaultMeshShader;
|
program = Globals.terrainShaderProgram;
|
||||||
|
|
||||||
drawRadius = Globals.userSettings.getGraphicsPerformanceLODChunkRadius();
|
drawRadius = Globals.userSettings.getGraphicsPerformanceLODChunkRadius();
|
||||||
drawStepdownInterval = Globals.userSettings.getGameplayPhysicsCellRadius();
|
drawStepdownInterval = Globals.userSettings.getGameplayPhysicsCellRadius();
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class Mesh {
|
|||||||
boolean hasBones = true;
|
boolean hasBones = true;
|
||||||
public boolean hasTextureCoords = true;
|
public boolean hasTextureCoords = true;
|
||||||
|
|
||||||
public List<Texture> textureList;
|
public List<Texture> textureList = new ArrayList();
|
||||||
public boolean useTextureList;
|
public boolean useTextureList;
|
||||||
public String textureListArrayUniformName;
|
public String textureListArrayUniformName;
|
||||||
|
|
||||||
@ -758,11 +758,7 @@ public class Mesh {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(useTextureList){
|
|
||||||
for(Texture texture : textureList){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -774,6 +770,16 @@ public class Mesh {
|
|||||||
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "shadowMap"), 3);
|
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "shadowMap"), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(useTextureList){
|
||||||
|
int i = 0;
|
||||||
|
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "groundTextures"),4);
|
||||||
|
for(Texture texture : textureList){
|
||||||
|
// glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "groundTextures[" + 4+i*2 + "]"),4+i*2);
|
||||||
|
texture.bind(4+i*2);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(setBones){
|
if(setBones){
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user