[iortcw] 70/89: All: Rend2: Don't use initialized arrays in glsl shaders

Simon McVittie smcv at debian.org
Fri Sep 8 10:44:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to tag 1.51b
in repository iortcw.

commit 088b1359ec123c77fac6bf1580bdd8c539eaf934
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Mon Jul 24 22:15:26 2017 -0400

    All: Rend2: Don't use initialized arrays in glsl shaders
---
 MP/code/rend2/glsl/bokeh_fp.glsl     | 18 ++++++++++++++++--
 MP/code/rend2/glsl/depthblur_fp.glsl |  8 +++++++-
 MP/code/rend2/glsl/ssao_fp.glsl      | 15 +++++++++++++++
 SP/code/rend2/glsl/bokeh_fp.glsl     | 18 ++++++++++++++++--
 SP/code/rend2/glsl/depthblur_fp.glsl |  8 +++++++-
 SP/code/rend2/glsl/ssao_fp.glsl      | 15 +++++++++++++++
 6 files changed, 76 insertions(+), 6 deletions(-)

diff --git a/MP/code/rend2/glsl/bokeh_fp.glsl b/MP/code/rend2/glsl/bokeh_fp.glsl
index d08816a..d2ec5b4 100644
--- a/MP/code/rend2/glsl/bokeh_fp.glsl
+++ b/MP/code/rend2/glsl/bokeh_fp.glsl
@@ -11,7 +11,15 @@ void main()
 	vec2 tc;
 
 #if 0
-	float c[7] = float[7](1.0, 0.9659258263, 0.8660254038, 0.7071067812, 0.5, 0.2588190451, 0.0);
+	float c[7];
+
+	c[0] = 1.0;
+	c[1] = 0.9659258263;
+	c[2] = 0.8660254038;
+	c[3] = 0.7071067812;
+	c[4] = 0.5;
+	c[5] = 0.2588190451;
+	c[6] = 0.0;
 
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[0],  c[6]);  color =  texture2D(u_TextureMap, tc);
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[1],  c[5]);  color += texture2D(u_TextureMap, tc);
@@ -44,7 +52,13 @@ void main()
 	gl_FragColor = color * 0.04166667 * u_Color;
 #endif
 
-	float c[5] = float[5](1.0, 0.9238795325, 0.7071067812, 0.3826834324, 0.0);
+	float c[5];
+
+	c[0] = 1.0;
+	c[1] = 0.9238795325;
+	c[2] = 0.7071067812;
+	c[3] = 0.3826834324;
+	c[4] = 0.0;
 
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[0],  c[4]);  color =  texture2D(u_TextureMap, tc);
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[1],  c[3]);  color += texture2D(u_TextureMap, tc);
diff --git a/MP/code/rend2/glsl/depthblur_fp.glsl b/MP/code/rend2/glsl/depthblur_fp.glsl
index d71b348..d63df88 100644
--- a/MP/code/rend2/glsl/depthblur_fp.glsl
+++ b/MP/code/rend2/glsl/depthblur_fp.glsl
@@ -6,7 +6,7 @@ varying vec2   var_ScreenTex;
 
 //float gauss[8] = float[8](0.17, 0.17, 0.16, 0.14, 0.12, 0.1, 0.08, 0.06);
 //float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033);
-float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);
+//float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);
 //float gauss[3] = float[3](0.60, 0.19, 0.0066);
 #define BLUR_SIZE 4
 
@@ -22,6 +22,12 @@ float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNea
 
 vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFarDivZNear, float zFar, vec2 scale)
 {
+	float gauss[4];
+
+	gauss[0] = 0.40;
+	gauss[1] = 0.24;
+	gauss[2] = 0.054;
+	gauss[3] = 0.0044;
 
 #if defined(USE_DEPTH)
 	float depthCenter = getLinearDepth(depthMap, tex, zFarDivZNear);
diff --git a/MP/code/rend2/glsl/ssao_fp.glsl b/MP/code/rend2/glsl/ssao_fp.glsl
index 93f6185..d4c4306 100644
--- a/MP/code/rend2/glsl/ssao_fp.glsl
+++ b/MP/code/rend2/glsl/ssao_fp.glsl
@@ -4,6 +4,7 @@ uniform vec4   u_ViewInfo; // zfar / znear, zfar, 1/width, 1/height
 
 varying vec2   var_ScreenTex;
 
+#if 0
 vec2 poissonDisc[9] = vec2[9](
 vec2(-0.7055767, 0.196515),    vec2(0.3524343, -0.7791386),
 vec2(0.2391056, 0.9189604),    vec2(-0.07580382, -0.09224417),
@@ -11,6 +12,8 @@ vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181),
 vec2(-0.6335801, -0.5247476),  vec2(-0.5579782, 0.7491854),
 vec2(0.7320465, 0.6317794)
 );
+#endif
+
 #define NUM_SAMPLES 3
 
 // Input: It uses texture coords as the random number seed.
