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

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 00d2b86e621357f1441e62dc6ba3db51c3749d76
Author: m4n4t4...@gmail.com 
<m4n4t4...@gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Mon Mar 17 01:41:09 2014 +0000

    All: Rend2: Parallax corrected cubemap (cheaper trick)
---
 MP/code/rend2/glsl/lightall_fp.glsl | 17 ++++++++++++++---
 MP/code/rend2/tr_glsl.c             |  4 +++-
 MP/code/rend2/tr_local.h            |  2 ++
 MP/code/rend2/tr_shade.c            | 13 +++++++++++++
 SP/code/rend2/glsl/lightall_fp.glsl | 17 ++++++++++++++---
 SP/code/rend2/tr_glsl.c             |  4 +++-
 SP/code/rend2/tr_local.h            |  2 ++
 SP/code/rend2/tr_shade.c            | 13 +++++++++++++
 8 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/MP/code/rend2/glsl/lightall_fp.glsl 
b/MP/code/rend2/glsl/lightall_fp.glsl
index c74d684..0f50a03 100644
--- a/MP/code/rend2/glsl/lightall_fp.glsl
+++ b/MP/code/rend2/glsl/lightall_fp.glsl
@@ -44,6 +44,12 @@ uniform vec4      u_NormalScale;
 uniform vec4      u_SpecularScale;
 #endif
 
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
+#if defined(USE_CUBEMAP)
+uniform vec4      u_CubeMapInfo;
+#endif
+#endif
+
 varying vec4      var_TexCoords;
 
 varying vec4      var_Color;
@@ -323,19 +329,20 @@ mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv )
 
 void main()
 {
+       vec3 viewDir;
        vec3 L, N, E, H;
        float NL, NH, NE, EH;
 
 #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
   #if defined(USE_VERT_TANGENT_SPACE)
        mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, 
var_Normal.xyz);
-       E = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
+       viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
   #else
        mat3 tangentToWorld = cotangent_frame(var_Normal, -var_ViewDir, 
var_TexCoords.xy);
-       E = var_ViewDir;
+       viewDir = var_ViewDir;
   #endif
 
-       E = normalize(E);
+       E = normalize(viewDir);
 
        L = var_LightDir.xyz;
   #if defined(USE_DELUXEMAP)
@@ -497,6 +504,10 @@ void main()
 
        vec3 R = reflect(E, N);
 
+       // parallax corrected cubemap (cheaper trick)
+       // from 
http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
+       R += u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir;
+
        vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 
7.0).rgb * u_EnableTextures.w;
 
        #if defined(USE_LIGHTMAP)
diff --git a/MP/code/rend2/tr_glsl.c b/MP/code/rend2/tr_glsl.c
index e4d5e63..29a3e21 100644
--- a/MP/code/rend2/tr_glsl.c
+++ b/MP/code/rend2/tr_glsl.c
@@ -142,7 +142,9 @@ static uniformInfo_t uniformsInfo[] =
        { "u_PrimaryLightOrigin",  GLSL_VEC4  },
        { "u_PrimaryLightColor",   GLSL_VEC3  },
        { "u_PrimaryLightAmbient", GLSL_VEC3  },
-       { "u_PrimaryLightRadius",  GLSL_FLOAT }
+       { "u_PrimaryLightRadius",  GLSL_FLOAT },
+
+       { "u_CubeMapInfo", GLSL_VEC4 },
 };
 
 
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index e7fb060..7f31447 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -783,6 +783,8 @@ typedef enum
        UNIFORM_PRIMARYLIGHTAMBIENT,
        UNIFORM_PRIMARYLIGHTRADIUS,
 
+       UNIFORM_CUBEMAPINFO,
+
        UNIFORM_COUNT
 } uniform_t;
 
diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index c429e5c..ad8ad92 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -1482,8 +1482,21 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                // testing cube map
                //
                if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && 
input->cubemapIndex && r_cubeMapping->integer)
+               {
+                       vec4_t vec;
+
                        GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], 
TB_CUBEMAP);
 
