delete actorshadermask
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
897b867641
commit
a5d4e2348e
@ -2063,6 +2063,7 @@ Actor code cleanup
|
||||
Refactor animation logic into dedicated actor class
|
||||
Simplify draw call logic
|
||||
Error report on window.java
|
||||
Delete ActorShaderMask
|
||||
|
||||
|
||||
|
||||
|
||||
@ -6,8 +6,8 @@ import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.queue.QueuedAsset;
|
||||
import electrosphere.engine.assetmanager.queue.QueuedShader;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.actor.mask.ActorShaderMask;
|
||||
import electrosphere.renderer.buffer.HomogenousInstancedArray;
|
||||
import electrosphere.renderer.buffer.HomogenousUniformBuffer;
|
||||
import electrosphere.renderer.loading.ModelLoader;
|
||||
@ -58,7 +58,7 @@ public class AssetManager {
|
||||
|
||||
Map<String,VisualShader> shadersLoadedIntoMemory = new HashMap<String,VisualShader>();
|
||||
List<String> shadersInDeleteQueue = new LinkedList<String>();
|
||||
List<ActorShaderMask> shadersInQueue = new LinkedList<ActorShaderMask>();
|
||||
List<QueuedShader> shadersInQueue = new LinkedList<QueuedShader>();
|
||||
|
||||
//
|
||||
//Compute shader related
|
||||
@ -147,7 +147,7 @@ public class AssetManager {
|
||||
//shaders
|
||||
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Load visual shaders");
|
||||
Globals.profiler.beginCpuSample("AssetManager.loadAssetsInQueue - Load visual shaders");
|
||||
for(ActorShaderMask currentShader : shadersInQueue){
|
||||
for(QueuedShader currentShader : shadersInQueue){
|
||||
String key = getShaderKey(currentShader.getVertexShaderPath(),currentShader.getFragmentShaderPath());
|
||||
shadersLoadedIntoMemory.put(
|
||||
key,
|
||||
@ -662,7 +662,7 @@ public class AssetManager {
|
||||
//
|
||||
public void addShaderToQueue(String vertexShader, String fragmentShader){
|
||||
lock.lock();
|
||||
shadersInQueue.add(new ActorShaderMask("","",vertexShader,fragmentShader));
|
||||
shadersInQueue.add(new QueuedShader(vertexShader,fragmentShader));
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@ -688,7 +688,7 @@ public class AssetManager {
|
||||
lock.lock();
|
||||
for(String shaderKey : shadersLoadedIntoMemory.keySet()){
|
||||
String shaderPaths[] = shaderKey.split("-");
|
||||
shadersInQueue.add(new ActorShaderMask("","",shaderPaths[0],shaderPaths[1]));
|
||||
shadersInQueue.add(new QueuedShader(shaderPaths[0],shaderPaths[1]));
|
||||
}
|
||||
shadersLoadedIntoMemory.clear();
|
||||
lock.unlock();
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package electrosphere.engine.assetmanager.queue;
|
||||
|
||||
/**
|
||||
* A shader queued to be created
|
||||
*/
|
||||
public class QueuedShader {
|
||||
|
||||
/**
|
||||
* The vertex shader's path
|
||||
*/
|
||||
private String vertexShaderPath;
|
||||
|
||||
/**
|
||||
* The fragment shader's path
|
||||
*/
|
||||
private String fragmentShaderPath;
|
||||
|
||||
/**
|
||||
* A queued shader
|
||||
* @param vertexShaderPath The vertex shader path
|
||||
* @param fragmentShaderPath The fragment shader path
|
||||
*/
|
||||
public QueuedShader(String vertexShaderPath, String fragmentShaderPath) {
|
||||
this.vertexShaderPath = vertexShaderPath;
|
||||
this.fragmentShaderPath = fragmentShaderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vertex shader's path
|
||||
* @return The vertex shader's path
|
||||
*/
|
||||
public String getVertexShaderPath() {
|
||||
return vertexShaderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fragment shader's path
|
||||
* @return The fragment shader's path
|
||||
*/
|
||||
public String getFragmentShaderPath() {
|
||||
return fragmentShaderPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -6,14 +6,12 @@ import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.actor.mask.ActorAnimationData;
|
||||
import electrosphere.renderer.actor.mask.ActorMeshMask;
|
||||
import electrosphere.renderer.actor.mask.ActorShaderMask;
|
||||
import electrosphere.renderer.actor.mask.ActorTextureMask;
|
||||
import electrosphere.renderer.actor.mask.ActorUniformMap;
|
||||
import electrosphere.renderer.actor.mask.ActorUniformMap.UniformValue;
|
||||
import electrosphere.renderer.model.Model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -119,11 +117,6 @@ public class Actor {
|
||||
*/
|
||||
private ActorMeshMask meshMask = new ActorMeshMask();
|
||||
|
||||
/**
|
||||
* optional overrides for specific shaders
|
||||
*/
|
||||
private List<ActorShaderMask> shaderMasks = new LinkedList<ActorShaderMask>();
|
||||
|
||||
/**
|
||||
* optional overrides for textures
|
||||
*/
|
||||
@ -203,11 +196,6 @@ public class Actor {
|
||||
meshMask.processMeshMaskQueue();
|
||||
model.setMeshMask(meshMask);
|
||||
model.setTextureMask(textureMap);
|
||||
for(ActorShaderMask shaderMask : shaderMasks){
|
||||
if(shaderMask.getModelName().equals(pathToFetch)){
|
||||
model.getShaderMask().put(shaderMask.getMeshName(),shaderMask);
|
||||
}
|
||||
}
|
||||
this.animationData.calculateNodeTransforms(model);
|
||||
//apply uniform overrides
|
||||
if(this.uniformMap.getMeshes() != null && this.uniformMap.getMeshes().size() > 0){
|
||||
@ -219,7 +207,6 @@ public class Actor {
|
||||
}
|
||||
}
|
||||
model.draw(renderPipelineState,openGLState);
|
||||
model.getShaderMask().clear();
|
||||
model.setTextureMask(null);
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
@ -242,7 +229,6 @@ public class Actor {
|
||||
this.animationData.isPlayingAnimation() &&
|
||||
this.meshMask.getBlockedMeshes().size() == 0 &&
|
||||
this.textureMap == null &&
|
||||
this.shaderMasks.size() == 0 &&
|
||||
this.uniformMap.isEmpty() &&
|
||||
this.animationData.getStaticMorph() == null
|
||||
)
|
||||
@ -264,7 +250,6 @@ public class Actor {
|
||||
rVal = rVal + this.animationData.isPlayingAnimation() + "\n";
|
||||
rVal = rVal + (this.meshMask.getBlockedMeshes().size() == 0) + "\n";
|
||||
rVal = rVal + (this.textureMap == null) + "\n";
|
||||
rVal = rVal + (this.shaderMasks.size() == 0) + "\n";
|
||||
rVal = rVal + this.uniformMap.isEmpty() + "\n";
|
||||
rVal = rVal + (this.animationData.getStaticMorph() == null) + "\n";
|
||||
return rVal;
|
||||
@ -323,24 +308,6 @@ public class Actor {
|
||||
return meshMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Masks a shader with another shader
|
||||
* @param mesh The mesh to apply the mask on
|
||||
* @param vertexShader the vertex shader to apply
|
||||
* @param fragmentShader the fragment shader to apply
|
||||
*/
|
||||
public void maskShader(String mesh, String vertexShader, String fragmentShader){
|
||||
shaderMasks.add(new ActorShaderMask(this.baseModelPath, mesh, vertexShader, fragmentShader));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmasks a shader
|
||||
* @param mesh the mesh to unmask
|
||||
*/
|
||||
public void unmaskShader(String mesh){
|
||||
throw new UnsupportedOperationException("Not implemented yet");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a texture mask to this actor
|
||||
* @param textureMask The texture mask
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
@ -36,7 +36,7 @@ public class ActorMeshMask {
|
||||
/**
|
||||
* lock for queueing blockers
|
||||
*/
|
||||
private Semaphore queueLock = new Semaphore(1);
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
/**
|
||||
* The set of queued meshes
|
||||
@ -56,9 +56,9 @@ public class ActorMeshMask {
|
||||
* @param meshName The mesh's name
|
||||
*/
|
||||
public void queueMesh(String modelName, String meshName){
|
||||
queueLock.acquireUninterruptibly();
|
||||
lock.lock();
|
||||
queuedMeshes.add(new MeshDrawQueueItem(modelName, meshName));
|
||||
queueLock.release();
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +67,7 @@ public class ActorMeshMask {
|
||||
public void processMeshMaskQueue(){
|
||||
Model model;
|
||||
Mesh mesh;
|
||||
if(queueLock.tryAcquire()){
|
||||
if(lock.tryLock()){
|
||||
if(queuedMeshes.size() > 0 || queuedBlockers.size() > 0){
|
||||
//process queued meshes
|
||||
List<MeshDrawQueueItem> toRemove = new LinkedList<MeshDrawQueueItem>();
|
||||
@ -96,7 +96,7 @@ public class ActorMeshMask {
|
||||
queuedBlockers.remove(item);
|
||||
}
|
||||
}
|
||||
queueLock.release();
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,9 +152,9 @@ public class ActorMeshMask {
|
||||
* @param meshName The name of the mesh
|
||||
*/
|
||||
public void blockMesh(String modelName, String meshName){
|
||||
queueLock.acquireUninterruptibly();
|
||||
lock.lock();
|
||||
queuedBlockers.add(new MeshDrawQueueItem(modelName, meshName));
|
||||
queueLock.release();
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,74 +0,0 @@
|
||||
package electrosphere.renderer.actor.mask;
|
||||
|
||||
/**
|
||||
* Masks a shader on a mesh with another shader
|
||||
*/
|
||||
public class ActorShaderMask {
|
||||
|
||||
/**
|
||||
* The name of the model
|
||||
*/
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* The name of the mesh to apply the shader to
|
||||
*/
|
||||
private String meshName;
|
||||
|
||||
/**
|
||||
* The vertex shader's path
|
||||
*/
|
||||
private String vertexShaderPath;
|
||||
|
||||
/**
|
||||
* The fragment shader's path
|
||||
*/
|
||||
private String fragmentShaderPath;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param modelName
|
||||
* @param meshName
|
||||
* @param vertexShaderPath
|
||||
* @param fragmentShaderPath
|
||||
*/
|
||||
public ActorShaderMask(String modelName, String meshName, String vertexShaderPath, String fragmentShaderPath){
|
||||
this.modelName = modelName;
|
||||
this.meshName = meshName;
|
||||
this.vertexShaderPath = vertexShaderPath;
|
||||
this.fragmentShaderPath = fragmentShaderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the model name
|
||||
* @return the model name
|
||||
*/
|
||||
public String getModelName(){
|
||||
return modelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mesh name
|
||||
* @return the mesh name
|
||||
*/
|
||||
public String getMeshName(){
|
||||
return meshName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vertex shader path
|
||||
* @return the vertex shader path
|
||||
*/
|
||||
public String getVertexShaderPath(){
|
||||
return vertexShaderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fragment shader path
|
||||
* @return the fragment shader path
|
||||
*/
|
||||
public String getFragmentShaderPath(){
|
||||
return fragmentShaderPath;
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,13 +5,11 @@ import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.actor.ActorBoneRotator;
|
||||
import electrosphere.renderer.actor.ActorStaticMorph;
|
||||
import electrosphere.renderer.actor.mask.ActorMeshMask;
|
||||
import electrosphere.renderer.actor.mask.ActorShaderMask;
|
||||
import electrosphere.renderer.actor.mask.ActorTextureMask;
|
||||
import electrosphere.renderer.anim.AnimChannel;
|
||||
import electrosphere.renderer.anim.Animation;
|
||||
import electrosphere.renderer.loading.ModelPretransforms;
|
||||
import electrosphere.renderer.meshgen.MeshLoader;
|
||||
import electrosphere.renderer.shader.VisualShader;
|
||||
import electrosphere.renderer.anim.AnimNode;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
@ -106,11 +104,6 @@ public class Model {
|
||||
*/
|
||||
private ActorMeshMask meshMask;
|
||||
|
||||
/**
|
||||
* A mask that overwrites shaders on a given mesh
|
||||
*/
|
||||
private Map<String,ActorShaderMask> shaderMask = new HashMap<String,ActorShaderMask>();
|
||||
|
||||
/**
|
||||
* A mask that overwrites textures on a given mesh
|
||||
*/
|
||||
@ -271,10 +264,6 @@ public class Model {
|
||||
while(mesh_Iterator.hasNext()){
|
||||
Mesh currentMesh = mesh_Iterator.next();
|
||||
if(meshMask == null || (meshMask != null && !meshMask.isBlockedMesh(currentMesh.getMeshName()))){
|
||||
//set shader
|
||||
VisualShader original = currentMesh.getShader();
|
||||
VisualShader shader = getCorrectShader(shaderMask, currentMesh, currentMesh.getShader());
|
||||
currentMesh.setShader(shader);
|
||||
//set texture mask
|
||||
if(this.textureMap != null && textureMap.containsKey(currentMesh.getMeshName())){
|
||||
currentMesh.setTextureMask(textureMap.get(currentMesh.getMeshName()));
|
||||
@ -283,22 +272,14 @@ public class Model {
|
||||
currentMesh.complexDraw(renderPipelineState, openGLState);
|
||||
//reset texture mask
|
||||
currentMesh.setTextureMask(null);
|
||||
//reset shader
|
||||
currentMesh.setShader(original);
|
||||
}
|
||||
}
|
||||
if(meshMask != null){
|
||||
for(Mesh toDraw : meshMask.getToDrawMeshes()){
|
||||
toDraw.setBones(bones);
|
||||
toDraw.setParent(this);
|
||||
//set shader
|
||||
VisualShader original = toDraw.getShader();
|
||||
VisualShader shader = getCorrectShader(shaderMask, toDraw, toDraw.getShader());
|
||||
toDraw.setShader(shader);
|
||||
//draw
|
||||
toDraw.complexDraw(renderPipelineState, openGLState);
|
||||
//reset shader
|
||||
toDraw.setShader(original);
|
||||
}
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
@ -323,25 +304,6 @@ public class Model {
|
||||
return this.meshes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the correct shader to use for a given mesh
|
||||
* @param shaderMask The shader mask
|
||||
* @param mesh The mesh
|
||||
* @param oldShader The original shader on the mesh
|
||||
* @return The correct shader program to use for this mesh
|
||||
*/
|
||||
private VisualShader getCorrectShader(Map<String,ActorShaderMask> shaderMask, Mesh mesh, VisualShader oldShader){
|
||||
VisualShader rVal = oldShader;
|
||||
if(shaderMask.containsKey(mesh.getMeshName())){
|
||||
ActorShaderMask specificMask = shaderMask.get(mesh.getMeshName());
|
||||
VisualShader overwriteShader = null;
|
||||
if((overwriteShader = Globals.assetManager.fetchShader(specificMask.getVertexShaderPath(), specificMask.getFragmentShaderPath())) != null){
|
||||
rVal = overwriteShader;
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies an animation mask to the model
|
||||
@ -662,14 +624,6 @@ public class Model {
|
||||
this.textureMap = textureMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shader mask map
|
||||
* @return The shader mask map
|
||||
*/
|
||||
public Map<String,ActorShaderMask> getShaderMask(){
|
||||
return shaderMask;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility method to attempt overwriting the model's meshes with a new material
|
||||
|
||||
Loading…
Reference in New Issue
Block a user