This commit is contained in:
parent
172030b95d
commit
3bfcc4c5d1
@ -32,6 +32,7 @@ uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
uniform vec3 viewPos;
|
||||
uniform vec3 modelWorldPos;
|
||||
uniform float time;
|
||||
|
||||
|
||||
@ -77,7 +78,12 @@ void main() {
|
||||
|
||||
//
|
||||
//curve float noise
|
||||
vec4 worldPos = model * vec4(aPos.x + xOffset,aPos.y + yOffset,aPos.z + zOffset,1.0);
|
||||
vec4 worldPos = vec4(
|
||||
xOffset + modelWorldPos.x,
|
||||
yOffset + modelWorldPos.y,
|
||||
zOffset + modelWorldPos.z,
|
||||
1.0
|
||||
);
|
||||
float curveFloatNoiseSample = clamp(map(openSimplex2_ImproveXY(vec3(worldPos.x,worldPos.z,time)).x,-1.0,1.0,0,1),0,1);
|
||||
|
||||
//
|
||||
@ -86,12 +92,27 @@ void main() {
|
||||
mat4 localRot = rotation3dY(rotVar);
|
||||
mat4 localRot2 = rotation3dZ(curveAmount);
|
||||
|
||||
float windDirectionSpeedMagnitude = 0.05;
|
||||
vec3 windDirectionMovementOverTime = vec3(
|
||||
windDirectionSpeedMagnitude * time,
|
||||
windDirectionSpeedMagnitude * time,
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
float windStrengthMagnitude = 0.2;
|
||||
vec3 windStrengthOverTime = vec3(
|
||||
windStrengthMagnitude * time,
|
||||
windStrengthMagnitude * time,
|
||||
0
|
||||
);
|
||||
|
||||
//
|
||||
//rotate with wind
|
||||
float windDir = clamp(map(openSimplex2_ImproveXY(vec3(worldPos.x,worldPos.z,0) * 0.05 + 0.05 * time * vec3(1,1,0)).x,-1.0,1.0,0,1),0,1);
|
||||
float windDir = clamp(map(openSimplex2_ImproveXY(vec3(worldPos.x,worldPos.z,0) * 0.05 + windDirectionMovementOverTime).x,-1.0,1.0,0,1),0,1);
|
||||
windDir = map(windDir,0.0,1.0,0.0,PI * 2.0);
|
||||
//strength
|
||||
float windStrength = clamp(map(openSimplex2_ImproveXY(vec3(worldPos.x,worldPos.z,0) * 0.25 + 0.2 * time * vec3(1,1,0)).x,-3.0,3.0,0,1),0,1);
|
||||
float windStrength = clamp(map(openSimplex2_ImproveXY(vec3(worldPos.x,worldPos.z,0) * 0.2 + windStrengthOverTime).x,-3.0,3.0,0,1),0,1);
|
||||
//try to shape with easeIn
|
||||
float windLeanAngle = map(windStrength, 0.0, 1.0, 0.1, 0.9);
|
||||
windLeanAngle = easeIn(windLeanAngle) * 1.25;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Sun Apr 14 15:53:43 EDT 2024
|
||||
buildNumber=98
|
||||
#Sun Apr 21 21:07:34 EDT 2024
|
||||
buildNumber=101
|
||||
|
||||
@ -222,8 +222,7 @@ UI Work
|
||||
|
||||
Fix Movement Bug where player keeps running after releasing control
|
||||
|
||||
# TODO
|
||||
|
||||
(04/21/2024)
|
||||
UI Fixes
|
||||
- Refactor ui toolkit elements to separate absolute and relative position
|
||||
- Fix inventory menus
|
||||
@ -236,6 +235,26 @@ More Debug menus
|
||||
- Screen that shows the overall status of client scene
|
||||
- Number of entities
|
||||
- Maybe a listing of each one?
|
||||
|
||||
Another pass at grass
|
||||
- Fix shader being camera position independent (if you move the wind moves with you lol)
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
Data Cleanup
|
||||
- Clean up creatures
|
||||
- Remove unused ones
|
||||
- Fix values for movement now that physics has changed
|
||||
- Fix characters bouncing when landing from a fall
|
||||
- Clean up unused models
|
||||
- Clean up textures
|
||||
- Move model textures into models
|
||||
- Recursive model transform data
|
||||
- Clean up audio
|
||||
- Fix ui audio effects having play times that are wayyyy too long
|
||||
|
||||
More Debug menus
|
||||
- Screen that shows the overall status of draw cell manager
|
||||
- Screen that shows the overall status of fluid cell manager
|
||||
- Screen that shows the overall status of realm 0
|
||||
@ -264,7 +283,6 @@ Transvoxel Algorithm
|
||||
- Rewrite marching cubes shader to leverage this atlas
|
||||
|
||||
Another pass at grass
|
||||
- Fix shader being camera position independent (if you move the wind moves with you lol)
|
||||
- Multiple foliage models in same cell
|
||||
|
||||
Build a lod system
|
||||
|
||||
@ -450,7 +450,7 @@ public class ClientFoliageManager {
|
||||
TextureInstancedActor.attachTextureInstancedActor(grassEntity, foliageType.getModelPath(), vertexPath, fragmentPath, dataTexture, drawCount);
|
||||
EntityUtils.getPosition(grassEntity).set(realPos);
|
||||
EntityUtils.getRotation(grassEntity).set(0,0,0,1);
|
||||
EntityUtils.getScale(grassEntity).set(new Vector3d(4.0, 4.0, 4.0));
|
||||
EntityUtils.getScale(grassEntity).set(1,1,1);
|
||||
//add ambient foliage behavior tree
|
||||
AmbientFoliage.attachAmbientFoliageTree(grassEntity, initialGrowthLevel, foliageType.getGrowthModel().getGrowthRate());
|
||||
cell.addEntity(grassEntity);
|
||||
|
||||
@ -104,7 +104,7 @@ public class FoliageCell {
|
||||
modelMatrix.translate(cameraModifiedPosition);
|
||||
modelMatrix.rotate(new Quaterniond(grassRotation));
|
||||
modelMatrix.scale(new Vector3d(EntityUtils.getScale(entity)));
|
||||
actor.applyModelMatrix(modelMatrix);
|
||||
actor.applySpatialData(modelMatrix,grassPosition);
|
||||
|
||||
|
||||
//draw
|
||||
|
||||
@ -187,10 +187,16 @@ public class Actor {
|
||||
this.animationScalar = animationScalar;
|
||||
}
|
||||
|
||||
public void applyModelMatrix(Matrix4d modelMatrix){
|
||||
/**
|
||||
* Applies spatial data on the actor, this includes the model matrix as well as the real world position
|
||||
* @param modelMatrix The model matrix
|
||||
* @param worldPos The world position of the model
|
||||
*/
|
||||
public void applySpatialData(Matrix4d modelMatrix, Vector3d worldPos){
|
||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||
if(model != null){
|
||||
model.setModelMatrix(modelMatrix);
|
||||
model.setWorldPos(worldPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.renderer.actor.instance;
|
||||
|
||||
import org.joml.Matrix4d;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
@ -68,12 +69,14 @@ public class TextureInstancedActor {
|
||||
boolean materialState = renderPipelineState.getUseMaterial();
|
||||
boolean useShader = renderPipelineState.getUseMeshShader();
|
||||
boolean bufferStandardUniforms = renderPipelineState.getBufferStandardUniforms();
|
||||
boolean bufferNonStandardUniforms = renderPipelineState.getBufferNonStandardUniforms();
|
||||
boolean useLight = renderPipelineState.getUseLight();
|
||||
renderPipelineState.setInstanced(true);
|
||||
renderPipelineState.setUseMaterial(false);
|
||||
renderPipelineState.setUseMeshShader(false);
|
||||
renderPipelineState.setInstanceCount(drawCount);
|
||||
renderPipelineState.setBufferStandardUniforms(true);
|
||||
renderPipelineState.setBufferNonStandardUniforms(true);
|
||||
renderPipelineState.setUseLight(true);
|
||||
renderPipelineState.setInstanceData(null); //need to set the instance data to null otherwise it will overwrite what we currently have set (ie overwrite draw calls count, etc)
|
||||
|
||||
@ -87,6 +90,7 @@ public class TextureInstancedActor {
|
||||
renderPipelineState.setUseMaterial(materialState);
|
||||
renderPipelineState.setUseMeshShader(useShader);
|
||||
renderPipelineState.setBufferStandardUniforms(bufferStandardUniforms);
|
||||
renderPipelineState.setBufferNonStandardUniforms(bufferNonStandardUniforms);
|
||||
renderPipelineState.setUseLight(useLight);
|
||||
}
|
||||
}
|
||||
@ -109,13 +113,15 @@ public class TextureInstancedActor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the model matrix to the model underlying this textured instanced actor
|
||||
* Applies spatial data on the actor, this includes the model matrix as well as the real world position
|
||||
* @param modelMatrix The model matrix
|
||||
* @param worldPos the real world coordinates of the model
|
||||
*/
|
||||
public void applyModelMatrix(Matrix4d modelMatrix){
|
||||
public void applySpatialData(Matrix4d modelMatrix, Vector3d worldPos){
|
||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||
if(model != null){
|
||||
model.setModelMatrix(modelMatrix);
|
||||
model.setWorldPos(worldPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import org.lwjgl.opengl.GL20;
|
||||
import static org.lwjgl.opengl.GL40.*;
|
||||
|
||||
import org.lwjgl.opengl.GL45;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
/**
|
||||
* A mesh, a collection of buffer data on the GPU
|
||||
@ -433,13 +434,17 @@ public class Mesh {
|
||||
|
||||
if(renderPipelineState.getBufferStandardUniforms()){
|
||||
//buffer model/view/proj matrices
|
||||
GL45.glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexModelLoc, false, parent.getModelMatrix().get(new float[16]));
|
||||
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexViewLoc, false, Globals.viewMatrix.get(new float[16]));
|
||||
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
||||
glUniform3fv(openGLState.getActiveShader().shaderVertexViewPosLoc, CameraEntityUtils.getCameraEye(Globals.playerCamera).get(BufferUtils.createFloatBuffer(3)));
|
||||
glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
glUniform1f(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "time"), (float)Globals.timekeeper.getCurrentRendererTime());
|
||||
try(MemoryStack stack = MemoryStack.stackPush()){
|
||||
GL45.glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexModelLoc, false, parent.getModelMatrix().get(new float[16]));
|
||||
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexViewLoc, false, Globals.viewMatrix.get(new float[16]));
|
||||
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
||||
glUniform3fv(openGLState.getActiveShader().shaderVertexViewPosLoc, CameraEntityUtils.getCameraEye(Globals.playerCamera).get(stack.floats(3)));
|
||||
Vector3f worldPos = new Vector3f((float)parent.getWorldPos().x,(float)parent.getWorldPos().y,(float)parent.getWorldPos().z);
|
||||
glUniform3fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "modelWorldPos"), worldPos.get(stack.mallocFloat(3)));
|
||||
glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
glUniform1f(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "time"), (float)Globals.timekeeper.getCurrentRendererTime());
|
||||
}
|
||||
}
|
||||
|
||||
if(renderPipelineState.getBufferNonStandardUniforms()){
|
||||
|
||||
@ -44,6 +44,9 @@ public class Model {
|
||||
//the model matrix for this model
|
||||
private Matrix4d modelMatrix = new Matrix4d();
|
||||
|
||||
//the real world coordinates of this object (not model space)
|
||||
private Vector3d worldPos = new Vector3d();
|
||||
|
||||
//an optional global transform applied to the parent bone. Typically found in models loaded from files
|
||||
private Matrix4d globalInverseTransform = new Matrix4d();
|
||||
|
||||
@ -478,6 +481,22 @@ public class Model {
|
||||
return modelMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the world position of the model
|
||||
* @param worldPos the world pos
|
||||
*/
|
||||
public void setWorldPos(Vector3d worldPos){
|
||||
this.worldPos = worldPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the world position stored in this model
|
||||
* @return The world pos
|
||||
*/
|
||||
public Vector3d getWorldPos(){
|
||||
return this.worldPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of bones
|
||||
* @return the list of bones
|
||||
|
||||
@ -72,7 +72,7 @@ public class MainContentNoOITPipeline implements RenderPipeline {
|
||||
RenderingEngine.modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
RenderingEngine.modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
RenderingEngine.modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(RenderingEngine.modelTransformMatrix);
|
||||
currentActor.applySpatialData(RenderingEngine.modelTransformMatrix,position);
|
||||
//draw
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||
//draw
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
}
|
||||
@ -169,7 +169,7 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||
//draw
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public class NormalsForOutlinePipeline implements RenderPipeline {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||
//draw
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ public class ShadowMapPipeline implements RenderPipeline {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||
//draw
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class VolumeBufferPipeline implements RenderPipeline {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||
//draw
|
||||
// if(!currentEntity.getDataKeys().contains(EntityDataStrings.TERRAIN_IS_TERRAIN) && !currentEntity.getDataKeys().contains(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE)){
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
@ -124,7 +124,7 @@ public class VolumeBufferPipeline implements RenderPipeline {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
}
|
||||
}
|
||||
@ -171,7 +171,7 @@ public class VolumeBufferPipeline implements RenderPipeline {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||
//draw
|
||||
// if(!currentEntity.getDataKeys().contains(EntityDataStrings.TERRAIN_IS_TERRAIN) && !currentEntity.getDataKeys().contains(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE)){
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
|
||||
@ -124,7 +124,7 @@ public class ActorPanel extends StandardElement implements DrawableElement, Drag
|
||||
|
||||
|
||||
|
||||
actor.applyModelMatrix(modelMatrix);
|
||||
actor.applySpatialData(modelMatrix,new Vector3d(actorPosition));
|
||||
actor.draw(renderPipelineState,openGLState);
|
||||
|
||||
RenderingEngine.setFOV(Globals.verticalFOV);
|
||||
@ -220,7 +220,7 @@ public class ActorPanel extends StandardElement implements DrawableElement, Drag
|
||||
modelMatrix.translate(actorPosition);
|
||||
modelMatrix.rotate(actorRotation);
|
||||
modelMatrix.scale(new Vector3d(actorScale));
|
||||
actor.applyModelMatrix(modelMatrix);
|
||||
actor.applySpatialData(modelMatrix,new Vector3d(actorPosition));
|
||||
}
|
||||
|
||||
public boolean handleEvent(Event event){
|
||||
|
||||
@ -27,7 +27,7 @@ public class ArenaChunkGenerator implements ChunkGenerator {
|
||||
for(int weightX = 0; weightX < ServerTerrainChunk.CHUNK_DIMENSION; weightX++){
|
||||
for(int weightZ = 0; weightZ < ServerTerrainChunk.CHUNK_DIMENSION; weightZ++){
|
||||
weights[weightX][0][weightZ] = 0.1f;
|
||||
values[weightX][0][weightZ] = 1;
|
||||
values[weightX][0][weightZ] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user