mesh color uniform
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-29 16:36:16 -04:00
parent 678e5b9c88
commit ccd10c9665
5 changed files with 27 additions and 2 deletions

View File

@ -19,7 +19,7 @@ uniform Material material;
/** /**
The color to apply to the model The color to apply to the model
*/ */
uniform vec3 color; uniform vec4 color;
/** /**
The output The output

View File

@ -2066,6 +2066,7 @@ Error report on window.java
Delete ActorShaderMask Delete ActorShaderMask
Fix string carousels Fix string carousels
Fix sprint animation data Fix sprint animation data
Color uniform on meshes

View File

@ -100,7 +100,7 @@ public class Actor {
/** /**
* the model path of the model backing the actor * the model path of the model backing the actor
*/ */
private String baseModelPath; private final String baseModelPath;
/** /**
* Path to the low res model * Path to the low res model

View File

@ -25,6 +25,7 @@ import org.joml.Sphered;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3i; import org.joml.Vector3i;
import org.joml.Vector4d;
import org.joml.Vector4f; import org.joml.Vector4f;
import org.lwjgl.opengl.GL45; import org.lwjgl.opengl.GL45;
@ -174,6 +175,11 @@ public class Mesh {
*/ */
private Material material; private Material material;
/**
* The color to apply to the mesh
*/
private Vector4d color = new Vector4d(1);
/** /**
* the bounding sphere for this mesh * the bounding sphere for this mesh
*/ */
@ -582,6 +588,7 @@ public class Mesh {
Globals.profiler.beginAggregateCpuSample("Buffer standard uniforms"); Globals.profiler.beginAggregateCpuSample("Buffer standard uniforms");
//buffer model/view/proj matrices //buffer model/view/proj matrices
try(MemoryStack stack = MemoryStack.stackPush()){ try(MemoryStack stack = MemoryStack.stackPush()){
openGLState.getActiveShader().setUniform(openGLState, "color", this.color);
openGLState.getActiveShader().setUniform(openGLState, "model", parent.getModelMatrix()); openGLState.getActiveShader().setUniform(openGLState, "model", parent.getModelMatrix());
openGLState.getActiveShader().setUniform(openGLState, "viewPos", CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera)); openGLState.getActiveShader().setUniform(openGLState, "viewPos", CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
drawVec3f.set((float)parent.getWorldPos().x,(float)parent.getWorldPos().y,(float)parent.getWorldPos().z); drawVec3f.set((float)parent.getWorldPos().x,(float)parent.getWorldPos().y,(float)parent.getWorldPos().z);

View File

@ -9,6 +9,7 @@ import org.joml.Vector2i;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3i; import org.joml.Vector3i;
import org.joml.Vector4d;
import org.joml.Vector4f; import org.joml.Vector4f;
import org.lwjgl.opengl.GL40; import org.lwjgl.opengl.GL40;
@ -91,6 +92,22 @@ public class ShaderUtils {
uniformMap.put(uniformLocation,new Matrix4d(currentUniform)); //create new matrix4f to break pointer-matching with equals on cache check uniformMap.put(uniformLocation,new Matrix4d(currentUniform)); //create new matrix4f to break pointer-matching with equals on cache check
} }
//
//vector4d
} else if(value instanceof Vector4d){
Vector4d currentUniform = (Vector4d)value;
float4Arr[0] = (float)currentUniform.x;
float4Arr[1] = (float)currentUniform.y;
float4Arr[2] = (float)currentUniform.z;
float4Arr[3] = (float)currentUniform.w;
GL40.glUniform4fv(uniformLocation, float4Arr);
Globals.renderingEngine.checkError();
if(uniformMap.containsKey(uniformLocation)){
((Vector4d)uniformMap.get(uniformLocation)).set(currentUniform);
} else {
uniformMap.put(uniformLocation,new Vector4d(currentUniform)); //create new vector3f to break pointer-matching with equals on cache check
}
// //
//vector4f //vector4f
} else if(value instanceof Vector4f){ } else if(value instanceof Vector4f){