summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2024-01-31 15:54:14 -0800
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2024-01-31 15:54:14 -0800
commit476cbaed6a876c308baa057b50af2631668f7293 (patch)
tree0699bf3a2efcb7185ff13827794a0b9a506b0f4b /indra
parent80ce790d2e952c7fb41cea69071fc026ac82f691 (diff)
#677 Some clipping WIP
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl1
-rw-r--r--indra/newview/lldrawpoolmaterials.cpp8
-rw-r--r--indra/newview/llheroprobemanager.cpp18
-rw-r--r--indra/newview/llheroprobemanager.h5
-rw-r--r--indra/newview/llsettingsvo.cpp12
7 files changed, 31 insertions, 27 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
index 65706e2c3f..41112bce30 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
@@ -127,7 +127,7 @@ void main()
vertex_color = diffuse_color;
#if !defined(HAS_SKIN)
- vary_position = (projection_matrix*vec4(position.xyz, 1.0)).xyz;
+ vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz;
#endif
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index b3b1aaed56..8fe0e1cec8 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -48,15 +48,18 @@ vec3 linear_to_srgb(vec3 cs);
uniform vec4 clipPlane;
uniform float clipSign;
uniform float mirror_flag;
+uniform mat4 modelview_matrix;
+uniform mat3 normal_matrix;
void applyClip(vec3 pos)
{
- float funnyClip = 0;
+
if (mirror_flag > 0)
{
- if ((dot(pos.xyz, clipPlane.xyz) + clipPlane.w) > 0.0)
- {
+ if ((dot(pos.xyz, clipPlane.xyz) + clipPlane.w) < 0.0)
+ {
discard;
- }
+ }
+
}
}
@@ -308,7 +311,6 @@ void main()
// diffcol == diffuse map combined with vertex color
vec4 diffcol = texture(diffuseMap, vary_texcoord0.xy);
diffcol.rgb *= vertex_color.rgb;
-
alphaMask(diffcol.a);
// spec == specular map combined with specular color
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index f1de0b88d6..b49c3386db 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -201,7 +201,6 @@ void main()
#ifdef HERO_PROBES
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR))
color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor;
#endif
}
diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp
index 063dd948f7..15033160d5 100644
--- a/indra/newview/lldrawpoolmaterials.cpp
+++ b/indra/newview/lldrawpoolmaterials.cpp
@@ -192,10 +192,10 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass)
mShader->uniform1f(LLShaderMgr::MIRROR_FLAG, 0);
}
- LLVector4 clipPlane = LLVector4(gPipeline.mHeroProbeManager.currentMirrorClip()[0],
- gPipeline.mHeroProbeManager.currentMirrorClip()[1],
- gPipeline.mHeroProbeManager.currentMirrorClip()[2],
- gPipeline.mHeroProbeManager.currentMirrorClip()[3]);
+ LLVector4 clipPlane = LLVector4(gPipeline.mHeroProbeManager.mMirrorPosition[0],
+ gPipeline.mHeroProbeManager.mMirrorPosition[1],
+ gPipeline.mHeroProbeManager.mMirrorPosition[2],
+ 1);
mShader->uniform4fv(LLShaderMgr::CLIP_PLANE,
1, clipPlane.mV);
diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp
index 1ecafd4f54..bbe493f6a9 100644
--- a/indra/newview/llheroprobemanager.cpp
+++ b/indra/newview/llheroprobemanager.cpp
@@ -165,20 +165,10 @@ void LLHeroProbeManager::update()
LLVector3 reject = offset - project;
LLVector3 point = (reject - project) + hero_pos;
- glh::matrix4f mat = copy_matrix(gGLModelView);
- glh::vec4f tc(face_normal.mV);
- mat.mult_matrix_vec(tc);
-
- LLVector3 mirror_normal;
- mirror_normal.set(tc.v);
-
- LLVector3 hero_pos_render;
- tc = glh::vec4f(hero_pos.mV);
-
- mat.mult_matrix_vec(tc);
- hero_pos_render.set(tc.v);
-
- mCurrentClipPlane.setVec(hero_pos_render, mirror_normal);
+ mCurrentClipPlane.setVec(hero_pos, face_normal);
+ mMirrorPosition = hero_pos;
+ mMirrorNormal = LLVector3(0, 0, 1);
+
probe_pos.load3(point.mV);
}
diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h
index 68cfdbfd99..0b32768bb1 100644
--- a/indra/newview/llheroprobemanager.h
+++ b/indra/newview/llheroprobemanager.h
@@ -75,7 +75,9 @@ public:
bool isMirrorPass() const { return mRenderingMirror; }
- LLPlane currentMirrorClip() const { return mCurrentClipPlane; }
+ LLPlane currentMirrorClip() const { return mCurrentClipPlane; }
+ LLVector3 mMirrorPosition;
+ LLVector3 mMirrorNormal;
private:
friend class LLPipeline;
@@ -102,6 +104,7 @@ private:
LLPlane mCurrentClipPlane;
+
// update the specified face of the specified probe
void updateProbeFace(LLReflectionMap* probe, U32 face, F32 near_clip);
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index c07c939862..9cfb774a90 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -1017,10 +1017,20 @@ void LLSettingsVOWater::applySpecial(void *ptarget, bool force)
LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm));
+ norm = glh::vec3f(gPipeline.mHeroProbeManager.mMirrorNormal.mV[0], gPipeline.mHeroProbeManager.mMirrorNormal.mV[1],
+ gPipeline.mHeroProbeManager.mMirrorNormal.mV[2]);
+ p = glh::vec3f(gPipeline.mHeroProbeManager.mMirrorPosition.mV[0], gPipeline.mHeroProbeManager.mMirrorPosition.mV[1],
+ gPipeline.mHeroProbeManager.mMirrorPosition.mV[2]);
+ invtrans.mult_matrix_vec(norm, enorm);
+ enorm.normalize();
+ mat.mult_matrix_vec(p, ep);
+
+ LLVector4 mirrorPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm));
+
LLDrawPoolAlpha::sWaterPlane = waterPlane;
shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, waterPlane.mV);
-
+ shader->uniform4fv(LLShaderMgr::CLIP_PLANE, mirrorPlane.mV);
LLVector4 light_direction = env.getClampedLightNorm();
F32 waterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP);