[iortcw] 247/497: All: Rend2: Bit more parallax optimization
Simon McVittie
smcv at debian.org
Wed Sep 21 19:48:22 UTC 2016
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 f943abf5280676da5e06f011d76144839b9a7da0
Author: M4N4T4RMS at gmail.com <M4N4T4RMS at gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date: Fri Nov 14 22:25:59 2014 +0000
All: Rend2: Bit more parallax optimization
---
MP/code/rend2/glsl/lightall_fp.glsl | 12 ++++++++----
SP/code/rend2/glsl/lightall_fp.glsl | 12 ++++++++----
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/MP/code/rend2/glsl/lightall_fp.glsl b/MP/code/rend2/glsl/lightall_fp.glsl
index d1155de..d118278 100644
--- a/MP/code/rend2/glsl/lightall_fp.glsl
+++ b/MP/code/rend2/glsl/lightall_fp.glsl
@@ -103,6 +103,9 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
// texture depth at best depth
float texDepth = 0.0;
+ float prevT = SampleDepth(normalMap, dp);
+ float prevTexDepth = prevT;
+
// search front to back for first point inside object
for(int i = 0; i < linearSearchSteps - 1; ++i)
{
@@ -115,15 +118,16 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
{
bestDepth = depth; // store best depth
texDepth = t;
+ prevTexDepth = prevT;
}
+ prevT = 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);
+ float div = 1.0 / (1.0 + (prevTexDepth - texDepth) * float(linearSearchSteps));
+ bestDepth -= (depth - size - prevTexDepth) * div;
#else
// recurse around first point (depth) for closest match
for(int i = 0; i < binarySearchSteps; ++i)
@@ -369,7 +373,7 @@ void main()
vec2 texCoords = var_TexCoords.xy;
#if defined(USE_PARALLAXMAP)
- vec3 offsetDir = normalize(E * tangentToWorld);
+ vec3 offsetDir = viewDir * tangentToWorld;
offsetDir.xy *= -u_NormalScale.a / offsetDir.z;
diff --git a/SP/code/rend2/glsl/lightall_fp.glsl b/SP/code/rend2/glsl/lightall_fp.glsl
index d1155de..d118278 100644
--- a/SP/code/rend2/glsl/lightall_fp.glsl
+++ b/SP/code/rend2/glsl/lightall_fp.glsl
@@ -103,6 +103,9 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
// texture depth at best depth
float texDepth = 0.0;
+ float prevT = SampleDepth(normalMap, dp);
+ float prevTexDepth = prevT;
+
// search front to back for first point inside object
for(int i = 0; i < linearSearchSteps - 1; ++i)
{
@@ -115,15 +118,16 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
{
bestDepth = depth; // store best depth
texDepth = t;
+ prevTexDepth = prevT;
}
+ prevT = 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);
+ float div = 1.0 / (1.0 + (prevTexDepth - texDepth) * float(linearSearchSteps));
+ bestDepth -= (depth - size - prevTexDepth) * div;
#else
// recurse around first point (depth) for closest match
for(int i = 0; i < binarySearchSteps; ++i)
@@ -369,7 +373,7 @@ void main()
vec2 texCoords = var_TexCoords.xy;
#if defined(USE_PARALLAXMAP)
- vec3 offsetDir = normalize(E * tangentToWorld);
+ vec3 offsetDir = viewDir * tangentToWorld;
offsetDir.xy *= -u_NormalScale.a / offsetDir.z;
--
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