+                       vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] 
- backEnd.viewParms.or.origin[0];
+                       vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] 
- backEnd.viewParms.or.origin[1];
+                       vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] 
- backEnd.viewParms.or.origin[2];
+                       vec[3] = 1.0f;
+
+                       VectorScale4(vec, 1.0f / 1000.0f, vec);
+
+                       GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec);
+               }
+
                //
                // draw
                //
diff --git a/SP/code/rend2/glsl/lightall_fp.glsl 
b/SP/code/rend2/glsl/lightall_fp.glsl
index c74d684..0f50a03 100644
--- a/SP/code/rend2/glsl/lightall_fp.glsl
+++ b/SP/code/rend2/glsl/lightall_fp.glsl
@@ -44,6 +44,12 @@ uniform vec4      u_NormalScale;
 uniform vec4      u_SpecularScale;
 #endif
 
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
+#if defined(USE_CUBEMAP)
+uniform vec4      u_CubeMapInfo;
+#endif
+#endif
+
 varying vec4      var_TexCoords;
 
 varying vec4      var_Color;
@@ -323,19 +329,20 @@ mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv )
 
 void main()
 {
+       vec3 viewDir;
        vec3 L, N, E, H;
        float NL, NH, NE, EH;
 
 #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
   #if defined(USE_VERT_TANGENT_SPACE)
        mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, 
var_Normal.xyz);
-       E = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
+       viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
   #else
        mat3 tangentToWorld = cotangent_frame(var_Normal, -var_ViewDir, 
var_TexCoords.xy);
-       E = var_ViewDir;
+       viewDir = var_ViewDir;
   #endif
 
-       E = normalize(E);
+       E = normalize(viewDir);
 
        L = var_LightDir.xyz;
   #if defined(USE_DELUXEMAP)
@@ -497,6 +504,10 @@ void main()
 
        vec3 R = reflect(E, N);
 
+       // parallax corrected cubemap (cheaper trick)
+       // from 
http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
+       R += u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir;
+
        vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 
7.0).rgb * u_EnableTextures.w;
 
        #if defined(USE_LIGHTMAP)
diff --git a/SP/code/rend2/tr_glsl.c b/SP/code/rend2/tr_glsl.c
index e4d5e63..29a3e21 100644
--- a/SP/code/rend2/tr_glsl.c
+++ b/SP/code/rend2/tr_glsl.c
@@ -142,7 +142,9 @@ static uniformInfo_t uniformsInfo[] =
        { "u_PrimaryLightOrigin",  GLSL_VEC4  },
        { "u_PrimaryLightColor",   GLSL_VEC3  },
        { "u_PrimaryLightAmbient", GLSL_VEC3  },
-       { "u_PrimaryLightRadius",  GLSL_FLOAT }
+       { "u_PrimaryLightRadius",  GLSL_FLOAT },
+
+       { "u_CubeMapInfo", GLSL_VEC4 },
 };
 
 
diff --git a/SP/code/rend2/tr_local.h b/SP/code/rend2/tr_local.h
index 81ae644..33925f8 100644
--- a/SP/code/rend2/tr_local.h
+++ b/SP/code/rend2/tr_local.h
@@ -788,6 +788,8 @@ typedef enum
        UNIFORM_PRIMARYLIGHTAMBIENT,
        UNIFORM_PRIMARYLIGHTRADIUS,
 
+       UNIFORM_CUBEMAPINFO,
+
        UNIFORM_COUNT
 } uniform_t;
 
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index 58788d3..44bcdf3 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -1477,8 +1477,21 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                // testing cube map
                //
                if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && 
input->cubemapIndex && r_cubeMapping->integer)
+               {
+                       vec4_t vec;
+
                        GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], 
TB_CUBEMAP);
 
+                       vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] 
- backEnd.viewParms.or.origin[0];
+                       vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] 
- backEnd.viewParms.or.origin[1];
+                       vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] 
- backEnd.viewParms.or.origin[2];
+                       vec[3] = 1.0f;
+
+                       VectorScale4(vec, 1.0f / 1000.0f, vec);
+
+                       GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec);
+               }
+
                //
                // draw
                //

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

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to