From 58c094917ec58e49df18e5439800b9a66a64af7e Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 2 Aug 2014 00:50:56 +0200 Subject: [PATCH] Use an header included in every shaders. --- data/shaders/billboard.vert | 1 - data/shaders/bloomblend.frag | 10 ---------- data/shaders/diffuseenvmap.frag | 9 --------- data/shaders/displace.frag | 10 ---------- data/shaders/displace.vert | 17 ----------------- data/shaders/dof.frag | 10 ---------- data/shaders/flipparticle.vert | 10 ---------- data/shaders/fog.frag | 18 ------------------ data/shaders/frustrum.vert | 10 ---------- data/shaders/gi.frag | 10 ---------- data/shaders/grass_pass.vert | 17 ----------------- data/shaders/grass_pass2.frag | 18 ------------------ data/shaders/header.txt | 16 ++++++++++++++++ data/shaders/instanced_grass.vert | 10 ---------- data/shaders/instanced_object_pass.vert | 17 ----------------- data/shaders/instanciedgrassshadow.vert | 8 -------- data/shaders/instanciedshadow.vert | 9 --------- data/shaders/linearizedepth.frag | 10 ---------- data/shaders/mlaa_blend2.frag | 10 ---------- data/shaders/mlaa_offset.vert | 10 ---------- data/shaders/motion_blur.frag | 10 ---------- data/shaders/normalmap.vert | 9 --------- data/shaders/object_pass.vert | 17 ----------------- data/shaders/objectpass_spheremap.frag | 18 ------------------ data/shaders/particle.frag | 10 ---------- data/shaders/particle.vert | 9 --------- data/shaders/pointlight.frag | 18 ------------------ data/shaders/pointlight.vert | 17 ----------------- data/shaders/rhdebug.vert | 10 ---------- data/shaders/shadow.vert | 9 --------- data/shaders/shadow_grass.vert | 9 --------- data/shaders/sky.frag | 18 ------------------ data/shaders/splatting.frag | 10 ---------- data/shaders/ssao.frag | 19 ------------------- data/shaders/sunlight.frag | 18 ------------------ data/shaders/sunlightshadow.frag | 19 ------------------- data/shaders/sunlightshadowdebug.frag | 18 ------------------ data/shaders/tonemap.frag | 10 ---------- data/shaders/transparentfog.frag | 11 ----------- src/graphics/glwrap.cpp | 18 ++++++++++++++++++ 40 files changed, 34 insertions(+), 473 deletions(-) create mode 100644 data/shaders/header.txt diff --git a/data/shaders/billboard.vert b/data/shaders/billboard.vert index f6ec9e5f1..53751f9c2 100644 --- a/data/shaders/billboard.vert +++ b/data/shaders/billboard.vert @@ -1,5 +1,4 @@ uniform mat4 ModelViewMatrix; -uniform mat4 ProjectionMatrix; uniform vec3 Position; uniform vec2 Size; diff --git a/data/shaders/bloomblend.frag b/data/shaders/bloomblend.frag index 6b97b8c4e..503c9dcb9 100644 --- a/data/shaders/bloomblend.frag +++ b/data/shaders/bloomblend.frag @@ -2,16 +2,6 @@ uniform sampler2D tex_128; uniform sampler2D tex_256; uniform sampler2D tex_512; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - out vec4 FragColor; void main() diff --git a/data/shaders/diffuseenvmap.frag b/data/shaders/diffuseenvmap.frag index 81cc8ebe1..c88478b23 100644 --- a/data/shaders/diffuseenvmap.frag +++ b/data/shaders/diffuseenvmap.frag @@ -3,15 +3,6 @@ uniform float greenLmn[9]; uniform float redLmn[9]; uniform sampler2D ntex; uniform mat4 TransposeViewMatrix; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; out vec4 Diff; diff --git a/data/shaders/displace.frag b/data/shaders/displace.frag index eca0e7189..f1423b840 100644 --- a/data/shaders/displace.frag +++ b/data/shaders/displace.frag @@ -5,16 +5,6 @@ uniform sampler2D tex; uniform vec2 dir; uniform vec2 dir2; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - #if __VERSION__ >= 130 in vec2 uv; in vec2 uv_bis; diff --git a/data/shaders/displace.vert b/data/shaders/displace.vert index 6d1f04893..8c4ce9805 100644 --- a/data/shaders/displace.vert +++ b/data/shaders/displace.vert @@ -1,20 +1,3 @@ -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - uniform mat4 ModelMatrix; #if __VERSION__ >= 330 diff --git a/data/shaders/dof.frag b/data/shaders/dof.frag index 028f587d3..541cd1e67 100644 --- a/data/shaders/dof.frag +++ b/data/shaders/dof.frag @@ -1,16 +1,6 @@ uniform sampler2D tex; uniform sampler2D dtex; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - out vec4 FragColor; float focalDepth = 10.; diff --git a/data/shaders/flipparticle.vert b/data/shaders/flipparticle.vert index 5f9954d3a..4ef8cc68d 100644 --- a/data/shaders/flipparticle.vert +++ b/data/shaders/flipparticle.vert @@ -1,13 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - in vec2 quadcorner; in vec2 texcoord; in vec3 position; diff --git a/data/shaders/fog.frag b/data/shaders/fog.frag index fc6380e65..cb5ec7348 100644 --- a/data/shaders/fog.frag +++ b/data/shaders/fog.frag @@ -7,24 +7,6 @@ uniform float start; uniform float end; uniform vec3 col; -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - out vec4 FragColor; diff --git a/data/shaders/frustrum.vert b/data/shaders/frustrum.vert index 489241b4d..1ef1ee264 100644 --- a/data/shaders/frustrum.vert +++ b/data/shaders/frustrum.vert @@ -1,13 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - uniform int idx; in vec3 Position; diff --git a/data/shaders/gi.frag b/data/shaders/gi.frag index b6983b4f2..e90f88d92 100644 --- a/data/shaders/gi.frag +++ b/data/shaders/gi.frag @@ -14,16 +14,6 @@ uniform vec3 extents; uniform mat4 RHMatrix; uniform mat4 InvRHMatrix; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - vec4 SHBasis (const in vec3 dir) { float L00 = 0.282095; diff --git a/data/shaders/grass_pass.vert b/data/shaders/grass_pass.vert index fc3e83ed7..495a2ada3 100644 --- a/data/shaders/grass_pass.vert +++ b/data/shaders/grass_pass.vert @@ -1,20 +1,3 @@ -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - uniform vec3 windDir; uniform mat4 ModelMatrix; uniform mat4 InverseModelMatrix; diff --git a/data/shaders/grass_pass2.frag b/data/shaders/grass_pass2.frag index 55aeecf59..663232a72 100644 --- a/data/shaders/grass_pass2.frag +++ b/data/shaders/grass_pass2.frag @@ -1,21 +1,3 @@ -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - uniform sampler2D Albedo; uniform vec3 SunDir; uniform sampler2D dtex; diff --git a/data/shaders/header.txt b/data/shaders/header.txt new file mode 100644 index 000000000..df5c0d061 --- /dev/null +++ b/data/shaders/header.txt @@ -0,0 +1,16 @@ +#ifdef UBO_DISABLED +uniform mat4 ViewMatrix; +uniform mat4 ProjectionMatrix; +uniform mat4 InverseViewMatrix; +uniform mat4 InverseProjectionMatrix; +#else +layout (std140) uniform MatrixesData +{ + mat4 ViewMatrix; + mat4 ProjectionMatrix; + mat4 InverseViewMatrix; + mat4 InverseProjectionMatrix; + mat4 ShadowViewProjMatrixes[4]; + vec2 screen; +}; +#endif diff --git a/data/shaders/instanced_grass.vert b/data/shaders/instanced_grass.vert index 0c1978cf4..803fa7f92 100644 --- a/data/shaders/instanced_grass.vert +++ b/data/shaders/instanced_grass.vert @@ -1,13 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - uniform vec3 windDir; #if __VERSION__ >= 330 diff --git a/data/shaders/instanced_object_pass.vert b/data/shaders/instanced_object_pass.vert index 84274db61..409487993 100644 --- a/data/shaders/instanced_object_pass.vert +++ b/data/shaders/instanced_object_pass.vert @@ -1,20 +1,3 @@ -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - #if __VERSION__ >= 330 layout(location = 0) in vec3 Position; layout(location = 1) in vec3 Normal; diff --git a/data/shaders/instanciedgrassshadow.vert b/data/shaders/instanciedgrassshadow.vert index 92c21af65..d27f2e808 100644 --- a/data/shaders/instanciedgrassshadow.vert +++ b/data/shaders/instanciedgrassshadow.vert @@ -1,11 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; -}; uniform vec3 windDir; #if __VERSION__ >= 330 layout(location = 0) in vec3 Position; diff --git a/data/shaders/instanciedshadow.vert b/data/shaders/instanciedshadow.vert index 845d07c6e..a9f5fc34d 100644 --- a/data/shaders/instanciedshadow.vert +++ b/data/shaders/instanciedshadow.vert @@ -1,12 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; -}; - #if __VERSION__ >= 330 layout(location = 0) in vec3 Position; layout(location = 3) in vec2 Texcoord; diff --git a/data/shaders/linearizedepth.frag b/data/shaders/linearizedepth.frag index 43e5fcaf1..8d31e0f24 100644 --- a/data/shaders/linearizedepth.frag +++ b/data/shaders/linearizedepth.frag @@ -2,16 +2,6 @@ uniform sampler2D tex; uniform float zn; uniform float zf; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - out float Depth; void main() diff --git a/data/shaders/mlaa_blend2.frag b/data/shaders/mlaa_blend2.frag index d227dfc83..1e12621f9 100644 --- a/data/shaders/mlaa_blend2.frag +++ b/data/shaders/mlaa_blend2.frag @@ -1,16 +1,6 @@ uniform sampler2D edgesMap; uniform sampler2D areaMap; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - #define MAX_SEARCH_STEPS 8.0 #define MAX_DISTANCE 33.0 diff --git a/data/shaders/mlaa_offset.vert b/data/shaders/mlaa_offset.vert index 88aa272ba..1a7a01c21 100644 --- a/data/shaders/mlaa_offset.vert +++ b/data/shaders/mlaa_offset.vert @@ -1,13 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - in vec2 Position; in vec2 Texcoord; diff --git a/data/shaders/motion_blur.frag b/data/shaders/motion_blur.frag index ae21e33d1..91dc4bcd3 100644 --- a/data/shaders/motion_blur.frag +++ b/data/shaders/motion_blur.frag @@ -37,16 +37,6 @@ uniform float mask_radius; uniform mat4 previous_viewproj; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - out vec4 FragColor; // Number of samples used for blurring diff --git a/data/shaders/normalmap.vert b/data/shaders/normalmap.vert index 2104372a4..91bd707b7 100644 --- a/data/shaders/normalmap.vert +++ b/data/shaders/normalmap.vert @@ -1,12 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; -}; - uniform mat4 ModelMatrix; uniform mat4 InverseModelMatrix; diff --git a/data/shaders/object_pass.vert b/data/shaders/object_pass.vert index 1adea5425..dfd7d315f 100644 --- a/data/shaders/object_pass.vert +++ b/data/shaders/object_pass.vert @@ -1,20 +1,3 @@ -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - uniform mat4 ModelMatrix; uniform mat4 InverseModelMatrix; diff --git a/data/shaders/objectpass_spheremap.frag b/data/shaders/objectpass_spheremap.frag index d8c35f4d1..138936d23 100644 --- a/data/shaders/objectpass_spheremap.frag +++ b/data/shaders/objectpass_spheremap.frag @@ -1,23 +1,5 @@ // See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - uniform sampler2D tex; #if __VERSION__ >= 130 diff --git a/data/shaders/particle.frag b/data/shaders/particle.frag index b3a5c1d57..54fca2871 100644 --- a/data/shaders/particle.frag +++ b/data/shaders/particle.frag @@ -2,16 +2,6 @@ uniform sampler2D tex; uniform sampler2D dtex; uniform mat4 invproj; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - in float lf; in vec2 tc; in vec3 pc; diff --git a/data/shaders/particle.vert b/data/shaders/particle.vert index 61ba3ac3d..dd8efbac2 100644 --- a/data/shaders/particle.vert +++ b/data/shaders/particle.vert @@ -1,12 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; uniform vec3 color_from; uniform vec3 color_to; diff --git a/data/shaders/pointlight.frag b/data/shaders/pointlight.frag index 532aa115c..c8913fd50 100644 --- a/data/shaders/pointlight.frag +++ b/data/shaders/pointlight.frag @@ -2,24 +2,6 @@ uniform sampler2D ntex; uniform sampler2D dtex; uniform float spec; -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - flat in vec3 center; flat in float energy; flat in vec3 col; diff --git a/data/shaders/pointlight.vert b/data/shaders/pointlight.vert index 7918176b6..9cbb558b6 100644 --- a/data/shaders/pointlight.vert +++ b/data/shaders/pointlight.vert @@ -1,20 +1,3 @@ -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - in vec3 Position; in float Energy; in vec3 Color; diff --git a/data/shaders/rhdebug.vert b/data/shaders/rhdebug.vert index dde66246b..42e9e654f 100644 --- a/data/shaders/rhdebug.vert +++ b/data/shaders/rhdebug.vert @@ -1,15 +1,5 @@ uniform vec3 extents; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - uniform mat4 RHMatrix; ivec3 resolution = ivec3(32, 16, 32); diff --git a/data/shaders/shadow.vert b/data/shaders/shadow.vert index d7f6316e6..7fe9b6fa8 100644 --- a/data/shaders/shadow.vert +++ b/data/shaders/shadow.vert @@ -1,12 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; -}; - uniform mat4 ModelMatrix; #if __VERSION__ >= 330 diff --git a/data/shaders/shadow_grass.vert b/data/shaders/shadow_grass.vert index 7b1ce0caf..39ae2ea5c 100644 --- a/data/shaders/shadow_grass.vert +++ b/data/shaders/shadow_grass.vert @@ -1,12 +1,3 @@ -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; -}; - uniform mat4 ModelMatrix; uniform vec3 windDir; diff --git a/data/shaders/sky.frag b/data/shaders/sky.frag index f941a2a48..ee8e57d25 100644 --- a/data/shaders/sky.frag +++ b/data/shaders/sky.frag @@ -1,21 +1,3 @@ -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - uniform samplerCube tex; #if __VERSION__ >= 130 diff --git a/data/shaders/splatting.frag b/data/shaders/splatting.frag index ede2b6a47..10c9b8ad1 100644 --- a/data/shaders/splatting.frag +++ b/data/shaders/splatting.frag @@ -8,16 +8,6 @@ uniform sampler2D SpecularMap; uniform sampler2D SSAO; uniform vec3 ambient; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - #if __VERSION__ >= 130 in vec2 uv; in vec2 uv_bis; diff --git a/data/shaders/ssao.frag b/data/shaders/ssao.frag index c31e34f0b..2e551ddb4 100644 --- a/data/shaders/ssao.frag +++ b/data/shaders/ssao.frag @@ -3,25 +3,6 @@ uniform sampler2D dtex; uniform vec4 samplePoints[16]; - -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - out float AO; const float sigma = 1.; diff --git a/data/shaders/sunlight.frag b/data/shaders/sunlight.frag index 5ec6061e7..1bbe36bff 100644 --- a/data/shaders/sunlight.frag +++ b/data/shaders/sunlight.frag @@ -8,24 +8,6 @@ uniform mat4 invproj; //uniform int hasclouds; //uniform vec2 wind; -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - out vec4 Diff; out vec4 Spec; diff --git a/data/shaders/sunlightshadow.frag b/data/shaders/sunlightshadow.frag index 194a68333..0fe6dc07f 100644 --- a/data/shaders/sunlightshadow.frag +++ b/data/shaders/sunlightshadow.frag @@ -10,25 +10,6 @@ uniform vec3 col; //uniform vec2 wind; //uniform float shadowoffset; -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform mat4 ShadowViewProjMatrixes[4]; -uniform vec2 screen; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; -#endif - in vec2 uv; out vec4 Diff; out vec4 Spec; diff --git a/data/shaders/sunlightshadowdebug.frag b/data/shaders/sunlightshadowdebug.frag index 5d59dfa3a..d3ad9ac76 100644 --- a/data/shaders/sunlightshadowdebug.frag +++ b/data/shaders/sunlightshadowdebug.frag @@ -5,24 +5,6 @@ uniform sampler2DArrayShadow shadowtex; uniform vec3 direction; uniform vec3 col; -#ifdef UBO_DISABLED -uniform mat4 ViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat4 InverseViewMatrix; -uniform mat4 InverseProjectionMatrix; -uniform mat4 ShadowViewProjMatrixes[4]; -#else -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; -}; -#endif - - in vec2 uv; out vec4 Diff; out vec4 Spec; diff --git a/data/shaders/tonemap.frag b/data/shaders/tonemap.frag index 7982e66cb..f7b2d54b7 100644 --- a/data/shaders/tonemap.frag +++ b/data/shaders/tonemap.frag @@ -6,16 +6,6 @@ uniform float exposure = .09; uniform float Lwhite = 1.; uniform float vignette_weight = 0.; -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - out vec4 FragColor; vec3 getCIEYxy(vec3 rgbColor); diff --git a/data/shaders/transparentfog.frag b/data/shaders/transparentfog.frag index 76e315a0d..d6f0f3344 100644 --- a/data/shaders/transparentfog.frag +++ b/data/shaders/transparentfog.frag @@ -7,17 +7,6 @@ uniform float start; uniform float end; uniform vec3 col; - -layout (std140) uniform MatrixesData -{ - mat4 ViewMatrix; - mat4 ProjectionMatrix; - mat4 InverseViewMatrix; - mat4 InverseProjectionMatrix; - mat4 ShadowViewProjMatrixes[4]; - vec2 screen; -}; - in vec2 uv; in vec4 color; out vec4 FragColor; diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 302f36a98..968fccc7f 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -245,6 +245,22 @@ void initGL() #endif } +static std::string LoadHeader() +{ + std::string result; + std::ifstream Stream(file_manager->getAsset("shaders/header.txt").c_str(), std::ios::in); + + if (Stream.is_open()) + { + std::string Line = ""; + while (getline(Stream, Line)) + result += "\n" + Line; + Stream.close(); + } + + return result; +} + // Mostly from shader tutorial GLuint LoadShader(const char * file, unsigned type) { @@ -258,6 +274,7 @@ GLuint LoadShader(const char * file, unsigned type) Code += "#define UBO_DISABLED\n"; if (irr_driver->hasVSLayerExtension()) Code += "#define VSLayer\n"; + Code += LoadHeader(); if (Stream.is_open()) { std::string Line = ""; @@ -284,6 +301,7 @@ GLuint LoadShader(const char * file, unsigned type) ErrorMessage[0]=0; glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage); Log::error("GLWrap", ErrorMessage); + Log::error("GLWrap", Code.c_str()); delete[] ErrorMessage; }