Fix particle placement on spawn
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-11-25 19:39:03 -05:00
parent 46fc63bc63
commit a1eb17cb51
8 changed files with 47 additions and 24 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Sun Nov 24 15:46:03 EST 2024 #Mon Nov 25 18:13:49 EST 2024
buildNumber=404 buildNumber=405

View File

@ -1162,6 +1162,7 @@ Geometry mesh generation class
Cloud shader Cloud shader
VisualShader refactoring VisualShader refactoring
VisualShader #include macro implementation VisualShader #include macro implementation
Fix particles not spawning in correct positions
# TODO # TODO
@ -1190,12 +1191,10 @@ Implement gadgets
Bug Fixes Bug Fixes
- Fix hitbox placement does not scale with entity scale on server - Fix hitbox placement does not scale with entity scale on server
- Fix not all grass tiles update when updating a nearby voxel (ie it doesn't go into negative coordinates to scan for foliage updates)
- Calculate bounding sphere for meshes by deforming vertices with bone default pose instead of no bone deform - Calculate bounding sphere for meshes by deforming vertices with bone default pose instead of no bone deform
- Fix light cluster mapping for foliage shader - Fix light cluster mapping for foliage shader
- Fix foliage placement - Fix foliage placement
- Fix block tree preventing initiating an attack - Fix block tree preventing initiating an attack
- Fix particles not spawning in correct positions
- Fix flickering when applying yoga signal (may need to rethink arch here) - Fix flickering when applying yoga signal (may need to rethink arch here)
- Fix virtual scrollables not working - Fix virtual scrollables not working
- Fix foliage flickering on edit - Fix foliage flickering on edit
@ -1220,8 +1219,7 @@ Code Generation
Rearchitecting Rearchitecting
- Main render is a ui element (that we can have multiple of) - Main render is a ui element (that we can have multiple of)
- Shader handling updates to allow for library based shader compilation - Shader injecting consts from the engine itself (ie max lights is dynamically injected, that way never have to worry about .glsl and .java not aligning)
- Also allow injecting consts from the engine itself (ie max lights is dynamically injected, that way never have to worry about .glsl and .java not aligning)
- Cache busting for particle atlas cache - Cache busting for particle atlas cache
Code cleanup Code cleanup
@ -1269,9 +1267,6 @@ More Debug menus
Revisit first attempt at instancing (its really laggy lol) Revisit first attempt at instancing (its really laggy lol)
- Maybe have draw call happen on top level entity and immediately queue all children recursively - Maybe have draw call happen on top level entity and immediately queue all children recursively
Shader library system
- Abiltiy to include the shader library in individual files (ie implement #include)
Another pass at grass Another pass at grass
- Multiple foliage models in same cell - Multiple foliage models in same cell

View File

@ -11,13 +11,19 @@ import electrosphere.renderer.buffer.HomogenousUniformBuffer.HomogenousBufferTyp
*/ */
public class InstanceTemplate { public class InstanceTemplate {
//The path for the model for this instance /**
* The path for the model for this instance
*/
protected String modelPath; protected String modelPath;
//The total number of instances to draw at a given time /**
* The total number of instances to draw at a given time
*/
protected int capacity; protected int capacity;
//The map of all attributes for instanced foliage /**
* The map of all attributes for instanced foliage
*/
protected Map<ShaderAttribute,HomogenousBufferTypes> attributes; protected Map<ShaderAttribute,HomogenousBufferTypes> attributes;
/** /**
@ -30,8 +36,14 @@ public class InstanceTemplate {
*/ */
int dataBindPoint; int dataBindPoint;
//shader paths /**
* Vertex shader path
*/
protected String vertexPath; protected String vertexPath;
/**
* Fragment shader path
*/
protected String fragmentPath; protected String fragmentPath;
/** /**

View File

@ -3,6 +3,7 @@ package electrosphere.client.entity.particle;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import electrosphere.client.entity.instance.InstanceTemplate; import electrosphere.client.entity.instance.InstanceTemplate;
@ -141,13 +142,16 @@ public class ParticleService extends SignalServiceImpl {
* Spawns a particle * Spawns a particle
* @param data The particle data for the particle * @param data The particle data for the particle
* @param position The position of the particle * @param position The position of the particle
* @param rotation The rotation of the particle
* @return The particle * @return The particle
*/ */
public Entity spawn(ParticleData data, Vector3d position){ public Entity spawn(ParticleData data, Vector3d position, Quaterniond rotation){
Entity rVal = EntityCreationUtils.createClientSpatialEntity(); Entity rVal = EntityCreationUtils.createClientSpatialEntity();
InstancedEntityUtils.makeEntityInstanced(rVal, instanceTemplate); InstancedEntityUtils.makeEntityInstancedWithModelTransform(rVal, instanceTemplate, modelAttrib);
DrawableUtils.makeEntityTransparent(rVal); DrawableUtils.makeEntityTransparent(rVal);
EntityUtils.getPosition(rVal).set(position); EntityUtils.getPosition(rVal).set(position);
EntityUtils.getRotation(rVal).set(rotation);
EntityUtils.getScale(rVal).set(data.getSize());
ClientParticleTree.attachTree(rVal, data); ClientParticleTree.attachTree(rVal, data);
return rVal; return rVal;
} }

View File

@ -47,10 +47,11 @@ public class ClientParticleEmitterComponent implements BehaviorTree {
lastEmittedFrame = Globals.timekeeper.getNumberOfRenderFramesElapsed(); lastEmittedFrame = Globals.timekeeper.getNumberOfRenderFramesElapsed();
//create particle here //create particle here
Vector3d spawnPos = new Vector3d(entityPos); Vector3d spawnPos = new Vector3d(entityPos);
Quaterniond rotation = new Quaterniond(EntityUtils.getRotation(parent));
if(this.particleEmitter.getOffset() != null){ if(this.particleEmitter.getOffset() != null){
spawnPos = spawnPos.add(new Vector3d(this.particleEmitter.getOffset()).rotate(new Quaterniond(EntityUtils.getRotation(parent)))); spawnPos = spawnPos.add(new Vector3d(this.particleEmitter.getOffset()).rotate(rotation));
} }
Globals.particleService.spawn(this.getData(), spawnPos); Globals.particleService.spawn(this.getData(), spawnPos, rotation);
} }
} }

View File

@ -101,7 +101,7 @@ public class ClientParticleTree implements BehaviorTree {
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera); Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
//update position //update position
position = position.set(new Vector3d(position).add(velocity)); position.add(velocity);
EntityUtils.getPosition(parent).set(position); EntityUtils.getPosition(parent).set(position);
//update velocity //update velocity
@ -113,7 +113,7 @@ public class ClientParticleTree implements BehaviorTree {
} }
//add radial acceleration //add radial acceleration
if(this.emitterData.getRadialAcceleration() != null){ if(this.emitterData.getRadialAcceleration() != null){
Vector3d towardsParent = new Vector3d(EntityUtils.getPosition(this.particleData.getParentEmitter())).sub(position).normalize().mul(this.emitterData.getRadialAcceleration()); Vector3d towardsParent = new Vector3d(EntityUtils.getPosition(this.particleData.getParentEmitter())).sub(position.x, position.y, position.z).normalize().mul(this.emitterData.getRadialAcceleration());
velocity = velocity.add(towardsParent); velocity = velocity.add(towardsParent);
} }
@ -155,7 +155,7 @@ public class ClientParticleTree implements BehaviorTree {
TextureAtlas particleTextureAtlas = Globals.particleService.getTextureAtlas(); TextureAtlas particleTextureAtlas = Globals.particleService.getTextureAtlas();
int textureIndex = particleTextureAtlas.getTextureIndex(this.particleData.getTexture()); int textureIndex = particleTextureAtlas.getTextureIndex(this.particleData.getTexture());
instancedActor.setAttribute(Globals.particleService.getModelAttrib(), new Matrix4f().translationRotateScale( instancedActor.setAttribute(Globals.particleService.getModelAttrib(), new Matrix4f().translationRotateScale(
new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(cameraPos), new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(cameraPos.x, cameraPos.y, cameraPos.z),
new Quaternionf(rotation), new Quaternionf(rotation),
scale scale
)); ));

View File

@ -26,14 +26,25 @@ import electrosphere.renderer.model.Model;
* An instanced actor is a static (not bone animated) actor for an instanced model (eg grass, trees, leaves, rocks, etc) * An instanced actor is a static (not bone animated) actor for an instanced model (eg grass, trees, leaves, rocks, etc)
*/ */
public class InstancedActor implements Comparable<InstancedActor> { public class InstancedActor implements Comparable<InstancedActor> {
//path of the model that this instanced actor uses
/**
* Path of the model that this instanced actor uses
*/
String modelPath; String modelPath;
//priority and index used for deciding to draw this and where in the data array it is /**
* priority used for deciding to draw this actor or not
*/
int priority; int priority;
/**
* Index used for deciding where in the data array it is
*/
int index; int index;
//actually unique information about the instance /**
* Actually unique information about the instance
*/
Map<ShaderAttribute,Object> attributes = new HashMap<ShaderAttribute,Object>(); Map<ShaderAttribute,Object> attributes = new HashMap<ShaderAttribute,Object>();
/** /**

View File

@ -117,7 +117,7 @@ public class MainContentPipeline implements RenderPipeline {
} }
} }
//draw all instanced models //draw all instanced models
Globals.clientInstanceManager.draw(renderPipelineState,openGLState); Globals.clientInstanceManager.draw(renderPipelineState, openGLState);
this.firstPersonSubPipeline.render(openGLState, renderPipelineState); this.firstPersonSubPipeline.render(openGLState, renderPipelineState);
// //