diff options
Diffstat (limited to 'linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl')
-rw-r--r-- | linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl deleted file mode 100644 index 6519594..0000000 --- a/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | /** | ||
2 | * @file multiSpotLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #version 120 | ||
9 | |||
10 | #extension GL_ARB_texture_rectangle : enable | ||
11 | |||
12 | uniform sampler2DRect diffuseRect; | ||
13 | uniform sampler2DRect specularRect; | ||
14 | uniform sampler2DRect depthMap; | ||
15 | uniform sampler2DRect normalMap; | ||
16 | uniform samplerCube environmentMap; | ||
17 | uniform sampler2DRect lightMap; | ||
18 | uniform sampler2D noiseMap; | ||
19 | uniform sampler2D lightFunc; | ||
20 | uniform sampler2D projectionMap; | ||
21 | |||
22 | uniform mat4 proj_mat; //screen space to light space | ||
23 | uniform float proj_near; //near clip for projection | ||
24 | uniform vec3 proj_p; //plane projection is emitting from (in screen space) | ||
25 | uniform vec3 proj_n; | ||
26 | uniform float proj_focus; //distance from plane to begin blurring | ||
27 | uniform float proj_lod; //(number of mips in proj map) | ||
28 | uniform float proj_range; //range between near clip and far clip plane of projection | ||
29 | uniform float proj_ambient_lod; | ||
30 | uniform float proj_ambiance; | ||
31 | uniform float near_clip; | ||
32 | uniform float far_clip; | ||
33 | |||
34 | uniform vec3 proj_origin; //origin of projection to be used for angular attenuation | ||
35 | uniform float sun_wash; | ||
36 | uniform int proj_shadow_idx; | ||
37 | uniform float shadow_fade; | ||
38 | |||
39 | varying vec4 vary_light; | ||
40 | |||
41 | varying vec4 vary_fragcoord; | ||
42 | uniform vec2 screen_res; | ||
43 | |||
44 | uniform mat4 inv_proj; | ||
45 | |||
46 | vec4 getPosition(vec2 pos_screen) | ||
47 | { | ||
48 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
49 | vec2 sc = pos_screen.xy*2.0; | ||
50 | sc /= screen_res; | ||
51 | sc -= vec2(1.0,1.0); | ||
52 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
53 | vec4 pos = inv_proj * ndc; | ||
54 | pos /= pos.w; | ||
55 | pos.w = 1.0; | ||
56 | return pos; | ||
57 | } | ||
58 | |||
59 | void main() | ||
60 | { | ||
61 | vec4 frag = vary_fragcoord; | ||
62 | frag.xyz /= frag.w; | ||
63 | frag.xyz = frag.xyz*0.5+0.5; | ||
64 | frag.xy *= screen_res; | ||
65 | |||
66 | vec3 pos = getPosition(frag.xy).xyz; | ||
67 | vec3 lv = vary_light.xyz-pos.xyz; | ||
68 | float dist2 = dot(lv,lv); | ||
69 | dist2 /= vary_light.w; | ||
70 | if (dist2 > 1.0) | ||
71 | { | ||
72 | discard; | ||
73 | } | ||
74 | |||
75 | float shadow = 1.0; | ||
76 | |||
77 | if (proj_shadow_idx >= 0) | ||
78 | { | ||
79 | vec4 shd = texture2DRect(lightMap, frag.xy); | ||
80 | float sh[2]; | ||
81 | sh[0] = shd.b; | ||
82 | sh[1] = shd.a; | ||
83 | shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); | ||
84 | } | ||
85 | |||
86 | vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0; | ||
87 | |||
88 | norm = normalize(norm); | ||
89 | float l_dist = -dot(lv, proj_n); | ||
90 | |||
91 | vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); | ||
92 | if (proj_tc.z < 0.0) | ||
93 | { | ||
94 | discard; | ||
95 | } | ||
96 | |||
97 | proj_tc.xyz /= proj_tc.w; | ||
98 | |||
99 | float fa = gl_Color.a+1.0; | ||
100 | float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0); | ||
101 | if (dist_atten <= 0.0) | ||
102 | { | ||
103 | discard; | ||
104 | } | ||
105 | |||
106 | lv = proj_origin-pos.xyz; | ||
107 | lv = normalize(lv); | ||
108 | float da = dot(norm, lv); | ||
109 | |||
110 | vec3 col = vec3(0,0,0); | ||
111 | |||
112 | vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; | ||
113 | |||
114 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | ||
115 | if (proj_tc.z > 0.0 && | ||
116 | proj_tc.x < 1.0 && | ||
117 | proj_tc.y < 1.0 && | ||
118 | proj_tc.x > 0.0 && | ||
119 | proj_tc.y > 0.0) | ||
120 | { | ||
121 | float lit = 0.0; | ||
122 | float amb_da = proj_ambiance; | ||
123 | |||
124 | if (da > 0.0) | ||
125 | { | ||
126 | float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); | ||
127 | float lod = diff * proj_lod; | ||
128 | |||
129 | vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
130 | |||
131 | vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; | ||
132 | |||
133 | lit = da * dist_atten * noise; | ||
134 | |||
135 | col = lcol*lit*diff_tex*shadow; | ||
136 | amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; | ||
137 | } | ||
138 | |||
139 | //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); | ||
140 | vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_ambient_lod); | ||
141 | |||
142 | amb_da += (da*da*0.5+0.5)*proj_ambiance; | ||
143 | |||
144 | amb_da *= dist_atten * noise; | ||
145 | |||
146 | amb_da = min(amb_da, 1.0-lit); | ||
147 | |||
148 | col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; | ||
149 | } | ||
150 | |||
151 | |||
152 | vec4 spec = texture2DRect(specularRect, frag.xy); | ||
153 | if (spec.a > 0.0) | ||
154 | { | ||
155 | vec3 ref = reflect(normalize(pos), norm); | ||
156 | |||
157 | //project from point pos in direction ref to plane proj_p, proj_n | ||
158 | vec3 pdelta = proj_p-pos; | ||
159 | float ds = dot(ref, proj_n); | ||
160 | |||
161 | if (ds < 0.0) | ||
162 | { | ||
163 | vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; | ||
164 | |||
165 | vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); | ||
166 | |||
167 | if (stc.z > 0.0) | ||
168 | { | ||
169 | stc.xy /= stc.w; | ||
170 | |||
171 | if (stc.x < 1.0 && | ||
172 | stc.y < 1.0 && | ||
173 | stc.x > 0.0 && | ||
174 | stc.y > 0.0) | ||
175 | { | ||
176 | vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); | ||
177 | col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow; | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | |||
183 | //attenuate point light contribution by SSAO component | ||
184 | col *= texture2DRect(lightMap, frag.xy).g; | ||
185 | |||
186 | gl_FragColor.rgb = col; | ||
187 | gl_FragColor.a = 0.0; | ||
188 | } | ||