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 d3b70dfcde73160918f07ce988582e6d8c15dee6
Author: m4n4t4...@gmail.com 
<m4n4t4...@gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Fri Nov 14 00:03:41 2014 +0000

    All: Rend2: Add support for parallax occlusion mapping
---
 MP/code/rend2/glsl/lightall_fp.glsl | 14 +++++++++++++-
 MP/code/rend2/tr_glsl.c             |  4 ++++
 MP/rend2-readme.txt                 |  3 ++-
 SP/code/rend2/glsl/lightall_fp.glsl | 14 +++++++++++++-
 SP/code/rend2/tr_glsl.c             |  4 ++++
 SP/rend2-readme.txt                 |  3 ++-
 6 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/MP/code/rend2/glsl/lightall_fp.glsl 
b/MP/code/rend2/glsl/lightall_fp.glsl
index f2da782..d1155de 100644
--- a/MP/code/rend2/glsl/lightall_fp.glsl
+++ b/MP/code/rend2/glsl/lightall_fp.glsl
@@ -100,6 +100,9 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D 
normalMap)
        // best match found (starts with last position 1.0)
        float bestDepth = 1.0;
 
+       // texture depth at best depth
+       float texDepth = 0.0;
+
        // search front to back for first point inside object
        for(int i = 0; i < linearSearchSteps - 1; ++i)
        {
@@ -109,11 +112,19 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D 
normalMap)
                
                if(bestDepth > 0.996)           // if no depth found yet
                        if(depth >= t)
+                       {
                                bestDepth = depth;      // store best depth
+                               texDepth = t;
+                       }
        }
 
        depth = bestDepth;
-       
+
+#if !defined (USE_RELIEFMAP)
+       float prevDepth = depth - size;
+       float prevTexDepth = SampleDepth(normalMap, dp + ds * prevDepth);
+       bestDepth -= size * (prevDepth - prevTexDepth) / (size - texDepth + 
prevTexDepth);
+#else
        // recurse around first point (depth) for closest match
        for(int i = 0; i < binarySearchSteps; ++i)
        {
@@ -129,6 +140,7 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D 
normalMap)
 
                depth += size;
        }
+#endif
 
        return bestDepth;
 }
diff --git a/MP/code/rend2/tr_glsl.c b/MP/code/rend2/tr_glsl.c
index 074218d..ca8e5a5 100644
--- a/MP/code/rend2/tr_glsl.c
+++ b/MP/code/rend2/tr_glsl.c
@@ -1091,7 +1091,11 @@ void GLSL_InitGPUShaders(void)
 #endif
 
                                if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & 
LIGHTDEF_ENTITY) && r_parallaxMapping->integer)
+                               {
                                        Q_strcat(extradefines, 1024, "#define 
USE_PARALLAXMAP\n");
+                                       if (r_parallaxMapping->integer > 1)
+                                               Q_strcat(extradefines, 1024, 
"#define USE_RELIEFMAP\n");
+                               }
                        }
 
                        if (r_specularMapping->integer)
diff --git a/MP/rend2-readme.txt b/MP/rend2-readme.txt
index fc2fd10..7d62bb2 100644
--- a/MP/rend2-readme.txt
+++ b/MP/rend2-readme.txt
@@ -187,7 +187,8 @@ Cvars for advanced material usage:
   r_parallaxMapping              - Enable parallax mapping for materials that
                                    support it.
                                      0 - No. (default)
-                                     1 - Yes.
+                                     1 - Use parallax occlusion mapping.
+                                     2 - Use relief mapping. (slower)
 
   r_baseSpecular                 - Set the specular reflectance of materials
                                    which don't include a specular map or
diff --git a/SP/code/rend2/glsl/lightall_fp.glsl 
b/SP/code/rend2/glsl/lightall_fp.glsl
index f2da782..d1155de 100644
--- a/SP/code/rend2/glsl/lightall_fp.glsl
+++ b/SP/code/rend2/glsl/lightall_fp.glsl
@@ -100,6 +100,9 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D 
normalMap)
        // best match found (starts with last position 1.0)
        float bestDepth = 1.0;
 
+       // texture depth at best depth
+       float texDepth = 0.0;
+
        // search front to back for first point inside object
        for(int i = 0; i < linearSearchSteps - 1; ++i)
        {
@@ -109,11 +112,19 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D 
normalMap)
                
                if(bestDepth > 0.996)           // if no depth found yet
                        if(depth >= t)
+                       {
                                bestDepth = depth;      // store best depth
+                               texDepth = t;
+                       }
        }
 
        depth = bestDepth;
-       
+
+#if !defined (USE_RELIEFMAP)
+       float prevDepth = depth - size;
+       float prevTexDepth = SampleDepth(normalMap, dp + ds * prevDepth);
+       bestDepth -= size * (prevDepth - prevTexDepth) / (size - texDepth + 
prevTexDepth);
+#else
        // recurse around first point (depth) for closest match
        for(int i = 0; i < binarySearchSteps; ++i)
        {
@@ -129,6 +140,7 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D 
normalMap)
 
                depth += size;
        }
+#endif
 
        return bestDepth;
 }
diff --git a/SP/code/rend2/tr_glsl.c b/SP/code/rend2/tr_glsl.c
index 074218d..ca8e5a5 100644
--- a/SP/code/rend2/tr_glsl.c
+++ b/SP/code/rend2/tr_glsl.c
@@ -1091,7 +1091,11 @@ void GLSL_InitGPUShaders(void)
 #endif
 
                                if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & 
LIGHTDEF_ENTITY) && r_parallaxMapping->integer)
+                               {
                                        Q_strcat(extradefines, 1024, "#define 
USE_PARALLAXMAP\n");
+                                       if (r_parallaxMapping->integer > 1)
+                                               Q_strcat(extradefines, 1024, 
"#define USE_RELIEFMAP\n");
+                               }
                        }
 
                        if (r_specularMapping->integer)
diff --git a/SP/rend2-readme.txt b/SP/rend2-readme.txt
index f52d894..e8a17b5 100644
--- a/SP/rend2-readme.txt
+++ b/SP/rend2-readme.txt
@@ -187,7 +187,8 @@ Cvars for advanced material usage:
   r_parallaxMapping              - Enable parallax mapping for materials that
                                    support it.
                                      0 - No. (default)
-                                     1 - Yes.
+                                     1 - Use parallax occlusion mapping.
+                                     2 - Use relief mapping. (slower)
 
   r_baseSpecular                 - Set the specular reflectance of materials
                                    which don't include a specular map or

-- 
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