leverage standard uniforms buffer
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
1999319433
commit
f02d9979e3
@ -2,6 +2,7 @@
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "./lib/lights.fs"
|
||||
#include "./lib/material.fs"
|
||||
#include "./lib/standarduniform.fs"
|
||||
|
||||
//Shaders/FragmentShader.fs
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
//Vertex Shader
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "./lib/standarduniform.fs"
|
||||
|
||||
|
||||
|
||||
@ -12,11 +14,7 @@ layout (location = 4) in vec2 aTex;
|
||||
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 transform;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
|
||||
//bone related variables
|
||||
const int MAX_WEIGHTS = 4;
|
||||
@ -58,14 +56,14 @@ void main() {
|
||||
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
FragPos = vec3(model * FinalVertex);
|
||||
ViewFragPos = vec3(view * model * FinalVertex);
|
||||
ViewFragPos = vec3(standardUniforms.view * model * FinalVertex);
|
||||
Normal = mat3(transpose(inverse(model))) * FinalNormal.xyz;
|
||||
TexCoord = aTex;
|
||||
|
||||
//shadow map stuff
|
||||
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
FragPosLightSpace = standardUniforms.lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
|
||||
|
||||
//set final position with opengl space
|
||||
gl_Position = projection * view * model * FinalVertex;
|
||||
gl_Position = standardUniforms.projection * standardUniforms.view * model * FinalVertex;
|
||||
}
|
||||
@ -1,9 +1,12 @@
|
||||
#version 330 core
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 2) in vec4 aWeights;
|
||||
layout (location = 3) in vec4 aIndex;
|
||||
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
uniform mat4 model;
|
||||
|
||||
//bone related variables
|
||||
@ -23,5 +26,5 @@ void main(){
|
||||
|
||||
FinalVertex = vec4(aPos, 1.0);
|
||||
|
||||
gl_Position = lightSpaceMatrix * model * FinalVertex;
|
||||
gl_Position = standardUniforms.lightSpaceMatrix * model * FinalVertex;
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../../lib/lights.fs"
|
||||
#include "../../../lib/material.fs"
|
||||
#include "../../../lib/standarduniform.fs"
|
||||
|
||||
|
||||
layout (location = 0) out vec4 accum;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
//Vertex Shader
|
||||
#version 400 core
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../../lib/standarduniform.fs"
|
||||
|
||||
|
||||
|
||||
@ -12,11 +14,7 @@ layout (location = 4) in vec2 aTex;
|
||||
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 transform;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
|
||||
//bone related variables
|
||||
const int MAX_WEIGHTS = 4;
|
||||
@ -58,14 +56,14 @@ void main() {
|
||||
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
FragPos = vec3(model * FinalVertex);
|
||||
ViewFragPos = vec3(view * model * FinalVertex);
|
||||
ViewFragPos = vec3(standardUniforms.view * model * FinalVertex);
|
||||
Normal = mat3(transpose(inverse(model))) * FinalNormal.xyz;
|
||||
TexCoord = aTex;
|
||||
|
||||
//shadow map stuff
|
||||
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
FragPosLightSpace = standardUniforms.lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
|
||||
|
||||
//set final position with opengl space
|
||||
gl_Position = projection * view * model * FinalVertex;
|
||||
gl_Position = standardUniforms.projection * standardUniforms.view * model * FinalVertex;
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
//Vertex Shader
|
||||
#version 330 core
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
//defines
|
||||
#define TEXTURE_MAP_SCALE 1.0
|
||||
@ -14,11 +16,7 @@ layout (location = 5) in int samplerIndices;
|
||||
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 transform;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
|
||||
|
||||
|
||||
@ -41,7 +39,7 @@ void main() {
|
||||
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
FragPos = vec3(model * FinalVertex);
|
||||
ViewFragPos = vec3(view * model * FinalVertex);
|
||||
ViewFragPos = vec3(standardUniforms.view * model * FinalVertex);
|
||||
Normal = mat3(transpose(inverse(model))) * aNormal;
|
||||
uv = aTex;
|
||||
|
||||
@ -50,9 +48,9 @@ void main() {
|
||||
|
||||
|
||||
//shadow map stuff
|
||||
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
FragPosLightSpace = standardUniforms.lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
|
||||
|
||||
//set final position with opengl space
|
||||
gl_Position = projection * view * model * FinalVertex;
|
||||
gl_Position = standardUniforms.projection * standardUniforms.view * model * FinalVertex;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
//foliage.fs
|
||||
|
||||
@ -22,22 +23,13 @@ in vec3 normalRot2;
|
||||
|
||||
|
||||
uniform dvec3 viewPos;
|
||||
// uniform DirLight dirLight;
|
||||
// uniform PointLight pointLights[NR_POINT_LIGHTS];
|
||||
// uniform SpotLight spotLight;
|
||||
uniform Material material;
|
||||
|
||||
//texture stuff
|
||||
// uniform sampler2D ourTexture;
|
||||
uniform int hasTransparency;
|
||||
// uniform sampler2D specularTexture;
|
||||
uniform vec3 baseColor;
|
||||
uniform vec3 tipColor;
|
||||
|
||||
|
||||
uniform mat4 view;
|
||||
|
||||
|
||||
/**
|
||||
The output
|
||||
*/
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
//Vertex Shader
|
||||
#version 430 core
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/material.fs"
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
|
||||
|
||||
@ -27,14 +28,8 @@ uniform Material material;
|
||||
uniform sampler2D dataMap;
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 transform;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
uniform dvec3 viewPos;
|
||||
uniform vec3 modelWorldPos;
|
||||
uniform float time;
|
||||
|
||||
|
||||
/**
|
||||
@ -96,7 +91,7 @@ void main() {
|
||||
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);
|
||||
float curveFloatNoiseSample = clamp(map(openSimplex2_ImproveXY(vec3(worldPos.x,worldPos.z,standardUniforms.time)).x,-1.0,1.0,0,1),0,1);
|
||||
|
||||
//
|
||||
//calculate rotations
|
||||
@ -106,16 +101,16 @@ void main() {
|
||||
|
||||
float windDirectionSpeedMagnitude = 0.05;
|
||||
vec3 windDirectionMovementOverTime = vec3(
|
||||
windDirectionSpeedMagnitude * time,
|
||||
windDirectionSpeedMagnitude * time,
|
||||
windDirectionSpeedMagnitude * standardUniforms.time,
|
||||
windDirectionSpeedMagnitude * standardUniforms.time,
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
float windStrengthMagnitude = 0.2;
|
||||
vec3 windStrengthOverTime = vec3(
|
||||
windStrengthMagnitude * time,
|
||||
windStrengthMagnitude * time,
|
||||
windStrengthMagnitude * standardUniforms.time,
|
||||
windStrengthMagnitude * standardUniforms.time,
|
||||
0
|
||||
);
|
||||
|
||||
@ -160,7 +155,7 @@ void main() {
|
||||
//shift in viewspace to make it feel slightly fuller
|
||||
//
|
||||
//dot view and normal
|
||||
vec3 viewDir = normalize(vec3(viewPos) - FinalVertex.xyz);
|
||||
vec3 viewDir = normalize(vec3(standardUniforms.viewPos) - FinalVertex.xyz);
|
||||
float viewDotNormal = clamp(dot(FinalNormal.xz,viewDir.xz),0,1);
|
||||
//calculate thinkening factor to shift verts slightly based on view angle
|
||||
float viewSpaceThickenFactor = easeOut(1.0 - viewDotNormal);
|
||||
@ -174,17 +169,17 @@ void main() {
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
//
|
||||
FragPos = vec3(FinalVertex);
|
||||
ViewFragPos = vec3(view * model * FinalVertex);
|
||||
ViewFragPos = vec3(standardUniforms.view * model * FinalVertex);
|
||||
Normal = vec3(FinalNormal);
|
||||
TexCoord = aTex;
|
||||
|
||||
|
||||
//shadow map stuff
|
||||
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
FragPosLightSpace = standardUniforms.lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
|
||||
|
||||
//set final position with opengl space
|
||||
gl_Position = projection * view * FinalVertex;
|
||||
gl_Position = standardUniforms.projection * standardUniforms.view * FinalVertex;
|
||||
}
|
||||
|
||||
mat4 rotation3dX(float angle) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
#version 330 core
|
||||
#version 450 core
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
//Vertex Shader
|
||||
#version 330 core
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
|
||||
|
||||
@ -9,10 +11,7 @@ layout (location = 1) in float id;
|
||||
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 transform;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
|
||||
|
||||
@ -29,6 +28,6 @@ void main()
|
||||
//send color to the frag shader
|
||||
color = colors[int(id)];
|
||||
//set final position with opengl space
|
||||
vec4 pos = projection * view * model * FinalVertex;
|
||||
vec4 pos = standardUniforms.projection * standardUniforms.view * model * FinalVertex;
|
||||
gl_Position = pos.xyww;
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//Vertex Shader
|
||||
#version 330 core
|
||||
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
|
||||
//input buffers
|
||||
@ -10,11 +11,7 @@ layout (location = 4) in vec2 aTex;
|
||||
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 transform;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
|
||||
|
||||
|
||||
@ -36,15 +33,15 @@ void main() {
|
||||
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
FragPos = vec3(model * FinalVertex);
|
||||
ViewFragPos = vec3(view * model * FinalVertex);
|
||||
ViewFragPos = vec3(standardUniforms.view * model * FinalVertex);
|
||||
Normal = mat3(transpose(inverse(model))) * aNormal;
|
||||
TexCoord = aTex;
|
||||
|
||||
|
||||
//shadow map stuff
|
||||
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
FragPosLightSpace = standardUniforms.lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
|
||||
|
||||
//set final position with opengl space
|
||||
gl_Position = projection * view * model * FinalVertex;
|
||||
gl_Position = standardUniforms.projection * standardUniforms.view * model * FinalVertex;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
//texture defines
|
||||
#define ATLAS_ELEMENT_DIM 256.0
|
||||
@ -35,7 +36,6 @@ uniform dvec3 viewPos;
|
||||
// uniform PointLight pointLights[NR_POINT_LIGHTS];
|
||||
// uniform SpotLight spotLight;
|
||||
uniform Material material;
|
||||
uniform mat4 view;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
//Vertex Shader
|
||||
#version 330 core
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/standarduniform.fs"
|
||||
|
||||
//defines
|
||||
#define TEXTURE_MAP_SCALE 1.0
|
||||
@ -15,11 +17,7 @@ layout (location = 6) in vec3 samplerRatioVectors; //the interpolated ratio of H
|
||||
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 transform;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 lightSpaceMatrix;
|
||||
|
||||
|
||||
|
||||
@ -45,7 +43,7 @@ void main() {
|
||||
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
FragPos = vec3(model * FinalVertex);
|
||||
ViewFragPos = vec3(view * model * FinalVertex);
|
||||
ViewFragPos = vec3(standardUniforms.view * model * FinalVertex);
|
||||
Normal = mat3(transpose(inverse(model))) * aNormal;
|
||||
|
||||
// //clamp the aPos vector to just shy of its surrounding values
|
||||
@ -68,11 +66,11 @@ void main() {
|
||||
|
||||
|
||||
//shadow map stuff
|
||||
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
FragPosLightSpace = standardUniforms.lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
|
||||
|
||||
//set final position with opengl space
|
||||
gl_Position = projection * view * model * FinalVertex;
|
||||
gl_Position = standardUniforms.projection * standardUniforms.view * model * FinalVertex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1974,6 +1974,7 @@ Performance improvements
|
||||
- Far-away entities do not spawn physics by default
|
||||
- Clustering terrain draw calls
|
||||
- Reduce allocations in some rendering paths
|
||||
- Leverage standard uniforms buffer
|
||||
Lod emitter service checker function
|
||||
Mesh profiling
|
||||
Upgrade target framerate
|
||||
|
||||
@ -700,11 +700,13 @@ public class PhysicsEntityUtils {
|
||||
* @return The rigid body created (note, attachment has already been performed)
|
||||
*/
|
||||
public static void clientAttachTriGeomRigidBody(Entity terrain, TriGeomData data){
|
||||
CollisionEngine.lockOde();
|
||||
DBody terrainBody = CollisionBodyCreation.generateBodyFromTerrainData(Globals.clientState.clientSceneWrapper.getCollisionEngine(), data, Collidable.TYPE_STATIC_BIT);
|
||||
CollisionBodyCreation.setAutoDisable(Globals.clientState.clientSceneWrapper.getCollisionEngine(), terrainBody, true, LINEAR_THRESHOLD, ANGULAR_THRESHOLD, STEP_THRESHOLD);
|
||||
Collidable collidable = new Collidable(terrain,Collidable.TYPE_STATIC, false);
|
||||
Globals.clientState.clientSceneWrapper.getCollisionEngine().registerCollisionObject(terrainBody, collidable);
|
||||
PhysicsEntityUtils.setDBody(terrain,terrainBody);
|
||||
CollisionEngine.unlockOde();
|
||||
terrain.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
||||
}
|
||||
|
||||
@ -715,10 +717,12 @@ public class PhysicsEntityUtils {
|
||||
* @return The rigid body created (note, attachment has already been performed)
|
||||
*/
|
||||
public static void clientAttachTriGeomCollider(Entity terrain, TriGeomData data){
|
||||
CollisionEngine.lockOde();
|
||||
DGeom terrainGeom = CollisionBodyCreation.generateGeomFromTerrainData(Globals.clientState.clientSceneWrapper.getCollisionEngine(), data, Collidable.TYPE_STATIC_BIT);
|
||||
Collidable collidable = new Collidable(terrain,Collidable.TYPE_STATIC, true);
|
||||
PhysicsEntityUtils.setCollidable(terrain, collidable);
|
||||
Globals.clientState.clientSceneWrapper.getCollisionEngine().registerCollisionObject(terrainGeom, collidable);
|
||||
CollisionEngine.unlockOde();
|
||||
PhysicsEntityUtils.setDGeom(terrain,terrainGeom);
|
||||
}
|
||||
|
||||
|
||||
@ -563,14 +563,9 @@ public class Mesh {
|
||||
//buffer model/view/proj matrices
|
||||
try(MemoryStack stack = MemoryStack.stackPush()){
|
||||
openGLState.getActiveShader().setUniform(openGLState, "model", parent.getModelMatrix());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "view", Globals.renderingEngine.getViewMatrix());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "projection", Globals.renderingEngine.getProjectionMatrix());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "viewPos", CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3f worldPos = new Vector3f((float)parent.getWorldPos().x,(float)parent.getWorldPos().y,(float)parent.getWorldPos().z);
|
||||
openGLState.getActiveShader().setUniform(openGLState, "modelWorldPos", worldPos);
|
||||
openGLState.getActiveShader().setUniform(openGLState, "lightSpaceMatrix", Globals.renderingEngine.getLightDepthMatrix());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "frame", (int)Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "time", (float)Globals.engineState.timekeeper.getCurrentRendererTime());
|
||||
openGLState.glBindBufferBase(StandardUniformManager.STANDARD_UNIFORM_BUFFER_BIND_POINT, Globals.renderingEngine.getStandardUniformManager().getStandardUnifomSSBO());
|
||||
}
|
||||
Globals.renderingEngine.checkError();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user