summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2022-07-21 19:55:11 -0700
committerPtolemy <ptolemy@lindenlab.com>2022-08-02 09:44:44 -0700
commitfb29b66fcf029342959d9403964f5e3b3be89a23 (patch)
treeacf1e0cb5ef6b463fea4ec08973ff579d00f3577 /indra/newview/app_settings/shaders/class1
parent2bdb97613b1c1ac76c6c1eed7038e390d80594bd (diff)
SL-17762: PBR: Cleanup code, add clipProjectedLightVars()
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl34
1 files changed, 34 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 4df74b762a..721bd933cc 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -26,6 +26,13 @@
uniform sampler2DRect normalMap;
uniform sampler2DRect depthMap;
+// projected lighted params
+uniform mat4 proj_mat; //screen space to light space projector
+uniform vec3 proj_n; // projector normal
+
+// light params
+uniform float size; // light_size
+
uniform mat4 inv_proj;
uniform vec2 screen_res;
@@ -52,6 +59,33 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v,
lightDist = length(lv);
}
+// In:
+// light_center
+// pos
+// Out:
+// dist
+// l_dist
+// lv
+// proj_tc Projector Textue Coordinates
+bool clipProjectedLightVars(vec3 light_center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc )
+{
+ lv = light_center - pos.xyz;
+ dist = length(lv);
+ bool clipped = (dist >= size);
+ if ( !clipped )
+ {
+ dist /= size;
+
+ l_dist = -dot(lv, proj_n);
+ vec4 projected_point = (proj_mat * vec4(pos.xyz, 1.0));
+ clipped = (projected_point.z < 0.0);
+ projected_point.xyz /= projected_point.w;
+ proj_tc = projected_point;
+ }
+
+ return clipped;
+}
+
vec2 getScreenCoordinate(vec2 screenpos)
{
vec2 sc = screenpos.xy * 2.0;