@@ -46,6 +49,18 @@ float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNea
 
 float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZNear, const float zFar, const vec2 scale)
 {
+	vec2 poissonDisc[9];
+
+	poissonDisc[0] = vec2(-0.7055767, 0.196515);
+	poissonDisc[1] = vec2(0.3524343, -0.7791386);
+	poissonDisc[2] = vec2(0.2391056, 0.9189604);
+	poissonDisc[3] = vec2(-0.07580382, -0.09224417);
+	poissonDisc[4] = vec2(0.5784913, -0.002528916);
+	poissonDisc[5] = vec2(0.192888, 0.4064181);
+	poissonDisc[6] = vec2(-0.6335801, -0.5247476);
+	poissonDisc[7] = vec2(-0.5579782, 0.7491854);
+	poissonDisc[8] = vec2(0.7320465, 0.6317794);
+
 	float result = 0;
 
 	float sampleZ = getLinearDepth(depthMap, tex, zFarDivZNear);
diff --git a/SP/code/rend2/glsl/bokeh_fp.glsl b/SP/code/rend2/glsl/bokeh_fp.glsl
index d08816a..d2ec5b4 100644
--- a/SP/code/rend2/glsl/bokeh_fp.glsl
+++ b/SP/code/rend2/glsl/bokeh_fp.glsl
@@ -11,7 +11,15 @@ void main()
 	vec2 tc;
 
 #if 0
-	float c[7] = float[7](1.0, 0.9659258263, 0.8660254038, 0.7071067812, 0.5, 0.2588190451, 0.0);
+	float c[7];
+
+	c[0] = 1.0;
+	c[1] = 0.9659258263;
+	c[2] = 0.8660254038;
+	c[3] = 0.7071067812;
+	c[4] = 0.5;
+	c[5] = 0.2588190451;
+	c[6] = 0.0;
 
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[0],  c[6]);  color =  texture2D(u_TextureMap, tc);
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[1],  c[5]);  color += texture2D(u_TextureMap, tc);
@@ -44,7 +52,13 @@ void main()
 	gl_FragColor = color * 0.04166667 * u_Color;
 #endif
 
-	float c[5] = float[5](1.0, 0.9238795325, 0.7071067812, 0.3826834324, 0.0);
+	float c[5];
+
+	c[0] = 1.0;
+	c[1] = 0.9238795325;
+	c[2] = 0.7071067812;
+	c[3] = 0.3826834324;
+	c[4] = 0.0;
 
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[0],  c[4]);  color =  texture2D(u_TextureMap, tc);
 	tc = var_TexCoords + u_InvTexRes * vec2(  c[1],  c[3]);  color += texture2D(u_TextureMap, tc);
diff --git a/SP/code/rend2/glsl/depthblur_fp.glsl b/SP/code/rend2/glsl/depthblur_fp.glsl
index d71b348..d63df88 100644
--- a/SP/code/rend2/glsl/depthblur_fp.glsl
+++ b/SP/code/rend2/glsl/depthblur_fp.glsl
@@ -6,7 +6,7 @@ varying vec2   var_ScreenTex;
 
 //float gauss[8] = float[8](0.17, 0.17, 0.16, 0.14, 0.12, 0.1, 0.08, 0.06);
 //float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033);
-float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);
+//float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);
 //float gauss[3] = float[3](0.60, 0.19, 0.0066);
 #define BLUR_SIZE 4
 
@@ -22,6 +22,12 @@ float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNea
 
 vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFarDivZNear, float zFar, vec2 scale)
 {
+	float gauss[4];
+
+	gauss[0] = 0.40;
+	gauss[1] = 0.24;
+	gauss[2] = 0.054;
+	gauss[3] = 0.0044;
 
 #if defined(USE_DEPTH)
 	float depthCenter = getLinearDepth(depthMap, tex, zFarDivZNear);
diff --git a/SP/code/rend2/glsl/ssao_fp.glsl b/SP/code/rend2/glsl/ssao_fp.glsl
index 93f6185..d4c4306 100644
--- a/SP/code/rend2/glsl/ssao_fp.glsl
+++ b/SP/code/rend2/glsl/ssao_fp.glsl
@@ -4,6 +4,7 @@ uniform vec4   u_ViewInfo; // zfar / znear, zfar, 1/width, 1/height
 
 varying vec2   var_ScreenTex;
 
+#if 0
 vec2 poissonDisc[9] = vec2[9](
 vec2(-0.7055767, 0.196515),    vec2(0.3524343, -0.7791386),
 vec2(0.2391056, 0.9189604),    vec2(-0.07580382, -0.09224417),
@@ -11,6 +12,8 @@ vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181),
 vec2(-0.6335801, -0.5247476),  vec2(-0.5579782, 0.7491854),
 vec2(0.7320465, 0.6317794)
 );
+#endif
+
 #define NUM_SAMPLES 3
 
 // Input: It uses texture coords as the random number seed.
@@ -46,6 +49,18 @@ float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNea
 
 float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZNear, const float zFar, const vec2 scale)
 {
+	vec2 poissonDisc[9];
+
+	poissonDisc[0] = vec2(-0.7055767, 0.196515);
+	poissonDisc[1] = vec2(0.3524343, -0.7791386);
+	poissonDisc[2] = vec2(0.2391056, 0.9189604);
+	poissonDisc[3] = vec2(-0.07580382, -0.09224417);
+	poissonDisc[4] = vec2(0.5784913, -0.002528916);
+	poissonDisc[5] = vec2(0.192888, 0.4064181);
+	poissonDisc[6] = vec2(-0.6335801, -0.5247476);
+	poissonDisc[7] = vec2(-0.5579782, 0.7491854);
+	poissonDisc[8] = vec2(0.7320465, 0.6317794);
+
 	float result = 0;
 
 	float sampleZ = getLinearDepth(depthMap, tex, zFarDivZNear);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list