diff options
author | Armin Weatherwax | 2010-09-07 13:41:02 +0200 |
---|---|---|
committer | Armin Weatherwax | 2010-09-23 15:42:40 +0200 |
commit | 087e15e89930d51c3964329befb273ae3b2d330d (patch) | |
tree | 684c49a772b0097ed88a25660e1fd3dd10b264cc /linden/indra/newview | |
parent | Robin Cornelius: fixes for building plugins on Linux 64bit (diff) | |
download | meta-impy-087e15e89930d51c3964329befb273ae3b2d330d.zip meta-impy-087e15e89930d51c3964329befb273ae3b2d330d.tar.gz meta-impy-087e15e89930d51c3964329befb273ae3b2d330d.tar.bz2 meta-impy-087e15e89930d51c3964329befb273ae3b2d330d.tar.xz |
port of LL renderpipeline/Kirstens S19 pipeline for bridging to Viewer 2 texture system
Diffstat (limited to '')
187 files changed, 11372 insertions, 1902 deletions
diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index e0c6c61..6fd259a 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt | |||
@@ -329,6 +329,7 @@ set(viewer_SOURCE_FILES | |||
329 | llpolymesh.cpp | 329 | llpolymesh.cpp |
330 | llpolymorph.cpp | 330 | llpolymorph.cpp |
331 | llprefsadvanced.cpp | 331 | llprefsadvanced.cpp |
332 | llpostprocess.cpp | ||
332 | llprefschat.cpp | 333 | llprefschat.cpp |
333 | llprefsim.cpp | 334 | llprefsim.cpp |
334 | llprefsvoice.cpp | 335 | llprefsvoice.cpp |
@@ -359,6 +360,7 @@ set(viewer_SOURCE_FILES | |||
359 | llsurface.cpp | 360 | llsurface.cpp |
360 | llsurfacepatch.cpp | 361 | llsurfacepatch.cpp |
361 | lltexlayer.cpp | 362 | lltexlayer.cpp |
363 | lltextureatlasmanager.cpp | ||
362 | lltexturecache.cpp | 364 | lltexturecache.cpp |
363 | lltexturectrl.cpp | 365 | lltexturectrl.cpp |
364 | lltexturefetch.cpp | 366 | lltexturefetch.cpp |
@@ -777,6 +779,7 @@ set(viewer_HEADER_FILES | |||
777 | llpolymesh.h | 779 | llpolymesh.h |
778 | llpolymorph.h | 780 | llpolymorph.h |
779 | llprefsadvanced.h | 781 | llprefsadvanced.h |
782 | llpostprocess.h | ||
780 | llprefschat.h | 783 | llprefschat.h |
781 | llprefsim.h | 784 | llprefsim.h |
782 | llprefsvoice.h | 785 | llprefsvoice.h |
@@ -809,6 +812,7 @@ set(viewer_HEADER_FILES | |||
809 | llsurfacepatch.h | 812 | llsurfacepatch.h |
810 | lltable.h | 813 | lltable.h |
811 | lltexlayer.h | 814 | lltexlayer.h |
815 | lltextureatlasmanager.h | ||
812 | lltexturecache.h | 816 | lltexturecache.h |
813 | lltexturectrl.h | 817 | lltexturectrl.h |
814 | lltexturefetch.h | 818 | lltexturefetch.h |
diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index f70c0fc..c7f8d36 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml | |||
@@ -5097,6 +5097,21 @@ | |||
5097 | <key>Value</key> | 5097 | <key>Value</key> |
5098 | <integer>1</integer> | 5098 | <integer>1</integer> |
5099 | </map> | 5099 | </map> |
5100 | |||
5101 | <!--KL port --> | ||
5102 | <key>EnableTextureAtlas</key> | ||
5103 | <map> | ||
5104 | <key>Comment</key> | ||
5105 | <string>Whether to use texture atlas or not</string> | ||
5106 | <key>Persist</key> | ||
5107 | <integer>1</integer> | ||
5108 | <key>Type</key> | ||
5109 | <string>Boolean</string> | ||
5110 | <key>Value</key> | ||
5111 | <integer>0</integer> | ||
5112 | </map> | ||
5113 | <!--/KL port --> | ||
5114 | |||
5100 | <key>EnableVoiceChat</key> | 5115 | <key>EnableVoiceChat</key> |
5101 | <map> | 5116 | <map> |
5102 | <key>Comment</key> | 5117 | <key>Comment</key> |
@@ -8928,11 +8943,74 @@ | |||
8928 | <string>Vector3</string> | 8943 | <string>Vector3</string> |
8929 | <key>Value</key> | 8944 | <key>Value</key> |
8930 | <array> | 8945 | <array> |
8946 | <real>1.0</real> | ||
8947 | <real>12.0</real> | ||
8948 | <real>32.0</real> | ||
8949 | </array> | ||
8950 | </map> | ||
8951 | <key>RenderShadowSplitExponent</key> | ||
8952 | <map> | ||
8953 | <key>Comment</key> | ||
8954 | <string>Near clip plane split distances for shadow map frusta (x=perspective, y=ortho, z=transition rate).</string> | ||
8955 | <key>Persist</key> | ||
8956 | <integer>1</integer> | ||
8957 | <key>Type</key> | ||
8958 | <string>Vector3</string> | ||
8959 | <key>Value</key> | ||
8960 | <array> | ||
8961 | <real>3.0</real> | ||
8962 | <real>3.0</real> | ||
8963 | <real>2.0</real> | ||
8964 | </array> | ||
8965 | </map> | ||
8966 | <key>RenderShadowOrthoClipPlanes</key> | ||
8967 | <map> | ||
8968 | <key>Comment</key> | ||
8969 | <string>Near clip plane split distances for orthographic shadow map frusta.</string> | ||
8970 | <key>Persist</key> | ||
8971 | <integer>1</integer> | ||
8972 | <key>Type</key> | ||
8973 | <string>Vector3</string> | ||
8974 | <key>Value</key> | ||
8975 | <array> | ||
8931 | <real>4.0</real> | 8976 | <real>4.0</real> |
8932 | <real>8.0</real> | 8977 | <real>8.0</real> |
8933 | <real>24.0</real> | 8978 | <real>24.0</real> |
8934 | </array> | 8979 | </array> |
8935 | </map> | 8980 | </map> |
8981 | <key>RenderShadowProjOffset</key> | ||
8982 | <map> | ||
8983 | <key>Comment</key> | ||
8984 | <string>Amount to scale distance to virtual origin of shadow perspective projection.</string> | ||
8985 | <key>Persist</key> | ||
8986 | <integer>1</integer> | ||
8987 | <key>Type</key> | ||
8988 | <string>F32</string> | ||
8989 | <key>Value</key> | ||
8990 | <real>2.0</real> | ||
8991 | </map> | ||
8992 | <key>RenderShadowSlopeThreshold</key> | ||
8993 | <map> | ||
8994 | <key>Comment</key> | ||
8995 | <string>Cutoff slope value for points to affect perspective shadow generation</string> | ||
8996 | <key>Persist</key> | ||
8997 | <integer>1</integer> | ||
8998 | <key>Type</key> | ||
8999 | <string>F32</string> | ||
9000 | <key>Value</key> | ||
9001 | <real>0.0</real> | ||
9002 | </map> | ||
9003 | <key>RenderShadowProjExponent</key> | ||
9004 | <map> | ||
9005 | <key>Comment</key> | ||
9006 | <string>Exponent applied to transition between ortho and perspective shadow projections based on viewing angle and light vector.</string> | ||
9007 | <key>Persist</key> | ||
9008 | <integer>1</integer> | ||
9009 | <key>Type</key> | ||
9010 | <string>F32</string> | ||
9011 | <key>Value</key> | ||
9012 | <real>0.5</real> | ||
9013 | </map> | ||
8936 | <key>RenderSSAOScale</key> | 9014 | <key>RenderSSAOScale</key> |
8937 | <map> | 9015 | <map> |
8938 | <key>Comment</key> | 9016 | <key>Comment</key> |
@@ -9092,6 +9170,184 @@ | |||
9092 | <key>Value</key> | 9170 | <key>Value</key> |
9093 | <integer>0</integer> | 9171 | <integer>0</integer> |
9094 | </map> | 9172 | </map> |
9173 | |||
9174 | <key>RenderGILightRadius</key> | ||
9175 | <map> | ||
9176 | <key>Comment</key> | ||
9177 | <string>Distance of ambiant bounce lighting from sun.</string> | ||
9178 | <key>Persist</key> | ||
9179 | <integer>1</integer> | ||
9180 | <key>Type</key> | ||
9181 | <string>F32</string> | ||
9182 | <key>Value</key> | ||
9183 | <real>8</real> | ||
9184 | </map> | ||
9185 | |||
9186 | <key>RenderGISamples</key> | ||
9187 | <map> | ||
9188 | <key>Comment</key> | ||
9189 | <string>Number of samples to take for GI.</string> | ||
9190 | <key>Persist</key> | ||
9191 | <integer>1</integer> | ||
9192 | <key>Type</key> | ||
9193 | <string>U32</string> | ||
9194 | <key>Value</key> | ||
9195 | <real>64</real> | ||
9196 | </map> | ||
9197 | |||
9198 | <key>RenderGIRange</key> | ||
9199 | <map> | ||
9200 | <key>Comment</key> | ||
9201 | <string>Distance to cut off GI effect.</string> | ||
9202 | <key>Persist</key> | ||
9203 | <integer>1</integer> | ||
9204 | <key>Type</key> | ||
9205 | <string>F32</string> | ||
9206 | <key>Value</key> | ||
9207 | <real>128</real> | ||
9208 | </map> | ||
9209 | |||
9210 | |||
9211 | <key>RenderGIDirectionWeight</key> | ||
9212 | <map> | ||
9213 | <key>Comment</key> | ||
9214 | <string>Weight of reflected light vector in GI angular attenuation.</string> | ||
9215 | <key>Persist</key> | ||
9216 | <integer>1</integer> | ||
9217 | <key>Type</key> | ||
9218 | <string>F32</string> | ||
9219 | <key>Value</key> | ||
9220 | <real>0.5</real> | ||
9221 | </map> | ||
9222 | |||
9223 | <key>RenderGILightOffset</key> | ||
9224 | <map> | ||
9225 | <key>Comment</key> | ||
9226 | <string>Amount to offset light from point of impact in gi map (scaled by light radius).</string> | ||
9227 | <key>Persist</key> | ||
9228 | <integer>1</integer> | ||
9229 | <key>Type</key> | ||
9230 | <string>F32</string> | ||
9231 | <key>Value</key> | ||
9232 | <real>0.0</real> | ||
9233 | </map> | ||
9234 | |||
9235 | <key>RenderGIColorCurve</key> | ||
9236 | <map> | ||
9237 | <key>Comment</key> | ||
9238 | <string>Global illumination color correction curve parameters.</string> | ||
9239 | <key>Persist</key> | ||
9240 | <integer>1</integer> | ||
9241 | <key>Type</key> | ||
9242 | <string>Vector3</string> | ||
9243 | <key>Value</key> | ||
9244 | <array> | ||
9245 | <real>0.0</real> | ||
9246 | <real>0.2</real> | ||
9247 | <real>0.02</real> | ||
9248 | </array> | ||
9249 | </map> | ||
9250 | |||
9251 | <key>RenderLuminanceColorCurve</key> | ||
9252 | <map> | ||
9253 | <key>Comment</key> | ||
9254 | <string>Luminance color correction curve parameters.</string> | ||
9255 | <key>Persist</key> | ||
9256 | <integer>1</integer> | ||
9257 | <key>Type</key> | ||
9258 | <string>Vector3</string> | ||
9259 | <key>Value</key> | ||
9260 | <array> | ||
9261 | <real>0.30</real> | ||
9262 | <real>0.0</real> | ||
9263 | <real>0.04</real> | ||
9264 | </array> | ||
9265 | </map> | ||
9266 | |||
9267 | <key>RenderGILuminanceColorCurve</key> | ||
9268 | <map> | ||
9269 | <key>Comment</key> | ||
9270 | <string>Luminance color correction curve parameters.</string> | ||
9271 | <key>Persist</key> | ||
9272 | <integer>1</integer> | ||
9273 | <key>Type</key> | ||
9274 | <string>Vector3</string> | ||
9275 | <key>Value</key> | ||
9276 | <array> | ||
9277 | <real>0.4</real> | ||
9278 | <real>0.0</real> | ||
9279 | <real>0.05</real> | ||
9280 | </array> | ||
9281 | </map> | ||
9282 | |||
9283 | <key>RenderSunLuminanceColorCurve</key> | ||
9284 | <map> | ||
9285 | <key>Comment</key> | ||
9286 | <string>Luminance color correction curve parameters.</string> | ||
9287 | <key>Persist</key> | ||
9288 | <integer>1</integer> | ||
9289 | <key>Type</key> | ||
9290 | <string>Vector3</string> | ||
9291 | <key>Value</key> | ||
9292 | <array> | ||
9293 | <real>0.6</real> | ||
9294 | <real>0.0</real> | ||
9295 | <real>-0.3</real> | ||
9296 | </array> | ||
9297 | </map> | ||
9298 | |||
9299 | <key>RenderLuminanceDetail</key> | ||
9300 | <map> | ||
9301 | <key>Comment</key> | ||
9302 | <string>Mipmap level to use for luminance</string> | ||
9303 | <key>Persist</key> | ||
9304 | <integer>1</integer> | ||
9305 | <key>Type</key> | ||
9306 | <string>F32</string> | ||
9307 | <key>Value</key> | ||
9308 | <real>8.0</real> | ||
9309 | </map> | ||
9310 | |||
9311 | <key>RenderLuminanceFade</key> | ||
9312 | <map> | ||
9313 | <key>Comment</key> | ||
9314 | <string>Scaler for speed of luminance adjustment</string> | ||
9315 | <key>Persist</key> | ||
9316 | <integer>1</integer> | ||
9317 | <key>Type</key> | ||
9318 | <string>F32</string> | ||
9319 | <key>Value</key> | ||
9320 | <real>0.05</real> | ||
9321 | </map> | ||
9322 | |||
9323 | <key>RenderGISpecularCurve</key> | ||
9324 | <map> | ||
9325 | <key>Comment</key> | ||
9326 | <string>Global illumination specular color correction curve parameters.</string> | ||
9327 | <key>Persist</key> | ||
9328 | <integer>1</integer> | ||
9329 | <key>Type</key> | ||
9330 | <string>Vector3</string> | ||
9331 | <key>Value</key> | ||
9332 | <array> | ||
9333 | <real>0.1</real> | ||
9334 | <real>0.0</real> | ||
9335 | <real>0.9</real> | ||
9336 | </array> | ||
9337 | </map> | ||
9338 | |||
9339 | <key>RenderGIIntensity</key> | ||
9340 | <map> | ||
9341 | <key>Comment</key> | ||
9342 | <string>Distance of ambiant bounce lighting from sun.</string> | ||
9343 | <key>Persist</key> | ||
9344 | <integer>1</integer> | ||
9345 | <key>Type</key> | ||
9346 | <string>F32</string> | ||
9347 | <key>Value</key> | ||
9348 | <real>0.2f</real> | ||
9349 | </map> | ||
9350 | |||
9095 | <key>RenderDeferredAlphaSoften</key> | 9351 | <key>RenderDeferredAlphaSoften</key> |
9096 | <map> | 9352 | <map> |
9097 | <key>Comment</key> | 9353 | <key>Comment</key> |
@@ -9114,6 +9370,178 @@ | |||
9114 | <key>Value</key> | 9370 | <key>Value</key> |
9115 | <real>4</real> | 9371 | <real>4</real> |
9116 | </map> | 9372 | </map> |
9373 | <key>RenderDeferredSpotShadowBias</key> | ||
9374 | <map> | ||
9375 | <key>Comment</key> | ||
9376 | <string>Bias value for spot shadows (prevent shadow acne).</string> | ||
9377 | <key>Persist</key> | ||
9378 | <integer>1</integer> | ||
9379 | <key>Type</key> | ||
9380 | <string>F32</string> | ||
9381 | <key>Value</key> | ||
9382 | <real>-64.0</real> | ||
9383 | </map> | ||
9384 | <key>RenderDeferredSpotShadowOffset</key> | ||
9385 | <map> | ||
9386 | <key>Comment</key> | ||
9387 | <string>Offset value for spot shadows (prevent shadow acne).</string> | ||
9388 | <key>Persist</key> | ||
9389 | <integer>1</integer> | ||
9390 | <key>Type</key> | ||
9391 | <string>F32</string> | ||
9392 | <key>Value</key> | ||
9393 | <real>0.8</real> | ||
9394 | </map> | ||
9395 | |||
9396 | <key>RenderShadowBias</key> | ||
9397 | <map> | ||
9398 | <key>Comment</key> | ||
9399 | <string>Bias value for shadows (prevent shadow acne).</string> | ||
9400 | <key>Persist</key> | ||
9401 | <integer>1</integer> | ||
9402 | <key>Type</key> | ||
9403 | <string>F32</string> | ||
9404 | <key>Value</key> | ||
9405 | <real>0.001</real> | ||
9406 | </map> | ||
9407 | <key>RenderShadowOffset</key> | ||
9408 | <map> | ||
9409 | <key>Comment</key> | ||
9410 | <string>Offset value for shadows (prevent shadow acne).</string> | ||
9411 | <key>Persist</key> | ||
9412 | <integer>1</integer> | ||
9413 | <key>Type</key> | ||
9414 | <string>F32</string> | ||
9415 | <key>Value</key> | ||
9416 | <real>0.6</real> | ||
9417 | </map> | ||
9418 | |||
9419 | <key>RenderShadowResolutionScale</key> | ||
9420 | <map> | ||
9421 | <key>Comment</key> | ||
9422 | <string>Scale of shadow map resolution vs. screen resolution</string> | ||
9423 | <key>Persist</key> | ||
9424 | <integer>1</integer> | ||
9425 | <key>Type</key> | ||
9426 | <string>F32</string> | ||
9427 | <key>Value</key> | ||
9428 | <real>1.0</real> | ||
9429 | </map> | ||
9430 | |||
9431 | |||
9432 | |||
9433 | <key>RenderDeferredTreeShadowBias</key> | ||
9434 | <map> | ||
9435 | <key>Comment</key> | ||
9436 | <string>Bias value for tree shadows (prevent shadow acne).</string> | ||
9437 | <key>Persist</key> | ||
9438 | <integer>1</integer> | ||
9439 | <key>Type</key> | ||
9440 | <string>F32</string> | ||
9441 | <key>Value</key> | ||
9442 | <real>1.0</real> | ||
9443 | </map> | ||
9444 | <key>RenderDeferredTreeShadowOffset</key> | ||
9445 | <map> | ||
9446 | <key>Comment</key> | ||
9447 | <string>Offset value for tree shadows (prevent shadow acne).</string> | ||
9448 | <key>Persist</key> | ||
9449 | <integer>1</integer> | ||
9450 | <key>Type</key> | ||
9451 | <string>F32</string> | ||
9452 | <key>Value</key> | ||
9453 | <real>1.0</real> | ||
9454 | </map> | ||
9455 | |||
9456 | <key>RenderHighlightFadeTime</key> | ||
9457 | <map> | ||
9458 | <key>Comment</key> | ||
9459 | <string>Transition time for mouseover highlights.</string> | ||
9460 | <key>Persist</key> | ||
9461 | <integer>1</integer> | ||
9462 | <key>Type</key> | ||
9463 | <string>F32</string> | ||
9464 | <key>Value</key> | ||
9465 | <real>0.2</real> | ||
9466 | </map> | ||
9467 | |||
9468 | <key>RenderHighlightBrightness</key> | ||
9469 | <map> | ||
9470 | <key>Comment</key> | ||
9471 | <string>Brightness of mouseover highlights.</string> | ||
9472 | <key>Persist</key> | ||
9473 | <integer>1</integer> | ||
9474 | <key>Type</key> | ||
9475 | <string>F32</string> | ||
9476 | <key>Value</key> | ||
9477 | <real>4.0</real> | ||
9478 | </map> | ||
9479 | |||
9480 | <key>RenderHighlightThickness</key> | ||
9481 | <map> | ||
9482 | <key>Comment</key> | ||
9483 | <string>Thickness of mouseover highlights.</string> | ||
9484 | <key>Persist</key> | ||
9485 | <integer>1</integer> | ||
9486 | <key>Type</key> | ||
9487 | <string>F32</string> | ||
9488 | <key>Value</key> | ||
9489 | <real>0.6</real> | ||
9490 | </map> | ||
9491 | |||
9492 | <key>RenderHighlightColor</key> | ||
9493 | <map> | ||
9494 | <key>Comment</key> | ||
9495 | <string>Brightness of mouseover highlights.</string> | ||
9496 | <key>Persist</key> | ||
9497 | <integer>1</integer> | ||
9498 | <key>Type</key> | ||
9499 | <string>Color4</string> | ||
9500 | <key>Value</key> | ||
9501 | <array> | ||
9502 | <real>0.4</real> | ||
9503 | <real>0.98</real> | ||
9504 | <real>0.93</real> | ||
9505 | <real>1.0</real> | ||
9506 | </array> | ||
9507 | </map> | ||
9508 | |||
9509 | <key>RenderSpecularResX</key> | ||
9510 | <map> | ||
9511 | <key>Comment</key> | ||
9512 | <string>Spec map resolution.</string> | ||
9513 | <key>Persist</key> | ||
9514 | <integer>1</integer> | ||
9515 | <key>Type</key> | ||
9516 | <string>U32</string> | ||
9517 | <key>Value</key> | ||
9518 | <real>128</real> | ||
9519 | </map> | ||
9520 | |||
9521 | <key>RenderSpecularResY</key> | ||
9522 | <map> | ||
9523 | <key>Comment</key> | ||
9524 | <string>Spec map resolution.</string> | ||
9525 | <key>Persist</key> | ||
9526 | <integer>1</integer> | ||
9527 | <key>Type</key> | ||
9528 | <string>U32</string> | ||
9529 | <key>Value</key> | ||
9530 | <real>128</real> | ||
9531 | </map> | ||
9532 | |||
9533 | <key>RenderSpecularExponent</key> | ||
9534 | <map> | ||
9535 | <key>Comment</key> | ||
9536 | <string>Specular exponent for generating spec map</string> | ||
9537 | <key>Persist</key> | ||
9538 | <integer>1</integer> | ||
9539 | <key>Type</key> | ||
9540 | <string>F32</string> | ||
9541 | <key>Value</key> | ||
9542 | <real>1</real> | ||
9543 | </map> | ||
9544 | |||
9117 | <key>RenderDeferred</key> | 9545 | <key>RenderDeferred</key> |
9118 | <map> | 9546 | <map> |
9119 | <key>Comment</key> | 9547 | <key>Comment</key> |
@@ -9125,6 +9553,31 @@ | |||
9125 | <key>Value</key> | 9553 | <key>Value</key> |
9126 | <integer>0</integer> | 9554 | <integer>0</integer> |
9127 | </map> | 9555 | </map> |
9556 | |||
9557 | <key>RenderDeferredShadow</key> | ||
9558 | <map> | ||
9559 | <key>Comment</key> | ||
9560 | <string>Enable shadows in deferred renderer.</string> | ||
9561 | <key>Persist</key> | ||
9562 | <integer>1</integer> | ||
9563 | <key>Type</key> | ||
9564 | <string>Boolean</string> | ||
9565 | <key>Value</key> | ||
9566 | <integer>1</integer> | ||
9567 | </map> | ||
9568 | |||
9569 | <key>RenderDeferredGI</key> | ||
9570 | <map> | ||
9571 | <key>Comment</key> | ||
9572 | <string>Enable GI in deferred renderer.</string> | ||
9573 | <key>Persist</key> | ||
9574 | <integer>1</integer> | ||
9575 | <key>Type</key> | ||
9576 | <string>Boolean</string> | ||
9577 | <key>Value</key> | ||
9578 | <integer>0</integer> | ||
9579 | </map> | ||
9580 | |||
9128 | <key>RenderDeferredSunShadow</key> | 9581 | <key>RenderDeferredSunShadow</key> |
9129 | <map> | 9582 | <map> |
9130 | <key>Comment</key> | 9583 | <key>Comment</key> |
@@ -9136,6 +9589,67 @@ | |||
9136 | <key>Value</key> | 9589 | <key>Value</key> |
9137 | <integer>1</integer> | 9590 | <integer>1</integer> |
9138 | </map> | 9591 | </map> |
9592 | |||
9593 | <key>RenderDeferredSun</key> | ||
9594 | <map> | ||
9595 | <key>Comment</key> | ||
9596 | <string>Execute sunlight shader in deferred renderer.</string> | ||
9597 | <key>Persist</key> | ||
9598 | <integer>1</integer> | ||
9599 | <key>Type</key> | ||
9600 | <string>Boolean</string> | ||
9601 | <key>Value</key> | ||
9602 | <integer>1</integer> | ||
9603 | </map> | ||
9604 | |||
9605 | <key>RenderDeferredAtmospheric</key> | ||
9606 | <map> | ||
9607 | <key>Comment</key> | ||
9608 | <string>Execute atmospheric shader in deferred renderer.</string> | ||
9609 | <key>Persist</key> | ||
9610 | <integer>1</integer> | ||
9611 | <key>Type</key> | ||
9612 | <string>Boolean</string> | ||
9613 | <key>Value</key> | ||
9614 | <integer>1</integer> | ||
9615 | </map> | ||
9616 | |||
9617 | <key>RenderDeferredBlurLight</key> | ||
9618 | <map> | ||
9619 | <key>Comment</key> | ||
9620 | <string>Execute shadow softening shader in deferred renderer.</string> | ||
9621 | <key>Persist</key> | ||
9622 | <integer>1</integer> | ||
9623 | <key>Type</key> | ||
9624 | <string>Boolean</string> | ||
9625 | <key>Value</key> | ||
9626 | <integer>1</integer> | ||
9627 | </map> | ||
9628 | |||
9629 | <key>RenderDeferredLocalLights</key> | ||
9630 | <map> | ||
9631 | <key>Comment</key> | ||
9632 | <string>Execute local lighting shader in deferred renderer.</string> | ||
9633 | <key>Persist</key> | ||
9634 | <integer>1</integer> | ||
9635 | <key>Type</key> | ||
9636 | <string>Boolean</string> | ||
9637 | <key>Value</key> | ||
9638 | <integer>1</integer> | ||
9639 | </map> | ||
9640 | |||
9641 | <key>RenderDeferredFullscreenLights</key> | ||
9642 | <map> | ||
9643 | <key>Comment</key> | ||
9644 | <string>Execute local lighting shader in deferred renderer.</string> | ||
9645 | <key>Persist</key> | ||
9646 | <integer>1</integer> | ||
9647 | <key>Type</key> | ||
9648 | <string>Boolean</string> | ||
9649 | <key>Value</key> | ||
9650 | <integer>1</integer> | ||
9651 | </map> | ||
9652 | |||
9139 | <key>RenderDeferredSunWash</key> | 9653 | <key>RenderDeferredSunWash</key> |
9140 | <map> | 9654 | <map> |
9141 | <key>Comment</key> | 9655 | <key>Comment</key> |
@@ -9158,6 +9672,45 @@ | |||
9158 | <key>Value</key> | 9672 | <key>Value</key> |
9159 | <real>-0.0001</real> | 9673 | <real>-0.0001</real> |
9160 | </map> | 9674 | </map> |
9675 | <key>RenderShadowErrorCutoff</key> | ||
9676 | <map> | ||
9677 | <key>Comment</key> | ||
9678 | <string>Cutoff error value to use ortho instead of perspective projection.</string> | ||
9679 | <key>Persist</key> | ||
9680 | <integer>1</integer> | ||
9681 | <key>Type</key> | ||
9682 | <string>F32</string> | ||
9683 | <key>Value</key> | ||
9684 | <real>5.0</real> | ||
9685 | </map> | ||
9686 | <key>RenderShadowFOVCutoff</key> | ||
9687 | <map> | ||
9688 | <key>Comment</key> | ||
9689 | <string>Cutoff FOV to use ortho instead of perspective projection.</string> | ||
9690 | <key>Persist</key> | ||
9691 | <integer>1</integer> | ||
9692 | <key>Type</key> | ||
9693 | <string>F32</string> | ||
9694 | <key>Value</key> | ||
9695 | <real>1.1</real> | ||
9696 | </map> | ||
9697 | |||
9698 | <key>RenderShadowGaussian</key> | ||
9699 | <map> | ||
9700 | <key>Comment</key> | ||
9701 | <string>Gaussian coefficients for the two shadow/SSAO blurring passes (z component unused).</string> | ||
9702 | <key>Persist</key> | ||
9703 | <integer>1</integer> | ||
9704 | <key>Type</key> | ||
9705 | <string>Vector3</string> | ||
9706 | <key>Value</key> | ||
9707 | <array> | ||
9708 | <real>3.0</real> | ||
9709 | <real>2.0</real> | ||
9710 | <real>0.0</real> | ||
9711 | </array> | ||
9712 | </map> | ||
9713 | |||
9161 | <key>RenderShadowBlurSize</key> | 9714 | <key>RenderShadowBlurSize</key> |
9162 | <map> | 9715 | <map> |
9163 | <key>Comment</key> | 9716 | <key>Comment</key> |
@@ -9167,7 +9720,7 @@ | |||
9167 | <key>Type</key> | 9720 | <key>Type</key> |
9168 | <string>F32</string> | 9721 | <string>F32</string> |
9169 | <key>Value</key> | 9722 | <key>Value</key> |
9170 | <real>0.7</real> | 9723 | <real>0.8</real> |
9171 | </map> | 9724 | </map> |
9172 | <key>RenderShadowBlurSamples</key> | 9725 | <key>RenderShadowBlurSamples</key> |
9173 | <map> | 9726 | <map> |
@@ -9178,8 +9731,94 @@ | |||
9178 | <key>Type</key> | 9731 | <key>Type</key> |
9179 | <string>U32</string> | 9732 | <string>U32</string> |
9180 | <key>Value</key> | 9733 | <key>Value</key> |
9181 | <real>5</real> | 9734 | <real>4</real> |
9735 | </map> | ||
9736 | <key>RenderShadowBlurDistFactor</key> | ||
9737 | <map> | ||
9738 | <key>Comment</key> | ||
9739 | <string>Distance scaler for shadow blur.</string> | ||
9740 | <key>Persist</key> | ||
9741 | <integer>1</integer> | ||
9742 | <key>Type</key> | ||
9743 | <string>F32</string> | ||
9744 | <key>Value</key> | ||
9745 | <real>0.1</real> | ||
9746 | </map> | ||
9747 | |||
9748 | <key>RenderGIBlurColorCurve</key> | ||
9749 | <map> | ||
9750 | <key>Comment</key> | ||
9751 | <string>Color curve for GI softening kernel</string> | ||
9752 | <key>Persist</key> | ||
9753 | <integer>1</integer> | ||
9754 | <key>Type</key> | ||
9755 | <string>Vector3</string> | ||
9756 | <key>Value</key> | ||
9757 | <array> | ||
9758 | <real>1.0</real> | ||
9759 | <real>0.6</real> | ||
9760 | <real>0.1</real> | ||
9761 | </array> | ||
9762 | </map> | ||
9763 | |||
9764 | <key>RenderGIGaussian</key> | ||
9765 | <map> | ||
9766 | <key>Comment</key> | ||
9767 | <string>Gaussian coefficient for the two GI blurring passes.</string> | ||
9768 | <key>Persist</key> | ||
9769 | <integer>1</integer> | ||
9770 | <key>Type</key> | ||
9771 | <string>F32</string> | ||
9772 | <key>Value</key> | ||
9773 | <real>64</real> | ||
9774 | </map> | ||
9775 | |||
9776 | <key>RenderGIBlurPasses</key> | ||
9777 | <map> | ||
9778 | <key>Comment</key> | ||
9779 | <string>Scale of GI softening kernel.</string> | ||
9780 | <key>Persist</key> | ||
9781 | <integer>1</integer> | ||
9782 | <key>Type</key> | ||
9783 | <string>U32</string> | ||
9784 | <key>Value</key> | ||
9785 | <real>2</real> | ||
9786 | </map> | ||
9787 | |||
9788 | <key>RenderGIBlurSize</key> | ||
9789 | <map> | ||
9790 | <key>Comment</key> | ||
9791 | <string>Scale of GI softening kernel.</string> | ||
9792 | <key>Persist</key> | ||
9793 | <integer>1</integer> | ||
9794 | <key>Type</key> | ||
9795 | <string>F32</string> | ||
9796 | <key>Value</key> | ||
9797 | <real>3.0</real> | ||
9798 | </map> | ||
9799 | <key>RenderGIBlurSamples</key> | ||
9800 | <map> | ||
9801 | <key>Comment</key> | ||
9802 | <string>Number of samples to take for each pass of GI blur (value range 1-16). Actual number of samples is value * 2 - 1.</string> | ||
9803 | <key>Persist</key> | ||
9804 | <integer>1</integer> | ||
9805 | <key>Type</key> | ||
9806 | <string>U32</string> | ||
9807 | <key>Value</key> | ||
9808 | <real>6</real> | ||
9182 | </map> | 9809 | </map> |
9810 | <key>RenderGIBlurDistFactor</key> | ||
9811 | <map> | ||
9812 | <key>Comment</key> | ||
9813 | <string>Distance scaler for GI blur.</string> | ||
9814 | <key>Persist</key> | ||
9815 | <integer>1</integer> | ||
9816 | <key>Type</key> | ||
9817 | <string>F32</string> | ||
9818 | <key>Value</key> | ||
9819 | <real>0.0</real> | ||
9820 | </map> | ||
9821 | |||
9183 | <key>RenderDynamicLOD</key> | 9822 | <key>RenderDynamicLOD</key> |
9184 | <map> | 9823 | <map> |
9185 | <key>Comment</key> | 9824 | <key>Comment</key> |
@@ -9430,6 +10069,17 @@ | |||
9430 | <key>Value</key> | 10069 | <key>Value</key> |
9431 | <integer>0</integer> | 10070 | <integer>0</integer> |
9432 | </map> | 10071 | </map> |
10072 | <key>RenderHighlightSelections</key> | ||
10073 | <map> | ||
10074 | <key>Comment</key> | ||
10075 | <string>Show selection outlines on objects</string> | ||
10076 | <key>Persist</key> | ||
10077 | <integer>1</integer> | ||
10078 | <key>Type</key> | ||
10079 | <string>Boolean</string> | ||
10080 | <key>Value</key> | ||
10081 | <integer>1</integer> | ||
10082 | </map> | ||
9433 | <key>RenderHiddenSelections</key> | 10083 | <key>RenderHiddenSelections</key> |
9434 | <map> | 10084 | <map> |
9435 | <key>Comment</key> | 10085 | <key>Comment</key> |
@@ -9738,6 +10388,17 @@ | |||
9738 | <key>Value</key> | 10388 | <key>Value</key> |
9739 | <integer>0</integer> | 10389 | <integer>0</integer> |
9740 | </map> | 10390 | </map> |
10391 | <key>RenderUIBuffer</key> | ||
10392 | <map> | ||
10393 | <key>Comment</key> | ||
10394 | <string>Cache ui render in a screen aligned buffer.</string> | ||
10395 | <key>Persist</key> | ||
10396 | <integer>1</integer> | ||
10397 | <key>Type</key> | ||
10398 | <string>Boolean</string> | ||
10399 | <key>Value</key> | ||
10400 | <integer>0</integer> | ||
10401 | </map> | ||
9741 | <key>RenderUnloadedAvatar</key> | 10402 | <key>RenderUnloadedAvatar</key> |
9742 | <map> | 10403 | <map> |
9743 | <key>Comment</key> | 10404 | <key>Comment</key> |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index a91e9fa..f90d91f 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | |||
@@ -13,9 +13,9 @@ uniform sampler2DShadow shadowMap1; | |||
13 | uniform sampler2DShadow shadowMap2; | 13 | uniform sampler2DShadow shadowMap2; |
14 | uniform sampler2DShadow shadowMap3; | 14 | uniform sampler2DShadow shadowMap3; |
15 | uniform sampler2D noiseMap; | 15 | uniform sampler2D noiseMap; |
16 | uniform sampler2DRect positionMap; | 16 | uniform sampler2DRect depthMap; |
17 | 17 | ||
18 | uniform mat4 shadow_matrix[4]; | 18 | uniform mat4 shadow_matrix[6]; |
19 | uniform vec4 shadow_clip; | 19 | uniform vec4 shadow_clip; |
20 | uniform vec2 screen_res; | 20 | uniform vec2 screen_res; |
21 | 21 | ||
@@ -26,15 +26,31 @@ varying vec3 vary_ambient; | |||
26 | varying vec3 vary_directional; | 26 | varying vec3 vary_directional; |
27 | varying vec3 vary_fragcoord; | 27 | varying vec3 vary_fragcoord; |
28 | varying vec3 vary_position; | 28 | varying vec3 vary_position; |
29 | varying vec3 vary_light; | ||
29 | 30 | ||
30 | uniform float alpha_soften; | 31 | uniform float alpha_soften; |
31 | 32 | ||
33 | uniform mat4 inv_proj; | ||
34 | |||
35 | vec4 getPosition(vec2 pos_screen) | ||
36 | { | ||
37 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
38 | vec2 sc = pos_screen.xy*2.0; | ||
39 | sc /= screen_res; | ||
40 | sc -= vec2(1.0,1.0); | ||
41 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
42 | vec4 pos = inv_proj * ndc; | ||
43 | pos /= pos.w; | ||
44 | pos.w = 1.0; | ||
45 | return pos; | ||
46 | } | ||
47 | |||
32 | void main() | 48 | void main() |
33 | { | 49 | { |
34 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; | 50 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; |
35 | frag *= screen_res; | 51 | frag *= screen_res; |
36 | 52 | ||
37 | vec3 samp_pos = texture2DRect(positionMap, frag).xyz; | 53 | vec3 samp_pos = getPosition(frag).xyz; |
38 | 54 | ||
39 | float shadow = 1.0; | 55 | float shadow = 1.0; |
40 | vec4 pos = vec4(vary_position, 1.0); | 56 | vec4 pos = vec4(vary_position, 1.0); |
@@ -82,7 +98,7 @@ void main() | |||
82 | 98 | ||
83 | //gl_FragColor = gl_Color; | 99 | //gl_FragColor = gl_Color; |
84 | gl_FragColor = color; | 100 | gl_FragColor = color; |
85 | //gl_FragColor = vec4(1,0,1,1); | 101 | //gl_FragColor = vec4(1,0,1,1)*shadow; |
86 | 102 | ||
87 | } | 103 | } |
88 | 104 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index b496bd6..48baf77 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl | |||
@@ -20,8 +20,11 @@ varying vec3 vary_ambient; | |||
20 | varying vec3 vary_directional; | 20 | varying vec3 vary_directional; |
21 | varying vec3 vary_fragcoord; | 21 | varying vec3 vary_fragcoord; |
22 | varying vec3 vary_position; | 22 | varying vec3 vary_position; |
23 | varying vec3 vary_light; | ||
23 | 24 | ||
24 | uniform float near_clip; | 25 | uniform float near_clip; |
26 | uniform float shadow_offset; | ||
27 | uniform float shadow_bias; | ||
25 | 28 | ||
26 | void main() | 29 | void main() |
27 | { | 30 | { |
@@ -32,8 +35,9 @@ void main() | |||
32 | 35 | ||
33 | vec4 pos = (gl_ModelViewMatrix * gl_Vertex); | 36 | vec4 pos = (gl_ModelViewMatrix * gl_Vertex); |
34 | vec3 norm = normalize(gl_NormalMatrix * gl_Normal); | 37 | vec3 norm = normalize(gl_NormalMatrix * gl_Normal); |
35 | vary_position = pos.xyz; | 38 | // KL this works around ATI not compiling the shader but maintains shadow offset and bias vec3 not vec4 |
36 | 39 | vary_position = pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias); | |
40 | |||
37 | calcAtmospherics(pos.xyz); | 41 | calcAtmospherics(pos.xyz); |
38 | 42 | ||
39 | //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); | 43 | //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); |
@@ -54,6 +58,8 @@ void main() | |||
54 | col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); | 58 | col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); |
55 | col.rgb = scaleDownLight(col.rgb); | 59 | col.rgb = scaleDownLight(col.rgb); |
56 | 60 | ||
61 | vary_light = gl_LightSource[0].position.xyz; | ||
62 | |||
57 | vary_ambient = col.rgb*gl_Color.rgb; | 63 | vary_ambient = col.rgb*gl_Color.rgb; |
58 | vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a))); | 64 | vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a))); |
59 | 65 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl index 6c94f5c..ff64a6b 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl | |||
@@ -12,7 +12,7 @@ uniform sampler2DShadow shadowMap2; | |||
12 | uniform sampler2DShadow shadowMap3; | 12 | uniform sampler2DShadow shadowMap3; |
13 | uniform sampler2D noiseMap; | 13 | uniform sampler2D noiseMap; |
14 | 14 | ||
15 | uniform mat4 shadow_matrix[4]; | 15 | uniform mat4 shadow_matrix[6]; |
16 | uniform vec4 shadow_clip; | 16 | uniform vec4 shadow_clip; |
17 | 17 | ||
18 | vec3 atmosLighting(vec3 light); | 18 | vec3 atmosLighting(vec3 light); |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index 58aa5a9..4b9cca2 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl | |||
@@ -8,13 +8,18 @@ | |||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec3 vary_normal; | 10 | varying vec3 vary_normal; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
15 | gl_FragData[0] = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); | 14 | vec4 diff = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); |
15 | // Viewer 2.0 uses 0.2 but for KL's viewer if i want a complete avatar need this to be 0.0 for now. | ||
16 | if (diff.a < 0.0) | ||
17 | { | ||
18 | discard; | ||
19 | } | ||
20 | |||
21 | gl_FragData[0] = vec4(diff.rgb, 1.0); | ||
16 | gl_FragData[1] = vec4(0,0,0,0); | 22 | gl_FragData[1] = vec4(0,0,0,0); |
17 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 23 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
18 | gl_FragData[3] = vary_position; | ||
19 | } | 24 | } |
20 | 25 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index 27c09db..00083eb 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl | |||
@@ -10,6 +10,7 @@ uniform sampler2D diffuseMap; | |||
10 | 10 | ||
11 | void main() | 11 | void main() |
12 | { | 12 | { |
13 | gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy)); | 13 | gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a); |
14 | //gl_FragColor = vec4(1,1,1,1); | ||
14 | } | 15 | } |
15 | 16 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl index 14da6b1..8c8489d 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl | |||
@@ -28,8 +28,7 @@ void main() | |||
28 | norm = normalize(norm); | 28 | norm = normalize(norm); |
29 | 29 | ||
30 | pos = gl_ProjectionMatrix * pos; | 30 | pos = gl_ProjectionMatrix * pos; |
31 | //smash geometry against near clip plane | 31 | pos.z = max(pos.z, -pos.w+0.01); |
32 | pos.z = max(pos.z, -1.0); | ||
33 | gl_Position = pos; | 32 | gl_Position = pos; |
34 | 33 | ||
35 | gl_FrontColor = gl_Color; | 34 | gl_FrontColor = gl_Color; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl index 12a7ff7..471a1f0 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl | |||
@@ -10,7 +10,6 @@ mat4 getSkinnedTransform(); | |||
10 | attribute vec4 weight; | 10 | attribute vec4 weight; |
11 | 11 | ||
12 | varying vec3 vary_normal; | 12 | varying vec3 vary_normal; |
13 | varying vec4 vary_position; | ||
14 | 13 | ||
15 | void main() | 14 | void main() |
16 | { | 15 | { |
@@ -30,7 +29,6 @@ void main() | |||
30 | norm.z = dot(trans[2].xyz, gl_Normal); | 29 | norm.z = dot(trans[2].xyz, gl_Normal); |
31 | norm = normalize(norm); | 30 | norm = normalize(norm); |
32 | 31 | ||
33 | vary_position = pos; | ||
34 | vary_normal = norm; | 32 | vary_normal = norm; |
35 | 33 | ||
36 | gl_Position = gl_ProjectionMatrix * pos; | 34 | gl_Position = gl_ProjectionMatrix * pos; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index 3c6700a..1713fe9 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl | |||
@@ -7,10 +7,11 @@ | |||
7 | 7 | ||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2DRect positionMap; | 10 | uniform sampler2DRect depthMap; |
11 | uniform sampler2DRect normalMap; | 11 | uniform sampler2DRect normalMap; |
12 | uniform sampler2DRect lightMap; | 12 | uniform sampler2DRect lightMap; |
13 | 13 | ||
14 | uniform float dist_factor; | ||
14 | uniform float blur_size; | 15 | uniform float blur_size; |
15 | uniform vec2 delta; | 16 | uniform vec2 delta; |
16 | uniform vec3 kern[32]; | 17 | uniform vec3 kern[32]; |
@@ -19,30 +20,52 @@ uniform float kern_scale; | |||
19 | 20 | ||
20 | varying vec2 vary_fragcoord; | 21 | varying vec2 vary_fragcoord; |
21 | 22 | ||
23 | uniform mat4 inv_proj; | ||
24 | uniform vec2 screen_res; | ||
25 | |||
26 | vec4 getPosition(vec2 pos_screen) | ||
27 | { | ||
28 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
29 | vec2 sc = pos_screen.xy*2.0; | ||
30 | sc /= screen_res; | ||
31 | sc -= vec2(1.0,1.0); | ||
32 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
33 | vec4 pos = inv_proj * ndc; | ||
34 | pos /= pos.w; | ||
35 | pos.w = 1.0; | ||
36 | return pos; | ||
37 | } | ||
38 | |||
22 | void main() | 39 | void main() |
23 | { | 40 | { |
24 | vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz; | 41 | vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0; |
25 | vec3 pos = texture2DRect(positionMap, vary_fragcoord.xy).xyz; | 42 | vec3 pos = getPosition(vary_fragcoord.xy).xyz; |
26 | vec2 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rg; | 43 | vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba; |
27 | 44 | ||
28 | vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); | 45 | vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); |
29 | 46 | ||
47 | dlt /= max(-pos.z*dist_factor, 1.0); | ||
48 | |||
30 | vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free' | 49 | vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free' |
31 | vec2 col = defined_weight * ccol; | 50 | vec4 col = defined_weight.xyxx * ccol; |
32 | 51 | ||
33 | for (int i = 1; i < kern_length; i++) | 52 | for (int i = 1; i < kern_length; i++) |
34 | { | 53 | { |
35 | vec2 tc = vary_fragcoord.xy + kern[i].z*dlt; | 54 | vec2 tc = vary_fragcoord.xy + kern[i].z*dlt; |
36 | vec3 samppos = texture2DRect(positionMap, tc).xyz; | 55 | vec3 samppos = getPosition(tc).xyz; |
37 | float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane | 56 | float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane |
38 | if (d*d <= 0.003) | 57 | if (d*d <= 0.003) |
39 | { | 58 | { |
40 | col += texture2DRect(lightMap, tc).rg*kern[i].xy; | 59 | col += texture2DRect(lightMap, tc)*kern[i].xyxx; |
41 | defined_weight += kern[i].xy; | 60 | defined_weight += kern[i].xy; |
42 | } | 61 | } |
43 | } | 62 | } |
44 | 63 | ||
45 | col /= defined_weight; | ||
46 | 64 | ||
47 | gl_FragColor = vec4(col.r, col.g, 0.0, 1.0); | 65 | |
66 | col /= defined_weight.xyxx; | ||
67 | |||
68 | gl_FragColor = col; | ||
69 | |||
70 | //gl_FragColor = ccol; | ||
48 | } | 71 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl index a8712bc..1c29dae 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl | |||
@@ -11,7 +11,6 @@ uniform sampler2D bumpMap; | |||
11 | varying vec3 vary_mat0; | 11 | varying vec3 vary_mat0; |
12 | varying vec3 vary_mat1; | 12 | varying vec3 vary_mat1; |
13 | varying vec3 vary_mat2; | 13 | varying vec3 vary_mat2; |
14 | varying vec4 vary_position; | ||
15 | 14 | ||
16 | void main() | 15 | void main() |
17 | { | 16 | { |
@@ -22,8 +21,7 @@ void main() | |||
22 | dot(norm,vary_mat1), | 21 | dot(norm,vary_mat1), |
23 | dot(norm,vary_mat2)); | 22 | dot(norm,vary_mat2)); |
24 | 23 | ||
25 | gl_FragData[0].rgb = gl_Color.rgb*col; | 24 | gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0); |
26 | gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); | 25 | gl_FragData[1] = vec4(col*gl_Color.a, gl_Color.a); |
27 | gl_FragData[2] = vec4(normalize(tnorm), 0.0); | 26 | gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0); |
28 | gl_FragData[3] = vary_position; | ||
29 | } | 27 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl index ba18092..9589912 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl | |||
@@ -8,7 +8,6 @@ | |||
8 | varying vec3 vary_mat0; | 8 | varying vec3 vary_mat0; |
9 | varying vec3 vary_mat1; | 9 | varying vec3 vary_mat1; |
10 | varying vec3 vary_mat2; | 10 | varying vec3 vary_mat2; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
@@ -16,8 +15,6 @@ void main() | |||
16 | gl_Position = ftransform(); | 15 | gl_Position = ftransform(); |
17 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 16 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
18 | 17 | ||
19 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
20 | |||
21 | vec3 n = normalize(gl_NormalMatrix * gl_Normal); | 18 | vec3 n = normalize(gl_NormalMatrix * gl_Normal); |
22 | vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz); | 19 | vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz); |
23 | vec3 t = cross(b, n); | 20 | vec3 t = cross(b, n); |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl index f2ba2df..919dd5d 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl | |||
@@ -8,13 +8,11 @@ | |||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec3 vary_normal; | 10 | varying vec3 vary_normal; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
15 | vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb; | 14 | vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb; |
16 | gl_FragData[0] = vec4(gl_Color.rgb*col, 1.0); | 15 | gl_FragData[0] = vec4(gl_Color.rgb*col, 1.0); // KL viewer 2.0 has 0.0 but this is not working right yet besides i like to see my eyes :) |
17 | gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); | 16 | gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); |
18 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 17 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
19 | gl_FragData[3] = vary_position; | ||
20 | } | 18 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl index 3413a7f..44468cd 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl | |||
@@ -6,16 +6,13 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec3 vary_normal; | 8 | varying vec3 vary_normal; |
9 | varying vec4 vary_position; | ||
10 | 9 | ||
11 | void main() | 10 | void main() |
12 | { | 11 | { |
13 | //transform vertex | 12 | //transform vertex |
14 | gl_Position = ftransform(); | 13 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
15 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 14 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
16 | 15 | ||
17 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
18 | |||
19 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); | 16 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); |
20 | 17 | ||
21 | gl_FrontColor = gl_Color; | 18 | gl_FrontColor = gl_Color; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 2a811c5..e518bdd 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl | |||
@@ -8,14 +8,9 @@ | |||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2D diffuseMap; | 10 | uniform sampler2D diffuseMap; |
11 | uniform sampler2DShadow shadowMap0; | 11 | uniform sampler2DRect depthMap; |
12 | uniform sampler2DShadow shadowMap1; | ||
13 | uniform sampler2DShadow shadowMap2; | ||
14 | uniform sampler2DShadow shadowMap3; | ||
15 | uniform sampler2D noiseMap; | 12 | uniform sampler2D noiseMap; |
16 | uniform sampler2DRect positionMap; | ||
17 | 13 | ||
18 | uniform mat4 shadow_matrix[4]; | ||
19 | uniform vec4 shadow_clip; | 14 | uniform vec4 shadow_clip; |
20 | uniform vec2 screen_res; | 15 | uniform vec2 screen_res; |
21 | 16 | ||
@@ -30,12 +25,27 @@ varying vec3 vary_fragcoord; | |||
30 | 25 | ||
31 | uniform float alpha_soften; | 26 | uniform float alpha_soften; |
32 | 27 | ||
28 | uniform mat4 inv_proj; | ||
29 | |||
30 | vec4 getPosition(vec2 pos_screen) | ||
31 | { | ||
32 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
33 | vec2 sc = pos_screen.xy*2.0; | ||
34 | sc /= screen_res; | ||
35 | sc -= vec2(1.0,1.0); | ||
36 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
37 | vec4 pos = inv_proj * ndc; | ||
38 | pos /= pos.w; | ||
39 | pos.w = 1.0; | ||
40 | return pos; | ||
41 | } | ||
42 | |||
33 | void main() | 43 | void main() |
34 | { | 44 | { |
35 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; | 45 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; |
36 | frag *= screen_res; | 46 | frag *= screen_res; |
37 | 47 | ||
38 | vec3 samp_pos = texture2DRect(positionMap, frag).xyz; | 48 | vec3 samp_pos = getPosition(frag).xyz; |
39 | 49 | ||
40 | float shadow = 1.0; | 50 | float shadow = 1.0; |
41 | vec4 pos = vary_position; | 51 | vec4 pos = vary_position; |
@@ -46,10 +56,10 @@ void main() | |||
46 | 56 | ||
47 | color.rgb = fullbrightScaleSoftClip(color.rgb); | 57 | color.rgb = fullbrightScaleSoftClip(color.rgb); |
48 | 58 | ||
49 | if (samp_pos.z != 0.0) | 59 | if (samp_pos.z != 0.0 && color.a < 1.0) |
50 | { | 60 | { |
51 | float dist_factor = alpha_soften; | 61 | float dist_factor = alpha_soften; |
52 | float a = gl_Color.a; | 62 | float a = color.a; |
53 | a *= a; | 63 | a *= a; |
54 | dist_factor *= 1.0/(1.0-a); | 64 | dist_factor *= 1.0/(1.0-a); |
55 | color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0); | 65 | color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0); |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl index 6381a1c..aff5117 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl | |||
@@ -12,12 +12,12 @@ vec3 atmosAffectDirectionalLight(float lightIntensity); | |||
12 | vec3 scaleDownLight(vec3 light); | 12 | vec3 scaleDownLight(vec3 light); |
13 | vec3 scaleUpLight(vec3 light); | 13 | vec3 scaleUpLight(vec3 light); |
14 | 14 | ||
15 | varying vec4 vary_position; | ||
16 | varying vec3 vary_ambient; | 15 | varying vec3 vary_ambient; |
17 | varying vec3 vary_directional; | 16 | varying vec3 vary_directional; |
18 | varying vec3 vary_normal; | 17 | varying vec3 vary_normal; |
19 | varying vec3 vary_fragcoord; | 18 | varying vec3 vary_fragcoord; |
20 | uniform float near_clip; | 19 | uniform float near_clip; |
20 | varying vec4 vary_position; | ||
21 | 21 | ||
22 | void main() | 22 | void main() |
23 | { | 23 | { |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl new file mode 100644 index 0000000..b351eec --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl | |||
@@ -0,0 +1,165 @@ | |||
1 | /** | ||
2 | * @file giF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect depthMap; | ||
11 | uniform sampler2DRect normalMap; | ||
12 | uniform sampler2D noiseMap; | ||
13 | |||
14 | uniform sampler2D diffuseGIMap; | ||
15 | uniform sampler2D normalGIMap; | ||
16 | uniform sampler2D depthGIMap; | ||
17 | |||
18 | uniform sampler2D lightFunc; | ||
19 | |||
20 | // Inputs | ||
21 | varying vec2 vary_fragcoord; | ||
22 | |||
23 | uniform vec2 screen_res; | ||
24 | |||
25 | uniform mat4 inv_proj; | ||
26 | uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space | ||
27 | uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space | ||
28 | uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix | ||
29 | uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space | ||
30 | uniform float gi_radius; | ||
31 | uniform float gi_intensity; | ||
32 | uniform int gi_samples; | ||
33 | uniform vec2 gi_kern[25]; | ||
34 | uniform vec2 gi_scale; | ||
35 | uniform vec3 gi_quad; | ||
36 | uniform vec3 gi_spec; | ||
37 | uniform float gi_direction_weight; | ||
38 | uniform float gi_light_offset; | ||
39 | |||
40 | vec4 getPosition(vec2 pos_screen) | ||
41 | { | ||
42 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
43 | vec2 sc = pos_screen.xy*2.0; | ||
44 | sc /= screen_res; | ||
45 | sc -= vec2(1.0,1.0); | ||
46 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
47 | vec4 pos = inv_proj * ndc; | ||
48 | pos /= pos.w; | ||
49 | pos.w = 1.0; | ||
50 | return pos; | ||
51 | } | ||
52 | |||
53 | vec4 getGIPosition(vec2 gi_tc) | ||
54 | { | ||
55 | float depth = texture2D(depthGIMap, gi_tc).a; | ||
56 | vec2 sc = gi_tc*2.0; | ||
57 | sc -= vec2(1.0, 1.0); | ||
58 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
59 | vec4 pos = gi_inv_proj*ndc; | ||
60 | pos.xyz /= pos.w; | ||
61 | pos.w = 1.0; | ||
62 | return pos; | ||
63 | } | ||
64 | |||
65 | vec3 giAmbient(vec3 pos, vec3 norm) | ||
66 | { | ||
67 | vec4 gi_c = gi_mat_proj * vec4(pos, 1.0); | ||
68 | gi_c.xyz /= gi_c.w; | ||
69 | |||
70 | vec4 gi_pos = gi_mat*vec4(pos,1.0); | ||
71 | vec3 gi_norm = (gi_norm_mat*vec4(norm,1.0)).xyz; | ||
72 | gi_norm = normalize(gi_norm); | ||
73 | |||
74 | vec2 tcx = gi_norm.xy; | ||
75 | vec2 tcy = gi_norm.yx; | ||
76 | |||
77 | vec4 eye_pos = gi_mat*vec4(0,0,0,1.0); | ||
78 | |||
79 | vec3 eye_dir = normalize(gi_pos.xyz-eye_pos.xyz/eye_pos.w); | ||
80 | |||
81 | //vec3 eye_dir = vec3(0,0,-1); | ||
82 | //eye_dir = (gi_norm_mat*vec4(eye_dir, 1.0)).xyz; | ||
83 | //eye_dir = normalize(eye_dir); | ||
84 | |||
85 | //float round_x = gi_scale.x; | ||
86 | //float round_y = gi_scale.y; | ||
87 | |||
88 | vec3 debug = texture2D(normalGIMap, gi_c.xy).rgb*0.5+0.5; | ||
89 | debug.xz = vec2(0.0,0.0); | ||
90 | //debug = fract(debug); | ||
91 | |||
92 | float round_x = 1.0/64.0; | ||
93 | float round_y = 1.0/64.0; | ||
94 | |||
95 | //gi_c.x = floor(gi_c.x/round_x+0.5)*round_x; | ||
96 | //gi_c.y = floor(gi_c.y/round_y+0.5)*round_y; | ||
97 | |||
98 | float fda = 0.0; | ||
99 | vec3 fdiff = vec3(0,0,0); | ||
100 | |||
101 | vec3 rcol = vec3(0,0,0); | ||
102 | |||
103 | float fsa = 0.0; | ||
104 | |||
105 | for (int i = -1; i < 2; i+=2 ) | ||
106 | { | ||
107 | for (int j = -1; j < 2; j+=2) | ||
108 | { | ||
109 | vec2 tc = vec2(i, j)*0.75; | ||
110 | vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0+tc*0.5).xyz; | ||
111 | //tc += gi_norm.xy*nz.z; | ||
112 | tc += nz.xy*2.0; | ||
113 | tc /= gi_samples; | ||
114 | tc += gi_c.xy; | ||
115 | |||
116 | vec3 lnorm = -normalize(texture2D(normalGIMap, tc.xy).xyz*2.0-1.0); | ||
117 | vec3 lpos = getGIPosition(tc.xy).xyz; | ||
118 | |||
119 | vec3 at = lpos-gi_pos.xyz; | ||
120 | float dist = dot(at,at); | ||
121 | float da = clamp(1.0/(gi_spec.x*dist), 0.0, 1.0); | ||
122 | |||
123 | if (da > 0.0) | ||
124 | { | ||
125 | //add angular attenuation | ||
126 | vec3 ldir = at; | ||
127 | float ang_atten = clamp(dot(ldir, gi_norm), 0.0, 1.0); | ||
128 | |||
129 | float ld = -dot(ldir, lnorm); | ||
130 | |||
131 | if (ang_atten > 0.0 && ld < 0.0) | ||
132 | { | ||
133 | vec3 diff = texture2D(diffuseGIMap, tc.xy).xyz; | ||
134 | da = da*ang_atten; | ||
135 | fda += da; | ||
136 | fdiff += diff*da; | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | |||
142 | fdiff /= max(gi_spec.y*fda, gi_quad.z); | ||
143 | fdiff = clamp(fdiff, vec3(0), vec3(1)); | ||
144 | |||
145 | vec3 ret = fda*fdiff; | ||
146 | //ret = ret*ret*gi_quad.x+ret*gi_quad.y+gi_quad.z; | ||
147 | |||
148 | //fda *= nz.z; | ||
149 | |||
150 | //rcol.rgb *= gi_intensity; | ||
151 | //return rcol.rgb+vary_AmblitColor.rgb*0.25; | ||
152 | //return vec4(debug, 0.0); | ||
153 | //return vec4(fda*fdiff, 0.0); | ||
154 | return clamp(ret,vec3(0.0), vec3(1.0)); | ||
155 | //return debug.xyz; | ||
156 | } | ||
157 | |||
158 | void main() | ||
159 | { | ||
160 | vec2 pos_screen = vary_fragcoord.xy; | ||
161 | vec4 pos = getPosition(pos_screen); | ||
162 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0; | ||
163 | |||
164 | gl_FragData[0].xyz = giAmbient(pos, norm); | ||
165 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl new file mode 100644 index 0000000..71dcea9 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl | |||
@@ -0,0 +1,22 @@ | |||
1 | /** | ||
2 | * @file giV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | |||
10 | uniform vec2 screen_res; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
17 | vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; | ||
18 | vec4 tex = gl_MultiTexCoord0; | ||
19 | tex.w = 1.0; | ||
20 | |||
21 | gl_FrontColor = gl_Color; | ||
22 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl new file mode 100644 index 0000000..e8b53b0 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl | |||
@@ -0,0 +1,15 @@ | |||
1 | /** | ||
2 | * @file luminanceF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect diffuseMap; | ||
9 | |||
10 | varying vec2 vary_fragcoord; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | gl_FragColor = texture2DRect(diffuseMap, vary_fragcoord.xy); | ||
15 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl new file mode 100644 index 0000000..db8775f --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl | |||
@@ -0,0 +1,20 @@ | |||
1 | /** | ||
2 | * @file giV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | |||
10 | uniform vec2 screen_res; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
17 | vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; | ||
18 | |||
19 | gl_FrontColor = gl_Color; | ||
20 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 3689d12..ce0494c 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl | |||
@@ -7,13 +7,15 @@ | |||
7 | 7 | ||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2DRect depthMap; | ||
10 | uniform sampler2DRect diffuseRect; | 11 | uniform sampler2DRect diffuseRect; |
11 | uniform sampler2DRect specularRect; | 12 | uniform sampler2DRect specularRect; |
12 | uniform sampler2DRect positionMap; | ||
13 | uniform sampler2DRect normalMap; | 13 | uniform sampler2DRect normalMap; |
14 | uniform samplerCube environmentMap; | 14 | uniform samplerCube environmentMap; |
15 | uniform sampler2DRect lightMap; | 15 | uniform sampler2DRect lightMap; |
16 | uniform sampler2D noiseMap; | 16 | uniform sampler2D noiseMap; |
17 | uniform sampler2D lightFunc; | ||
18 | |||
17 | 19 | ||
18 | uniform vec3 env_mat[3]; | 20 | uniform vec3 env_mat[3]; |
19 | uniform float sun_wash; | 21 | uniform float sun_wash; |
@@ -23,24 +25,48 @@ uniform int light_count; | |||
23 | uniform vec4 light[16]; | 25 | uniform vec4 light[16]; |
24 | uniform vec4 light_col[16]; | 26 | uniform vec4 light_col[16]; |
25 | 27 | ||
26 | varying vec3 vary_fragcoord; | 28 | varying vec4 vary_fragcoord; |
27 | uniform vec2 screen_res; | 29 | uniform vec2 screen_res; |
28 | 30 | ||
31 | uniform float far_z; | ||
32 | |||
33 | uniform mat4 inv_proj; | ||
34 | |||
35 | vec4 getPosition(vec2 pos_screen) | ||
36 | { | ||
37 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
38 | vec2 sc = pos_screen.xy*2.0; | ||
39 | sc /= screen_res; | ||
40 | sc -= vec2(1.0,1.0); | ||
41 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
42 | vec4 pos = inv_proj * ndc; | ||
43 | pos /= pos.w; | ||
44 | pos.w = 1.0; | ||
45 | return pos; | ||
46 | } | ||
47 | |||
29 | void main() | 48 | void main() |
30 | { | 49 | { |
31 | vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res; | 50 | vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res; |
32 | vec3 pos = texture2DRect(positionMap, frag.xy).xyz; | 51 | vec3 pos = getPosition(frag.xy).xyz; |
33 | vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz); | 52 | if (pos.z < far_z) |
53 | { | ||
54 | discard; | ||
55 | } | ||
56 | |||
57 | vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz*2.0-1.0); | ||
34 | vec4 spec = texture2DRect(specularRect, frag.xy); | 58 | vec4 spec = texture2DRect(specularRect, frag.xy); |
35 | vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; | 59 | vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; |
36 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | 60 | float noise = texture2D(noiseMap, frag.xy/128.0).b; |
37 | vec3 out_col = vec3(0,0,0); | 61 | vec3 out_col = vec3(0,0,0); |
62 | vec3 npos = normalize(-pos); | ||
38 | 63 | ||
39 | for (int i = 0; i < light_count; ++i) | 64 | for (int i = 0; i < light_count; ++i) |
40 | { | 65 | { |
41 | vec3 lv = light[i].xyz-pos; | 66 | vec3 lv = light[i].xyz-pos; |
42 | float dist2 = dot(lv,lv); | 67 | float dist2 = dot(lv,lv); |
43 | if (dist2 > light[i].w) | 68 | dist2 /= light[i].w; |
69 | if (dist2 > 1.0) | ||
44 | { | 70 | { |
45 | continue; | 71 | continue; |
46 | } | 72 | } |
@@ -55,29 +81,41 @@ void main() | |||
55 | da = dot(norm, lv); | 81 | da = dot(norm, lv); |
56 | 82 | ||
57 | float fa = light_col[i].a+1.0; | 83 | float fa = light_col[i].a+1.0; |
58 | float dist_atten = clamp(1.0-(dist2-light[i].w*(1.0-fa))/(light[i].w*fa), 0.0, 1.0); | 84 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); |
59 | dist_atten *= noise; | 85 | dist_atten *= noise; |
60 | 86 | ||
61 | float lit = da * dist_atten; | 87 | float lit = da * dist_atten; |
62 | 88 | ||
63 | vec3 col = light_col[i].rgb*lit*diff; | 89 | vec3 col = light_col[i].rgb*lit*diff; |
90 | //vec3 col = vec3(dist2, light_col[i].a, lit); | ||
64 | 91 | ||
65 | if (spec.a > 0.0) | 92 | if (spec.a > 0.0) |
66 | { | 93 | { |
67 | vec3 ref = reflect(normalize(pos), norm); | 94 | //vec3 ref = dot(pos+lv, norm); |
68 | float sa = dot(ref,lv); | 95 | |
69 | sa = max(sa, 0.0); | 96 | float sa = dot(normalize(lv+npos),norm); |
70 | sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); | 97 | |
71 | sa *= noise; | 98 | if (sa > 0) |
72 | col += da*sa*light_col[i].rgb*spec.rgb; | 99 | { |
100 | sa = texture2D(lightFunc,vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); | ||
101 | sa *= noise; | ||
102 | col += da*sa*light_col[i].rgb*spec.rgb; | ||
103 | } | ||
73 | } | 104 | } |
74 | 105 | ||
75 | out_col += col; | 106 | out_col += col; |
76 | } | 107 | } |
77 | 108 | ||
109 | if (dot(out_col, out_col) <= 0.0) | ||
110 | { | ||
111 | discard; | ||
112 | } | ||
113 | |||
78 | //attenuate point light contribution by SSAO component | 114 | //attenuate point light contribution by SSAO component |
79 | out_col *= texture2DRect(lightMap, frag.xy).g; | 115 | out_col *= texture2DRect(lightMap, frag.xy).g; |
80 | 116 | ||
81 | gl_FragColor.rgb = out_col; | 117 | gl_FragColor.rgb = out_col; |
82 | gl_FragColor.a = 0.0; | 118 | gl_FragColor.a = 0.0; |
119 | |||
120 | //gl_FragColor = vec4(0.1, 0.025, 0.025/4.0, 0.0); | ||
83 | } | 121 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl new file mode 100644 index 0000000..021e8a2 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl | |||
@@ -0,0 +1,184 @@ | |||
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 = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); | ||
101 | |||
102 | lv = proj_origin-pos.xyz; | ||
103 | lv = normalize(lv); | ||
104 | float da = dot(norm, lv); | ||
105 | |||
106 | vec3 col = vec3(0,0,0); | ||
107 | |||
108 | vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; | ||
109 | |||
110 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | ||
111 | if (proj_tc.z > 0.0 && | ||
112 | proj_tc.x < 1.0 && | ||
113 | proj_tc.y < 1.0 && | ||
114 | proj_tc.x > 0.0 && | ||
115 | proj_tc.y > 0.0) | ||
116 | { | ||
117 | float lit = 0.0; | ||
118 | float amb_da = proj_ambiance; | ||
119 | |||
120 | if (da > 0.0) | ||
121 | { | ||
122 | float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); | ||
123 | float lod = diff * proj_lod; | ||
124 | |||
125 | vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
126 | |||
127 | vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; | ||
128 | |||
129 | lit = da * dist_atten * noise; | ||
130 | |||
131 | col = lcol*lit*diff_tex*shadow; | ||
132 | amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; | ||
133 | } | ||
134 | |||
135 | //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); | ||
136 | vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_ambient_lod); | ||
137 | |||
138 | amb_da += (da*da*0.5+0.5)*proj_ambiance; | ||
139 | |||
140 | amb_da *= dist_atten * noise; | ||
141 | |||
142 | amb_da = min(amb_da, 1.0-lit); | ||
143 | |||
144 | col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; | ||
145 | } | ||
146 | |||
147 | |||
148 | vec4 spec = texture2DRect(specularRect, frag.xy); | ||
149 | if (spec.a > 0.0) | ||
150 | { | ||
151 | vec3 ref = reflect(normalize(pos), norm); | ||
152 | |||
153 | //project from point pos in direction ref to plane proj_p, proj_n | ||
154 | vec3 pdelta = proj_p-pos; | ||
155 | float ds = dot(ref, proj_n); | ||
156 | |||
157 | if (ds < 0.0) | ||
158 | { | ||
159 | vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; | ||
160 | |||
161 | vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); | ||
162 | |||
163 | if (stc.z > 0.0) | ||
164 | { | ||
165 | stc.xy /= stc.w; | ||
166 | |||
167 | if (stc.x < 1.0 && | ||
168 | stc.y < 1.0 && | ||
169 | stc.x > 0.0 && | ||
170 | stc.y > 0.0) | ||
171 | { | ||
172 | vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); | ||
173 | col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow; | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | |||
179 | //attenuate point light contribution by SSAO component | ||
180 | col *= texture2DRect(lightMap, frag.xy).g; | ||
181 | |||
182 | gl_FragColor.rgb = col; | ||
183 | gl_FragColor.a = 0.0; | ||
184 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 52bad1f..d8ccfd4 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | |||
@@ -9,33 +9,54 @@ | |||
9 | 9 | ||
10 | uniform sampler2DRect diffuseRect; | 10 | uniform sampler2DRect diffuseRect; |
11 | uniform sampler2DRect specularRect; | 11 | uniform sampler2DRect specularRect; |
12 | uniform sampler2DRect positionMap; | ||
13 | uniform sampler2DRect normalMap; | 12 | uniform sampler2DRect normalMap; |
14 | uniform samplerCube environmentMap; | 13 | uniform samplerCube environmentMap; |
15 | uniform sampler2DRect lightMap; | 14 | uniform sampler2DRect lightMap; |
16 | uniform sampler2D noiseMap; | 15 | uniform sampler2D noiseMap; |
16 | uniform sampler2D lightFunc; | ||
17 | uniform sampler2DRect depthMap; | ||
17 | 18 | ||
18 | uniform vec3 env_mat[3]; | 19 | uniform vec3 env_mat[3]; |
19 | uniform float sun_wash; | 20 | uniform float sun_wash; |
20 | 21 | ||
21 | varying vec4 vary_light; | 22 | varying vec4 vary_light; |
22 | 23 | ||
23 | varying vec3 vary_fragcoord; | 24 | varying vec4 vary_fragcoord; |
24 | uniform vec2 screen_res; | 25 | uniform vec2 screen_res; |
25 | 26 | ||
27 | uniform mat4 inv_proj; | ||
28 | uniform vec4 viewport; | ||
29 | |||
30 | vec4 getPosition(vec2 pos_screen) | ||
31 | { | ||
32 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
33 | vec2 sc = (pos_screen.xy-viewport.xy)*2.0; | ||
34 | sc /= viewport.zw; | ||
35 | sc -= vec2(1.0,1.0); | ||
36 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
37 | vec4 pos = inv_proj * ndc; | ||
38 | pos /= pos.w; | ||
39 | pos.w = 1.0; | ||
40 | return pos; | ||
41 | } | ||
42 | |||
26 | void main() | 43 | void main() |
27 | { | 44 | { |
28 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; | 45 | vec4 frag = vary_fragcoord; |
29 | frag *= screen_res; | 46 | frag.xyz /= frag.w; |
30 | vec3 pos = texture2DRect(positionMap, frag).xyz; | 47 | frag.xyz = frag.xyz*0.5+0.5; |
48 | frag.xy *= screen_res; | ||
49 | |||
50 | vec3 pos = getPosition(frag.xy).xyz; | ||
31 | vec3 lv = vary_light.xyz-pos; | 51 | vec3 lv = vary_light.xyz-pos; |
32 | float dist2 = dot(lv,lv); | 52 | float dist2 = dot(lv,lv); |
33 | if (dist2 > vary_light.w) | 53 | dist2 /= vary_light.w; |
54 | if (dist2 > 1.0) | ||
34 | { | 55 | { |
35 | discard; | 56 | discard; |
36 | } | 57 | } |
37 | 58 | ||
38 | vec3 norm = texture2DRect(normalMap, frag).xyz; | 59 | vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0; |
39 | float da = dot(norm, lv); | 60 | float da = dot(norm, lv); |
40 | if (da < 0.0) | 61 | if (da < 0.0) |
41 | { | 62 | { |
@@ -46,24 +67,30 @@ void main() | |||
46 | lv = normalize(lv); | 67 | lv = normalize(lv); |
47 | da = dot(norm, lv); | 68 | da = dot(norm, lv); |
48 | 69 | ||
49 | float noise = texture2D(noiseMap, frag/128.0).b; | 70 | float noise = texture2D(noiseMap, frag.xy/128.0).b; |
50 | 71 | ||
51 | vec3 col = texture2DRect(diffuseRect, frag).rgb; | 72 | vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; |
52 | float fa = gl_Color.a+1.0; | 73 | float fa = gl_Color.a+1.0; |
53 | float dist_atten = clamp(1.0-(dist2-vary_light.w*(1.0-fa))/(vary_light.w*fa), 0.0, 1.0); | 74 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); |
54 | float lit = da * dist_atten * noise; | 75 | float lit = da * dist_atten * noise; |
55 | 76 | ||
56 | col = gl_Color.rgb*lit*col; | 77 | col = gl_Color.rgb*lit*col; |
57 | 78 | ||
58 | vec4 spec = texture2DRect(specularRect, frag); | 79 | vec4 spec = texture2DRect(specularRect, frag.xy); |
59 | if (spec.a > 0.0) | 80 | if (spec.a > 0.0) |
60 | { | 81 | { |
61 | vec3 ref = reflect(normalize(pos), norm); | 82 | float sa = dot(normalize(lv-normalize(pos)),norm); |
62 | float sa = dot(ref,lv); | 83 | if (sa > 0.0) |
63 | sa = max(sa, 0.0); | 84 | { |
64 | sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); | 85 | sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); |
65 | sa *= noise; | 86 | sa *= noise; |
66 | col += da*sa*gl_Color.rgb*spec.rgb; | 87 | col += da*sa*gl_Color.rgb*spec.rgb; |
88 | } | ||
89 | } | ||
90 | |||
91 | if (dot(col, col) <= 0.0) | ||
92 | { | ||
93 | discard; | ||
67 | } | 94 | } |
68 | 95 | ||
69 | //attenuate point light contribution by SSAO component | 96 | //attenuate point light contribution by SSAO component |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl index a4edb88..e815ca2 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl | |||
@@ -6,7 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec4 vary_light; | 8 | varying vec4 vary_light; |
9 | varying vec3 vary_fragcoord; | 9 | varying vec4 vary_fragcoord; |
10 | 10 | ||
11 | uniform vec2 screen_res; | 11 | uniform vec2 screen_res; |
12 | uniform float near_clip; | 12 | uniform float near_clip; |
@@ -14,10 +14,10 @@ uniform float near_clip; | |||
14 | void main() | 14 | void main() |
15 | { | 15 | { |
16 | //transform vertex | 16 | //transform vertex |
17 | gl_Position = ftransform(); | 17 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
18 | 18 | ||
19 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | 19 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; |
20 | vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); | 20 | vary_fragcoord = pos; |
21 | 21 | ||
22 | vec4 tex = gl_MultiTexCoord0; | 22 | vec4 tex = gl_MultiTexCoord0; |
23 | tex.w = 1.0; | 23 | tex.w = 1.0; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl new file mode 100644 index 0000000..71de036 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl | |||
@@ -0,0 +1,57 @@ | |||
1 | /** | ||
2 | * @file postDeferredF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect diffuseRect; | ||
11 | uniform sampler2DRect localLightMap; | ||
12 | uniform sampler2DRect sunLightMap; | ||
13 | uniform sampler2DRect giLightMap; | ||
14 | uniform sampler2D luminanceMap; | ||
15 | uniform sampler2DRect lightMap; | ||
16 | |||
17 | uniform vec3 lum_quad; | ||
18 | uniform float lum_lod; | ||
19 | uniform vec4 ambient; | ||
20 | |||
21 | uniform vec3 gi_quad; | ||
22 | |||
23 | uniform vec2 screen_res; | ||
24 | varying vec2 vary_fragcoord; | ||
25 | |||
26 | void main() | ||
27 | { | ||
28 | vec2 tc = vary_fragcoord.xy; | ||
29 | vec3 lum = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb; | ||
30 | float luminance = lum.r; | ||
31 | luminance = luminance*lum_quad.y+lum_quad.z; | ||
32 | |||
33 | vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy); | ||
34 | |||
35 | float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g; | ||
36 | |||
37 | vec3 gi_col = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
38 | gi_col = gi_col*gi_col*gi_quad.x + gi_col*gi_quad.y+gi_quad.z*ambocc*ambient.rgb; | ||
39 | gi_col *= diff; | ||
40 | |||
41 | vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy); | ||
42 | |||
43 | vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb; | ||
44 | |||
45 | |||
46 | sun_col *= 1.0/min(luminance, 1.0); | ||
47 | gi_col *= 1.0/luminance; | ||
48 | |||
49 | vec3 col = sun_col.rgb+gi_col+local_col; | ||
50 | |||
51 | gl_FragColor.rgb = col.rgb; | ||
52 | col.rgb = max(col.rgb-vec3(1.0,1.0,1.0), vec3(0.0, 0.0, 0.0)); | ||
53 | |||
54 | gl_FragColor.a = 0.0; // max(dot(col.rgb,col.rgb)*lum_quad.x, sun_col.a); | ||
55 | |||
56 | //gl_FragColor.rgb = vec3(lum_lod); | ||
57 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl new file mode 100644 index 0000000..9819232 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | * @file postDeferredV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | uniform vec2 screen_res; | ||
10 | |||
11 | void main() | ||
12 | { | ||
13 | //transform vertex | ||
14 | gl_Position = ftransform(); | ||
15 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
16 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
17 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl new file mode 100644 index 0000000..3556c7b --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl | |||
@@ -0,0 +1,107 @@ | |||
1 | /** | ||
2 | * @file postgiF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2D diffuseGIMap; | ||
9 | uniform sampler2D normalGIMap; | ||
10 | uniform sampler2D depthGIMap; | ||
11 | uniform sampler2D diffuseMap; | ||
12 | |||
13 | uniform sampler2D lastDiffuseGIMap; | ||
14 | uniform sampler2D lastNormalGIMap; | ||
15 | uniform sampler2D lastMinpGIMap; | ||
16 | uniform sampler2D lastMaxpGIMap; | ||
17 | |||
18 | uniform float gi_blend; | ||
19 | |||
20 | uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space | ||
21 | uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space | ||
22 | uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix | ||
23 | uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space | ||
24 | uniform float gi_radius; | ||
25 | uniform float gi_intensity; | ||
26 | uniform vec2 gi_kern[16]; | ||
27 | uniform vec2 gi_scale; | ||
28 | |||
29 | |||
30 | vec4 getGIPosition(vec2 gi_tc) | ||
31 | { | ||
32 | float depth = texture2D(depthGIMap, gi_tc).a; | ||
33 | vec2 sc = gi_tc*2.0; | ||
34 | sc -= vec2(1.0, 1.0); | ||
35 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
36 | vec4 pos = gi_inv_proj*ndc; | ||
37 | pos.xyz /= pos.w; | ||
38 | pos.w = 1.0; | ||
39 | return pos; | ||
40 | } | ||
41 | |||
42 | |||
43 | void main() | ||
44 | { | ||
45 | vec2 c_tc = gl_TexCoord[0].xy; | ||
46 | |||
47 | vec3 diff = vec3(0,0,0); | ||
48 | vec3 minp = vec3(1024,1024,1024); | ||
49 | vec3 maxp = vec3(-1024,-1024,-1024); | ||
50 | vec3 norm = vec3(0,0,0); | ||
51 | |||
52 | float dweight = 0.0; | ||
53 | |||
54 | vec3 cnorm = normalize(texture2D(normalGIMap, c_tc).rgb*2.0-1.0); | ||
55 | |||
56 | vec3 cpos = vec3(0,0,0); | ||
57 | float tweight = 0.0; | ||
58 | |||
59 | for (int i = 0; i < 8; ++i) | ||
60 | { | ||
61 | for (int j = 0; j < 8; ++j) | ||
62 | { | ||
63 | vec2 tc = vec2(i-4+0.5, j-4+0.5); | ||
64 | float weight = 1.0-length(tc)/6.0; | ||
65 | tc *= 1.0/(256.0); | ||
66 | tc += c_tc; | ||
67 | |||
68 | vec3 n = texture2D(normalGIMap, tc).rgb*2.0-1.0; | ||
69 | tweight += weight; | ||
70 | |||
71 | diff += weight*texture2D(diffuseGIMap, tc).rgb; | ||
72 | |||
73 | norm += n*weight; | ||
74 | |||
75 | dweight += dot(n, cnorm); | ||
76 | |||
77 | vec3 pos = getGIPosition(tc).xyz; | ||
78 | cpos += pos*weight; | ||
79 | |||
80 | minp = min(pos, minp); | ||
81 | maxp = max(pos, maxp); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | dweight = abs(1.0-dweight/64.0); | ||
86 | float mind = min(sqrt(dweight+0.5), 1.0); | ||
87 | |||
88 | dweight *= dweight; | ||
89 | |||
90 | cpos /= tweight; | ||
91 | |||
92 | diff = clamp(diff/tweight, vec3(1.0/2.2), vec3(1,1,1)); | ||
93 | norm = normalize(norm); | ||
94 | maxp = cpos; | ||
95 | minp = vec3(dweight, mind, cpos.z-minp.z); | ||
96 | |||
97 | //float blend = 1.0; | ||
98 | //diff = mix(texture2D(lastDiffuseGIMap, c_tc).rgb, diff, blend); | ||
99 | //norm = mix(texture2D(lastNormalGIMap, c_tc).rgb, norm, blend); | ||
100 | //maxp = mix(texture2D(lastMaxpGIMap, c_tc).rgb, maxp, blend); | ||
101 | //minp = mix(texture2D(lastMinpGIMap, c_tc).rgb, minp, blend); | ||
102 | |||
103 | gl_FragData[0].rgb = diff; | ||
104 | gl_FragData[2].xyz = normalize(norm); | ||
105 | gl_FragData[1].xyz = maxp; | ||
106 | gl_FragData[3].xyz = minp; | ||
107 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl new file mode 100644 index 0000000..5a8eb65 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl | |||
@@ -0,0 +1,16 @@ | |||
1 | /** | ||
2 | * @file postgiV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec3 vary_normal; | ||
9 | |||
10 | void main() | ||
11 | { | ||
12 | //transform vertex | ||
13 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
14 | gl_Position = pos; | ||
15 | gl_TexCoord[0].xy = pos.xy*0.5+0.5; | ||
16 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl index b3758c3..b0b31fd 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl | |||
@@ -7,8 +7,11 @@ | |||
7 | 7 | ||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec4 post_pos; | ||
10 | 11 | ||
11 | void main() | 12 | void main() |
12 | { | 13 | { |
13 | gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); | 14 | gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); |
15 | |||
16 | gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); | ||
14 | } | 17 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl index aae1bee..7214d24 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl | |||
@@ -5,13 +5,17 @@ | |||
5 | * $License$ | 5 | * $License$ |
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec4 post_pos; | ||
9 | |||
8 | void main() | 10 | void main() |
9 | { | 11 | { |
10 | //transform vertex | 12 | //transform vertex |
11 | vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex; | 13 | vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex; |
12 | //smash geometry against the near clip plane (great for ortho projections) | 14 | |
13 | pos.z = max(pos.z, -1.0); | 15 | post_pos = pos; |
14 | gl_Position = pos; | 16 | |
17 | gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); | ||
18 | |||
15 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 19 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
16 | gl_FrontColor = gl_Color; | 20 | gl_FrontColor = gl_Color; |
17 | } | 21 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index d5671a6..64e263a 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | |||
@@ -272,8 +272,4 @@ void main() | |||
272 | 272 | ||
273 | gl_FragColor.rgb = col; | 273 | gl_FragColor.rgb = col; |
274 | gl_FragColor.a = 0.0; | 274 | gl_FragColor.a = 0.0; |
275 | //gl_FragColor.rg = scol_ambocc.rg; | ||
276 | //gl_FragColor.rgb = norm.rgb*0.5+0.5; | ||
277 | //gl_FragColor.rgb = vec3(ambocc); | ||
278 | //gl_FragColor.rgb = vec3(scol); | ||
279 | } | 275 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl new file mode 100644 index 0000000..d653408 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl | |||
@@ -0,0 +1,199 @@ | |||
1 | /** | ||
2 | * @file spotLightF.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_ambiance; | ||
30 | uniform float near_clip; | ||
31 | uniform float far_clip; | ||
32 | |||
33 | uniform vec3 proj_origin; //origin of projection to be used for angular attenuation | ||
34 | uniform float sun_wash; | ||
35 | uniform int proj_shadow_idx; | ||
36 | uniform float shadow_fade; | ||
37 | |||
38 | varying vec4 vary_light; | ||
39 | |||
40 | varying vec4 vary_fragcoord; | ||
41 | uniform vec2 screen_res; | ||
42 | |||
43 | uniform mat4 inv_proj; | ||
44 | |||
45 | vec4 getPosition(vec2 pos_screen) | ||
46 | { | ||
47 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
48 | vec2 sc = pos_screen.xy*2.0; | ||
49 | sc /= screen_res; | ||
50 | sc -= vec2(1.0,1.0); | ||
51 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
52 | vec4 pos = inv_proj * ndc; | ||
53 | pos /= pos.w; | ||
54 | pos.w = 1.0; | ||
55 | return pos; | ||
56 | } | ||
57 | |||
58 | void main() | ||
59 | { | ||
60 | vec4 frag = vary_fragcoord; | ||
61 | frag.xyz /= frag.w; | ||
62 | frag.xyz = frag.xyz*0.5+0.5; | ||
63 | frag.xy *= screen_res; | ||
64 | |||
65 | float shadow = 1.0; | ||
66 | |||
67 | if (proj_shadow_idx >= 0) | ||
68 | { | ||
69 | vec4 shd = texture2DRect(lightMap, frag.xy); | ||
70 | float sh[2]; | ||
71 | sh[0] = shd.b; | ||
72 | sh[1] = shd.a; | ||
73 | shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); | ||
74 | } | ||
75 | |||
76 | vec3 pos = getPosition(frag.xy).xyz; | ||
77 | vec3 lv = vary_light.xyz-pos.xyz; | ||
78 | float dist2 = dot(lv,lv); | ||
79 | dist2 /= vary_light.w; | ||
80 | if (dist2 > 1.0) | ||
81 | { | ||
82 | discard; | ||
83 | } | ||
84 | |||
85 | vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0; | ||
86 | |||
87 | norm = normalize(norm); | ||
88 | float l_dist = -dot(lv, proj_n); | ||
89 | |||
90 | vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); | ||
91 | if (proj_tc.z < 0.0) | ||
92 | { | ||
93 | discard; | ||
94 | } | ||
95 | |||
96 | proj_tc.xyz /= proj_tc.w; | ||
97 | |||
98 | float fa = gl_Color.a+1.0; | ||
99 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); | ||
100 | |||
101 | lv = proj_origin-pos.xyz; | ||
102 | lv = normalize(lv); | ||
103 | float da = dot(norm, lv); | ||
104 | |||
105 | vec3 col = vec3(0,0,0); | ||
106 | |||
107 | vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; | ||
108 | |||
109 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | ||
110 | if (proj_tc.z > 0.0 && | ||
111 | proj_tc.x < 1.0 && | ||
112 | proj_tc.y < 1.0 && | ||
113 | proj_tc.x > 0.0 && | ||
114 | proj_tc.y > 0.0) | ||
115 | { | ||
116 | float lit = 0.0; | ||
117 | if (da > 0.0) | ||
118 | { | ||
119 | float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); | ||
120 | float lod = diff * proj_lod; | ||
121 | |||
122 | vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
123 | |||
124 | vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; | ||
125 | |||
126 | lit = da * dist_atten * noise; | ||
127 | |||
128 | col = lcol*lit*diff_tex*shadow; | ||
129 | } | ||
130 | |||
131 | float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); | ||
132 | float lod = diff * proj_lod; | ||
133 | vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
134 | //float amb_da = mix(proj_ambiance, proj_ambiance*max(-da, 0.0), max(da, 0.0)); | ||
135 | float amb_da = proj_ambiance; | ||
136 | if (da > 0.0) | ||
137 | { | ||
138 | amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; | ||
139 | } | ||
140 | |||
141 | amb_da += (da*da*0.5+0.5)*proj_ambiance; | ||
142 | |||
143 | amb_da *= dist_atten * noise; | ||
144 | |||
145 | amb_da = min(amb_da, 1.0-lit); | ||
146 | |||
147 | col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; | ||
148 | } | ||
149 | |||
150 | |||
151 | vec4 spec = texture2DRect(specularRect, frag.xy); | ||
152 | if (spec.a > 0.0) | ||
153 | { | ||
154 | vec3 ref = reflect(normalize(pos), norm); | ||
155 | |||
156 | //project from point pos in direction ref to plane proj_p, proj_n | ||
157 | vec3 pdelta = proj_p-pos; | ||
158 | float ds = dot(ref, proj_n); | ||
159 | |||
160 | if (ds < 0.0) | ||
161 | { | ||
162 | vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; | ||
163 | |||
164 | vec3 stc = (proj_mat * vec4(pfinal.xyz, 1.0)).xyz; | ||
165 | |||
166 | if (stc.z > 0.0) | ||
167 | { | ||
168 | stc.xy /= stc.z+proj_near; | ||
169 | |||
170 | if (stc.x < 1.0 && | ||
171 | stc.y < 1.0 && | ||
172 | stc.x > 0.0 && | ||
173 | stc.y > 0.0) | ||
174 | { | ||
175 | vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); | ||
176 | col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow; | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | /*if (spec.a > 0.0) | ||
183 | { | ||
184 | //vec3 ref = reflect(normalize(pos), norm); | ||
185 | float sa = dot(normalize(lv-normalize(pos)),norm);; | ||
186 | //sa = max(sa, 0.0); | ||
187 | //sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); | ||
188 | sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); | ||
189 | sa *= noise; | ||
190 | col += da*sa*lcol*spec.rgb; | ||
191 | }*/ | ||
192 | |||
193 | //attenuate point light contribution by SSAO component | ||
194 | col *= texture2DRect(lightMap, frag.xy).g; | ||
195 | |||
196 | |||
197 | gl_FragColor.rgb = col; | ||
198 | gl_FragColor.a = 0.0; | ||
199 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl index d43fe6c..22bdd2c 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl | |||
@@ -7,17 +7,21 @@ | |||
7 | 7 | ||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2DRect positionMap; | ||
11 | uniform sampler2DRect normalMap; | ||
12 | uniform sampler2DRect depthMap; | 10 | uniform sampler2DRect depthMap; |
13 | uniform sampler2DShadow shadowMap0; | 11 | uniform sampler2DRect normalMap; |
14 | uniform sampler2DShadow shadowMap1; | 12 | uniform sampler2DRectShadow shadowMap0; |
15 | uniform sampler2DShadow shadowMap2; | 13 | uniform sampler2DRectShadow shadowMap1; |
16 | uniform sampler2DShadow shadowMap3; | 14 | uniform sampler2DRectShadow shadowMap2; |
15 | uniform sampler2DRectShadow shadowMap3; | ||
16 | uniform sampler2DRectShadow shadowMap4; | ||
17 | uniform sampler2DRectShadow shadowMap5; | ||
17 | uniform sampler2D noiseMap; | 18 | uniform sampler2D noiseMap; |
18 | 19 | ||
20 | uniform sampler2D lightFunc; | ||
21 | |||
22 | |||
19 | // Inputs | 23 | // Inputs |
20 | uniform mat4 shadow_matrix[4]; | 24 | uniform mat4 shadow_matrix[6]; |
21 | uniform vec4 shadow_clip; | 25 | uniform vec4 shadow_clip; |
22 | uniform float ssao_radius; | 26 | uniform float ssao_radius; |
23 | uniform float ssao_max_radius; | 27 | uniform float ssao_max_radius; |
@@ -27,6 +31,25 @@ uniform float ssao_factor_inv; | |||
27 | varying vec2 vary_fragcoord; | 31 | varying vec2 vary_fragcoord; |
28 | varying vec4 vary_light; | 32 | varying vec4 vary_light; |
29 | 33 | ||
34 | uniform mat4 inv_proj; | ||
35 | uniform vec2 screen_res; | ||
36 | |||
37 | uniform float shadow_bias; | ||
38 | uniform float shadow_offset; | ||
39 | |||
40 | vec4 getPosition(vec2 pos_screen) | ||
41 | { | ||
42 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
43 | vec2 sc = pos_screen.xy*2.0; | ||
44 | sc /= screen_res; | ||
45 | sc -= vec2(1.0,1.0); | ||
46 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
47 | vec4 pos = inv_proj * ndc; | ||
48 | pos /= pos.w; | ||
49 | pos.w = 1.0; | ||
50 | return pos; | ||
51 | } | ||
52 | |||
30 | //calculate decreases in ambient lighting when crowded out (SSAO) | 53 | //calculate decreases in ambient lighting when crowded out (SSAO) |
31 | float calcAmbientOcclusion(vec4 pos, vec3 norm) | 54 | float calcAmbientOcclusion(vec4 pos, vec3 norm) |
32 | { | 55 | { |
@@ -54,7 +77,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) | |||
54 | for (int i = 0; i < 8; i++) | 77 | for (int i = 0; i < 8; i++) |
55 | { | 78 | { |
56 | vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect); | 79 | vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect); |
57 | vec3 samppos_world = texture2DRect(positionMap, samppos_screen).xyz; | 80 | vec3 samppos_world = getPosition(samppos_screen).xyz; |
58 | 81 | ||
59 | vec3 diff = pos_world - samppos_world; | 82 | vec3 diff = pos_world - samppos_world; |
60 | float dist2 = dot(diff, diff); | 83 | float dist2 = dot(diff, diff); |
@@ -74,14 +97,18 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) | |||
74 | 97 | ||
75 | angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); | 98 | angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); |
76 | 99 | ||
77 | return 1.0 - (float(points != 0) * angle_hidden); | 100 | return (1.0 - (float(points != 0) * angle_hidden)); |
78 | } | 101 | } |
79 | 102 | ||
80 | void main() | 103 | void main() |
81 | { | 104 | { |
82 | vec2 pos_screen = vary_fragcoord.xy; | 105 | vec2 pos_screen = vary_fragcoord.xy; |
83 | vec4 pos = vec4(texture2DRect(positionMap, pos_screen).xyz, 1.0); | 106 | |
84 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz; | 107 | //try doing an unproject here |
108 | |||
109 | vec4 pos = getPosition(pos_screen); | ||
110 | |||
111 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0; | ||
85 | 112 | ||
86 | /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL | 113 | /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL |
87 | { | 114 | { |
@@ -90,35 +117,45 @@ void main() | |||
90 | }*/ | 117 | }*/ |
91 | 118 | ||
92 | float shadow = 1.0; | 119 | float shadow = 1.0; |
93 | float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); | 120 | float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); |
94 | 121 | ||
122 | vec4 spos = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0); | ||
123 | |||
124 | //vec3 debug = vec3(0,0,0); | ||
125 | |||
95 | if (dp_directional_light == 0.0) | 126 | if (dp_directional_light == 0.0) |
96 | { | 127 | { |
97 | // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup | 128 | // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup |
98 | shadow = 0.0; | 129 | shadow = 0.0; |
99 | } | 130 | } |
100 | else if (pos.z > -shadow_clip.w) | 131 | else if (spos.z > -shadow_clip.w) |
101 | { | 132 | { |
102 | if (pos.z < -shadow_clip.z) | 133 | vec4 lpos; |
134 | |||
135 | if (spos.z < -shadow_clip.z) | ||
103 | { | 136 | { |
104 | vec4 lpos = shadow_matrix[3]*pos; | 137 | lpos = shadow_matrix[3]*spos; |
105 | shadow = shadow2DProj(shadowMap3, lpos).x; | 138 | lpos.xy *= screen_res; |
139 | shadow = shadow2DRectProj(shadowMap3, lpos).x; | ||
106 | shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); | 140 | shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); |
107 | } | 141 | } |
108 | else if (pos.z < -shadow_clip.y) | 142 | else if (spos.z < -shadow_clip.y) |
109 | { | 143 | { |
110 | vec4 lpos = shadow_matrix[2]*pos; | 144 | lpos = shadow_matrix[2]*spos; |
111 | shadow = shadow2DProj(shadowMap2, lpos).x; | 145 | lpos.xy *= screen_res; |
146 | shadow = shadow2DRectProj(shadowMap2, lpos).x; | ||
112 | } | 147 | } |
113 | else if (pos.z < -shadow_clip.x) | 148 | else if (spos.z < -shadow_clip.x) |
114 | { | 149 | { |
115 | vec4 lpos = shadow_matrix[1]*pos; | 150 | lpos = shadow_matrix[1]*spos; |
116 | shadow = shadow2DProj(shadowMap1, lpos).x; | 151 | lpos.xy *= screen_res; |
152 | shadow = shadow2DRectProj(shadowMap1, lpos).x; | ||
117 | } | 153 | } |
118 | else | 154 | else |
119 | { | 155 | { |
120 | vec4 lpos = shadow_matrix[0]*pos; | 156 | lpos = shadow_matrix[0]*spos; |
121 | shadow = shadow2DProj(shadowMap0, lpos).x; | 157 | lpos.xy *= screen_res; |
158 | shadow = shadow2DRectProj(shadowMap0, lpos).x; | ||
122 | } | 159 | } |
123 | 160 | ||
124 | // take the most-shadowed value out of these two: | 161 | // take the most-shadowed value out of these two: |
@@ -126,6 +163,17 @@ void main() | |||
126 | // * an unblurred dot product between the sun and this norm | 163 | // * an unblurred dot product between the sun and this norm |
127 | // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting | 164 | // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting |
128 | shadow = min(shadow, dp_directional_light); | 165 | shadow = min(shadow, dp_directional_light); |
166 | |||
167 | /*debug.r = lpos.y / (lpos.w*screen_res.y); | ||
168 | |||
169 | lpos.xy /= lpos.w*32.0; | ||
170 | if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1) | ||
171 | { | ||
172 | debug.gb = vec2(0.5, 0.5); | ||
173 | } | ||
174 | |||
175 | debug += (1.0-shadow)*0.5;*/ | ||
176 | |||
129 | } | 177 | } |
130 | else | 178 | else |
131 | { | 179 | { |
@@ -135,5 +183,18 @@ void main() | |||
135 | 183 | ||
136 | gl_FragColor[0] = shadow; | 184 | gl_FragColor[0] = shadow; |
137 | gl_FragColor[1] = calcAmbientOcclusion(pos, norm); | 185 | gl_FragColor[1] = calcAmbientOcclusion(pos, norm); |
138 | //gl_FragColor[2] is unused as of August 2008, may be used for debugging | 186 | |
187 | //spotlight shadow 1 | ||
188 | vec4 lpos = shadow_matrix[4]*spos; | ||
189 | lpos.xy *= screen_res; | ||
190 | gl_FragColor[2] = shadow2DRectProj(shadowMap4, lpos).x; | ||
191 | |||
192 | //spotlight shadow 2 | ||
193 | lpos = shadow_matrix[5]*spos; | ||
194 | lpos.xy *= screen_res; | ||
195 | gl_FragColor[3] = shadow2DRectProj(shadowMap5, lpos).x; | ||
196 | |||
197 | //gl_FragColor.rgb = pos.xyz; | ||
198 | //gl_FragColor.b = shadow; | ||
199 | //gl_FragColor.rgb = debug; | ||
139 | } | 200 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index 211b2e0..308b9b1 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl | |||
@@ -12,7 +12,6 @@ uniform sampler2D detail_3; | |||
12 | uniform sampler2D alpha_ramp; | 12 | uniform sampler2D alpha_ramp; |
13 | 13 | ||
14 | varying vec3 vary_normal; | 14 | varying vec3 vary_normal; |
15 | varying vec4 vary_position; | ||
16 | 15 | ||
17 | void main() | 16 | void main() |
18 | { | 17 | { |
@@ -28,9 +27,8 @@ void main() | |||
28 | float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a; | 27 | float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a; |
29 | vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); | 28 | vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); |
30 | 29 | ||
31 | gl_FragData[0] = vec4(outColor.rgb, 1.0); | 30 | gl_FragData[0] = vec4(outColor.rgb, 0.0); // Kl 0.0 looks fine atm however check grass above waterline when GI enabled in future releases! |
32 | gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2); | 31 | gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2); |
33 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 32 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
34 | gl_FragData[3] = vary_position; | ||
35 | } | 33 | } |
36 | 34 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl index e9d6dca..3038b14 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec3 vary_normal; | 8 | varying vec3 vary_normal; |
9 | varying vec4 vary_position; | ||
10 | 9 | ||
11 | vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) | 10 | vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) |
12 | { | 11 | { |
@@ -27,7 +26,6 @@ void main() | |||
27 | //transform vertex | 26 | //transform vertex |
28 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | 27 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
29 | 28 | ||
30 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
31 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); | 29 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); |
32 | 30 | ||
33 | // Transform and pass tex coords | 31 | // Transform and pass tex coords |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl index bc2c981..49c65f1 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl | |||
@@ -8,13 +8,11 @@ | |||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec3 vary_normal; | 10 | varying vec3 vary_normal; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
15 | vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); | 14 | vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); |
16 | gl_FragData[0] = gl_Color*col; | 15 | gl_FragData[0] = gl_Color*col; |
17 | gl_FragData[1] = vec4(0,0,0,0); | 16 | gl_FragData[1] = vec4(0,0,0,0); |
18 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 17 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
19 | gl_FragData[3] = vary_position; | ||
20 | } | 18 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl index 9131d7c..6b9dc2d 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec3 vary_normal; | 8 | varying vec3 vary_normal; |
9 | varying vec4 vary_position; | ||
10 | 9 | ||
11 | void main() | 10 | void main() |
12 | { | 11 | { |
@@ -14,8 +13,6 @@ void main() | |||
14 | gl_Position = ftransform(); | 13 | gl_Position = ftransform(); |
15 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 14 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
16 | 15 | ||
17 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
18 | |||
19 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); | 16 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); |
20 | 17 | ||
21 | gl_FrontColor = gl_Color; | 18 | gl_FrontColor = gl_Color; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 0a1f019..6eea656 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | |||
@@ -17,7 +17,7 @@ uniform sampler2DShadow shadowMap2; | |||
17 | uniform sampler2DShadow shadowMap3; | 17 | uniform sampler2DShadow shadowMap3; |
18 | uniform sampler2D noiseMap; | 18 | uniform sampler2D noiseMap; |
19 | 19 | ||
20 | uniform mat4 shadow_matrix[4]; | 20 | uniform mat4 shadow_matrix[6]; |
21 | uniform vec4 shadow_clip; | 21 | uniform vec4 shadow_clip; |
22 | 22 | ||
23 | uniform float sunAngle; | 23 | uniform float sunAngle; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl b/linden/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl new file mode 100644 index 0000000..623ef7a --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl | |||
@@ -0,0 +1,31 @@ | |||
1 | /** | ||
2 | * @file colorFilterF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect RenderTexture; | ||
9 | uniform float brightness; | ||
10 | uniform float contrast; | ||
11 | uniform vec3 contrastBase; | ||
12 | uniform float saturation; | ||
13 | uniform vec3 lumWeights; | ||
14 | |||
15 | const float gamma = 2.0; | ||
16 | |||
17 | void main(void) | ||
18 | { | ||
19 | vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); | ||
20 | |||
21 | /// Modulate brightness | ||
22 | color *= brightness; | ||
23 | |||
24 | /// Modulate contrast | ||
25 | color = mix(contrastBase, color, contrast); | ||
26 | |||
27 | /// Modulate saturation | ||
28 | color = mix(vec3(dot(color, lumWeights)), color, saturation); | ||
29 | |||
30 | gl_FragColor = vec4(color, 1.0); | ||
31 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/effects/drawQuadV.glsl b/linden/indra/newview/app_settings/shaders/class1/effects/drawQuadV.glsl new file mode 100644 index 0000000..29c2a09 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/effects/drawQuadV.glsl | |||
@@ -0,0 +1,14 @@ | |||
1 | /** | ||
2 | * @file drawQuadV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | void main(void) | ||
9 | { | ||
10 | //transform vertex | ||
11 | gl_Position = ftransform(); | ||
12 | gl_TexCoord[0] = gl_MultiTexCoord0; | ||
13 | gl_TexCoord[1] = gl_MultiTexCoord1; | ||
14 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl b/linden/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl new file mode 100644 index 0000000..271d5cf --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl | |||
@@ -0,0 +1,42 @@ | |||
1 | /** | ||
2 | * @file nightVisionF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect RenderTexture; | ||
9 | uniform sampler2D NoiseTexture; | ||
10 | uniform float brightMult; | ||
11 | uniform float noiseStrength; | ||
12 | |||
13 | float luminance(vec3 color) | ||
14 | { | ||
15 | /// CALCULATING LUMINANCE (Using NTSC lum weights) | ||
16 | /// http://en.wikipedia.org/wiki/Luma_%28video%29 | ||
17 | return dot(color, vec3(0.299, 0.587, 0.114)); | ||
18 | } | ||
19 | |||
20 | void main(void) | ||
21 | { | ||
22 | /// Get scene color | ||
23 | vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); | ||
24 | |||
25 | /// Extract luminance and scale up by night vision brightness | ||
26 | float lum = luminance(color) * brightMult; | ||
27 | |||
28 | /// Convert into night vision color space | ||
29 | /// Newer NVG colors (crisper and more saturated) | ||
30 | vec3 outColor = (lum * vec3(0.91, 1.21, 0.9)) + vec3(-0.07, 0.1, -0.12); | ||
31 | |||
32 | /// Add noise | ||
33 | float noiseValue = texture2D(NoiseTexture, gl_TexCoord[1].st).r; | ||
34 | noiseValue = (noiseValue - 0.5) * noiseStrength; | ||
35 | |||
36 | /// Older NVG colors (more muted) | ||
37 | // vec3 outColor = (lum * vec3(0.82, 0.75, 0.83)) + vec3(0.05, 0.32, -0.11); | ||
38 | |||
39 | outColor += noiseValue; | ||
40 | |||
41 | gl_FragColor = vec4(outColor, 1.0); | ||
42 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl new file mode 100644 index 0000000..0055a73 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl | |||
@@ -0,0 +1,112 @@ | |||
1 | /** | ||
2 | * @file alphaF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2D diffuseMap; | ||
11 | uniform sampler2DRectShadow shadowMap0; | ||
12 | uniform sampler2DRectShadow shadowMap1; | ||
13 | uniform sampler2DRectShadow shadowMap2; | ||
14 | uniform sampler2DRectShadow shadowMap3; | ||
15 | uniform sampler2D noiseMap; | ||
16 | uniform sampler2DRect depthMap; | ||
17 | |||
18 | uniform mat4 shadow_matrix[6]; | ||
19 | uniform vec4 shadow_clip; | ||
20 | uniform vec2 screen_res; | ||
21 | |||
22 | vec3 atmosLighting(vec3 light); | ||
23 | vec3 scaleSoftClip(vec3 light); | ||
24 | |||
25 | varying vec3 vary_ambient; | ||
26 | varying vec3 vary_directional; | ||
27 | varying vec3 vary_fragcoord; | ||
28 | varying vec3 vary_position; | ||
29 | varying vec3 vary_light; | ||
30 | |||
31 | uniform float alpha_soften; | ||
32 | |||
33 | uniform mat4 inv_proj; | ||
34 | |||
35 | vec4 getPosition(vec2 pos_screen) | ||
36 | { | ||
37 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
38 | vec2 sc = pos_screen.xy*2.0; | ||
39 | sc /= screen_res; | ||
40 | sc -= vec2(1.0,1.0); | ||
41 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
42 | vec4 pos = inv_proj * ndc; | ||
43 | pos /= pos.w; | ||
44 | pos.w = 1.0; | ||
45 | return pos; | ||
46 | } | ||
47 | |||
48 | void main() | ||
49 | { | ||
50 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; | ||
51 | frag *= screen_res; | ||
52 | |||
53 | vec3 samp_pos = getPosition(frag).xyz; | ||
54 | |||
55 | float shadow = 1.0; | ||
56 | vec4 pos = vec4(vary_position, 1.0); | ||
57 | |||
58 | vec4 spos = pos; | ||
59 | |||
60 | if (spos.z > -shadow_clip.w) | ||
61 | { | ||
62 | vec4 lpos; | ||
63 | |||
64 | if (spos.z < -shadow_clip.z) | ||
65 | { | ||
66 | lpos = shadow_matrix[3]*spos; | ||
67 | lpos.xy *= screen_res; | ||
68 | shadow = shadow2DRectProj(shadowMap3, lpos).x; | ||
69 | shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); | ||
70 | } | ||
71 | else if (spos.z < -shadow_clip.y) | ||
72 | { | ||
73 | lpos = shadow_matrix[2]*spos; | ||
74 | lpos.xy *= screen_res; | ||
75 | shadow = shadow2DRectProj(shadowMap2, lpos).x; | ||
76 | } | ||
77 | else if (spos.z < -shadow_clip.x) | ||
78 | { | ||
79 | lpos = shadow_matrix[1]*spos; | ||
80 | lpos.xy *= screen_res; | ||
81 | shadow = shadow2DRectProj(shadowMap1, lpos).x; | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | lpos = shadow_matrix[0]*spos; | ||
86 | lpos.xy *= screen_res; | ||
87 | shadow = shadow2DRectProj(shadowMap0, lpos).x; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, gl_Color.a); | ||
92 | vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * col; | ||
93 | |||
94 | color.rgb = atmosLighting(color.rgb); | ||
95 | |||
96 | color.rgb = scaleSoftClip(color.rgb); | ||
97 | |||
98 | if (samp_pos.z != 0.0) | ||
99 | { | ||
100 | float dist_factor = alpha_soften; | ||
101 | float a = gl_Color.a; | ||
102 | a *= a; | ||
103 | dist_factor *= 1.0/(1.0-a); | ||
104 | color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0); | ||
105 | } | ||
106 | |||
107 | //gl_FragColor = gl_Color; | ||
108 | gl_FragColor = color; | ||
109 | //gl_FragColor = vec4(1,0,1,1)*shadow; | ||
110 | |||
111 | } | ||
112 | |||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl new file mode 100644 index 0000000..ab60b65 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl | |||
@@ -0,0 +1,75 @@ | |||
1 | /** | ||
2 | * @file alphaV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); | ||
9 | void calcAtmospherics(vec3 inPositionEye); | ||
10 | |||
11 | float calcDirectionalLight(vec3 n, vec3 l); | ||
12 | float calcPointLight(vec3 v, vec3 n, vec4 lp, float la); | ||
13 | |||
14 | vec3 atmosAmbient(vec3 light); | ||
15 | vec3 atmosAffectDirectionalLight(float lightIntensity); | ||
16 | vec3 scaleDownLight(vec3 light); | ||
17 | vec3 scaleUpLight(vec3 light); | ||
18 | |||
19 | varying vec3 vary_ambient; | ||
20 | varying vec3 vary_directional; | ||
21 | varying vec3 vary_fragcoord; | ||
22 | varying vec3 vary_position; | ||
23 | varying vec3 vary_light; | ||
24 | |||
25 | uniform float near_clip; | ||
26 | uniform float shadow_offset; | ||
27 | uniform float shadow_bias; | ||
28 | |||
29 | void main() | ||
30 | { | ||
31 | //transform vertex | ||
32 | gl_Position = ftransform(); | ||
33 | |||
34 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | ||
35 | |||
36 | vec4 pos = (gl_ModelViewMatrix * gl_Vertex); | ||
37 | vec3 norm = normalize(gl_NormalMatrix * gl_Normal); | ||
38 | |||
39 | vary_position = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0); | ||
40 | |||
41 | calcAtmospherics(pos.xyz); | ||
42 | |||
43 | //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); | ||
44 | vec4 col; | ||
45 | col.a = gl_Color.a; | ||
46 | |||
47 | // Add windlight lights | ||
48 | col.rgb = atmosAmbient(vec3(0.)); | ||
49 | col.rgb = scaleUpLight(col.rgb); | ||
50 | |||
51 | // Collect normal lights (need to be divided by two, as we later multiply by 2) | ||
52 | col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation); | ||
53 | col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation); | ||
54 | col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation); | ||
55 | col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation); | ||
56 | col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation); | ||
57 | col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation); | ||
58 | col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); | ||
59 | col.rgb = scaleDownLight(col.rgb); | ||
60 | |||
61 | vary_light = gl_LightSource[0].position.xyz; | ||
62 | |||
63 | vary_ambient = col.rgb*gl_Color.rgb; | ||
64 | vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a))); | ||
65 | |||
66 | col.rgb = min(col.rgb*gl_Color.rgb, 1.0); | ||
67 | |||
68 | gl_FrontColor = col; | ||
69 | |||
70 | gl_FogFragCoord = pos.z; | ||
71 | |||
72 | pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
73 | vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); | ||
74 | |||
75 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaF.glsl new file mode 100644 index 0000000..fe83c3c --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaF.glsl | |||
@@ -0,0 +1,77 @@ | |||
1 | /** | ||
2 | * @file avatarAlphaF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2D diffuseMap; | ||
9 | uniform sampler2DRectShadow shadowMap0; | ||
10 | uniform sampler2DRectShadow shadowMap1; | ||
11 | uniform sampler2DRectShadow shadowMap2; | ||
12 | uniform sampler2DRectShadow shadowMap3; | ||
13 | uniform sampler2D noiseMap; | ||
14 | |||
15 | uniform mat4 shadow_matrix[6]; | ||
16 | uniform vec4 shadow_clip; | ||
17 | uniform vec2 screen_res; | ||
18 | |||
19 | vec3 atmosLighting(vec3 light); | ||
20 | vec3 scaleSoftClip(vec3 light); | ||
21 | |||
22 | varying vec3 vary_ambient; | ||
23 | varying vec3 vary_directional; | ||
24 | varying vec4 vary_position; | ||
25 | varying vec3 vary_normal; | ||
26 | |||
27 | void main() | ||
28 | { | ||
29 | float shadow = 1.0; | ||
30 | vec4 pos = vary_position; | ||
31 | vec3 norm = normalize(vary_normal); | ||
32 | |||
33 | vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz; | ||
34 | |||
35 | vec4 spos = pos; | ||
36 | |||
37 | if (spos.z > -shadow_clip.w) | ||
38 | { | ||
39 | vec4 lpos; | ||
40 | |||
41 | if (spos.z < -shadow_clip.z) | ||
42 | { | ||
43 | lpos = shadow_matrix[3]*spos; | ||
44 | lpos.xy *= screen_res; | ||
45 | shadow = shadow2DRectProj(shadowMap3, lpos).x; | ||
46 | shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); | ||
47 | } | ||
48 | else if (spos.z < -shadow_clip.y) | ||
49 | { | ||
50 | lpos = shadow_matrix[2]*spos; | ||
51 | lpos.xy *= screen_res; | ||
52 | shadow = shadow2DRectProj(shadowMap2, lpos).x; | ||
53 | } | ||
54 | else if (spos.z < -shadow_clip.x) | ||
55 | { | ||
56 | lpos = shadow_matrix[1]*spos; | ||
57 | lpos.xy *= screen_res; | ||
58 | shadow = shadow2DRectProj(shadowMap1, lpos).x; | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | lpos = shadow_matrix[0]*spos; | ||
63 | lpos.xy *= screen_res; | ||
64 | shadow = shadow2DRectProj(shadowMap0, lpos).x; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | |||
69 | vec4 col = vec4(vary_ambient + vary_directional*shadow, gl_Color.a); | ||
70 | vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * col; | ||
71 | |||
72 | color.rgb = atmosLighting(color.rgb); | ||
73 | |||
74 | color.rgb = scaleSoftClip(color.rgb); | ||
75 | |||
76 | gl_FragColor = color; | ||
77 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl new file mode 100644 index 0000000..c1988d3 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl | |||
@@ -0,0 +1,78 @@ | |||
1 | /** | ||
2 | * @file avatarAlphaV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); | ||
9 | mat4 getSkinnedTransform(); | ||
10 | void calcAtmospherics(vec3 inPositionEye); | ||
11 | |||
12 | float calcDirectionalLight(vec3 n, vec3 l); | ||
13 | float calcPointLight(vec3 v, vec3 n, vec4 lp, float la); | ||
14 | |||
15 | vec3 atmosAmbient(vec3 light); | ||
16 | vec3 atmosAffectDirectionalLight(float lightIntensity); | ||
17 | vec3 scaleDownLight(vec3 light); | ||
18 | vec3 scaleUpLight(vec3 light); | ||
19 | |||
20 | varying vec4 vary_position; | ||
21 | varying vec3 vary_ambient; | ||
22 | varying vec3 vary_directional; | ||
23 | varying vec3 vary_normal; | ||
24 | |||
25 | void main() | ||
26 | { | ||
27 | gl_TexCoord[0] = gl_MultiTexCoord0; | ||
28 | |||
29 | vec4 pos; | ||
30 | vec3 norm; | ||
31 | |||
32 | mat4 trans = getSkinnedTransform(); | ||
33 | pos.x = dot(trans[0], gl_Vertex); | ||
34 | pos.y = dot(trans[1], gl_Vertex); | ||
35 | pos.z = dot(trans[2], gl_Vertex); | ||
36 | pos.w = 1.0; | ||
37 | |||
38 | norm.x = dot(trans[0].xyz, gl_Normal); | ||
39 | norm.y = dot(trans[1].xyz, gl_Normal); | ||
40 | norm.z = dot(trans[2].xyz, gl_Normal); | ||
41 | norm = normalize(norm); | ||
42 | |||
43 | gl_Position = gl_ProjectionMatrix * pos; | ||
44 | vary_position = pos; | ||
45 | vary_normal = norm; | ||
46 | |||
47 | calcAtmospherics(pos.xyz); | ||
48 | |||
49 | //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); | ||
50 | vec4 col; | ||
51 | col.a = gl_Color.a; | ||
52 | |||
53 | // Add windlight lights | ||
54 | col.rgb = atmosAmbient(vec3(0.)); | ||
55 | col.rgb = scaleUpLight(col.rgb); | ||
56 | |||
57 | // Collect normal lights (need to be divided by two, as we later multiply by 2) | ||
58 | col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation); | ||
59 | col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation); | ||
60 | col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation); | ||
61 | col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation); | ||
62 | col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation); | ||
63 | col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation); | ||
64 | col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); | ||
65 | col.rgb = scaleDownLight(col.rgb); | ||
66 | |||
67 | vary_ambient = col.rgb*gl_Color.rgb; | ||
68 | vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a))); | ||
69 | |||
70 | col.rgb = min(col.rgb*gl_Color.rgb, 1.0); | ||
71 | |||
72 | gl_FrontColor = col; | ||
73 | |||
74 | gl_FogFragCoord = pos.z; | ||
75 | |||
76 | } | ||
77 | |||
78 | |||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl new file mode 100644 index 0000000..1713fe9 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl | |||
@@ -0,0 +1,71 @@ | |||
1 | /** | ||
2 | * @file blurLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect depthMap; | ||
11 | uniform sampler2DRect normalMap; | ||
12 | uniform sampler2DRect lightMap; | ||
13 | |||
14 | uniform float dist_factor; | ||
15 | uniform float blur_size; | ||
16 | uniform vec2 delta; | ||
17 | uniform vec3 kern[32]; | ||
18 | uniform int kern_length; | ||
19 | uniform float kern_scale; | ||
20 | |||
21 | varying vec2 vary_fragcoord; | ||
22 | |||
23 | uniform mat4 inv_proj; | ||
24 | uniform vec2 screen_res; | ||
25 | |||
26 | vec4 getPosition(vec2 pos_screen) | ||
27 | { | ||
28 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
29 | vec2 sc = pos_screen.xy*2.0; | ||
30 | sc /= screen_res; | ||
31 | sc -= vec2(1.0,1.0); | ||
32 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
33 | vec4 pos = inv_proj * ndc; | ||
34 | pos /= pos.w; | ||
35 | pos.w = 1.0; | ||
36 | return pos; | ||
37 | } | ||
38 | |||
39 | void main() | ||
40 | { | ||
41 | vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0; | ||
42 | vec3 pos = getPosition(vary_fragcoord.xy).xyz; | ||
43 | vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba; | ||
44 | |||
45 | vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); | ||
46 | |||
47 | dlt /= max(-pos.z*dist_factor, 1.0); | ||
48 | |||
49 | vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free' | ||
50 | vec4 col = defined_weight.xyxx * ccol; | ||
51 | |||
52 | for (int i = 1; i < kern_length; i++) | ||
53 | { | ||
54 | vec2 tc = vary_fragcoord.xy + kern[i].z*dlt; | ||
55 | vec3 samppos = getPosition(tc).xyz; | ||
56 | float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane | ||
57 | if (d*d <= 0.003) | ||
58 | { | ||
59 | col += texture2DRect(lightMap, tc)*kern[i].xyxx; | ||
60 | defined_weight += kern[i].xy; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | |||
65 | |||
66 | col /= defined_weight.xyxx; | ||
67 | |||
68 | gl_FragColor = col; | ||
69 | |||
70 | //gl_FragColor = ccol; | ||
71 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightV.glsl new file mode 100644 index 0000000..b7f07e5 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightV.glsl | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | * @file blurLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | uniform vec2 screen_res; | ||
10 | |||
11 | void main() | ||
12 | { | ||
13 | //transform vertex | ||
14 | gl_Position = ftransform(); | ||
15 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
16 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
17 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl new file mode 100644 index 0000000..6519594 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl | |||
@@ -0,0 +1,188 @@ | |||
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 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredF.glsl new file mode 100644 index 0000000..ee0e9d6 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredF.glsl | |||
@@ -0,0 +1,59 @@ | |||
1 | /** | ||
2 | * @file postDeferredF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect diffuseRect; | ||
9 | uniform sampler2DRect localLightMap; | ||
10 | uniform sampler2DRect sunLightMap; | ||
11 | uniform sampler2DRect giLightMap; | ||
12 | uniform sampler2D luminanceMap; | ||
13 | uniform sampler2DRect lightMap; | ||
14 | |||
15 | uniform vec3 gi_lum_quad; | ||
16 | uniform vec3 sun_lum_quad; | ||
17 | uniform vec3 lum_quad; | ||
18 | uniform float lum_lod; | ||
19 | uniform vec4 ambient; | ||
20 | |||
21 | uniform vec3 gi_quad; | ||
22 | |||
23 | uniform vec2 screen_res; | ||
24 | varying vec2 vary_fragcoord; | ||
25 | |||
26 | void main() | ||
27 | { | ||
28 | vec2 tc = vary_fragcoord.xy; | ||
29 | vec3 lcol = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb; | ||
30 | |||
31 | float lum = sqrt(lcol.r)*lum_quad.x+lcol.r*lcol.r*lum_quad.y+lcol.r*lum_quad.z; | ||
32 | |||
33 | vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy); | ||
34 | |||
35 | float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g; | ||
36 | |||
37 | vec3 gi_col = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
38 | gi_col = gi_col*gi_col*gi_quad.x + gi_col*gi_quad.y+gi_quad.z*ambocc*ambient.rgb; | ||
39 | gi_col *= diff; | ||
40 | |||
41 | vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy); | ||
42 | |||
43 | vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb; | ||
44 | |||
45 | |||
46 | float sun_lum = 1.0-lum; | ||
47 | sun_lum = sun_lum*sun_lum*sun_lum_quad.x + sun_lum*sun_lum_quad.y+sun_lum_quad.z; | ||
48 | |||
49 | float gi_lum = lum; | ||
50 | gi_lum = gi_lum*gi_lum*gi_lum_quad.x+gi_lum*gi_lum_quad.y+gi_lum_quad.z; | ||
51 | gi_col *= 1.0/gi_lum; | ||
52 | |||
53 | vec3 col = sun_col.rgb*(1.0+max(sun_lum,0.0))+gi_col+local_col; | ||
54 | |||
55 | gl_FragColor.rgb = col.rgb; | ||
56 | gl_FragColor.a = max(sun_lum*min(sun_col.r+sun_col.g+sun_col.b, 1.0), sun_col.a); | ||
57 | |||
58 | //gl_FragColor.rgb = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
59 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredV.glsl new file mode 100644 index 0000000..9819232 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredV.glsl | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | * @file postDeferredV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | uniform vec2 screen_res; | ||
10 | |||
11 | void main() | ||
12 | { | ||
13 | //transform vertex | ||
14 | gl_Position = ftransform(); | ||
15 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
16 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
17 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl new file mode 100644 index 0000000..52b79e3 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | |||
@@ -0,0 +1,294 @@ | |||
1 | /** | ||
2 | * @file softenLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect diffuseRect; | ||
11 | uniform sampler2DRect specularRect; | ||
12 | uniform sampler2DRect normalMap; | ||
13 | uniform sampler2DRect lightMap; | ||
14 | uniform sampler2D noiseMap; | ||
15 | uniform samplerCube environmentMap; | ||
16 | uniform sampler2D lightFunc; | ||
17 | uniform vec3 gi_quad; | ||
18 | |||
19 | uniform float blur_size; | ||
20 | uniform float blur_fidelity; | ||
21 | |||
22 | // Inputs | ||
23 | uniform vec4 morphFactor; | ||
24 | uniform vec3 camPosLocal; | ||
25 | //uniform vec4 camPosWorld; | ||
26 | uniform vec4 gamma; | ||
27 | uniform vec4 lightnorm; | ||
28 | uniform vec4 sunlight_color; | ||
29 | uniform vec4 ambient; | ||
30 | uniform vec4 blue_horizon; | ||
31 | uniform vec4 blue_density; | ||
32 | uniform vec4 haze_horizon; | ||
33 | uniform vec4 haze_density; | ||
34 | uniform vec4 cloud_shadow; | ||
35 | uniform vec4 density_multiplier; | ||
36 | uniform vec4 distance_multiplier; | ||
37 | uniform vec4 max_y; | ||
38 | uniform vec4 glow; | ||
39 | uniform float scene_light_strength; | ||
40 | uniform vec3 env_mat[3]; | ||
41 | uniform vec4 shadow_clip; | ||
42 | uniform mat3 ssao_effect_mat; | ||
43 | |||
44 | uniform sampler2DRect depthMap; | ||
45 | uniform mat4 inv_proj; | ||
46 | uniform vec2 screen_res; | ||
47 | |||
48 | varying vec4 vary_light; | ||
49 | varying vec2 vary_fragcoord; | ||
50 | |||
51 | vec3 vary_PositionEye; | ||
52 | |||
53 | vec3 vary_SunlitColor; | ||
54 | vec3 vary_AmblitColor; | ||
55 | vec3 vary_AdditiveColor; | ||
56 | vec3 vary_AtmosAttenuation; | ||
57 | |||
58 | vec4 getPosition(vec2 pos_screen) | ||
59 | { //get position in screen space (world units) given window coordinate and depth map | ||
60 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
61 | vec2 sc = pos_screen.xy*2.0; | ||
62 | sc /= screen_res; | ||
63 | sc -= vec2(1.0,1.0); | ||
64 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
65 | vec4 pos = inv_proj * ndc; | ||
66 | pos /= pos.w; | ||
67 | pos.w = 1.0; | ||
68 | return pos; | ||
69 | } | ||
70 | |||
71 | vec3 getPositionEye() | ||
72 | { | ||
73 | return vary_PositionEye; | ||
74 | } | ||
75 | vec3 getSunlitColor() | ||
76 | { | ||
77 | return vary_SunlitColor; | ||
78 | } | ||
79 | vec3 getAmblitColor() | ||
80 | { | ||
81 | return vary_AmblitColor; | ||
82 | } | ||
83 | vec3 getAdditiveColor() | ||
84 | { | ||
85 | return vary_AdditiveColor; | ||
86 | } | ||
87 | vec3 getAtmosAttenuation() | ||
88 | { | ||
89 | return vary_AtmosAttenuation; | ||
90 | } | ||
91 | |||
92 | |||
93 | void setPositionEye(vec3 v) | ||
94 | { | ||
95 | vary_PositionEye = v; | ||
96 | } | ||
97 | |||
98 | void setSunlitColor(vec3 v) | ||
99 | { | ||
100 | vary_SunlitColor = v; | ||
101 | } | ||
102 | |||
103 | void setAmblitColor(vec3 v) | ||
104 | { | ||
105 | vary_AmblitColor = v; | ||
106 | } | ||
107 | |||
108 | void setAdditiveColor(vec3 v) | ||
109 | { | ||
110 | vary_AdditiveColor = v; | ||
111 | } | ||
112 | |||
113 | void setAtmosAttenuation(vec3 v) | ||
114 | { | ||
115 | vary_AtmosAttenuation = v; | ||
116 | } | ||
117 | |||
118 | void calcAtmospherics(vec3 inPositionEye, float ambFactor) { | ||
119 | |||
120 | vec3 P = inPositionEye; | ||
121 | setPositionEye(P); | ||
122 | |||
123 | //(TERRAIN) limit altitude | ||
124 | if (P.y > max_y.x) P *= (max_y.x / P.y); | ||
125 | if (P.y < -max_y.x) P *= (-max_y.x / P.y); | ||
126 | |||
127 | vec3 tmpLightnorm = lightnorm.xyz; | ||
128 | |||
129 | vec3 Pn = normalize(P); | ||
130 | float Plen = length(P); | ||
131 | |||
132 | vec4 temp1 = vec4(0); | ||
133 | vec3 temp2 = vec3(0); | ||
134 | vec4 blue_weight; | ||
135 | vec4 haze_weight; | ||
136 | vec4 sunlight = sunlight_color; | ||
137 | vec4 light_atten; | ||
138 | |||
139 | //sunlight attenuation effect (hue and brightness) due to atmosphere | ||
140 | //this is used later for sunlight modulation at various altitudes | ||
141 | light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x); | ||
142 | //I had thought blue_density and haze_density should have equal weighting, | ||
143 | //but attenuation due to haze_density tends to seem too strong | ||
144 | |||
145 | temp1 = blue_density + vec4(haze_density.r); | ||
146 | blue_weight = blue_density / temp1; | ||
147 | haze_weight = vec4(haze_density.r) / temp1; | ||
148 | |||
149 | //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) | ||
150 | temp2.y = max(0.0, tmpLightnorm.y); | ||
151 | temp2.y = 1. / temp2.y; | ||
152 | sunlight *= exp( - light_atten * temp2.y); | ||
153 | |||
154 | // main atmospheric scattering line integral | ||
155 | temp2.z = Plen * density_multiplier.x; | ||
156 | |||
157 | // Transparency (-> temp1) | ||
158 | // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati | ||
159 | // compiler gets confused. | ||
160 | temp1 = exp(-temp1 * temp2.z * distance_multiplier.x); | ||
161 | |||
162 | //final atmosphere attenuation factor | ||
163 | setAtmosAttenuation(temp1.rgb); | ||
164 | |||
165 | //compute haze glow | ||
166 | //(can use temp2.x as temp because we haven't used it yet) | ||
167 | temp2.x = dot(Pn, tmpLightnorm.xyz); | ||
168 | temp2.x = 1. - temp2.x; | ||
169 | //temp2.x is 0 at the sun and increases away from sun | ||
170 | temp2.x = max(temp2.x, .03); //was glow.y | ||
171 | //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) | ||
172 | temp2.x *= glow.x; | ||
173 | //higher glow.x gives dimmer glow (because next step is 1 / "angle") | ||
174 | temp2.x = pow(temp2.x, glow.z); | ||
175 | //glow.z should be negative, so we're doing a sort of (1 / "angle") function | ||
176 | |||
177 | //add "minimum anti-solar illumination" | ||
178 | temp2.x += .25; | ||
179 | |||
180 | //increase ambient when there are more clouds | ||
181 | vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5; | ||
182 | |||
183 | /* decrease value and saturation (that in HSV, not HSL) for occluded areas | ||
184 | * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html | ||
185 | * // The following line of code performs the equivalent of: | ||
186 | * float ambAlpha = tmpAmbient.a; | ||
187 | * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis | ||
188 | * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); | ||
189 | * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); | ||
190 | */ | ||
191 | tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); | ||
192 | |||
193 | //haze color | ||
194 | setAdditiveColor( | ||
195 | vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient) | ||
196 | + (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x | ||
197 | + tmpAmbient))); | ||
198 | |||
199 | //brightness of surface both sunlight and ambient | ||
200 | setSunlitColor(vec3(sunlight * .5)); | ||
201 | setAmblitColor(vec3(tmpAmbient * .25)); | ||
202 | setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); | ||
203 | } | ||
204 | |||
205 | vec3 atmosLighting(vec3 light) | ||
206 | { | ||
207 | light *= getAtmosAttenuation().r; | ||
208 | light += getAdditiveColor(); | ||
209 | return (2.0 * light); | ||
210 | } | ||
211 | |||
212 | vec3 atmosTransport(vec3 light) { | ||
213 | light *= getAtmosAttenuation().r; | ||
214 | light += getAdditiveColor() * 2.0; | ||
215 | return light; | ||
216 | } | ||
217 | vec3 atmosGetDiffuseSunlightColor() | ||
218 | { | ||
219 | return getSunlitColor(); | ||
220 | } | ||
221 | |||
222 | vec3 scaleDownLight(vec3 light) | ||
223 | { | ||
224 | return (light / scene_light_strength ); | ||
225 | } | ||
226 | |||
227 | vec3 scaleUpLight(vec3 light) | ||
228 | { | ||
229 | return (light * scene_light_strength); | ||
230 | } | ||
231 | |||
232 | vec3 atmosAmbient(vec3 light) | ||
233 | { | ||
234 | return getAmblitColor() + light / 2.0; | ||
235 | } | ||
236 | |||
237 | vec3 atmosAffectDirectionalLight(float lightIntensity) | ||
238 | { | ||
239 | return getSunlitColor() * lightIntensity; | ||
240 | } | ||
241 | |||
242 | vec3 scaleSoftClip(vec3 light) | ||
243 | { | ||
244 | //soft clip effect: | ||
245 | light = 1. - clamp(light, vec3(0.), vec3(1.)); | ||
246 | light = 1. - pow(light, gamma.xxx); | ||
247 | |||
248 | return light; | ||
249 | } | ||
250 | |||
251 | void main() | ||
252 | { | ||
253 | vec2 tc = vary_fragcoord.xy; | ||
254 | vec3 pos = getPosition(tc).xyz; | ||
255 | vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0; | ||
256 | vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz; | ||
257 | |||
258 | float da = max(dot(norm.xyz, vary_light.xyz), 0.0); | ||
259 | |||
260 | vec4 diffuse = texture2DRect(diffuseRect, tc); | ||
261 | vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); | ||
262 | |||
263 | vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; | ||
264 | float scol = max(scol_ambocc.r, diffuse.a); | ||
265 | float ambocc = scol_ambocc.g; | ||
266 | |||
267 | calcAtmospherics(pos.xyz, ambocc); | ||
268 | |||
269 | vec3 col = atmosAmbient(vec3(0)); | ||
270 | col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); | ||
271 | |||
272 | col *= diffuse.rgb; | ||
273 | |||
274 | if (spec.a > 0.0) | ||
275 | { | ||
276 | vec3 ref = normalize(reflect(pos.xyz, norm.xyz)); | ||
277 | float sa = dot(ref, vary_light.xyz); | ||
278 | col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a; | ||
279 | } | ||
280 | |||
281 | col = atmosLighting(col); | ||
282 | col = scaleSoftClip(col); | ||
283 | |||
284 | gl_FragColor.rgb = col; | ||
285 | |||
286 | //gl_FragColor.rgb = gi_col.rgb; | ||
287 | gl_FragColor.a = 0.0; | ||
288 | |||
289 | //gl_FragColor.rg = scol_ambocc.rg; | ||
290 | //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb; | ||
291 | //gl_FragColor.rgb = norm.rgb*0.5+0.5; | ||
292 | //gl_FragColor.rgb = vec3(ambocc); | ||
293 | //gl_FragColor.rgb = vec3(scol); | ||
294 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl new file mode 100644 index 0000000..ad8af47 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl | |||
@@ -0,0 +1,24 @@ | |||
1 | /** | ||
2 | * @file softenLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform vec2 screen_res; | ||
9 | |||
10 | varying vec4 vary_light; | ||
11 | varying vec2 vary_fragcoord; | ||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | |||
17 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
18 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
19 | |||
20 | vec4 tex = gl_MultiTexCoord0; | ||
21 | tex.w = 1.0; | ||
22 | |||
23 | vary_light = gl_MultiTexCoord0; | ||
24 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl new file mode 100644 index 0000000..d653408 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | |||
@@ -0,0 +1,199 @@ | |||
1 | /** | ||
2 | * @file spotLightF.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_ambiance; | ||
30 | uniform float near_clip; | ||
31 | uniform float far_clip; | ||
32 | |||
33 | uniform vec3 proj_origin; //origin of projection to be used for angular attenuation | ||
34 | uniform float sun_wash; | ||
35 | uniform int proj_shadow_idx; | ||
36 | uniform float shadow_fade; | ||
37 | |||
38 | varying vec4 vary_light; | ||
39 | |||
40 | varying vec4 vary_fragcoord; | ||
41 | uniform vec2 screen_res; | ||
42 | |||
43 | uniform mat4 inv_proj; | ||
44 | |||
45 | vec4 getPosition(vec2 pos_screen) | ||
46 | { | ||
47 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
48 | vec2 sc = pos_screen.xy*2.0; | ||
49 | sc /= screen_res; | ||
50 | sc -= vec2(1.0,1.0); | ||
51 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
52 | vec4 pos = inv_proj * ndc; | ||
53 | pos /= pos.w; | ||
54 | pos.w = 1.0; | ||
55 | return pos; | ||
56 | } | ||
57 | |||
58 | void main() | ||
59 | { | ||
60 | vec4 frag = vary_fragcoord; | ||
61 | frag.xyz /= frag.w; | ||
62 | frag.xyz = frag.xyz*0.5+0.5; | ||
63 | frag.xy *= screen_res; | ||
64 | |||
65 | float shadow = 1.0; | ||
66 | |||
67 | if (proj_shadow_idx >= 0) | ||
68 | { | ||
69 | vec4 shd = texture2DRect(lightMap, frag.xy); | ||
70 | float sh[2]; | ||
71 | sh[0] = shd.b; | ||
72 | sh[1] = shd.a; | ||
73 | shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); | ||
74 | } | ||
75 | |||
76 | vec3 pos = getPosition(frag.xy).xyz; | ||
77 | vec3 lv = vary_light.xyz-pos.xyz; | ||
78 | float dist2 = dot(lv,lv); | ||
79 | dist2 /= vary_light.w; | ||
80 | if (dist2 > 1.0) | ||
81 | { | ||
82 | discard; | ||
83 | } | ||
84 | |||
85 | vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0; | ||
86 | |||
87 | norm = normalize(norm); | ||
88 | float l_dist = -dot(lv, proj_n); | ||
89 | |||
90 | vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); | ||
91 | if (proj_tc.z < 0.0) | ||
92 | { | ||
93 | discard; | ||
94 | } | ||
95 | |||
96 | proj_tc.xyz /= proj_tc.w; | ||
97 | |||
98 | float fa = gl_Color.a+1.0; | ||
99 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); | ||
100 | |||
101 | lv = proj_origin-pos.xyz; | ||
102 | lv = normalize(lv); | ||
103 | float da = dot(norm, lv); | ||
104 | |||
105 | vec3 col = vec3(0,0,0); | ||
106 | |||
107 | vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; | ||
108 | |||
109 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | ||
110 | if (proj_tc.z > 0.0 && | ||
111 | proj_tc.x < 1.0 && | ||
112 | proj_tc.y < 1.0 && | ||
113 | proj_tc.x > 0.0 && | ||
114 | proj_tc.y > 0.0) | ||
115 | { | ||
116 | float lit = 0.0; | ||
117 | if (da > 0.0) | ||
118 | { | ||
119 | float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); | ||
120 | float lod = diff * proj_lod; | ||
121 | |||
122 | vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
123 | |||
124 | vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; | ||
125 | |||
126 | lit = da * dist_atten * noise; | ||
127 | |||
128 | col = lcol*lit*diff_tex*shadow; | ||
129 | } | ||
130 | |||
131 | float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); | ||
132 | float lod = diff * proj_lod; | ||
133 | vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
134 | //float amb_da = mix(proj_ambiance, proj_ambiance*max(-da, 0.0), max(da, 0.0)); | ||
135 | float amb_da = proj_ambiance; | ||
136 | if (da > 0.0) | ||
137 | { | ||
138 | amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; | ||
139 | } | ||
140 | |||
141 | amb_da += (da*da*0.5+0.5)*proj_ambiance; | ||
142 | |||
143 | amb_da *= dist_atten * noise; | ||
144 | |||
145 | amb_da = min(amb_da, 1.0-lit); | ||
146 | |||
147 | col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; | ||
148 | } | ||
149 | |||
150 | |||
151 | vec4 spec = texture2DRect(specularRect, frag.xy); | ||
152 | if (spec.a > 0.0) | ||
153 | { | ||
154 | vec3 ref = reflect(normalize(pos), norm); | ||
155 | |||
156 | //project from point pos in direction ref to plane proj_p, proj_n | ||
157 | vec3 pdelta = proj_p-pos; | ||
158 | float ds = dot(ref, proj_n); | ||
159 | |||
160 | if (ds < 0.0) | ||
161 | { | ||
162 | vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; | ||
163 | |||
164 | vec3 stc = (proj_mat * vec4(pfinal.xyz, 1.0)).xyz; | ||
165 | |||
166 | if (stc.z > 0.0) | ||
167 | { | ||
168 | stc.xy /= stc.z+proj_near; | ||
169 | |||
170 | if (stc.x < 1.0 && | ||
171 | stc.y < 1.0 && | ||
172 | stc.x > 0.0 && | ||
173 | stc.y > 0.0) | ||
174 | { | ||
175 | vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); | ||
176 | col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow; | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | /*if (spec.a > 0.0) | ||
183 | { | ||
184 | //vec3 ref = reflect(normalize(pos), norm); | ||
185 | float sa = dot(normalize(lv-normalize(pos)),norm);; | ||
186 | //sa = max(sa, 0.0); | ||
187 | //sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); | ||
188 | sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); | ||
189 | sa *= noise; | ||
190 | col += da*sa*lcol*spec.rgb; | ||
191 | }*/ | ||
192 | |||
193 | //attenuate point light contribution by SSAO component | ||
194 | col *= texture2DRect(lightMap, frag.xy).g; | ||
195 | |||
196 | |||
197 | gl_FragColor.rgb = col; | ||
198 | gl_FragColor.a = 0.0; | ||
199 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl new file mode 100644 index 0000000..8ced94e --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl | |||
@@ -0,0 +1,203 @@ | |||
1 | /** | ||
2 | * @file sunLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect depthMap; | ||
11 | uniform sampler2DRect normalMap; | ||
12 | uniform sampler2DRectShadow shadowMap0; | ||
13 | uniform sampler2DRectShadow shadowMap1; | ||
14 | uniform sampler2DRectShadow shadowMap2; | ||
15 | uniform sampler2DRectShadow shadowMap3; | ||
16 | uniform sampler2DRectShadow shadowMap4; | ||
17 | uniform sampler2DRectShadow shadowMap5; | ||
18 | uniform sampler2D noiseMap; | ||
19 | |||
20 | uniform sampler2D lightFunc; | ||
21 | |||
22 | |||
23 | // Inputs | ||
24 | uniform mat4 shadow_matrix[6]; | ||
25 | uniform vec4 shadow_clip; | ||
26 | uniform float ssao_radius; | ||
27 | uniform float ssao_max_radius; | ||
28 | uniform float ssao_factor; | ||
29 | uniform float ssao_factor_inv; | ||
30 | |||
31 | varying vec2 vary_fragcoord; | ||
32 | varying vec4 vary_light; | ||
33 | |||
34 | uniform mat4 inv_proj; | ||
35 | uniform vec2 screen_res; | ||
36 | |||
37 | uniform float shadow_bias; | ||
38 | uniform float shadow_offset; | ||
39 | |||
40 | vec4 getPosition(vec2 pos_screen) | ||
41 | { | ||
42 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
43 | vec2 sc = pos_screen.xy*2.0; | ||
44 | sc /= screen_res; | ||
45 | sc -= vec2(1.0,1.0); | ||
46 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
47 | vec4 pos = inv_proj * ndc; | ||
48 | pos /= pos.w; | ||
49 | pos.w = 1.0; | ||
50 | return pos; | ||
51 | } | ||
52 | |||
53 | //calculate decreases in ambient lighting when crowded out (SSAO) | ||
54 | float calcAmbientOcclusion(vec4 pos, vec3 norm) | ||
55 | { | ||
56 | vec2 kern[8]; | ||
57 | // exponentially (^2) distant occlusion samples spread around origin | ||
58 | kern[0] = vec2(-1.0, 0.0) * 0.125*0.125; | ||
59 | kern[1] = vec2(1.0, 0.0) * 0.250*0.250; | ||
60 | kern[2] = vec2(0.0, 1.0) * 0.375*0.375; | ||
61 | kern[3] = vec2(0.0, -1.0) * 0.500*0.500; | ||
62 | kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625; | ||
63 | kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750; | ||
64 | kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; | ||
65 | kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; | ||
66 | |||
67 | vec2 pos_screen = vary_fragcoord.xy; | ||
68 | vec3 pos_world = pos.xyz; | ||
69 | vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy; | ||
70 | |||
71 | float angle_hidden = 0.0; | ||
72 | int points = 0; | ||
73 | |||
74 | float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); | ||
75 | |||
76 | // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?) | ||
77 | for (int i = 0; i < 8; i++) | ||
78 | { | ||
79 | vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect); | ||
80 | vec3 samppos_world = getPosition(samppos_screen).xyz; | ||
81 | |||
82 | vec3 diff = pos_world - samppos_world; | ||
83 | float dist2 = dot(diff, diff); | ||
84 | |||
85 | // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area | ||
86 | // --> solid angle shrinking by the square of distance | ||
87 | //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2 | ||
88 | //(k should vary inversely with # of samples, but this is taken care of later) | ||
89 | |||
90 | //if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) // -0.05*norm to shift sample point back slightly for flat surfaces | ||
91 | // angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional. max of 1.0 (= ssao_factor_inv * ssao_factor) | ||
92 | angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv); | ||
93 | |||
94 | // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" | ||
95 | points = points + int(diff.z > -1.0); | ||
96 | } | ||
97 | |||
98 | angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); | ||
99 | |||
100 | return (1.0 - (float(points != 0) * angle_hidden)); | ||
101 | } | ||
102 | |||
103 | void main() | ||
104 | { | ||
105 | vec2 pos_screen = vary_fragcoord.xy; | ||
106 | |||
107 | //try doing an unproject here | ||
108 | |||
109 | vec4 pos = getPosition(pos_screen); | ||
110 | |||
111 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0; | ||
112 | |||
113 | /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL | ||
114 | { | ||
115 | gl_FragColor = vec4(0.0); // doesn't matter | ||
116 | return; | ||
117 | }*/ | ||
118 | |||
119 | float shadow = 1.0; | ||
120 | float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); | ||
121 | |||
122 | vec4 spos = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0); | ||
123 | |||
124 | //vec3 debug = vec3(0,0,0); | ||
125 | |||
126 | if (spos.z > -shadow_clip.w) | ||
127 | { | ||
128 | if (dp_directional_light == 0.0) | ||
129 | { | ||
130 | // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup | ||
131 | shadow = 0.0; | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | vec4 lpos; | ||
136 | |||
137 | if (spos.z < -shadow_clip.z) | ||
138 | { | ||
139 | lpos = shadow_matrix[3]*spos; | ||
140 | lpos.xy *= screen_res; | ||
141 | shadow = shadow2DRectProj(shadowMap3, lpos).x; | ||
142 | shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); | ||
143 | } | ||
144 | else if (spos.z < -shadow_clip.y) | ||
145 | { | ||
146 | lpos = shadow_matrix[2]*spos; | ||
147 | lpos.xy *= screen_res; | ||
148 | shadow = shadow2DRectProj(shadowMap2, lpos).x; | ||
149 | } | ||
150 | else if (spos.z < -shadow_clip.x) | ||
151 | { | ||
152 | lpos = shadow_matrix[1]*spos; | ||
153 | lpos.xy *= screen_res; | ||
154 | shadow = shadow2DRectProj(shadowMap1, lpos).x; | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | lpos = shadow_matrix[0]*spos; | ||
159 | lpos.xy *= screen_res; | ||
160 | shadow = shadow2DRectProj(shadowMap0, lpos).x; | ||
161 | } | ||
162 | |||
163 | // take the most-shadowed value out of these two: | ||
164 | // * the blurred sun shadow in the light (shadow) map | ||
165 | // * an unblurred dot product between the sun and this norm | ||
166 | // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting | ||
167 | shadow = min(shadow, dp_directional_light); | ||
168 | } | ||
169 | |||
170 | /*debug.r = lpos.y / (lpos.w*screen_res.y); | ||
171 | |||
172 | lpos.xy /= lpos.w*32.0; | ||
173 | if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1) | ||
174 | { | ||
175 | debug.gb = vec2(0.5, 0.5); | ||
176 | } | ||
177 | |||
178 | debug += (1.0-shadow)*0.5;*/ | ||
179 | |||
180 | } | ||
181 | else | ||
182 | { | ||
183 | // more distant than the shadow map covers | ||
184 | shadow = 1.0; | ||
185 | } | ||
186 | |||
187 | gl_FragColor[0] = shadow; | ||
188 | gl_FragColor[1] = calcAmbientOcclusion(pos, norm); | ||
189 | |||
190 | //spotlight shadow 1 | ||
191 | vec4 lpos = shadow_matrix[4]*spos; | ||
192 | lpos.xy *= screen_res; | ||
193 | gl_FragColor[2] = shadow2DRectProj(shadowMap4, lpos).x; | ||
194 | |||
195 | //spotlight shadow 2 | ||
196 | lpos = shadow_matrix[5]*spos; | ||
197 | lpos.xy *= screen_res; | ||
198 | gl_FragColor[3] = shadow2DRectProj(shadowMap5, lpos).x; | ||
199 | |||
200 | //gl_FragColor.rgb = pos.xyz; | ||
201 | //gl_FragColor.b = shadow; | ||
202 | //gl_FragColor.rgb = debug; | ||
203 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl new file mode 100644 index 0000000..5081485 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl | |||
@@ -0,0 +1,25 @@ | |||
1 | /** | ||
2 | * @file sunLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec4 vary_light; | ||
9 | varying vec2 vary_fragcoord; | ||
10 | |||
11 | uniform vec2 screen_res; | ||
12 | |||
13 | void main() | ||
14 | { | ||
15 | //transform vertex | ||
16 | gl_Position = ftransform(); | ||
17 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
18 | vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; | ||
19 | vec4 tex = gl_MultiTexCoord0; | ||
20 | tex.w = 1.0; | ||
21 | |||
22 | vary_light = gl_MultiTexCoord0; | ||
23 | |||
24 | gl_FrontColor = gl_Color; | ||
25 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/waterF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/waterF.glsl new file mode 100644 index 0000000..7342186 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/waterF.glsl | |||
@@ -0,0 +1,139 @@ | |||
1 | /** | ||
2 | * @file waterF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | vec3 scaleSoftClip(vec3 inColor); | ||
9 | vec3 atmosTransport(vec3 inColor); | ||
10 | |||
11 | uniform sampler2D bumpMap; | ||
12 | uniform sampler2D screenTex; | ||
13 | uniform sampler2D refTex; | ||
14 | uniform sampler2DRectShadow shadowMap0; | ||
15 | uniform sampler2DRectShadow shadowMap1; | ||
16 | uniform sampler2DRectShadow shadowMap2; | ||
17 | uniform sampler2DRectShadow shadowMap3; | ||
18 | uniform sampler2D noiseMap; | ||
19 | |||
20 | uniform mat4 shadow_matrix[6]; | ||
21 | uniform vec4 shadow_clip; | ||
22 | |||
23 | uniform float sunAngle; | ||
24 | uniform float sunAngle2; | ||
25 | uniform vec3 lightDir; | ||
26 | uniform vec3 specular; | ||
27 | uniform float lightExp; | ||
28 | uniform float refScale; | ||
29 | uniform float kd; | ||
30 | uniform vec2 screenRes; | ||
31 | uniform vec3 normScale; | ||
32 | uniform float fresnelScale; | ||
33 | uniform float fresnelOffset; | ||
34 | uniform float blurMultiplier; | ||
35 | uniform vec2 screen_res; | ||
36 | uniform mat4 norm_mat; //region space to screen space | ||
37 | |||
38 | //bigWave is (refCoord.w, view.w); | ||
39 | varying vec4 refCoord; | ||
40 | varying vec4 littleWave; | ||
41 | varying vec4 view; | ||
42 | varying vec4 vary_position; | ||
43 | |||
44 | void main() | ||
45 | { | ||
46 | vec4 color; | ||
47 | float dist = length(view.xy); | ||
48 | |||
49 | //normalize view vector | ||
50 | vec3 viewVec = normalize(view.xyz); | ||
51 | |||
52 | //get wave normals | ||
53 | vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; | ||
54 | vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; | ||
55 | vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; | ||
56 | //get base fresnel components | ||
57 | |||
58 | vec3 df = vec3( | ||
59 | dot(viewVec, wave1), | ||
60 | dot(viewVec, (wave2 + wave3) * 0.5), | ||
61 | dot(viewVec, wave3) | ||
62 | ) * fresnelScale + fresnelOffset; | ||
63 | df *= df; | ||
64 | |||
65 | vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; | ||
66 | |||
67 | float dist2 = dist; | ||
68 | dist = max(dist, 5.0); | ||
69 | |||
70 | float dmod = sqrt(dist); | ||
71 | |||
72 | vec2 dmod_scale = vec2(dmod*dmod, dmod); | ||
73 | |||
74 | //get reflected color | ||
75 | vec2 refdistort1 = wave1.xy*normScale.x; | ||
76 | vec2 refvec1 = distort+refdistort1/dmod_scale; | ||
77 | vec4 refcol1 = texture2D(refTex, refvec1); | ||
78 | |||
79 | vec2 refdistort2 = wave2.xy*normScale.y; | ||
80 | vec2 refvec2 = distort+refdistort2/dmod_scale; | ||
81 | vec4 refcol2 = texture2D(refTex, refvec2); | ||
82 | |||
83 | vec2 refdistort3 = wave3.xy*normScale.z; | ||
84 | vec2 refvec3 = distort+refdistort3/dmod_scale; | ||
85 | vec4 refcol3 = texture2D(refTex, refvec3); | ||
86 | |||
87 | vec4 refcol = refcol1 + refcol2 + refcol3; | ||
88 | float df1 = df.x + df.y + df.z; | ||
89 | refcol *= df1 * 0.333; | ||
90 | |||
91 | vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; | ||
92 | //wavef.z *= max(-viewVec.z, 0.1); | ||
93 | wavef = normalize(wavef); | ||
94 | |||
95 | float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; | ||
96 | |||
97 | vec2 refdistort4 = wavef.xy*0.125; | ||
98 | refdistort4.y -= abs(refdistort4.y); | ||
99 | vec2 refvec4 = distort+refdistort4/dmod; | ||
100 | float dweight = min(dist2*blurMultiplier, 1.0); | ||
101 | vec4 baseCol = texture2D(refTex, refvec4); | ||
102 | refcol = mix(baseCol*df2, refcol, dweight); | ||
103 | |||
104 | //get specular component | ||
105 | //float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); | ||
106 | |||
107 | //harden specular | ||
108 | //spec = pow(spec, 128.0); | ||
109 | |||
110 | //figure out distortion vector (ripply) | ||
111 | vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); | ||
112 | |||
113 | vec4 fb = texture2D(screenTex, distort2); | ||
114 | |||
115 | //mix with reflection | ||
116 | // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug | ||
117 | color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); | ||
118 | |||
119 | float shadow = 1.0; | ||
120 | vec4 pos = vary_position; | ||
121 | |||
122 | vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz; | ||
123 | vec4 spos = pos; | ||
124 | |||
125 | //spec *= shadow; | ||
126 | //color.rgb += spec * specular; | ||
127 | |||
128 | //color.rgb = atmosTransport(color.rgb); | ||
129 | //color.rgb = scaleSoftClip(color.rgb); | ||
130 | //color.a = spec * sunAngle2; | ||
131 | |||
132 | //wavef.z *= 0.1f; | ||
133 | wavef = normalize(wavef); | ||
134 | wavef = (norm_mat*vec4(wavef, 1.0)).xyz; | ||
135 | |||
136 | gl_FragData[0] = vec4(color.rgb, 0.75); | ||
137 | gl_FragData[1] = vec4(1,1,1, 0.8); | ||
138 | gl_FragData[2] = vec4(wavef*0.5+0.5, 0.f); | ||
139 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl new file mode 100644 index 0000000..b45e5c5 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl | |||
@@ -0,0 +1,76 @@ | |||
1 | /** | ||
2 | * @file waterV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | void calcAtmospherics(vec3 inPositionEye); | ||
9 | |||
10 | uniform vec2 d1; | ||
11 | uniform vec2 d2; | ||
12 | uniform float time; | ||
13 | uniform vec3 eyeVec; | ||
14 | uniform float waterHeight; | ||
15 | |||
16 | varying vec4 refCoord; | ||
17 | varying vec4 littleWave; | ||
18 | varying vec4 view; | ||
19 | |||
20 | varying vec4 vary_position; | ||
21 | |||
22 | float wave(vec2 v, float t, float f, vec2 d, float s) | ||
23 | { | ||
24 | return (dot(d, v)*f + t*s)*f; | ||
25 | } | ||
26 | |||
27 | void main() | ||
28 | { | ||
29 | //transform vertex | ||
30 | vec4 position = gl_Vertex; | ||
31 | mat4 modelViewProj = gl_ModelViewProjectionMatrix; | ||
32 | |||
33 | vec4 oPosition; | ||
34 | |||
35 | //get view vector | ||
36 | vec3 oEyeVec; | ||
37 | oEyeVec.xyz = position.xyz-eyeVec; | ||
38 | |||
39 | float d = length(oEyeVec.xy); | ||
40 | float ld = min(d, 2560.0); | ||
41 | |||
42 | position.xy = eyeVec.xy + oEyeVec.xy/d*ld; | ||
43 | view.xyz = oEyeVec; | ||
44 | |||
45 | d = clamp(ld/1536.0-0.5, 0.0, 1.0); | ||
46 | d *= d; | ||
47 | |||
48 | oPosition = position; | ||
49 | oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); | ||
50 | vary_position = gl_ModelViewMatrix * oPosition; | ||
51 | oPosition = modelViewProj * oPosition; | ||
52 | |||
53 | refCoord.xyz = oPosition.xyz + vec3(0,0,0.2); | ||
54 | |||
55 | //get wave position parameter (create sweeping horizontal waves) | ||
56 | vec3 v = position.xyz; | ||
57 | v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0; | ||
58 | |||
59 | //push position for further horizon effect. | ||
60 | position.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z); | ||
61 | position.w = 1.0; | ||
62 | position = position*gl_ModelViewMatrix; | ||
63 | |||
64 | calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz); | ||
65 | |||
66 | |||
67 | //pass wave parameters to pixel shader | ||
68 | vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055; | ||
69 | //get two normal map (detail map) texture coordinates | ||
70 | littleWave.xy = (v.xy) * vec2(0.45, 0.9) + d2 * time * 0.13; | ||
71 | littleWave.zw = (v.xy) * vec2(0.1, 0.2) + d1 * time * 0.1; | ||
72 | view.w = bigWave.y; | ||
73 | refCoord.w = bigWave.x; | ||
74 | |||
75 | gl_Position = oPosition; | ||
76 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/avatarF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/avatarF.glsl new file mode 100644 index 0000000..9cc71a7 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/avatarF.glsl | |||
@@ -0,0 +1,18 @@ | |||
1 | /** | ||
2 | * @file avatarF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2D diffuseMap; | ||
9 | |||
10 | varying vec3 vary_normal; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | gl_FragData[0] = vec4(gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb, 0.0); | ||
15 | gl_FragData[1] = vec4(0,0,0,0); | ||
16 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); | ||
17 | } | ||
18 | |||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/bumpF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/bumpF.glsl new file mode 100644 index 0000000..6eb4a51 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/bumpF.glsl | |||
@@ -0,0 +1,27 @@ | |||
1 | /** | ||
2 | * @file bumpF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2D diffuseMap; | ||
9 | uniform sampler2D bumpMap; | ||
10 | |||
11 | varying vec3 vary_mat0; | ||
12 | varying vec3 vary_mat1; | ||
13 | varying vec3 vary_mat2; | ||
14 | |||
15 | void main() | ||
16 | { | ||
17 | vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb; | ||
18 | vec3 norm = texture2D(bumpMap, gl_TexCoord[0].xy).rgb * 2.0 - 1.0; | ||
19 | |||
20 | vec3 tnorm = vec3(dot(norm,vary_mat0), | ||
21 | dot(norm,vary_mat1), | ||
22 | dot(norm,vary_mat2)); | ||
23 | |||
24 | gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0); | ||
25 | gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); | ||
26 | gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0); | ||
27 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/diffuseF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/diffuseF.glsl new file mode 100644 index 0000000..c9f75f7 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/diffuseF.glsl | |||
@@ -0,0 +1,18 @@ | |||
1 | /** | ||
2 | * @file diffuseF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2D diffuseMap; | ||
9 | |||
10 | varying vec3 vary_normal; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb; | ||
15 | gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0); | ||
16 | gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); | ||
17 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); | ||
18 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl new file mode 100644 index 0000000..7325825 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl | |||
@@ -0,0 +1,84 @@ | |||
1 | /** | ||
2 | * @file giDownsampleF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect giLightMap; | ||
9 | |||
10 | uniform vec2 kern[32]; | ||
11 | uniform float dist_factor; | ||
12 | uniform float blur_size; | ||
13 | uniform vec2 delta; | ||
14 | uniform int kern_length; | ||
15 | uniform float kern_scale; | ||
16 | uniform vec3 blur_quad; | ||
17 | |||
18 | varying vec2 vary_fragcoord; | ||
19 | |||
20 | uniform mat4 inv_proj; | ||
21 | uniform vec2 screen_res; | ||
22 | |||
23 | vec4 getPosition(vec2 pos_screen) | ||
24 | { | ||
25 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
26 | vec2 sc = pos_screen.xy*2.0; | ||
27 | sc /= screen_res; | ||
28 | sc -= vec2(1.0,1.0); | ||
29 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
30 | vec4 pos = inv_proj * ndc; | ||
31 | pos /= pos.w; | ||
32 | pos.w = 1.0; | ||
33 | return pos; | ||
34 | } | ||
35 | |||
36 | float getDepth(vec2 pos_screen) | ||
37 | { | ||
38 | float z = texture2DRect(depthMap, pos_screen.xy).a; | ||
39 | z = z*2.0-1.0; | ||
40 | vec4 ndc = vec4(0.0, 0.0, z, 1.0); | ||
41 | vec4 p = inv_proj*ndc; | ||
42 | return p.z/p.w; | ||
43 | } | ||
44 | |||
45 | void main() | ||
46 | { | ||
47 | vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0; | ||
48 | float depth = getDepth(vary_fragcoord.xy); | ||
49 | |||
50 | vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
51 | vec2 dlt = kern_scale * delta/(vec2(1.0,1.0)+norm.xy*norm.xy); | ||
52 | dlt /= clamp(-depth*blur_quad.x, 1.0, 3.0); | ||
53 | float defined_weight = kern[0].x; | ||
54 | vec3 col = ccol*kern[0].x; | ||
55 | |||
56 | for (int i = 0; i < kern_length; i++) | ||
57 | { | ||
58 | vec2 tc = vary_fragcoord.xy + kern[i].y*dlt; | ||
59 | vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0; | ||
60 | |||
61 | float d = dot(norm.xyz, sampNorm); | ||
62 | |||
63 | if (d > 0.5) | ||
64 | { | ||
65 | float sampdepth = getDepth(tc.xy); | ||
66 | sampdepth -= depth; | ||
67 | if (sampdepth*sampdepth < blur_quad.z) | ||
68 | { | ||
69 | col += texture2DRect(giLightMap, tc).rgb*kern[i].x; | ||
70 | defined_weight += kern[i].x; | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | col /= defined_weight; | ||
76 | |||
77 | //col = ccol; | ||
78 | |||
79 | col = col*blur_quad.y; | ||
80 | |||
81 | gl_FragData[0].xyz = col; | ||
82 | |||
83 | //gl_FragColor = ccol; | ||
84 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl new file mode 100644 index 0000000..6adcda8 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | * @file postgiV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | uniform vec2 screen_res; | ||
10 | |||
11 | void main() | ||
12 | { | ||
13 | //transform vertex | ||
14 | gl_Position = ftransform(); | ||
15 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
16 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
17 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giF.glsl new file mode 100644 index 0000000..43da836 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giF.glsl | |||
@@ -0,0 +1,219 @@ | |||
1 | /** | ||
2 | * @file giF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect depthMap; | ||
11 | uniform sampler2DRect normalMap; | ||
12 | uniform sampler2DRect lightMap; | ||
13 | uniform sampler2DRect specularRect; | ||
14 | |||
15 | uniform sampler2D noiseMap; | ||
16 | |||
17 | uniform sampler2D diffuseGIMap; | ||
18 | uniform sampler2D specularGIMap; | ||
19 | uniform sampler2D normalGIMap; | ||
20 | uniform sampler2D depthGIMap; | ||
21 | |||
22 | uniform sampler2D lightFunc; | ||
23 | |||
24 | // Inputs | ||
25 | varying vec2 vary_fragcoord; | ||
26 | |||
27 | uniform vec2 screen_res; | ||
28 | |||
29 | uniform vec4 sunlight_color; | ||
30 | |||
31 | uniform mat4 inv_proj; | ||
32 | uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space | ||
33 | uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space | ||
34 | uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix | ||
35 | uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space | ||
36 | uniform float gi_radius; | ||
37 | uniform float gi_intensity; | ||
38 | uniform int gi_samples; | ||
39 | uniform vec2 gi_kern[25]; | ||
40 | uniform vec2 gi_scale; | ||
41 | uniform vec3 gi_quad; | ||
42 | uniform vec3 gi_spec; | ||
43 | uniform float gi_direction_weight; | ||
44 | uniform float gi_light_offset; | ||
45 | uniform float gi_range; | ||
46 | |||
47 | vec4 getPosition(vec2 pos_screen) | ||
48 | { | ||
49 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
50 | vec2 sc = pos_screen.xy*2.0; | ||
51 | sc /= screen_res; | ||
52 | sc -= vec2(1.0,1.0); | ||
53 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
54 | vec4 pos = inv_proj * ndc; | ||
55 | pos /= pos.w; | ||
56 | pos.w = 1.0; | ||
57 | return pos; | ||
58 | } | ||
59 | |||
60 | vec4 getGIPosition(vec2 gi_tc) | ||
61 | { | ||
62 | float depth = texture2D(depthGIMap, gi_tc).a; | ||
63 | vec2 sc = gi_tc*2.0; | ||
64 | sc -= vec2(1.0, 1.0); | ||
65 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
66 | vec4 pos = gi_inv_proj*ndc; | ||
67 | pos.xyz /= pos.w; | ||
68 | pos.w = 1.0; | ||
69 | return pos; | ||
70 | } | ||
71 | |||
72 | vec3 giAmbient(vec3 pos, vec3 norm) | ||
73 | { | ||
74 | vec4 gi_c = gi_mat_proj * vec4(pos, 1.0); | ||
75 | gi_c.xyz /= gi_c.w; | ||
76 | |||
77 | vec4 gi_pos = gi_mat*vec4(pos,1.0); | ||
78 | vec3 gi_norm = (gi_norm_mat*vec4(norm,1.0)).xyz; | ||
79 | gi_norm = normalize(gi_norm); | ||
80 | |||
81 | vec4 c_spec = texture2DRect(specularRect, vary_fragcoord.xy); | ||
82 | gi_pos.xyz += (texture2D(noiseMap, vary_fragcoord.xy/128.0).x)*gi_spec.z*gi_norm.xyz; | ||
83 | vec2 tcx = gi_norm.xy; | ||
84 | vec2 tcy = gi_norm.yx; | ||
85 | |||
86 | vec4 eye_pos = gi_mat*vec4(0,0,0,1.0); | ||
87 | |||
88 | vec3 eye_dir = normalize(gi_pos.xyz-eye_pos.xyz); | ||
89 | vec3 eye_ref = reflect(eye_dir, gi_norm); | ||
90 | |||
91 | //vec3 eye_dir = vec3(0,0,-1); | ||
92 | //eye_dir = (gi_norm_mat*vec4(eye_dir, 1.0)).xyz; | ||
93 | //eye_dir = normalize(eye_dir); | ||
94 | |||
95 | //float round_x = gi_scale.x; | ||
96 | //float round_y = gi_scale.y; | ||
97 | |||
98 | vec3 debug = texture2D(normalGIMap, gi_c.xy).rgb; | ||
99 | //debug.xz = vec2(0.0,0.0); | ||
100 | //debug = fract(debug); | ||
101 | |||
102 | float round_x = 1.0/64.0; | ||
103 | float round_y = 1.0/64.0; | ||
104 | |||
105 | //gi_c.x = floor(gi_c.x/round_x+0.5)*round_x; | ||
106 | //gi_c.y = floor(gi_c.y/round_y+0.5)*round_y; | ||
107 | |||
108 | float da = texture2DRect(lightMap, vary_fragcoord.xy).r; | ||
109 | |||
110 | vec3 fdiff = vec3(da); | ||
111 | |||
112 | if (da > 0.0) | ||
113 | { | ||
114 | vec3 ha = -eye_dir; | ||
115 | ha.z += 1.0; | ||
116 | ha = normalize(ha); | ||
117 | |||
118 | float sa = dot(ha,gi_norm); | ||
119 | da = min(da, texture2D(lightFunc, vec2(sa, c_spec.a)).a); | ||
120 | fdiff += da*(c_spec.rgb*c_spec.a*2.0); | ||
121 | } | ||
122 | |||
123 | float fda = da; | ||
124 | |||
125 | vec3 rcol = vec3(0,0,0); | ||
126 | |||
127 | float fsa = 0.0; | ||
128 | |||
129 | |||
130 | for (int i = -1; i <= 1; i += 1 ) | ||
131 | { | ||
132 | for (int j = -1; j <= 1; j+= 1) | ||
133 | { | ||
134 | vec2 tc = vec2(i, j)*0.75+gi_norm.xy; | ||
135 | vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0+tc*0.5).xyz; | ||
136 | tc += gi_norm.xy*nz.z; | ||
137 | tc += nz.xy*2.0; | ||
138 | tc /= gi_samples; | ||
139 | tc += gi_c.xy; | ||
140 | |||
141 | vec3 lnorm = -normalize(texture2D(normalGIMap, tc.xy).xyz*2.0-1.0); | ||
142 | vec3 lpos = getGIPosition(tc.xy).xyz; | ||
143 | |||
144 | vec3 at = lpos-gi_pos.xyz; | ||
145 | float dist = dot(at,at); | ||
146 | float da = clamp(1.0/(gi_spec.x*dist), 0.0, 1.0); | ||
147 | |||
148 | |||
149 | if (da > 0.01) | ||
150 | { //possible contribution of indirect light to this surface | ||
151 | vec3 ldir = at; | ||
152 | |||
153 | float ld = -dot(ldir, lnorm); | ||
154 | |||
155 | if (ld < 0.0) | ||
156 | { | ||
157 | float ang_atten = dot(ldir, gi_norm); | ||
158 | |||
159 | if (ang_atten > 0.0) | ||
160 | { | ||
161 | vec4 spec = texture2D(specularGIMap, tc.xy); | ||
162 | at = normalize(at); | ||
163 | vec3 diff; | ||
164 | |||
165 | { //contribution from indirect source to visible pixel | ||
166 | vec3 ha = at; | ||
167 | ha.z -= 1.0; | ||
168 | ha = normalize(ha); | ||
169 | float sa = dot(ha,lnorm); | ||
170 | da = min(da, texture2D(lightFunc, vec2(sa, spec.a)).a); | ||
171 | |||
172 | diff = texture2D(diffuseGIMap, tc.xy).rgb+spec.rgb*spec.a*2.0; | ||
173 | } | ||
174 | |||
175 | if (da > 0.0) | ||
176 | { //contribution from visible pixel to eye | ||
177 | vec3 ha = normalize(at-eye_dir); | ||
178 | float sa = dot(ha, gi_norm); | ||
179 | da = min(da, texture2D(lightFunc, vec2(sa, c_spec.a)).a); | ||
180 | fda += da; | ||
181 | fdiff += da*(c_spec.rgb*c_spec.a*2.0+vec3(1,1,1))*diff.rgb; | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | |||
189 | //fdiff /= max(gi_spec.y*fda, gi_quad.z); | ||
190 | //fdiff = clamp(fdiff, vec3(0), vec3(1)); | ||
191 | fdiff *= 64.0; | ||
192 | fdiff *= sunlight_color.rgb; | ||
193 | |||
194 | vec3 ret = fda*fdiff; | ||
195 | //ret = ret*ret*gi_quad.x+ret*gi_quad.y+gi_quad.z; | ||
196 | |||
197 | //fda *= nz.z; | ||
198 | |||
199 | //rcol.rgb *= gi_intensity; | ||
200 | //return rcol.rgb+vary_AmblitColor.rgb*0.25; | ||
201 | //return vec4(debug, 0.0); | ||
202 | //return vec4(fda*fdiff, 0.0); | ||
203 | return clamp(ret,vec3(0.0), vec3(1.0)); | ||
204 | //return debug.xyz; | ||
205 | } | ||
206 | |||
207 | void main() | ||
208 | { | ||
209 | vec2 pos_screen = vary_fragcoord.xy; | ||
210 | vec4 pos = getPosition(pos_screen); | ||
211 | |||
212 | float rad = gi_range*0.5; | ||
213 | |||
214 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0; | ||
215 | float dist = max(length(pos.xyz)-rad, 0.0); | ||
216 | |||
217 | float da = clamp(1.0-dist/rad, 0.0, 1.0); | ||
218 | gl_FragData[0].xyz = da > 0.0 ? giAmbient(pos, norm)*da : vec3(0,0,0); | ||
219 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giV.glsl new file mode 100644 index 0000000..71dcea9 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giV.glsl | |||
@@ -0,0 +1,22 @@ | |||
1 | /** | ||
2 | * @file giV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | |||
10 | uniform vec2 screen_res; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
17 | vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; | ||
18 | vec4 tex = gl_MultiTexCoord0; | ||
19 | tex.w = 1.0; | ||
20 | |||
21 | gl_FrontColor = gl_Color; | ||
22 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl new file mode 100644 index 0000000..0de0d11 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl | |||
@@ -0,0 +1,16 @@ | |||
1 | /** | ||
2 | * @file luminanceF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect diffuseMap; | ||
9 | |||
10 | varying vec2 vary_fragcoord; | ||
11 | uniform float fade; | ||
12 | void main() | ||
13 | { | ||
14 | gl_FragColor.rgb = texture2DRect(diffuseMap, vary_fragcoord.xy).rgb; | ||
15 | gl_FragColor.a = fade; | ||
16 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl new file mode 100644 index 0000000..db8775f --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl | |||
@@ -0,0 +1,20 @@ | |||
1 | /** | ||
2 | * @file giV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | |||
10 | uniform vec2 screen_res; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
17 | vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; | ||
18 | |||
19 | gl_FrontColor = gl_Color; | ||
20 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl new file mode 100644 index 0000000..609fb1d --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl | |||
@@ -0,0 +1,76 @@ | |||
1 | /** | ||
2 | * @file postDeferredF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect diffuseRect; | ||
9 | uniform sampler2DRect specularRect; | ||
10 | uniform sampler2DRect localLightMap; | ||
11 | uniform sampler2DRect sunLightMap; | ||
12 | uniform sampler2DRect giLightMap; | ||
13 | uniform sampler2D luminanceMap; | ||
14 | uniform sampler2DRect lightMap; | ||
15 | uniform sampler2D lightFunc; | ||
16 | |||
17 | |||
18 | uniform vec3 gi_lum_quad; | ||
19 | uniform vec3 sun_lum_quad; | ||
20 | uniform vec3 lum_quad; | ||
21 | uniform float lum_lod; | ||
22 | uniform vec4 ambient; | ||
23 | |||
24 | uniform vec3 gi_quad; | ||
25 | |||
26 | uniform vec2 screen_res; | ||
27 | varying vec2 vary_fragcoord; | ||
28 | |||
29 | void main() | ||
30 | { | ||
31 | vec2 tc = vary_fragcoord.xy; | ||
32 | vec3 lcol = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb; | ||
33 | |||
34 | float lum = sqrt(lcol.r)*lum_quad.x+lcol.r*lcol.r*lum_quad.y+lcol.r*lum_quad.z; | ||
35 | |||
36 | vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy); | ||
37 | vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); | ||
38 | |||
39 | float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g; | ||
40 | |||
41 | vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
42 | vec3 gi_col = ccol; | ||
43 | /*for (int i = -1; i <= 1; i+=1) | ||
44 | { | ||
45 | for (int j = -1; j <= 1; j+=1) | ||
46 | { | ||
47 | vec2 tc = vec2(i,j); | ||
48 | float wght = 1.0/(length(tc)+1.0); | ||
49 | gi_col += texture2DRect(giLightMap, vary_fragcoord.xy+vec2(i,j)).rgb * wght; | ||
50 | } | ||
51 | }*/ | ||
52 | |||
53 | //gi_col *= 1.0+spec.a*4.0; | ||
54 | gi_col = (sqrt(gi_col)*gi_quad.x + gi_col*gi_quad.y)*(diff.rgb+spec.rgb*spec.a)+gi_quad.z*ambocc*ambient.rgb*diff.rgb; | ||
55 | |||
56 | vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy); | ||
57 | |||
58 | vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb; | ||
59 | |||
60 | |||
61 | float sun_lum = 1.0-lum; | ||
62 | sun_lum = sun_lum*sun_lum*sun_lum_quad.x + sun_lum*sun_lum_quad.y+sun_lum_quad.z; | ||
63 | |||
64 | float gi_lum = lum; | ||
65 | gi_lum = gi_lum*gi_lum*gi_lum_quad.x+gi_lum*gi_lum_quad.y+gi_lum_quad.z; | ||
66 | gi_col *= 1.0/gi_lum; | ||
67 | |||
68 | |||
69 | vec3 col = sun_col.rgb*(1.0+max(sun_lum,0.0))+gi_col+local_col; | ||
70 | |||
71 | gl_FragColor.rgb = col.rgb; | ||
72 | gl_FragColor.a = max(sun_lum*min(sun_col.r+sun_col.g+sun_col.b, 1.0), sun_col.a); | ||
73 | |||
74 | //gl_FragColor.rgb = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
75 | //gl_FragColor.rgb = vec3(texture2D(lightFunc, vary_fragcoord.xy/512.0-vec2(0.5, 0.5)).a); | ||
76 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl new file mode 100644 index 0000000..9819232 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | * @file postDeferredV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | uniform vec2 screen_res; | ||
10 | |||
11 | void main() | ||
12 | { | ||
13 | //transform vertex | ||
14 | gl_Position = ftransform(); | ||
15 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
16 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
17 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl new file mode 100644 index 0000000..12a5f39 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl | |||
@@ -0,0 +1,87 @@ | |||
1 | /** | ||
2 | * @file postgiF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect depthMap; | ||
9 | uniform sampler2DRect normalMap; | ||
10 | uniform sampler2DRect giLightMap; | ||
11 | uniform sampler2D noiseMap; | ||
12 | |||
13 | uniform vec2 kern[32]; | ||
14 | uniform float dist_factor; | ||
15 | uniform float blur_size; | ||
16 | uniform vec2 delta; | ||
17 | uniform int kern_length; | ||
18 | uniform float kern_scale; | ||
19 | uniform vec3 blur_quad; | ||
20 | |||
21 | varying vec2 vary_fragcoord; | ||
22 | |||
23 | uniform mat4 inv_proj; | ||
24 | uniform vec2 screen_res; | ||
25 | |||
26 | vec4 getPosition(vec2 pos_screen) | ||
27 | { | ||
28 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
29 | vec2 sc = pos_screen.xy*2.0; | ||
30 | sc /= screen_res; | ||
31 | sc -= vec2(1.0,1.0); | ||
32 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
33 | vec4 pos = inv_proj * ndc; | ||
34 | pos /= pos.w; | ||
35 | pos.w = 1.0; | ||
36 | return pos; | ||
37 | } | ||
38 | |||
39 | float getDepth(vec2 pos_screen) | ||
40 | { | ||
41 | float z = texture2DRect(depthMap, pos_screen.xy).a; | ||
42 | z = z*2.0-1.0; | ||
43 | vec4 ndc = vec4(0.0, 0.0, z, 1.0); | ||
44 | vec4 p = inv_proj*ndc; | ||
45 | return p.z/p.w; | ||
46 | } | ||
47 | |||
48 | void main() | ||
49 | { | ||
50 | vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0; | ||
51 | float depth = getDepth(vary_fragcoord.xy); | ||
52 | |||
53 | vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
54 | vec2 dlt = kern_scale * delta/(vec2(1.0,1.0)+norm.xy*norm.xy); | ||
55 | dlt /= clamp(-depth*blur_quad.x, 1.0, 3.0); | ||
56 | float defined_weight = kern[0].x; | ||
57 | vec3 col = ccol*kern[0].x; | ||
58 | |||
59 | for (int i = 0; i < kern_length; i++) | ||
60 | { | ||
61 | vec2 tc = vary_fragcoord.xy + kern[i].y*dlt; | ||
62 | vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0; | ||
63 | |||
64 | float d = dot(norm.xyz, sampNorm); | ||
65 | |||
66 | if (d > 0.5) | ||
67 | { | ||
68 | float sampdepth = getDepth(tc.xy); | ||
69 | sampdepth -= depth; | ||
70 | if (sampdepth*sampdepth < blur_quad.z) | ||
71 | { | ||
72 | col += texture2DRect(giLightMap, tc).rgb*kern[i].x; | ||
73 | defined_weight += kern[i].x; | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | col /= defined_weight; | ||
79 | |||
80 | //col = ccol; | ||
81 | |||
82 | col = col*blur_quad.y; | ||
83 | |||
84 | gl_FragData[0].xyz = col; | ||
85 | |||
86 | //gl_FragColor = ccol; | ||
87 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl new file mode 100644 index 0000000..6adcda8 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | * @file postgiV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | uniform vec2 screen_res; | ||
10 | |||
11 | void main() | ||
12 | { | ||
13 | //transform vertex | ||
14 | gl_Position = ftransform(); | ||
15 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
16 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
17 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl new file mode 100644 index 0000000..654b182 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | |||
@@ -0,0 +1,312 @@ | |||
1 | /** | ||
2 | * @file softenLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect diffuseRect; | ||
11 | uniform sampler2DRect specularRect; | ||
12 | uniform sampler2DRect normalMap; | ||
13 | uniform sampler2DRect lightMap; | ||
14 | uniform sampler2DRect giLightMap; | ||
15 | uniform sampler2D noiseMap; | ||
16 | uniform samplerCube environmentMap; | ||
17 | uniform sampler2D lightFunc; | ||
18 | uniform sampler2D luminanceMap; | ||
19 | |||
20 | uniform vec3 gi_quad; | ||
21 | uniform vec3 lum_quad; | ||
22 | uniform float lum_lod; | ||
23 | |||
24 | uniform float blur_size; | ||
25 | uniform float blur_fidelity; | ||
26 | |||
27 | // Inputs | ||
28 | uniform vec4 morphFactor; | ||
29 | uniform vec3 camPosLocal; | ||
30 | //uniform vec4 camPosWorld; | ||
31 | uniform vec4 gamma; | ||
32 | uniform vec4 lightnorm; | ||
33 | uniform vec4 sunlight_color; | ||
34 | uniform vec4 ambient; | ||
35 | uniform vec4 blue_horizon; | ||
36 | uniform vec4 blue_density; | ||
37 | uniform vec4 haze_horizon; | ||
38 | uniform vec4 haze_density; | ||
39 | uniform vec4 cloud_shadow; | ||
40 | uniform vec4 density_multiplier; | ||
41 | uniform vec4 distance_multiplier; | ||
42 | uniform vec4 max_y; | ||
43 | uniform vec4 glow; | ||
44 | uniform float scene_light_strength; | ||
45 | uniform vec3 env_mat[3]; | ||
46 | uniform vec4 shadow_clip; | ||
47 | uniform mat3 ssao_effect_mat; | ||
48 | |||
49 | uniform sampler2DRect depthMap; | ||
50 | uniform mat4 inv_proj; | ||
51 | uniform vec2 screen_res; | ||
52 | |||
53 | varying vec4 vary_light; | ||
54 | varying vec2 vary_fragcoord; | ||
55 | |||
56 | vec3 vary_PositionEye; | ||
57 | |||
58 | vec3 vary_SunlitColor; | ||
59 | vec3 vary_AmblitColor; | ||
60 | vec3 vary_AdditiveColor; | ||
61 | vec3 vary_AtmosAttenuation; | ||
62 | |||
63 | vec4 getPosition(vec2 pos_screen) | ||
64 | { //get position in screen space (world units) given window coordinate and depth map | ||
65 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
66 | vec2 sc = pos_screen.xy*2.0; | ||
67 | sc /= screen_res; | ||
68 | sc -= vec2(1.0,1.0); | ||
69 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
70 | vec4 pos = inv_proj * ndc; | ||
71 | pos /= pos.w; | ||
72 | pos.w = 1.0; | ||
73 | return pos; | ||
74 | } | ||
75 | |||
76 | vec3 getPositionEye() | ||
77 | { | ||
78 | return vary_PositionEye; | ||
79 | } | ||
80 | vec3 getSunlitColor() | ||
81 | { | ||
82 | return vary_SunlitColor; | ||
83 | } | ||
84 | vec3 getAmblitColor() | ||
85 | { | ||
86 | return vary_AmblitColor; | ||
87 | } | ||
88 | vec3 getAdditiveColor() | ||
89 | { | ||
90 | return vary_AdditiveColor; | ||
91 | } | ||
92 | vec3 getAtmosAttenuation() | ||
93 | { | ||
94 | return vary_AtmosAttenuation; | ||
95 | } | ||
96 | |||
97 | |||
98 | void setPositionEye(vec3 v) | ||
99 | { | ||
100 | vary_PositionEye = v; | ||
101 | } | ||
102 | |||
103 | void setSunlitColor(vec3 v) | ||
104 | { | ||
105 | vary_SunlitColor = v; | ||
106 | } | ||
107 | |||
108 | void setAmblitColor(vec3 v) | ||
109 | { | ||
110 | vary_AmblitColor = v; | ||
111 | } | ||
112 | |||
113 | void setAdditiveColor(vec3 v) | ||
114 | { | ||
115 | vary_AdditiveColor = v; | ||
116 | } | ||
117 | |||
118 | void setAtmosAttenuation(vec3 v) | ||
119 | { | ||
120 | vary_AtmosAttenuation = v; | ||
121 | } | ||
122 | |||
123 | void calcAtmospherics(vec3 inPositionEye, float ambFactor) { | ||
124 | |||
125 | vec3 P = inPositionEye; | ||
126 | setPositionEye(P); | ||
127 | |||
128 | //(TERRAIN) limit altitude | ||
129 | if (P.y > max_y.x) P *= (max_y.x / P.y); | ||
130 | if (P.y < -max_y.x) P *= (-max_y.x / P.y); | ||
131 | |||
132 | vec3 tmpLightnorm = lightnorm.xyz; | ||
133 | |||
134 | vec3 Pn = normalize(P); | ||
135 | float Plen = length(P); | ||
136 | |||
137 | vec4 temp1 = vec4(0); | ||
138 | vec3 temp2 = vec3(0); | ||
139 | vec4 blue_weight; | ||
140 | vec4 haze_weight; | ||
141 | vec4 sunlight = sunlight_color; | ||
142 | vec4 light_atten; | ||
143 | |||
144 | //sunlight attenuation effect (hue and brightness) due to atmosphere | ||
145 | //this is used later for sunlight modulation at various altitudes | ||
146 | light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x); | ||
147 | //I had thought blue_density and haze_density should have equal weighting, | ||
148 | //but attenuation due to haze_density tends to seem too strong | ||
149 | |||
150 | temp1 = blue_density + vec4(haze_density.r); | ||
151 | blue_weight = blue_density / temp1; | ||
152 | haze_weight = vec4(haze_density.r) / temp1; | ||
153 | |||
154 | //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) | ||
155 | temp2.y = max(0.0, tmpLightnorm.y); | ||
156 | temp2.y = 1. / temp2.y; | ||
157 | sunlight *= exp( - light_atten * temp2.y); | ||
158 | |||
159 | // main atmospheric scattering line integral | ||
160 | temp2.z = Plen * density_multiplier.x; | ||
161 | |||
162 | // Transparency (-> temp1) | ||
163 | // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati | ||
164 | // compiler gets confused. | ||
165 | temp1 = exp(-temp1 * temp2.z * distance_multiplier.x); | ||
166 | |||
167 | //final atmosphere attenuation factor | ||
168 | setAtmosAttenuation(temp1.rgb); | ||
169 | |||
170 | //compute haze glow | ||
171 | //(can use temp2.x as temp because we haven't used it yet) | ||
172 | temp2.x = dot(Pn, tmpLightnorm.xyz); | ||
173 | temp2.x = 1. - temp2.x; | ||
174 | //temp2.x is 0 at the sun and increases away from sun | ||
175 | temp2.x = max(temp2.x, .03); //was glow.y | ||
176 | //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) | ||
177 | temp2.x *= glow.x; | ||
178 | //higher glow.x gives dimmer glow (because next step is 1 / "angle") | ||
179 | temp2.x = pow(temp2.x, glow.z); | ||
180 | //glow.z should be negative, so we're doing a sort of (1 / "angle") function | ||
181 | |||
182 | //add "minimum anti-solar illumination" | ||
183 | temp2.x += .25; | ||
184 | |||
185 | //increase ambient when there are more clouds | ||
186 | vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5; | ||
187 | |||
188 | /* decrease value and saturation (that in HSV, not HSL) for occluded areas | ||
189 | * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html | ||
190 | * // The following line of code performs the equivalent of: | ||
191 | * float ambAlpha = tmpAmbient.a; | ||
192 | * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis | ||
193 | * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); | ||
194 | * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); | ||
195 | */ | ||
196 | tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); | ||
197 | |||
198 | //haze color | ||
199 | setAdditiveColor( | ||
200 | vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient) | ||
201 | + (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x | ||
202 | + tmpAmbient))); | ||
203 | |||
204 | //brightness of surface both sunlight and ambient | ||
205 | setSunlitColor(vec3(sunlight * .5)); | ||
206 | setAmblitColor(vec3(tmpAmbient * .25)); | ||
207 | setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); | ||
208 | } | ||
209 | |||
210 | vec3 atmosLighting(vec3 light) | ||
211 | { | ||
212 | light *= getAtmosAttenuation().r; | ||
213 | light += getAdditiveColor(); | ||
214 | return (2.0 * light); | ||
215 | } | ||
216 | |||
217 | vec3 atmosTransport(vec3 light) { | ||
218 | light *= getAtmosAttenuation().r; | ||
219 | light += getAdditiveColor() * 2.0; | ||
220 | return light; | ||
221 | } | ||
222 | vec3 atmosGetDiffuseSunlightColor() | ||
223 | { | ||
224 | return getSunlitColor(); | ||
225 | } | ||
226 | |||
227 | vec3 scaleDownLight(vec3 light) | ||
228 | { | ||
229 | return (light / scene_light_strength ); | ||
230 | } | ||
231 | |||
232 | vec3 scaleUpLight(vec3 light) | ||
233 | { | ||
234 | return (light * scene_light_strength); | ||
235 | } | ||
236 | |||
237 | vec3 atmosAmbient(vec3 light) | ||
238 | { | ||
239 | return getAmblitColor() + light / 2.0; | ||
240 | } | ||
241 | |||
242 | vec3 atmosAffectDirectionalLight(float lightIntensity) | ||
243 | { | ||
244 | return getSunlitColor() * lightIntensity; | ||
245 | } | ||
246 | |||
247 | vec3 scaleSoftClip(vec3 light) | ||
248 | { | ||
249 | //soft clip effect: | ||
250 | light = 1. - clamp(light, vec3(0.), vec3(1.)); | ||
251 | light = 1. - pow(light, gamma.xxx); | ||
252 | |||
253 | return light; | ||
254 | } | ||
255 | |||
256 | void main() | ||
257 | { | ||
258 | vec2 tc = vary_fragcoord.xy; | ||
259 | vec3 pos = getPosition(tc).xyz; | ||
260 | vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0; | ||
261 | vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz; | ||
262 | |||
263 | vec3 at = normalize(pos); | ||
264 | |||
265 | vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); | ||
266 | |||
267 | vec3 lum = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb; | ||
268 | |||
269 | vec3 ha = normalize(vary_light.xyz-at); | ||
270 | |||
271 | float da = dot(ha, norm.xyz); | ||
272 | da = texture2D(lightFunc, vec2(da, spec.a)).a; | ||
273 | |||
274 | vec4 diffuse = texture2DRect(diffuseRect, tc); | ||
275 | |||
276 | vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; | ||
277 | float scol = max(scol_ambocc.r, diffuse.a); | ||
278 | float ambocc = scol_ambocc.g; | ||
279 | |||
280 | calcAtmospherics(pos.xyz, ambocc); | ||
281 | |||
282 | vec3 col = vec3(0,0,0); | ||
283 | |||
284 | col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)*(1.0+spec.a)); | ||
285 | |||
286 | col *= diffuse.rgb; | ||
287 | |||
288 | col += da*spec.rgb*spec.a*vary_SunlitColor*scol_ambocc.r; | ||
289 | |||
290 | /*if (spec.a > 0.0) | ||
291 | { | ||
292 | vec3 ref = normalize(reflect(pos.xyz, norm.xyz)); | ||
293 | float sa = dot(ref, vary_light.xyz); | ||
294 | col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a; | ||
295 | }*/ | ||
296 | |||
297 | col = atmosLighting(col); | ||
298 | col = scaleSoftClip(col); | ||
299 | |||
300 | col = col*vec3(1.0+1.0/2.2); | ||
301 | |||
302 | gl_FragColor.rgb = col; | ||
303 | //gl_FragColor.rgb = lum; | ||
304 | |||
305 | gl_FragColor.a = 0.0; | ||
306 | |||
307 | //gl_FragColor.rg = scol_ambocc.rg; | ||
308 | //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb; | ||
309 | //gl_FragColor.rgb = norm.rgb*0.5+0.5; | ||
310 | //gl_FragColor.rgb = vec3(ambocc); | ||
311 | //gl_FragColor.rgb = vec3(scol); | ||
312 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl new file mode 100644 index 0000000..ad8af47 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl | |||
@@ -0,0 +1,24 @@ | |||
1 | /** | ||
2 | * @file softenLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform vec2 screen_res; | ||
9 | |||
10 | varying vec4 vary_light; | ||
11 | varying vec2 vary_fragcoord; | ||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | |||
17 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
18 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
19 | |||
20 | vec4 tex = gl_MultiTexCoord0; | ||
21 | tex.w = 1.0; | ||
22 | |||
23 | vary_light = gl_MultiTexCoord0; | ||
24 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl new file mode 100644 index 0000000..258acee --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl | |||
@@ -0,0 +1,18 @@ | |||
1 | /** | ||
2 | * @file treeF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2D diffuseMap; | ||
9 | |||
10 | varying vec3 vary_normal; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); | ||
15 | gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, col.a <= 0.5 ? 0.0 : 0.005); | ||
16 | gl_FragData[1] = vec4(0,0,0,0); | ||
17 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); | ||
18 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl new file mode 100644 index 0000000..bea1515 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl | |||
@@ -0,0 +1,139 @@ | |||
1 | /** | ||
2 | * @file waterF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | vec3 scaleSoftClip(vec3 inColor); | ||
9 | vec3 atmosTransport(vec3 inColor); | ||
10 | |||
11 | uniform sampler2D bumpMap; | ||
12 | uniform sampler2D screenTex; | ||
13 | uniform sampler2D refTex; | ||
14 | uniform sampler2DRectShadow shadowMap0; | ||
15 | uniform sampler2DRectShadow shadowMap1; | ||
16 | uniform sampler2DRectShadow shadowMap2; | ||
17 | uniform sampler2DRectShadow shadowMap3; | ||
18 | uniform sampler2D noiseMap; | ||
19 | |||
20 | uniform mat4 shadow_matrix[6]; | ||
21 | uniform vec4 shadow_clip; | ||
22 | |||
23 | uniform float sunAngle; | ||
24 | uniform float sunAngle2; | ||
25 | uniform vec3 lightDir; | ||
26 | uniform vec3 specular; | ||
27 | uniform float lightExp; | ||
28 | uniform float refScale; | ||
29 | uniform float kd; | ||
30 | uniform vec2 screenRes; | ||
31 | uniform vec3 normScale; | ||
32 | uniform float fresnelScale; | ||
33 | uniform float fresnelOffset; | ||
34 | uniform float blurMultiplier; | ||
35 | uniform vec2 screen_res; | ||
36 | uniform mat4 norm_mat; //region space to screen space | ||
37 | |||
38 | //bigWave is (refCoord.w, view.w); | ||
39 | varying vec4 refCoord; | ||
40 | varying vec4 littleWave; | ||
41 | varying vec4 view; | ||
42 | varying vec4 vary_position; | ||
43 | |||
44 | void main() | ||
45 | { | ||
46 | vec4 color; | ||
47 | float dist = length(view.xy); | ||
48 | |||
49 | //normalize view vector | ||
50 | vec3 viewVec = normalize(view.xyz); | ||
51 | |||
52 | //get wave normals | ||
53 | vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; | ||
54 | vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; | ||
55 | vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; | ||
56 | //get base fresnel components | ||
57 | |||
58 | vec3 df = vec3( | ||
59 | dot(viewVec, wave1), | ||
60 | dot(viewVec, (wave2 + wave3) * 0.5), | ||
61 | dot(viewVec, wave3) | ||
62 | ) * fresnelScale + fresnelOffset; | ||
63 | df *= df; | ||
64 | |||
65 | vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; | ||
66 | |||
67 | float dist2 = dist; | ||
68 | dist = max(dist, 5.0); | ||
69 | |||
70 | float dmod = sqrt(dist); | ||
71 | |||
72 | vec2 dmod_scale = vec2(dmod*dmod, dmod); | ||
73 | |||
74 | //get reflected color | ||
75 | vec2 refdistort1 = wave1.xy*normScale.x; | ||
76 | vec2 refvec1 = distort+refdistort1/dmod_scale; | ||
77 | vec4 refcol1 = texture2D(refTex, refvec1); | ||
78 | |||
79 | vec2 refdistort2 = wave2.xy*normScale.y; | ||
80 | vec2 refvec2 = distort+refdistort2/dmod_scale; | ||
81 | vec4 refcol2 = texture2D(refTex, refvec2); | ||
82 | |||
83 | vec2 refdistort3 = wave3.xy*normScale.z; | ||
84 | vec2 refvec3 = distort+refdistort3/dmod_scale; | ||
85 | vec4 refcol3 = texture2D(refTex, refvec3); | ||
86 | |||
87 | vec4 refcol = refcol1 + refcol2 + refcol3; | ||
88 | float df1 = df.x + df.y + df.z; | ||
89 | refcol *= df1 * 0.333; | ||
90 | |||
91 | vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; | ||
92 | //wavef.z *= max(-viewVec.z, 0.1); | ||
93 | wavef = normalize(wavef); | ||
94 | |||
95 | float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; | ||
96 | |||
97 | vec2 refdistort4 = wavef.xy*0.125; | ||
98 | refdistort4.y -= abs(refdistort4.y); | ||
99 | vec2 refvec4 = distort+refdistort4/dmod; | ||
100 | float dweight = min(dist2*blurMultiplier, 1.0); | ||
101 | vec4 baseCol = texture2D(refTex, refvec4); | ||
102 | refcol = mix(baseCol*df2, refcol, dweight); | ||
103 | |||
104 | //get specular component | ||
105 | //float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); | ||
106 | |||
107 | //harden specular | ||
108 | //spec = pow(spec, 128.0); | ||
109 | |||
110 | //figure out distortion vector (ripply) | ||
111 | vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); | ||
112 | |||
113 | vec4 fb = texture2D(screenTex, distort2); | ||
114 | |||
115 | //mix with reflection | ||
116 | // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug | ||
117 | color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); | ||
118 | |||
119 | float shadow = 1.0; | ||
120 | vec4 pos = vary_position; | ||
121 | |||
122 | vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz; | ||
123 | vec4 spos = pos; | ||
124 | |||
125 | //spec *= shadow; | ||
126 | //color.rgb += spec * specular; | ||
127 | |||
128 | //color.rgb = atmosTransport(color.rgb); | ||
129 | //color.rgb = scaleSoftClip(color.rgb); | ||
130 | //color.a = spec * sunAngle2; | ||
131 | |||
132 | //wavef.z *= 0.1f; | ||
133 | wavef = normalize(wavef); | ||
134 | wavef = (norm_mat*vec4(wavef, 1.0)).xyz; | ||
135 | |||
136 | gl_FragData[0] = vec4(color.rgb, 0.5); | ||
137 | gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); | ||
138 | gl_FragData[2] = vec4(wavef*0.5+0.5, 0.f); | ||
139 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/blurF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/blurF.glsl new file mode 100644 index 0000000..9443320 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/effects/blurF.glsl | |||
@@ -0,0 +1,31 @@ | |||
1 | /** | ||
2 | * @file blurf.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect RenderTexture; | ||
9 | uniform float bloomStrength; | ||
10 | |||
11 | varying vec4 gl_TexCoord[gl_MaxTextureCoords]; | ||
12 | void main(void) | ||
13 | { | ||
14 | float blurWeights[7]; | ||
15 | blurWeights[0] = 0.05; | ||
16 | blurWeights[1] = 0.1; | ||
17 | blurWeights[2] = 0.2; | ||
18 | blurWeights[3] = 0.3; | ||
19 | blurWeights[4] = 0.2; | ||
20 | blurWeights[5] = 0.1; | ||
21 | blurWeights[6] = 0.05; | ||
22 | |||
23 | vec3 color = vec3(0,0,0); | ||
24 | for (int i = 0; i < 7; i++){ | ||
25 | color += vec3(texture2DRect(RenderTexture, gl_TexCoord[i].st)) * blurWeights[i]; | ||
26 | } | ||
27 | |||
28 | color *= bloomStrength; | ||
29 | |||
30 | gl_FragColor = vec4(color, 1.0); | ||
31 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/blurV.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/blurV.glsl new file mode 100644 index 0000000..ba65b16 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/effects/blurV.glsl | |||
@@ -0,0 +1,35 @@ | |||
1 | /** | ||
2 | * @file blurV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform vec2 texelSize; | ||
9 | uniform vec2 blurDirection; | ||
10 | uniform float blurWidth; | ||
11 | |||
12 | void main(void) | ||
13 | { | ||
14 | // Transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | |||
17 | vec2 blurDelta = texelSize * blurDirection * vec2(blurWidth, blurWidth); | ||
18 | vec2 s = gl_MultiTexCoord0.st - (blurDelta * 3.0); | ||
19 | |||
20 | // for (int i = 0; i < 7; i++) { | ||
21 | // gl_TexCoord[i].st = s + (i * blurDelta); | ||
22 | // } | ||
23 | |||
24 | // MANUALLY UNROLL | ||
25 | gl_TexCoord[0].st = s; | ||
26 | gl_TexCoord[1].st = s + blurDelta; | ||
27 | gl_TexCoord[2].st = s + (2. * blurDelta); | ||
28 | gl_TexCoord[3].st = s + (3. * blurDelta); | ||
29 | gl_TexCoord[4].st = s + (4. * blurDelta); | ||
30 | gl_TexCoord[5].st = s + (5. * blurDelta); | ||
31 | gl_TexCoord[6].st = s + (6. * blurDelta); | ||
32 | |||
33 | // gl_TexCoord[0].st = s; | ||
34 | // gl_TexCoord[1].st = blurDelta; | ||
35 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/colorFilterF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/colorFilterF.glsl new file mode 100644 index 0000000..623ef7a --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/effects/colorFilterF.glsl | |||
@@ -0,0 +1,31 @@ | |||
1 | /** | ||
2 | * @file colorFilterF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect RenderTexture; | ||
9 | uniform float brightness; | ||
10 | uniform float contrast; | ||
11 | uniform vec3 contrastBase; | ||
12 | uniform float saturation; | ||
13 | uniform vec3 lumWeights; | ||
14 | |||
15 | const float gamma = 2.0; | ||
16 | |||
17 | void main(void) | ||
18 | { | ||
19 | vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); | ||
20 | |||
21 | /// Modulate brightness | ||
22 | color *= brightness; | ||
23 | |||
24 | /// Modulate contrast | ||
25 | color = mix(contrastBase, color, contrast); | ||
26 | |||
27 | /// Modulate saturation | ||
28 | color = mix(vec3(dot(color, lumWeights)), color, saturation); | ||
29 | |||
30 | gl_FragColor = vec4(color, 1.0); | ||
31 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/drawQuadV.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/drawQuadV.glsl new file mode 100644 index 0000000..29c2a09 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/effects/drawQuadV.glsl | |||
@@ -0,0 +1,14 @@ | |||
1 | /** | ||
2 | * @file drawQuadV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | void main(void) | ||
9 | { | ||
10 | //transform vertex | ||
11 | gl_Position = ftransform(); | ||
12 | gl_TexCoord[0] = gl_MultiTexCoord0; | ||
13 | gl_TexCoord[1] = gl_MultiTexCoord1; | ||
14 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/extractF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/extractF.glsl new file mode 100644 index 0000000..a1583b1 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/effects/extractF.glsl | |||
@@ -0,0 +1,22 @@ | |||
1 | /** | ||
2 | * @file extractF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect RenderTexture; | ||
9 | uniform float extractLow; | ||
10 | uniform float extractHigh; | ||
11 | uniform vec3 lumWeights; | ||
12 | |||
13 | void main(void) | ||
14 | { | ||
15 | /// Get scene color | ||
16 | vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); | ||
17 | |||
18 | /// Extract luminance and scale up by night vision brightness | ||
19 | float lum = smoothstep(extractLow, extractHigh, dot(color, lumWeights)); | ||
20 | |||
21 | gl_FragColor = vec4(vec3(lum), 1.0); | ||
22 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/nightVisionF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/nightVisionF.glsl new file mode 100644 index 0000000..271d5cf --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/effects/nightVisionF.glsl | |||
@@ -0,0 +1,42 @@ | |||
1 | /** | ||
2 | * @file nightVisionF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect RenderTexture; | ||
9 | uniform sampler2D NoiseTexture; | ||
10 | uniform float brightMult; | ||
11 | uniform float noiseStrength; | ||
12 | |||
13 | float luminance(vec3 color) | ||
14 | { | ||
15 | /// CALCULATING LUMINANCE (Using NTSC lum weights) | ||
16 | /// http://en.wikipedia.org/wiki/Luma_%28video%29 | ||
17 | return dot(color, vec3(0.299, 0.587, 0.114)); | ||
18 | } | ||
19 | |||
20 | void main(void) | ||
21 | { | ||
22 | /// Get scene color | ||
23 | vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); | ||
24 | |||
25 | /// Extract luminance and scale up by night vision brightness | ||
26 | float lum = luminance(color) * brightMult; | ||
27 | |||
28 | /// Convert into night vision color space | ||
29 | /// Newer NVG colors (crisper and more saturated) | ||
30 | vec3 outColor = (lum * vec3(0.91, 1.21, 0.9)) + vec3(-0.07, 0.1, -0.12); | ||
31 | |||
32 | /// Add noise | ||
33 | float noiseValue = texture2D(NoiseTexture, gl_TexCoord[1].st).r; | ||
34 | noiseValue = (noiseValue - 0.5) * noiseStrength; | ||
35 | |||
36 | /// Older NVG colors (more muted) | ||
37 | // vec3 outColor = (lum * vec3(0.82, 0.75, 0.83)) + vec3(0.05, 0.32, -0.11); | ||
38 | |||
39 | outColor += noiseValue; | ||
40 | |||
41 | gl_FragColor = vec4(outColor, 1.0); | ||
42 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/simpleF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/simpleF.glsl new file mode 100644 index 0000000..e55d278 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class3/effects/simpleF.glsl | |||
@@ -0,0 +1,14 @@ | |||
1 | /** | ||
2 | * @file simpleF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect RenderTexture; | ||
9 | |||
10 | void main(void) | ||
11 | { | ||
12 | vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); | ||
13 | gl_FragColor = vec4(1.0 - color, 1.0); | ||
14 | } | ||
diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp index 5bcffdb..4342e60 100644 --- a/linden/indra/newview/llagent.cpp +++ b/linden/indra/newview/llagent.cpp | |||
@@ -223,6 +223,7 @@ LLAgent gAgent; | |||
223 | // Statics | 223 | // Statics |
224 | // | 224 | // |
225 | BOOL LLAgent::sPhantom = FALSE; | 225 | BOOL LLAgent::sPhantom = FALSE; |
226 | BOOL LLAgent::sDebugDisplayTarget = FALSE; | ||
226 | 227 | ||
227 | const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f; | 228 | const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f; |
228 | 229 | ||
@@ -6618,7 +6619,7 @@ void LLAgent::saveWearable( EWearableType type, BOOL send_update ) | |||
6618 | return; | 6619 | return; |
6619 | } | 6620 | } |
6620 | 6621 | ||
6621 | getAvatarObject()->wearableUpdated( type ); | 6622 | // getAvatarObject()->wearableUpdated( type ); |
6622 | 6623 | ||
6623 | if( send_update ) | 6624 | if( send_update ) |
6624 | { | 6625 | { |
diff --git a/linden/indra/newview/llagent.h b/linden/indra/newview/llagent.h index 3a39448..d3c16c5 100644 --- a/linden/indra/newview/llagent.h +++ b/linden/indra/newview/llagent.h | |||
@@ -765,6 +765,7 @@ public: | |||
765 | 765 | ||
766 | BOOL mInitialized; | 766 | BOOL mInitialized; |
767 | 767 | ||
768 | static BOOL sDebugDisplayTarget; | ||
768 | S32 mNumPendingQueries; | 769 | S32 mNumPendingQueries; |
769 | S32* mActiveCacheQueries; | 770 | S32* mActiveCacheQueries; |
770 | 771 | ||
diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index 86c83b9..a9a6052 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp | |||
@@ -447,7 +447,7 @@ static void settings_modify() | |||
447 | LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] | 447 | LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] |
448 | gDebugGL = gSavedSettings.getBOOL("RenderDebugGL"); | 448 | gDebugGL = gSavedSettings.getBOOL("RenderDebugGL"); |
449 | gDebugPipeline = gSavedSettings.getBOOL("RenderDebugPipeline"); | 449 | gDebugPipeline = gSavedSettings.getBOOL("RenderDebugPipeline"); |
450 | gAuditTexture = gSavedSettings.getBOOL("AuditTexture"); | 450 | // gAuditTexture = gSavedSettings.getBOOL("AuditTexture"); |
451 | #if LL_VECTORIZE | 451 | #if LL_VECTORIZE |
452 | if (gSysCPU.hasAltivec()) | 452 | if (gSysCPU.hasAltivec()) |
453 | { | 453 | { |
diff --git a/linden/indra/newview/llcolorswatch.cpp b/linden/indra/newview/llcolorswatch.cpp index 5905bb0..3222c0d 100644 --- a/linden/indra/newview/llcolorswatch.cpp +++ b/linden/indra/newview/llcolorswatch.cpp | |||
@@ -219,11 +219,12 @@ void LLColorSwatchCtrl::draw() | |||
219 | gl_rect_2d(interior, mColor, TRUE); | 219 | gl_rect_2d(interior, mColor, TRUE); |
220 | LLColor4 opaque_color = mColor; | 220 | LLColor4 opaque_color = mColor; |
221 | opaque_color.mV[VALPHA] = 1.f; | 221 | opaque_color.mV[VALPHA] = 1.f; |
222 | gGL.color4fv(opaque_color.mV); | ||
222 | if (mAlphaGradientImage.notNull()) | 223 | if (mAlphaGradientImage.notNull()) |
223 | { | 224 | { |
224 | gGL.pushMatrix(); | 225 | gGL.pushMatrix(); |
225 | { | 226 | { |
226 | mAlphaGradientImage->draw(interior, opaque_color); | 227 | mAlphaGradientImage->draw(interior, mColor); |
227 | } | 228 | } |
228 | gGL.popMatrix(); | 229 | gGL.popMatrix(); |
229 | } | 230 | } |
diff --git a/linden/indra/newview/llcompilequeue.cpp b/linden/indra/newview/llcompilequeue.cpp index ed18a10..a81972d 100644 --- a/linden/indra/newview/llcompilequeue.cpp +++ b/linden/indra/newview/llcompilequeue.cpp | |||
@@ -58,7 +58,6 @@ | |||
58 | #include "llfloaterchat.h" | 58 | #include "llfloaterchat.h" |
59 | #include "llviewerstats.h" | 59 | #include "llviewerstats.h" |
60 | #include "lluictrlfactory.h" | 60 | #include "lluictrlfactory.h" |
61 | #include "llselectmgr.h" | ||
62 | 61 | ||
63 | ///---------------------------------------------------------------------------- | 62 | ///---------------------------------------------------------------------------- |
64 | /// Local function declarations, constants, enums, and typedefs | 63 | /// Local function declarations, constants, enums, and typedefs |
diff --git a/linden/indra/newview/llconsole.cpp b/linden/indra/newview/llconsole.cpp index 2379da3..a8554a0 100644 --- a/linden/indra/newview/llconsole.cpp +++ b/linden/indra/newview/llconsole.cpp | |||
@@ -63,17 +63,25 @@ const S32 CONSOLE_GUTTER_LEFT = 14; | |||
63 | const S32 CONSOLE_GUTTER_RIGHT = 15; | 63 | const S32 CONSOLE_GUTTER_RIGHT = 15; |
64 | 64 | ||
65 | 65 | ||
66 | LLConsole::LLConsole(const std::string& name, const U32 max_lines, const LLRect &rect, | 66 | LLConsole::LLConsole(const std::string& name, const LLRect &rect, |
67 | S32 font_size_index, F32 persist_time ) | 67 | S32 font_size_index, F32 persist_time ) |
68 | : | 68 | : LLFixedBuffer(), |
69 | LLFixedBuffer(max_lines), | 69 | LLView(name, rect, FALSE), |
70 | LLView(name, rect, FALSE) | 70 | mLinePersistTime(persist_time), |
71 | mFadeTime(persist_time - FADE_DURATION), | ||
72 | mFont(LLFontGL::getFontSansSerif()), | ||
73 | mConsoleWidth(0), | ||
74 | mConsoleHeight(0), | ||
75 | mQueueMutex(NULL) | ||
71 | { | 76 | { |
72 | mLinePersistTime = persist_time; // seconds | 77 | mTimer.reset(); |
73 | mFadeTime = persist_time - FADE_DURATION; | ||
74 | 78 | ||
75 | setFontSize( font_size_index ); | 79 | setFontSize( font_size_index ); |
76 | setMaxLines(gSavedSettings.getS32("ConsoleMaxLines")); | 80 | } |
81 | |||
82 | LLConsole::~LLConsole() | ||
83 | { | ||
84 | clear(); | ||
77 | } | 85 | } |
78 | 86 | ||
79 | void LLConsole::setLinePersistTime(F32 seconds) | 87 | void LLConsole::setLinePersistTime(F32 seconds) |
@@ -98,10 +106,10 @@ void LLConsole::reshape(S32 width, S32 height, BOOL called_from_parent) | |||
98 | mConsoleHeight= new_height; | 106 | mConsoleHeight= new_height; |
99 | 107 | ||
100 | LLView::reshape(new_width, new_height, called_from_parent); | 108 | LLView::reshape(new_width, new_height, called_from_parent); |
101 | 109 | ||
102 | for(paragraph_t::iterator paragraph_it = mParagraphs.begin(); paragraph_it != mParagraphs.end(); paragraph_it++) | 110 | for(paragraph_t::iterator paragraph_it = mParagraphs.begin(); paragraph_it != mParagraphs.end(); paragraph_it++) |
103 | { | 111 | { |
104 | (*paragraph_it).updateLines((F32)getRect().getWidth(), mFont, true); | 112 | (*paragraph_it)->updateLines((F32)getRect().getWidth(), mFont, true); |
105 | } | 113 | } |
106 | } | 114 | } |
107 | 115 | ||
@@ -126,7 +134,7 @@ void LLConsole::setFontSize(S32 size_index) | |||
126 | 134 | ||
127 | for(paragraph_t::iterator paragraph_it = mParagraphs.begin(); paragraph_it != mParagraphs.end(); paragraph_it++) | 135 | for(paragraph_t::iterator paragraph_it = mParagraphs.begin(); paragraph_it != mParagraphs.end(); paragraph_it++) |
128 | { | 136 | { |
129 | (*paragraph_it).updateLines((F32)getRect().getWidth(), mFont, true); | 137 | (*paragraph_it)->updateLines((F32)getRect().getWidth(), mFont, true); |
130 | } | 138 | } |
131 | } | 139 | } |
132 | 140 | ||
@@ -134,35 +142,49 @@ void LLConsole::draw() | |||
134 | { | 142 | { |
135 | LLGLSUIDefault gls_ui; | 143 | LLGLSUIDefault gls_ui; |
136 | 144 | ||
137 | // skip lines added more than mLinePersistTime ago | 145 | { |
138 | F32 cur_time = mTimer.getElapsedTimeF32(); | 146 | LLMutexLock lock(&mQueueMutex); |
139 | 147 | for(paragraph_t::iterator paragraph_it = mNewParagraphs.begin(); paragraph_it != mNewParagraphs.end(); paragraph_it++) | |
140 | F32 skip_time = cur_time - mLinePersistTime; | 148 | { |
141 | F32 fade_time = cur_time - mFadeTime; | 149 | Paragraph* paragraph = *paragraph_it; |
142 | 150 | mParagraphs.push_back(paragraph); | |
143 | updateBuffer() ; | 151 | paragraph->updateLines((F32)getRect().getWidth(), mFont); |
152 | } | ||
153 | mNewParagraphs.clear(); | ||
154 | } | ||
144 | 155 | ||
145 | if (mParagraphs.empty()) //No text to draw. | 156 | if (mParagraphs.empty()) //No text to draw. |
146 | { | 157 | { |
147 | return; | 158 | return; |
148 | } | 159 | } |
149 | 160 | ||
161 | // skip lines added more than mLinePersistTime ago | ||
162 | F32 cur_time = mTimer.getElapsedTimeF32(); | ||
163 | |||
164 | F32 skip_time = cur_time - mLinePersistTime; | ||
165 | F32 fade_time = cur_time - mFadeTime; | ||
166 | |||
167 | U32 max_lines = gSavedSettings.getS32("ConsoleMaxLines"); | ||
150 | U32 num_lines=0; | 168 | U32 num_lines=0; |
151 | 169 | ||
152 | paragraph_t::reverse_iterator paragraph_it; | 170 | paragraph_t::reverse_iterator paragraph_it; |
153 | paragraph_it = mParagraphs.rbegin(); | 171 | paragraph_it = mParagraphs.rbegin(); |
154 | U32 paragraph_num=mParagraphs.size(); | 172 | U32 paragraph_num=mParagraphs.size(); |
155 | 173 | ||
156 | while (!mParagraphs.empty() && paragraph_it != mParagraphs.rend()) | 174 | while (!mParagraphs.empty() && paragraph_it != mParagraphs.rend()) |
157 | { | 175 | { |
158 | num_lines += (*paragraph_it).mLines.size(); | 176 | num_lines += (*paragraph_it)->mLines.size(); |
159 | if(num_lines > mMaxLines | 177 | if(num_lines > max_lines |
160 | || ( (mLinePersistTime > (F32)0.f) && ((*paragraph_it).mAddTime - skip_time)/(mLinePersistTime - mFadeTime) <= (F32)0.f)) | 178 | || ( (mLinePersistTime > (F32)0.f) && ((*paragraph_it)->mAddTime - skip_time)/(mLinePersistTime - mFadeTime) <= (F32)0.f)) |
161 | { //All lines above here are done. Lose them. | 179 | { //All lines above here are done. Lose them. |
162 | for (U32 i=0;i<paragraph_num;i++) | 180 | for (U32 i=0;i<paragraph_num;i++) |
163 | { | 181 | { |
164 | if (!mParagraphs.empty()) | 182 | if (!mParagraphs.empty()) |
183 | { | ||
184 | Paragraph* paragraph = mParagraphs.front(); | ||
165 | mParagraphs.pop_front(); | 185 | mParagraphs.pop_front(); |
186 | delete paragraph; | ||
187 | } | ||
166 | } | 188 | } |
167 | break; | 189 | break; |
168 | } | 190 | } |
@@ -193,8 +215,8 @@ void LLConsole::draw() | |||
193 | S32 bkg_width=0; | 215 | S32 bkg_width=0; |
194 | for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++) | 216 | for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++) |
195 | { | 217 | { |
196 | S32 target_height = llfloor( (*paragraph_it).mLines.size() * line_height + message_spacing); | 218 | S32 target_height = llfloor( (*paragraph_it)->mLines.size() * line_height + message_spacing); |
197 | S32 target_width = llfloor( (*paragraph_it).mMaxWidth + CONSOLE_GUTTER_RIGHT); | 219 | S32 target_width = llfloor( (*paragraph_it)->mMaxWidth + CONSOLE_GUTTER_RIGHT); |
198 | 220 | ||
199 | bkg_height+= target_height; | 221 | bkg_height+= target_height; |
200 | if (target_width > bkg_width) | 222 | if (target_width > bkg_width) |
@@ -203,7 +225,7 @@ void LLConsole::draw() | |||
203 | } | 225 | } |
204 | 226 | ||
205 | // Why is this not using llfloor as above? | 227 | // Why is this not using llfloor as above? |
206 | y_pos += ((*paragraph_it).mLines.size()) * line_height; | 228 | y_pos += ((*paragraph_it)->mLines.size()) * line_height; |
207 | y_pos += message_spacing; //Extra spacing between messages. | 229 | y_pos += message_spacing; //Extra spacing between messages. |
208 | } | 230 | } |
209 | imagep->drawSolid(-CONSOLE_GUTTER_LEFT, (S32)(y_pos + line_height - bkg_height - message_spacing), bkg_width, bkg_height, color); | 231 | imagep->drawSolid(-CONSOLE_GUTTER_LEFT, (S32)(y_pos + line_height - bkg_height - message_spacing), bkg_width, bkg_height, color); |
@@ -213,10 +235,10 @@ void LLConsole::draw() | |||
213 | for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++) | 235 | for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++) |
214 | { | 236 | { |
215 | //080813 Spatters: Dainty per-message block boxes | 237 | //080813 Spatters: Dainty per-message block boxes |
216 | // S32 target_height = llfloor( (*paragraph_it).mLines.size() * line_height + 8); | 238 | // S32 target_height = llfloor( (*paragraph_it)->mLines.size() * line_height + 8); |
217 | S32 target_width = llfloor( (*paragraph_it).mMaxWidth + CONSOLE_GUTTER_RIGHT); | 239 | S32 target_width = llfloor( (*paragraph_it)->mMaxWidth + CONSOLE_GUTTER_RIGHT); |
218 | 240 | ||
219 | y_pos += ((*paragraph_it).mLines.size()) * line_height; | 241 | y_pos += ((*paragraph_it)->mLines.size()) * line_height; |
220 | //080813 Spatters: Dainty per-message block boxes | 242 | //080813 Spatters: Dainty per-message block boxes |
221 | // imagep->drawSolid(-14, (S32)(y_pos + line_height - target_height), target_width, target_height, color); | 243 | // imagep->drawSolid(-14, (S32)(y_pos + line_height - target_height), target_width, target_height, color); |
222 | 244 | ||
@@ -224,9 +246,9 @@ void LLConsole::draw() | |||
224 | 246 | ||
225 | F32 alpha; | 247 | F32 alpha; |
226 | 248 | ||
227 | if ((mLinePersistTime > 0.f) && ((*paragraph_it).mAddTime < fade_time)) | 249 | if ((mLinePersistTime > 0.f) && ((*paragraph_it)->mAddTime < fade_time)) |
228 | { | 250 | { |
229 | alpha = ((*paragraph_it).mAddTime - skip_time)/(mLinePersistTime - mFadeTime); | 251 | alpha = ((*paragraph_it)->mAddTime - skip_time)/(mLinePersistTime - mFadeTime); |
230 | } | 252 | } |
231 | else | 253 | else |
232 | { | 254 | { |
@@ -235,12 +257,12 @@ void LLConsole::draw() | |||
235 | 257 | ||
236 | if( alpha > 0.f ) | 258 | if( alpha > 0.f ) |
237 | { | 259 | { |
238 | for (lines_t::iterator line_it=(*paragraph_it).mLines.begin(); | 260 | for (lines_t::iterator line_it=(*paragraph_it)->mLines.begin(); |
239 | line_it != (*paragraph_it).mLines.end(); | 261 | line_it != (*paragraph_it)->mLines.end(); |
240 | line_it ++) | 262 | line_it ++) |
241 | { | 263 | { |
242 | for (line_color_segments_t::iterator seg_it = (*line_it).mLineColorSegments.begin(); | 264 | for (line_color_segments_t::iterator seg_it = (*line_it).begin(); |
243 | seg_it != (*line_it).mLineColorSegments.end(); | 265 | seg_it != (*line_it).end(); |
244 | seg_it++) | 266 | seg_it++) |
245 | { | 267 | { |
246 | mFont->render((*seg_it).mText, 0, (*seg_it).mXPosition - 8, y_pos - y_off, | 268 | mFont->render((*seg_it).mText, 0, (*seg_it).mXPosition - 8, y_pos - y_off, |
@@ -263,21 +285,34 @@ void LLConsole::draw() | |||
263 | } | 285 | } |
264 | } | 286 | } |
265 | 287 | ||
266 | void LLConsole::addLine(const std::string& utf8line) | 288 | //virtual |
289 | void LLConsole::clear() | ||
267 | { | 290 | { |
268 | LLWString wline = utf8str_to_wstring(utf8line); | 291 | mTimer.reset(); |
269 | addLine(wline, 0.f, LLColor4(1.f, 1.f, 1.f, 1.f)); | 292 | LLMutexLock lock(&mQueueMutex); |
293 | std::for_each(mParagraphs.begin(), mParagraphs.end(), DeletePointer()); | ||
294 | mParagraphs.clear(); | ||
295 | std::for_each(mNewParagraphs.begin(), mNewParagraphs.end(), DeletePointer()); | ||
296 | mNewParagraphs.clear(); | ||
270 | } | 297 | } |
271 | 298 | ||
272 | void LLConsole::addLine(const LLWString& wline) | 299 | //virtual |
300 | void LLConsole::addLine(const std::string& utf8line) | ||
273 | { | 301 | { |
274 | addLine(wline, 0.f, LLColor4(1.f, 1.f, 1.f, 1.f)); | 302 | addConsoleLine(utf8line, LLColor4(1.f, 1.f, 1.f, 1.f)); |
275 | } | 303 | } |
276 | 304 | ||
277 | void LLConsole::addLine(const std::string& utf8line, F32 size, const LLColor4 &color) | 305 | void LLConsole::addConsoleLine(const std::string& utf8line, const LLColor4 &color) |
278 | { | 306 | { |
279 | LLWString wline = utf8str_to_wstring(utf8line); | 307 | LLWString wline = utf8str_to_wstring(utf8line); |
280 | addLine(wline, size, color); | 308 | addConsoleLine(wline, color); |
309 | } | ||
310 | |||
311 | void LLConsole::addConsoleLine(const LLWString& wline, const LLColor4 &color) | ||
312 | { | ||
313 | Paragraph* paragraph = new Paragraph(wline, color, mTimer.getElapsedTimeF32()); | ||
314 | LLMutexLock lock(&mQueueMutex); | ||
315 | mNewParagraphs.push_back ( paragraph ); | ||
281 | } | 316 | } |
282 | 317 | ||
283 | //Generate highlight color segments for this paragraph. Pass in default color of paragraph. | 318 | //Generate highlight color segments for this paragraph. Pass in default color of paragraph. |
@@ -359,7 +394,7 @@ void LLConsole::Paragraph::updateLines(F32 screen_width, LLFontGL* font, bool fo | |||
359 | F32 x_position = 0; //Screen X position of text. | 394 | F32 x_position = 0; //Screen X position of text. |
360 | 395 | ||
361 | mMaxWidth = llmax( mMaxWidth, (F32)font->getWidth( mParagraphText.substr( paragraph_offset, drawable ).c_str() ) ); | 396 | mMaxWidth = llmax( mMaxWidth, (F32)font->getWidth( mParagraphText.substr( paragraph_offset, drawable ).c_str() ) ); |
362 | Line line; | 397 | line_color_segments_t line; |
363 | 398 | ||
364 | U32 left_to_draw = drawable; | 399 | U32 left_to_draw = drawable; |
365 | U32 drawn = 0; | 400 | U32 drawn = 0; |
@@ -368,7 +403,7 @@ void LLConsole::Paragraph::updateLines(F32 screen_width, LLFontGL* font, bool fo | |||
368 | && current_color != mParagraphColorSegments.end() ) | 403 | && current_color != mParagraphColorSegments.end() ) |
369 | { | 404 | { |
370 | LLWString color_text = mParagraphText.substr( paragraph_offset + drawn, current_color_length ); | 405 | LLWString color_text = mParagraphText.substr( paragraph_offset + drawn, current_color_length ); |
371 | line.mLineColorSegments.push_back( LineColorSegment( color_text, //Append segment to line. | 406 | line.push_back( LineColorSegment( color_text, //Append segment to line. |
372 | (*current_color).mColor, | 407 | (*current_color).mColor, |
373 | x_position ) ); | 408 | x_position ) ); |
374 | 409 | ||
@@ -389,7 +424,7 @@ void LLConsole::Paragraph::updateLines(F32 screen_width, LLFontGL* font, bool fo | |||
389 | { | 424 | { |
390 | LLWString color_text = mParagraphText.substr( paragraph_offset + drawn, left_to_draw ); | 425 | LLWString color_text = mParagraphText.substr( paragraph_offset + drawn, left_to_draw ); |
391 | 426 | ||
392 | line.mLineColorSegments.push_back( LineColorSegment( color_text, //Append segment to line. | 427 | line.push_back( LineColorSegment( color_text, //Append segment to line. |
393 | (*current_color).mColor, | 428 | (*current_color).mColor, |
394 | x_position ) ); | 429 | x_position ) ); |
395 | 430 | ||
@@ -407,50 +442,9 @@ void LLConsole::Paragraph::updateLines(F32 screen_width, LLFontGL* font, bool fo | |||
407 | } | 442 | } |
408 | 443 | ||
409 | //Pass in the string and the default color for this block of text. | 444 | //Pass in the string and the default color for this block of text. |
410 | LLConsole::Paragraph::Paragraph (LLWString str, const LLColor4 &color, F32 add_time, LLFontGL* font, F32 screen_width) | 445 | LLConsole::Paragraph::Paragraph (LLWString str, const LLColor4 &color, F32 add_time) |
411 | : mParagraphText(str), mAddTime(add_time), mMaxWidth(-1) | 446 | : mParagraphText(str), mAddTime(add_time), mMaxWidth(-1) |
412 | { | 447 | { |
413 | makeParagraphColorSegments(color); | 448 | makeParagraphColorSegments(color); |
414 | updateLines( screen_width, font ); | ||
415 | } | 449 | } |
416 | 450 | ||
417 | void LLConsole::addLine(const LLWString& wline, F32 size, const LLColor4 &color) | ||
418 | { | ||
419 | Paragraph paragraph(wline, color, mTimer.getElapsedTimeF32(), mFont, (F32)getRect().getWidth() ); | ||
420 | |||
421 | mParagraphs.push_back ( paragraph ); | ||
422 | |||
423 | #if LL_WINDOWS && LL_LCD_COMPILE | ||
424 | // add to LCD screen | ||
425 | AddNewDebugConsoleToLCD(wline); | ||
426 | #endif | ||
427 | } | ||
428 | |||
429 | // | ||
430 | //check if there are some messages stored in the buffer | ||
431 | //if yes, output them. | ||
432 | // | ||
433 | void LLConsole::updateBuffer() | ||
434 | { | ||
435 | BOOL need_clear = FALSE ; | ||
436 | |||
437 | mMutex.lock() ; | ||
438 | if(!mLines.empty()) | ||
439 | { | ||
440 | S32 end = mLines.size() ; | ||
441 | LLColor4 color(1.f, 1.f, 1.f, 1.f) ; | ||
442 | for(S32 i = 0 ; i < end ; i++) | ||
443 | { | ||
444 | Paragraph paragraph(mLines[i], color, mAddTimes[i], mFont, (F32)getRect().getWidth() ); | ||
445 | mParagraphs.push_back ( paragraph ); | ||
446 | } | ||
447 | |||
448 | need_clear = TRUE ; | ||
449 | } | ||
450 | mMutex.unlock() ; | ||
451 | |||
452 | if(need_clear) | ||
453 | { | ||
454 | clear() ; | ||
455 | } | ||
456 | } | ||
diff --git a/linden/indra/newview/llconsole.h b/linden/indra/newview/llconsole.h index 2915c48..578670e 100644 --- a/linden/indra/newview/llconsole.h +++ b/linden/indra/newview/llconsole.h | |||
@@ -33,7 +33,8 @@ | |||
33 | #ifndef LL_LLCONSOLE_H | 33 | #ifndef LL_LLCONSOLE_H |
34 | #define LL_LLCONSOLE_H | 34 | #define LL_LLCONSOLE_H |
35 | 35 | ||
36 | #include "llfixedbuffer.h" | 36 | #include "llerrorcontrol.h" // For LLLineBuffer |
37 | #include "llthread.h" | ||
37 | #include "llview.h" | 38 | #include "llview.h" |
38 | #include "v4color.h" | 39 | #include "v4color.h" |
39 | #include <deque> | 40 | #include <deque> |
@@ -47,10 +48,10 @@ private: | |||
47 | F32 mLinePersistTime; // Age at which to stop drawing. | 48 | F32 mLinePersistTime; // Age at which to stop drawing. |
48 | F32 mFadeTime; // Age at which to start fading | 49 | F32 mFadeTime; // Age at which to start fading |
49 | LLFontGL* mFont; | 50 | LLFontGL* mFont; |
50 | S32 mLastBoxHeight; | ||
51 | S32 mLastBoxWidth; | ||
52 | S32 mConsoleWidth; | 51 | S32 mConsoleWidth; |
53 | S32 mConsoleHeight; | 52 | S32 mConsoleHeight; |
53 | LLMutex mQueueMutex; | ||
54 | LLTimer mTimer; | ||
54 | 55 | ||
55 | public: | 56 | public: |
56 | //A paragraph color segment defines the color of text in a line | 57 | //A paragraph color segment defines the color of text in a line |
@@ -80,14 +81,7 @@ public: | |||
80 | 81 | ||
81 | typedef std::list<LineColorSegment> line_color_segments_t; | 82 | typedef std::list<LineColorSegment> line_color_segments_t; |
82 | 83 | ||
83 | //A line is composed of one or more color segments. | 84 | typedef std::list<line_color_segments_t> lines_t; |
84 | class Line | ||
85 | { | ||
86 | public: | ||
87 | line_color_segments_t mLineColorSegments; | ||
88 | }; | ||
89 | |||
90 | typedef std::list<Line> lines_t; | ||
91 | typedef std::list<ParagraphColorSegment> paragraph_color_segments_t; | 85 | typedef std::list<ParagraphColorSegment> paragraph_color_segments_t; |
92 | 86 | ||
93 | //A paragraph is a processed element containing the entire text of the | 87 | //A paragraph is a processed element containing the entire text of the |
@@ -98,7 +92,7 @@ public: | |||
98 | class Paragraph | 92 | class Paragraph |
99 | { | 93 | { |
100 | public: | 94 | public: |
101 | Paragraph (LLWString str, const LLColor4 &color, F32 add_time, LLFontGL* font, F32 screen_width); | 95 | Paragraph (LLWString str, const LLColor4 &color, F32 add_time); |
102 | void makeParagraphColorSegments ( const LLColor4 &color); | 96 | void makeParagraphColorSegments ( const LLColor4 &color); |
103 | void updateLines ( F32 screen_width, LLFontGL* font, bool force_resize=false ); | 97 | void updateLines ( F32 screen_width, LLFontGL* font, bool force_resize=false ); |
104 | public: | 98 | public: |
@@ -111,35 +105,32 @@ public: | |||
111 | }; | 105 | }; |
112 | 106 | ||
113 | //The console contains a deque of paragraphs which represent the individual messages. | 107 | //The console contains a deque of paragraphs which represent the individual messages. |
114 | typedef std::deque<Paragraph> paragraph_t; | 108 | typedef std::deque<Paragraph*> paragraph_t; |
115 | paragraph_t mParagraphs; | 109 | paragraph_t mParagraphs; |
110 | paragraph_t mNewParagraphs; | ||
116 | 111 | ||
117 | // Font size: | 112 | // Font size: |
118 | // -1 = monospace, 0 means small, font size = 1 means big | 113 | // -1 = monospace, 0 means small, font size = 1 means big |
119 | LLConsole(const std::string& name, const U32 max_lines, const LLRect &rect, | 114 | LLConsole(const std::string& name, const LLRect &rect, |
120 | S32 font_size_index, F32 persist_time ); | 115 | S32 font_size_index, F32 persist_time ); |
121 | ~LLConsole(){}; | 116 | ~LLConsole(); |
122 | 117 | ||
123 | // each line lasts this long after being added | 118 | // each line lasts this long after being added |
124 | void setLinePersistTime(F32 seconds); | 119 | void setLinePersistTime(F32 seconds); |
125 | 120 | ||
126 | void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); | 121 | void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); |
127 | 122 | ||
128 | // -1 = monospace, 0 means small, font size = 1 means big | 123 | // -1 = monospace, 0 means small, font size = 1 means big |
129 | void setFontSize(S32 size_index); | 124 | void setFontSize(S32 size_index); |
130 | 125 | ||
131 | void addLine(const std::string& utf8line, F32 size, const LLColor4 &color); | 126 | // From LLLineBuffer |
132 | void addLine(const LLWString& wline, F32 size, const LLColor4 &color); | 127 | /*virtual*/ void clear(); |
128 | /*virtual*/ void addLine(const std::string& utf8line); | ||
129 | void addConsoleLine(const std::string& utf8line, const LLColor4 &color); | ||
130 | void addConsoleLine(const LLWString& wline, const LLColor4 &color); | ||
133 | 131 | ||
134 | // Overrides | 132 | // Overrides |
135 | /*virtual*/ void draw(); | 133 | /*virtual*/ void draw(); |
136 | |||
137 | //do not make these two "virtual" | ||
138 | void addLine(const std::string& utf8line); | ||
139 | void addLine(const LLWString& line); | ||
140 | |||
141 | private: | ||
142 | void updateBuffer() ; | ||
143 | }; | 134 | }; |
144 | 135 | ||
145 | extern LLConsole* gConsole; | 136 | extern LLConsole* gConsole; |
diff --git a/linden/indra/newview/lldebugview.cpp b/linden/indra/newview/lldebugview.cpp index 40f5202..a6d6f2d 100644 --- a/linden/indra/newview/lldebugview.cpp +++ b/linden/indra/newview/lldebugview.cpp | |||
@@ -62,7 +62,7 @@ LLDebugView::LLDebugView(const std::string& name, const LLRect &rect) | |||
62 | LLRect r; | 62 | LLRect r; |
63 | 63 | ||
64 | r.set(10, rect.getHeight() - 100, rect.getWidth()/2, 100); | 64 | r.set(10, rect.getHeight() - 100, rect.getWidth()/2, 100); |
65 | mDebugConsolep = new LLConsole("debug console", 20, r, -1, 0.f ); | 65 | mDebugConsolep = new LLConsole("debug console", r, -1, 0.f ); |
66 | mDebugConsolep->setFollowsBottom(); | 66 | mDebugConsolep->setFollowsBottom(); |
67 | mDebugConsolep->setFollowsLeft(); | 67 | mDebugConsolep->setFollowsLeft(); |
68 | mDebugConsolep->setVisible( FALSE ); | 68 | mDebugConsolep->setVisible( FALSE ); |
@@ -98,6 +98,27 @@ LLDebugView::LLDebugView(const std::string& name, const LLRect &rect) | |||
98 | addChild(gTextureView); | 98 | addChild(gTextureView); |
99 | //gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE); | 99 | //gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE); |
100 | 100 | ||
101 | /* | ||
102 | //there seems to be some debug code, we don't have | ||
103 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
104 | r.set(150, rect.getHeight() - 50, 900 + LLImageGL::sTextureLoadedCounter.size() * 30, 100); | ||
105 | gTextureSizeView = new LLTextureSizeView("gTextureSizeView"); | ||
106 | gTextureSizeView->setRect(r); | ||
107 | gTextureSizeView->setFollowsBottom(); | ||
108 | gTextureSizeView->setFollowsLeft(); | ||
109 | addChild(gTextureSizeView); | ||
110 | |||
111 | |||
112 | r.set(150, rect.getHeight() - 50, 900 + LLImageGL::sTextureMemByCategory.size() * 30, 100); | ||
113 | gTextureCategoryView = new LLTextureSizeView("gTextureCategoryView"); | ||
114 | gTextureCategoryView->setRect(r); | ||
115 | gTextureCategoryView->setFollowsBottom(); | ||
116 | gTextureCategoryView->setFollowsLeft(); | ||
117 | gTextureCategoryView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_CATEGORY); | ||
118 | addChild(gTextureCategoryView); | ||
119 | #endif | ||
120 | */ | ||
121 | |||
101 | const S32 VELOCITY_LEFT = 10; // 370; | 122 | const S32 VELOCITY_LEFT = 10; // 370; |
102 | const S32 VELOCITY_WIDTH = 500; | 123 | const S32 VELOCITY_WIDTH = 500; |
103 | const S32 VELOCITY_TOP = 140; | 124 | const S32 VELOCITY_TOP = 140; |
@@ -115,5 +136,6 @@ LLDebugView::~LLDebugView() | |||
115 | // These have already been deleted. Fix the globals appropriately. | 136 | // These have already been deleted. Fix the globals appropriately. |
116 | gDebugView = NULL; | 137 | gDebugView = NULL; |
117 | gTextureView = NULL; | 138 | gTextureView = NULL; |
139 | gTextureSizeView = NULL; | ||
118 | } | 140 | } |
119 | 141 | ||
diff --git a/linden/indra/newview/lldrawable.cpp b/linden/indra/newview/lldrawable.cpp index 14aa38a..99577e3 100644 --- a/linden/indra/newview/lldrawable.cpp +++ b/linden/indra/newview/lldrawable.cpp | |||
@@ -102,7 +102,7 @@ void LLDrawable::init() | |||
102 | mVObjp = NULL; | 102 | mVObjp = NULL; |
103 | // mFaces | 103 | // mFaces |
104 | mSpatialGroupp = NULL; | 104 | mSpatialGroupp = NULL; |
105 | mVisible = sCurVisible - 2;//invisible for the current frame and the last frame. | 105 | mVisible = 0; |
106 | mRadius = 0.f; | 106 | mRadius = 0.f; |
107 | 107 | ||
108 | mGeneration = -1; | 108 | mGeneration = -1; |
@@ -125,7 +125,7 @@ void LLDrawable::destroy() | |||
125 | 125 | ||
126 | if (LLSpatialGroup::sNoDelete) | 126 | if (LLSpatialGroup::sNoDelete) |
127 | { | 127 | { |
128 | llerrs << "Illegal deletion of LLDrawable!" << llendl; | 128 | llwarns << "Illegal deletion of LLDrawable!" << llendl; |
129 | } | 129 | } |
130 | 130 | ||
131 | std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); | 131 | std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); |
@@ -234,7 +234,7 @@ LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerImage *texturep) | |||
234 | LLMemType mt(LLMemType::MTYPE_DRAWABLE); | 234 | LLMemType mt(LLMemType::MTYPE_DRAWABLE); |
235 | 235 | ||
236 | LLFace *face = new LLFace(this, mVObjp); | 236 | LLFace *face = new LLFace(this, mVObjp); |
237 | if (!face) llerrs << "Allocating new Face: " << mFaces.size() << llendl; | 237 | if (!face) llwarns << "Allocating new Face: " << mFaces.size() << llendl; |
238 | 238 | ||
239 | if (face) | 239 | if (face) |
240 | { | 240 | { |
@@ -346,7 +346,7 @@ void LLDrawable::deleteFaces(S32 offset, S32 count) | |||
346 | 346 | ||
347 | void LLDrawable::update() | 347 | void LLDrawable::update() |
348 | { | 348 | { |
349 | llerrs << "Shouldn't be called!" << llendl; | 349 | llwarns << "Shouldn't be called!" << llendl; |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
@@ -368,7 +368,7 @@ void LLDrawable::makeActive() | |||
368 | pcode == LLViewerObject::LL_VO_GROUND || | 368 | pcode == LLViewerObject::LL_VO_GROUND || |
369 | pcode == LLViewerObject::LL_VO_SKY) | 369 | pcode == LLViewerObject::LL_VO_SKY) |
370 | { | 370 | { |
371 | llerrs << "Static viewer object has active drawable!" << llendl; | 371 | llwarns << "Static viewer object has active drawable!" << llendl; |
372 | } | 372 | } |
373 | } | 373 | } |
374 | #endif | 374 | #endif |
@@ -692,19 +692,22 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) | |||
692 | pos += volume->getRegion()->getOriginAgent(); | 692 | pos += volume->getRegion()->getOriginAgent(); |
693 | } | 693 | } |
694 | 694 | ||
695 | for (S32 i = 0; i < getNumFaces(); i++) | 695 | if (isState(LLDrawable::HAS_ALPHA)) |
696 | { | 696 | { |
697 | LLFace* facep = getFace(i); | 697 | for (S32 i = 0; i < getNumFaces(); i++) |
698 | if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA) | ||
699 | { | 698 | { |
700 | LLVector3 box = (facep->mExtents[1] - facep->mExtents[0]) * 0.25f; | 699 | LLFace* facep = getFace(i); |
701 | LLVector3 v = (facep->mCenterLocal-camera.getOrigin()); | 700 | if (facep->getPoolType() == LLDrawPool::POOL_ALPHA) |
702 | LLVector3 at = camera.getAtAxis(); | ||
703 | for (U32 j = 0; j < 3; j++) | ||
704 | { | 701 | { |
705 | v.mV[j] -= box.mV[j] * at.mV[j]; | 702 | LLVector3 box = (facep->mExtents[1] - facep->mExtents[0]) * 0.25f; |
703 | LLVector3 v = (facep->mCenterLocal-camera.getOrigin()); | ||
704 | const LLVector3& at = camera.getAtAxis(); | ||
705 | for (U32 j = 0; j < 3; j++) | ||
706 | { | ||
707 | v.mV[j] -= box.mV[j] * at.mV[j]; | ||
708 | } | ||
709 | facep->mDistance = v * camera.getAtAxis(); | ||
706 | } | 710 | } |
707 | facep->mDistance = v * camera.getAtAxis(); | ||
708 | } | 711 | } |
709 | } | 712 | } |
710 | } | 713 | } |
@@ -736,7 +739,11 @@ void LLDrawable::updateTexture() | |||
736 | 739 | ||
737 | if (getVOVolume()) | 740 | if (getVOVolume()) |
738 | { | 741 | { |
739 | if (isActive()) | 742 | if (!isActive()) |
743 | { | ||
744 | //gPipeline.markMoved(this); | ||
745 | } | ||
746 | else | ||
740 | { | 747 | { |
741 | if (isRoot()) | 748 | if (isRoot()) |
742 | { | 749 | { |
@@ -1003,8 +1010,8 @@ BOOL LLDrawable::isVisible() const | |||
1003 | // Spatial Partition Bridging Drawable | 1010 | // Spatial Partition Bridging Drawable |
1004 | //======================================= | 1011 | //======================================= |
1005 | 1012 | ||
1006 | LLSpatialBridge::LLSpatialBridge(LLDrawable* root, U32 data_mask) | 1013 | LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask) // KL Sd version |
1007 | : LLSpatialPartition(data_mask, FALSE) | 1014 | : LLSpatialPartition(data_mask, render_by_group, FALSE) |
1008 | { | 1015 | { |
1009 | mDrawable = root; | 1016 | mDrawable = root; |
1010 | root->setSpatialBridge(this); | 1017 | root->setSpatialBridge(this); |
@@ -1134,26 +1141,26 @@ void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results, | |||
1134 | { | 1141 | { |
1135 | if (isActive() && !mParent->isActive()) | 1142 | if (isActive() && !mParent->isActive()) |
1136 | { | 1143 | { |
1137 | llerrs << "Active drawable has static parent!" << llendl; | 1144 | llwarns << "Active drawable has static parent!" << llendl; |
1138 | } | 1145 | } |
1139 | 1146 | ||
1140 | if (isStatic() && !mParent->isStatic()) | 1147 | if (isStatic() && !mParent->isStatic()) |
1141 | { | 1148 | { |
1142 | llerrs << "Static drawable has active parent!" << llendl; | 1149 | llwarns << "Static drawable has active parent!" << llendl; |
1143 | } | 1150 | } |
1144 | 1151 | ||
1145 | if (mSpatialBridge) | 1152 | if (mSpatialBridge) |
1146 | { | 1153 | { |
1147 | llerrs << "Child drawable has spatial bridge!" << llendl; | 1154 | llwarns << "Child drawable has spatial bridge!" << llendl; |
1148 | } | 1155 | } |
1149 | } | 1156 | } |
1150 | else if (isActive() && !mSpatialBridge) | 1157 | else if (isActive() && !mSpatialBridge) |
1151 | { | 1158 | { |
1152 | llerrs << "Active root drawable has no spatial bridge!" << llendl; | 1159 | llwarns << "Active root drawable has no spatial bridge!" << llendl; |
1153 | } | 1160 | } |
1154 | else if (isStatic() && mSpatialBridge.notNull()) | 1161 | else if (isStatic() && mSpatialBridge.notNull()) |
1155 | { | 1162 | { |
1156 | llerrs << "Static drawable has spatial bridge!" << llendl; | 1163 | llwarns << "Static drawable has spatial bridge!" << llendl; |
1157 | } | 1164 | } |
1158 | } | 1165 | } |
1159 | #endif | 1166 | #endif |
@@ -1277,12 +1284,25 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) | |||
1277 | return; | 1284 | return; |
1278 | } | 1285 | } |
1279 | 1286 | ||
1280 | LLCamera camera = transformCamera(camera_in); | 1287 | if (mDrawable->getVObj()) |
1288 | { | ||
1289 | if (mDrawable->getVObj()->isAttachment()) | ||
1290 | { | ||
1291 | LLDrawable* parent = mDrawable->getParent(); | ||
1292 | if (parent && parent->getVObj()) | ||
1293 | { | ||
1294 | LLVOAvatar* av = parent->getVObj()->asAvatar(); | ||
1295 | if (av && av->isImpostor()) | ||
1296 | { | ||
1297 | return; | ||
1298 | } | ||
1299 | } | ||
1300 | } | ||
1301 | |||
1302 | LLCamera camera = transformCamera(camera_in); | ||
1281 | 1303 | ||
1282 | mDrawable->updateDistance(camera, force_update); | 1304 | mDrawable->updateDistance(camera, force_update); |
1283 | 1305 | ||
1284 | if (mDrawable->getVObj()) | ||
1285 | { | ||
1286 | LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren(); | 1306 | LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren(); |
1287 | for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); | 1307 | for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); |
1288 | iter != child_list.end(); iter++) | 1308 | iter != child_list.end(); iter++) |
@@ -1304,7 +1324,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) | |||
1304 | 1324 | ||
1305 | void LLSpatialBridge::makeActive() | 1325 | void LLSpatialBridge::makeActive() |
1306 | { //it is an error to make a spatial bridge active (it's already active) | 1326 | { //it is an error to make a spatial bridge active (it's already active) |
1307 | llerrs << "makeActive called on spatial bridge" << llendl; | 1327 | llwarns << "makeActive called on spatial bridge" << llendl; |
1308 | } | 1328 | } |
1309 | 1329 | ||
1310 | void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate) | 1330 | void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate) |
@@ -1420,9 +1440,9 @@ void LLDrawable::updateFaceSize(S32 idx) | |||
1420 | } | 1440 | } |
1421 | 1441 | ||
1422 | LLBridgePartition::LLBridgePartition() | 1442 | LLBridgePartition::LLBridgePartition() |
1423 | : LLSpatialPartition(0, TRUE) | 1443 | : LLSpatialPartition(0, FALSE, 0) |
1424 | { | 1444 | { |
1425 | mRenderByGroup = FALSE; | 1445 | //mRenderByGroup = FALSE; // KL |
1426 | mDrawableType = LLPipeline::RENDER_TYPE_AVATAR; | 1446 | mDrawableType = LLPipeline::RENDER_TYPE_AVATAR; |
1427 | mPartitionType = LLViewerRegion::PARTITION_BRIDGE; | 1447 | mPartitionType = LLViewerRegion::PARTITION_BRIDGE; |
1428 | mLODPeriod = 16; | 1448 | mLODPeriod = 16; |
diff --git a/linden/indra/newview/lldrawable.h b/linden/indra/newview/lldrawable.h index 71b75dc..e6753b5 100644 --- a/linden/indra/newview/lldrawable.h +++ b/linden/indra/newview/lldrawable.h | |||
@@ -267,7 +267,8 @@ public: | |||
267 | BUILT = 0x08000000, | 267 | BUILT = 0x08000000, |
268 | FORCE_INVISIBLE = 0x10000000, // stay invis until CLEAR_INVISIBLE is set (set of orphaned) | 268 | FORCE_INVISIBLE = 0x10000000, // stay invis until CLEAR_INVISIBLE is set (set of orphaned) |
269 | CLEAR_INVISIBLE = 0x20000000, // clear FORCE_INVISIBLE next draw frame | 269 | CLEAR_INVISIBLE = 0x20000000, // clear FORCE_INVISIBLE next draw frame |
270 | REBUILD_SHADOW = 0x40000000 | 270 | REBUILD_SHADOW = 0x40000000, |
271 | HAS_ALPHA = 0x80000000, | ||
271 | } EDrawableFlags; | 272 | } EDrawableFlags; |
272 | 273 | ||
273 | LLXformMatrix mXform; | 274 | LLXformMatrix mXform; |
diff --git a/linden/indra/newview/lldrawpool.h b/linden/indra/newview/lldrawpool.h index 87c3cca..9052710 100644 --- a/linden/indra/newview/lldrawpool.h +++ b/linden/indra/newview/lldrawpool.h | |||
@@ -67,6 +67,11 @@ public: | |||
67 | POOL_GLOW, | 67 | POOL_GLOW, |
68 | POOL_ALPHA, | 68 | POOL_ALPHA, |
69 | NUM_POOL_TYPES, | 69 | NUM_POOL_TYPES, |
70 | // * invisiprims work by rendering to the depth buffer but not the color buffer, occluding anything rendered after them | ||
71 | // - and the LLDrawPool types enum controls what order things are rendered in | ||
72 | // - so, it has absolute control over what invisprims block | ||
73 | // ...invisiprims being rendered in pool_invisible | ||
74 | // ...shiny/bump mapped objects in rendered in POOL_BUMP | ||
70 | }; | 75 | }; |
71 | 76 | ||
72 | LLDrawPool(const U32 type); | 77 | LLDrawPool(const U32 type); |
diff --git a/linden/indra/newview/lldrawpoolalpha.cpp b/linden/indra/newview/lldrawpoolalpha.cpp index 4b552ac..c9c06f4 100644 --- a/linden/indra/newview/lldrawpoolalpha.cpp +++ b/linden/indra/newview/lldrawpoolalpha.cpp | |||
@@ -88,7 +88,12 @@ void LLDrawPoolAlpha::beginDeferredPass(S32 pass) | |||
88 | 88 | ||
89 | void LLDrawPoolAlpha::endDeferredPass(S32 pass) | 89 | void LLDrawPoolAlpha::endDeferredPass(S32 pass) |
90 | { | 90 | { |
91 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.4f); | 91 | |
92 | } | ||
93 | |||
94 | void LLDrawPoolAlpha::renderDeferred(S32 pass) | ||
95 | { | ||
96 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); | ||
92 | { | 97 | { |
93 | LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); | 98 | LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); |
94 | gDeferredTreeProgram.bind(); | 99 | gDeferredTreeProgram.bind(); |
@@ -99,11 +104,6 @@ void LLDrawPoolAlpha::endDeferredPass(S32 pass) | |||
99 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | 104 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); |
100 | } | 105 | } |
101 | 106 | ||
102 | void LLDrawPoolAlpha::renderDeferred(S32 pass) | ||
103 | { | ||
104 | |||
105 | } | ||
106 | |||
107 | 107 | ||
108 | S32 LLDrawPoolAlpha::getNumPostDeferredPasses() | 108 | S32 LLDrawPoolAlpha::getNumPostDeferredPasses() |
109 | { | 109 | { |
@@ -261,6 +261,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) | |||
261 | { | 261 | { |
262 | BOOL initialized_lighting = FALSE; | 262 | BOOL initialized_lighting = FALSE; |
263 | BOOL light_enabled = TRUE; | 263 | BOOL light_enabled = TRUE; |
264 | S32 diffuse_channel = 0; | ||
265 | |||
264 | //BOOL is_particle = FALSE; | 266 | //BOOL is_particle = FALSE; |
265 | BOOL use_shaders = (LLPipeline::sUnderWaterRender && gPipeline.canUseVertexShaders()) | 267 | BOOL use_shaders = (LLPipeline::sUnderWaterRender && gPipeline.canUseVertexShaders()) |
266 | || gPipeline.canUseWindLightShadersOnObjects(); | 268 | || gPipeline.canUseWindLightShadersOnObjects(); |
@@ -291,19 +293,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) | |||
291 | 293 | ||
292 | LLRenderPass::applyModelMatrix(params); | 294 | LLRenderPass::applyModelMatrix(params); |
293 | 295 | ||
294 | if (params.mTexture.notNull()) | ||
295 | { | ||
296 | gGL.getTexUnit(0)->activate(); | ||
297 | gGL.getTexUnit(0)->bind(params.mTexture.get()); | ||
298 | |||
299 | if (params.mTextureMatrix) | ||
300 | { | ||
301 | glMatrixMode(GL_TEXTURE); | ||
302 | glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); | ||
303 | gPipeline.mTextureMatrixOps++; | ||
304 | } | ||
305 | } | ||
306 | |||
307 | if (params.mFullbright) | 296 | if (params.mFullbright) |
308 | { | 297 | { |
309 | // Turn off lighting if it hasn't already been so. | 298 | // Turn off lighting if it hasn't already been so. |
@@ -344,11 +333,13 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) | |||
344 | if (deferred_render && current_shader != NULL) | 333 | if (deferred_render && current_shader != NULL) |
345 | { | 334 | { |
346 | gPipeline.unbindDeferredShader(*current_shader); | 335 | gPipeline.unbindDeferredShader(*current_shader); |
336 | diffuse_channel = 0; | ||
347 | } | 337 | } |
348 | current_shader = target_shader; | 338 | current_shader = target_shader; |
349 | if (deferred_render) | 339 | if (deferred_render) |
350 | { | 340 | { |
351 | gPipeline.bindDeferredShader(*current_shader); | 341 | gPipeline.bindDeferredShader(*current_shader); |
342 | diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); | ||
352 | } | 343 | } |
353 | else | 344 | else |
354 | { | 345 | { |
@@ -357,11 +348,12 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) | |||
357 | } | 348 | } |
358 | else if (!use_shaders && current_shader != NULL) | 349 | else if (!use_shaders && current_shader != NULL) |
359 | { | 350 | { |
360 | LLGLSLShader::bindNoShader(); | ||
361 | if (deferred_render) | 351 | if (deferred_render) |
362 | { | 352 | { |
363 | gPipeline.unbindDeferredShader(*current_shader); | 353 | gPipeline.unbindDeferredShader(*current_shader); |
354 | diffuse_channel = 0; | ||
364 | } | 355 | } |
356 | LLGLSLShader::bindNoShader(); | ||
365 | current_shader = NULL; | 357 | current_shader = NULL; |
366 | } | 358 | } |
367 | 359 | ||
@@ -369,6 +361,24 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) | |||
369 | { | 361 | { |
370 | params.mGroup->rebuildMesh(); | 362 | params.mGroup->rebuildMesh(); |
371 | } | 363 | } |
364 | |||
365 | |||
366 | if (params.mTexture.notNull()) | ||
367 | { | ||
368 | gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get(), TRUE, TRUE); | ||
369 | if(params.mViewerTexture.notNull()) | ||
370 | { | ||
371 | params.mViewerTexture->addTextureStats(params.mVSize); | ||
372 | } | ||
373 | if (params.mTextureMatrix) | ||
374 | { | ||
375 | gGL.getTexUnit(0)->activate(); | ||
376 | glMatrixMode(GL_TEXTURE); | ||
377 | glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); | ||
378 | gPipeline.mTextureMatrixOps++; | ||
379 | } | ||
380 | } | ||
381 | |||
372 | params.mVertexBuffer->setBuffer(mask); | 382 | params.mVertexBuffer->setBuffer(mask); |
373 | params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); | 383 | params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); |
374 | gPipeline.addTrianglesDrawn(params.mCount/3); | 384 | gPipeline.addTrianglesDrawn(params.mCount/3); |
@@ -383,6 +393,15 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) | |||
383 | } | 393 | } |
384 | } | 394 | } |
385 | 395 | ||
396 | if (deferred_render && current_shader != NULL) | ||
397 | { | ||
398 | gPipeline.unbindDeferredShader(*current_shader); | ||
399 | LLVertexBuffer::unbind(); | ||
400 | LLGLState::checkStates(); | ||
401 | LLGLState::checkTextureChannels(); | ||
402 | LLGLState::checkClientArrays(); | ||
403 | } | ||
404 | |||
386 | if (!light_enabled) | 405 | if (!light_enabled) |
387 | { | 406 | { |
388 | gPipeline.enableLightsDynamic(); | 407 | gPipeline.enableLightsDynamic(); |
diff --git a/linden/indra/newview/lldrawpoolavatar.cpp b/linden/indra/newview/lldrawpoolavatar.cpp index 80c7d73..af7b5e3 100644 --- a/linden/indra/newview/lldrawpoolavatar.cpp +++ b/linden/indra/newview/lldrawpoolavatar.cpp | |||
@@ -94,6 +94,7 @@ BOOL gAvatarEmbossBumpMap = FALSE; | |||
94 | static BOOL sRenderingSkinned = FALSE; | 94 | static BOOL sRenderingSkinned = FALSE; |
95 | S32 normal_channel = -1; | 95 | S32 normal_channel = -1; |
96 | S32 specular_channel = -1; | 96 | S32 specular_channel = -1; |
97 | S32 diffuse_channel = -1; | ||
97 | 98 | ||
98 | LLDrawPoolAvatar::LLDrawPoolAvatar() : | 99 | LLDrawPoolAvatar::LLDrawPoolAvatar() : |
99 | LLFacePool(POOL_AVATAR) | 100 | LLFacePool(POOL_AVATAR) |
@@ -447,7 +448,8 @@ void LLDrawPoolAvatar::beginDeferredImpostor() | |||
447 | 448 | ||
448 | normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); | 449 | normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); |
449 | specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); | 450 | specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); |
450 | 451 | diffuse_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); // KL SD | |
452 | |||
451 | sVertexProgram->bind(); | 453 | sVertexProgram->bind(); |
452 | } | 454 | } |
453 | 455 | ||
@@ -456,6 +458,7 @@ void LLDrawPoolAvatar::endDeferredImpostor() | |||
456 | sShaderLevel = mVertexShaderLevel; | 458 | sShaderLevel = mVertexShaderLevel; |
457 | sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); | 459 | sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); |
458 | sVertexProgram->disableTexture(LLViewerShaderMgr::SPECULAR_MAP); | 460 | sVertexProgram->disableTexture(LLViewerShaderMgr::SPECULAR_MAP); |
461 | sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); // KL SD | ||
459 | sVertexProgram->unbind(); | 462 | sVertexProgram->unbind(); |
460 | gGL.getTexUnit(0)->activate(); | 463 | gGL.getTexUnit(0)->activate(); |
461 | } | 464 | } |
@@ -699,7 +702,8 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) | |||
699 | avatarp->mImpostor.bindTexture(1, specular_channel); | 702 | avatarp->mImpostor.bindTexture(1, specular_channel); |
700 | } | 703 | } |
701 | } | 704 | } |
702 | avatarp->renderImpostor(); | 705 | // avatarp->renderImpostor(LLColor4U(255,255,255,255), diffuse_channel); // KL SD |
706 | avatarp->renderImpostor(); | ||
703 | } | 707 | } |
704 | else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS) && !LLPipeline::sRenderDeferred) | 708 | else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS) && !LLPipeline::sRenderDeferred) |
705 | { | 709 | { |
@@ -752,6 +756,67 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) | |||
752 | 756 | ||
753 | if( !single_avatar || (avatarp == single_avatar) ) | 757 | if( !single_avatar || (avatarp == single_avatar) ) |
754 | { | 758 | { |
759 | if (LLVOAvatar::sShowCollisionVolumes) | ||
760 | { | ||
761 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
762 | avatarp->renderCollisionVolumes(); | ||
763 | } | ||
764 | |||
765 | if (avatarp->isSelf() && LLAgent::sDebugDisplayTarget) | ||
766 | { | ||
767 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
768 | LLVector3 pos = avatarp->getPositionAgent(); | ||
769 | |||
770 | gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f); | ||
771 | gGL.begin(LLRender::LINES); | ||
772 | { | ||
773 | gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); | ||
774 | gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); | ||
775 | gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV); | ||
776 | gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV); | ||
777 | gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV); | ||
778 | gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV); | ||
779 | }gGL.end(); | ||
780 | |||
781 | pos = avatarp->mDrawable->getPositionAgent(); | ||
782 | gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f); | ||
783 | gGL.begin(LLRender::LINES); | ||
784 | { | ||
785 | gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); | ||
786 | gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); | ||
787 | gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV); | ||
788 | gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV); | ||
789 | gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV); | ||
790 | gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV); | ||
791 | }gGL.end(); | ||
792 | |||
793 | pos = avatarp->mRoot.getWorldPosition(); | ||
794 | gGL.color4f(1.0f, 1.0f, 1.0f, 0.8f); | ||
795 | gGL.begin(LLRender::LINES); | ||
796 | { | ||
797 | gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); | ||
798 | gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); | ||
799 | gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV); | ||
800 | gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV); | ||
801 | gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV); | ||
802 | gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV); | ||
803 | }gGL.end(); | ||
804 | |||
805 | pos = avatarp->mPelvisp->getWorldPosition(); | ||
806 | gGL.color4f(0.0f, 0.0f, 1.0f, 0.8f); | ||
807 | gGL.begin(LLRender::LINES); | ||
808 | { | ||
809 | gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); | ||
810 | gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); | ||
811 | gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV); | ||
812 | gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV); | ||
813 | gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV); | ||
814 | gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV); | ||
815 | }gGL.end(); | ||
816 | |||
817 | color.setColor(1.0f, 1.0f, 1.0f, 1.0f); | ||
818 | } | ||
819 | |||
755 | avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); | 820 | avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); |
756 | } | 821 | } |
757 | } | 822 | } |
diff --git a/linden/indra/newview/lldrawpoolbump.cpp b/linden/indra/newview/lldrawpoolbump.cpp index fb7a213..dcaa742 100644 --- a/linden/indra/newview/lldrawpoolbump.cpp +++ b/linden/indra/newview/lldrawpoolbump.cpp | |||
@@ -140,7 +140,7 @@ void LLStandardBumpmap::restoreGL() | |||
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | llinfos << "Loading bumpmap: " << bump_file << " from viewerart" << llendl; | 143 | // llinfos << "Loading bumpmap: " << bump_file << " from viewerart" << llendl; |
144 | gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mLabel = label; | 144 | gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mLabel = label; |
145 | gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage = | 145 | gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage = |
146 | gImageList.getImageFromFile(bump_file, | 146 | gImageList.getImageFromFile(bump_file, |
@@ -309,8 +309,8 @@ void LLDrawPoolBump::endRenderPass(S32 pass) | |||
309 | void LLDrawPoolBump::beginShiny(bool invisible) | 309 | void LLDrawPoolBump::beginShiny(bool invisible) |
310 | { | 310 | { |
311 | LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY); | 311 | LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY); |
312 | if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| | 312 | if (!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY)|| |
313 | (invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY))) | 313 | invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)) |
314 | { | 314 | { |
315 | return; | 315 | return; |
316 | } | 316 | } |
@@ -384,8 +384,8 @@ void LLDrawPoolBump::beginShiny(bool invisible) | |||
384 | void LLDrawPoolBump::renderShiny(bool invisible) | 384 | void LLDrawPoolBump::renderShiny(bool invisible) |
385 | { | 385 | { |
386 | LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY); | 386 | LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY); |
387 | if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| | 387 | if (!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY)|| |
388 | (invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY))) | 388 | invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)) |
389 | { | 389 | { |
390 | return; | 390 | return; |
391 | } | 391 | } |
@@ -411,8 +411,8 @@ void LLDrawPoolBump::renderShiny(bool invisible) | |||
411 | void LLDrawPoolBump::endShiny(bool invisible) | 411 | void LLDrawPoolBump::endShiny(bool invisible) |
412 | { | 412 | { |
413 | LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY); | 413 | LLFastTimer t(LLFastTimer::FTM_RENDER_SHINY); |
414 | if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| | 414 | if (!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY)|| |
415 | (invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY))) | 415 | invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)) |
416 | { | 416 | { |
417 | return; | 417 | return; |
418 | } | 418 | } |
@@ -572,7 +572,11 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel) | |||
572 | LLImageGL* bump = NULL; | 572 | LLImageGL* bump = NULL; |
573 | 573 | ||
574 | U8 bump_code = params.mBump; | 574 | U8 bump_code = params.mBump; |
575 | LLViewerImage* tex = params.mTexture; | 575 | LLViewerImage* tex = params.mViewerTexture; |
576 | if(!tex) | ||
577 | { | ||
578 | return FALSE ; | ||
579 | } | ||
576 | 580 | ||
577 | switch( bump_code ) | 581 | switch( bump_code ) |
578 | { | 582 | { |
@@ -1226,7 +1230,10 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) | |||
1226 | if (params.mTexture.notNull()) | 1230 | if (params.mTexture.notNull()) |
1227 | { | 1231 | { |
1228 | gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get()); | 1232 | gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get()); |
1229 | //params.mTexture->addTextureStats(params.mVSize); | 1233 | if(params.mViewerTexture.notNull()) |
1234 | { | ||
1235 | params.mViewerTexture->addTextureStats(params.mVSize); | ||
1236 | } | ||
1230 | } | 1237 | } |
1231 | else | 1238 | else |
1232 | { | 1239 | { |
diff --git a/linden/indra/newview/lldrawpoolsky.cpp b/linden/indra/newview/lldrawpoolsky.cpp index f0ed380..7f21adc 100644 --- a/linden/indra/newview/lldrawpoolsky.cpp +++ b/linden/indra/newview/lldrawpoolsky.cpp | |||
@@ -61,8 +61,8 @@ LLDrawPool *LLDrawPoolSky::instancePool() | |||
61 | 61 | ||
62 | void LLDrawPoolSky::prerender() | 62 | void LLDrawPoolSky::prerender() |
63 | { | 63 | { |
64 | mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); | 64 | mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); |
65 | gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); | 65 | // gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); |
66 | } | 66 | } |
67 | 67 | ||
68 | void LLDrawPoolSky::render(S32 pass) | 68 | void LLDrawPoolSky::render(S32 pass) |
@@ -97,6 +97,7 @@ void LLDrawPoolSky::render(S32 pass) | |||
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | LLVOSky *voskyp = gSky.mVOSkyp; | ||
100 | LLGLSPipelineSkyBox gls_skybox; | 101 | LLGLSPipelineSkyBox gls_skybox; |
101 | 102 | ||
102 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); | 103 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); |
@@ -119,9 +120,43 @@ void LLDrawPoolSky::render(S32 pass) | |||
119 | { | 120 | { |
120 | renderSkyCubeFace(i); | 121 | renderSkyCubeFace(i); |
121 | } | 122 | } |
123 | |||
124 | LLFace *hbfaces[3]; | ||
125 | hbfaces[0] = NULL; | ||
126 | hbfaces[1] = NULL; | ||
127 | hbfaces[2] = NULL; | ||
128 | for (S32 curr_face = 0; curr_face < face_count; curr_face++) | ||
129 | { | ||
130 | LLFace* facep = mDrawFace[curr_face]; | ||
131 | if (voskyp->isSameFace(LLVOSky::FACE_SUN, facep)) | ||
132 | { | ||
133 | hbfaces[0] = facep; | ||
134 | } | ||
135 | if (voskyp->isSameFace(LLVOSky::FACE_MOON, facep)) | ||
136 | { | ||
137 | hbfaces[1] = facep; | ||
138 | } | ||
139 | if (voskyp->isSameFace(LLVOSky::FACE_BLOOM, facep)) | ||
140 | { | ||
141 | hbfaces[2] = facep; | ||
142 | } | ||
143 | } | ||
122 | 144 | ||
123 | LLGLEnable blend(GL_BLEND); | 145 | LLGLEnable blend(GL_BLEND); |
124 | 146 | ||
147 | if (hbfaces[2]) | ||
148 | { | ||
149 | // renderSunHalo(hbfaces[2]); | ||
150 | } | ||
151 | if (hbfaces[0]) | ||
152 | { | ||
153 | // renderHeavenlyBody(0, hbfaces[0]); | ||
154 | } | ||
155 | if (hbfaces[1]) | ||
156 | { | ||
157 | // renderHeavenlyBody(1, hbfaces[1]); | ||
158 | } | ||
159 | |||
125 | glPopMatrix(); | 160 | glPopMatrix(); |
126 | } | 161 | } |
127 | 162 | ||
@@ -146,6 +181,35 @@ void LLDrawPoolSky::renderSkyCubeFace(U8 side) | |||
146 | } | 181 | } |
147 | } | 182 | } |
148 | 183 | ||
184 | void LLDrawPoolSky::renderHeavenlyBody(U8 hb, LLFace* face) | ||
185 | { | ||
186 | if ( !mHB[hb]->getDraw() ) return; | ||
187 | if (! face->getGeomCount()) return; | ||
188 | |||
189 | LLImageGL* tex = face->getTexture(); | ||
190 | gGL.getTexUnit(0)->bind(tex); | ||
191 | LLColor4 color(mHB[hb]->getInterpColor()); | ||
192 | LLOverrideFaceColor override(this, color); | ||
193 | face->renderIndexed(); | ||
194 | } | ||
195 | |||
196 | |||
197 | |||
198 | void LLDrawPoolSky::renderSunHalo(LLFace* face) | ||
199 | { | ||
200 | if (! mHB[0]->getDraw()) return; | ||
201 | if (! face->getGeomCount()) return; | ||
202 | |||
203 | LLImageGL* tex = face->getTexture(); | ||
204 | gGL.getTexUnit(0)->bind(tex); | ||
205 | LLColor4 color(mHB[0]->getInterpColor()); | ||
206 | color.mV[3] = llclamp(mHB[0]->getHaloBrighness(), 0.f, 1.f); | ||
207 | |||
208 | LLOverrideFaceColor override(this, color); | ||
209 | face->renderIndexed(); | ||
210 | } | ||
211 | |||
212 | |||
149 | void LLDrawPoolSky::renderForSelect() | 213 | void LLDrawPoolSky::renderForSelect() |
150 | { | 214 | { |
151 | } | 215 | } |
diff --git a/linden/indra/newview/lldrawpoolsky.h b/linden/indra/newview/lldrawpoolsky.h index 8595d73..f35b114 100644 --- a/linden/indra/newview/lldrawpoolsky.h +++ b/linden/indra/newview/lldrawpoolsky.h | |||
@@ -36,12 +36,14 @@ | |||
36 | #include "lldrawpool.h" | 36 | #include "lldrawpool.h" |
37 | 37 | ||
38 | class LLSkyTex; | 38 | class LLSkyTex; |
39 | class LLHeavenBody; | ||
39 | class LLGLSLShader; | 40 | class LLGLSLShader; |
40 | 41 | ||
41 | class LLDrawPoolSky : public LLFacePool | 42 | class LLDrawPoolSky : public LLFacePool |
42 | { | 43 | { |
43 | private: | 44 | private: |
44 | LLSkyTex *mSkyTex; | 45 | LLSkyTex *mSkyTex; |
46 | LLHeavenBody *mHB[2]; // Sun and Moon | ||
45 | LLGLSLShader *mShader; | 47 | LLGLSLShader *mShader; |
46 | 48 | ||
47 | public: | 49 | public: |
@@ -67,6 +69,8 @@ public: | |||
67 | /*virtual*/ void renderForSelect(); | 69 | /*virtual*/ void renderForSelect(); |
68 | /*virtual*/ void endRenderPass(S32 pass); | 70 | /*virtual*/ void endRenderPass(S32 pass); |
69 | void setSkyTex(LLSkyTex* const st) { mSkyTex = st; } | 71 | void setSkyTex(LLSkyTex* const st) { mSkyTex = st; } |
72 | void setSun(LLHeavenBody* sun_flag) { mHB[0] = sun_flag; } | ||
73 | void setMoon(LLHeavenBody* moon) { mHB[1] = moon; } | ||
70 | 74 | ||
71 | void renderSkyCubeFace(U8 side); | 75 | void renderSkyCubeFace(U8 side); |
72 | void renderHeavenlyBody(U8 hb, LLFace* face); | 76 | void renderHeavenlyBody(U8 hb, LLFace* face); |
diff --git a/linden/indra/newview/lldrawpoolterrain.cpp b/linden/indra/newview/lldrawpoolterrain.cpp index cac5162..3ee955a 100644 --- a/linden/indra/newview/lldrawpoolterrain.cpp +++ b/linden/indra/newview/lldrawpoolterrain.cpp | |||
@@ -73,19 +73,19 @@ LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) : | |||
73 | TRUE, TRUE, GL_ALPHA8, GL_ALPHA, | 73 | TRUE, TRUE, GL_ALPHA8, GL_ALPHA, |
74 | LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb")); | 74 | LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb")); |
75 | 75 | ||
76 | gGL.getTexUnit(0)->bind(mAlphaRampImagep.get()); | 76 | //gGL.getTexUnit(0)->bind(mAlphaRampImagep.get()); |
77 | mAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); | 77 | mAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); |
78 | 78 | ||
79 | m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c", | 79 | m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c", |
80 | TRUE, TRUE, GL_ALPHA8, GL_ALPHA, | 80 | TRUE, TRUE, GL_ALPHA8, GL_ALPHA, |
81 | LLUUID("38b86f85-2575-52a9-a531-23108d8da837")); | 81 | LLUUID("38b86f85-2575-52a9-a531-23108d8da837")); |
82 | 82 | ||
83 | gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); | 83 | //gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); |
84 | m2DAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); | 84 | m2DAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); |
85 | 85 | ||
86 | mTexturep->setBoostLevel(LLViewerImageBoostLevel::BOOST_TERRAIN); | 86 | mTexturep->setBoostLevel(LLViewerImageBoostLevel::BOOST_TERRAIN); |
87 | 87 | ||
88 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | 88 | //gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
89 | } | 89 | } |
90 | 90 | ||
91 | LLDrawPoolTerrain::~LLDrawPoolTerrain() | 91 | LLDrawPoolTerrain::~LLDrawPoolTerrain() |
diff --git a/linden/indra/newview/lldrawpooltree.cpp b/linden/indra/newview/lldrawpooltree.cpp index 46cd2d5..873f0f6 100644 --- a/linden/indra/newview/lldrawpooltree.cpp +++ b/linden/indra/newview/lldrawpooltree.cpp | |||
@@ -52,7 +52,7 @@ LLDrawPoolTree::LLDrawPoolTree(LLViewerImage *texturep) : | |||
52 | LLFacePool(POOL_TREE), | 52 | LLFacePool(POOL_TREE), |
53 | mTexturep(texturep) | 53 | mTexturep(texturep) |
54 | { | 54 | { |
55 | gGL.getTexUnit(0)->bind(mTexturep.get()); | 55 | // gGL.getTexUnit(0)->bind(mTexturep.get()); |
56 | mTexturep->setAddressMode(LLTexUnit::TAM_WRAP); | 56 | mTexturep->setAddressMode(LLTexUnit::TAM_WRAP); |
57 | } | 57 | } |
58 | 58 | ||
@@ -108,7 +108,7 @@ void LLDrawPoolTree::render(S32 pass) | |||
108 | } | 108 | } |
109 | else | 109 | else |
110 | { | 110 | { |
111 | gGL.getTexUnit(sDiffTex)->bind(mTexturep); | 111 | gGL.getTexUnit(sDiffTex)->bind(mTexturep, TRUE); |
112 | 112 | ||
113 | for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); | 113 | for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); |
114 | iter != mDrawFace.end(); iter++) | 114 | iter != mDrawFace.end(); iter++) |
@@ -138,7 +138,7 @@ void LLDrawPoolTree::endRenderPass(S32 pass) | |||
138 | void LLDrawPoolTree::beginDeferredPass(S32 pass) | 138 | void LLDrawPoolTree::beginDeferredPass(S32 pass) |
139 | { | 139 | { |
140 | LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); | 140 | LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); |
141 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); | 141 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); // KL Render-pipeline has this set at 0.f ... NOOOOOO! make shitty trees :) |
142 | 142 | ||
143 | shader = &gDeferredTreeProgram; | 143 | shader = &gDeferredTreeProgram; |
144 | shader->bind(); | 144 | shader->bind(); |
@@ -164,6 +164,9 @@ void LLDrawPoolTree::beginShadowPass(S32 pass) | |||
164 | { | 164 | { |
165 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); | 165 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); |
166 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); | 166 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); |
167 | glPolygonOffset(gSavedSettings.getF32("RenderDeferredTreeShadowOffset"), | ||
168 | gSavedSettings.getF32("RenderDeferredTreeShadowBias")); | ||
169 | |||
167 | gDeferredShadowProgram.bind(); | 170 | gDeferredShadowProgram.bind(); |
168 | } | 171 | } |
169 | 172 | ||
@@ -176,7 +179,11 @@ void LLDrawPoolTree::endShadowPass(S32 pass) | |||
176 | { | 179 | { |
177 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); | 180 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); |
178 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | 181 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); |
179 | gDeferredShadowProgram.unbind(); | 182 | |
183 | glPolygonOffset(gSavedSettings.getF32("RenderDeferredSpotShadowOffset"), | ||
184 | gSavedSettings.getF32("RenderDeferredSpotShadowBias")); | ||
185 | |||
186 | //gDeferredShadowProgram.unbind(); | ||
180 | } | 187 | } |
181 | 188 | ||
182 | 189 | ||
diff --git a/linden/indra/newview/lldrawpoolwater.cpp b/linden/indra/newview/lldrawpoolwater.cpp index ce3425d..5c0363e 100644 --- a/linden/indra/newview/lldrawpoolwater.cpp +++ b/linden/indra/newview/lldrawpoolwater.cpp | |||
@@ -98,7 +98,7 @@ void LLDrawPoolWater::restoreGL() | |||
98 | 98 | ||
99 | LLDrawPool *LLDrawPoolWater::instancePool() | 99 | LLDrawPool *LLDrawPoolWater::instancePool() |
100 | { | 100 | { |
101 | llerrs << "Should never be calling instancePool on a water pool!" << llendl; | 101 | llwarns << "Should never be calling instancePool on a water pool!" << llendl; |
102 | return NULL; | 102 | return NULL; |
103 | } | 103 | } |
104 | 104 | ||
@@ -401,6 +401,15 @@ void LLDrawPoolWater::shade() | |||
401 | shader = &gWaterProgram; | 401 | shader = &gWaterProgram; |
402 | } | 402 | } |
403 | 403 | ||
404 | if (deferred_render) | ||
405 | { | ||
406 | gPipeline.bindDeferredShader(*shader); | ||
407 | } | ||
408 | else | ||
409 | { | ||
410 | shader->bind(); | ||
411 | } | ||
412 | |||
404 | sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; | 413 | sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; |
405 | 414 | ||
406 | S32 reftex = shader->enableTexture(LLViewerShaderMgr::WATER_REFTEX); | 415 | S32 reftex = shader->enableTexture(LLViewerShaderMgr::WATER_REFTEX); |
@@ -436,15 +445,6 @@ void LLDrawPoolWater::shade() | |||
436 | 445 | ||
437 | S32 screentex = shader->enableTexture(LLViewerShaderMgr::WATER_SCREENTEX); | 446 | S32 screentex = shader->enableTexture(LLViewerShaderMgr::WATER_SCREENTEX); |
438 | 447 | ||
439 | if (deferred_render) | ||
440 | { | ||
441 | gPipeline.bindDeferredShader(*shader); | ||
442 | } | ||
443 | else | ||
444 | { | ||
445 | shader->bind(); | ||
446 | } | ||
447 | |||
448 | if (screentex > -1) | 448 | if (screentex > -1) |
449 | { | 449 | { |
450 | shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); | 450 | shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); |
diff --git a/linden/indra/newview/lldynamictexture.cpp b/linden/indra/newview/lldynamictexture.cpp index 61f5a89..e219d4b 100644 --- a/linden/indra/newview/lldynamictexture.cpp +++ b/linden/indra/newview/lldynamictexture.cpp | |||
@@ -41,6 +41,7 @@ | |||
41 | #include "llvertexbuffer.h" | 41 | #include "llvertexbuffer.h" |
42 | #include "llviewerdisplay.h" | 42 | #include "llviewerdisplay.h" |
43 | #include "llrender.h" | 43 | #include "llrender.h" |
44 | #include "pipeline.h" | ||
44 | 45 | ||
45 | // static | 46 | // static |
46 | LLDynamicTexture::instance_list_t LLDynamicTexture::sInstances[ LLDynamicTexture::ORDER_COUNT ]; | 47 | LLDynamicTexture::instance_list_t LLDynamicTexture::sInstances[ LLDynamicTexture::ORDER_COUNT ]; |
@@ -58,9 +59,14 @@ LLDynamicTexture::LLDynamicTexture(S32 width, S32 height, S32 components, EOrder | |||
58 | mClamp(clamp) | 59 | mClamp(clamp) |
59 | { | 60 | { |
60 | llassert((1 <= components) && (components <= 4)); | 61 | llassert((1 <= components) && (components <= 4)); |
61 | 62 | if(!LLPipeline::sRenderDeferred) | |
62 | generateGLTexture(); | 63 | { |
63 | 64 | generateGLTexture(); | |
65 | } | ||
66 | else | ||
67 | { | ||
68 | gPipeline.markGLRebuild(this); // KL SD well for this to work its either gotta be one or the other so lets slap in the if/else can't do any harm. | ||
69 | } | ||
64 | llassert( 0 <= order && order < ORDER_COUNT ); | 70 | llassert( 0 <= order && order < ORDER_COUNT ); |
65 | LLDynamicTexture::sInstances[ order ].insert(this); | 71 | LLDynamicTexture::sInstances[ order ].insert(this); |
66 | } | 72 | } |
@@ -77,6 +83,11 @@ LLDynamicTexture::~LLDynamicTexture() | |||
77 | } | 83 | } |
78 | } | 84 | } |
79 | 85 | ||
86 | void LLDynamicTexture::updateGL() | ||
87 | { | ||
88 | generateGLTexture(); | ||
89 | } | ||
90 | |||
80 | //----------------------------------------------------------------------------- | 91 | //----------------------------------------------------------------------------- |
81 | // releaseGLTexture() | 92 | // releaseGLTexture() |
82 | //----------------------------------------------------------------------------- | 93 | //----------------------------------------------------------------------------- |
@@ -101,7 +112,7 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima | |||
101 | { | 112 | { |
102 | if (mComponents < 1 || mComponents > 4) | 113 | if (mComponents < 1 || mComponents > 4) |
103 | { | 114 | { |
104 | llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl; | 115 | llwarns << "Bad number of components in dynamic texture: " << mComponents << llendl; |
105 | } | 116 | } |
106 | releaseGLTexture(); | 117 | releaseGLTexture(); |
107 | LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents); | 118 | LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents); |
@@ -111,7 +122,7 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima | |||
111 | mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes); | 122 | mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes); |
112 | } | 123 | } |
113 | // llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl; | 124 | // llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl; |
114 | mTexture->createGLTexture(0, raw_image, 0, TRUE, LLViewerImageBoostLevel::DYNAMIC_TEX); | 125 | mTexture->createGLTexture(0, raw_image); |
115 | mTexture->setAddressMode((mClamp) ? LLTexUnit::TAM_CLAMP : LLTexUnit::TAM_WRAP); | 126 | mTexture->setAddressMode((mClamp) ? LLTexUnit::TAM_CLAMP : LLTexUnit::TAM_WRAP); |
116 | mTexture->setGLTextureCreated(false); | 127 | mTexture->setGLTextureCreated(false); |
117 | } | 128 | } |
diff --git a/linden/indra/newview/lldynamictexture.h b/linden/indra/newview/lldynamictexture.h index 5a20eae..1480799 100644 --- a/linden/indra/newview/lldynamictexture.h +++ b/linden/indra/newview/lldynamictexture.h | |||
@@ -37,7 +37,7 @@ | |||
37 | #include "llcoord.h" | 37 | #include "llcoord.h" |
38 | #include "llimagegl.h" | 38 | #include "llimagegl.h" |
39 | 39 | ||
40 | class LLDynamicTexture | 40 | class LLDynamicTexture : public LLGLUpdate |
41 | { | 41 | { |
42 | public: | 42 | public: |
43 | enum EOrder { ORDER_FIRST = 0, ORDER_MIDDLE = 1, ORDER_LAST = 2, ORDER_RESET = 3, ORDER_COUNT = 4 }; | 43 | enum EOrder { ORDER_FIRST = 0, ORDER_MIDDLE = 1, ORDER_LAST = 2, ORDER_RESET = 3, ORDER_COUNT = 4 }; |
@@ -49,6 +49,8 @@ public: | |||
49 | BOOL clamp); | 49 | BOOL clamp); |
50 | virtual ~LLDynamicTexture(); | 50 | virtual ~LLDynamicTexture(); |
51 | 51 | ||
52 | void updateGL(); | ||
53 | |||
52 | S32 getOriginX() { return mOrigin.mX; } | 54 | S32 getOriginX() { return mOrigin.mX; } |
53 | S32 getOriginY() { return mOrigin.mY; } | 55 | S32 getOriginY() { return mOrigin.mY; } |
54 | S32 getWidth() { return mWidth; } | 56 | S32 getWidth() { return mWidth; } |
diff --git a/linden/indra/newview/llface.cpp b/linden/indra/newview/llface.cpp index aa8cd15..ae57a3c 100644 --- a/linden/indra/newview/llface.cpp +++ b/linden/indra/newview/llface.cpp | |||
@@ -176,8 +176,8 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) | |||
176 | mLastIndicesCount = mIndicesCount; | 176 | mLastIndicesCount = mIndicesCount; |
177 | mLastIndicesIndex = mIndicesIndex; | 177 | mLastIndicesIndex = mIndicesIndex; |
178 | 178 | ||
179 | mImportanceToCamera = 0.f ; | 179 | mAtlasInfop = NULL ; |
180 | mBoundingSphereRadius = 0.0f ; | 180 | mUsingAtlas = FALSE ; |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
@@ -205,12 +205,14 @@ void LLFace::destroy() | |||
205 | if (group) | 205 | if (group) |
206 | { | 206 | { |
207 | group->dirtyGeom(); | 207 | group->dirtyGeom(); |
208 | gPipeline.markRebuild(group, TRUE); | ||
208 | } | 209 | } |
209 | } | 210 | } |
210 | } | 211 | } |
211 | 212 | ||
212 | setDrawInfo(NULL); | 213 | setDrawInfo(NULL); |
213 | 214 | ||
215 | removeAtlas(); | ||
214 | mDrawablep = NULL; | 216 | mDrawablep = NULL; |
215 | mVObjp = NULL; | 217 | mVObjp = NULL; |
216 | } | 218 | } |
@@ -223,7 +225,7 @@ void LLFace::initClass() | |||
223 | 225 | ||
224 | void LLFace::setWorldMatrix(const LLMatrix4 &mat) | 226 | void LLFace::setWorldMatrix(const LLMatrix4 &mat) |
225 | { | 227 | { |
226 | llerrs << "Faces on this drawable are not independently modifiable\n" << llendl; | 228 | llwarns << "Faces on this drawable are not independently modifiable\n" << llendl; |
227 | } | 229 | } |
228 | 230 | ||
229 | void LLFace::setPool(LLFacePool* new_pool, LLViewerImage *texturep) | 231 | void LLFace::setPool(LLFacePool* new_pool, LLViewerImage *texturep) |
@@ -232,7 +234,7 @@ void LLFace::setPool(LLFacePool* new_pool, LLViewerImage *texturep) | |||
232 | 234 | ||
233 | if (!new_pool) | 235 | if (!new_pool) |
234 | { | 236 | { |
235 | llerrs << "Setting pool to null!" << llendl; | 237 | llwarns << "Setting pool to null!" << llendl; |
236 | } | 238 | } |
237 | 239 | ||
238 | if (new_pool != mDrawPoolp) | 240 | if (new_pool != mDrawPoolp) |
@@ -270,6 +272,7 @@ void LLFace::setTexture(LLViewerImage* tex) | |||
270 | if(mTexture.notNull()) | 272 | if(mTexture.notNull()) |
271 | { | 273 | { |
272 | mTexture->removeFace(this) ; | 274 | mTexture->removeFace(this) ; |
275 | removeAtlas() ; | ||
273 | } | 276 | } |
274 | 277 | ||
275 | mTexture = tex ; | 278 | mTexture = tex ; |
@@ -453,8 +456,15 @@ void LLFace::renderForSelect(U32 data_mask) | |||
453 | 456 | ||
454 | void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color) | 457 | void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color) |
455 | { | 458 | { |
456 | if(mDrawablep.isNull() || mVertexBuffer.isNull() || mDrawablep->getSpatialGroup() == NULL || | 459 | if (mDrawablep->getSpatialGroup() == NULL) |
457 | mDrawablep->getSpatialGroup()->isState(LLSpatialGroup::GEOM_DIRTY)) | 460 | { |
461 | return; | ||
462 | } | ||
463 | |||
464 | mDrawablep->getSpatialGroup()->rebuildGeom(); | ||
465 | mDrawablep->getSpatialGroup()->rebuildMesh(); | ||
466 | |||
467 | if(mDrawablep.isNull() || mVertexBuffer.isNull()) | ||
458 | { | 468 | { |
459 | return; | 469 | return; |
460 | } | 470 | } |
@@ -473,17 +483,10 @@ void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color) | |||
473 | glMultMatrixf((GLfloat*)mDrawablep->getRegion()->mRenderMatrix.mMatrix); | 483 | glMultMatrixf((GLfloat*)mDrawablep->getRegion()->mRenderMatrix.mMatrix); |
474 | } | 484 | } |
475 | 485 | ||
476 | setFaceColor(color); | 486 | glColor4fv(color.mV); |
477 | renderSetColor(); | ||
478 | |||
479 | mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); | 487 | mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); |
480 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
481 | LLGLState::checkClientArrays("", LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); | ||
482 | #endif | ||
483 | mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); | 488 | mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); |
484 | 489 | ||
485 | unsetFaceColor(); | ||
486 | unsetFaceColor(); | ||
487 | gGL.popMatrix(); | 490 | gGL.popMatrix(); |
488 | } | 491 | } |
489 | } | 492 | } |
@@ -727,8 +730,8 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, | |||
727 | } | 730 | } |
728 | 731 | ||
729 | mCenterLocal = (newMin+newMax)*0.5f; | 732 | mCenterLocal = (newMin+newMax)*0.5f; |
730 | LLVector3 tmp = (newMin - newMax) ; | 733 | // LLVector3 tmp = (newMin - newMax) ; |
731 | mBoundingSphereRadius = tmp.length() * 0.5f ; | 734 | // mBoundingSphereRadius = tmp.length() * 0.5f ; |
732 | 735 | ||
733 | updateCenterAgent(); | 736 | updateCenterAgent(); |
734 | } | 737 | } |
@@ -963,6 +966,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
963 | mVertexBuffer->getBinormalStrider(binormals, mGeomIndex); | 966 | mVertexBuffer->getBinormalStrider(binormals, mGeomIndex); |
964 | } | 967 | } |
965 | 968 | ||
969 | F32 tcoord_xoffset = 0.f ; | ||
970 | F32 tcoord_yoffset = 0.f ; | ||
971 | F32 tcoord_xscale = 1.f ; | ||
972 | F32 tcoord_yscale = 1.f ; | ||
973 | BOOL in_atlas = FALSE ; | ||
974 | |||
966 | if (rebuild_tcoord) | 975 | if (rebuild_tcoord) |
967 | { | 976 | { |
968 | mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex); | 977 | mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex); |
@@ -970,6 +979,18 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
970 | { | 979 | { |
971 | mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex); | 980 | mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex); |
972 | } | 981 | } |
982 | |||
983 | in_atlas = isAtlasInUse() ; | ||
984 | if(in_atlas) | ||
985 | { | ||
986 | const LLVector2* tmp = getTexCoordOffset() ; | ||
987 | tcoord_xoffset = tmp->mV[0] ; | ||
988 | tcoord_yoffset = tmp->mV[1] ; | ||
989 | |||
990 | tmp = getTexCoordScale() ; | ||
991 | tcoord_xscale = tmp->mV[0] ; | ||
992 | tcoord_yscale = tmp->mV[1] ; | ||
993 | } | ||
973 | } | 994 | } |
974 | if (rebuild_color) | 995 | if (rebuild_color) |
975 | { | 996 | { |
@@ -1057,7 +1078,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1057 | 0.75f | 1078 | 0.75f |
1058 | }; | 1079 | }; |
1059 | 1080 | ||
1060 | if (getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny()))) | 1081 | if (getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || LLPipeline::sRenderBump && tep->getShiny())) |
1061 | { | 1082 | { |
1062 | color.mV[3] = U8 (alpha[tep->getShiny()] * 255); | 1083 | color.mV[3] = U8 (alpha[tep->getShiny()] * 255); |
1063 | } | 1084 | } |
@@ -1179,6 +1200,93 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1179 | xform(tc, cos_ang, sin_ang, os, ot, ms, mt); | 1200 | xform(tc, cos_ang, sin_ang, os, ot, ms, mt); |
1180 | } | 1201 | } |
1181 | 1202 | ||
1203 | if(in_atlas) | ||
1204 | { | ||
1205 | // | ||
1206 | //manually calculate tex-coord per vertex for varying address modes. | ||
1207 | //should be removed if shader can handle this. | ||
1208 | // | ||
1209 | |||
1210 | S32 int_part = 0 ; | ||
1211 | switch(mTexture->getAddressMode()) | ||
1212 | { | ||
1213 | case LLTexUnit::TAM_CLAMP: | ||
1214 | if(tc.mV[0] < 0.f) | ||
1215 | { | ||
1216 | tc.mV[0] = 0.f ; | ||
1217 | } | ||
1218 | else if(tc.mV[0] > 1.f) | ||
1219 | { | ||
1220 | tc.mV[0] = 1.f; | ||
1221 | } | ||
1222 | |||
1223 | if(tc.mV[1] < 0.f) | ||
1224 | { | ||
1225 | tc.mV[1] = 0.f ; | ||
1226 | } | ||
1227 | else if(tc.mV[1] > 1.f) | ||
1228 | { | ||
1229 | tc.mV[1] = 1.f; | ||
1230 | } | ||
1231 | break; | ||
1232 | case LLTexUnit::TAM_MIRROR: | ||
1233 | if(tc.mV[0] < 0.f) | ||
1234 | { | ||
1235 | tc.mV[0] = -tc.mV[0] ; | ||
1236 | } | ||
1237 | int_part = (S32)tc.mV[0] ; | ||
1238 | if(int_part & 1) //odd number | ||
1239 | { | ||
1240 | tc.mV[0] = int_part + 1 - tc.mV[0] ; | ||
1241 | } | ||
1242 | else //even number | ||
1243 | { | ||
1244 | tc.mV[0] -= int_part ; | ||
1245 | } | ||
1246 | |||
1247 | if(tc.mV[1] < 0.f) | ||
1248 | { | ||
1249 | tc.mV[1] = -tc.mV[1] ; | ||
1250 | } | ||
1251 | int_part = (S32)tc.mV[1] ; | ||
1252 | if(int_part & 1) //odd number | ||
1253 | { | ||
1254 | tc.mV[1] = int_part + 1 - tc.mV[1] ; | ||
1255 | } | ||
1256 | else //even number | ||
1257 | { | ||
1258 | tc.mV[1] -= int_part ; | ||
1259 | } | ||
1260 | break; | ||
1261 | case LLTexUnit::TAM_WRAP: | ||
1262 | if(tc.mV[0] > 1.f) | ||
1263 | tc.mV[0] -= (S32)(tc.mV[0] - 0.00001f) ; | ||
1264 | else if(tc.mV[0] < -1.f) | ||
1265 | tc.mV[0] -= (S32)(tc.mV[0] + 0.00001f) ; | ||
1266 | |||
1267 | if(tc.mV[1] > 1.f) | ||
1268 | tc.mV[1] -= (S32)(tc.mV[1] - 0.00001f) ; | ||
1269 | else if(tc.mV[1] < -1.f) | ||
1270 | tc.mV[1] -= (S32)(tc.mV[1] + 0.00001f) ; | ||
1271 | |||
1272 | if(tc.mV[0] < 0.f) | ||
1273 | { | ||
1274 | tc.mV[0] = 1.0f + tc.mV[0] ; | ||
1275 | } | ||
1276 | if(tc.mV[1] < 0.f) | ||
1277 | { | ||
1278 | tc.mV[1] = 1.0f + tc.mV[1] ; | ||
1279 | } | ||
1280 | break; | ||
1281 | default: | ||
1282 | break; | ||
1283 | } | ||
1284 | |||
1285 | tc.mV[0] = tcoord_xoffset + tcoord_xscale * tc.mV[0] ; | ||
1286 | tc.mV[1] = tcoord_yoffset + tcoord_yscale * tc.mV[1] ; | ||
1287 | } | ||
1288 | |||
1289 | |||
1182 | *tex_coords++ = tc; | 1290 | *tex_coords++ = tc; |
1183 | 1291 | ||
1184 | if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1)) | 1292 | if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1)) |
@@ -1245,159 +1353,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1245 | return TRUE; | 1353 | return TRUE; |
1246 | } | 1354 | } |
1247 | 1355 | ||
1248 | const F32 LEAST_IMPORTANCE = 0.05f ; | ||
1249 | const F32 LEAST_IMPORTANCE_FOR_LARGE_IMAGE = 0.3f ; | ||
1250 | |||
1251 | F32 LLFace::getTextureVirtualSize() | ||
1252 | { | ||
1253 | F32 radius; | ||
1254 | F32 cos_angle_to_view_dir; | ||
1255 | mPixelArea = calcPixelArea(cos_angle_to_view_dir, radius); | ||
1256 | |||
1257 | if (mPixelArea <= 0) | ||
1258 | { | ||
1259 | return 0.f; | ||
1260 | } | ||
1261 | |||
1262 | //get area of circle in texture space | ||
1263 | LLVector2 tdim = mTexExtents[1] - mTexExtents[0]; | ||
1264 | F32 texel_area = (tdim * 0.5f).lengthSquared()*3.14159f; | ||
1265 | if (texel_area <= 0) | ||
1266 | { | ||
1267 | // Probably animated, use default | ||
1268 | texel_area = 1.f; | ||
1269 | } | ||
1270 | |||
1271 | F32 face_area; | ||
1272 | if (mVObjp->isSculpted() && texel_area > 1.f) | ||
1273 | { | ||
1274 | //sculpts can break assumptions about texel area | ||
1275 | face_area = mPixelArea; | ||
1276 | } | ||
1277 | else | ||
1278 | { | ||
1279 | //apply texel area to face area to get accurate ratio | ||
1280 | //face_area /= llclamp(texel_area, 1.f/64.f, 16.f); | ||
1281 | face_area = mPixelArea / llclamp(texel_area, 0.015625f, 1024.f); | ||
1282 | } | ||
1283 | |||
1284 | if(face_area > LLViewerImage::sMaxSmallImageSize) | ||
1285 | { | ||
1286 | if(mImportanceToCamera < LEAST_IMPORTANCE) //if the face is not important, do not load hi-res. | ||
1287 | { | ||
1288 | face_area = LLViewerImage::sMaxSmallImageSize ; | ||
1289 | } | ||
1290 | else if(face_area > LLViewerImage::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping. | ||
1291 | { | ||
1292 | if(mImportanceToCamera < LEAST_IMPORTANCE_FOR_LARGE_IMAGE)//if the face is not important, do not load hi-res. | ||
1293 | { | ||
1294 | face_area = LLViewerImage::sMinLargeImageSize ; | ||
1295 | } | ||
1296 | else if(mTexture.notNull() && mTexture->isLargeImage()) | ||
1297 | { | ||
1298 | face_area *= adjustPartialOverlapPixelArea(cos_angle_to_view_dir, radius ); | ||
1299 | } | ||
1300 | } | ||
1301 | } | ||
1302 | |||
1303 | return face_area; | ||
1304 | } | ||
1305 | |||
1306 | F32 LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) | ||
1307 | { | ||
1308 | //get area of circle around face | ||
1309 | LLVector3 center = getPositionAgent(); | ||
1310 | LLVector3 size = (mExtents[1] - mExtents[0]) * 0.5f; | ||
1311 | |||
1312 | LLVector3 lookAt = center - LLViewerCamera::getInstance()->getOrigin(); | ||
1313 | F32 dist = lookAt.normVec() ; | ||
1314 | |||
1315 | //get area of circle around node | ||
1316 | F32 app_angle = atanf(size.length()/dist); | ||
1317 | radius = app_angle*LLDrawable::sCurPixelAngle; | ||
1318 | F32 face_area = radius*radius * 3.14159f; | ||
1319 | |||
1320 | if(dist < mBoundingSphereRadius) //camera is very close | ||
1321 | { | ||
1322 | cos_angle_to_view_dir = 1.0f ; | ||
1323 | mImportanceToCamera = 1.0f ; | ||
1324 | } | ||
1325 | else | ||
1326 | { | ||
1327 | cos_angle_to_view_dir = lookAt * LLViewerCamera::getInstance()->getXAxis() ; | ||
1328 | mImportanceToCamera = LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist) ; | ||
1329 | } | ||
1330 | |||
1331 | return face_area ; | ||
1332 | } | ||
1333 | |||
1334 | //the projection of the face partially overlaps with the screen | ||
1335 | F32 LLFace::adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius ) | ||
1336 | { | ||
1337 | F32 screen_radius = (F32)llmax(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()) ; | ||
1338 | F32 center_angle = acosf(cos_angle_to_view_dir) ; | ||
1339 | F32 d = center_angle * LLDrawable::sCurPixelAngle ; | ||
1340 | |||
1341 | if(d + radius > screen_radius + 5.f) | ||
1342 | { | ||
1343 | //---------------------------------------------- | ||
1344 | //calculate the intersection area of two circles | ||
1345 | //F32 radius_square = radius * radius ; | ||
1346 | //F32 d_square = d * d ; | ||
1347 | //F32 screen_radius_square = screen_radius * screen_radius ; | ||
1348 | //face_area = | ||
1349 | // radius_square * acosf((d_square + radius_square - screen_radius_square)/(2 * d * radius)) + | ||
1350 | // screen_radius_square * acosf((d_square + screen_radius_square - radius_square)/(2 * d * screen_radius)) - | ||
1351 | // 0.5f * sqrtf((-d + radius + screen_radius) * (d + radius - screen_radius) * (d - radius + screen_radius) * (d + radius + screen_radius)) ; | ||
1352 | //---------------------------------------------- | ||
1353 | |||
1354 | //the above calculation is too expensive | ||
1355 | //the below is a good estimation: bounding box of the bounding sphere: | ||
1356 | F32 alpha = 0.5f * (radius + screen_radius - d) / radius ; | ||
1357 | alpha = llclamp(alpha, 0.f, 1.f) ; | ||
1358 | return alpha * alpha ; | ||
1359 | } | ||
1360 | return 1.0f ; | ||
1361 | } | ||
1362 | |||
1363 | const S8 FACE_IMPORTANCE_LEVEL = 4 ; | ||
1364 | const F32 FACE_IMPORTANCE_TO_CAMERA_OVER_DISTANCE[FACE_IMPORTANCE_LEVEL][2] = //{distance, importance_weight} | ||
1365 | {{16.1f, 1.0f}, {32.1f, 0.5f}, {48.1f, 0.2f}, {96.1f, 0.05f} } ; | ||
1366 | const F32 FACE_IMPORTANCE_TO_CAMERA_OVER_ANGLE[FACE_IMPORTANCE_LEVEL][2] = //{cos(angle), importance_weight} | ||
1367 | {{0.985f /*cos(10 degrees)*/, 1.0f}, {0.94f /*cos(20 degrees)*/, 0.8f}, {0.866f /*cos(30 degrees)*/, 0.64f}, {0.0f, 0.36f}} ; | ||
1368 | |||
1369 | //static | ||
1370 | F32 LLFace::calcImportanceToCamera(F32 cos_angle_to_view_dir, F32 dist) | ||
1371 | { | ||
1372 | F32 importance = 0.f ; | ||
1373 | |||
1374 | if(cos_angle_to_view_dir > LLViewerCamera::getInstance()->getCosHalfFov() && | ||
1375 | dist < FACE_IMPORTANCE_TO_CAMERA_OVER_DISTANCE[FACE_IMPORTANCE_LEVEL - 1][0]) | ||
1376 | { | ||
1377 | F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ; | ||
1378 | F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed(); | ||
1379 | |||
1380 | if(camera_moving_speed > 10.0f || camera_angular_speed > 1.0f) | ||
1381 | { | ||
1382 | //if camera moves or rotates too fast, ignore the importance factor | ||
1383 | return 0.f ; | ||
1384 | } | ||
1385 | |||
1386 | //F32 camera_relative_speed = camera_moving_speed * (lookAt * LLViewerCamera::getInstance()->getVelocityDir()) ; | ||
1387 | |||
1388 | S32 i = 0 ; | ||
1389 | for(i = 0; i < FACE_IMPORTANCE_LEVEL && dist > FACE_IMPORTANCE_TO_CAMERA_OVER_DISTANCE[i][0]; ++i); | ||
1390 | i = llmin(i, FACE_IMPORTANCE_LEVEL - 1) ; | ||
1391 | F32 dist_factor = FACE_IMPORTANCE_TO_CAMERA_OVER_DISTANCE[i][1] ; | ||
1392 | |||
1393 | for(i = 0; i < FACE_IMPORTANCE_LEVEL && cos_angle_to_view_dir < FACE_IMPORTANCE_TO_CAMERA_OVER_ANGLE[i][0] ; ++i) ; | ||
1394 | i = llmin(i, FACE_IMPORTANCE_LEVEL - 1) ; | ||
1395 | importance = dist_factor * FACE_IMPORTANCE_TO_CAMERA_OVER_ANGLE[i][1] ; | ||
1396 | } | ||
1397 | |||
1398 | return importance ; | ||
1399 | } | ||
1400 | |||
1401 | BOOL LLFace::verify(const U32* indices_array) const | 1356 | BOOL LLFace::verify(const U32* indices_array) const |
1402 | { | 1357 | { |
1403 | BOOL ok = TRUE; | 1358 | BOOL ok = TRUE; |
@@ -1586,3 +1541,153 @@ LLVector3 LLFace::getPositionAgent() const | |||
1586 | return mCenterLocal * getRenderMatrix(); | 1541 | return mCenterLocal * getRenderMatrix(); |
1587 | } | 1542 | } |
1588 | } | 1543 | } |
1544 | |||
1545 | // | ||
1546 | //atlas | ||
1547 | // | ||
1548 | void LLFace::removeAtlas() | ||
1549 | { | ||
1550 | setAtlasInUse(FALSE) ; | ||
1551 | mAtlasInfop = NULL ; | ||
1552 | } | ||
1553 | |||
1554 | const LLTextureAtlas* LLFace::getAtlas()const | ||
1555 | { | ||
1556 | if(mAtlasInfop) | ||
1557 | { | ||
1558 | return mAtlasInfop->getAtlas() ; | ||
1559 | } | ||
1560 | return NULL ; | ||
1561 | } | ||
1562 | |||
1563 | const LLVector2* LLFace::getTexCoordOffset()const | ||
1564 | { | ||
1565 | if(isAtlasInUse()) | ||
1566 | { | ||
1567 | return mAtlasInfop->getTexCoordOffset() ; | ||
1568 | } | ||
1569 | return NULL ; | ||
1570 | } | ||
1571 | const LLVector2* LLFace::getTexCoordScale() const | ||
1572 | { | ||
1573 | if(isAtlasInUse()) | ||
1574 | { | ||
1575 | return mAtlasInfop->getTexCoordScale() ; | ||
1576 | } | ||
1577 | return NULL ; | ||
1578 | } | ||
1579 | |||
1580 | BOOL LLFace::isAtlasInUse()const | ||
1581 | { | ||
1582 | return mUsingAtlas ; | ||
1583 | } | ||
1584 | |||
1585 | BOOL LLFace::canUseAtlas()const | ||
1586 | { | ||
1587 | //no drawable or no spatial group, do not use atlas | ||
1588 | if(!mDrawablep || !mDrawablep->getSpatialGroup()) | ||
1589 | { | ||
1590 | return FALSE ; | ||
1591 | } | ||
1592 | |||
1593 | //if bump face, do not use atlas | ||
1594 | if(getTextureEntry() && getTextureEntry()->getBumpmap()) | ||
1595 | { | ||
1596 | return FALSE ; | ||
1597 | } | ||
1598 | |||
1599 | //if animated texture, do not use atlas | ||
1600 | if(isState(TEXTURE_ANIM)) | ||
1601 | { | ||
1602 | return FALSE ; | ||
1603 | } | ||
1604 | |||
1605 | return TRUE ; | ||
1606 | } | ||
1607 | |||
1608 | void LLFace::setAtlasInUse(BOOL flag) | ||
1609 | { | ||
1610 | //no valid atlas to use. | ||
1611 | if(flag && (!mAtlasInfop || !mAtlasInfop->isValid())) | ||
1612 | { | ||
1613 | flag = FALSE ; | ||
1614 | } | ||
1615 | |||
1616 | if(!flag && !mUsingAtlas) | ||
1617 | { | ||
1618 | return ; | ||
1619 | } | ||
1620 | |||
1621 | // | ||
1622 | //at this stage (flag || mUsingAtlas) is always true. | ||
1623 | // | ||
1624 | |||
1625 | //rebuild the tex coords | ||
1626 | if(mDrawablep) | ||
1627 | { | ||
1628 | gPipeline.markRebuild(mDrawablep, LLDrawable::REBUILD_TCOORD); | ||
1629 | mUsingAtlas = flag ; | ||
1630 | } | ||
1631 | else | ||
1632 | { | ||
1633 | mUsingAtlas = FALSE ; | ||
1634 | } | ||
1635 | } | ||
1636 | |||
1637 | LLTextureAtlasSlot* LLFace::getAtlasInfo() | ||
1638 | { | ||
1639 | return mAtlasInfop ; | ||
1640 | } | ||
1641 | |||
1642 | void LLFace::setAtlasInfo(LLTextureAtlasSlot* atlasp) | ||
1643 | { | ||
1644 | if(mAtlasInfop != atlasp) | ||
1645 | { | ||
1646 | if(mAtlasInfop) | ||
1647 | { | ||
1648 | //llwarns << "Atlas slot changed!" << llendl ; | ||
1649 | } | ||
1650 | mAtlasInfop = atlasp ; | ||
1651 | } | ||
1652 | } | ||
1653 | |||
1654 | LLImageGL* LLFace::getGLTexture() const | ||
1655 | { | ||
1656 | if(isAtlasInUse()) | ||
1657 | { | ||
1658 | return (LLImageGL*)mAtlasInfop->getAtlas() ; | ||
1659 | } | ||
1660 | |||
1661 | return (LLImageGL*)mTexture ; | ||
1662 | } | ||
1663 | |||
1664 | //switch to atlas or switch back to gl texture | ||
1665 | //return TRUE if using atlas. | ||
1666 | BOOL LLFace::switchTexture() | ||
1667 | { | ||
1668 | //no valid atlas or texture | ||
1669 | if(!mAtlasInfop || !mAtlasInfop->isValid() || !mTexture) | ||
1670 | { | ||
1671 | return FALSE ; | ||
1672 | } | ||
1673 | |||
1674 | if(mTexture->getTexelsInAtlas() >= (U32)mVSize || mTexture->getTexelsInAtlas() >= mTexture->getTexelsInGLTexture()) | ||
1675 | { | ||
1676 | //switch to use atlas | ||
1677 | //atlas resolution is qualified, use it. | ||
1678 | if(!mUsingAtlas) | ||
1679 | { | ||
1680 | setAtlasInUse(TRUE) ; | ||
1681 | } | ||
1682 | } | ||
1683 | else //if atlas not qualified. | ||
1684 | { | ||
1685 | //switch back to GL texture | ||
1686 | if(mUsingAtlas && mTexture->isGLTextureCreated() && mTexture->getDiscardLevel() < mTexture->getDiscardLevelInAtlas()) | ||
1687 | { | ||
1688 | setAtlasInUse(FALSE) ; | ||
1689 | } | ||
1690 | } | ||
1691 | |||
1692 | return mUsingAtlas ; | ||
1693 | } | ||
diff --git a/linden/indra/newview/llface.h b/linden/indra/newview/llface.h index 4893e82..9f76d6b 100644 --- a/linden/indra/newview/llface.h +++ b/linden/indra/newview/llface.h | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "llviewerimage.h" | 48 | #include "llviewerimage.h" |
49 | #include "llstat.h" | 49 | #include "llstat.h" |
50 | #include "lldrawable.h" | 50 | #include "lldrawable.h" |
51 | #include "lltextureatlasmanager.h" | ||
51 | 52 | ||
52 | class LLFacePool; | 53 | class LLFacePool; |
53 | class LLVolume; | 54 | class LLVolume; |
@@ -56,6 +57,7 @@ class LLTextureEntry; | |||
56 | class LLVertexProgram; | 57 | class LLVertexProgram; |
57 | class LLViewerImage; | 58 | class LLViewerImage; |
58 | class LLGeometryManager; | 59 | class LLGeometryManager; |
60 | class LLTextureAtlasSlot; | ||
59 | 61 | ||
60 | const F32 MIN_ALPHA_SIZE = 1024.f; | 62 | const F32 MIN_ALPHA_SIZE = 1024.f; |
61 | const F32 MIN_TEX_ANIM_SIZE = 512.f; | 63 | const F32 MIN_TEX_ANIM_SIZE = 512.f; |
@@ -189,14 +191,18 @@ public: | |||
189 | void setIndicesIndex(S32 idx) { mIndicesIndex = idx; } | 191 | void setIndicesIndex(S32 idx) { mIndicesIndex = idx; } |
190 | void setDrawInfo(LLDrawInfo* draw_info); | 192 | void setDrawInfo(LLDrawInfo* draw_info); |
191 | 193 | ||
192 | F32 getTextureVirtualSize() ; | 194 | // KL was atlas S19 |
193 | F32 getImportanceToCamera()const {return mImportanceToCamera ;} | 195 | LLImageGL* getGLTexture() const; |
194 | 196 | LLTextureAtlasSlot* getAtlasInfo() ; | |
195 | private: | 197 | void setAtlasInUse(BOOL flag); |
196 | F32 adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius ); | 198 | void setAtlasInfo(LLTextureAtlasSlot* atlasp); |
197 | F32 calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) ; | 199 | BOOL isAtlasInUse()const; |
198 | public: | 200 | BOOL canUseAtlas() const; |
199 | static F32 calcImportanceToCamera(F32 to_view_dir, F32 dist); | 201 | const LLVector2* getTexCoordScale() const ; |
202 | const LLVector2* getTexCoordOffset()const; | ||
203 | const LLTextureAtlas* getAtlas()const ; | ||
204 | void removeAtlas() ; | ||
205 | BOOL switchTexture() ; | ||
200 | 206 | ||
201 | public: | 207 | public: |
202 | 208 | ||
@@ -212,7 +218,7 @@ public: | |||
212 | LLMatrix4* mTextureMatrix; | 218 | LLMatrix4* mTextureMatrix; |
213 | LLDrawInfo* mDrawInfo; | 219 | LLDrawInfo* mDrawInfo; |
214 | 220 | ||
215 | private: | 221 | protected: |
216 | friend class LLGeometryManager; | 222 | friend class LLGeometryManager; |
217 | friend class LLVolumeGeometryManager; | 223 | friend class LLVolumeGeometryManager; |
218 | 224 | ||
@@ -242,12 +248,10 @@ private: | |||
242 | F32 mVSize; | 248 | F32 mVSize; |
243 | F32 mPixelArea; | 249 | F32 mPixelArea; |
244 | 250 | ||
245 | //importance factor, in the range [0, 1.0]. | 251 | //atlas |
246 | //1.0: the most important. | 252 | LLPointer<LLTextureAtlasSlot> mAtlasInfop ; |
247 | //based on the distance from the face to the view point and the angle from the face center to the view direction. | 253 | BOOL mUsingAtlas ; |
248 | F32 mImportanceToCamera ; | 254 | |
249 | F32 mBoundingSphereRadius ; | ||
250 | |||
251 | protected: | 255 | protected: |
252 | static BOOL sSafeRenderSelect; | 256 | static BOOL sSafeRenderSelect; |
253 | 257 | ||
@@ -275,9 +279,9 @@ public: | |||
275 | const LLTextureEntry* lte = lhs->getTextureEntry(); | 279 | const LLTextureEntry* lte = lhs->getTextureEntry(); |
276 | const LLTextureEntry* rte = rhs->getTextureEntry(); | 280 | const LLTextureEntry* rte = rhs->getTextureEntry(); |
277 | 281 | ||
278 | if (lhs->getTexture() != rhs->getTexture()) | 282 | if(lhs->getGLTexture() != rhs->getGLTexture()) // KL SD get GL |
279 | { | 283 | { |
280 | return lhs->getTexture() < rhs->getTexture(); | 284 | return lhs->getGLTexture() < rhs->getGLTexture(); // not getTexture? |
281 | } | 285 | } |
282 | else if (lte->getBumpShinyFullbright() != rte->getBumpShinyFullbright()) | 286 | else if (lte->getBumpShinyFullbright() != rte->getBumpShinyFullbright()) |
283 | { | 287 | { |
diff --git a/linden/indra/newview/llfloaterassetbrowser.cpp b/linden/indra/newview/llfloaterassetbrowser.cpp index af81c4a..9b41390 100644 --- a/linden/indra/newview/llfloaterassetbrowser.cpp +++ b/linden/indra/newview/llfloaterassetbrowser.cpp | |||
@@ -63,7 +63,7 @@ LLFloaterAssetBrowser::~LLFloaterAssetBrowser() | |||
63 | mTextureAssets.clear(); | 63 | mTextureAssets.clear(); |
64 | mMaxIndex = 0; | 64 | mMaxIndex = 0; |
65 | mFirstIndex = 0; | 65 | mFirstIndex = 0; |
66 | mMouseOverIndex = 0; | 66 | mMouseOverIndex = NULL; |
67 | mMouseOverUUID = LLUUID::null; | 67 | mMouseOverUUID = LLUUID::null; |
68 | mMouseOverAssetUUID = LLUUID::null; | 68 | mMouseOverAssetUUID = LLUUID::null; |
69 | mFloaterTitle = ""; | 69 | mFloaterTitle = ""; |
@@ -79,7 +79,7 @@ void LLFloaterAssetBrowser::initialize() | |||
79 | mAssetInfoIndex = 0; | 79 | mAssetInfoIndex = 0; |
80 | mFloaterHeight = getRect().getHeight(); | 80 | mFloaterHeight = getRect().getHeight(); |
81 | mFloaterWidth = getRect().getWidth(); | 81 | mFloaterWidth = getRect().getWidth(); |
82 | mMouseOverIndex = 0; | 82 | mMouseOverIndex = NULL; |
83 | mMouseOverUUID = LLUUID::null; | 83 | mMouseOverUUID = LLUUID::null; |
84 | mMouseOverAssetUUID = LLUUID::null; | 84 | mMouseOverAssetUUID = LLUUID::null; |
85 | mFloaterTitle = ""; | 85 | mFloaterTitle = ""; |
@@ -122,7 +122,7 @@ void LLFloaterAssetBrowser::createThumbnails() | |||
122 | temp.mUUID = itemp->getUUID(); | 122 | temp.mUUID = itemp->getUUID(); |
123 | temp.mName = itemp->getName(); | 123 | temp.mName = itemp->getName(); |
124 | temp.mTexturep = NULL; | 124 | temp.mTexturep = NULL; |
125 | temp.mAssetRect = LLRect::null; | 125 | temp.mAssetRect = NULL; |
126 | mTextureAssets.push_back(temp); | 126 | mTextureAssets.push_back(temp); |
127 | } | 127 | } |
128 | 128 | ||
@@ -131,14 +131,14 @@ void LLFloaterAssetBrowser::createThumbnails() | |||
131 | { | 131 | { |
132 | mTextureAssets[i].mTexturep = gImageList.getImage(mTextureAssets[i].mAssetUUID, MIPMAP_YES, IMMEDIATE_NO); | 132 | mTextureAssets[i].mTexturep = gImageList.getImage(mTextureAssets[i].mAssetUUID, MIPMAP_YES, IMMEDIATE_NO); |
133 | mTextureAssets[i].mTexturep->setBoostLevel(LLViewerImageBoostLevel::BOOST_PREVIEW); | 133 | mTextureAssets[i].mTexturep->setBoostLevel(LLViewerImageBoostLevel::BOOST_PREVIEW); |
134 | //mTextureAssets[i].mTexturep->processTextureStats(); | 134 | mTextureAssets[i].mTexturep->processTextureStats(); |
135 | } | 135 | } |
136 | 136 | ||
137 | //Generate the asset info text | 137 | //Generate the asset info text |
138 | /*for(S32 i = 0; i < items.count(); i++) | 138 | for(S32 i = 0; i < items.count(); i++) |
139 | { | 139 | { |
140 | LLString asset_info; | 140 | std::string asset_info; |
141 | LLString dimensions; | 141 | std::string dimensions; |
142 | 142 | ||
143 | asset_info.append(mTextureAssets[i].mName); | 143 | asset_info.append(mTextureAssets[i].mName); |
144 | 144 | ||
@@ -151,7 +151,7 @@ void LLFloaterAssetBrowser::createThumbnails() | |||
151 | asset_info.append(dimensions); | 151 | asset_info.append(dimensions); |
152 | 152 | ||
153 | mTextureAssets[i].mAssetInfo = asset_info; | 153 | mTextureAssets[i].mAssetInfo = asset_info; |
154 | }*/ | 154 | } |
155 | 155 | ||
156 | mFloaterTitle = llformat("Asset Browser (%d assets fetched)", mTextureAssets.size()); | 156 | mFloaterTitle = llformat("Asset Browser (%d assets fetched)", mTextureAssets.size()); |
157 | setTitle(mFloaterTitle); | 157 | setTitle(mFloaterTitle); |
@@ -288,7 +288,7 @@ void LLFloaterAssetBrowser::draw() | |||
288 | if(mImageAssetID.notNull()) | 288 | if(mImageAssetID.notNull()) |
289 | { | 289 | { |
290 | mTexturep = gImageList.getImage(mImageAssetID, MIPMAP_YES, IMMEDIATE_NO); | 290 | mTexturep = gImageList.getImage(mImageAssetID, MIPMAP_YES, IMMEDIATE_NO); |
291 | //mTexturep->setBoostLevel(LLViewerImage::BOOST_PREVIEW); | 291 | mTexturep->setBoostLevel(LLViewerImageBoostLevel::BOOST_PREVIEW); |
292 | mTexturep->processTextureStats(); | 292 | mTexturep->processTextureStats(); |
293 | mTextureAssets[i].mWidth = mTexturep->mFullWidth; | 293 | mTextureAssets[i].mWidth = mTexturep->mFullWidth; |
294 | mTextureAssets[i].mHeight = mTexturep->mFullHeight; | 294 | mTextureAssets[i].mHeight = mTexturep->mFullHeight; |
diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index 2daa5aa..5f43406 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp | |||
@@ -582,7 +582,8 @@ void LLFloaterChat::addChat(const LLChat& chat, | |||
582 | // We display anything if it's not an IM. If it's an IM, check pref... | 582 | // We display anything if it's not an IM. If it's an IM, check pref... |
583 | if ( !from_instant_message || gSavedSettings.getBOOL("IMInChatConsole") ) | 583 | if ( !from_instant_message || gSavedSettings.getBOOL("IMInChatConsole") ) |
584 | { | 584 | { |
585 | gConsole->addLine(chat.mText, size, text_color); | 585 | gConsole->addConsoleLine(chat.mText, text_color); |
586 | |||
586 | } | 587 | } |
587 | } | 588 | } |
588 | 589 | ||
diff --git a/linden/indra/newview/llfloaterhardwaresettings.cpp b/linden/indra/newview/llfloaterhardwaresettings.cpp index 7886e39..8c91f5a 100644 --- a/linden/indra/newview/llfloaterhardwaresettings.cpp +++ b/linden/indra/newview/llfloaterhardwaresettings.cpp | |||
@@ -68,6 +68,7 @@ void LLFloaterHardwareSettings::onClickHelp(void* data) | |||
68 | 68 | ||
69 | void LLFloaterHardwareSettings::initCallbacks(void) | 69 | void LLFloaterHardwareSettings::initCallbacks(void) |
70 | { | 70 | { |
71 | childSetCommitCallback("fbo", refreshState); | ||
71 | } | 72 | } |
72 | 73 | ||
73 | // menu maintenance functions | 74 | // menu maintenance functions |
@@ -83,7 +84,8 @@ void LLFloaterHardwareSettings::refresh() | |||
83 | mVideoCardMem = gSavedSettings.getS32("TextureMemory"); | 84 | mVideoCardMem = gSavedSettings.getS32("TextureMemory"); |
84 | mFogRatio = gSavedSettings.getF32("RenderFogRatio"); | 85 | mFogRatio = gSavedSettings.getF32("RenderFogRatio"); |
85 | mProbeHardwareOnStartup = gSavedSettings.getBOOL("ProbeHardwareOnStartup"); | 86 | mProbeHardwareOnStartup = gSavedSettings.getBOOL("ProbeHardwareOnStartup"); |
86 | 87 | mRenderDeferred = gSavedSettings.getBOOL("RenderDeferred"); | |
88 | mRenderUseFBO = gSavedSettings.getBOOL("RenderUseFBO"); | ||
87 | childSetValue("fsaa", (LLSD::Integer) mFSAASamples); | 89 | childSetValue("fsaa", (LLSD::Integer) mFSAASamples); |
88 | refreshEnabledState(); | 90 | refreshEnabledState(); |
89 | } | 91 | } |
@@ -101,6 +103,20 @@ void LLFloaterHardwareSettings::refreshEnabledState() | |||
101 | childSetEnabled("vbo", FALSE); | 103 | childSetEnabled("vbo", FALSE); |
102 | } | 104 | } |
103 | 105 | ||
106 | if (!gGLManager.mHasFramebufferObject) | ||
107 | { | ||
108 | childSetEnabled("fbo", FALSE); | ||
109 | } | ||
110 | |||
111 | if (!gGLManager.mHasDrawBuffers || !gSavedSettings.getBOOL("RenderUseFBO")) | ||
112 | { | ||
113 | childSetEnabled("deferred", FALSE); | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | childSetEnabled("deferred", TRUE); | ||
118 | } | ||
119 | |||
104 | // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance | 120 | // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance |
105 | childSetEnabled("gamma", !gPipeline.canUseWindLightShaders()); | 121 | childSetEnabled("gamma", !gPipeline.canUseWindLightShaders()); |
106 | childSetEnabled("(brightness, lower is brighter)", !gPipeline.canUseWindLightShaders()); | 122 | childSetEnabled("(brightness, lower is brighter)", !gPipeline.canUseWindLightShaders()); |
@@ -108,6 +124,12 @@ void LLFloaterHardwareSettings::refreshEnabledState() | |||
108 | 124 | ||
109 | } | 125 | } |
110 | 126 | ||
127 | //static | ||
128 | void LLFloaterHardwareSettings::refreshState(LLUICtrl*, void*) | ||
129 | { | ||
130 | LLFloaterHardwareSettings::instance()->refreshEnabledState(); | ||
131 | } | ||
132 | |||
111 | // static instance of it | 133 | // static instance of it |
112 | LLFloaterHardwareSettings* LLFloaterHardwareSettings::instance() | 134 | LLFloaterHardwareSettings* LLFloaterHardwareSettings::instance() |
113 | { | 135 | { |
@@ -202,7 +224,8 @@ void LLFloaterHardwareSettings::cancel() | |||
202 | gSavedSettings.setS32("TextureMemory", mVideoCardMem); | 224 | gSavedSettings.setS32("TextureMemory", mVideoCardMem); |
203 | gSavedSettings.setF32("RenderFogRatio", mFogRatio); | 225 | gSavedSettings.setF32("RenderFogRatio", mFogRatio); |
204 | gSavedSettings.setBOOL("ProbeHardwareOnStartup", mProbeHardwareOnStartup ); | 226 | gSavedSettings.setBOOL("ProbeHardwareOnStartup", mProbeHardwareOnStartup ); |
205 | 227 | gSavedSettings.setBOOL("RenderUseFBO", mRenderUseFBO); | |
228 | gSavedSettings.setBOOL("RenderDeferred", mRenderDeferred); | ||
206 | close(); | 229 | close(); |
207 | } | 230 | } |
208 | 231 | ||
diff --git a/linden/indra/newview/llfloaterhardwaresettings.h b/linden/indra/newview/llfloaterhardwaresettings.h index 04a33f6..e564e1c 100644 --- a/linden/indra/newview/llfloaterhardwaresettings.h +++ b/linden/indra/newview/llfloaterhardwaresettings.h | |||
@@ -61,6 +61,8 @@ public: | |||
61 | /// OK button | 61 | /// OK button |
62 | static void onBtnOK( void* userdata ); | 62 | static void onBtnOK( void* userdata ); |
63 | 63 | ||
64 | static void refreshState(LLUICtrl*, void*); | ||
65 | |||
64 | //// menu management | 66 | //// menu management |
65 | 67 | ||
66 | /// show off our menu | 68 | /// show off our menu |
@@ -88,6 +90,8 @@ protected: | |||
88 | LLSliderCtrl* mCtrlVideoCardMem; | 90 | LLSliderCtrl* mCtrlVideoCardMem; |
89 | 91 | ||
90 | BOOL mUseVBO; | 92 | BOOL mUseVBO; |
93 | BOOL mRenderUseFBO; | ||
94 | BOOL mRenderDeferred; | ||
91 | BOOL mUseAniso; | 95 | BOOL mUseAniso; |
92 | U32 mFSAASamples; | 96 | U32 mFSAASamples; |
93 | F32 mGamma; | 97 | F32 mGamma; |
diff --git a/linden/indra/newview/llfloaterlagmeter.cpp b/linden/indra/newview/llfloaterlagmeter.cpp index 8fe455f..2ae2e32 100644 --- a/linden/indra/newview/llfloaterlagmeter.cpp +++ b/linden/indra/newview/llfloaterlagmeter.cpp | |||
@@ -180,7 +180,7 @@ void LLFloaterLagMeter::determineClient() | |||
180 | { | 180 | { |
181 | mClientCause->setText( getString("client_texture_loading_cause_msg", mStringArgs) ); | 181 | mClientCause->setText( getString("client_texture_loading_cause_msg", mStringArgs) ); |
182 | } | 182 | } |
183 | else if((BYTES_TO_MEGA_BYTES(LLViewerImage::sBoundTextureMemoryInBytes)) > LLViewerImage::sMaxBoundTextureMemInMegaBytes) | 183 | else if((LLViewerImage::sBoundTextureMemoryInBytes >> 20) > LLViewerImage::sMaxBoundTextureMemInMegaBytes) |
184 | { | 184 | { |
185 | mClientCause->setText( getString("client_texture_memory_cause_msg", mStringArgs) ); | 185 | mClientCause->setText( getString("client_texture_memory_cause_msg", mStringArgs) ); |
186 | } | 186 | } |
diff --git a/linden/indra/newview/llfloaterpostprocess.cpp b/linden/indra/newview/llfloaterpostprocess.cpp index de9b598..c5b2018 100644 --- a/linden/indra/newview/llfloaterpostprocess.cpp +++ b/linden/indra/newview/llfloaterpostprocess.cpp | |||
@@ -52,28 +52,29 @@ LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater(std::string("Post-Proce | |||
52 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_post_process.xml"); | 52 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_post_process.xml"); |
53 | 53 | ||
54 | /// Color Filter Callbacks | 54 | /// Color Filter Callbacks |
55 | childSetCommitCallback("ColorFilterToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_color_filter"); | 55 | //childSetCommitCallback("ColorFilterToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_color_filter"); |
56 | childSetCommitCallback("wmiColorFilterToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_color_filter"); | ||
56 | //childSetCommitCallback("ColorFilterGamma", &LLFloaterPostProcess::onFloatControlMoved, &(gPostProcess->tweaks.gamma())); | 57 | //childSetCommitCallback("ColorFilterGamma", &LLFloaterPostProcess::onFloatControlMoved, &(gPostProcess->tweaks.gamma())); |
57 | childSetCommitCallback("ColorFilterBrightness", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness"); | 58 | childSetCommitCallback("wmiColorFilterBrightness", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness"); |
58 | childSetCommitCallback("ColorFilterSaturation", &LLFloaterPostProcess::onFloatControlMoved, (char*)"saturation"); | 59 | childSetCommitCallback("wmiColorFilterSaturation", &LLFloaterPostProcess::onFloatControlMoved, (char*)"saturation"); |
59 | childSetCommitCallback("ColorFilterContrast", &LLFloaterPostProcess::onFloatControlMoved, (char*)"contrast"); | 60 | childSetCommitCallback("wmiColorFilterContrast", &LLFloaterPostProcess::onFloatControlMoved, (char*)"contrast"); |
60 | 61 | ||
61 | childSetCommitCallback("ColorFilterBaseR", &LLFloaterPostProcess::onColorControlRMoved, (char*)"contrast_base"); | 62 | childSetCommitCallback("wmiColorFilterBaseR", &LLFloaterPostProcess::onColorControlRMoved, (char*)"contrast_base"); |
62 | childSetCommitCallback("ColorFilterBaseG", &LLFloaterPostProcess::onColorControlGMoved, (char*)"contrast_base"); | 63 | childSetCommitCallback("wmiColorFilterBaseG", &LLFloaterPostProcess::onColorControlGMoved, (char*)"contrast_base"); |
63 | childSetCommitCallback("ColorFilterBaseB", &LLFloaterPostProcess::onColorControlBMoved, (char*)"contrast_base"); | 64 | childSetCommitCallback("wmiColorFilterBaseB", &LLFloaterPostProcess::onColorControlBMoved, (char*)"contrast_base"); |
64 | childSetCommitCallback("ColorFilterBaseI", &LLFloaterPostProcess::onColorControlIMoved, (char*)"contrast_base"); | 65 | childSetCommitCallback("wmiColorFilterBaseI", &LLFloaterPostProcess::onColorControlIMoved, (char*)"contrast_base"); |
65 | 66 | ||
66 | /// Night Vision Callbacks | 67 | /// Night Vision Callbacks |
67 | childSetCommitCallback("NightVisionToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_night_vision"); | 68 | childSetCommitCallback("wmiNightVisionToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_night_vision"); |
68 | childSetCommitCallback("NightVisionBrightMult", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness_multiplier"); | 69 | childSetCommitCallback("wmiNightVisionBrightMult", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness_multiplier"); |
69 | childSetCommitCallback("NightVisionNoiseSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_size"); | 70 | childSetCommitCallback("wmiNightVisionNoiseSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_size"); |
70 | childSetCommitCallback("NightVisionNoiseStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_strength"); | 71 | childSetCommitCallback("wmiNightVisionNoiseStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_strength"); |
71 | 72 | ||
72 | /// Bloom Callbacks | 73 | /// Bloom Callbacks |
73 | childSetCommitCallback("BloomToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_bloom"); | 74 | childSetCommitCallback("wmiBloomToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_bloom"); |
74 | childSetCommitCallback("BloomExtract", &LLFloaterPostProcess::onFloatControlMoved, (char*)"extract_low"); | 75 | childSetCommitCallback("wmiBloomExtract", &LLFloaterPostProcess::onFloatControlMoved, (char*)"extract_low"); |
75 | childSetCommitCallback("BloomSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_width"); | 76 | childSetCommitCallback("wmiBloomSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_width"); |
76 | childSetCommitCallback("BloomStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_strength"); | 77 | childSetCommitCallback("wmiBloomStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_strength"); |
77 | 78 | ||
78 | // Effect loading and saving. | 79 | // Effect loading and saving. |
79 | LLComboBox* comboBox = getChild<LLComboBox>("PPEffectsCombo"); | 80 | LLComboBox* comboBox = getChild<LLComboBox>("PPEffectsCombo"); |
@@ -113,6 +114,7 @@ void LLFloaterPostProcess::onBoolToggle(LLUICtrl* ctrl, void* userData) | |||
113 | // check the bool | 114 | // check the bool |
114 | LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl); | 115 | LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl); |
115 | gPostProcess->tweaks[boolVariableName] = cbCtrl->getValue(); | 116 | gPostProcess->tweaks[boolVariableName] = cbCtrl->getValue(); |
117 | |||
116 | } | 118 | } |
117 | 119 | ||
118 | // Float Moved | 120 | // Float Moved |
@@ -247,25 +249,25 @@ void LLFloaterPostProcess::syncMenu() | |||
247 | comboBox->selectByValue(gPostProcess->getSelectedEffect()); | 249 | comboBox->selectByValue(gPostProcess->getSelectedEffect()); |
248 | 250 | ||
249 | /// Sync Color Filter Menu | 251 | /// Sync Color Filter Menu |
250 | childSetValue("ColorFilterToggle", gPostProcess->tweaks.useColorFilter()); | 252 | childSetValue("wmiColorFilterToggle", gPostProcess->tweaks.useColorFilter()); |
251 | //childSetValue("ColorFilterGamma", gPostProcess->tweaks.gamma()); | 253 | //childSetValue("ColorFilterGamma", gPostProcess->tweaks.gamma()); |
252 | childSetValue("ColorFilterBrightness", gPostProcess->tweaks.brightness()); | 254 | childSetValue("wmiColorFilterBrightness", gPostProcess->tweaks.brightness()); |
253 | childSetValue("ColorFilterSaturation", gPostProcess->tweaks.saturation()); | 255 | childSetValue("wmiColorFilterSaturation", gPostProcess->tweaks.saturation()); |
254 | childSetValue("ColorFilterContrast", gPostProcess->tweaks.contrast()); | 256 | childSetValue("wmiColorFilterContrast", gPostProcess->tweaks.contrast()); |
255 | childSetValue("ColorFilterBaseR", gPostProcess->tweaks.contrastBaseR()); | 257 | childSetValue("wmiColorFilterBaseR", gPostProcess->tweaks.contrastBaseR()); |
256 | childSetValue("ColorFilterBaseG", gPostProcess->tweaks.contrastBaseG()); | 258 | childSetValue("wmiColorFilterBaseG", gPostProcess->tweaks.contrastBaseG()); |
257 | childSetValue("ColorFilterBaseB", gPostProcess->tweaks.contrastBaseB()); | 259 | childSetValue("wmiColorFilterBaseB", gPostProcess->tweaks.contrastBaseB()); |
258 | childSetValue("ColorFilterBaseI", gPostProcess->tweaks.contrastBaseIntensity()); | 260 | childSetValue("wmiColorFilterBaseI", gPostProcess->tweaks.contrastBaseIntensity()); |
259 | 261 | ||
260 | /// Sync Night Vision Menu | 262 | /// Sync Night Vision Menu |
261 | childSetValue("NightVisionToggle", gPostProcess->tweaks.useNightVisionShader()); | 263 | childSetValue("wmiNightVisionToggle", gPostProcess->tweaks.useNightVisionShader()); |
262 | childSetValue("NightVisionBrightMult", gPostProcess->tweaks.brightMult()); | 264 | childSetValue("wmiNightVisionBrightMult", gPostProcess->tweaks.brightMult()); |
263 | childSetValue("NightVisionNoiseSize", gPostProcess->tweaks.noiseSize()); | 265 | childSetValue("wmiNightVisionNoiseSize", gPostProcess->tweaks.noiseSize()); |
264 | childSetValue("NightVisionNoiseStrength", gPostProcess->tweaks.noiseStrength()); | 266 | childSetValue("wmiNightVisionNoiseStrength", gPostProcess->tweaks.noiseStrength()); |
265 | 267 | ||
266 | /// Sync Bloom Menu | 268 | /// Sync Bloom Menu |
267 | childSetValue("BloomToggle", LLSD(gPostProcess->tweaks.useBloomShader())); | 269 | childSetValue("wmiBloomToggle", LLSD(gPostProcess->tweaks.useBloomShader())); |
268 | childSetValue("BloomExtract", gPostProcess->tweaks.extractLow()); | 270 | childSetValue("wmiBloomExtract", gPostProcess->tweaks.extractLow()); |
269 | childSetValue("BloomSize", gPostProcess->tweaks.bloomWidth()); | 271 | childSetValue("wmiBloomSize", gPostProcess->tweaks.bloomWidth()); |
270 | childSetValue("BloomStrength", gPostProcess->tweaks.bloomStrength()); | 272 | childSetValue("wmiBloomStrength", gPostProcess->tweaks.bloomStrength()); |
271 | } | 273 | } |
diff --git a/linden/indra/newview/llfloaterreporter.cpp b/linden/indra/newview/llfloaterreporter.cpp index a7f41ea..9209f41 100644 --- a/linden/indra/newview/llfloaterreporter.cpp +++ b/linden/indra/newview/llfloaterreporter.cpp | |||
@@ -952,7 +952,8 @@ void LLFloaterReporter::takeScreenshot() | |||
952 | 952 | ||
953 | // store in the image list so it doesn't try to fetch from the server | 953 | // store in the image list so it doesn't try to fetch from the server |
954 | LLPointer<LLViewerImage> image_in_list = new LLViewerImage(mResourceDatap->mAssetInfo.mUuid); | 954 | LLPointer<LLViewerImage> image_in_list = new LLViewerImage(mResourceDatap->mAssetInfo.mUuid); |
955 | image_in_list->createGLTexture(0, raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | 955 | image_in_list->createGLTexture(0, raw); |
956 | |||
956 | gImageList.addImage(image_in_list); | 957 | gImageList.addImage(image_in_list); |
957 | 958 | ||
958 | // the texture picker then uses that texture | 959 | // the texture picker then uses that texture |
diff --git a/linden/indra/newview/llhudeffect.cpp b/linden/indra/newview/llhudeffect.cpp index c1d46f9..20bbb32 100644 --- a/linden/indra/newview/llhudeffect.cpp +++ b/linden/indra/newview/llhudeffect.cpp | |||
@@ -78,7 +78,7 @@ void LLHUDEffect::unpackData(LLMessageSystem *mesgsys, S32 blocknum) | |||
78 | 78 | ||
79 | void LLHUDEffect::render() | 79 | void LLHUDEffect::render() |
80 | { | 80 | { |
81 | llerrs << "Never call this!" << llendl; | 81 | llwarns << "Never call this!" << llendl; // Then why the &*^&*^ is it here? |
82 | } | 82 | } |
83 | 83 | ||
84 | void LLHUDEffect::setID(const LLUUID &id) | 84 | void LLHUDEffect::setID(const LLUUID &id) |
diff --git a/linden/indra/newview/llhudtext.cpp b/linden/indra/newview/llhudtext.cpp index 661a786..b170337 100644 --- a/linden/indra/newview/llhudtext.cpp +++ b/linden/indra/newview/llhudtext.cpp | |||
@@ -1111,6 +1111,8 @@ void LLHUDText::renderAllHUD() | |||
1111 | 1111 | ||
1112 | LLVertexBuffer::unbind(); | 1112 | LLVertexBuffer::unbind(); |
1113 | 1113 | ||
1114 | LLVertexBuffer::unbind(); // KL not entirely sure why but render pipeline has this twice? | ||
1115 | |||
1114 | LLGLState::checkStates(); | 1116 | LLGLState::checkStates(); |
1115 | LLGLState::checkTextureChannels(); | 1117 | LLGLState::checkTextureChannels(); |
1116 | LLGLState::checkClientArrays(); | 1118 | LLGLState::checkClientArrays(); |
diff --git a/linden/indra/newview/llmanip.cpp b/linden/indra/newview/llmanip.cpp index 45550fc..0c88c47 100644 --- a/linden/indra/newview/llmanip.cpp +++ b/linden/indra/newview/llmanip.cpp | |||
@@ -60,7 +60,7 @@ | |||
60 | #include "llglheaders.h" | 60 | #include "llglheaders.h" |
61 | 61 | ||
62 | // Local constants... | 62 | // Local constants... |
63 | const S32 VERTICAL_OFFSET = 50; | 63 | const S32 VERTICAL_OFFSET = 100; // KL adjusted to compensate for toolbars move to the top of the screen! |
64 | 64 | ||
65 | F32 LLManip::sHelpTextVisibleTime = 2.f; | 65 | F32 LLManip::sHelpTextVisibleTime = 2.f; |
66 | F32 LLManip::sHelpTextFadeTime = 2.f; | 66 | F32 LLManip::sHelpTextFadeTime = 2.f; |
diff --git a/linden/indra/newview/llmaniptranslate.h b/linden/indra/newview/llmaniptranslate.h index 77f12ff..25ff35c 100644 --- a/linden/indra/newview/llmaniptranslate.h +++ b/linden/indra/newview/llmaniptranslate.h | |||
@@ -116,7 +116,7 @@ private: | |||
116 | LLVector3d mDragCursorStartGlobal; | 116 | LLVector3d mDragCursorStartGlobal; |
117 | LLVector3d mDragSelectionStartGlobal; | 117 | LLVector3d mDragSelectionStartGlobal; |
118 | LLTimer mUpdateTimer; | 118 | LLTimer mUpdateTimer; |
119 | typedef std::multiset<ManipulatorHandle*, compare_manipulators> minpulator_list_t; | 119 | typedef std::set<ManipulatorHandle*, compare_manipulators> minpulator_list_t; |
120 | minpulator_list_t mProjectedManipulators; | 120 | minpulator_list_t mProjectedManipulators; |
121 | LLVector4 mManipulatorVertices[18]; | 121 | LLVector4 mManipulatorVertices[18]; |
122 | F32 mSnapOffsetMeters; | 122 | F32 mSnapOffsetMeters; |
diff --git a/linden/indra/newview/llmediactrl.cpp b/linden/indra/newview/llmediactrl.cpp index 1530598..a517332 100644 --- a/linden/indra/newview/llmediactrl.cpp +++ b/linden/indra/newview/llmediactrl.cpp | |||
@@ -1012,8 +1012,7 @@ BOOL LLWebBrowserTexture::render() | |||
1012 | x_pos, | 1012 | x_pos, |
1013 | y_pos, | 1013 | y_pos, |
1014 | width, | 1014 | width, |
1015 | height, | 1015 | height); |
1016 | TRUE); // force a fast update (i.e. don't call analyzeAlpha, etc.) | ||
1017 | } | 1016 | } |
1018 | 1017 | ||
1019 | media_plugin->resetDirty(); | 1018 | media_plugin->resetDirty(); |
diff --git a/linden/indra/newview/lloverlaybar.cpp b/linden/indra/newview/lloverlaybar.cpp index db4422d..e903df7 100644 --- a/linden/indra/newview/lloverlaybar.cpp +++ b/linden/indra/newview/lloverlaybar.cpp | |||
@@ -491,7 +491,6 @@ void LLOverlayBar::toggleMusicPlay(void*) | |||
491 | // if ( gAudiop->isInternetStreamPlaying() == 0 ) | 491 | // if ( gAudiop->isInternetStreamPlaying() == 0 ) |
492 | { | 492 | { |
493 | gAudiop->startInternetStream(parcel->getMusicURL()); | 493 | gAudiop->startInternetStream(parcel->getMusicURL()); |
494 | //awfixme sTitleObserver.init(parcel->getMusicURL()); | ||
495 | } | 494 | } |
496 | } | 495 | } |
497 | } | 496 | } |
diff --git a/linden/indra/newview/llpanelvolume.cpp b/linden/indra/newview/llpanelvolume.cpp index 6d014a2..4270f0b 100644 --- a/linden/indra/newview/llpanelvolume.cpp +++ b/linden/indra/newview/llpanelvolume.cpp | |||
@@ -53,6 +53,7 @@ | |||
53 | #include "llbutton.h" | 53 | #include "llbutton.h" |
54 | #include "llcheckboxctrl.h" | 54 | #include "llcheckboxctrl.h" |
55 | #include "llcolorswatch.h" | 55 | #include "llcolorswatch.h" |
56 | #include "lltexturectrl.h" | ||
56 | #include "llcombobox.h" | 57 | #include "llcombobox.h" |
57 | #include "llfirstuse.h" | 58 | #include "llfirstuse.h" |
58 | #include "llfocusmgr.h" | 59 | #include "llfocusmgr.h" |
@@ -111,12 +112,28 @@ BOOL LLPanelVolume::postBuild() | |||
111 | LightColorSwatch->setOnSelectCallback(onLightSelectColor); | 112 | LightColorSwatch->setOnSelectCallback(onLightSelectColor); |
112 | childSetCommitCallback("colorswatch",onCommitLight,this); | 113 | childSetCommitCallback("colorswatch",onCommitLight,this); |
113 | } | 114 | } |
115 | |||
116 | LLTextureCtrl* LightTexPicker = getChild<LLTextureCtrl>("light texture control"); | ||
117 | if (LightTexPicker) | ||
118 | { | ||
119 | LightTexPicker->setOnCancelCallback(onLightCancelTexture); | ||
120 | LightTexPicker->setOnSelectCallback(onLightSelectTexture); | ||
121 | childSetCommitCallback("light texture control", onCommitLight, this); | ||
122 | } | ||
123 | |||
114 | childSetCommitCallback("Light Intensity",onCommitLight,this); | 124 | childSetCommitCallback("Light Intensity",onCommitLight,this); |
115 | childSetValidate("Light Intensity",precommitValidate); | 125 | childSetValidate("Light Intensity",precommitValidate); |
116 | childSetCommitCallback("Light Radius",onCommitLight,this); | 126 | childSetCommitCallback("Light Radius",onCommitLight,this); |
117 | childSetValidate("Light Radius",precommitValidate); | 127 | childSetValidate("Light Radius",precommitValidate); |
118 | childSetCommitCallback("Light Falloff",onCommitLight,this); | 128 | childSetCommitCallback("Light Falloff",onCommitLight,this); |
119 | childSetValidate("Light Falloff",precommitValidate); | 129 | childSetValidate("Light Falloff",precommitValidate); |
130 | |||
131 | childSetCommitCallback("Light FOV", onCommitLight, this); | ||
132 | childSetValidate("Light FOV", precommitValidate); | ||
133 | childSetCommitCallback("Light Focus", onCommitLight, this); | ||
134 | childSetValidate("Light Focus", precommitValidate); | ||
135 | childSetCommitCallback("Light Ambiance", onCommitLight, this); | ||
136 | childSetValidate("Light Ambiance", precommitValidate); | ||
120 | } | 137 | } |
121 | 138 | ||
122 | // Start with everyone disabled | 139 | // Start with everyone disabled |
@@ -221,14 +238,32 @@ void LLPanelVolume::getState( ) | |||
221 | LightColorSwatch->setValid( TRUE ); | 238 | LightColorSwatch->setValid( TRUE ); |
222 | LightColorSwatch->set(volobjp->getLightBaseColor()); | 239 | LightColorSwatch->set(volobjp->getLightBaseColor()); |
223 | } | 240 | } |
241 | |||
242 | LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control"); | ||
243 | if (LightTextureCtrl) | ||
244 | { | ||
245 | LightTextureCtrl->setEnabled(TRUE); | ||
246 | LightTextureCtrl->setValid(TRUE); | ||
247 | LightTextureCtrl->setImageAssetID(volobjp->getLightTextureID()); | ||
248 | } | ||
249 | |||
224 | childSetEnabled("Light Intensity",true); | 250 | childSetEnabled("Light Intensity",true); |
225 | childSetEnabled("Light Radius",true); | 251 | childSetEnabled("Light Radius",true); |
226 | childSetEnabled("Light Falloff",true); | 252 | childSetEnabled("Light Falloff",true); |
227 | 253 | ||
254 | childSetEnabled("Light FOV", true); | ||
255 | childSetEnabled("Light Focus", true); | ||
256 | childSetEnabled("Light Ambiance", true); | ||
257 | |||
228 | childSetValue("Light Intensity",volobjp->getLightIntensity()); | 258 | childSetValue("Light Intensity",volobjp->getLightIntensity()); |
229 | childSetValue("Light Radius",volobjp->getLightRadius()); | 259 | childSetValue("Light Radius",volobjp->getLightRadius()); |
230 | childSetValue("Light Falloff",volobjp->getLightFalloff()); | 260 | childSetValue("Light Falloff",volobjp->getLightFalloff()); |
231 | 261 | ||
262 | LLVector3 params = volobjp->getSpotLightParams(); | ||
263 | childSetValue("Light FOV", params.mV[0]); | ||
264 | childSetValue("Light Focus", params.mV[1]); | ||
265 | childSetValue("Light Ambiance", params.mV[2]); | ||
266 | |||
232 | mLightSavedColor = volobjp->getLightColor(); | 267 | mLightSavedColor = volobjp->getLightColor(); |
233 | } | 268 | } |
234 | else | 269 | else |
@@ -244,9 +279,20 @@ void LLPanelVolume::getState( ) | |||
244 | LightColorSwatch->setEnabled( FALSE ); | 279 | LightColorSwatch->setEnabled( FALSE ); |
245 | LightColorSwatch->setValid( FALSE ); | 280 | LightColorSwatch->setValid( FALSE ); |
246 | } | 281 | } |
282 | LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control"); | ||
283 | if (LightTextureCtrl) | ||
284 | { | ||
285 | LightTextureCtrl->setEnabled(FALSE); | ||
286 | LightTextureCtrl->setValid(FALSE); | ||
287 | } | ||
288 | |||
247 | childSetEnabled("Light Intensity",false); | 289 | childSetEnabled("Light Intensity",false); |
248 | childSetEnabled("Light Radius",false); | 290 | childSetEnabled("Light Radius",false); |
249 | childSetEnabled("Light Falloff",false); | 291 | childSetEnabled("Light Falloff",false); |
292 | |||
293 | childSetEnabled("Light FOV",false); | ||
294 | childSetEnabled("Light Focus",false); | ||
295 | childSetEnabled("Light Ambiance",false); | ||
250 | } | 296 | } |
251 | 297 | ||
252 | // Flexible properties | 298 | // Flexible properties |
@@ -362,6 +408,13 @@ void LLPanelVolume::clearCtrls() | |||
362 | LightColorSwatch->setEnabled( FALSE ); | 408 | LightColorSwatch->setEnabled( FALSE ); |
363 | LightColorSwatch->setValid( FALSE ); | 409 | LightColorSwatch->setValid( FALSE ); |
364 | } | 410 | } |
411 | LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control"); | ||
412 | if(LightTextureCtrl) | ||
413 | { | ||
414 | LightTextureCtrl->setEnabled( FALSE ); | ||
415 | LightTextureCtrl->setValid( FALSE ); | ||
416 | } | ||
417 | |||
365 | childSetEnabled("Light Intensity",false); | 418 | childSetEnabled("Light Intensity",false); |
366 | childSetEnabled("Light Radius",false); | 419 | childSetEnabled("Light Radius",false); |
367 | childSetEnabled("Light Falloff",false); | 420 | childSetEnabled("Light Falloff",false); |
@@ -438,6 +491,16 @@ void LLPanelVolume::onLightCancelColor(LLUICtrl* ctrl, void* userdata) | |||
438 | onLightSelectColor(NULL, userdata); | 491 | onLightSelectColor(NULL, userdata); |
439 | } | 492 | } |
440 | 493 | ||
494 | void LLPanelVolume::onLightCancelTexture(LLUICtrl* ctrl, void* userdata) | ||
495 | { | ||
496 | LLPanelVolume* self = (LLPanelVolume*) userdata; | ||
497 | LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control"); | ||
498 | if (LightTextureCtrl) | ||
499 | { | ||
500 | LightTextureCtrl->setImageAssetID(self->mLightSavedTexture); | ||
501 | } | ||
502 | } | ||
503 | |||
441 | void LLPanelVolume::onLightSelectColor(LLUICtrl* ctrl, void* userdata) | 504 | void LLPanelVolume::onLightSelectColor(LLUICtrl* ctrl, void* userdata) |
442 | { | 505 | { |
443 | LLPanelVolume* self = (LLPanelVolume*) userdata; | 506 | LLPanelVolume* self = (LLPanelVolume*) userdata; |
@@ -459,6 +522,25 @@ void LLPanelVolume::onLightSelectColor(LLUICtrl* ctrl, void* userdata) | |||
459 | } | 522 | } |
460 | } | 523 | } |
461 | 524 | ||
525 | void LLPanelVolume::onLightSelectTexture(LLUICtrl* ctrl, void* userdata) | ||
526 | { | ||
527 | LLPanelVolume* self = (LLPanelVolume*) userdata; | ||
528 | LLViewerObject* objectp = self->mObject; | ||
529 | if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) | ||
530 | { | ||
531 | return; | ||
532 | } | ||
533 | LLVOVolume *volobjp = (LLVOVolume *)objectp; | ||
534 | |||
535 | |||
536 | LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control"); | ||
537 | if(LightTextureCtrl) | ||
538 | { | ||
539 | LLUUID id = LightTextureCtrl->getImageAssetID(); | ||
540 | volobjp->setLightTextureID(id); | ||
541 | self->mLightSavedTexture = id; | ||
542 | } | ||
543 | } | ||
462 | // static | 544 | // static |
463 | void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) | 545 | void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) |
464 | { | 546 | { |
@@ -474,12 +556,47 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) | |||
474 | volobjp->setLightIntensity((F32)self->childGetValue("Light Intensity").asReal()); | 556 | volobjp->setLightIntensity((F32)self->childGetValue("Light Intensity").asReal()); |
475 | volobjp->setLightRadius((F32)self->childGetValue("Light Radius").asReal()); | 557 | volobjp->setLightRadius((F32)self->childGetValue("Light Radius").asReal()); |
476 | volobjp->setLightFalloff((F32)self->childGetValue("Light Falloff").asReal()); | 558 | volobjp->setLightFalloff((F32)self->childGetValue("Light Falloff").asReal()); |
559 | |||
477 | LLColorSwatchCtrl* LightColorSwatch = self->getChild<LLColorSwatchCtrl>("colorswatch"); | 560 | LLColorSwatchCtrl* LightColorSwatch = self->getChild<LLColorSwatchCtrl>("colorswatch"); |
478 | if(LightColorSwatch) | 561 | if(LightColorSwatch) |
479 | { | 562 | { |
480 | LLColor4 clr = LightColorSwatch->get(); | 563 | LLColor4 clr = LightColorSwatch->get(); |
481 | volobjp->setLightColor(LLColor3(clr)); | 564 | volobjp->setLightColor(LLColor3(clr)); |
482 | } | 565 | } |
566 | |||
567 | LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control"); | ||
568 | if(LightTextureCtrl) | ||
569 | { | ||
570 | LLUUID id = LightTextureCtrl->getImageAssetID(); | ||
571 | if (id.notNull()) | ||
572 | { | ||
573 | if (volobjp->getLightTextureID().isNull()) | ||
574 | { //this commit is making this a spot light, set UI to default params | ||
575 | volobjp->setLightTextureID(id); | ||
576 | LLVector3 spot_params = volobjp->getSpotLightParams(); | ||
577 | self->childSetValue("Light FOV", spot_params.mV[0]); | ||
578 | self->childSetValue("Light Focus", spot_params.mV[1]); | ||
579 | self->childSetValue("Light Ambiance", spot_params.mV[2]); | ||
580 | } | ||
581 | else | ||
582 | { //modifying existing params | ||
583 | LLVector3 spot_params; | ||
584 | spot_params.mV[0] = (F32) self->childGetValue("Light FOV").asReal(); | ||
585 | spot_params.mV[1] = (F32) self->childGetValue("Light Focus").asReal(); | ||
586 | spot_params.mV[2] = (F32) self->childGetValue("Light Ambiance").asReal(); | ||
587 | volobjp->setSpotLightParams(spot_params); | ||
588 | } | ||
589 | } | ||
590 | else if (volobjp->getLightTextureID().notNull()) | ||
591 | { //no longer a spot light | ||
592 | volobjp->setLightTextureID(id); | ||
593 | //self->childDisable("Light FOV"); | ||
594 | //self->childDisable("Light Focus"); | ||
595 | //self->childDisable("Light Ambiance"); | ||
596 | } | ||
597 | } | ||
598 | |||
599 | |||
483 | } | 600 | } |
484 | 601 | ||
485 | // static | 602 | // static |
diff --git a/linden/indra/newview/llpanelvolume.h b/linden/indra/newview/llpanelvolume.h index 841880b..5d206fc 100644 --- a/linden/indra/newview/llpanelvolume.h +++ b/linden/indra/newview/llpanelvolume.h | |||
@@ -74,6 +74,10 @@ public: | |||
74 | static void onLightCancelColor(LLUICtrl* ctrl, void* userdata); | 74 | static void onLightCancelColor(LLUICtrl* ctrl, void* userdata); |
75 | static void onLightSelectColor(LLUICtrl* ctrl, void* userdata); | 75 | static void onLightSelectColor(LLUICtrl* ctrl, void* userdata); |
76 | 76 | ||
77 | static void onLightCancelTexture(LLUICtrl* ctrl, void* userdata); | ||
78 | static void onLightSelectTexture(LLUICtrl* ctrl, void* userdata); | ||
79 | |||
80 | |||
77 | protected: | 81 | protected: |
78 | void getState(); | 82 | void getState(); |
79 | 83 | ||
@@ -99,6 +103,7 @@ protected: | |||
99 | */ | 103 | */ |
100 | 104 | ||
101 | LLColor4 mLightSavedColor; | 105 | LLColor4 mLightSavedColor; |
106 | LLUUID mLightSavedTexture; | ||
102 | LLPointer<LLViewerObject> mObject; | 107 | LLPointer<LLViewerObject> mObject; |
103 | LLPointer<LLViewerObject> mRootObject; | 108 | LLPointer<LLViewerObject> mRootObject; |
104 | }; | 109 | }; |
diff --git a/linden/indra/newview/llpostprocess.cpp b/linden/indra/newview/llpostprocess.cpp new file mode 100644 index 0000000..c7d5dad --- /dev/null +++ b/linden/indra/newview/llpostprocess.cpp | |||
@@ -0,0 +1,594 @@ | |||
1 | /** | ||
2 | * @file llpostprocess.cpp | ||
3 | * @brief LLPostProcess class implementation | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #include "llviewerprecompiledheaders.h" | ||
34 | |||
35 | #include "linden_common.h" | ||
36 | |||
37 | #include "llpostprocess.h" | ||
38 | #include "llglslshader.h" | ||
39 | #include "llsdserialize.h" | ||
40 | #include "llrender.h" | ||
41 | |||
42 | #include "llviewershadermgr.h" // KL throwing some includes at postprocess see if we can get the bastard working! | ||
43 | #include "pipeline.h" | ||
44 | #include "llimagegl.h" | ||
45 | |||
46 | |||
47 | |||
48 | LLPostProcess * gPostProcess = NULL; | ||
49 | |||
50 | |||
51 | static const unsigned int NOISE_SIZE = 512; | ||
52 | |||
53 | /// CALCULATING LUMINANCE (Using NTSC lum weights) | ||
54 | /// http://en.wikipedia.org/wiki/Luma_%28video%29 | ||
55 | static const float LUMINANCE_R = 0.299f; | ||
56 | static const float LUMINANCE_G = 0.587f; | ||
57 | static const float LUMINANCE_B = 0.114f; | ||
58 | |||
59 | static const char * const XML_FILENAME = "postprocesseffects.xml"; | ||
60 | |||
61 | LLPostProcess::LLPostProcess(void) : | ||
62 | initialized(false), | ||
63 | mAllEffects(LLSD::emptyMap()), | ||
64 | screenW(1), screenH(1) | ||
65 | { | ||
66 | mSceneRenderTexture = NULL ; | ||
67 | mNoiseTexture = NULL ; | ||
68 | mTempBloomTexture = NULL ; | ||
69 | |||
70 | // Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. | ||
71 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); | ||
72 | LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; | ||
73 | |||
74 | llifstream effectsXML(pathName); | ||
75 | |||
76 | if (effectsXML) | ||
77 | { | ||
78 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
79 | |||
80 | parser->parse(effectsXML, mAllEffects, LLSDSerialize::SIZE_UNLIMITED); | ||
81 | } | ||
82 | |||
83 | if (!mAllEffects.has("default")) | ||
84 | { | ||
85 | LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap()); | ||
86 | |||
87 | defaultEffect["enable_night_vision"] = LLSD::Boolean(false); | ||
88 | defaultEffect["enable_bloom"] = LLSD::Boolean(false); | ||
89 | defaultEffect["enable_color_filter"] = LLSD::Boolean(false); | ||
90 | |||
91 | /// NVG Defaults | ||
92 | defaultEffect["brightness_multiplier"] = 3.0; | ||
93 | defaultEffect["noise_size"] = 25.0; | ||
94 | defaultEffect["noise_strength"] = 0.4; | ||
95 | |||
96 | // TODO BTest potentially add this to tweaks? | ||
97 | noiseTextureScale = 1.0f; | ||
98 | |||
99 | /// Bloom Defaults | ||
100 | defaultEffect["extract_low"] = 0.95; | ||
101 | defaultEffect["extract_high"] = 1.0; | ||
102 | defaultEffect["bloom_width"] = 2.25; | ||
103 | defaultEffect["bloom_strength"] = 1.5; | ||
104 | |||
105 | /// Color Filter Defaults | ||
106 | defaultEffect["brightness"] = 1.0; | ||
107 | defaultEffect["contrast"] = 1.0; | ||
108 | defaultEffect["saturation"] = 1.0; | ||
109 | |||
110 | LLSD& contrastBase = (defaultEffect["contrast_base"] = LLSD::emptyArray()); | ||
111 | contrastBase.append(1.0); | ||
112 | contrastBase.append(1.0); | ||
113 | contrastBase.append(1.0); | ||
114 | contrastBase.append(0.5); | ||
115 | } | ||
116 | |||
117 | setSelectedEffect("default"); | ||
118 | |||
119 | } | ||
120 | |||
121 | LLPostProcess::~LLPostProcess(void) | ||
122 | { | ||
123 | invalidate() ; | ||
124 | } | ||
125 | |||
126 | // static | ||
127 | void LLPostProcess::initClass(void) | ||
128 | { | ||
129 | //this will cause system to crash at second time login | ||
130 | //if first time login fails due to network connection --- bao | ||
131 | //***llassert_always(gPostProcess == NULL); | ||
132 | //replaced by the following line: | ||
133 | if(gPostProcess) | ||
134 | return ; | ||
135 | |||
136 | |||
137 | gPostProcess = new LLPostProcess(); | ||
138 | } | ||
139 | |||
140 | // static | ||
141 | void LLPostProcess::cleanupClass() | ||
142 | { | ||
143 | delete gPostProcess; | ||
144 | gPostProcess = NULL; | ||
145 | } | ||
146 | |||
147 | void LLPostProcess::setSelectedEffect(std::string const & effectName) | ||
148 | { | ||
149 | mSelectedEffectName = effectName; | ||
150 | static_cast<LLSD &>(tweaks) = mAllEffects[effectName]; | ||
151 | } | ||
152 | |||
153 | void LLPostProcess::saveEffect(std::string const & effectName) | ||
154 | { | ||
155 | // Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. | ||
156 | mAllEffects[effectName] = tweaks; | ||
157 | |||
158 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); | ||
159 | //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl; | ||
160 | |||
161 | llofstream effectsXML(pathName); | ||
162 | |||
163 | LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); | ||
164 | |||
165 | formatter->format(mAllEffects, effectsXML); | ||
166 | |||
167 | } | ||
168 | void LLPostProcess::invalidate() | ||
169 | { | ||
170 | mSceneRenderTexture = NULL ; | ||
171 | mNoiseTexture = NULL ; | ||
172 | mTempBloomTexture = NULL ; | ||
173 | initialized = FALSE ; | ||
174 | } | ||
175 | |||
176 | void LLPostProcess::apply(unsigned int width, unsigned int height) | ||
177 | { | ||
178 | if (!initialized || width != screenW || height != screenH){ | ||
179 | initialize(width, height); | ||
180 | } | ||
181 | if (shadersEnabled()){ | ||
182 | doEffects(); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | void LLPostProcess::initialize(unsigned int width, unsigned int height) | ||
187 | { | ||
188 | screenW = width; | ||
189 | screenH = height; | ||
190 | createTexture(mSceneRenderTexture, screenW, screenH); | ||
191 | initialized = true; | ||
192 | |||
193 | checkError(); | ||
194 | createNightVisionShader(); | ||
195 | createBloomShader(); | ||
196 | createColorFilterShader(); | ||
197 | checkError(); | ||
198 | } | ||
199 | |||
200 | inline bool LLPostProcess::shadersEnabled(void) | ||
201 | { | ||
202 | return (tweaks.useColorFilter().asBoolean() || | ||
203 | tweaks.useNightVisionShader().asBoolean() || | ||
204 | tweaks.useBloomShader().asBoolean() ); | ||
205 | |||
206 | } | ||
207 | |||
208 | void LLPostProcess::applyShaders(void) | ||
209 | { | ||
210 | if (tweaks.useColorFilter()){ | ||
211 | applyColorFilterShader(); | ||
212 | checkError(); | ||
213 | } | ||
214 | if (tweaks.useNightVisionShader()){ | ||
215 | /// If any of the above shaders have been called update the frame buffer; | ||
216 | if (tweaks.useColorFilter()) | ||
217 | { | ||
218 | U32 tex = mSceneRenderTexture->getTexName() ; | ||
219 | copyFrameBuffer(tex, screenW, screenH); | ||
220 | } | ||
221 | applyNightVisionShader(); | ||
222 | checkError(); | ||
223 | } | ||
224 | if (tweaks.useBloomShader()){ | ||
225 | /// If any of the above shaders have been called update the frame buffer; | ||
226 | if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()) | ||
227 | { | ||
228 | U32 tex = mSceneRenderTexture->getTexName() ; | ||
229 | copyFrameBuffer(tex, screenW, screenH); | ||
230 | } | ||
231 | applyBloomShader(); | ||
232 | checkError(); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | void LLPostProcess::applyColorFilterShader(void) | ||
237 | { | ||
238 | // Do nothing. moved back to newview work in progress KL | ||
239 | gPostColorFilterProgram.bind(); | ||
240 | |||
241 | gGL.getTexUnit(0)->activate(); | ||
242 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); | ||
243 | |||
244 | U32 tex = mSceneRenderTexture->getTexName() ; // KL | ||
245 | |||
246 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, tex); | ||
247 | |||
248 | getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); | ||
249 | glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); | ||
250 | glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness()); | ||
251 | glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast()); | ||
252 | float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f; | ||
253 | baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI); | ||
254 | float baseR = tweaks.getContrastBaseR() * baseI; | ||
255 | float baseG = tweaks.getContrastBaseG() * baseI; | ||
256 | float baseB = tweaks.getContrastBaseB() * baseI; | ||
257 | glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB); | ||
258 | glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation()); | ||
259 | glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); | ||
260 | |||
261 | LLGLEnable blend(GL_BLEND); | ||
262 | gGL.setSceneBlendType(LLRender::BT_REPLACE); | ||
263 | LLGLDepthTest depth(GL_FALSE); | ||
264 | |||
265 | /// Draw a screen space quad | ||
266 | drawOrthoQuad(screenW, screenH, QUAD_NORMAL); | ||
267 | gPostColorFilterProgram.unbind(); | ||
268 | |||
269 | } | ||
270 | |||
271 | void LLPostProcess::createColorFilterShader(void) | ||
272 | { | ||
273 | /// Define uniform names | ||
274 | colorFilterUniforms["RenderTexture"] = 0; | ||
275 | colorFilterUniforms["brightness"] = 0; | ||
276 | colorFilterUniforms["contrast"] = 0; | ||
277 | colorFilterUniforms["contrastBase"] = 0; | ||
278 | colorFilterUniforms["saturation"] = 0; | ||
279 | colorFilterUniforms["lumWeights"] = 0; | ||
280 | } | ||
281 | |||
282 | void LLPostProcess::applyNightVisionShader(void) | ||
283 | { | ||
284 | // KL re-enabled and moved back to newview | ||
285 | gPostNightVisionProgram.bind(); | ||
286 | |||
287 | gGL.getTexUnit(0)->activate(); | ||
288 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); | ||
289 | |||
290 | getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); | ||
291 | U32 sceneRenderTexture = mSceneRenderTexture->getTexName() ; // KL | ||
292 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); | ||
293 | glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); | ||
294 | |||
295 | gGL.getTexUnit(1)->activate(); | ||
296 | gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); | ||
297 | U32 noiseTexture = mNoiseTexture->getTexName(); //KL | ||
298 | gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture); | ||
299 | glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); | ||
300 | |||
301 | |||
302 | glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult()); | ||
303 | glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength()); | ||
304 | noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f); | ||
305 | noiseTextureScale *= (screenH / NOISE_SIZE); | ||
306 | |||
307 | |||
308 | glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); | ||
309 | |||
310 | LLGLEnable blend(GL_BLEND); | ||
311 | gGL.setSceneBlendType(LLRender::BT_REPLACE); | ||
312 | LLGLDepthTest depth(GL_FALSE); | ||
313 | |||
314 | /// Draw a screen space quad | ||
315 | drawOrthoQuad(screenW, screenH, QUAD_NOISE); | ||
316 | gPostNightVisionProgram.unbind(); | ||
317 | gGL.getTexUnit(0)->activate(); | ||
318 | |||
319 | } | ||
320 | |||
321 | void LLPostProcess::createNightVisionShader(void) | ||
322 | { | ||
323 | /// Define uniform names | ||
324 | nightVisionUniforms["RenderTexture"] = 0; | ||
325 | nightVisionUniforms["NoiseTexture"] = 0; | ||
326 | nightVisionUniforms["brightMult"] = 0; | ||
327 | nightVisionUniforms["noiseStrength"] = 0; | ||
328 | nightVisionUniforms["lumWeights"] = 0; | ||
329 | |||
330 | createNoiseTexture(mNoiseTexture); | ||
331 | } | ||
332 | |||
333 | void LLPostProcess::applyBloomShader(void) | ||
334 | { | ||
335 | |||
336 | } | ||
337 | |||
338 | void LLPostProcess::createBloomShader(void) | ||
339 | { | ||
340 | createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); | ||
341 | |||
342 | /// Create Bloom Extract Shader | ||
343 | bloomExtractUniforms["RenderTexture"] = 0; | ||
344 | bloomExtractUniforms["extractLow"] = 0; | ||
345 | bloomExtractUniforms["extractHigh"] = 0; | ||
346 | bloomExtractUniforms["lumWeights"] = 0; | ||
347 | |||
348 | /// Create Bloom Blur Shader | ||
349 | bloomBlurUniforms["RenderTexture"] = 0; | ||
350 | bloomBlurUniforms["bloomStrength"] = 0; | ||
351 | bloomBlurUniforms["texelSize"] = 0; | ||
352 | bloomBlurUniforms["blurDirection"] = 0; | ||
353 | bloomBlurUniforms["blurWidth"] = 0; | ||
354 | } | ||
355 | |||
356 | void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) | ||
357 | { | ||
358 | /// Find uniform locations and insert into map | ||
359 | std::map<const char *, GLuint>::iterator i; | ||
360 | for (i = uniforms.begin(); i != uniforms.end(); ++i){ | ||
361 | i->second = glGetUniformLocationARB(prog, i->first); | ||
362 | } | ||
363 | } | ||
364 | |||
365 | void LLPostProcess::doEffects(void) | ||
366 | { | ||
367 | /// Save GL State | ||
368 | glPushAttrib(GL_ALL_ATTRIB_BITS); | ||
369 | glPushClientAttrib(GL_ALL_ATTRIB_BITS); | ||
370 | |||
371 | /// Copy the screen buffer to the render texture | ||
372 | { | ||
373 | U32 tex = mSceneRenderTexture->getTexName() ; | ||
374 | copyFrameBuffer(tex, screenW, screenH); | ||
375 | } | ||
376 | |||
377 | /// Clear the frame buffer. | ||
378 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | ||
379 | glClear(GL_COLOR_BUFFER_BIT); | ||
380 | |||
381 | /// Change to an orthogonal view | ||
382 | viewOrthogonal(screenW, screenH); | ||
383 | |||
384 | checkError(); | ||
385 | applyShaders(); | ||
386 | |||
387 | LLGLSLShader::bindNoShader(); | ||
388 | checkError(); | ||
389 | |||
390 | /// Change to a perspective view | ||
391 | viewPerspective(); | ||
392 | |||
393 | /// Reset GL State | ||
394 | glPopClientAttrib(); | ||
395 | glPopAttrib(); | ||
396 | checkError(); | ||
397 | } | ||
398 | |||
399 | void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height) | ||
400 | { | ||
401 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); | ||
402 | glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); | ||
403 | } | ||
404 | |||
405 | void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type) | ||
406 | { | ||
407 | |||
408 | float noiseX = 0.f; | ||
409 | float noiseY = 0.f; | ||
410 | float screenRatio = 1.0f; | ||
411 | |||
412 | if (type == QUAD_NOISE){ | ||
413 | noiseX = ((float) rand() / (float) RAND_MAX); | ||
414 | noiseY = ((float) rand() / (float) RAND_MAX); | ||
415 | screenRatio = (float) width / (float) height; | ||
416 | } | ||
417 | |||
418 | |||
419 | glBegin(GL_QUADS); | ||
420 | if (type != QUAD_BLOOM_EXTRACT){ | ||
421 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height); | ||
422 | } else { | ||
423 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f); | ||
424 | } | ||
425 | if (type == QUAD_NOISE){ | ||
426 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, | ||
427 | noiseX, | ||
428 | noiseTextureScale + noiseY); | ||
429 | } else if (type == QUAD_BLOOM_COMBINE){ | ||
430 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f); | ||
431 | } | ||
432 | glVertex2f(0.f, (GLfloat) screenH - height); | ||
433 | |||
434 | if (type != QUAD_BLOOM_EXTRACT){ | ||
435 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); | ||
436 | } else { | ||
437 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); | ||
438 | } | ||
439 | if (type == QUAD_NOISE){ | ||
440 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, | ||
441 | noiseX, | ||
442 | noiseY); | ||
443 | } else if (type == QUAD_BLOOM_COMBINE){ | ||
444 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f); | ||
445 | } | ||
446 | glVertex2f(0.f, (GLfloat) height + (screenH - height)); | ||
447 | |||
448 | |||
449 | if (type != QUAD_BLOOM_EXTRACT){ | ||
450 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f); | ||
451 | } else { | ||
452 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f); | ||
453 | } | ||
454 | if (type == QUAD_NOISE){ | ||
455 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, | ||
456 | screenRatio * noiseTextureScale + noiseX, | ||
457 | noiseY); | ||
458 | } else if (type == QUAD_BLOOM_COMBINE){ | ||
459 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f); | ||
460 | } | ||
461 | glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height)); | ||
462 | |||
463 | |||
464 | if (type != QUAD_BLOOM_EXTRACT){ | ||
465 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height); | ||
466 | } else { | ||
467 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f); | ||
468 | } | ||
469 | if (type == QUAD_NOISE){ | ||
470 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, | ||
471 | screenRatio * noiseTextureScale + noiseX, | ||
472 | noiseTextureScale + noiseY); | ||
473 | } else if (type == QUAD_BLOOM_COMBINE){ | ||
474 | glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f); | ||
475 | } | ||
476 | glVertex2f((GLfloat) width, (GLfloat) screenH - height); | ||
477 | glEnd(); | ||
478 | |||
479 | } | ||
480 | |||
481 | void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) | ||
482 | { | ||
483 | glMatrixMode(GL_PROJECTION); | ||
484 | glPushMatrix(); | ||
485 | glLoadIdentity(); | ||
486 | glOrtho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); | ||
487 | glMatrixMode(GL_MODELVIEW); | ||
488 | glPushMatrix(); | ||
489 | glLoadIdentity(); | ||
490 | } | ||
491 | |||
492 | void LLPostProcess::viewPerspective(void) | ||
493 | { | ||
494 | glMatrixMode( GL_PROJECTION ); | ||
495 | glPopMatrix(); | ||
496 | glMatrixMode( GL_MODELVIEW ); | ||
497 | glPopMatrix(); | ||
498 | } | ||
499 | |||
500 | void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height) | ||
501 | { | ||
502 | viewPerspective(); | ||
503 | viewOrthogonal(width, height); | ||
504 | } | ||
505 | |||
506 | void LLPostProcess::createTexture(LLPointer<LLImageGL>& texture, unsigned int width, unsigned int height) | ||
507 | { | ||
508 | std::vector<GLubyte> data(width * height * 4, 0) ; | ||
509 | |||
510 | texture = new LLImageGL(FALSE) ; | ||
511 | if(texture->createGLTexture()) | ||
512 | { | ||
513 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName()); | ||
514 | glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, | ||
515 | GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); | ||
516 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
517 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); | ||
518 | } | ||
519 | } | ||
520 | |||
521 | void LLPostProcess::createNoiseTexture(LLPointer<LLImageGL>& texture) | ||
522 | { | ||
523 | std::vector<GLubyte> buffer(NOISE_SIZE * NOISE_SIZE); | ||
524 | for (unsigned int i = 0; i < NOISE_SIZE; i++){ | ||
525 | for (unsigned int k = 0; k < NOISE_SIZE; k++){ | ||
526 | buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); | ||
527 | } | ||
528 | } | ||
529 | |||
530 | texture = new LLImageGL(FALSE) ; | ||
531 | if(texture->createGLTexture()) | ||
532 | { | ||
533 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName()); | ||
534 | LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); | ||
535 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
536 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP); | ||
537 | } | ||
538 | } | ||
539 | |||
540 | bool LLPostProcess::checkError(void) | ||
541 | { | ||
542 | GLenum glErr; | ||
543 | bool retCode = false; | ||
544 | |||
545 | glErr = glGetError(); | ||
546 | while (glErr != GL_NO_ERROR) | ||
547 | { | ||
548 | // shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl; | ||
549 | char const * err_str_raw = (const char *) gluErrorString(glErr); | ||
550 | |||
551 | if(err_str_raw == NULL) | ||
552 | { | ||
553 | std::ostringstream err_builder; | ||
554 | err_builder << "unknown error number " << glErr; | ||
555 | mShaderErrorString = err_builder.str(); | ||
556 | } | ||
557 | else | ||
558 | { | ||
559 | mShaderErrorString = err_str_raw; | ||
560 | } | ||
561 | |||
562 | retCode = true; | ||
563 | glErr = glGetError(); | ||
564 | } | ||
565 | return retCode; | ||
566 | } | ||
567 | |||
568 | void LLPostProcess::checkShaderError(GLhandleARB shader) | ||
569 | { | ||
570 | GLint infologLength = 0; | ||
571 | GLint charsWritten = 0; | ||
572 | GLchar *infoLog; | ||
573 | |||
574 | checkError(); // Check for OpenGL errors | ||
575 | |||
576 | glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength); | ||
577 | |||
578 | checkError(); // Check for OpenGL errors | ||
579 | |||
580 | if (infologLength > 0) | ||
581 | { | ||
582 | infoLog = (GLchar *)malloc(infologLength); | ||
583 | if (infoLog == NULL) | ||
584 | { | ||
585 | /// Could not allocate infolog buffer | ||
586 | return; | ||
587 | } | ||
588 | glGetInfoLogARB(shader, infologLength, &charsWritten, infoLog); | ||
589 | // shaderErrorLog << (char *) infoLog << std::endl; | ||
590 | mShaderErrorString = (char *) infoLog; | ||
591 | free(infoLog); | ||
592 | } | ||
593 | checkError(); // Check for OpenGL errors | ||
594 | } \ No newline at end of file | ||
diff --git a/linden/indra/newview/llpostprocess.h b/linden/indra/newview/llpostprocess.h new file mode 100644 index 0000000..d6926e4 --- /dev/null +++ b/linden/indra/newview/llpostprocess.h | |||
@@ -0,0 +1,274 @@ | |||
1 | /** | ||
2 | * @file llpostprocess.h | ||
3 | * @brief LLPostProcess class definition | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #ifndef LL_POSTPROCESS_H | ||
34 | #define LL_POSTPROCESS_H | ||
35 | |||
36 | #include <map> | ||
37 | #include <fstream> | ||
38 | #include "llgl.h" | ||
39 | #include "llglheaders.h" | ||
40 | |||
41 | class LLPostProcess | ||
42 | { | ||
43 | public: | ||
44 | |||
45 | typedef enum _QuadType { | ||
46 | QUAD_NORMAL, | ||
47 | QUAD_NOISE, | ||
48 | QUAD_BLOOM_EXTRACT, | ||
49 | QUAD_BLOOM_COMBINE | ||
50 | } QuadType; | ||
51 | |||
52 | /// GLSL Shader Encapsulation Struct | ||
53 | typedef std::map<const char *, GLuint> glslUniforms; | ||
54 | |||
55 | struct PostProcessTweaks : public LLSD { | ||
56 | inline PostProcessTweaks() : LLSD(LLSD::emptyMap()) | ||
57 | { | ||
58 | } | ||
59 | |||
60 | inline LLSD & brightMult() { | ||
61 | return (*this)["brightness_multiplier"]; | ||
62 | } | ||
63 | |||
64 | inline LLSD & noiseStrength() { | ||
65 | return (*this)["noise_strength"]; | ||
66 | } | ||
67 | |||
68 | inline LLSD & noiseSize() { | ||
69 | return (*this)["noise_size"]; | ||
70 | } | ||
71 | |||
72 | inline LLSD & extractLow() { | ||
73 | return (*this)["extract_low"]; | ||
74 | } | ||
75 | |||
76 | inline LLSD & extractHigh() { | ||
77 | return (*this)["extract_high"]; | ||
78 | } | ||
79 | |||
80 | inline LLSD & bloomWidth() { | ||
81 | return (*this)["bloom_width"]; | ||
82 | } | ||
83 | |||
84 | inline LLSD & bloomStrength() { | ||
85 | return (*this)["bloom_strength"]; | ||
86 | } | ||
87 | |||
88 | inline LLSD & brightness() { | ||
89 | return (*this)["brightness"]; | ||
90 | } | ||
91 | |||
92 | inline LLSD & contrast() { | ||
93 | return (*this)["contrast"]; | ||
94 | } | ||
95 | |||
96 | inline LLSD & contrastBaseR() { | ||
97 | return (*this)["contrast_base"][0]; | ||
98 | } | ||
99 | |||
100 | inline LLSD & contrastBaseG() { | ||
101 | return (*this)["contrast_base"][1]; | ||
102 | } | ||
103 | |||
104 | inline LLSD & contrastBaseB() { | ||
105 | return (*this)["contrast_base"][2]; | ||
106 | } | ||
107 | |||
108 | inline LLSD & contrastBaseIntensity() { | ||
109 | return (*this)["contrast_base"][3]; | ||
110 | } | ||
111 | |||
112 | inline LLSD & saturation() { | ||
113 | return (*this)["saturation"]; | ||
114 | } | ||
115 | |||
116 | inline LLSD & useNightVisionShader() { | ||
117 | return (*this)["enable_night_vision"]; | ||
118 | } | ||
119 | |||
120 | inline LLSD & useBloomShader() { | ||
121 | return (*this)["enable_bloom"]; | ||
122 | } | ||
123 | |||
124 | inline LLSD & useColorFilter() { | ||
125 | return (*this)["enable_color_filter"]; | ||
126 | } | ||
127 | |||
128 | |||
129 | inline F32 getBrightMult() const { | ||
130 | return F32((*this)["brightness_multiplier"].asReal()); | ||
131 | } | ||
132 | |||
133 | inline F32 getNoiseStrength() const { | ||
134 | return F32((*this)["noise_strength"].asReal()); | ||
135 | } | ||
136 | |||
137 | inline F32 getNoiseSize() const { | ||
138 | return F32((*this)["noise_size"].asReal()); | ||
139 | } | ||
140 | |||
141 | inline F32 getExtractLow() const { | ||
142 | return F32((*this)["extract_low"].asReal()); | ||
143 | } | ||
144 | |||
145 | inline F32 getExtractHigh() const { | ||
146 | return F32((*this)["extract_high"].asReal()); | ||
147 | } | ||
148 | |||
149 | inline F32 getBloomWidth() const { | ||
150 | return F32((*this)["bloom_width"].asReal()); | ||
151 | } | ||
152 | |||
153 | inline F32 getBloomStrength() const { | ||
154 | return F32((*this)["bloom_strength"].asReal()); | ||
155 | } | ||
156 | |||
157 | inline F32 getBrightness() const { | ||
158 | return F32((*this)["brightness"].asReal()); | ||
159 | } | ||
160 | |||
161 | inline F32 getContrast() const { | ||
162 | return F32((*this)["contrast"].asReal()); | ||
163 | } | ||
164 | |||
165 | inline F32 getContrastBaseR() const { | ||
166 | return F32((*this)["contrast_base"][0].asReal()); | ||
167 | } | ||
168 | |||
169 | inline F32 getContrastBaseG() const { | ||
170 | return F32((*this)["contrast_base"][1].asReal()); | ||
171 | } | ||
172 | |||
173 | inline F32 getContrastBaseB() const { | ||
174 | return F32((*this)["contrast_base"][2].asReal()); | ||
175 | } | ||
176 | |||
177 | inline F32 getContrastBaseIntensity() const { | ||
178 | return F32((*this)["contrast_base"][3].asReal()); | ||
179 | } | ||
180 | |||
181 | inline F32 getSaturation() const { | ||
182 | return F32((*this)["saturation"].asReal()); | ||
183 | } | ||
184 | |||
185 | }; | ||
186 | |||
187 | bool initialized; | ||
188 | PostProcessTweaks tweaks; | ||
189 | |||
190 | // the map of all availible effects | ||
191 | LLSD mAllEffects; | ||
192 | |||
193 | private: | ||
194 | LLPointer<LLImageGL> mSceneRenderTexture ; | ||
195 | LLPointer<LLImageGL> mNoiseTexture ; | ||
196 | LLPointer<LLImageGL> mTempBloomTexture ; | ||
197 | |||
198 | |||
199 | |||
200 | public: | ||
201 | LLPostProcess(void); | ||
202 | |||
203 | ~LLPostProcess(void); | ||
204 | |||
205 | void apply(unsigned int width, unsigned int height); | ||
206 | void invalidate() ; | ||
207 | |||
208 | /// Perform global initialization for this class. | ||
209 | static void initClass(void); | ||
210 | |||
211 | // Cleanup of global data that's only inited once per class. | ||
212 | static void cleanupClass(); | ||
213 | |||
214 | void setSelectedEffect(std::string const & effectName); | ||
215 | |||
216 | inline std::string const & getSelectedEffect(void) const { | ||
217 | return mSelectedEffectName; | ||
218 | } | ||
219 | |||
220 | void saveEffect(std::string const & effectName); | ||
221 | |||
222 | private: | ||
223 | /// read in from file | ||
224 | std::string mShaderErrorString; | ||
225 | unsigned int screenW; | ||
226 | unsigned int screenH; | ||
227 | |||
228 | float noiseTextureScale; | ||
229 | |||
230 | /// Shader Uniforms | ||
231 | glslUniforms nightVisionUniforms; | ||
232 | glslUniforms bloomExtractUniforms; | ||
233 | glslUniforms bloomBlurUniforms; | ||
234 | glslUniforms colorFilterUniforms; | ||
235 | |||
236 | // the name of currently selected effect in mAllEffects | ||
237 | //invariant: tweaks == mAllEffects[mSelectedEffectName] | ||
238 | std::string mSelectedEffectName; | ||
239 | |||
240 | /// General functions | ||
241 | void initialize(unsigned int width, unsigned int height); | ||
242 | void doEffects(void); | ||
243 | void applyShaders(void); | ||
244 | bool shadersEnabled(void); | ||
245 | |||
246 | /// Night Vision Functions | ||
247 | void createNightVisionShader(void); | ||
248 | void applyNightVisionShader(void); | ||
249 | |||
250 | /// Bloom Functions | ||
251 | void createBloomShader(void); | ||
252 | void applyBloomShader(void); | ||
253 | |||
254 | /// Color Filter Functions | ||
255 | void createColorFilterShader(void); | ||
256 | void applyColorFilterShader(void); | ||
257 | |||
258 | /// OpenGL Helper Functions | ||
259 | void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); | ||
260 | void createTexture(LLPointer<LLImageGL>& texture, unsigned int width, unsigned int height); | ||
261 | void copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height); | ||
262 | void createNoiseTexture(LLPointer<LLImageGL>& texture); | ||
263 | bool checkError(void); | ||
264 | void checkShaderError(GLhandleARB shader); | ||
265 | void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); | ||
266 | void viewOrthogonal(unsigned int width, unsigned int height); | ||
267 | void changeOrthogonal(unsigned int width, unsigned int height); | ||
268 | void viewPerspective(void); | ||
269 | }; | ||
270 | |||
271 | extern LLPostProcess * gPostProcess; | ||
272 | |||
273 | |||
274 | #endif // LL_POSTPROCESS_H | ||
diff --git a/linden/indra/newview/llpreview.cpp b/linden/indra/newview/llpreview.cpp index f679a75..019bd5f 100644 --- a/linden/indra/newview/llpreview.cpp +++ b/linden/indra/newview/llpreview.cpp | |||
@@ -641,6 +641,7 @@ void LLPreview::setAssetId(const LLUUID& asset_id) | |||
641 | LLViewerObject* object = gObjectList.findObject(mObjectUUID); | 641 | LLViewerObject* object = gObjectList.findObject(mObjectUUID); |
642 | if(NULL == object) | 642 | if(NULL == object) |
643 | { | 643 | { |
644 | llwarns << "LLPreview::setAssetId() called on unrecognized object, UUID : " << mObjectUUID << llendl; | ||
644 | return; | 645 | return; |
645 | } | 646 | } |
646 | object->updateViewerInventoryAsset(item, asset_id); | 647 | object->updateViewerInventoryAsset(item, asset_id); |
diff --git a/linden/indra/newview/llselectmgr.cpp b/linden/indra/newview/llselectmgr.cpp index b2904b9..0fa8285 100644 --- a/linden/indra/newview/llselectmgr.cpp +++ b/linden/indra/newview/llselectmgr.cpp | |||
@@ -764,7 +764,7 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab | |||
764 | } | 764 | } |
765 | else | 765 | else |
766 | { | 766 | { |
767 | llerrs << "LLSelectMgr::add face " << face << " out-of-range" << llendl; | 767 | llwarns << "LLSelectMgr::add face " << face << " out-of-range" << llendl; |
768 | return; | 768 | return; |
769 | } | 769 | } |
770 | 770 | ||
@@ -1187,7 +1187,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable) | |||
1187 | } | 1187 | } |
1188 | else | 1188 | else |
1189 | { | 1189 | { |
1190 | llerrs << "LLSelectMgr::remove - tried to remove TE " << te << " that wasn't selected" << llendl; | 1190 | llwarns << "LLSelectMgr::remove - tried to remove TE " << te << " that wasn't selected" << llendl; |
1191 | return; | 1191 | return; |
1192 | } | 1192 | } |
1193 | 1193 | ||
@@ -1210,7 +1210,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable) | |||
1210 | else | 1210 | else |
1211 | { | 1211 | { |
1212 | // ...out of range face | 1212 | // ...out of range face |
1213 | llerrs << "LLSelectMgr::remove - TE " << te << " out of range" << llendl; | 1213 | llwarns << "LLSelectMgr::remove - TE " << te << " out of range" << llendl; |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | updateSelectionCenter(); | 1216 | updateSelectionCenter(); |
@@ -1709,7 +1709,7 @@ void LLSelectMgr::selectionSetFullbright(U8 fullbright) | |||
1709 | } sendfunc(fullbright); | 1709 | } sendfunc(fullbright); |
1710 | getSelection()->applyToObjects(&sendfunc); | 1710 | getSelection()->applyToObjects(&sendfunc); |
1711 | } | 1711 | } |
1712 | 1712 | /* | |
1713 | void LLSelectMgr::selectionSetMediaTypeAndURL(U8 media_type, const std::string& media_url) | 1713 | void LLSelectMgr::selectionSetMediaTypeAndURL(U8 media_type, const std::string& media_url) |
1714 | { | 1714 | { |
1715 | U8 media_flags = LLTextureEntry::MF_NONE; | 1715 | U8 media_flags = LLTextureEntry::MF_NONE; |
@@ -1752,7 +1752,7 @@ void LLSelectMgr::selectionSetMediaTypeAndURL(U8 media_type, const std::string& | |||
1752 | } sendfunc(media_type, media_url); | 1752 | } sendfunc(media_type, media_url); |
1753 | getSelection()->applyToObjects(&sendfunc); | 1753 | getSelection()->applyToObjects(&sendfunc); |
1754 | } | 1754 | } |
1755 | 1755 | */ | |
1756 | void LLSelectMgr::selectionSetGlow(F32 glow) | 1756 | void LLSelectMgr::selectionSetGlow(F32 glow) |
1757 | { | 1757 | { |
1758 | struct f1 : public LLSelectedTEFunctor | 1758 | struct f1 : public LLSelectedTEFunctor |
@@ -3344,7 +3344,7 @@ void LLSelectMgr::packPermissionsHead(void* user_data) | |||
3344 | /* | 3344 | /* |
3345 | void LLSelectMgr::sendSelect() | 3345 | void LLSelectMgr::sendSelect() |
3346 | { | 3346 | { |
3347 | llerrs << "Not implemented" << llendl; | 3347 | llwarns << "Not implemented" << llendl; |
3348 | } | 3348 | } |
3349 | */ | 3349 | */ |
3350 | 3350 | ||
@@ -4156,7 +4156,7 @@ void LLSelectMgr::sendListToRegions(const std::string& message_name, | |||
4156 | break; | 4156 | break; |
4157 | 4157 | ||
4158 | default: | 4158 | default: |
4159 | llerrs << "Bad send type " << send_type << " passed to SendListToRegions()" << llendl; | 4159 | llwarns << "Bad send type " << send_type << " passed to SendListToRegions()" << llendl; |
4160 | } | 4160 | } |
4161 | 4161 | ||
4162 | // bail if nothing selected | 4162 | // bail if nothing selected |
@@ -4563,11 +4563,6 @@ extern LLGLdouble gGLModelView[16]; | |||
4563 | 4563 | ||
4564 | void LLSelectMgr::updateSilhouettes() | 4564 | void LLSelectMgr::updateSilhouettes() |
4565 | { | 4565 | { |
4566 | if (!mRenderSilhouettes || !LLSelectMgr::sRenderSelectionHighlights) | ||
4567 | { | ||
4568 | return; | ||
4569 | } | ||
4570 | |||
4571 | S32 num_sils_genned = 0; | 4566 | S32 num_sils_genned = 0; |
4572 | 4567 | ||
4573 | LLVector3d cameraPos = gAgent.getCameraPositionGlobal(); | 4568 | LLVector3d cameraPos = gAgent.getCameraPositionGlobal(); |
@@ -5781,8 +5776,7 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object) | |||
5781 | } | 5776 | } |
5782 | 5777 | ||
5783 | if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || | 5778 | if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || |
5784 | (gSavedSettings.getBOOL("SelectMovableOnly") && !object->permMove()) || | 5779 | (gSavedSettings.getBOOL("SelectMovableOnly") && !object->permMove())) |
5785 | (gSavedSettings.getBOOL("SelectCopyableOnly") && !object->permCopy())) | ||
5786 | { | 5780 | { |
5787 | // only select my own objects | 5781 | // only select my own objects |
5788 | return FALSE; | 5782 | return FALSE; |
diff --git a/linden/indra/newview/llselectmgr.h b/linden/indra/newview/llselectmgr.h index 6278049..b565770 100644 --- a/linden/indra/newview/llselectmgr.h +++ b/linden/indra/newview/llselectmgr.h | |||
@@ -503,7 +503,7 @@ public: | |||
503 | void selectionSetTexGen( U8 texgen ); | 503 | void selectionSetTexGen( U8 texgen ); |
504 | void selectionSetShiny( U8 shiny ); | 504 | void selectionSetShiny( U8 shiny ); |
505 | void selectionSetFullbright( U8 fullbright ); | 505 | void selectionSetFullbright( U8 fullbright ); |
506 | void selectionSetMediaTypeAndURL( U8 media_type, const std::string& media_url ); | 506 | // void selectionSetMediaTypeAndURL( U8 media_type, const std::string& media_url ); |
507 | void selectionSetClickAction(U8 action); | 507 | void selectionSetClickAction(U8 action); |
508 | void selectionSetIncludeInSearch(bool include_in_search); | 508 | void selectionSetIncludeInSearch(bool include_in_search); |
509 | void selectionSetGlow(const F32 glow); | 509 | void selectionSetGlow(const F32 glow); |
diff --git a/linden/indra/newview/llsky.cpp b/linden/indra/newview/llsky.cpp index ac7e865..b779aa0 100644 --- a/linden/indra/newview/llsky.cpp +++ b/linden/indra/newview/llsky.cpp | |||
@@ -422,6 +422,20 @@ void LLSky::updateFog(const F32 distance) | |||
422 | 422 | ||
423 | void LLSky::updateCull() | 423 | void LLSky::updateCull() |
424 | { | 424 | { |
425 | /*if (mVOSkyp.notNull() && mVOSkyp->mDrawable.notNull()) | ||
426 | { | ||
427 | gPipeline.markVisible(mVOSkyp->mDrawable); | ||
428 | } | ||
429 | else | ||
430 | { | ||
431 | llinfos << "No sky drawable!" << llendl; | ||
432 | }*/ | ||
433 | |||
434 | /*if (mVOGroundp.notNull() && mVOGroundp->mDrawable.notNull()) | ||
435 | { | ||
436 | gPipeline.markVisible(mVOGroundp->mDrawable); | ||
437 | }*/ | ||
438 | |||
425 | // *TODO: do culling for wl sky properly -Brad | 439 | // *TODO: do culling for wl sky properly -Brad |
426 | } | 440 | } |
427 | 441 | ||
diff --git a/linden/indra/newview/llspatialpartition.cpp b/linden/indra/newview/llspatialpartition.cpp index 31b537c..114d3b5 100644 --- a/linden/indra/newview/llspatialpartition.cpp +++ b/linden/indra/newview/llspatialpartition.cpp | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "llrender.h" | 48 | #include "llrender.h" |
49 | #include "lloctree.h" | 49 | #include "lloctree.h" |
50 | #include "llvoavatar.h" | 50 | #include "llvoavatar.h" |
51 | #include "lltextureatlas.h" | ||
51 | 52 | ||
52 | const F32 SG_OCCLUSION_FUDGE = 0.25f; | 53 | const F32 SG_OCCLUSION_FUDGE = 0.25f; |
53 | #define SG_DISCARD_TOLERANCE 0.01f | 54 | #define SG_DISCARD_TOLERANCE 0.01f |
@@ -95,7 +96,7 @@ void sg_assert(BOOL expr) | |||
95 | #if LL_OCTREE_PARANOIA_CHECK | 96 | #if LL_OCTREE_PARANOIA_CHECK |
96 | if (!expr) | 97 | if (!expr) |
97 | { | 98 | { |
98 | llerrs << "Octree invalid!" << llendl; | 99 | llwarns << "Octree invalid!" << llendl; |
99 | } | 100 | } |
100 | #endif | 101 | #endif |
101 | } | 102 | } |
@@ -281,10 +282,10 @@ S32 LLSphereAABB(const LLVector3& center, const LLVector3& size, const LLVector3 | |||
281 | 282 | ||
282 | LLSpatialGroup::~LLSpatialGroup() | 283 | LLSpatialGroup::~LLSpatialGroup() |
283 | { | 284 | { |
284 | if (sNoDelete) | 285 | /*if (sNoDelete) |
285 | { | 286 | { |
286 | llerrs << "Illegal deletion of LLSpatialGroup!" << llendl; | 287 | llwarns << "Illegal deletion of LLSpatialGroup!" << llendl; |
287 | } | 288 | }*/ |
288 | 289 | ||
289 | if (isState(DEAD)) | 290 | if (isState(DEAD)) |
290 | { | 291 | { |
@@ -302,6 +303,129 @@ LLSpatialGroup::~LLSpatialGroup() | |||
302 | 303 | ||
303 | LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); | 304 | LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); |
304 | clearDrawMap(); | 305 | clearDrawMap(); |
306 | clearAtlasList() ; | ||
307 | } | ||
308 | |||
309 | BOOL LLSpatialGroup::hasAtlas(LLTextureAtlas* atlasp) | ||
310 | { | ||
311 | S8 type = atlasp->getComponents() - 1 ; | ||
312 | for(std::list<LLTextureAtlas*>::iterator iter = mAtlasList[type].begin(); iter != mAtlasList[type].end() ; ++iter) | ||
313 | { | ||
314 | if(atlasp == *iter) | ||
315 | { | ||
316 | return TRUE ; | ||
317 | } | ||
318 | } | ||
319 | return FALSE ; | ||
320 | } | ||
321 | |||
322 | void LLSpatialGroup::addAtlas(LLTextureAtlas* atlasp, S8 recursive_level) | ||
323 | { | ||
324 | if(!hasAtlas(atlasp)) | ||
325 | { | ||
326 | mAtlasList[atlasp->getComponents() - 1].push_back(atlasp) ; | ||
327 | atlasp->addSpatialGroup(this) ; | ||
328 | } | ||
329 | |||
330 | --recursive_level; | ||
331 | if(recursive_level)//levels propagating up. | ||
332 | { | ||
333 | LLSpatialGroup* parent = getParent() ; | ||
334 | if(parent) | ||
335 | { | ||
336 | parent->addAtlas(atlasp, recursive_level) ; | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | |||
341 | void LLSpatialGroup::removeAtlas(LLTextureAtlas* atlasp, BOOL remove_group, S8 recursive_level) | ||
342 | { | ||
343 | mAtlasList[atlasp->getComponents() - 1].remove(atlasp) ; | ||
344 | if(remove_group) | ||
345 | { | ||
346 | atlasp->removeSpatialGroup(this) ; | ||
347 | } | ||
348 | |||
349 | --recursive_level; | ||
350 | if(recursive_level)//levels propagating up. | ||
351 | { | ||
352 | LLSpatialGroup* parent = getParent() ; | ||
353 | if(parent) | ||
354 | { | ||
355 | parent->removeAtlas(atlasp, recursive_level) ; | ||
356 | } | ||
357 | } | ||
358 | } | ||
359 | |||
360 | void LLSpatialGroup::clearAtlasList() | ||
361 | { | ||
362 | std::list<LLTextureAtlas*>::iterator iter ; | ||
363 | for(S8 i = 0 ; i < 4 ; i++) | ||
364 | { | ||
365 | if(mAtlasList[i].size() > 0) | ||
366 | { | ||
367 | for(iter = mAtlasList[i].begin(); iter != mAtlasList[i].end() ; ++iter) | ||
368 | { | ||
369 | ((LLTextureAtlas*)*iter)->removeSpatialGroup(this) ; | ||
370 | } | ||
371 | mAtlasList[i].clear() ; | ||
372 | } | ||
373 | } | ||
374 | } | ||
375 | |||
376 | LLTextureAtlas* LLSpatialGroup::getAtlas(S8 ncomponents, S8 to_be_reserved, S8 recursive_level) | ||
377 | { | ||
378 | S8 type = ncomponents - 1 ; | ||
379 | if(mAtlasList[type].size() > 0) | ||
380 | { | ||
381 | for(std::list<LLTextureAtlas*>::iterator iter = mAtlasList[type].begin(); iter != mAtlasList[type].end() ; ++iter) | ||
382 | { | ||
383 | if(!((LLTextureAtlas*)*iter)->isFull(to_be_reserved)) | ||
384 | { | ||
385 | return *iter ; | ||
386 | } | ||
387 | } | ||
388 | } | ||
389 | |||
390 | --recursive_level; | ||
391 | if(recursive_level) | ||
392 | { | ||
393 | LLSpatialGroup* parent = getParent() ; | ||
394 | if(parent) | ||
395 | { | ||
396 | return parent->getAtlas(ncomponents, to_be_reserved, recursive_level) ; | ||
397 | } | ||
398 | } | ||
399 | return NULL ; | ||
400 | } | ||
401 | |||
402 | void LLSpatialGroup::setCurUpdatingSlot(LLTextureAtlasSlot* slotp) | ||
403 | { | ||
404 | mCurUpdatingSlotp = slotp; | ||
405 | |||
406 | //if(!hasAtlas(mCurUpdatingSlotp->getAtlas())) | ||
407 | //{ | ||
408 | // addAtlas(mCurUpdatingSlotp->getAtlas()) ; | ||
409 | //} | ||
410 | } | ||
411 | |||
412 | LLTextureAtlasSlot* LLSpatialGroup::getCurUpdatingSlot(LLViewerImage* imagep, S8 recursive_level) | ||
413 | { | ||
414 | if(gFrameCount && mCurUpdatingTime == gFrameCount && mCurUpdatingTexture == imagep) | ||
415 | { | ||
416 | return mCurUpdatingSlotp ; | ||
417 | } | ||
418 | |||
419 | //--recursive_level ; | ||
420 | //if(recursive_level) | ||
421 | //{ | ||
422 | // LLSpatialGroup* parent = getParent() ; | ||
423 | // if(parent) | ||
424 | // { | ||
425 | // return parent->getCurUpdatingSlot(imagep, recursive_level) ; | ||
426 | // } | ||
427 | //} | ||
428 | return NULL ; | ||
305 | } | 429 | } |
306 | 430 | ||
307 | void LLSpatialGroup::clearDrawMap() | 431 | void LLSpatialGroup::clearDrawMap() |
@@ -348,7 +472,7 @@ void LLSpatialGroup::validate() | |||
348 | LLSpatialPartition* part = drawable->asPartition(); | 472 | LLSpatialPartition* part = drawable->asPartition(); |
349 | if (!part) | 473 | if (!part) |
350 | { | 474 | { |
351 | llerrs << "Drawable reports it is a spatial bridge but not a partition." << llendl; | 475 | llwarns << "Drawable reports it is a spatial bridge but not a partition." << llendl; |
352 | } | 476 | } |
353 | LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0); | 477 | LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0); |
354 | group->validate(); | 478 | group->validate(); |
@@ -411,7 +535,7 @@ public: | |||
411 | 535 | ||
412 | if (mInheritedMask && !group->isState(mInheritedMask)) | 536 | if (mInheritedMask && !group->isState(mInheritedMask)) |
413 | { | 537 | { |
414 | llerrs << "Spatial group failed inherited mask test." << llendl; | 538 | llwarns << "Spatial group failed inherited mask test." << llendl; |
415 | } | 539 | } |
416 | 540 | ||
417 | if (group->isState(LLSpatialGroup::DIRTY)) | 541 | if (group->isState(LLSpatialGroup::DIRTY)) |
@@ -427,7 +551,7 @@ public: | |||
427 | { | 551 | { |
428 | if (!parent->isState(state)) | 552 | if (!parent->isState(state)) |
429 | { | 553 | { |
430 | llerrs << "Spatial group failed parent state check." << llendl; | 554 | llwarns << "Spatial group failed parent state check." << llendl; |
431 | } | 555 | } |
432 | parent = parent->getParent(); | 556 | parent = parent->getParent(); |
433 | } | 557 | } |
@@ -448,39 +572,39 @@ void validate_draw_info(LLDrawInfo& params) | |||
448 | #if LL_OCTREE_PARANOIA_CHECK | 572 | #if LL_OCTREE_PARANOIA_CHECK |
449 | if (params.mVertexBuffer.isNull()) | 573 | if (params.mVertexBuffer.isNull()) |
450 | { | 574 | { |
451 | llerrs << "Draw batch has no vertex buffer." << llendl; | 575 | llwarns << "Draw batch has no vertex buffer." << llendl; |
452 | } | 576 | } |
453 | 577 | ||
454 | //bad range | 578 | //bad range |
455 | if (params.mStart >= params.mEnd) | 579 | if (params.mStart >= params.mEnd) |
456 | { | 580 | { |
457 | llerrs << "Draw batch has invalid range." << llendl; | 581 | llwarns << "Draw batch has invalid range." << llendl; |
458 | } | 582 | } |
459 | 583 | ||
460 | if (params.mEnd >= (U32) params.mVertexBuffer->getNumVerts()) | 584 | if (params.mEnd >= (U32) params.mVertexBuffer->getNumVerts()) |
461 | { | 585 | { |
462 | llerrs << "Draw batch has buffer overrun error." << llendl; | 586 | llwarns << "Draw batch has buffer overrun error." << llendl; |
463 | } | 587 | } |
464 | 588 | ||
465 | if (params.mOffset + params.mCount > (U32) params.mVertexBuffer->getNumIndices()) | 589 | if (params.mOffset + params.mCount > (U32) params.mVertexBuffer->getNumIndices()) |
466 | { | 590 | { |
467 | llerrs << "Draw batch has index buffer ovverrun error." << llendl; | 591 | llwarns << "Draw batch has index buffer ovverrun error." << llendl; |
468 | } | 592 | } |
469 | 593 | ||
470 | //bad indices | 594 | //bad indices |
471 | U32* indicesp = (U32*) params.mVertexBuffer->getIndicesPointer(); | 595 | U16* indicesp = (U16*) params.mVertexBuffer->getIndicesPointer(); // KL 16 indices for SD not 32 |
472 | if (indicesp) | 596 | if (indicesp) |
473 | { | 597 | { |
474 | for (U32 i = params.mOffset; i < params.mOffset+params.mCount; i++) | 598 | for (U32 i = params.mOffset; i < params.mOffset+params.mCount; i++) |
475 | { | 599 | { |
476 | if (indicesp[i] < params.mStart) | 600 | if (indicesp[i] < (U16)params.mStart) //KL |
477 | { | 601 | { |
478 | llerrs << "Draw batch has vertex buffer index out of range error (index too low)." << llendl; | 602 | llwarns << "Draw batch has vertex buffer index out of range error (index too low)." << llendl; |
479 | } | 603 | } |
480 | 604 | ||
481 | if (indicesp[i] > params.mEnd) | 605 | if (indicesp[i] > (U16)params.mEnd) // KL |
482 | { | 606 | { |
483 | llerrs << "Draw batch has vertex buffer index out of range error (index too high)." << llendl; | 607 | llwarns << "Draw batch has vertex buffer index out of range error (index too high)." << llendl; |
484 | } | 608 | } |
485 | } | 609 | } |
486 | } | 610 | } |
@@ -540,6 +664,7 @@ BOOL LLSpatialGroup::addObject(LLDrawable *drawablep, BOOL add_all, BOOL from_oc | |||
540 | drawablep->setSpatialGroup(this); | 664 | drawablep->setSpatialGroup(this); |
541 | validate_drawable(drawablep); | 665 | validate_drawable(drawablep); |
542 | setState(OBJECT_DIRTY | GEOM_DIRTY | DISCARD_QUERY); | 666 | setState(OBJECT_DIRTY | GEOM_DIRTY | DISCARD_QUERY); |
667 | gPipeline.markRebuild(this, TRUE); | ||
543 | if (drawablep->isSpatialBridge()) | 668 | if (drawablep->isSpatialBridge()) |
544 | { | 669 | { |
545 | mBridgeList.push_back((LLSpatialBridge*) drawablep); | 670 | mBridgeList.push_back((LLSpatialBridge*) drawablep); |
@@ -572,22 +697,23 @@ void LLSpatialGroup::rebuildMesh() | |||
572 | 697 | ||
573 | void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group) | 698 | void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group) |
574 | { | 699 | { |
575 | if (!gPipeline.hasRenderType(mDrawableType)) | 700 | /*if (!gPipeline.hasRenderType(mDrawableType)) |
576 | { | 701 | { |
577 | return; | 702 | return; |
578 | } | 703 | }*/ |
579 | |||
580 | if (!LLPipeline::sSkipUpdate && group->changeLOD()) | ||
581 | { | ||
582 | group->mLastUpdateDistance = group->mDistance; | ||
583 | group->mLastUpdateViewAngle = group->mViewAngle; | ||
584 | } | ||
585 | 704 | ||
586 | if (group->isDead() || !group->isState(LLSpatialGroup::GEOM_DIRTY)) | 705 | if (group->isDead() || !group->isState(LLSpatialGroup::GEOM_DIRTY)) |
587 | { | 706 | { |
707 | /*if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && mRenderByGroup) | ||
708 | { | ||
709 | llwarns << "WTF?" << llendl; | ||
710 | }*/ | ||
588 | return; | 711 | return; |
589 | } | 712 | } |
590 | 713 | ||
714 | group->mLastUpdateDistance = group->mDistance; | ||
715 | group->mLastUpdateViewAngle = group->mViewAngle; | ||
716 | |||
591 | LLFastTimer ftm(LLFastTimer::FTM_REBUILD_VBO); | 717 | LLFastTimer ftm(LLFastTimer::FTM_REBUILD_VBO); |
592 | 718 | ||
593 | group->clearDrawMap(); | 719 | group->clearDrawMap(); |
@@ -625,6 +751,7 @@ void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group) | |||
625 | group->clearState(LLSpatialGroup::GEOM_DIRTY); | 751 | group->clearState(LLSpatialGroup::GEOM_DIRTY); |
626 | } | 752 | } |
627 | 753 | ||
754 | |||
628 | void LLSpatialPartition::rebuildMesh(LLSpatialGroup* group) | 755 | void LLSpatialPartition::rebuildMesh(LLSpatialGroup* group) |
629 | { | 756 | { |
630 | 757 | ||
@@ -663,8 +790,11 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector3& minOut, LLVector3& maxO | |||
663 | drawablep = *i; | 790 | drawablep = *i; |
664 | minMax = drawablep->getSpatialExtents(); | 791 | minMax = drawablep->getSpatialExtents(); |
665 | 792 | ||
793 | update_min_max(newMin, newMax, minMax[0]); | ||
794 | update_min_max(newMin, newMax, minMax[1]); | ||
795 | |||
666 | //bin up the object | 796 | //bin up the object |
667 | for (U32 i = 0; i < 3; i++) | 797 | /*for (U32 i = 0; i < 3; i++) |
668 | { | 798 | { |
669 | if (minMax[0].mV[i] < newMin.mV[i]) | 799 | if (minMax[0].mV[i] < newMin.mV[i]) |
670 | { | 800 | { |
@@ -674,7 +804,7 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector3& minOut, LLVector3& maxO | |||
674 | { | 804 | { |
675 | newMax.mV[i] = minMax[1].mV[i]; | 805 | newMax.mV[i] = minMax[1].mV[i]; |
676 | } | 806 | } |
677 | } | 807 | }*/ |
678 | } | 808 | } |
679 | 809 | ||
680 | mObjectBounds[0] = (newMin + newMax) * 0.5f; | 810 | mObjectBounds[0] = (newMin + newMax) * 0.5f; |
@@ -738,6 +868,10 @@ LLSpatialGroup* LLSpatialGroup::getParent() | |||
738 | return NULL; | 868 | return NULL; |
739 | } | 869 | } |
740 | 870 | ||
871 | if(!mOctreeNode) | ||
872 | { | ||
873 | return NULL; | ||
874 | } | ||
741 | OctreeNode* parent = mOctreeNode->getOctParent(); | 875 | OctreeNode* parent = mOctreeNode->getOctParent(); |
742 | 876 | ||
743 | if (parent) | 877 | if (parent) |
@@ -763,6 +897,8 @@ BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree) | |||
763 | { | 897 | { |
764 | drawablep->setSpatialGroup(NULL); | 898 | drawablep->setSpatialGroup(NULL); |
765 | setState(GEOM_DIRTY); | 899 | setState(GEOM_DIRTY); |
900 | gPipeline.markRebuild(this, TRUE); | ||
901 | |||
766 | if (drawablep->isSpatialBridge()) | 902 | if (drawablep->isSpatialBridge()) |
767 | { | 903 | { |
768 | for (bridge_list_t::iterator i = mBridgeList.begin(); i != mBridgeList.end(); ++i) | 904 | for (bridge_list_t::iterator i = mBridgeList.begin(); i != mBridgeList.end(); ++i) |
@@ -799,6 +935,7 @@ void LLSpatialGroup::shift(const LLVector3 &offset) | |||
799 | //if (!mSpatialPartition->mRenderByGroup) | 935 | //if (!mSpatialPartition->mRenderByGroup) |
800 | { | 936 | { |
801 | setState(GEOM_DIRTY); | 937 | setState(GEOM_DIRTY); |
938 | gPipeline.markRebuild(this, TRUE); | ||
802 | } | 939 | } |
803 | 940 | ||
804 | if (mOcclusionVerts) | 941 | if (mOcclusionVerts) |
@@ -948,7 +1085,11 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : | |||
948 | mLastUpdateDistance(-1.f), | 1085 | mLastUpdateDistance(-1.f), |
949 | mLastUpdateTime(gFrameTimeSeconds), | 1086 | mLastUpdateTime(gFrameTimeSeconds), |
950 | mViewAngle(0.f), | 1087 | mViewAngle(0.f), |
951 | mLastUpdateViewAngle(-1.f) | 1088 | mLastUpdateViewAngle(-1.f), |
1089 | mAtlasList(4), | ||
1090 | mCurUpdatingTime(0), | ||
1091 | mCurUpdatingSlotp(NULL), | ||
1092 | mCurUpdatingTexture (NULL) | ||
952 | { | 1093 | { |
953 | sNodeCount++; | 1094 | sNodeCount++; |
954 | LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); | 1095 | LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); |
@@ -956,6 +1097,7 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : | |||
956 | sg_assert(mOctreeNode->getListenerCount() == 0); | 1097 | sg_assert(mOctreeNode->getListenerCount() == 0); |
957 | mOctreeNode->addListener(this); | 1098 | mOctreeNode->addListener(this); |
958 | setState(SG_INITIAL_STATE_MASK); | 1099 | setState(SG_INITIAL_STATE_MASK); |
1100 | gPipeline.markRebuild(this, TRUE); | ||
959 | 1101 | ||
960 | mBounds[0] = LLVector3(node->getCenter()); | 1102 | mBounds[0] = LLVector3(node->getCenter()); |
961 | mBounds[1] = LLVector3(node->getSize()); | 1103 | mBounds[1] = LLVector3(node->getSize()); |
@@ -975,7 +1117,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera) | |||
975 | #if !LL_RELEASE_FOR_DOWNLOAD | 1117 | #if !LL_RELEASE_FOR_DOWNLOAD |
976 | if (isState(LLSpatialGroup::OBJECT_DIRTY)) | 1118 | if (isState(LLSpatialGroup::OBJECT_DIRTY)) |
977 | { | 1119 | { |
978 | llerrs << "Spatial group dirty on distance update." << llendl; | 1120 | llwarns << "Spatial group dirty on distance update." << llendl; |
979 | } | 1121 | } |
980 | #endif | 1122 | #endif |
981 | if (!getData().empty() && !LLSpatialPartition::sFreezeState) | 1123 | if (!getData().empty() && !LLSpatialPartition::sFreezeState) |
@@ -1014,6 +1156,7 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera) | |||
1014 | //NOTE: If there is a trivial way to detect that alpha sorting here would not change the render order, | 1156 | //NOTE: If there is a trivial way to detect that alpha sorting here would not change the render order, |
1015 | //not setting this node to dirty would be a very good thing | 1157 | //not setting this node to dirty would be a very good thing |
1016 | group->setState(LLSpatialGroup::ALPHA_DIRTY); | 1158 | group->setState(LLSpatialGroup::ALPHA_DIRTY); |
1159 | gPipeline.markRebuild(group, FALSE); | ||
1017 | } | 1160 | } |
1018 | } | 1161 | } |
1019 | } | 1162 | } |
@@ -1050,6 +1193,18 @@ F32 LLSpatialPartition::calcPixelArea(LLSpatialGroup* group, LLCamera& camera) | |||
1050 | return LLPipeline::calcPixelArea(group->mObjectBounds[0], group->mObjectBounds[1], camera); | 1193 | return LLPipeline::calcPixelArea(group->mObjectBounds[0], group->mObjectBounds[1], camera); |
1051 | } | 1194 | } |
1052 | 1195 | ||
1196 | F32 LLSpatialGroup::getUpdateUrgency() const | ||
1197 | { | ||
1198 | if (!isVisible()) | ||
1199 | { | ||
1200 | return 0.f; | ||
1201 | } | ||
1202 | else | ||
1203 | { | ||
1204 | return (gFrameTimeSeconds - mLastUpdateTime+4.f)/mDistance; | ||
1205 | } | ||
1206 | } | ||
1207 | |||
1053 | BOOL LLSpatialGroup::needsUpdate() | 1208 | BOOL LLSpatialGroup::needsUpdate() |
1054 | { | 1209 | { |
1055 | return (LLDrawable::getCurrentFrame()%mSpatialPartition->mLODPeriod == mLODHash) ? TRUE : FALSE; | 1210 | return (LLDrawable::getCurrentFrame()%mSpatialPartition->mLODPeriod == mLODHash) ? TRUE : FALSE; |
@@ -1157,6 +1312,8 @@ void LLSpatialGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNo | |||
1157 | void LLSpatialGroup::destroyGL() | 1312 | void LLSpatialGroup::destroyGL() |
1158 | { | 1313 | { |
1159 | setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY); | 1314 | setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY); |
1315 | gPipeline.markRebuild(this, TRUE); | ||
1316 | |||
1160 | mLastUpdateTime = gFrameTimeSeconds; | 1317 | mLastUpdateTime = gFrameTimeSeconds; |
1161 | mVertexBuffer = NULL; | 1318 | mVertexBuffer = NULL; |
1162 | mBufferMap.clear(); | 1319 | mBufferMap.clear(); |
@@ -1339,7 +1496,8 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera) | |||
1339 | 1496 | ||
1340 | //============================================== | 1497 | //============================================== |
1341 | 1498 | ||
1342 | LLSpatialPartition::LLSpatialPartition(U32 data_mask, U32 buffer_usage) | 1499 | LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 buffer_usage) |
1500 | : mRenderByGroup(render_by_group) | ||
1343 | { | 1501 | { |
1344 | LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); | 1502 | LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); |
1345 | mOcclusionEnabled = TRUE; | 1503 | mOcclusionEnabled = TRUE; |
@@ -1351,7 +1509,7 @@ LLSpatialPartition::LLSpatialPartition(U32 data_mask, U32 buffer_usage) | |||
1351 | mBufferUsage = buffer_usage; | 1509 | mBufferUsage = buffer_usage; |
1352 | mDepthMask = FALSE; | 1510 | mDepthMask = FALSE; |
1353 | mSlopRatio = 0.25f; | 1511 | mSlopRatio = 0.25f; |
1354 | mRenderByGroup = TRUE; | 1512 | //mRenderByGroup = TRUE; |
1355 | mInfiniteFarClip = FALSE; | 1513 | mInfiniteFarClip = FALSE; |
1356 | 1514 | ||
1357 | LLGLNamePool::registerPool(&sQueryPool); | 1515 | LLGLNamePool::registerPool(&sQueryPool); |
@@ -1647,13 +1805,76 @@ public: | |||
1647 | return false; | 1805 | return false; |
1648 | } | 1806 | } |
1649 | 1807 | ||
1808 | virtual void traverse(const LLSpatialGroup::TreeNode* n) | ||
1809 | { | ||
1810 | LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0); | ||
1811 | |||
1812 | if (earlyFail(group)) | ||
1813 | { | ||
1814 | return; | ||
1815 | } | ||
1816 | |||
1817 | if (mRes == 2) | ||
1818 | { | ||
1819 | //fully in, don't traverse further (won't effect extents | ||
1820 | } | ||
1821 | else if (mRes && group->isState(LLSpatialGroup::SKIP_FRUSTUM_CHECK)) | ||
1822 | { //don't need to do frustum check | ||
1823 | LLSpatialGroup::OctreeTraveler::traverse(n); | ||
1824 | } | ||
1825 | else | ||
1826 | { | ||
1827 | mRes = frustumCheck(group); | ||
1828 | |||
1829 | if (mRes) | ||
1830 | { //at least partially in, run on down | ||
1831 | LLSpatialGroup::OctreeTraveler::traverse(n); | ||
1832 | } | ||
1833 | |||
1834 | mRes = 0; | ||
1835 | } | ||
1836 | } | ||
1837 | |||
1650 | virtual void processGroup(LLSpatialGroup* group) | 1838 | virtual void processGroup(LLSpatialGroup* group) |
1651 | { | 1839 | { |
1652 | if (group->mObjectBounds[1].magVecSquared() < 256.f * 256.f) | 1840 | if (group->isState(LLSpatialGroup::DIRTY) || group->getData().empty()) |
1653 | { //megaprims and water edge patches be damned! | 1841 | { |
1842 | llwarns << "WTF?" << llendl; | ||
1843 | } | ||
1844 | |||
1845 | if (mRes < 2) | ||
1846 | { | ||
1847 | |||
1848 | if (mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]) == 2) | ||
1849 | { | ||
1850 | mEmpty = FALSE; | ||
1851 | update_min_max(mMin, mMax, group->mObjectExtents[0]); | ||
1852 | update_min_max(mMin, mMax, group->mObjectExtents[1]); | ||
1853 | } | ||
1854 | else | ||
1855 | { | ||
1856 | if (group->mObjectBounds[1].magVecSquared() < 256.f * 256.f) | ||
1857 | { //megaprims and water edge patches be damned! | ||
1858 | for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i) | ||
1859 | { | ||
1860 | LLDrawable* drawable = i->get(); | ||
1861 | const LLVector3* ext = drawable->getSpatialExtents(); | ||
1862 | |||
1863 | if (mCamera->AABBInFrustum((ext[1]+ext[0])*0.5f, (ext[1]-ext[0])*0.5f)) | ||
1864 | { | ||
1865 | mEmpty = FALSE; | ||
1866 | update_min_max(mMin, mMax, ext[0]); | ||
1867 | update_min_max(mMin, mMax, ext[1]); | ||
1868 | } | ||
1869 | } | ||
1870 | } | ||
1871 | } | ||
1872 | } | ||
1873 | else | ||
1874 | { | ||
1654 | mEmpty = FALSE; | 1875 | mEmpty = FALSE; |
1655 | update_min_max(mMin, mMax, group->mObjectExtents[0]); | 1876 | update_min_max(mMin, mMax, group->mExtents[0]); |
1656 | update_min_max(mMin, mMax, group->mObjectExtents[1]); | 1877 | update_min_max(mMin, mMax, group->mExtents[1]); |
1657 | } | 1878 | } |
1658 | } | 1879 | } |
1659 | 1880 | ||
@@ -2431,6 +2652,39 @@ void renderBatchSize(LLDrawInfo* params) | |||
2431 | pushVerts(params, LLVertexBuffer::MAP_VERTEX); | 2652 | pushVerts(params, LLVertexBuffer::MAP_VERTEX); |
2432 | } | 2653 | } |
2433 | 2654 | ||
2655 | void renderShadowFrusta(LLDrawInfo* params) | ||
2656 | { | ||
2657 | LLGLEnable blend(GL_BLEND); | ||
2658 | gGL.setSceneBlendType(LLRender::BT_ADD); | ||
2659 | |||
2660 | LLVector3 center = (params->mExtents[1]+params->mExtents[0])*0.5f; | ||
2661 | LLVector3 size = (params->mExtents[1]-params->mExtents[0])*0.5f; | ||
2662 | |||
2663 | if (gPipeline.mShadowCamera[4].AABBInFrustum(center, size)) | ||
2664 | { | ||
2665 | glColor3f(1,0,0); | ||
2666 | pushVerts(params, LLVertexBuffer::MAP_VERTEX); | ||
2667 | } | ||
2668 | if (gPipeline.mShadowCamera[5].AABBInFrustum(center, size)) | ||
2669 | { | ||
2670 | glColor3f(0,1,0); | ||
2671 | pushVerts(params, LLVertexBuffer::MAP_VERTEX); | ||
2672 | } | ||
2673 | if (gPipeline.mShadowCamera[6].AABBInFrustum(center, size)) | ||
2674 | { | ||
2675 | glColor3f(0,0,1); | ||
2676 | pushVerts(params, LLVertexBuffer::MAP_VERTEX); | ||
2677 | } | ||
2678 | if (gPipeline.mShadowCamera[7].AABBInFrustum(center, size)) | ||
2679 | { | ||
2680 | glColor3f(1,0,1); | ||
2681 | pushVerts(params, LLVertexBuffer::MAP_VERTEX); | ||
2682 | } | ||
2683 | |||
2684 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | ||
2685 | } | ||
2686 | |||
2687 | |||
2434 | void renderLights(LLDrawable* drawablep) | 2688 | void renderLights(LLDrawable* drawablep) |
2435 | { | 2689 | { |
2436 | if (!drawablep->isLight()) | 2690 | if (!drawablep->isLight()) |
@@ -2566,6 +2820,9 @@ public: | |||
2566 | //draw tight fit bounding boxes for spatial group | 2820 | //draw tight fit bounding boxes for spatial group |
2567 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCTREE)) | 2821 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCTREE)) |
2568 | { | 2822 | { |
2823 | group->rebuildGeom(); | ||
2824 | group->rebuildMesh(); | ||
2825 | |||
2569 | renderOctree(group); | 2826 | renderOctree(group); |
2570 | stop_glerror(); | 2827 | stop_glerror(); |
2571 | } | 2828 | } |
@@ -2573,6 +2830,9 @@ public: | |||
2573 | //render visibility wireframe | 2830 | //render visibility wireframe |
2574 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) | 2831 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) |
2575 | { | 2832 | { |
2833 | group->rebuildGeom(); | ||
2834 | group->rebuildMesh(); | ||
2835 | |||
2576 | gGL.flush(); | 2836 | gGL.flush(); |
2577 | glPushMatrix(); | 2837 | glPushMatrix(); |
2578 | gGLLastMatrix = NULL; | 2838 | gGLLastMatrix = NULL; |
@@ -2598,6 +2858,19 @@ public: | |||
2598 | LLVector3 nodeCenter = group->mBounds[0]; | 2858 | LLVector3 nodeCenter = group->mBounds[0]; |
2599 | LLVector3 octCenter = LLVector3(group->mOctreeNode->getCenter()); | 2859 | LLVector3 octCenter = LLVector3(group->mOctreeNode->getCenter()); |
2600 | 2860 | ||
2861 | group->rebuildGeom(); | ||
2862 | group->rebuildMesh(); | ||
2863 | |||
2864 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BBOXES)) | ||
2865 | { | ||
2866 | if (!group->getData().empty()) | ||
2867 | { | ||
2868 | gGL.color3f(0,0,1); | ||
2869 | drawBoxOutline(group->mObjectBounds[0], | ||
2870 | group->mObjectBounds[1]); | ||
2871 | } | ||
2872 | } | ||
2873 | |||
2601 | for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i) | 2874 | for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i) |
2602 | { | 2875 | { |
2603 | LLDrawable* drawable = *i; | 2876 | LLDrawable* drawable = *i; |
@@ -2607,6 +2880,16 @@ public: | |||
2607 | renderBoundingBox(drawable); | 2880 | renderBoundingBox(drawable); |
2608 | } | 2881 | } |
2609 | 2882 | ||
2883 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BUILD_QUEUE)) | ||
2884 | { | ||
2885 | if (drawable->isState(LLDrawable::IN_REBUILD_Q2)) | ||
2886 | { | ||
2887 | gGL.color4f(0.6f, 0.6f, 0.1f, 1.f); | ||
2888 | const LLVector3* ext = drawable->getSpatialExtents(); | ||
2889 | drawBoxOutline((ext[0]+ext[1])*0.5f, (ext[1]-ext[0])*0.5f); | ||
2890 | } | ||
2891 | } | ||
2892 | |||
2610 | if (drawable->getVOVolume() && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) | 2893 | if (drawable->getVOVolume() && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) |
2611 | { | 2894 | { |
2612 | renderTexturePriority(drawable); | 2895 | renderTexturePriority(drawable); |
@@ -2627,9 +2910,9 @@ public: | |||
2627 | renderRaycast(drawable); | 2910 | renderRaycast(drawable); |
2628 | } | 2911 | } |
2629 | 2912 | ||
2630 | LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(drawable->getVObj().get()); | 2913 | // LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(drawable->getVObj().get()); |
2631 | 2914 | ||
2632 | if (avatar && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_AVATAR_VOLUME)) | 2915 | /* if (avatar && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_AVATAR_VOLUME)) |
2633 | { | 2916 | { |
2634 | renderAvatarCollisionVolumes(avatar); | 2917 | renderAvatarCollisionVolumes(avatar); |
2635 | } | 2918 | } |
@@ -2637,7 +2920,7 @@ public: | |||
2637 | if (avatar && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_AGENT_TARGET)) | 2920 | if (avatar && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_AGENT_TARGET)) |
2638 | { | 2921 | { |
2639 | renderAgentTarget(avatar); | 2922 | renderAgentTarget(avatar); |
2640 | } | 2923 | } */ |
2641 | 2924 | ||
2642 | } | 2925 | } |
2643 | 2926 | ||
@@ -2655,6 +2938,10 @@ public: | |||
2655 | { | 2938 | { |
2656 | renderBatchSize(draw_info); | 2939 | renderBatchSize(draw_info); |
2657 | } | 2940 | } |
2941 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) | ||
2942 | { | ||
2943 | renderShadowFrusta(draw_info); | ||
2944 | } | ||
2658 | } | 2945 | } |
2659 | } | 2946 | } |
2660 | } | 2947 | } |
@@ -2705,7 +2992,7 @@ void LLSpatialPartition::renderIntersectingBBoxes(LLCamera* camera) | |||
2705 | pusher.traverse(mOctree); | 2992 | pusher.traverse(mOctree); |
2706 | } | 2993 | } |
2707 | 2994 | ||
2708 | void LLSpatialPartition::renderDebug() | 2995 | void LLSpatialPartition::renderDebug() // KL SD version |
2709 | { | 2996 | { |
2710 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCTREE | | 2997 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCTREE | |
2711 | LLPipeline::RENDER_DEBUG_OCCLUSION | | 2998 | LLPipeline::RENDER_DEBUG_OCCLUSION | |
@@ -2716,8 +3003,8 @@ void LLSpatialPartition::renderDebug() | |||
2716 | LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY | | 3003 | LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY | |
2717 | LLPipeline::RENDER_DEBUG_TEXTURE_ANIM | | 3004 | LLPipeline::RENDER_DEBUG_TEXTURE_ANIM | |
2718 | LLPipeline::RENDER_DEBUG_RAYCAST | | 3005 | LLPipeline::RENDER_DEBUG_RAYCAST | |
2719 | LLPipeline::RENDER_DEBUG_AVATAR_VOLUME | | 3006 | LLPipeline::RENDER_DEBUG_BUILD_QUEUE | |
2720 | LLPipeline::RENDER_DEBUG_AGENT_TARGET)) | 3007 | LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) |
2721 | { | 3008 | { |
2722 | return; | 3009 | return; |
2723 | } | 3010 | } |
@@ -2752,6 +3039,12 @@ void LLSpatialPartition::renderDebug() | |||
2752 | render_debug.traverse(mOctree); | 3039 | render_debug.traverse(mOctree); |
2753 | } | 3040 | } |
2754 | 3041 | ||
3042 | void LLSpatialGroup::drawObjectBox(LLColor4 col) | ||
3043 | { | ||
3044 | gGL.color4fv(col.mV); | ||
3045 | drawBox(mObjectBounds[0], mObjectBounds[1]*1.01f+LLVector3(0.001f, 0.001f, 0.001f)); | ||
3046 | } | ||
3047 | |||
2755 | 3048 | ||
2756 | BOOL LLSpatialPartition::isVisible(const LLVector3& v) | 3049 | BOOL LLSpatialPartition::isVisible(const LLVector3& v) |
2757 | { | 3050 | { |
@@ -2896,11 +3189,12 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, con | |||
2896 | } | 3189 | } |
2897 | 3190 | ||
2898 | LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, | 3191 | LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, |
2899 | LLViewerImage* texture, LLVertexBuffer* buffer, | 3192 | LLImageGL* gl_texture, LLViewerImage* texture, LLVertexBuffer* buffer, |
2900 | BOOL fullbright, U8 bump, BOOL particle, F32 part_size) | 3193 | BOOL fullbright, U8 bump, BOOL particle, F32 part_size) |
2901 | : | 3194 | : |
2902 | mVertexBuffer(buffer), | 3195 | mVertexBuffer(buffer), |
2903 | mTexture(texture), | 3196 | mTexture(gl_texture), |
3197 | mViewerTexture(texture), | ||
2904 | mTextureMatrix(NULL), | 3198 | mTextureMatrix(NULL), |
2905 | mModelMatrix(NULL), | 3199 | mModelMatrix(NULL), |
2906 | mStart(start), | 3200 | mStart(start), |
@@ -2920,22 +3214,22 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, | |||
2920 | if (mStart >= mVertexBuffer->getRequestedVerts() || | 3214 | if (mStart >= mVertexBuffer->getRequestedVerts() || |
2921 | mEnd >= mVertexBuffer->getRequestedVerts()) | 3215 | mEnd >= mVertexBuffer->getRequestedVerts()) |
2922 | { | 3216 | { |
2923 | llerrs << "Invalid draw info vertex range." << llendl; | 3217 | llwarns << "Invalid draw info vertex range." << llendl; |
2924 | } | 3218 | } |
2925 | 3219 | ||
2926 | if (mOffset >= (U32) mVertexBuffer->getRequestedIndices() || | 3220 | if (mOffset >= (U32) mVertexBuffer->getRequestedIndices() || |
2927 | mOffset + mCount > (U32) mVertexBuffer->getRequestedIndices()) | 3221 | mOffset + mCount > (U32) mVertexBuffer->getRequestedIndices()) |
2928 | { | 3222 | { |
2929 | llerrs << "Invalid draw info index range." << llendl; | 3223 | llwarns << "Invalid draw info index range." << llendl; |
2930 | } | 3224 | } |
2931 | } | 3225 | } |
2932 | 3226 | ||
2933 | LLDrawInfo::~LLDrawInfo() | 3227 | LLDrawInfo::~LLDrawInfo() |
2934 | { | 3228 | { |
2935 | if (LLSpatialGroup::sNoDelete) | 3229 | /*if (LLSpatialGroup::sNoDelete) |
2936 | { | 3230 | { |
2937 | llerrs << "LLDrawInfo deleted illegally!" << llendl; | 3231 | llwarns << "LLDrawInfo deleted illegally!" << llendl; |
2938 | } | 3232 | }*/ |
2939 | 3233 | ||
2940 | if (mFace) | 3234 | if (mFace) |
2941 | { | 3235 | { |
@@ -3140,7 +3434,7 @@ void LLCullResult::assertDrawMapsEmpty() | |||
3140 | { | 3434 | { |
3141 | if (mRenderMapSize[i] != 0) | 3435 | if (mRenderMapSize[i] != 0) |
3142 | { | 3436 | { |
3143 | llerrs << "Stale LLDrawInfo's in LLCullResult!" << llendl; | 3437 | llwarns << "Stale LLDrawInfo's in LLCullResult!" << llendl; |
3144 | } | 3438 | } |
3145 | } | 3439 | } |
3146 | } | 3440 | } |
diff --git a/linden/indra/newview/llspatialpartition.h b/linden/indra/newview/llspatialpartition.h index df96152..8af5222 100644 --- a/linden/indra/newview/llspatialpartition.h +++ b/linden/indra/newview/llspatialpartition.h | |||
@@ -52,6 +52,8 @@ | |||
52 | class LLSpatialPartition; | 52 | class LLSpatialPartition; |
53 | class LLSpatialBridge; | 53 | class LLSpatialBridge; |
54 | class LLSpatialGroup; | 54 | class LLSpatialGroup; |
55 | class LLTextureAtlas; | ||
56 | class LLTextureAtlasSlot; | ||
55 | 57 | ||
56 | S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad); | 58 | S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad); |
57 | S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared); | 59 | S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared); |
@@ -66,12 +68,13 @@ protected: | |||
66 | 68 | ||
67 | public: | 69 | public: |
68 | LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, | 70 | LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, |
69 | LLViewerImage* image, LLVertexBuffer* buffer, | 71 | LLImageGL* gl_image, LLViewerImage* image, LLVertexBuffer* buffer, |
70 | BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0); | 72 | BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0); |
71 | 73 | ||
72 | 74 | ||
73 | LLPointer<LLVertexBuffer> mVertexBuffer; | 75 | LLPointer<LLVertexBuffer> mVertexBuffer; |
74 | LLPointer<LLViewerImage> mTexture; | 76 | LLPointer<LLImageGL> mTexture; |
77 | LLPointer<LLViewerImage> mViewerTexture; | ||
75 | LLColor4U mGlowColor; | 78 | LLColor4U mGlowColor; |
76 | S32 mDebugColor; | 79 | S32 mDebugColor; |
77 | const LLMatrix4* mTextureMatrix; | 80 | const LLMatrix4* mTextureMatrix; |
@@ -159,11 +162,13 @@ public: | |||
159 | 162 | ||
160 | typedef std::vector<LLPointer<LLSpatialGroup> > sg_vector_t; | 163 | typedef std::vector<LLPointer<LLSpatialGroup> > sg_vector_t; |
161 | typedef std::set<LLPointer<LLSpatialGroup> > sg_set_t; | 164 | typedef std::set<LLPointer<LLSpatialGroup> > sg_set_t; |
165 | typedef std::list<LLPointer<LLSpatialGroup> > sg_list_t; | ||
162 | typedef std::vector<LLPointer<LLSpatialBridge> > bridge_list_t; | 166 | typedef std::vector<LLPointer<LLSpatialBridge> > bridge_list_t; |
163 | typedef std::vector<LLPointer<LLDrawInfo> > drawmap_elem_t; | 167 | typedef std::vector<LLPointer<LLDrawInfo> > drawmap_elem_t; |
164 | typedef std::map<U32, drawmap_elem_t > draw_map_t; | 168 | typedef std::map<U32, drawmap_elem_t > draw_map_t; |
165 | typedef std::vector<LLPointer<LLVertexBuffer> > buffer_list_t; | 169 | typedef std::vector<LLPointer<LLVertexBuffer> > buffer_list_t; |
166 | typedef std::map<LLPointer<LLViewerImage>, buffer_list_t> buffer_texture_map_t; | 170 | typedef std::map<LLPointer<LLImageGL>, buffer_list_t> buffer_texture_map_t; // KL render-pipeline |
171 | // typedef std::map<LLPointer<LLViewerImage>, buffer_list_t> buffer_texture_map_t; // KL standard | ||
167 | typedef std::map<U32, buffer_texture_map_t> buffer_map_t; | 172 | typedef std::map<U32, buffer_texture_map_t> buffer_map_t; |
168 | 173 | ||
169 | typedef LLOctreeListener<LLDrawable> BaseType; | 174 | typedef LLOctreeListener<LLDrawable> BaseType; |
@@ -183,6 +188,14 @@ public: | |||
183 | } | 188 | } |
184 | }; | 189 | }; |
185 | 190 | ||
191 | struct CompareUpdateUrgency | ||
192 | { | ||
193 | bool operator()(const LLPointer<LLSpatialGroup> lhs, const LLPointer<LLSpatialGroup> rhs) | ||
194 | { | ||
195 | return lhs->getUpdateUrgency() > rhs->getUpdateUrgency(); | ||
196 | } | ||
197 | }; | ||
198 | |||
186 | struct CompareDepthGreater | 199 | struct CompareDepthGreater |
187 | { | 200 | { |
188 | bool operator()(const LLSpatialGroup* const& lhs, const LLSpatialGroup* const& rhs) | 201 | bool operator()(const LLSpatialGroup* const& lhs, const LLSpatialGroup* const& rhs) |
@@ -209,6 +222,10 @@ public: | |||
209 | IMAGE_DIRTY = 0x00004000, | 222 | IMAGE_DIRTY = 0x00004000, |
210 | OCCLUSION_DIRTY = 0x00008000, | 223 | OCCLUSION_DIRTY = 0x00008000, |
211 | MESH_DIRTY = 0x00010000, | 224 | MESH_DIRTY = 0x00010000, |
225 | NEW_DRAWINFO = 0x00020000, | ||
226 | IN_BUILD_Q1 = 0x00040000, | ||
227 | IN_BUILD_Q2 = 0x00080000, | ||
228 | |||
212 | } eSpatialState; | 229 | } eSpatialState; |
213 | 230 | ||
214 | typedef enum | 231 | typedef enum |
@@ -252,6 +269,7 @@ public: | |||
252 | 269 | ||
253 | void updateDistance(LLCamera& camera); | 270 | void updateDistance(LLCamera& camera); |
254 | BOOL needsUpdate(); | 271 | BOOL needsUpdate(); |
272 | F32 getUpdateUrgency() const; | ||
255 | BOOL changeLOD(); | 273 | BOOL changeLOD(); |
256 | void rebuildGeom(); | 274 | void rebuildGeom(); |
257 | void rebuildMesh(); | 275 | void rebuildMesh(); |
@@ -261,6 +279,8 @@ public: | |||
261 | element_list& getData() { return mOctreeNode->getData(); } | 279 | element_list& getData() { return mOctreeNode->getData(); } |
262 | U32 getElementCount() const { return mOctreeNode->getElementCount(); } | 280 | U32 getElementCount() const { return mOctreeNode->getElementCount(); } |
263 | 281 | ||
282 | void drawObjectBox(LLColor4 col); | ||
283 | |||
264 | //LISTENER FUNCTIONS | 284 | //LISTENER FUNCTIONS |
265 | virtual void handleInsertion(const TreeNode* node, LLDrawable* face); | 285 | virtual void handleInsertion(const TreeNode* node, LLDrawable* face); |
266 | virtual void handleRemoval(const TreeNode* node, LLDrawable* face); | 286 | virtual void handleRemoval(const TreeNode* node, LLDrawable* face); |
@@ -269,6 +289,36 @@ public: | |||
269 | virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); | 289 | virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); |
270 | virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child); | 290 | virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child); |
271 | 291 | ||
292 | //------------------- | ||
293 | //for atlas use | ||
294 | //------------------- | ||
295 | //atlas | ||
296 | void setCurUpdatingTime(U32 t) {mCurUpdatingTime = t ;} | ||
297 | U32 getCurUpdatingTime() const { return mCurUpdatingTime ;} | ||
298 | |||
299 | void setCurUpdatingSlot(LLTextureAtlasSlot* slotp) ; | ||
300 | LLTextureAtlasSlot* getCurUpdatingSlot(LLViewerImage* imagep, S8 recursive_level = 3) ; | ||
301 | |||
302 | void setCurUpdatingTexture(LLViewerImage* tex){ mCurUpdatingTexture = tex ;} | ||
303 | LLViewerImage* getCurUpdatingTexture() const { return mCurUpdatingTexture ;} | ||
304 | |||
305 | BOOL hasAtlas(LLTextureAtlas* atlasp) ; | ||
306 | LLTextureAtlas* getAtlas(S8 ncomponents, S8 to_be_reserved, S8 recursive_level = 3) ; | ||
307 | void addAtlas(LLTextureAtlas* atlasp, S8 recursive_level = 3) ; | ||
308 | void removeAtlas(LLTextureAtlas* atlasp, BOOL remove_group = TRUE, S8 recursive_level = 3) ; | ||
309 | void clearAtlasList() ; | ||
310 | private: | ||
311 | U32 mCurUpdatingTime ; | ||
312 | //do not make the below two to use LLPointer | ||
313 | //because mCurUpdatingTime invalidates them automatically. | ||
314 | LLTextureAtlasSlot* mCurUpdatingSlotp ; | ||
315 | LLViewerImage* mCurUpdatingTexture ; | ||
316 | |||
317 | std::vector< std::list<LLTextureAtlas*> > mAtlasList ; | ||
318 | //------------------- | ||
319 | //end for atlas use | ||
320 | //------------------- | ||
321 | |||
272 | protected: | 322 | protected: |
273 | virtual ~LLSpatialGroup(); | 323 | virtual ~LLSpatialGroup(); |
274 | 324 | ||
@@ -327,7 +377,7 @@ class LLSpatialPartition: public LLGeometryManager | |||
327 | public: | 377 | public: |
328 | static BOOL sFreezeState; //if true, no spatialgroup state updates will be made | 378 | static BOOL sFreezeState; //if true, no spatialgroup state updates will be made |
329 | 379 | ||
330 | LLSpatialPartition(U32 data_mask, U32 mBufferUsage = GL_STATIC_DRAW_ARB); | 380 | LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 mBufferUsage); |
331 | virtual ~LLSpatialPartition(); | 381 | virtual ~LLSpatialPartition(); |
332 | 382 | ||
333 | LLSpatialGroup *put(LLDrawable *drawablep, BOOL was_visible = FALSE); | 383 | LLSpatialGroup *put(LLDrawable *drawablep, BOOL was_visible = FALSE); |
@@ -373,7 +423,7 @@ public: | |||
373 | BOOL mOcclusionEnabled; // if TRUE, occlusion culling is performed | 423 | BOOL mOcclusionEnabled; // if TRUE, occlusion culling is performed |
374 | BOOL mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane | 424 | BOOL mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane |
375 | U32 mBufferUsage; | 425 | U32 mBufferUsage; |
376 | BOOL mRenderByGroup; | 426 | const BOOL mRenderByGroup; |
377 | U32 mLODSeed; | 427 | U32 mLODSeed; |
378 | U32 mLODPeriod; //number of frames between LOD updates for a given spatial group (staggered by mLODSeed) | 428 | U32 mLODPeriod; //number of frames between LOD updates for a given spatial group (staggered by mLODSeed) |
379 | U32 mVertexDataMask; | 429 | U32 mVertexDataMask; |
@@ -392,7 +442,7 @@ protected: | |||
392 | public: | 442 | public: |
393 | typedef std::vector<LLPointer<LLSpatialBridge> > bridge_vector_t; | 443 | typedef std::vector<LLPointer<LLSpatialBridge> > bridge_vector_t; |
394 | 444 | ||
395 | LLSpatialBridge(LLDrawable* root, U32 data_mask); | 445 | LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask); |
396 | 446 | ||
397 | virtual BOOL isSpatialBridge() const { return TRUE; } | 447 | virtual BOOL isSpatialBridge() const { return TRUE; } |
398 | 448 | ||
diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index 87d48c8..237a967 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp | |||
@@ -3723,7 +3723,7 @@ void init_start_screen(S32 location_id) | |||
3723 | } | 3723 | } |
3724 | 3724 | ||
3725 | raw->expandToPowerOfTwo(); | 3725 | raw->expandToPowerOfTwo(); |
3726 | gStartImageGL->createGLTexture(0, raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | 3726 | gStartImageGL->createGLTexture(0, raw); |
3727 | } | 3727 | } |
3728 | 3728 | ||
3729 | 3729 | ||
diff --git a/linden/indra/newview/llsurface.cpp b/linden/indra/newview/llsurface.cpp index a27f0e2..2e20ace 100644 --- a/linden/indra/newview/llsurface.cpp +++ b/linden/indra/newview/llsurface.cpp | |||
@@ -149,7 +149,7 @@ LLSurface::~LLSurface() | |||
149 | } | 149 | } |
150 | else | 150 | else |
151 | { | 151 | { |
152 | llerrs << "Terrain pool not empty!" << llendl; | 152 | llwarns << "Terrain pool not empty!" << llendl; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
@@ -238,6 +238,7 @@ void LLSurface::createSTexture() | |||
238 | if (!mSTexturep) | 238 | if (!mSTexturep) |
239 | { | 239 | { |
240 | // Fill with dummy gray data. | 240 | // Fill with dummy gray data. |
241 | // GL NOT ACTIVE HERE | ||
241 | LLPointer<LLImageRaw> raw = new LLImageRaw(sTextureSize, sTextureSize, 3); | 242 | LLPointer<LLImageRaw> raw = new LLImageRaw(sTextureSize, sTextureSize, 3); |
242 | U8 *default_texture = raw->getData(); | 243 | U8 *default_texture = raw->getData(); |
243 | for (S32 i = 0; i < sTextureSize; i++) | 244 | for (S32 i = 0; i < sTextureSize; i++) |
@@ -255,6 +256,7 @@ void LLSurface::createSTexture() | |||
255 | gGL.getTexUnit(0)->bind(mSTexturep.get()); | 256 | gGL.getTexUnit(0)->bind(mSTexturep.get()); |
256 | mSTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); | 257 | mSTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); |
257 | gImageList.addImage(mSTexturep); | 258 | gImageList.addImage(mSTexturep); |
259 | |||
258 | } | 260 | } |
259 | } | 261 | } |
260 | 262 | ||
@@ -275,9 +277,10 @@ void LLSurface::createWaterTexture() | |||
275 | *(default_texture + (i*sTextureSize/2 + j)*4 + 3) = MAX_WATER_COLOR.mV[3]; | 277 | *(default_texture + (i*sTextureSize/2 + j)*4 + 3) = MAX_WATER_COLOR.mV[3]; |
276 | } | 278 | } |
277 | } | 279 | } |
278 | mWaterTexturep = new LLViewerImage(raw, FALSE); | 280 | |
281 | mWaterTexturep = new LLViewerImage(sTextureSize/2, sTextureSize/2, 4, FALSE); | ||
279 | mWaterTexturep->dontDiscard(); | 282 | mWaterTexturep->dontDiscard(); |
280 | gGL.getTexUnit(0)->bind(mWaterTexturep.get()); | 283 | gGL.getTexUnit(0)->bind(mWaterTexturep); |
281 | mWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); | 284 | mWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); |
282 | gImageList.addImage(mWaterTexturep); | 285 | gImageList.addImage(mWaterTexturep); |
283 | } | 286 | } |
@@ -629,6 +632,8 @@ void LLSurface::updatePatchVisibilities(LLAgent &agent) | |||
629 | 632 | ||
630 | BOOL LLSurface::idleUpdate(F32 max_update_time) | 633 | BOOL LLSurface::idleUpdate(F32 max_update_time) |
631 | { | 634 | { |
635 | //SG2: LLMemType mt_ius(LLMemType::MTYPE_IDLE_UPDATE_SURFACE); | ||
636 | |||
632 | if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_TERRAIN)) | 637 | if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_TERRAIN)) |
633 | { | 638 | { |
634 | return FALSE; | 639 | return FALSE; |
@@ -1133,12 +1138,12 @@ LLSurfacePatch *LLSurface::getPatch(const S32 x, const S32 y) const | |||
1133 | { | 1138 | { |
1134 | if ((x < 0) || (x >= mPatchesPerEdge)) | 1139 | if ((x < 0) || (x >= mPatchesPerEdge)) |
1135 | { | 1140 | { |
1136 | llerrs << "Asking for patch out of bounds" << llendl; | 1141 | llwarns << "Asking for patch out of bounds" << llendl; |
1137 | return NULL; | 1142 | return NULL; |
1138 | } | 1143 | } |
1139 | if ((y < 0) || (y >= mPatchesPerEdge)) | 1144 | if ((y < 0) || (y >= mPatchesPerEdge)) |
1140 | { | 1145 | { |
1141 | llerrs << "Asking for patch out of bounds" << llendl; | 1146 | llwarns << "Asking for patch out of bounds" << llendl; |
1142 | return NULL; | 1147 | return NULL; |
1143 | } | 1148 | } |
1144 | 1149 | ||
@@ -1277,6 +1282,11 @@ BOOL LLSurface::generateWaterTexture(const F32 x, const F32 y, | |||
1277 | } | 1282 | } |
1278 | } | 1283 | } |
1279 | 1284 | ||
1285 | if (!mWaterTexturep->getHasGLTexture()) | ||
1286 | { | ||
1287 | mWaterTexturep->createGLTexture(0, raw); | ||
1288 | } | ||
1289 | |||
1280 | mWaterTexturep->setSubImage(raw, x_begin, y_begin, x_end - x_begin, y_end - y_begin); | 1290 | mWaterTexturep->setSubImage(raw, x_begin, y_begin, x_end - x_begin, y_end - y_begin); |
1281 | return TRUE; | 1291 | return TRUE; |
1282 | } | 1292 | } |
diff --git a/linden/indra/newview/llsurfacepatch.cpp b/linden/indra/newview/llsurfacepatch.cpp index 5fac5fd..04b732a 100644 --- a/linden/indra/newview/llsurfacepatch.cpp +++ b/linden/indra/newview/llsurfacepatch.cpp | |||
@@ -712,17 +712,7 @@ BOOL LLSurfacePatch::updateTexture() | |||
712 | if (mVObjp) | 712 | if (mVObjp) |
713 | { | 713 | { |
714 | mVObjp->dirtyGeom(); | 714 | mVObjp->dirtyGeom(); |
715 | } | 715 | gPipeline.markGLRebuild(mVObjp); |
716 | updateCompositionStats(); | ||
717 | F32 tex_patch_size = meters_per_grid*grids_per_patch_edge; | ||
718 | if (comp->generateTexture((F32)origin_region[VX], (F32)origin_region[VY], | ||
719 | tex_patch_size, tex_patch_size)) | ||
720 | { | ||
721 | mSTexUpdate = FALSE; | ||
722 | |||
723 | // Also generate the water texture | ||
724 | mSurfacep->generateWaterTexture((F32)origin_region.mdV[VX], (F32)origin_region.mdV[VY], | ||
725 | tex_patch_size, tex_patch_size); | ||
726 | return TRUE; | 716 | return TRUE; |
727 | } | 717 | } |
728 | } | 718 | } |
@@ -735,6 +725,28 @@ BOOL LLSurfacePatch::updateTexture() | |||
735 | } | 725 | } |
736 | } | 726 | } |
737 | 727 | ||
728 | void LLSurfacePatch::updateGL() // KL SD | ||
729 | { | ||
730 | F32 meters_per_grid = getSurface()->getMetersPerGrid(); | ||
731 | F32 grids_per_patch_edge = (F32)getSurface()->getGridsPerPatchEdge(); | ||
732 | |||
733 | LLViewerRegion *regionp = getSurface()->getRegion(); | ||
734 | LLVector3d origin_region = getOriginGlobal() - getSurface()->getOriginGlobal(); | ||
735 | |||
736 | LLVLComposition* comp = regionp->getComposition(); | ||
737 | |||
738 | updateCompositionStats(); | ||
739 | F32 tex_patch_size = meters_per_grid*grids_per_patch_edge; | ||
740 | if (comp->generateTexture((F32)origin_region[VX], (F32)origin_region[VY], | ||
741 | tex_patch_size, tex_patch_size)) | ||
742 | { | ||
743 | mSTexUpdate = FALSE; | ||
744 | |||
745 | // Also generate the water texture | ||
746 | mSurfacep->generateWaterTexture((F32)origin_region.mdV[VX], (F32)origin_region.mdV[VY], | ||
747 | tex_patch_size, tex_patch_size); | ||
748 | } | ||
749 | } // KL | ||
738 | 750 | ||
739 | void LLSurfacePatch::dirtyZ() | 751 | void LLSurfacePatch::dirtyZ() |
740 | { | 752 | { |
diff --git a/linden/indra/newview/llsurfacepatch.h b/linden/indra/newview/llsurfacepatch.h index 7e84f7f..1f9658d 100644 --- a/linden/indra/newview/llsurfacepatch.h +++ b/linden/indra/newview/llsurfacepatch.h | |||
@@ -90,6 +90,7 @@ public: | |||
90 | 90 | ||
91 | void updateCameraDistanceRegion( const LLVector3 &pos_region); | 91 | void updateCameraDistanceRegion( const LLVector3 &pos_region); |
92 | void updateVisibility(); | 92 | void updateVisibility(); |
93 | void updateGL(); | ||
93 | 94 | ||
94 | void dirtyZ(); // Dirty the z values of this patch | 95 | void dirtyZ(); // Dirty the z values of this patch |
95 | void setHasReceivedData(); | 96 | void setHasReceivedData(); |
diff --git a/linden/indra/newview/lltexlayer.cpp b/linden/indra/newview/lltexlayer.cpp index 5175cbb..fb5be84 100644 --- a/linden/indra/newview/lltexlayer.cpp +++ b/linden/indra/newview/lltexlayer.cpp | |||
@@ -813,14 +813,19 @@ void LLTexLayerSet::requestUpdate() | |||
813 | if( mUpdatesEnabled ) | 813 | if( mUpdatesEnabled ) |
814 | { | 814 | { |
815 | createComposite(); | 815 | createComposite(); |
816 | mComposite->requestUpdate(); | 816 | if (mComposite) |
817 | { | ||
818 | mComposite->requestUpdate(); | ||
819 | } | ||
817 | } | 820 | } |
818 | } | 821 | } |
819 | 822 | ||
820 | void LLTexLayerSet::requestUpload() | 823 | void LLTexLayerSet::requestUpload() |
821 | { | 824 | { |
822 | createComposite(); | 825 | if (mComposite) |
823 | mComposite->requestUpload(); | 826 | { |
827 | mComposite->requestUpload(); | ||
828 | } | ||
824 | } | 829 | } |
825 | 830 | ||
826 | void LLTexLayerSet::cancelUpload() | 831 | void LLTexLayerSet::cancelUpload() |
@@ -835,6 +840,15 @@ void LLTexLayerSet::createComposite() | |||
835 | { | 840 | { |
836 | if( !mComposite ) | 841 | if( !mComposite ) |
837 | { | 842 | { |
843 | gPipeline.markGLRebuild(this); | ||
844 | } | ||
845 | //updateGL(); // KL | ||
846 | } | ||
847 | |||
848 | void LLTexLayerSet::updateGL() | ||
849 | { | ||
850 | if (!mComposite) | ||
851 | { | ||
838 | S32 width = mInfo->mWidth; | 852 | S32 width = mInfo->mWidth; |
839 | S32 height = mInfo->mHeight; | 853 | S32 height = mInfo->mHeight; |
840 | // Composite other avatars at reduced resolution | 854 | // Composite other avatars at reduced resolution |
@@ -865,7 +879,7 @@ void LLTexLayerSet::setUpdatesEnabled( BOOL b ) | |||
865 | void LLTexLayerSet::updateComposite() | 879 | void LLTexLayerSet::updateComposite() |
866 | { | 880 | { |
867 | createComposite(); | 881 | createComposite(); |
868 | mComposite->updateImmediate(); | 882 | //mComposite->updateImmediate(); //KL exception here this needs fixing for S19 |
869 | } | 883 | } |
870 | 884 | ||
871 | LLTexLayerSetBuffer* LLTexLayerSet::getComposite() | 885 | LLTexLayerSetBuffer* LLTexLayerSet::getComposite() |
@@ -2104,7 +2118,7 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height ) | |||
2104 | // Create the GL texture, and then hang onto it for future use. | 2118 | // Create the GL texture, and then hang onto it for future use. |
2105 | if( mNeedsCreateTexture ) | 2119 | if( mNeedsCreateTexture ) |
2106 | { | 2120 | { |
2107 | mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw, 0, TRUE, LLViewerImageBoostLevel::TEXLAYER_CACHE); | 2121 | mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw, 0); |
2108 | mNeedsCreateTexture = FALSE; | 2122 | mNeedsCreateTexture = FALSE; |
2109 | gGL.getTexUnit(0)->bind(mCachedProcessedImageGL); | 2123 | gGL.getTexUnit(0)->bind(mCachedProcessedImageGL); |
2110 | mCachedProcessedImageGL->setAddressMode(LLTexUnit::TAM_CLAMP); | 2124 | mCachedProcessedImageGL->setAddressMode(LLTexUnit::TAM_CLAMP); |
@@ -2560,7 +2574,7 @@ LLImageGL* LLTexStaticImageList::getImageGL(const std::string& file_name, BOOL i | |||
2560 | image_gl->setExplicitFormat( GL_ALPHA8, GL_ALPHA ); | 2574 | image_gl->setExplicitFormat( GL_ALPHA8, GL_ALPHA ); |
2561 | } | 2575 | } |
2562 | 2576 | ||
2563 | image_gl->createGLTexture(0, image_raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | 2577 | image_gl->createGLTexture(0, image_raw, 0); |
2564 | 2578 | ||
2565 | gGL.getTexUnit(0)->bind(image_gl); | 2579 | gGL.getTexUnit(0)->bind(image_gl); |
2566 | image_gl->setAddressMode(LLTexUnit::TAM_CLAMP); | 2580 | image_gl->setAddressMode(LLTexUnit::TAM_CLAMP); |
diff --git a/linden/indra/newview/lltexlayer.h b/linden/indra/newview/lltexlayer.h index 020ba86..b841fa3 100644 --- a/linden/indra/newview/lltexlayer.h +++ b/linden/indra/newview/lltexlayer.h | |||
@@ -249,7 +249,7 @@ private: | |||
249 | // LLTexLayerSet | 249 | // LLTexLayerSet |
250 | // An ordered set of texture layers that get composited into a single texture. | 250 | // An ordered set of texture layers that get composited into a single texture. |
251 | //----------------------------------------------------------------------------- | 251 | //----------------------------------------------------------------------------- |
252 | class LLTexLayerSet | 252 | class LLTexLayerSet : public LLGLUpdate |
253 | { | 253 | { |
254 | friend class LLTexLayerSetBuffer; | 254 | friend class LLTexLayerSetBuffer; |
255 | public: | 255 | public: |
@@ -284,7 +284,7 @@ public: | |||
284 | LLVOAvatarDefines::EBakedTextureIndex getBakedTexIndex() { return mBakedTexIndex; } | 284 | LLVOAvatarDefines::EBakedTextureIndex getBakedTexIndex() { return mBakedTexIndex; } |
285 | void setBakedTexIndex(LLVOAvatarDefines::EBakedTextureIndex index) { mBakedTexIndex = index; } | 285 | void setBakedTexIndex(LLVOAvatarDefines::EBakedTextureIndex index) { mBakedTexIndex = index; } |
286 | BOOL isVisible() const { return mIsVisible; } | 286 | BOOL isVisible() const { return mIsVisible; } |
287 | 287 | /*virtual*/ void updateGL(); | |
288 | public: | 288 | public: |
289 | static BOOL sHasCaches; | 289 | static BOOL sHasCaches; |
290 | 290 | ||
diff --git a/linden/indra/newview/lltextureatlasmanager.cpp b/linden/indra/newview/lltextureatlasmanager.cpp new file mode 100644 index 0000000..df6a39d --- /dev/null +++ b/linden/indra/newview/lltextureatlasmanager.cpp | |||
@@ -0,0 +1,274 @@ | |||
1 | /** | ||
2 | * @file lltextureatlasmanager.cpp | ||
3 | * @brief LLTextureAtlasManager class implementation. | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2002-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | #include "linden_common.h" | ||
34 | #include "llerror.h" | ||
35 | #include "llmath.h" | ||
36 | #include "lltextureatlas.h" | ||
37 | #include "lltextureatlasmanager.h" | ||
38 | #include "llspatialpartition.h" | ||
39 | |||
40 | const S8 MAX_NUM_EMPTY_ATLAS = 2 ; | ||
41 | const F32 MIN_ATLAS_FULLNESS = 0.6f ; | ||
42 | |||
43 | //********************************************************************************************* | ||
44 | //implementation of class LLTextureAtlasInfo | ||
45 | //********************************************************************************************* | ||
46 | LLTextureAtlasSlot::LLTextureAtlasSlot(LLTextureAtlas* atlasp, LLSpatialGroup* groupp, S16 col, S16 row, F32 xoffset, F32 yoffset, S8 slot_width) : | ||
47 | mAtlasp(atlasp), | ||
48 | mGroupp(groupp), | ||
49 | mCol(col), | ||
50 | mRow(row), | ||
51 | mReservedSlotWidth(slot_width), | ||
52 | mValid(FALSE), | ||
53 | mUpdatedTime(0), | ||
54 | mTexCoordOffset(xoffset, yoffset), | ||
55 | mTexCoordScale(1.f, 1.f) | ||
56 | { | ||
57 | llassert_always(mAtlasp || mGroupp || mReservedSlotWidth) ; | ||
58 | } | ||
59 | |||
60 | LLTextureAtlasSlot::~LLTextureAtlasSlot() | ||
61 | { | ||
62 | if(mAtlasp) | ||
63 | { | ||
64 | mAtlasp->releaseSlot(mCol, mRow, mReservedSlotWidth) ; | ||
65 | if(mAtlasp->isEmpty()) | ||
66 | { | ||
67 | LLTextureAtlasManager::getInstance()->releaseAtlas(mAtlasp) ; | ||
68 | } | ||
69 | mAtlasp = NULL ; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | //void LLTextureAtlasSlot::setAtlas(LLTextureAtlas* atlasp) | ||
74 | //{ | ||
75 | // mAtlasp = atlasp ; | ||
76 | //} | ||
77 | //void LLTextureAtlasSlot::setSlotPos(S16 col, S16 row) | ||
78 | //{ | ||
79 | // mCol = col ; | ||
80 | // mRow = row ; | ||
81 | //} | ||
82 | //void LLTextureAtlasSlot::setSlotWidth(S8 width) | ||
83 | //{ | ||
84 | // //slot is a square with each edge length a power-of-two number | ||
85 | // mReservedSlotWidth = width ; | ||
86 | //} | ||
87 | //void LLTextureAtlasSlot::setTexCoordOffset(F32 xoffset, F32 yoffset) | ||
88 | //{ | ||
89 | // mTexCoordOffset.mV[0] = xoffset ; | ||
90 | // mTexCoordOffset.mV[1] = yoffset ; | ||
91 | //} | ||
92 | |||
93 | void LLTextureAtlasSlot::setSpatialGroup(LLSpatialGroup* groupp) | ||
94 | { | ||
95 | mGroupp = groupp ; | ||
96 | } | ||
97 | void LLTextureAtlasSlot::setTexCoordScale(F32 xscale, F32 yscale) | ||
98 | { | ||
99 | mTexCoordScale.mV[0] = xscale ; | ||
100 | mTexCoordScale.mV[1] = yscale ; | ||
101 | } | ||
102 | //********************************************************************************************* | ||
103 | //END of implementation of class LLTextureAtlasInfo | ||
104 | //********************************************************************************************* | ||
105 | |||
106 | //********************************************************************************************* | ||
107 | //implementation of class LLTextureAtlasManager | ||
108 | //********************************************************************************************* | ||
109 | LLTextureAtlasManager::LLTextureAtlasManager() : | ||
110 | mAtlasMap(4), | ||
111 | mEmptyAtlasMap(4) | ||
112 | { | ||
113 | } | ||
114 | |||
115 | LLTextureAtlasManager::~LLTextureAtlasManager() | ||
116 | { | ||
117 | for(S32 i = 0 ; i < 4 ; i++) | ||
118 | { | ||
119 | for(ll_texture_atlas_list_t::iterator j = mAtlasMap[i].begin() ; j != mAtlasMap[i].end() ; ++j) | ||
120 | { | ||
121 | *j = NULL ; | ||
122 | } | ||
123 | for(ll_texture_atlas_list_t::iterator j = mEmptyAtlasMap[i].begin() ; j != mEmptyAtlasMap[i].end() ; ++j) | ||
124 | { | ||
125 | *j = NULL ; | ||
126 | } | ||
127 | |||
128 | mAtlasMap[i].clear() ; | ||
129 | mEmptyAtlasMap[i].clear() ; | ||
130 | } | ||
131 | mAtlasMap.clear() ; | ||
132 | mEmptyAtlasMap.clear() ; | ||
133 | } | ||
134 | |||
135 | //return TRUE if qualified | ||
136 | BOOL LLTextureAtlasManager::canAddToAtlas(S32 w, S32 h, S8 ncomponents, LLGLenum target) | ||
137 | { | ||
138 | if(ncomponents < 1 || ncomponents > 4) | ||
139 | { | ||
140 | return FALSE ; | ||
141 | } | ||
142 | //only support GL_TEXTURE_2D | ||
143 | if(GL_TEXTURE_2D != target) | ||
144 | { | ||
145 | return FALSE ; | ||
146 | } | ||
147 | //real image size overflows | ||
148 | if(w < 8 || w > LLTextureAtlas::sMaxSubTextureSize || h < 8 || h > LLTextureAtlas::sMaxSubTextureSize) | ||
149 | { | ||
150 | return FALSE ; | ||
151 | } | ||
152 | |||
153 | //if non-power-of-two number | ||
154 | if((w & (w - 1)) || (h & (h - 1))) | ||
155 | { | ||
156 | return FALSE ; | ||
157 | } | ||
158 | |||
159 | return TRUE ; | ||
160 | } | ||
161 | |||
162 | void LLTextureAtlasManager::releaseAtlas(LLTextureAtlas* atlasp) | ||
163 | { | ||
164 | LLSpatialGroup* groupp = atlasp->getLastSpatialGroup() ; | ||
165 | while(groupp) | ||
166 | { | ||
167 | groupp->removeAtlas(atlasp, FALSE) ; | ||
168 | atlasp->removeLastSpatialGroup() ; | ||
169 | |||
170 | groupp = atlasp->getLastSpatialGroup() ; | ||
171 | } | ||
172 | |||
173 | S8 type = atlasp->getComponents() - 1 ; | ||
174 | //insert to the empty list | ||
175 | if(mEmptyAtlasMap[type].size() < MAX_NUM_EMPTY_ATLAS) | ||
176 | { | ||
177 | mEmptyAtlasMap[type].push_back(atlasp) ; | ||
178 | } | ||
179 | |||
180 | //delete the atlasp | ||
181 | mAtlasMap[type].remove(atlasp) ; | ||
182 | } | ||
183 | |||
184 | // | ||
185 | //this function reserves an appropriate slot from atlas pool for an image. | ||
186 | //return non-NULL if succeeds. | ||
187 | //Note: | ||
188 | //1, this function does not check if the image this slot assigned for qualifies for atlas or not, | ||
189 | // call LLTextureAtlasManager::canAddToAtlas(...) to do the check before calling this function. | ||
190 | //2, this function also dose not check if the image is already in atlas. It always assigns a new slot anyway. | ||
191 | //3, this function tries to group sub-textures from same spatial group into ONE atlas to improve render batching. | ||
192 | // | ||
193 | LLPointer<LLTextureAtlasSlot> LLTextureAtlasManager::reserveAtlasSlot(S32 sub_texture_size, S8 ncomponents, | ||
194 | LLSpatialGroup* groupp, LLViewerImage* imagep) | ||
195 | { | ||
196 | if(!groupp) | ||
197 | { | ||
198 | //do not insert to atlas if does not have a group. | ||
199 | return NULL ; | ||
200 | } | ||
201 | |||
202 | //bits_len must <= 8 and is a power of two number, i.e.: must be one of these numbers: 1, 2, 4, 8. | ||
203 | if(sub_texture_size > LLTextureAtlas::sMaxSubTextureSize) | ||
204 | { | ||
205 | sub_texture_size = LLTextureAtlas::sMaxSubTextureSize ; | ||
206 | } | ||
207 | S8 bits_len = sub_texture_size / LLTextureAtlas::sSlotSize ; | ||
208 | if(bits_len < 1) | ||
209 | { | ||
210 | bits_len = 1 ; | ||
211 | } | ||
212 | |||
213 | S16 col = -1, row = -1; | ||
214 | S8 total_bits = bits_len * bits_len ; | ||
215 | |||
216 | //insert to the atlas reserved by the same spatial group | ||
217 | LLPointer<LLTextureAtlas> atlasp = groupp->getAtlas(ncomponents, total_bits) ; | ||
218 | if(atlasp.notNull()) | ||
219 | { | ||
220 | if(!atlasp->getNextAvailableSlot(bits_len, col, row)) | ||
221 | { | ||
222 | //failed | ||
223 | atlasp = NULL ; | ||
224 | } | ||
225 | } | ||
226 | |||
227 | //search an atlas to fit for 'size' | ||
228 | if(!atlasp) | ||
229 | { | ||
230 | S8 atlas_index = ncomponents - 1 ; | ||
231 | ll_texture_atlas_list_t::iterator iter = mAtlasMap[atlas_index].begin() ; | ||
232 | for(; iter != mAtlasMap[atlas_index].end(); ++iter) | ||
233 | { | ||
234 | LLTextureAtlas* cur = (LLTextureAtlas*)*iter ; | ||
235 | if(cur->getFullness() < MIN_ATLAS_FULLNESS)//this atlas is empty enough for this group to insert more sub-textures later if necessary. | ||
236 | { | ||
237 | if(cur->getNextAvailableSlot(bits_len, col, row)) | ||
238 | { | ||
239 | atlasp = cur ; | ||
240 | groupp->addAtlas(atlasp) ; | ||
241 | break ; | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | |||
247 | //create a new atlas if necessary | ||
248 | if(!atlasp) | ||
249 | { | ||
250 | if(mEmptyAtlasMap[ncomponents - 1].size() > 0) | ||
251 | { | ||
252 | //there is an empty one | ||
253 | atlasp = mEmptyAtlasMap[ncomponents - 1].back() ; | ||
254 | mEmptyAtlasMap[ncomponents - 1].pop_back() ; | ||
255 | } | ||
256 | else | ||
257 | { | ||
258 | atlasp = new LLTextureAtlas(ncomponents, 16) ; | ||
259 | } | ||
260 | mAtlasMap[ncomponents - 1].push_back(atlasp) ; | ||
261 | atlasp->getNextAvailableSlot(bits_len, col, row) ; | ||
262 | groupp->addAtlas(atlasp) ; | ||
263 | } | ||
264 | |||
265 | F32 xoffset, yoffset ; | ||
266 | atlasp->getTexCoordOffset(col, row, xoffset, yoffset) ; | ||
267 | LLPointer<LLTextureAtlasSlot> slot_infop = new LLTextureAtlasSlot(atlasp, groupp, col, row, xoffset, yoffset, bits_len) ; | ||
268 | |||
269 | return slot_infop ; | ||
270 | } | ||
271 | |||
272 | //********************************************************************************************* | ||
273 | //END of implementation of class LLTextureAtlasManager | ||
274 | //********************************************************************************************* | ||
diff --git a/linden/indra/newview/lltextureatlasmanager.h b/linden/indra/newview/lltextureatlasmanager.h new file mode 100644 index 0000000..70689bf --- /dev/null +++ b/linden/indra/newview/lltextureatlasmanager.h | |||
@@ -0,0 +1,112 @@ | |||
1 | /** | ||
2 | * @file lltextureatlasmanager.h | ||
3 | * @brief LLTextureAtlasManager base class. | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2002-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | |||
34 | #ifndef LL_TEXTUREATLASMANAGER_H | ||
35 | #define LL_TEXTUREATLASMANAGER_H | ||
36 | |||
37 | #include "llmemory.h" | ||
38 | |||
39 | class LLSpatialGroup ; | ||
40 | class LLViewerImage ; | ||
41 | |||
42 | //just use it as a structure. | ||
43 | class LLTextureAtlasSlot : public LLRefCount | ||
44 | { | ||
45 | public: | ||
46 | LLTextureAtlasSlot(LLTextureAtlas* atlasp, LLSpatialGroup* groupp, S16 col, S16 row, F32 xoffset, F32 yoffset, S8 slot_width) ; | ||
47 | |||
48 | protected: | ||
49 | virtual ~LLTextureAtlasSlot(); | ||
50 | |||
51 | public: | ||
52 | |||
53 | // | ||
54 | //do not allow to change those values | ||
55 | // | ||
56 | //void setAtlas(LLTextureAtlas* atlasp) ; | ||
57 | //void setSlotPos(S16 col, S16 row) ; | ||
58 | //void setSlotWidth(S8 width) ; | ||
59 | //void setTexCoordOffset(F32 xoffser, F32 yoffset) ; | ||
60 | // | ||
61 | |||
62 | void setSpatialGroup(LLSpatialGroup* groupp) ; | ||
63 | void setTexCoordScale(F32 xscale, F32 yscale) ; | ||
64 | void setValid() {mValid = TRUE ;} | ||
65 | |||
66 | LLTextureAtlas* getAtlas()const {return mAtlasp;} | ||
67 | LLSpatialGroup* getSpatialGroup() const {return mGroupp ;} | ||
68 | S16 getSlotCol()const {return mCol;} | ||
69 | S16 getSlotRow()const {return mRow;} | ||
70 | S8 getSlotWidth()const{return mReservedSlotWidth;} | ||
71 | BOOL isValid()const { return mValid;} | ||
72 | const LLVector2* getTexCoordOffset()const {return &mTexCoordOffset;} | ||
73 | const LLVector2* getTexCoordScale() const {return &mTexCoordScale;} | ||
74 | |||
75 | void setUpdatedTime(U32 t) {mUpdatedTime = t;} | ||
76 | U32 getUpdatedTime()const {return mUpdatedTime;} | ||
77 | |||
78 | private: | ||
79 | LLTextureAtlas* mAtlasp; | ||
80 | S16 mCol ;//col of the slot | ||
81 | S16 mRow ;//row of the slot | ||
82 | S8 mReservedSlotWidth ; //slot is a square with each edge length a power-of-two number | ||
83 | LLSpatialGroup* mGroupp ; | ||
84 | BOOL mValid ; | ||
85 | |||
86 | LLVector2 mTexCoordOffset ; | ||
87 | LLVector2 mTexCoordScale ; | ||
88 | |||
89 | U32 mUpdatedTime ; | ||
90 | } ; | ||
91 | |||
92 | class LLTextureAtlasManager : public LLSingleton<LLTextureAtlasManager> | ||
93 | { | ||
94 | private: | ||
95 | typedef std::list<LLPointer<LLTextureAtlas> > ll_texture_atlas_list_t ; | ||
96 | |||
97 | public: | ||
98 | LLTextureAtlasManager(); | ||
99 | ~LLTextureAtlasManager(); | ||
100 | |||
101 | LLPointer<LLTextureAtlasSlot> reserveAtlasSlot(S32 sub_texture_size, S8 ncomponents, | ||
102 | LLSpatialGroup* groupp, LLViewerImage* imagep) ; | ||
103 | void releaseAtlas(LLTextureAtlas* atlasp); | ||
104 | |||
105 | BOOL canAddToAtlas(S32 w, S32 h, S8 ncomponents, LLGLenum target) ; | ||
106 | |||
107 | private: | ||
108 | std::vector<ll_texture_atlas_list_t> mAtlasMap ; | ||
109 | std::vector<ll_texture_atlas_list_t> mEmptyAtlasMap ; //delay some empty atlases deletion to avoid possible creation of new atlas immediately. | ||
110 | }; | ||
111 | |||
112 | #endif | ||
diff --git a/linden/indra/newview/lltextureview.cpp b/linden/indra/newview/lltextureview.cpp index 04cebf5..903a6e5 100644 --- a/linden/indra/newview/lltextureview.cpp +++ b/linden/indra/newview/lltextureview.cpp | |||
@@ -57,14 +57,16 @@ | |||
57 | extern F32 texmem_lower_bound_scale; | 57 | extern F32 texmem_lower_bound_scale; |
58 | 58 | ||
59 | LLTextureView *gTextureView = NULL; | 59 | LLTextureView *gTextureView = NULL; |
60 | LLTextureSizeView *gTextureSizeView = NULL; | ||
61 | LLTextureSizeView *gTextureCategoryView = NULL; | ||
60 | 62 | ||
61 | //static | 63 | //static |
62 | std::set<LLViewerImage*> LLTextureView::sDebugImages; | 64 | std::set<LLViewerImage*> LLTextureView::sDebugImages; |
63 | 65 | ||
64 | //////////////////////////////////////////////////////////////////////////// | 66 | //////////////////////////////////////////////////////////////////////////// |
65 | 67 | ||
66 | static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max"); | 68 | static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download]"); |
67 | static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max"); | 69 | static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download]"); |
68 | static std::string title_string2("State"); | 70 | static std::string title_string2("State"); |
69 | static std::string title_string3("Pkt Bnd"); | 71 | static std::string title_string3("Pkt Bnd"); |
70 | static std::string title_string4(" W x H (Dis) Mem"); | 72 | static std::string title_string4(" W x H (Dis) Mem"); |
@@ -201,13 +203,14 @@ void LLTextureBar::draw() | |||
201 | } | 203 | } |
202 | else | 204 | else |
203 | { | 205 | { |
204 | tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x)", | 206 | tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x) %1.2f", |
205 | uuid_str.c_str(), | 207 | uuid_str.c_str(), |
206 | mImagep->mMaxVirtualSize, | 208 | mImagep->mMaxVirtualSize, |
207 | mImagep->mDesiredDiscardLevel, | 209 | mImagep->mDesiredDiscardLevel, |
208 | mImagep->mRequestedDiscardLevel, | 210 | mImagep->mRequestedDiscardLevel, |
209 | mImagep->getDecodePriority(), | 211 | mImagep->getDecodePriority(), |
210 | mImagep->mFetchPriority); | 212 | mImagep->mFetchPriority, |
213 | mImagep->mDownloadProgress); | ||
211 | } | 214 | } |
212 | 215 | ||
213 | LLFontGL::getFontMonospace()->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(), | 216 | LLFontGL::getFontMonospace()->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(), |
@@ -253,7 +256,7 @@ void LLTextureBar::draw() | |||
253 | 256 | ||
254 | // Draw the progress bar. | 257 | // Draw the progress bar. |
255 | S32 bar_width = 100; | 258 | S32 bar_width = 100; |
256 | S32 bar_left = 260; | 259 | S32 bar_left = 330; |
257 | left = bar_left; | 260 | left = bar_left; |
258 | right = left + bar_width; | 261 | right = left + bar_width; |
259 | 262 | ||
@@ -262,7 +265,7 @@ void LLTextureBar::draw() | |||
262 | 265 | ||
263 | F32 data_progress = mImagep->mDownloadProgress; | 266 | F32 data_progress = mImagep->mDownloadProgress; |
264 | 267 | ||
265 | if (data_progress > 0.0f) | 268 | if (data_progress > 0.0f && data_progress <= 1.0f) |
266 | { | 269 | { |
267 | // Downloaded bytes | 270 | // Downloaded bytes |
268 | right = left + llfloor(data_progress * (F32)bar_width); | 271 | right = left + llfloor(data_progress * (F32)bar_width); |
@@ -272,6 +275,16 @@ void LLTextureBar::draw() | |||
272 | gl_rect_2d(left, top, right, bottom); | 275 | gl_rect_2d(left, top, right, bottom); |
273 | } | 276 | } |
274 | } | 277 | } |
278 | else if (data_progress > 1.0f) | ||
279 | { | ||
280 | // Small cached textures generate this oddity. SNOW-168 | ||
281 | right = left + bar_width; | ||
282 | if (right > left) | ||
283 | { | ||
284 | gGL.color4f(0.f, 0.33f, 0.f, 0.75f); | ||
285 | gl_rect_2d(left, top, right, bottom); | ||
286 | } | ||
287 | } | ||
275 | 288 | ||
276 | S32 pip_width = 6; | 289 | S32 pip_width = 6; |
277 | S32 pip_space = 14; | 290 | S32 pip_space = 14; |
@@ -386,9 +399,9 @@ private: | |||
386 | 399 | ||
387 | void LLGLTexMemBar::draw() | 400 | void LLGLTexMemBar::draw() |
388 | { | 401 | { |
389 | S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sBoundTextureMemoryInBytes); | 402 | S32 bound_mem = (LLViewerImage::sBoundTextureMemoryInBytes >> 20); |
390 | S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMemInMegaBytes; | 403 | S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMemInMegaBytes; |
391 | S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sTotalTextureMemoryInBytes); | 404 | S32 total_mem = (LLViewerImage::sTotalTextureMemoryInBytes >> 20); |
392 | S32 max_total_mem = LLViewerImage::sMaxTotalTextureMemInMegaBytes; | 405 | S32 max_total_mem = LLViewerImage::sMaxTotalTextureMemInMegaBytes; |
393 | F32 discard_bias = LLViewerImage::sDesiredDiscardBias; | 406 | F32 discard_bias = LLViewerImage::sDesiredDiscardBias; |
394 | S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); | 407 | S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); |
@@ -478,28 +491,25 @@ void LLGLTexMemBar::draw() | |||
478 | #endif | 491 | #endif |
479 | //---------------------------------------------------------------------------- | 492 | //---------------------------------------------------------------------------- |
480 | 493 | ||
481 | text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d HTP:%d", | 494 | text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d HTP:%d BW: %.0f/%.0f", |
482 | gImageList.getNumImages(), | 495 | gImageList.getNumImages(), |
483 | LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(), | 496 | LLAppViewer::getTextureFetch()->getNumRequests(), |
484 | LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, | 497 | LLAppViewer::getTextureFetch()->getNumDeletes(), |
485 | LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(), | 498 | LLAppViewer::getTextureFetch()->mPacketCount, |
499 | LLAppViewer::getTextureFetch()->mBadPacketCount, | ||
500 | LLAppViewer::getTextureCache()->getNumReads(), | ||
501 | LLAppViewer::getTextureCache()->getNumWrites(), | ||
486 | LLLFSThread::sLocal->getPending(), | 502 | LLLFSThread::sLocal->getPending(), |
487 | LLAppViewer::getImageDecodeThread()->getPending(), | 503 | LLAppViewer::getImageDecodeThread()->getPending(), |
488 | LLImageRaw::sRawImageCount, | 504 | LLImageRaw::sRawImageCount, |
489 | LLAppViewer::getTextureFetch()->getNumHTTPRequests()); | 505 | LLAppViewer::getTextureFetch()->getNumHTTPRequests(), |
506 | LLAppViewer::getTextureFetch()->getTextureBandwidth(), | ||
507 | gSavedSettings.getF32("ThrottleBandwidthKBPS")); | ||
490 | 508 | ||
491 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2, | 509 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2, |
492 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | 510 | text_color, LLFontGL::LEFT, LLFontGL::TOP); |
493 | 511 | ||
494 | 512 | left = 600; | |
495 | left = 550; | ||
496 | F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth(); | ||
497 | F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS"); | ||
498 | color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; | ||
499 | color[VALPHA] = text_color[VALPHA]; | ||
500 | text = llformat("BW:%.0f/%.0f",bandwidth, max_bandwidth); | ||
501 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, line_height*2, | ||
502 | color, LLFontGL::LEFT, LLFontGL::TOP); | ||
503 | 513 | ||
504 | S32 dx1 = 0; | 514 | S32 dx1 = 0; |
505 | if (LLAppViewer::getTextureFetch()->mDebugPause) | 515 | if (LLAppViewer::getTextureFetch()->mDebugPause) |
@@ -566,7 +576,7 @@ public: | |||
566 | void setTop(S32 loaded, S32 bound, F32 scale) {mTopLoaded = loaded ; mTopBound = bound; mScale = scale ;} | 576 | void setTop(S32 loaded, S32 bound, F32 scale) {mTopLoaded = loaded ; mTopBound = bound; mScale = scale ;} |
567 | 577 | ||
568 | void draw(); | 578 | void draw(); |
569 | BOOL handleHover(S32 x, S32 y, MASK mask, BOOL set_pick_size) ; | 579 | BOOL handleHover(S32 x, S32 y, MASK mask) ; |
570 | 580 | ||
571 | private: | 581 | private: |
572 | S32 mIndex ; | 582 | S32 mIndex ; |
@@ -579,16 +589,19 @@ private: | |||
579 | F32 mScale ; | 589 | F32 mScale ; |
580 | }; | 590 | }; |
581 | 591 | ||
582 | BOOL LLGLTexSizeBar::handleHover(S32 x, S32 y, MASK mask, BOOL set_pick_size) | 592 | BOOL LLGLTexSizeBar::handleHover(S32 x, S32 y, MASK mask) |
583 | { | 593 | { |
594 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
584 | if(y > mBottom && (y < mBottom + (S32)(mTopLoaded * mScale) || y < mBottom + (S32)(mTopBound * mScale))) | 595 | if(y > mBottom && (y < mBottom + (S32)(mTopLoaded * mScale) || y < mBottom + (S32)(mTopBound * mScale))) |
585 | { | 596 | { |
586 | LLImageGL::setCurTexSizebar(mIndex, set_pick_size); | 597 | LLImageGL::setCurTexSizebar(mIndex); |
587 | } | 598 | } |
599 | #endif | ||
588 | return TRUE ; | 600 | return TRUE ; |
589 | } | 601 | } |
590 | void LLGLTexSizeBar::draw() | 602 | void LLGLTexSizeBar::draw() |
591 | { | 603 | { |
604 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
592 | LLGLSUIDefault gls_ui; | 605 | LLGLSUIDefault gls_ui; |
593 | 606 | ||
594 | if(LLImageGL::sCurTexSizeBar == mIndex) | 607 | if(LLImageGL::sCurTexSizeBar == mIndex) |
@@ -609,6 +622,7 @@ void LLGLTexSizeBar::draw() | |||
609 | F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; | 622 | F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; |
610 | gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ; | 623 | gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ; |
611 | gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ; | 624 | gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ; |
625 | #endif | ||
612 | } | 626 | } |
613 | //////////////////////////////////////////////////////////////////////////// | 627 | //////////////////////////////////////////////////////////////////////////// |
614 | 628 | ||
@@ -913,31 +927,7 @@ LLTextureSizeView::~LLTextureSizeView() | |||
913 | } | 927 | } |
914 | void LLTextureSizeView::draw() | 928 | void LLTextureSizeView::draw() |
915 | { | 929 | { |
916 | if(mType == TEXTURE_MEM_OVER_SIZE) | 930 | #if !LL_RELEASE_FOR_DOWNLOAD |
917 | { | ||
918 | drawTextureSizeGraph(); | ||
919 | } | ||
920 | else | ||
921 | { | ||
922 | drawTextureCategoryGraph() ; | ||
923 | } | ||
924 | |||
925 | LLView::draw(); | ||
926 | } | ||
927 | |||
928 | BOOL LLTextureSizeView::handleHover(S32 x, S32 y, MASK mask) | ||
929 | { | ||
930 | if(x > mTextureSizeBarRect.mLeft && x < mTextureSizeBarRect.mRight) | ||
931 | { | ||
932 | mTextureSizeBar[(x - mTextureSizeBarRect.mLeft) / mTextureSizeBarWidth]->handleHover(x, y, mask, (mType == TEXTURE_MEM_OVER_SIZE)) ; | ||
933 | } | ||
934 | |||
935 | return TRUE ; | ||
936 | } | ||
937 | |||
938 | //draw real-time texture mem bar over size | ||
939 | void LLTextureSizeView::drawTextureSizeGraph() | ||
940 | { | ||
941 | if(mTextureSizeBar.size() == 0) | 931 | if(mTextureSizeBar.size() == 0) |
942 | { | 932 | { |
943 | S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); | 933 | S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); |
@@ -958,16 +948,29 @@ void LLTextureSizeView::drawTextureSizeGraph() | |||
958 | mTextureSizeBar[i]->draw() ; | 948 | mTextureSizeBar[i]->draw() ; |
959 | } | 949 | } |
960 | LLImageGL::resetCurTexSizebar(); | 950 | LLImageGL::resetCurTexSizebar(); |
951 | |||
952 | LLView::draw(); | ||
953 | #endif | ||
954 | } | ||
955 | |||
956 | BOOL LLTextureSizeView::handleHover(S32 x, S32 y, MASK mask) | ||
957 | { | ||
958 | if(x > mTextureSizeBarRect.mLeft && x < mTextureSizeBarRect.mRight) | ||
959 | { | ||
960 | mTextureSizeBar[(x - mTextureSizeBarRect.mLeft) / mTextureSizeBarWidth]->handleHover(x, y, mask) ; | ||
961 | } | ||
962 | |||
963 | return TRUE ; | ||
961 | } | 964 | } |
962 | 965 | ||
963 | //draw background of texture size bar graph | 966 | //draw background of texture size bar graph |
964 | F32 LLTextureSizeView::drawTextureSizeDistributionGraph() | 967 | F32 LLTextureSizeView::drawTextureSizeDistributionGraph() |
965 | { | 968 | { |
966 | //scale | ||
967 | F32 scale = 1.0f ; | 969 | F32 scale = 1.0f ; |
968 | 970 | #if !LL_RELEASE_FOR_DOWNLOAD | |
969 | LLGLSUIDefault gls_ui; | 971 | LLGLSUIDefault gls_ui; |
970 | 972 | ||
973 | //scale | ||
971 | { | 974 | { |
972 | S32 count = 0 ; | 975 | S32 count = 0 ; |
973 | for(U32 i = 0 ; i < LLImageGL::sTextureLoadedCounter.size() ; i++) | 976 | for(U32 i = 0 ; i < LLImageGL::sTextureLoadedCounter.size() ; i++) |
@@ -1057,136 +1060,7 @@ F32 LLTextureSizeView::drawTextureSizeDistributionGraph() | |||
1057 | text = llformat("Texture Size Distribution") ; | 1060 | text = llformat("Texture Size Distribution") ; |
1058 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3, | 1061 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3, |
1059 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | 1062 | text_color, LLFontGL::LEFT, LLFontGL::TOP); |
1060 | return scale ; | ||
1061 | } | ||
1062 | |||
1063 | //draw real-time texture mem bar over category | ||
1064 | void LLTextureSizeView::drawTextureCategoryGraph() | ||
1065 | { | ||
1066 | if(mTextureSizeBar.size() == 0) | ||
1067 | { | ||
1068 | S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); | ||
1069 | mTextureSizeBar.resize(LLImageGL::sTextureMemByCategory.size()) ; | ||
1070 | mTextureSizeBarRect.set(700, line_height * 2 + 400, 700 + mTextureSizeBar.size() * mTextureSizeBarWidth, line_height * 2) ; | ||
1071 | |||
1072 | for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++) | ||
1073 | { | ||
1074 | mTextureSizeBar[i] = new LLGLTexSizeBar(i, mTextureSizeBarRect.mLeft + i * mTextureSizeBarWidth , | ||
1075 | line_height * 2, mTextureSizeBarRect.mLeft + (i + 1) * mTextureSizeBarWidth, line_height) ; | ||
1076 | } | ||
1077 | } | ||
1078 | |||
1079 | F32 size_bar_scale = drawTextureCategoryDistributionGraph() ; | ||
1080 | for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++) | ||
1081 | { | ||
1082 | mTextureSizeBar[i]->setTop(LLImageGL::sTextureMemByCategory[i] >> 20, LLImageGL::sTextureMemByCategoryBound[i] >> 20, size_bar_scale) ; | ||
1083 | mTextureSizeBar[i]->draw() ; | ||
1084 | } | ||
1085 | LLImageGL::resetCurTexSizebar(); | ||
1086 | } | ||
1087 | |||
1088 | //draw background for TEXTURE_MEM_OVER_CATEGORY | ||
1089 | F32 LLTextureSizeView::drawTextureCategoryDistributionGraph() | ||
1090 | { | ||
1091 | //scale | ||
1092 | F32 scale = 4.0f ; | ||
1093 | |||
1094 | LLGLSUIDefault gls_ui; | ||
1095 | |||
1096 | { | ||
1097 | S32 count = 0 ; | ||
1098 | for(U32 i = 0 ; i < LLImageGL::sTextureMemByCategory.size() ; i++) | ||
1099 | { | ||
1100 | S32 tmp = LLImageGL::sTextureMemByCategory[i] >> 20 ; | ||
1101 | if(tmp > count) | ||
1102 | { | ||
1103 | count = tmp ; | ||
1104 | } | ||
1105 | } | ||
1106 | if(count > mTextureSizeBarRect.getHeight() * 0.25f) | ||
1107 | { | ||
1108 | scale = (F32)mTextureSizeBarRect.getHeight() * 0.25f / count ; | ||
1109 | } | ||
1110 | } | ||
1111 | |||
1112 | S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); | ||
1113 | S32 left = mTextureSizeBarRect.mLeft ; | ||
1114 | S32 bottom = mTextureSizeBarRect.mBottom ; | ||
1115 | S32 right = mTextureSizeBarRect.mRight ; | ||
1116 | S32 top = mTextureSizeBarRect.mTop ; | ||
1117 | |||
1118 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
1119 | |||
1120 | //background rect | ||
1121 | gl_rect_2d(left - 25, top + 30, right + 100, bottom - 25, LLColor4(0.0f, 0.0f, 0.0f, 0.25f)) ; | ||
1122 | |||
1123 | //-------------------------------------------------- | ||
1124 | gGL.color4f(1.0f, 0.5f, 0.5f, 0.75f); | ||
1125 | gl_line_2d(left, bottom, right, bottom) ; //x axis | ||
1126 | gl_line_2d(left, bottom, left, top) ; //y axis | ||
1127 | |||
1128 | //ruler | ||
1129 | //-------------------------------------------------- | ||
1130 | gGL.color4f(1.0f, 0.5f, 0.5f, 0.5f); | ||
1131 | for(S32 i = bottom + 50 ; i <= top ; i += 50) | ||
1132 | { | ||
1133 | gl_line_2d(left, i, right, i) ; | ||
1134 | } | ||
1135 | |||
1136 | //texts | ||
1137 | //-------------------------------------------------- | ||
1138 | F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; | ||
1139 | std::string text; | ||
1140 | |||
1141 | //------- | ||
1142 | //x axis: size label | ||
1143 | static char category[LLViewerImageBoostLevel::MAX_GL_IMAGE_CATEGORY][4] = | ||
1144 | {"Non", "Bak", "Av", "Cld", "Scp", "Hi", "Trn", "Slt", "Hud", "Bsf", "UI", "Pvw", "Map", "Mvs", "Slf", "Tbp", "Scr", "Fnt", "Bmp", "Dyn", "Tlc", "Mdi", "ALT", "Oth" } ; | ||
1145 | |||
1146 | text = llformat("%s", category[0]) ; | ||
1147 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 12, bottom - line_height / 2, | ||
1148 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
1149 | for(U32 i = 1 ; i < mTextureSizeBar.size() ; i++) | ||
1150 | { | ||
1151 | text = llformat("%s", category[i]) ; | ||
1152 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + i * mTextureSizeBarWidth + 12, bottom - line_height / 2, | ||
1153 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
1154 | } | ||
1155 | //------- | ||
1156 | |||
1157 | //y axis: number label | ||
1158 | for(S32 i = bottom + 50 ; i <= top ; i += 50) | ||
1159 | { | ||
1160 | text = llformat("%d", (S32)((i - bottom) / scale)) ; | ||
1161 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left - 20, i + line_height / 2 , | ||
1162 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
1163 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, right + 5, i + line_height / 2 , | ||
1164 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
1165 | } | ||
1166 | |||
1167 | text = llformat("MB") ; | ||
1168 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left - 20, top + line_height * 2 , | ||
1169 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
1170 | //-------------------------------------------------- | ||
1171 | F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f}; | ||
1172 | gl_rect_2d(left + 70, top + line_height * 2, left + 90, top + line_height, loaded_color) ; | ||
1173 | text = llformat("Loaded") ; | ||
1174 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 100, top + line_height * 2, | ||
1175 | loaded_color, | ||
1176 | LLFontGL::LEFT, LLFontGL::TOP); | ||
1177 | |||
1178 | F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; | ||
1179 | gl_rect_2d(left + 170, top + line_height * 2, left + 190, top + line_height, bound_color) ; | ||
1180 | text = llformat("Bound") ; | ||
1181 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 200, top + line_height * 2, | ||
1182 | bound_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
1183 | |||
1184 | //-------------------------------------------------- | ||
1185 | |||
1186 | //title | ||
1187 | text = llformat("Texture Category Distribution") ; | ||
1188 | LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3, | ||
1189 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
1190 | 1063 | ||
1064 | #endif | ||
1191 | return scale ; | 1065 | return scale ; |
1192 | } | 1066 | } |
diff --git a/linden/indra/newview/lltoolpie.h b/linden/indra/newview/lltoolpie.h index 001886f..54bf409 100644 --- a/linden/indra/newview/lltoolpie.h +++ b/linden/indra/newview/lltoolpie.h | |||
@@ -86,7 +86,6 @@ private: | |||
86 | LLPickInfo mPick; | 86 | LLPickInfo mPick; |
87 | U8 mClickAction; | 87 | U8 mClickAction; |
88 | LLSafeHandle<LLObjectSelection> mLeftClickSelection; | 88 | LLSafeHandle<LLObjectSelection> mLeftClickSelection; |
89 | protected: | ||
90 | LLPointer<LLViewerObject> mClickActionObject; | 89 | LLPointer<LLViewerObject> mClickActionObject; |
91 | }; | 90 | }; |
92 | 91 | ||
diff --git a/linden/indra/newview/llviewercamera.cpp b/linden/indra/newview/llviewercamera.cpp index dade65f..6cef2af 100644 --- a/linden/indra/newview/llviewercamera.cpp +++ b/linden/indra/newview/llviewercamera.cpp | |||
@@ -769,8 +769,8 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts) | |||
769 | 769 | ||
770 | BOOL in_frustum = pointInFrustum(LLVector3(vec)) > 0; | 770 | BOOL in_frustum = pointInFrustum(LLVector3(vec)) > 0; |
771 | 771 | ||
772 | if (( !in_frustum && all_verts) || | 772 | if ( !in_frustum && all_verts || |
773 | (in_frustum && !all_verts)) | 773 | in_frustum && !all_verts) |
774 | { | 774 | { |
775 | return !all_verts; | 775 | return !all_verts; |
776 | } | 776 | } |
diff --git a/linden/indra/newview/llviewercontrol.cpp b/linden/indra/newview/llviewercontrol.cpp index 1531e6c..4c9c098 100644 --- a/linden/indra/newview/llviewercontrol.cpp +++ b/linden/indra/newview/llviewercontrol.cpp | |||
@@ -90,7 +90,7 @@ std::string gCurrentVersion; | |||
90 | extern BOOL gResizeScreenTexture; | 90 | extern BOOL gResizeScreenTexture; |
91 | extern BOOL gDebugGL; | 91 | extern BOOL gDebugGL; |
92 | 92 | ||
93 | extern BOOL gAuditTexture; | 93 | //extern BOOL gAuditTexture; |
94 | 94 | ||
95 | //////////////////////////////////////////////////////////////////////////// | 95 | //////////////////////////////////////////////////////////////////////////// |
96 | // Listeners | 96 | // Listeners |
@@ -418,12 +418,12 @@ static bool handleRenderUseImpostorsChanged(const LLSD& newvalue) | |||
418 | LLVOAvatar::sUseImpostors = newvalue.asBoolean(); | 418 | LLVOAvatar::sUseImpostors = newvalue.asBoolean(); |
419 | return true; | 419 | return true; |
420 | } | 420 | } |
421 | 421 | /* | |
422 | static bool handleAuditTextureChanged(const LLSD& newvalue) | 422 | static bool handleAuditTextureChanged(const LLSD& newvalue) |
423 | { | 423 | { |
424 | gAuditTexture = newvalue.asBoolean(); | 424 | gAuditTexture = newvalue.asBoolean(); |
425 | return true; | 425 | return true; |
426 | } | 426 | }*/ |
427 | 427 | ||
428 | static bool handleRenderDebugGLChanged(const LLSD& newvalue) | 428 | static bool handleRenderDebugGLChanged(const LLSD& newvalue) |
429 | { | 429 | { |
@@ -528,6 +528,11 @@ void settings_setup_listeners() | |||
528 | gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _1)); | 528 | gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _1)); |
529 | gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); | 529 | gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); |
530 | gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); | 530 | gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); |
531 | |||
532 | gSavedSettings.getControl("RenderSpecularResX")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _1)); | ||
533 | gSavedSettings.getControl("RenderSpecularResY")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _1)); | ||
534 | gSavedSettings.getControl("RenderSpecularExponent")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _1)); | ||
535 | |||
531 | gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _1)); | 536 | gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _1)); |
532 | gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); | 537 | gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); |
533 | gSavedSettings.getControl("EnableRippleWater")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); | 538 | gSavedSettings.getControl("EnableRippleWater")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); |
@@ -539,6 +544,9 @@ void settings_setup_listeners() | |||
539 | gSavedSettings.getControl("RenderAvatarInvisible")->getSignal()->connect(boost::bind(&handleSetSelfInvisible, _1)); | 544 | gSavedSettings.getControl("RenderAvatarInvisible")->getSignal()->connect(boost::bind(&handleSetSelfInvisible, _1)); |
540 | gSavedSettings.getControl("RenderVolumeLODFactor")->getSignal()->connect(boost::bind(&handleVolumeLODChanged, _1)); | 545 | gSavedSettings.getControl("RenderVolumeLODFactor")->getSignal()->connect(boost::bind(&handleVolumeLODChanged, _1)); |
541 | gSavedSettings.getControl("RenderAvatarLODFactor")->getSignal()->connect(boost::bind(&handleAvatarLODChanged, _1)); | 546 | gSavedSettings.getControl("RenderAvatarLODFactor")->getSignal()->connect(boost::bind(&handleAvatarLODChanged, _1)); |
547 | gSavedSettings.getControl("RenderDeferredShadow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); | ||
548 | gSavedSettings.getControl("RenderDeferredGI")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _1)); | ||
549 | |||
542 | gSavedSettings.getControl("RenderTerrainLODFactor")->getSignal()->connect(boost::bind(&handleTerrainLODChanged, _1)); | 550 | gSavedSettings.getControl("RenderTerrainLODFactor")->getSignal()->connect(boost::bind(&handleTerrainLODChanged, _1)); |
543 | gSavedSettings.getControl("RenderTreeLODFactor")->getSignal()->connect(boost::bind(&handleTreeLODChanged, _1)); | 551 | gSavedSettings.getControl("RenderTreeLODFactor")->getSignal()->connect(boost::bind(&handleTreeLODChanged, _1)); |
544 | gSavedSettings.getControl("RenderFlexTimeFactor")->getSignal()->connect(boost::bind(&handleFlexLODChanged, _1)); | 552 | gSavedSettings.getControl("RenderFlexTimeFactor")->getSignal()->connect(boost::bind(&handleFlexLODChanged, _1)); |
@@ -584,7 +592,7 @@ void settings_setup_listeners() | |||
584 | gSavedSettings.getControl("AudioLevelDoppler")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); | 592 | gSavedSettings.getControl("AudioLevelDoppler")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); |
585 | gSavedSettings.getControl("AudioLevelRolloff")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); | 593 | gSavedSettings.getControl("AudioLevelRolloff")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); |
586 | gSavedSettings.getControl("AudioStreamingMusic")->getSignal()->connect(boost::bind(&handleAudioStreamMusicChanged, _1)); | 594 | gSavedSettings.getControl("AudioStreamingMusic")->getSignal()->connect(boost::bind(&handleAudioStreamMusicChanged, _1)); |
587 | gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _1)); | 595 | // gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _1)); |
588 | gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); | 596 | gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); |
589 | gSavedSettings.getControl("MuteMusic")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); | 597 | gSavedSettings.getControl("MuteMusic")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); |
590 | gSavedSettings.getControl("MuteMedia")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); | 598 | gSavedSettings.getControl("MuteMedia")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1)); |
diff --git a/linden/indra/newview/llviewerdisplay.cpp b/linden/indra/newview/llviewerdisplay.cpp index ad186d5..8e066c8 100644 --- a/linden/indra/newview/llviewerdisplay.cpp +++ b/linden/indra/newview/llviewerdisplay.cpp | |||
@@ -128,6 +128,11 @@ void display_startup() | |||
128 | return; | 128 | return; |
129 | } | 129 | } |
130 | 130 | ||
131 | gPipeline.updateGL(); | ||
132 | |||
133 | // Update images? | ||
134 | gImageList.updateImages(0.01f); | ||
135 | |||
131 | LLGLSDefault gls_default; | 136 | LLGLSDefault gls_default; |
132 | 137 | ||
133 | // Required for HTML update in login screen | 138 | // Required for HTML update in login screen |
@@ -599,6 +604,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
599 | gPipeline.updateGeom(max_geom_update_time); | 604 | gPipeline.updateGeom(max_geom_update_time); |
600 | stop_glerror(); | 605 | stop_glerror(); |
601 | 606 | ||
607 | gPipeline.updateGL(); | ||
608 | stop_glerror(); | ||
609 | |||
602 | gFrameStats.start(LLFrameStats::UPDATE_CULL); | 610 | gFrameStats.start(LLFrameStats::UPDATE_CULL); |
603 | S32 water_clip = 0; | 611 | S32 water_clip = 0; |
604 | if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && | 612 | if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && |
@@ -688,6 +696,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
688 | gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); | 696 | gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); |
689 | } | 697 | } |
690 | 698 | ||
699 | LLVertexBuffer::unbind(); // KL | ||
700 | |||
691 | LLGLState::checkStates(); | 701 | LLGLState::checkStates(); |
692 | LLGLState::checkTextureChannels(); | 702 | LLGLState::checkTextureChannels(); |
693 | LLGLState::checkClientArrays(); | 703 | LLGLState::checkClientArrays(); |
@@ -718,6 +728,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
718 | { | 728 | { |
719 | LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); | 729 | LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); |
720 | gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); | 730 | gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); |
731 | gPipeline.generateHighlight(*LLViewerCamera::getInstance()); | ||
721 | } | 732 | } |
722 | 733 | ||
723 | ////////////////////////////////////// | 734 | ////////////////////////////////////// |
@@ -742,6 +753,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
742 | 753 | ||
743 | const F32 max_image_decode_time = llmin(0.005f, 0.005f*10.f*gFrameIntervalSeconds); // 50 ms/second decode time (no more than 5ms/frame) | 754 | const F32 max_image_decode_time = llmin(0.005f, 0.005f*10.f*gFrameIntervalSeconds); // 50 ms/second decode time (no more than 5ms/frame) |
744 | gImageList.updateImages(max_image_decode_time); | 755 | gImageList.updateImages(max_image_decode_time); |
756 | |||
757 | //remove dead textures from GL KL is it req? | ||
758 | LLImageGL::deleteDeadTextures(); | ||
745 | stop_glerror(); | 759 | stop_glerror(); |
746 | } | 760 | } |
747 | llpushcallstacks ; | 761 | llpushcallstacks ; |
@@ -896,7 +910,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
896 | /// and then display it again with compositor effects. | 910 | /// and then display it again with compositor effects. |
897 | /// Using render to texture would be faster/better, but I don't have a | 911 | /// Using render to texture would be faster/better, but I don't have a |
898 | /// grasp of their full display stack just yet. | 912 | /// grasp of their full display stack just yet. |
899 | // gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); | 913 | gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); // KL |
900 | 914 | ||
901 | if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) | 915 | if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) |
902 | { | 916 | { |
@@ -912,6 +926,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
912 | render_ui(); | 926 | render_ui(); |
913 | } | 927 | } |
914 | 928 | ||
929 | gPipeline.rebuildGroups(); | ||
930 | |||
915 | LLSpatialGroup::sNoDelete = FALSE; | 931 | LLSpatialGroup::sNoDelete = FALSE; |
916 | } | 932 | } |
917 | 933 | ||
@@ -998,6 +1014,15 @@ void render_hud_attachments() | |||
998 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_VOLUME); | 1014 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_VOLUME); |
999 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA); | 1015 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA); |
1000 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT); | 1016 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT); |
1017 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA); | ||
1018 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK); | ||
1019 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_BUMP); | ||
1020 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT); | ||
1021 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK); | ||
1022 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY); | ||
1023 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_SHINY); | ||
1024 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_INVISIBLE); | ||
1025 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY); | ||
1001 | 1026 | ||
1002 | gPipeline.stateSort(hud_cam, result); | 1027 | gPipeline.stateSort(hud_cam, result); |
1003 | 1028 | ||
diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp index 400fb2f..93c17a2 100644 --- a/linden/indra/newview/llviewerimage.cpp +++ b/linden/indra/newview/llviewerimage.cpp | |||
@@ -60,6 +60,8 @@ | |||
60 | #include "pipeline.h" | 60 | #include "pipeline.h" |
61 | #include "llappviewer.h" | 61 | #include "llappviewer.h" |
62 | #include "llface.h" | 62 | #include "llface.h" |
63 | #include "lltextureatlas.h" | ||
64 | #include "lltextureatlasmanager.h" | ||
63 | #include "llviewercamera.h" | 65 | #include "llviewercamera.h" |
64 | /////////////////////////////////////////////////////////////////////////////// | 66 | /////////////////////////////////////////////////////////////////////////////// |
65 | 67 | ||
@@ -102,7 +104,7 @@ void LLViewerImage::initClass() | |||
102 | sNullImagep = new LLImageGL(1,1,3,TRUE); | 104 | sNullImagep = new LLImageGL(1,1,3,TRUE); |
103 | LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3); | 105 | LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3); |
104 | raw->clear(0x77, 0x77, 0x77, 0xFF); | 106 | raw->clear(0x77, 0x77, 0x77, 0xFF); |
105 | sNullImagep->createGLTexture(0, raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | 107 | sNullImagep->createGLTexture(0, raw); |
106 | 108 | ||
107 | #if 1 | 109 | #if 1 |
108 | LLPointer<LLViewerImage> imagep = new LLViewerImage(IMG_DEFAULT); | 110 | LLPointer<LLViewerImage> imagep = new LLViewerImage(IMG_DEFAULT); |
@@ -131,7 +133,7 @@ void LLViewerImage::initClass() | |||
131 | } | 133 | } |
132 | } | 134 | } |
133 | } | 135 | } |
134 | imagep->createGLTexture(0, image_raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | 136 | imagep->createGLTexture(0, image_raw); |
135 | image_raw = NULL; | 137 | image_raw = NULL; |
136 | gImageList.addImage(imagep); | 138 | gImageList.addImage(imagep); |
137 | imagep->dontDiscard(); | 139 | imagep->dontDiscard(); |
@@ -141,48 +143,48 @@ void LLViewerImage::initClass() | |||
141 | sSmokeImagep = gImageList.getImage(IMG_SMOKE, TRUE, TRUE); | 143 | sSmokeImagep = gImageList.getImage(IMG_SMOKE, TRUE, TRUE); |
142 | sSmokeImagep->setNoDelete() ; | 144 | sSmokeImagep->setNoDelete() ; |
143 | 145 | ||
144 | if(gAuditTexture) | 146 | #if !LL_RELEASE_FOR_DOWNLOAD |
147 | sDefaultTexturep = new LLImageGL() ; | ||
148 | image_raw = new LLImageRaw(dim,dim,3); | ||
149 | data = image_raw->getData(); | ||
150 | for (S32 i = 0; i<dim; i++) | ||
145 | { | 151 | { |
146 | sDefaultTexturep = new LLImageGL() ; | 152 | for (S32 j = 0; j<dim; j++) |
147 | image_raw = new LLImageRaw(dim,dim,3); | ||
148 | data = image_raw->getData(); | ||
149 | for (S32 i = 0; i<dim; i++) | ||
150 | { | 153 | { |
151 | for (S32 j = 0; j<dim; j++) | 154 | const S32 border = 2; |
155 | if (i<border || j<border || i>=(dim-border) || j>=(dim-border)) | ||
152 | { | 156 | { |
153 | const S32 border = 2; | 157 | *data++ = 0xff; |
154 | if (i<border || j<border || i>=(dim-border) || j>=(dim-border)) | 158 | *data++ = 0xff; |
155 | { | 159 | *data++ = 0xff; |
156 | *data++ = 0xff; | 160 | } |
157 | *data++ = 0xff; | 161 | else |
158 | *data++ = 0xff; | 162 | { |
159 | } | 163 | *data++ = 0xff; |
160 | else | 164 | *data++ = 0xff; |
161 | { | 165 | *data++ = 0x00; |
162 | *data++ = 0xff; | ||
163 | *data++ = 0xff; | ||
164 | *data++ = 0x00; | ||
165 | } | ||
166 | } | 166 | } |
167 | } | 167 | } |
168 | sDefaultTexturep->createGLTexture(0, image_raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | ||
169 | image_raw = NULL; | ||
170 | sDefaultTexturep->dontDiscard(); | ||
171 | } | 168 | } |
169 | sDefaultTexturep->createGLTexture(0, image_raw); | ||
170 | image_raw = NULL; | ||
171 | sDefaultTexturep->dontDiscard(); | ||
172 | #endif | ||
172 | } | 173 | } |
173 | 174 | ||
174 | // static | 175 | // static |
175 | void LLViewerImage::cleanupClass() | 176 | void LLViewerImage::cleanupClass() |
176 | { | 177 | { |
177 | stop_glerror(); | 178 | stop_glerror(); |
178 | LLImageGL::cleanupClass() ; | ||
179 | |||
180 | sNullImagep = NULL; | 179 | sNullImagep = NULL; |
181 | sDefaultImagep = NULL; | 180 | sDefaultImagep = NULL; |
182 | sSmokeImagep = NULL; | 181 | sSmokeImagep = NULL; |
183 | sMissingAssetImagep = NULL; | 182 | sMissingAssetImagep = NULL; |
184 | sWhiteImagep = NULL; | 183 | sWhiteImagep = NULL; |
185 | sDefaultTexturep = NULL ; | 184 | |
185 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
186 | LLImageGL::sDefaultTexturep = NULL ; | ||
187 | #endif | ||
186 | } | 188 | } |
187 | 189 | ||
188 | // tuning params | 190 | // tuning params |
@@ -231,12 +233,7 @@ void LLViewerImage::updateClass(const F32 velocity, const F32 angular_velocity) | |||
231 | } | 233 | } |
232 | sDesiredDiscardBias = llclamp(sDesiredDiscardBias, sDesiredDiscardBiasMin, sDesiredDiscardBiasMax); | 234 | sDesiredDiscardBias = llclamp(sDesiredDiscardBias, sDesiredDiscardBiasMin, sDesiredDiscardBiasMax); |
233 | 235 | ||
234 | F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ; | 236 | LLImageGL::sUseTextureAtlas = gSavedSettings.getBOOL("EnableTextureAtlas") ; |
235 | F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed(); | ||
236 | sCameraMovingDiscardBias = (S8)llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1) ; | ||
237 | |||
238 | LLViewerImage::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) && | ||
239 | (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ; | ||
240 | } | 237 | } |
241 | 238 | ||
242 | // static | 239 | // static |
@@ -382,6 +379,7 @@ LLViewerImage::~LLViewerImage() | |||
382 | void LLViewerImage::cleanup() | 379 | void LLViewerImage::cleanup() |
383 | { | 380 | { |
384 | mFaceList.clear() ; | 381 | mFaceList.clear() ; |
382 | |||
385 | for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); | 383 | for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); |
386 | iter != mLoadedCallbackList.end(); ) | 384 | iter != mLoadedCallbackList.end(); ) |
387 | { | 385 | { |
@@ -411,6 +409,192 @@ void LLViewerImage::reinit(BOOL usemipmaps /* = TRUE */) | |||
411 | setSize(0,0,0); | 409 | setSize(0,0,0); |
412 | } | 410 | } |
413 | 411 | ||
412 | void LLViewerImage::resetFaceAtlas() | ||
413 | { | ||
414 | //Nothing should be done here. | ||
415 | } | ||
416 | |||
417 | //invalidate all atlas slots for this image. | ||
418 | void LLViewerImage::invalidateAtlas(BOOL rebuild_geom) | ||
419 | { | ||
420 | for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) | ||
421 | { | ||
422 | if(*iter) | ||
423 | { | ||
424 | LLFace* facep = (LLFace*)*iter ; | ||
425 | facep->removeAtlas() ; | ||
426 | if(rebuild_geom && facep->getDrawable() && facep->getDrawable()->getSpatialGroup()) | ||
427 | { | ||
428 | facep->getDrawable()->getSpatialGroup()->setState(LLSpatialGroup::GEOM_DIRTY); | ||
429 | } | ||
430 | } | ||
431 | } | ||
432 | } | ||
433 | |||
434 | BOOL LLViewerImage::insertToAtlas() | ||
435 | { | ||
436 | if(mFaceList.size() < 1) | ||
437 | { | ||
438 | return FALSE ; | ||
439 | } | ||
440 | if(!canAddToAtlas()) | ||
441 | { | ||
442 | return FALSE ; | ||
443 | } | ||
444 | if(getDiscardLevelInAtlas() > 0 && mRawDiscardLevel >= getDiscardLevelInAtlas()) | ||
445 | { | ||
446 | return FALSE ; | ||
447 | } | ||
448 | if(!LLTextureAtlasManager::getInstance()->canAddToAtlas(mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents(), getTexTarget())) | ||
449 | { | ||
450 | return FALSE ; | ||
451 | } | ||
452 | |||
453 | BOOL ret = TRUE ;//if ret is set to false, will generate a gl texture for this image. | ||
454 | S32 raw_w = mRawImage->getWidth() ; | ||
455 | S32 raw_h = mRawImage->getHeight() ; | ||
456 | F32 xscale = 1.0f, yscale = 1.0f ; | ||
457 | LLPointer<LLTextureAtlasSlot> slot_infop; | ||
458 | LLTextureAtlasSlot* cur_slotp ;//no need to be smart pointer. | ||
459 | LLSpatialGroup* groupp ; | ||
460 | LLFace* facep; | ||
461 | |||
462 | //if the atlas slot pointers for some faces are null, process them later. | ||
463 | ll_face_list_t waiting_list ; | ||
464 | |||
465 | for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) | ||
466 | { | ||
467 | if(*iter) | ||
468 | { | ||
469 | facep = (LLFace*)*iter ; | ||
470 | |||
471 | //face can not use atlas. | ||
472 | if(!facep->canUseAtlas()) | ||
473 | { | ||
474 | if(facep->getAtlasInfo()) | ||
475 | { | ||
476 | facep->removeAtlas() ; | ||
477 | } | ||
478 | ret = FALSE ; | ||
479 | continue ; | ||
480 | } | ||
481 | |||
482 | //the atlas slot is updated | ||
483 | slot_infop = facep->getAtlasInfo() ; | ||
484 | groupp = facep->getDrawable()->getSpatialGroup() ; | ||
485 | |||
486 | if(slot_infop) | ||
487 | { | ||
488 | if(slot_infop->getSpatialGroup() != groupp) | ||
489 | { | ||
490 | if((cur_slotp = groupp->getCurUpdatingSlot(this))) //switch slot | ||
491 | { | ||
492 | facep->setAtlasInfo(cur_slotp) ; | ||
493 | facep->setAtlasInUse(TRUE) ; | ||
494 | continue ; | ||
495 | } | ||
496 | else //do not forget to update slot_infop->getSpatialGroup(). | ||
497 | { | ||
498 | LLSpatialGroup* gp = slot_infop->getSpatialGroup() ; | ||
499 | gp->setCurUpdatingTime(gFrameCount) ; | ||
500 | gp->setCurUpdatingTexture(this) ; | ||
501 | gp->setCurUpdatingSlot(slot_infop) ; | ||
502 | } | ||
503 | } | ||
504 | else //same group | ||
505 | { | ||
506 | if(gFrameCount && slot_infop->getUpdatedTime() == gFrameCount)//slot is just updated | ||
507 | { | ||
508 | facep->setAtlasInUse(TRUE) ; | ||
509 | continue ; | ||
510 | } | ||
511 | } | ||
512 | } | ||
513 | else | ||
514 | { | ||
515 | //if the slot is null, wait to process them later. | ||
516 | waiting_list.push_back(facep) ; | ||
517 | continue ; | ||
518 | } | ||
519 | |||
520 | //---------- | ||
521 | //insert to atlas | ||
522 | if(!LLImageGL::createGLTextureInAtlas(mRawDiscardLevel, mRawImage, slot_infop->getAtlas(), slot_infop->getSlotCol(), slot_infop->getSlotRow())) | ||
523 | { | ||
524 | //the texture does not qualify to add to atlas, do not bother to try for other faces. | ||
525 | //invalidateAtlas(); | ||
526 | return FALSE ; | ||
527 | } | ||
528 | |||
529 | //update texture scale | ||
530 | slot_infop->getAtlas()->getTexCoordScale(raw_w, raw_h, xscale, yscale) ; | ||
531 | slot_infop->setTexCoordScale(xscale, yscale) ; | ||
532 | slot_infop->setValid() ; | ||
533 | slot_infop->setUpdatedTime(gFrameCount) ; | ||
534 | |||
535 | //update spatial group atlas info | ||
536 | groupp->setCurUpdatingTime(gFrameCount) ; | ||
537 | groupp->setCurUpdatingTexture(this) ; | ||
538 | groupp->setCurUpdatingSlot(slot_infop) ; | ||
539 | |||
540 | //make the face to switch to the atlas. | ||
541 | facep->setAtlasInUse(TRUE) ; | ||
542 | } | ||
543 | } | ||
544 | |||
545 | //process the waiting_list | ||
546 | for(ll_face_list_t::iterator iter = waiting_list.begin(); iter != waiting_list.end(); ++iter) | ||
547 | { | ||
548 | facep = (LLFace*)*iter ; | ||
549 | groupp = facep->getDrawable()->getSpatialGroup() ; | ||
550 | |||
551 | //check if this texture already inserted to atlas for this group | ||
552 | if((cur_slotp = groupp->getCurUpdatingSlot(this))) | ||
553 | { | ||
554 | facep->setAtlasInfo(cur_slotp) ; | ||
555 | facep->setAtlasInUse(TRUE) ; | ||
556 | continue ; | ||
557 | } | ||
558 | |||
559 | //need to reserve a slot from atlas | ||
560 | slot_infop = LLTextureAtlasManager::getInstance()->reserveAtlasSlot(llmax(mFullWidth, mFullHeight), getComponents(), groupp, this) ; | ||
561 | |||
562 | facep->setAtlasInfo(slot_infop) ; | ||
563 | |||
564 | groupp->setCurUpdatingTime(gFrameCount) ; | ||
565 | groupp->setCurUpdatingTexture(this) ; | ||
566 | groupp->setCurUpdatingSlot(slot_infop) ; | ||
567 | |||
568 | //slot allocation failed. | ||
569 | if(!slot_infop || !slot_infop->getAtlas()) | ||
570 | { | ||
571 | ret = FALSE ; | ||
572 | facep->setAtlasInUse(FALSE) ; | ||
573 | continue ; | ||
574 | } | ||
575 | |||
576 | //insert to atlas | ||
577 | if(!LLImageGL::createGLTextureInAtlas(mRawDiscardLevel, mRawImage, slot_infop->getAtlas(), slot_infop->getSlotCol(), slot_infop->getSlotRow())) | ||
578 | { | ||
579 | //the texture does not qualify to add to atlas, do not bother to try for other faces. | ||
580 | ret = FALSE ; | ||
581 | //invalidateAtlas(); | ||
582 | break ; | ||
583 | } | ||
584 | |||
585 | //update texture scale | ||
586 | slot_infop->getAtlas()->getTexCoordScale(raw_w, raw_h, xscale, yscale) ; | ||
587 | slot_infop->setTexCoordScale(xscale, yscale) ; | ||
588 | slot_infop->setValid() ; | ||
589 | slot_infop->setUpdatedTime(gFrameCount) ; | ||
590 | |||
591 | //make the face to switch to the atlas. | ||
592 | facep->setAtlasInUse(TRUE) ; | ||
593 | } | ||
594 | |||
595 | return ret ; | ||
596 | } | ||
597 | |||
414 | /////////////////////////////////////////////////////////////////////////////// | 598 | /////////////////////////////////////////////////////////////////////////////// |
415 | // ONLY called from LLViewerImageList | 599 | // ONLY called from LLViewerImageList |
416 | void LLViewerImage::destroyTexture() | 600 | void LLViewerImage::destroyTexture() |
@@ -432,7 +616,7 @@ void LLViewerImage::addToCreateTexture() | |||
432 | if(isForSculptOnly()) | 616 | if(isForSculptOnly()) |
433 | { | 617 | { |
434 | //just update some variables, not to create a real GL texture. | 618 | //just update some variables, not to create a real GL texture. |
435 | createGLTexture(mRawDiscardLevel, mRawImage, 0, FALSE) ; | 619 | createGLTexture(mRawDiscardLevel, mRawImage, 0) ; |
436 | mNeedsCreateTexture = FALSE ; | 620 | mNeedsCreateTexture = FALSE ; |
437 | destroyRawImage(); | 621 | destroyRawImage(); |
438 | } | 622 | } |
@@ -495,7 +679,7 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) | |||
495 | mNeedsCreateTexture = FALSE; | 679 | mNeedsCreateTexture = FALSE; |
496 | if (mRawImage.isNull()) | 680 | if (mRawImage.isNull()) |
497 | { | 681 | { |
498 | llerrs << "LLViewerImage trying to create texture with no Raw Image" << llendl; | 682 | llwarns << "LLViewerImage trying to create texture with no Raw Image" << llendl; |
499 | } | 683 | } |
500 | // llinfos << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ", | 684 | // llinfos << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ", |
501 | // mRawDiscardLevel, | 685 | // mRawDiscardLevel, |
@@ -519,32 +703,25 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) | |||
519 | mOrigHeight = mFullHeight; | 703 | mOrigHeight = mFullHeight; |
520 | } | 704 | } |
521 | 705 | ||
522 | bool size_okay = true; | 706 | if (LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight())) |
523 | |||
524 | U32 raw_width = mRawImage->getWidth() << mRawDiscardLevel; | ||
525 | U32 raw_height = mRawImage->getHeight() << mRawDiscardLevel; | ||
526 | if( raw_width > MAX_IMAGE_SIZE || raw_height > MAX_IMAGE_SIZE ) | ||
527 | { | 707 | { |
528 | llinfos << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << llendl; | 708 | if(!(res = insertToAtlas())) |
529 | size_okay = false; | 709 | { |
710 | res = LLImageGL::createGLTexture(mRawDiscardLevel, mRawImage, usename); | ||
711 | resetFaceAtlas() ; | ||
712 | } | ||
530 | } | 713 | } |
531 | 714 | ||
532 | if (!LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight())) | 715 | else |
533 | { | 716 | { |
534 | // A non power-of-two image was uploaded (through a non standard client) | 717 | // A non power-of-two image was uploaded (through a non standard client) |
535 | llinfos << "Non power of two width or height: (" << mRawImage->getWidth() << "," << mRawImage->getHeight() << ")" << llendl; | ||
536 | size_okay = false; | ||
537 | } | ||
538 | |||
539 | if( !size_okay ) | ||
540 | { | ||
541 | // An inappropriately-sized image was uploaded (through a non standard client) | ||
542 | // We treat these images as missing assets which causes them to | 718 | // We treat these images as missing assets which causes them to |
543 | // be renderd as 'missing image' and to stop requesting data | 719 | // be renderd as 'missing image' and to stop requesting data |
544 | setIsMissingAsset(); | 720 | setIsMissingAsset(); |
545 | destroyRawImage(); | 721 | destroyRawImage(); |
546 | return FALSE; | 722 | return FALSE; |
547 | } | 723 | } |
724 | |||
548 | if (mRawImage->getComponents()>4) | 725 | if (mRawImage->getComponents()>4) |
549 | { | 726 | { |
550 | LL_DEBUGS("Openjpeg")<<"broken raw image" << LL_ENDL; | 727 | LL_DEBUGS("Openjpeg")<<"broken raw image" << LL_ENDL; |
@@ -553,7 +730,6 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) | |||
553 | return FALSE; | 730 | return FALSE; |
554 | } | 731 | } |
555 | 732 | ||
556 | res = LLImageGL::createGLTexture(mRawDiscardLevel, mRawImage, usename); | ||
557 | } | 733 | } |
558 | 734 | ||
559 | // | 735 | // |
@@ -655,6 +831,7 @@ void LLViewerImage::processTextureStats() | |||
655 | S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT); | 831 | S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT); |
656 | S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT); | 832 | S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT); |
657 | mTexelsPerImage = (F32)fullwidth * fullheight; | 833 | mTexelsPerImage = (F32)fullwidth * fullheight; |
834 | |||
658 | F32 discard_level = 0.f; | 835 | F32 discard_level = 0.f; |
659 | 836 | ||
660 | // If we know the output width and height, we can force the discard | 837 | // If we know the output width and height, we can force the discard |
@@ -662,7 +839,8 @@ void LLViewerImage::processTextureStats() | |||
662 | // data than we need to. | 839 | // data than we need to. |
663 | if (mBoostLevel == LLViewerImageBoostLevel::BOOST_UI || | 840 | if (mBoostLevel == LLViewerImageBoostLevel::BOOST_UI || |
664 | mBoostLevel == LLViewerImageBoostLevel::BOOST_PREVIEW || | 841 | mBoostLevel == LLViewerImageBoostLevel::BOOST_PREVIEW || |
665 | mBoostLevel == LLViewerImageBoostLevel::BOOST_AVATAR_SELF) // JAMESDEBUG what about AVATAR_BAKED_SELF? | 842 | mBoostLevel == LLViewerImageBoostLevel::BOOST_AVATAR_SELF || |
843 | mBoostLevel == LLViewerImageBoostLevel::BOOST_AVATAR_BAKED_SELF) | ||
666 | { | 844 | { |
667 | discard_level = 0; // full res | 845 | discard_level = 0; // full res |
668 | } | 846 | } |
@@ -677,12 +855,6 @@ void LLViewerImage::processTextureStats() | |||
677 | } | 855 | } |
678 | else | 856 | else |
679 | { | 857 | { |
680 | if(isLargeImage() && !isJustBound() && mAdditionalDecodePriority < 1.0f) | ||
681 | { | ||
682 | //if is a big image and not being used recently, nor close to the view point, do not load hi-res data. | ||
683 | mMaxVirtualSize = llmin(mMaxVirtualSize, (F32)LLViewerImage::sMinLargeImageSize) ; | ||
684 | } | ||
685 | |||
686 | if ((mCalculatedDiscardLevel >= 0.f) && | 858 | if ((mCalculatedDiscardLevel >= 0.f) && |
687 | (llabs(mMaxVirtualSize - mDiscardVirtualSize) < mMaxVirtualSize*.20f)) | 859 | (llabs(mMaxVirtualSize - mDiscardVirtualSize) < mMaxVirtualSize*.20f)) |
688 | { | 860 | { |
@@ -705,6 +877,7 @@ void LLViewerImage::processTextureStats() | |||
705 | discard_level += sCameraMovingDiscardBias ; | 877 | discard_level += sCameraMovingDiscardBias ; |
706 | } | 878 | } |
707 | discard_level = floorf(discard_level); | 879 | discard_level = floorf(discard_level); |
880 | // discard_level -= (gImageList.mVideoMemorySetting>>1); // more video ram = higher detail | ||
708 | 881 | ||
709 | F32 min_discard = 0.f; | 882 | F32 min_discard = 0.f; |
710 | if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) | 883 | if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) |
@@ -726,15 +899,12 @@ void LLViewerImage::processTextureStats() | |||
726 | if ((sDesiredDiscardBias > 0.0f) && | 899 | if ((sDesiredDiscardBias > 0.0f) && |
727 | (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) | 900 | (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) |
728 | { | 901 | { |
729 | // Limit the amount of GL memory bound each frame | 902 | if ( (sBoundTextureMemoryInBytes >> 20) > sMaxBoundTextureMemInMegaBytes*texmem_middle_bound_scale) |
730 | if ( (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) && | ||
731 | (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) | ||
732 | { | 903 | { |
733 | scaleDown() ; | 904 | scaleDown() ; |
734 | } | 905 | } |
735 | // Only allow GL to have 2x the video card memory | 906 | // Only allow GL to have 2x the video card memory |
736 | else if ( (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale) && | 907 | else if (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel) |
737 | (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) | ||
738 | { | 908 | { |
739 | scaleDown() ; | 909 | scaleDown() ; |
740 | } | 910 | } |
@@ -756,7 +926,7 @@ void LLViewerImage::updateVirtualSize() | |||
756 | if(facep->getDrawable()->isRecentlyVisible()) | 926 | if(facep->getDrawable()->isRecentlyVisible()) |
757 | { | 927 | { |
758 | addTextureStats(facep->getVirtualSize()) ; | 928 | addTextureStats(facep->getVirtualSize()) ; |
759 | setAdditionalDecodePriority(facep->getImportanceToCamera()) ; | 929 | //setAdditionalDecodePriority(facep->getImportanceToCamera()) ; |
760 | } | 930 | } |
761 | } | 931 | } |
762 | } | 932 | } |
@@ -796,6 +966,7 @@ void LLViewerImage::switchToCachedImage() | |||
796 | mNeedsCreateTexture = TRUE; | 966 | mNeedsCreateTexture = TRUE; |
797 | } | 967 | } |
798 | } | 968 | } |
969 | |||
799 | //============================================================================ | 970 | //============================================================================ |
800 | 971 | ||
801 | F32 LLViewerImage::calcDecodePriority() | 972 | F32 LLViewerImage::calcDecodePriority() |
@@ -817,13 +988,6 @@ F32 LLViewerImage::calcDecodePriority() | |||
817 | } | 988 | } |
818 | 989 | ||
819 | S32 cur_discard = getDiscardLevel(); | 990 | S32 cur_discard = getDiscardLevel(); |
820 | |||
821 | //no need to update if the texture reaches its highest res and the memory is sufficient. | ||
822 | //if(LLViewerImage::sFreezeImageScalingDown && !cur_discard) | ||
823 | //{ | ||
824 | // return -5.0f ; | ||
825 | //} | ||
826 | |||
827 | bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel)); | 991 | bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel)); |
828 | F32 pixel_priority = fsqrtf(mMaxVirtualSize); | 992 | F32 pixel_priority = fsqrtf(mMaxVirtualSize); |
829 | const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame | 993 | const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame |
@@ -842,14 +1006,6 @@ F32 LLViewerImage::calcDecodePriority() | |||
842 | { | 1006 | { |
843 | priority = -1.0f ; | 1007 | priority = -1.0f ; |
844 | } | 1008 | } |
845 | else if (!isJustBound() && mCachedRawImageReady) | ||
846 | { | ||
847 | priority = -1.0f; | ||
848 | } | ||
849 | else if(mCachedRawDiscardLevel > -1 && mDesiredDiscardLevel >= mCachedRawDiscardLevel) | ||
850 | { | ||
851 | priority = -1.0f; | ||
852 | } | ||
853 | else if (mDesiredDiscardLevel > mMaxDiscardLevel) | 1009 | else if (mDesiredDiscardLevel > mMaxDiscardLevel) |
854 | { | 1010 | { |
855 | // Don't decode anything we don't need | 1011 | // Don't decode anything we don't need |
@@ -910,7 +1066,6 @@ F32 LLViewerImage::calcDecodePriority() | |||
910 | ddiscard-=2; | 1066 | ddiscard-=2; |
911 | } | 1067 | } |
912 | ddiscard = llclamp(ddiscard, 0, 4); | 1068 | ddiscard = llclamp(ddiscard, 0, 4); |
913 | |||
914 | priority = ddiscard*100000.f; | 1069 | priority = ddiscard*100000.f; |
915 | } | 1070 | } |
916 | if (priority > 0.0f) | 1071 | if (priority > 0.0f) |
@@ -942,7 +1097,7 @@ F32 LLViewerImage::calcDecodePriority() | |||
942 | //static | 1097 | //static |
943 | F32 LLViewerImage::maxDecodePriority() | 1098 | F32 LLViewerImage::maxDecodePriority() |
944 | { | 1099 | { |
945 | return 6000000.f; | 1100 | return 6000000.f; // KL 2000000 in render pipeline |
946 | } | 1101 | } |
947 | 1102 | ||
948 | void LLViewerImage::setDecodePriority(F32 priority) | 1103 | void LLViewerImage::setDecodePriority(F32 priority) |
@@ -969,10 +1124,7 @@ void LLViewerImage::setBoostLevel(S32 level) | |||
969 | { | 1124 | { |
970 | mBoostLevel = level; | 1125 | mBoostLevel = level; |
971 | 1126 | ||
972 | if(gAuditTexture) | 1127 | |
973 | { | ||
974 | setCategory(mBoostLevel); | ||
975 | } | ||
976 | 1128 | ||
977 | if(mBoostLevel != LLViewerImageBoostLevel::BOOST_NONE) | 1129 | if(mBoostLevel != LLViewerImageBoostLevel::BOOST_NONE) |
978 | { | 1130 | { |
@@ -1022,11 +1174,15 @@ bool LLViewerImage::updateFetch() | |||
1022 | return false; // process any raw image data in callbacks before replacing | 1174 | return false; // process any raw image data in callbacks before replacing |
1023 | } | 1175 | } |
1024 | 1176 | ||
1177 | mFetchState = 0; | ||
1178 | mFetchPriority = 0; | ||
1179 | mFetchDeltaTime = 999999.f; | ||
1180 | mRequestDeltaTime = 999999.f; | ||
1025 | S32 current_discard = getDiscardLevel(); | 1181 | S32 current_discard = getDiscardLevel(); |
1026 | S32 desired_discard = getDesiredDiscardLevel(); | 1182 | S32 desired_discard = getDesiredDiscardLevel(); |
1027 | F32 decode_priority = getDecodePriority(); | 1183 | F32 decode_priority = getDecodePriority(); |
1028 | decode_priority = llmax(decode_priority, 0.0f); | 1184 | decode_priority = llmax(decode_priority, 0.0f); |
1029 | decode_priority = llmin(decode_priority, maxDecodePriority()); | 1185 | //decode_priority = llmin(decode_priority, maxDecodePriority()); |
1030 | 1186 | ||
1031 | if (mIsFetching) | 1187 | if (mIsFetching) |
1032 | { | 1188 | { |
@@ -1059,7 +1215,6 @@ bool LLViewerImage::updateFetch() | |||
1059 | if (mRawImage.notNull()) | 1215 | if (mRawImage.notNull()) |
1060 | { | 1216 | { |
1061 | mRawDiscardLevel = fetch_discard; | 1217 | mRawDiscardLevel = fetch_discard; |
1062 | |||
1063 | if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && | 1218 | if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && |
1064 | (current_discard < 0 || mRawDiscardLevel < current_discard)) | 1219 | (current_discard < 0 || mRawDiscardLevel < current_discard)) |
1065 | { | 1220 | { |
@@ -1178,10 +1333,6 @@ bool LLViewerImage::updateFetch() | |||
1178 | { | 1333 | { |
1179 | make_request = false; | 1334 | make_request = false; |
1180 | } | 1335 | } |
1181 | else if (!isJustBound() && mCachedRawImageReady) | ||
1182 | { | ||
1183 | make_request = false; | ||
1184 | } | ||
1185 | else | 1336 | else |
1186 | { | 1337 | { |
1187 | if (mIsFetching) | 1338 | if (mIsFetching) |
@@ -1216,14 +1367,13 @@ bool LLViewerImage::updateFetch() | |||
1216 | w, h, c, desired_discard, needsAux()); | 1367 | w, h, c, desired_discard, needsAux()); |
1217 | 1368 | ||
1218 | if (fetch_request_created) | 1369 | if (fetch_request_created) |
1219 | { | 1370 | { |
1220 | mHasFetcher = TRUE; | 1371 | mHasFetcher = TRUE; |
1221 | mIsFetching = TRUE; | 1372 | mIsFetching = TRUE; |
1222 | mRequestedDiscardLevel = desired_discard; | 1373 | mRequestedDiscardLevel = desired_discard; |
1223 | |||
1224 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, | 1374 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, |
1225 | mFetchPriority, mFetchDeltaTime, mRequestDeltaTime); | 1375 | mFetchPriority, mFetchDeltaTime, mRequestDeltaTime); |
1226 | } | 1376 | } |
1227 | 1377 | ||
1228 | // if createRequest() failed, we're finishing up a request for this UUID, | 1378 | // if createRequest() failed, we're finishing up a request for this UUID, |
1229 | // wait for it to complete | 1379 | // wait for it to complete |
@@ -1295,12 +1445,12 @@ BOOL LLViewerImage::forceFetch() | |||
1295 | w, h, c, desired_discard, needsAux()); | 1445 | w, h, c, desired_discard, needsAux()); |
1296 | 1446 | ||
1297 | if (fetch_request_created) | 1447 | if (fetch_request_created) |
1298 | { | 1448 | { |
1299 | mHasFetcher = TRUE; | 1449 | mHasFetcher = TRUE; |
1300 | mIsFetching = TRUE; | 1450 | mIsFetching = TRUE; |
1301 | // Set the image's decode priority to maxDecodePriority() too, or updateFetch() will set | 1451 | // Set the image's decode priority to maxDecodePriority() too, or updateFetch() will set |
1302 | // the request priority to 0 and terminate the fetch before we even started (SNOW-203). | 1452 | // the request priority to 0 and terminate the fetch before we even started (SNOW-203). |
1303 | gImageList.bumpToMaxDecodePriority(this); | 1453 | // gImageList.bumpToMaxDecodePriority(this); // Kl force immediate update?? |
1304 | mRequestedDiscardLevel = desired_discard ; | 1454 | mRequestedDiscardLevel = desired_discard ; |
1305 | 1455 | ||
1306 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, | 1456 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, |
@@ -1473,8 +1623,8 @@ bool LLViewerImage::doLoadedCallbacks() | |||
1473 | 1623 | ||
1474 | destroyRawImage(); | 1624 | destroyRawImage(); |
1475 | readBackRawImage(gl_discard); | 1625 | readBackRawImage(gl_discard); |
1476 | llassert_always(mRawImage.notNull()); | 1626 | //llassert_always(mRawImage.notNull()); |
1477 | llassert_always(!mNeedsAux || mAuxRawImage.notNull()); | 1627 | //llassert_always(!mNeedsAux || mAuxRawImage.notNull()); |
1478 | } | 1628 | } |
1479 | 1629 | ||
1480 | // | 1630 | // |
@@ -1636,7 +1786,18 @@ bool LLViewerImage::bindDefaultImage(S32 stage) | |||
1636 | //virtual | 1786 | //virtual |
1637 | void LLViewerImage::forceImmediateUpdate() | 1787 | void LLViewerImage::forceImmediateUpdate() |
1638 | { | 1788 | { |
1639 | gImageList.bumpToMaxDecodePriority(this) ; | 1789 | //only immediately update a deleted texture which is now being re-used. |
1790 | if(!isDeleted()) | ||
1791 | { | ||
1792 | return ; | ||
1793 | } | ||
1794 | //if already called forceImmediateUpdate() | ||
1795 | if(mInImageList && mDecodePriority == LLViewerImage::maxDecodePriority()) | ||
1796 | { | ||
1797 | return ; | ||
1798 | } | ||
1799 | |||
1800 | gImageList.forceImmediateUpdate(this) ; | ||
1640 | return ; | 1801 | return ; |
1641 | } | 1802 | } |
1642 | 1803 | ||
@@ -1647,7 +1808,7 @@ LLImageRaw* LLViewerImage::readBackRawImage(S8 discard_level) | |||
1647 | llassert_always(mComponents > 0); | 1808 | llassert_always(mComponents > 0); |
1648 | if (mRawImage.notNull()) | 1809 | if (mRawImage.notNull()) |
1649 | { | 1810 | { |
1650 | llerrs << "called with existing mRawImage" << llendl; | 1811 | llwarns << "called with existing mRawImage" << llendl; |
1651 | mRawImage = NULL; | 1812 | mRawImage = NULL; |
1652 | } | 1813 | } |
1653 | 1814 | ||
@@ -1665,7 +1826,7 @@ LLImageRaw* LLViewerImage::readBackRawImage(S8 discard_level) | |||
1665 | 1826 | ||
1666 | sRawCount++; | 1827 | sRawCount++; |
1667 | mIsRawImageValid = TRUE; | 1828 | mIsRawImageValid = TRUE; |
1668 | 1829 | ||
1669 | return mRawImage; | 1830 | return mRawImage; |
1670 | } | 1831 | } |
1671 | 1832 | ||
diff --git a/linden/indra/newview/llviewerimage.h b/linden/indra/newview/llviewerimage.h index c82b68b..7d646be 100644 --- a/linden/indra/newview/llviewerimage.h +++ b/linden/indra/newview/llviewerimage.h | |||
@@ -41,11 +41,13 @@ | |||
41 | #include <map> | 41 | #include <map> |
42 | #include <list> | 42 | #include <list> |
43 | 43 | ||
44 | class LLFace; | 44 | |
45 | #define MIN_VIDEO_RAM_IN_MEGA_BYTES 32 | 45 | #define MIN_VIDEO_RAM_IN_MEGA_BYTES 32 |
46 | #define MAX_VIDEO_RAM_IN_MEGA_BYTES 512 // 512MB max for performance reasons. | 46 | #define MAX_VIDEO_RAM_IN_MEGA_BYTES 512 // 512MB max for performance reasons. |
47 | 47 | ||
48 | class LLViewerImage; | 48 | class LLViewerImage; |
49 | class LLTextureAtlas ; | ||
50 | class LLFace ; | ||
49 | 51 | ||
50 | typedef void (*loaded_callback_func)( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata ); | 52 | typedef void (*loaded_callback_func)( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata ); |
51 | 53 | ||
@@ -261,8 +263,29 @@ public: | |||
261 | void setMinDiscardLevel(S32 discard) { mMinDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel,(S8)discard); } | 263 | void setMinDiscardLevel(S32 discard) { mMinDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel,(S8)discard); } |
262 | 264 | ||
263 | // Host we think might have this image, used for baked av textures. | 265 | // Host we think might have this image, used for baked av textures. |
266 | void setTargetHost(LLHost host) { mTargetHost = host; } | ||
264 | LLHost getTargetHost() const { return mTargetHost; } | 267 | LLHost getTargetHost() const { return mTargetHost; } |
265 | 268 | ||
269 | enum | ||
270 | { | ||
271 | BOOST_NONE = 0, | ||
272 | BOOST_AVATAR_BAKED = 1, | ||
273 | BOOST_AVATAR = 2, | ||
274 | BOOST_CLOUDS = 3, | ||
275 | BOOST_SCULPTED = 4, | ||
276 | |||
277 | BOOST_HIGH = 10, | ||
278 | BOOST_TERRAIN = 11, // has to be high priority for minimap / low detail | ||
279 | BOOST_SELECTED = 12, | ||
280 | BOOST_HUD = 13, | ||
281 | BOOST_AVATAR_BAKED_SELF = 14, | ||
282 | BOOST_UI = 15, | ||
283 | BOOST_PREVIEW = 16, | ||
284 | BOOST_MAP = 17, | ||
285 | BOOST_MAP_LAYER = 18, | ||
286 | BOOST_AVATAR_SELF = 19, // needed for baking avatar | ||
287 | BOOST_MAX_LEVEL | ||
288 | }; | ||
266 | void setBoostLevel(S32 level); | 289 | void setBoostLevel(S32 level); |
267 | S32 getBoostLevel() { return mBoostLevel; } | 290 | S32 getBoostLevel() { return mBoostLevel; } |
268 | 291 | ||
@@ -295,6 +318,10 @@ public: | |||
295 | S32 getOriginalWidth() { return mOrigWidth; } | 318 | S32 getOriginalWidth() { return mOrigWidth; } |
296 | S32 getOriginalHeight() { return mOrigHeight; } | 319 | S32 getOriginalHeight() { return mOrigHeight; } |
297 | 320 | ||
321 | BOOL insertToAtlas() ; | ||
322 | void resetFaceAtlas() ; | ||
323 | void invalidateAtlas(BOOL rebuild_geom = FALSE); | ||
324 | |||
298 | BOOL isForSculptOnly() const ; | 325 | BOOL isForSculptOnly() const ; |
299 | void setForSculpt(); | 326 | void setForSculpt(); |
300 | 327 | ||
@@ -313,6 +340,7 @@ public: | |||
313 | 340 | ||
314 | void addFace(LLFace* facep) ; | 341 | void addFace(LLFace* facep) ; |
315 | void removeFace(LLFace* facep) ; | 342 | void removeFace(LLFace* facep) ; |
343 | BOOL isReferenced()const {return mFaceList.size() > 0 ; } | ||
316 | 344 | ||
317 | friend class LocalBitmap; // tag: vaa emerald local_asset_browser | 345 | friend class LocalBitmap; // tag: vaa emerald local_asset_browser |
318 | 346 | ||
@@ -418,6 +446,7 @@ private: | |||
418 | typedef std::list<LLFace*> ll_face_list_t ; | 446 | typedef std::list<LLFace*> ll_face_list_t ; |
419 | ll_face_list_t mFaceList ; //reverse pointer pointing to the faces using this image as texture | 447 | ll_face_list_t mFaceList ; //reverse pointer pointing to the faces using this image as texture |
420 | 448 | ||
449 | BOOL mInCreationList ; | ||
421 | public: | 450 | public: |
422 | static const U32 sCurrentFileVersion; | 451 | static const U32 sCurrentFileVersion; |
423 | // Default textures | 452 | // Default textures |
diff --git a/linden/indra/newview/llviewerimagelist.cpp b/linden/indra/newview/llviewerimagelist.cpp index 29c630b..f795de6 100644 --- a/linden/indra/newview/llviewerimagelist.cpp +++ b/linden/indra/newview/llviewerimagelist.cpp | |||
@@ -199,7 +199,6 @@ static std::string get_texture_list_name() | |||
199 | 199 | ||
200 | void LLViewerImageList::doPrefetchImages() | 200 | void LLViewerImageList::doPrefetchImages() |
201 | { | 201 | { |
202 | #if 1 | ||
203 | if (LLAppViewer::instance()->getPurgeCache()) | 202 | if (LLAppViewer::instance()->getPurgeCache()) |
204 | { | 203 | { |
205 | // cache was purged, no point | 204 | // cache was purged, no point |
@@ -227,7 +226,7 @@ void LLViewerImageList::doPrefetchImages() | |||
227 | image->addTextureStats((F32)pixel_area); | 226 | image->addTextureStats((F32)pixel_area); |
228 | } | 227 | } |
229 | } | 228 | } |
230 | #endif | 229 | |
231 | 230 | ||
232 | } | 231 | } |
233 | 232 | ||
@@ -486,7 +485,7 @@ void LLViewerImageList::removeImageFromList(LLViewerImage *image) | |||
486 | { | 485 | { |
487 | llinfos << "Image is not in mUUIDMap!" << llendl ; | 486 | llinfos << "Image is not in mUUIDMap!" << llendl ; |
488 | } | 487 | } |
489 | llerrs << "LLViewerImageList::removeImageFromList - Image not in list" << llendl; | 488 | llwarns << "LLViewerImageList::removeImageFromList - Image not in list" << llendl; |
490 | } | 489 | } |
491 | llverify(mImageList.erase(image) == 1); | 490 | llverify(mImageList.erase(image) == 1); |
492 | image->mInImageList = FALSE; | 491 | image->mInImageList = FALSE; |
@@ -535,7 +534,8 @@ void LLViewerImageList::deleteImage(LLViewerImage *image) | |||
535 | 534 | ||
536 | void LLViewerImageList::dirtyImage(LLViewerImage *image) | 535 | void LLViewerImageList::dirtyImage(LLViewerImage *image) |
537 | { | 536 | { |
538 | mDirtyTextureList.insert(image); | 537 | //mDirtyTextureList.insert(image); |
538 | image->invalidateAtlas(TRUE) ; // KL | ||
539 | } | 539 | } |
540 | 540 | ||
541 | //////////////////////////////////////////////////////////////////////////// | 541 | //////////////////////////////////////////////////////////////////////////// |
@@ -547,25 +547,21 @@ void LLViewerImageList::updateImages(F32 max_time) | |||
547 | 547 | ||
548 | sNumImagesStat.addValue(sNumImages); | 548 | sNumImagesStat.addValue(sNumImages); |
549 | sNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); | 549 | sNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); |
550 | sGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes)); | 550 | sGLTexMemStat.addValue((F32)(LLImageGL::sGlobalTextureMemoryInBytes >> 20)); |
551 | sGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes)); | 551 | sGLBoundMemStat.addValue((F32)(LLImageGL::sBoundTextureMemoryInBytes >> 20)); |
552 | sRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageRaw::sGlobalRawMemory)); | 552 | sRawMemStat.addValue((F32)(LLImageRaw::sGlobalRawMemory >> 20)); |
553 | sFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory)); | 553 | sFormattedMemStat.addValue((F32)(LLImageFormatted::sGlobalFormattedMemory >> 20)); |
554 | 554 | ||
555 | llpushcallstacks ; | 555 | llpushcallstacks ; |
556 | |||
557 | updateImagesDecodePriorities(); | 556 | updateImagesDecodePriorities(); |
558 | |||
559 | llpushcallstacks ; | 557 | llpushcallstacks ; |
560 | F32 total_max_time = max_time; | ||
561 | max_time -= updateImagesFetchTextures(max_time); | 558 | max_time -= updateImagesFetchTextures(max_time); |
562 | |||
563 | llpushcallstacks ; | 559 | llpushcallstacks ; |
564 | max_time = llmax(max_time, total_max_time*.25f); // at least 25% of max_time | 560 | max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f); |
565 | max_time -= updateImagesCreateTextures(max_time); | 561 | max_time -= updateImagesCreateTextures(max_time); |
566 | |||
567 | llpushcallstacks ; | 562 | llpushcallstacks ; |
568 | 563 | max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f); | |
564 | llpushcallstacks ; | ||
569 | if (!mDirtyTextureList.empty()) | 565 | if (!mDirtyTextureList.empty()) |
570 | { | 566 | { |
571 | LLFastTimer t(LLFastTimer::FTM_IMAGE_MARK_DIRTY); | 567 | LLFastTimer t(LLFastTimer::FTM_IMAGE_MARK_DIRTY); |
@@ -739,7 +735,7 @@ F32 LLViewerImageList::updateImagesCreateTextures(F32 max_time) | |||
739 | return create_timer.getElapsedTimeF32(); | 735 | return create_timer.getElapsedTimeF32(); |
740 | } | 736 | } |
741 | 737 | ||
742 | void LLViewerImageList::bumpToMaxDecodePriority(LLViewerImage* imagep) | 738 | void LLViewerImageList::forceImmediateUpdate(LLViewerImage* imagep) |
743 | { | 739 | { |
744 | if(!imagep) | 740 | if(!imagep) |
745 | { | 741 | { |
@@ -747,11 +743,6 @@ void LLViewerImageList::bumpToMaxDecodePriority(LLViewerImage* imagep) | |||
747 | } | 743 | } |
748 | if(imagep->mInImageList) | 744 | if(imagep->mInImageList) |
749 | { | 745 | { |
750 | if (imagep->getDecodePriority() == LLViewerImage::maxDecodePriority()) | ||
751 | { | ||
752 | // Already at maximum. | ||
753 | return; | ||
754 | } | ||
755 | removeImageFromList(imagep); | 746 | removeImageFromList(imagep); |
756 | } | 747 | } |
757 | 748 | ||
@@ -1028,13 +1019,16 @@ LLPointer<LLImageJ2C> LLViewerImageList::convertToUploadFile(LLPointer<LLImageRa | |||
1028 | 1019 | ||
1029 | return compressedImage; | 1020 | return compressedImage; |
1030 | } | 1021 | } |
1022 | |||
1023 | const S32 MIN_VIDEO_RAM = 32; | ||
1024 | const S32 MAX_VIDEO_RAM = 512; // 512MB max for performance reasons. | ||
1031 | 1025 | ||
1032 | // Returns min setting for TextureMemory (in MB) | 1026 | // Returns min setting for TextureMemory (in MB) |
1033 | S32 LLViewerImageList::getMinVideoRamSetting() | 1027 | S32 LLViewerImageList::getMinVideoRamSetting() |
1034 | { | 1028 | { |
1035 | S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); | 1029 | S32 system_ram = (S32)(gSysMemory.getPhysicalMemoryClamped() >> 20); |
1036 | //min texture mem sets to 64M if total physical mem is more than 1.5GB | 1030 | //min texture mem sets to 64M if total physical mem is more than 1.5GB |
1037 | return (system_ram > 1500) ? 64 : MIN_VIDEO_RAM_IN_MEGA_BYTES ; | 1031 | return (system_ram > 1500) ? 64 : MIN_VIDEO_RAM; |
1038 | } | 1032 | } |
1039 | 1033 | ||
1040 | //static | 1034 | //static |
@@ -1061,14 +1055,14 @@ S32 LLViewerImageList::getMaxVideoRamSetting(bool get_recommended) | |||
1061 | llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << llendl; | 1055 | llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << llendl; |
1062 | } | 1056 | } |
1063 | 1057 | ||
1064 | S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB | 1058 | S32 system_ram = (S32)(gSysMemory.getPhysicalMemoryClamped() >> 20); // In MB |
1065 | //llinfos << "*** DETECTED " << system_ram << " MB of system memory." << llendl; | 1059 | //llinfos << "*** DETECTED " << system_ram << " MB of system memory." << llendl; |
1066 | if (get_recommended) | 1060 | if (get_recommended) |
1067 | max_texmem = llmin(max_texmem, (S32)(system_ram/2)); | 1061 | max_texmem = llmin(max_texmem, (S32)(system_ram/2)); |
1068 | else | 1062 | else |
1069 | max_texmem = llmin(max_texmem, (S32)(system_ram)); | 1063 | max_texmem = llmin(max_texmem, (S32)(system_ram)); |
1070 | 1064 | ||
1071 | max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM_IN_MEGA_BYTES); | 1065 | max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM); |
1072 | 1066 | ||
1073 | return max_texmem; | 1067 | return max_texmem; |
1074 | } | 1068 | } |
@@ -1113,9 +1107,9 @@ void LLViewerImageList::updateMaxResidentTexMem(S32 mem) | |||
1113 | mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes >> 2); | 1107 | mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes >> 2); |
1114 | } | 1108 | } |
1115 | 1109 | ||
1116 | if (mMaxTotalTextureMemInMegaBytes > (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()) - 128) | 1110 | if (mMaxTotalTextureMemInMegaBytes > (S32)(gSysMemory.getPhysicalMemoryClamped() >> 20) - 128) |
1117 | { | 1111 | { |
1118 | mMaxTotalTextureMemInMegaBytes = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()) - 128 ; | 1112 | mMaxTotalTextureMemInMegaBytes = (gSysMemory.getPhysicalMemoryClamped() >> 20) - 128 ; |
1119 | } | 1113 | } |
1120 | 1114 | ||
1121 | llinfos << "Total Video Memory set to: " << vb_mem << " MB" << llendl; | 1115 | llinfos << "Total Video Memory set to: " << vb_mem << " MB" << llendl; |
diff --git a/linden/indra/newview/llviewerimagelist.h b/linden/indra/newview/llviewerimagelist.h index 561e8e5..f82d9f3 100644 --- a/linden/indra/newview/llviewerimagelist.h +++ b/linden/indra/newview/llviewerimagelist.h | |||
@@ -112,7 +112,7 @@ public: | |||
112 | LLGLenum primary_format = 0, | 112 | LLGLenum primary_format = 0, |
113 | const LLUUID& force_id = LLUUID::null | 113 | const LLUUID& force_id = LLUUID::null |
114 | ); | 114 | ); |
115 | 115 | ||
116 | // Request image from a specific host, used for baked avatar textures. | 116 | // Request image from a specific host, used for baked avatar textures. |
117 | // Implemented in header in case someone changes default params above. JC | 117 | // Implemented in header in case someone changes default params above. JC |
118 | LLViewerImage* getImageFromHost(const LLUUID& image_id, LLHost host) | 118 | LLViewerImage* getImageFromHost(const LLUUID& image_id, LLHost host) |
@@ -129,7 +129,7 @@ public: | |||
129 | 129 | ||
130 | // Using image stats, determine what images are necessary, and perform image updates. | 130 | // Using image stats, determine what images are necessary, and perform image updates. |
131 | void updateImages(F32 max_time); | 131 | void updateImages(F32 max_time); |
132 | void bumpToMaxDecodePriority(LLViewerImage* imagep) ; | 132 | void forceImmediateUpdate(LLViewerImage* imagep) ; |
133 | 133 | ||
134 | // Decode and create textures for all images currently in list. | 134 | // Decode and create textures for all images currently in list. |
135 | void decodeAllImages(F32 max_decode_time); | 135 | void decodeAllImages(F32 max_decode_time); |
diff --git a/linden/indra/newview/llviewerjointmesh.cpp b/linden/indra/newview/llviewerjointmesh.cpp index b6f0daf..dc08bcd 100644 --- a/linden/indra/newview/llviewerjointmesh.cpp +++ b/linden/indra/newview/llviewerjointmesh.cpp | |||
@@ -523,9 +523,9 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) | |||
523 | //---------------------------------------------------------------- | 523 | //---------------------------------------------------------------- |
524 | if (!gRenderForSelect) | 524 | if (!gRenderForSelect) |
525 | { | 525 | { |
526 | if (is_dummy) | 526 | /* if (is_dummy) |
527 | glColor4fv(LLVOAvatar::getDummyColor().mV); | 527 | glColor4fv(LLVOAvatar::getDummyColor().mV); |
528 | else | 528 | else */ |
529 | glColor4fv(mColor.mV); | 529 | glColor4fv(mColor.mV); |
530 | } | 530 | } |
531 | 531 | ||
@@ -557,7 +557,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) | |||
557 | { | 557 | { |
558 | if( mLayerSet->hasComposite() ) | 558 | if( mLayerSet->hasComposite() ) |
559 | { | 559 | { |
560 | gGL.getTexUnit(0)->bind(mLayerSet->getComposite()->getTexture()); | 560 | gGL.getTexUnit(0)->bind(mLayerSet->getComposite()->getTexture(), TRUE); // KL SD |
561 | } | 561 | } |
562 | else | 562 | else |
563 | { | 563 | { |
@@ -565,7 +565,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) | |||
565 | // Ignore the warning if that's the case. | 565 | // Ignore the warning if that's the case. |
566 | if (!gSavedSettings.getBOOL("RenderUnloadedAvatar")) | 566 | if (!gSavedSettings.getBOOL("RenderUnloadedAvatar")) |
567 | { | 567 | { |
568 | llwarns << "Layerset without composite" << llendl; | 568 | //llwarns << "Layerset without composite" << llendl; |
569 | } | 569 | } |
570 | gGL.getTexUnit(0)->bind(gImageList.getImage(IMG_DEFAULT)); | 570 | gGL.getTexUnit(0)->bind(gImageList.getImage(IMG_DEFAULT)); |
571 | } | 571 | } |
@@ -574,7 +574,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) | |||
574 | if ( !is_dummy && mTexture.notNull() ) | 574 | if ( !is_dummy && mTexture.notNull() ) |
575 | { | 575 | { |
576 | old_mode = mTexture->getAddressMode(); | 576 | old_mode = mTexture->getAddressMode(); |
577 | gGL.getTexUnit(0)->bind(mTexture.get()); | 577 | gGL.getTexUnit(0)->bind(mTexture.get(), TRUE); // KL SD |
578 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); | 578 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); |
579 | } | 579 | } |
580 | else | 580 | else |
diff --git a/linden/indra/newview/llviewermedia.cpp b/linden/indra/newview/llviewermedia.cpp index 8c5cf6a..8857170 100644 --- a/linden/indra/newview/llviewermedia.cpp +++ b/linden/indra/newview/llviewermedia.cpp | |||
@@ -938,9 +938,7 @@ void LLViewerMediaImpl::update() | |||
938 | x_pos, | 938 | x_pos, |
939 | y_pos, | 939 | y_pos, |
940 | width, | 940 | width, |
941 | height, | 941 | height); |
942 | TRUE); // force a fast update (i.e. don't call analyzeAlpha, etc.) | ||
943 | |||
944 | } | 942 | } |
945 | 943 | ||
946 | mMediaSource->resetDirty(); | 944 | mMediaSource->resetDirty(); |
diff --git a/linden/indra/newview/llviewermenu.cpp b/linden/indra/newview/llviewermenu.cpp index 7266dbc..314fc94 100644 --- a/linden/indra/newview/llviewermenu.cpp +++ b/linden/indra/newview/llviewermenu.cpp | |||
@@ -1408,14 +1408,14 @@ void init_debug_avatar_menu(LLMenuGL* menu) | |||
1408 | //menu->append(new LLMenuItemToggleGL("Show Attachment Points", &LLVOAvatar::sShowAttachmentPoints)); | 1408 | //menu->append(new LLMenuItemToggleGL("Show Attachment Points", &LLVOAvatar::sShowAttachmentPoints)); |
1409 | //diabling collision plane due to DEV-14477 -brad | 1409 | //diabling collision plane due to DEV-14477 -brad |
1410 | //menu->append(new LLMenuItemToggleGL("Show Collision Plane", &LLVOAvatar::sShowFootPlane)); | 1410 | //menu->append(new LLMenuItemToggleGL("Show Collision Plane", &LLVOAvatar::sShowFootPlane)); |
1411 | menu->append(new LLMenuItemCheckGL("Show Collision Skeleton", | 1411 | /*menu->append(new LLMenuItemCheckGL("Show Collision Skeleton", |
1412 | &LLPipeline::toggleRenderDebug, NULL, | 1412 | &LLPipeline::toggleRenderDebug, NULL, |
1413 | &LLPipeline::toggleRenderDebugControl, | 1413 | &LLPipeline::toggleRenderDebugControl, |
1414 | (void*)LLPipeline::RENDER_DEBUG_AVATAR_VOLUME)); | 1414 | (void*)LLPipeline::RENDER_DEBUG_AVATAR_VOLUME)); |
1415 | menu->append(new LLMenuItemCheckGL("Display Agent Target", | 1415 | menu->append(new LLMenuItemCheckGL("Display Agent Target", |
1416 | &LLPipeline::toggleRenderDebug, NULL, | 1416 | &LLPipeline::toggleRenderDebug, NULL, |
1417 | &LLPipeline::toggleRenderDebugControl, | 1417 | &LLPipeline::toggleRenderDebugControl, |
1418 | (void*)LLPipeline::RENDER_DEBUG_AGENT_TARGET)); | 1418 | (void*)LLPipeline::RENDER_DEBUG_AGENT_TARGET));*/ |
1419 | menu->append(new LLMenuItemToggleGL( "Debug Rotation", &LLVOAvatar::sDebugAvatarRotation)); | 1419 | menu->append(new LLMenuItemToggleGL( "Debug Rotation", &LLVOAvatar::sDebugAvatarRotation)); |
1420 | menu->append(new LLMenuItemCallGL("Dump Attachments", handle_dump_attachments)); | 1420 | menu->append(new LLMenuItemCallGL("Dump Attachments", handle_dump_attachments)); |
1421 | menu->append(new LLMenuItemCallGL("Refresh Appearance", handle_rebake_textures, NULL, NULL, 'R', MASK_ALT | MASK_CONTROL )); | 1421 | menu->append(new LLMenuItemCallGL("Refresh Appearance", handle_rebake_textures, NULL, NULL, 'R', MASK_ALT | MASK_CONTROL )); |
@@ -10436,7 +10436,7 @@ class LLAdvancedCheckShowCollisionPlane : public view_listener_t | |||
10436 | // SHOW COLLISION SKELETON // | 10436 | // SHOW COLLISION SKELETON // |
10437 | ///////////////////////////// | 10437 | ///////////////////////////// |
10438 | 10438 | ||
10439 | 10439 | /* | |
10440 | class LLAdvancedToggleShowCollisionSkeleton : public view_listener_t | 10440 | class LLAdvancedToggleShowCollisionSkeleton : public view_listener_t |
10441 | { | 10441 | { |
10442 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 10442 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
@@ -10457,13 +10457,13 @@ class LLAdvancedCheckShowCollisionSkeleton : public view_listener_t | |||
10457 | } | 10457 | } |
10458 | }; | 10458 | }; |
10459 | 10459 | ||
10460 | 10460 | */ | |
10461 | 10461 | ||
10462 | ////////////////////////// | 10462 | ////////////////////////// |
10463 | // DISPLAY AGENT TARGET // | 10463 | // DISPLAY AGENT TARGET // |
10464 | ////////////////////////// | 10464 | ////////////////////////// |
10465 | 10465 | ||
10466 | 10466 | /* | |
10467 | class LLAdvancedToggleDisplayAgentTarget : public view_listener_t | 10467 | class LLAdvancedToggleDisplayAgentTarget : public view_listener_t |
10468 | { | 10468 | { |
10469 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 10469 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
@@ -10484,7 +10484,7 @@ class LLAdvancedCheckDisplayAgentTarget : public view_listener_t | |||
10484 | } | 10484 | } |
10485 | }; | 10485 | }; |
10486 | 10486 | ||
10487 | 10487 | */ | |
10488 | 10488 | ||
10489 | /////////////////////////// | 10489 | /////////////////////////// |
10490 | // DEBUG AVATAR ROTATION // | 10490 | // DEBUG AVATAR ROTATION // |
@@ -11350,10 +11350,10 @@ void initialize_menus() | |||
11350 | addMenu(new LLAdvancedCheckDebugCharacterVis(), "Advanced.CheckDebugCharacterVis"); | 11350 | addMenu(new LLAdvancedCheckDebugCharacterVis(), "Advanced.CheckDebugCharacterVis"); |
11351 | // addMenu(new LLAdvancedToggleShowCollisionPlane(), "Advanced.ToggleShowCollisionPlane"); | 11351 | // addMenu(new LLAdvancedToggleShowCollisionPlane(), "Advanced.ToggleShowCollisionPlane"); |
11352 | // addMenu(new LLAdvancedCheckShowCollisionPlane(), "Advanced.CheckShowCollisionPlane"); | 11352 | // addMenu(new LLAdvancedCheckShowCollisionPlane(), "Advanced.CheckShowCollisionPlane"); |
11353 | addMenu(new LLAdvancedToggleShowCollisionSkeleton(), "Advanced.ToggleShowCollisionSkeleton"); | 11353 | // addMenu(new LLAdvancedToggleShowCollisionSkeleton(), "Advanced.ToggleShowCollisionSkeleton"); |
11354 | addMenu(new LLAdvancedCheckShowCollisionSkeleton(), "Advanced.CheckShowCollisionSkeleton"); | 11354 | // addMenu(new LLAdvancedCheckShowCollisionSkeleton(), "Advanced.CheckShowCollisionSkeleton"); |
11355 | addMenu(new LLAdvancedToggleDisplayAgentTarget(), "Advanced.ToggleDisplayAgentTarget"); | 11355 | // addMenu(new LLAdvancedToggleDisplayAgentTarget(), "Advanced.ToggleDisplayAgentTarget"); |
11356 | addMenu(new LLAdvancedCheckDisplayAgentTarget(), "Advanced.CheckDisplayAgentTarget"); | 11356 | // addMenu(new LLAdvancedCheckDisplayAgentTarget(), "Advanced.CheckDisplayAgentTarget"); |
11357 | addMenu(new LLAdvancedToggleDebugAvatarRotation(), "Advanced.ToggleDebugAvatarRotation"); | 11357 | addMenu(new LLAdvancedToggleDebugAvatarRotation(), "Advanced.ToggleDebugAvatarRotation"); |
11358 | addMenu(new LLAdvancedCheckDebugAvatarRotation(), "Advanced.CheckDebugAvatarRotation"); | 11358 | addMenu(new LLAdvancedCheckDebugAvatarRotation(), "Advanced.CheckDebugAvatarRotation"); |
11359 | addMenu(new LLAdvancedDumpAttachments(), "Advanced.DumpAttachments"); | 11359 | addMenu(new LLAdvancedDumpAttachments(), "Advanced.DumpAttachments"); |
diff --git a/linden/indra/newview/llviewerobject.cpp b/linden/indra/newview/llviewerobject.cpp index b40d4e0..2a6fafa 100644 --- a/linden/indra/newview/llviewerobject.cpp +++ b/linden/indra/newview/llviewerobject.cpp | |||
@@ -2785,6 +2785,11 @@ BOOL LLViewerObject::updateGeometry(LLDrawable *drawable) | |||
2785 | return TRUE; | 2785 | return TRUE; |
2786 | } | 2786 | } |
2787 | 2787 | ||
2788 | void LLViewerObject::updateGL() | ||
2789 | { | ||
2790 | |||
2791 | } | ||
2792 | |||
2788 | void LLViewerObject::updateFaceSize(S32 idx) | 2793 | void LLViewerObject::updateFaceSize(S32 idx) |
2789 | { | 2794 | { |
2790 | 2795 | ||
@@ -2889,7 +2894,7 @@ F32 LLViewerObject::getMidScale() const | |||
2889 | } | 2894 | } |
2890 | 2895 | ||
2891 | 2896 | ||
2892 | void LLViewerObject::updateTextures() | 2897 | void LLViewerObject::updateTextures(LLAgent &agent) |
2893 | { | 2898 | { |
2894 | } | 2899 | } |
2895 | 2900 | ||
@@ -3734,6 +3739,7 @@ S32 LLViewerObject::setTEColor(const U8 te, const LLColor4& color) | |||
3734 | else if (color != tep->getColor()) | 3739 | else if (color != tep->getColor()) |
3735 | { | 3740 | { |
3736 | retval = LLPrimitive::setTEColor(te, color); | 3741 | retval = LLPrimitive::setTEColor(te, color); |
3742 | //setChanged(TEXTURE); | ||
3737 | if (mDrawable.notNull() && retval) | 3743 | if (mDrawable.notNull() && retval) |
3738 | { | 3744 | { |
3739 | // These should only happen on updates which are not the initial update. | 3745 | // These should only happen on updates which are not the initial update. |
@@ -3972,7 +3978,7 @@ LLViewerImage *LLViewerObject::getTEImage(const U8 face) const | |||
3972 | } | 3978 | } |
3973 | } | 3979 | } |
3974 | 3980 | ||
3975 | llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl; | 3981 | llwarns << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl; |
3976 | 3982 | ||
3977 | return NULL; | 3983 | return NULL; |
3978 | } | 3984 | } |
@@ -4158,6 +4164,11 @@ void LLViewerObject::updateText() | |||
4158 | } | 4164 | } |
4159 | } | 4165 | } |
4160 | 4166 | ||
4167 | LLVOAvatar* LLViewerObject::asAvatar() | ||
4168 | { | ||
4169 | return NULL; | ||
4170 | } | ||
4171 | |||
4161 | BOOL LLViewerObject::isParticleSource() const | 4172 | BOOL LLViewerObject::isParticleSource() const |
4162 | { | 4173 | { |
4163 | return !mPartSourcep.isNull() && !mPartSourcep->isDead(); | 4174 | return !mPartSourcep.isNull() && !mPartSourcep->isDead(); |
@@ -4372,7 +4383,14 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow | |||
4372 | gAudiop->cleanupAudioSource(mAudioSourcep); | 4383 | gAudiop->cleanupAudioSource(mAudioSourcep); |
4373 | mAudioSourcep = NULL; | 4384 | mAudioSourcep = NULL; |
4374 | } | 4385 | } |
4375 | 4386 | /* | |
4387 | if (mAudioSourcep && mAudioSourcep->isMuted() && | ||
4388 | mAudioSourcep->getCurrentData() && mAudioSourcep->getCurrentData()->getID() == audio_uuid) | ||
4389 | { | ||
4390 | //llinfos << "Already having this sound as muted sound, ignoring" << llendl; | ||
4391 | return; | ||
4392 | } | ||
4393 | */ | ||
4376 | getAudioSource(owner_id); | 4394 | getAudioSource(owner_id); |
4377 | 4395 | ||
4378 | if (mAudioSourcep) | 4396 | if (mAudioSourcep) |
@@ -4466,7 +4484,11 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para | |||
4466 | new_block = new LLSculptParams(); | 4484 | new_block = new LLSculptParams(); |
4467 | break; | 4485 | break; |
4468 | } | 4486 | } |
4469 | 4487 | case LLNetworkData::PARAMS_LIGHT_IMAGE: | |
4488 | { | ||
4489 | new_block = new LLLightImageParams(); | ||
4490 | break; | ||
4491 | } | ||
4470 | default: | 4492 | default: |
4471 | { | 4493 | { |
4472 | llinfos << "Unknown param type." << llendl; | 4494 | llinfos << "Unknown param type." << llendl; |
@@ -4557,7 +4579,7 @@ bool LLViewerObject::setParameterEntry(U16 param_type, const LLNetworkData& new_ | |||
4557 | bool LLViewerObject::setParameterEntryInUse(U16 param_type, BOOL in_use, bool local_origin) | 4579 | bool LLViewerObject::setParameterEntryInUse(U16 param_type, BOOL in_use, bool local_origin) |
4558 | { | 4580 | { |
4559 | ExtraParameter* param = getExtraParameterEntryCreate(param_type); | 4581 | ExtraParameter* param = getExtraParameterEntryCreate(param_type); |
4560 | if (param->in_use != in_use) | 4582 | if (param && param->in_use != in_use) |
4561 | { | 4583 | { |
4562 | param->in_use = in_use; | 4584 | param->in_use = in_use; |
4563 | parameterChanged(param_type, param->data, in_use, local_origin); | 4585 | parameterChanged(param_type, param->data, in_use, local_origin); |
@@ -4973,7 +4995,7 @@ U32 LLViewerObject::getPartitionType() const | |||
4973 | return LLViewerRegion::PARTITION_NONE; | 4995 | return LLViewerRegion::PARTITION_NONE; |
4974 | } | 4996 | } |
4975 | 4997 | ||
4976 | void LLViewerObject::dirtySpatialGroup() const | 4998 | void LLViewerObject::dirtySpatialGroup(BOOL priority) const |
4977 | { | 4999 | { |
4978 | if (mDrawable) | 5000 | if (mDrawable) |
4979 | { | 5001 | { |
@@ -4981,6 +5003,7 @@ void LLViewerObject::dirtySpatialGroup() const | |||
4981 | if (group) | 5003 | if (group) |
4982 | { | 5004 | { |
4983 | group->dirtyGeom(); | 5005 | group->dirtyGeom(); |
5006 | gPipeline.markRebuild(group, priority); | ||
4984 | } | 5007 | } |
4985 | } | 5008 | } |
4986 | } | 5009 | } |
diff --git a/linden/indra/newview/llviewerobject.h b/linden/indra/newview/llviewerobject.h index 7f8bd63..41c406a 100644 --- a/linden/indra/newview/llviewerobject.h +++ b/linden/indra/newview/llviewerobject.h | |||
@@ -74,6 +74,7 @@ class LLViewerPartSourceScript; | |||
74 | class LLViewerRegion; | 74 | class LLViewerRegion; |
75 | class LLViewerObjectMedia; | 75 | class LLViewerObjectMedia; |
76 | class LLVOInventoryListener; | 76 | class LLVOInventoryListener; |
77 | class LLVOAvatar; | ||
77 | 78 | ||
78 | typedef enum e_object_update_type | 79 | typedef enum e_object_update_type |
79 | { | 80 | { |
@@ -116,7 +117,7 @@ public: | |||
116 | 117 | ||
117 | //============================================================================ | 118 | //============================================================================ |
118 | 119 | ||
119 | class LLViewerObject : public LLPrimitive, public LLRefCount | 120 | class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate |
120 | { | 121 | { |
121 | protected: | 122 | protected: |
122 | ~LLViewerObject(); // use unref() | 123 | ~LLViewerObject(); // use unref() |
@@ -143,6 +144,8 @@ public: | |||
143 | BOOL isOrphaned() const { return mOrphaned; } | 144 | BOOL isOrphaned() const { return mOrphaned; } |
144 | BOOL isParticleSource() const; | 145 | BOOL isParticleSource() const; |
145 | 146 | ||
147 | virtual LLVOAvatar* asAvatar(); | ||
148 | |||
146 | static void initVOClasses(); | 149 | static void initVOClasses(); |
147 | static void cleanupVOClasses(); | 150 | static void cleanupVOClasses(); |
148 | 151 | ||
@@ -189,11 +192,12 @@ public: | |||
189 | S32 getNumFaces() const { return mNumFaces; } | 192 | S32 getNumFaces() const { return mNumFaces; } |
190 | 193 | ||
191 | // Graphical stuff for objects - maybe broken out into render class later? | 194 | // Graphical stuff for objects - maybe broken out into render class later? |
192 | virtual void updateTextures(); | 195 | virtual void updateTextures(LLAgent &agent); |
193 | virtual void boostTexturePriority(BOOL boost_children = TRUE); // When you just want to boost priority of this object | 196 | virtual void boostTexturePriority(BOOL boost_children = TRUE); // When you just want to boost priority of this object |
194 | 197 | ||
195 | virtual LLDrawable* createDrawable(LLPipeline *pipeline); | 198 | virtual LLDrawable* createDrawable(LLPipeline *pipeline); |
196 | virtual BOOL updateGeometry(LLDrawable *drawable); | 199 | virtual BOOL updateGeometry(LLDrawable *drawable); |
200 | virtual void updateGL(); | ||
197 | virtual void updateFaceSize(S32 idx); | 201 | virtual void updateFaceSize(S32 idx); |
198 | virtual BOOL updateLOD(); | 202 | virtual BOOL updateLOD(); |
199 | virtual BOOL setDrawableParent(LLDrawable* parentp); | 203 | virtual BOOL setDrawableParent(LLDrawable* parentp); |
@@ -218,6 +222,7 @@ public: | |||
218 | 222 | ||
219 | virtual BOOL isFlexible() const { return FALSE; } | 223 | virtual BOOL isFlexible() const { return FALSE; } |
220 | virtual BOOL isSculpted() const { return FALSE; } | 224 | virtual BOOL isSculpted() const { return FALSE; } |
225 | virtual BOOL hasLightTexture() const { return FALSE; } | ||
221 | 226 | ||
222 | // This method returns true if the object is over land owned by | 227 | // This method returns true if the object is over land owned by |
223 | // the agent. | 228 | // the agent. |
@@ -468,7 +473,7 @@ public: | |||
468 | 473 | ||
469 | virtual S32 getLOD() const { return 3; } | 474 | virtual S32 getLOD() const { return 3; } |
470 | virtual U32 getPartitionType() const; | 475 | virtual U32 getPartitionType() const; |
471 | virtual void dirtySpatialGroup() const; | 476 | virtual void dirtySpatialGroup(BOOL priority = FALSE) const; |
472 | virtual void dirtyMesh(); | 477 | virtual void dirtyMesh(); |
473 | 478 | ||
474 | virtual LLNetworkData* getParameterEntry(U16 param_type) const; | 479 | virtual LLNetworkData* getParameterEntry(U16 param_type) const; |
diff --git a/linden/indra/newview/llviewerobjectlist.cpp b/linden/indra/newview/llviewerobjectlist.cpp index bfb248b..a289570 100644 --- a/linden/indra/newview/llviewerobjectlist.cpp +++ b/linden/indra/newview/llviewerobjectlist.cpp | |||
@@ -629,7 +629,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) | |||
629 | 629 | ||
630 | // Update distance & gpw | 630 | // Update distance & gpw |
631 | objectp->setPixelAreaAndAngle(agent); // Also sets the approx. pixel area | 631 | objectp->setPixelAreaAndAngle(agent); // Also sets the approx. pixel area |
632 | objectp->updateTextures(); // Update the image levels of textures for this object. | 632 | objectp->updateTextures(agent); // Update the image levels of textures for this object. |
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
diff --git a/linden/indra/newview/llviewerobjectlist.h b/linden/indra/newview/llviewerobjectlist.h index 07920cb..a77c33d 100644 --- a/linden/indra/newview/llviewerobjectlist.h +++ b/linden/indra/newview/llviewerobjectlist.h | |||
@@ -44,7 +44,6 @@ | |||
44 | // project includes | 44 | // project includes |
45 | #include "llviewerobject.h" | 45 | #include "llviewerobject.h" |
46 | 46 | ||
47 | class LLCamera; | ||
48 | class LLNetMap; | 47 | class LLNetMap; |
49 | class LLDebugBeacon; | 48 | class LLDebugBeacon; |
50 | 49 | ||
diff --git a/linden/indra/newview/llviewerparceloverlay.cpp b/linden/indra/newview/llviewerparceloverlay.cpp index 0bcd8f3..935e3e6 100644 --- a/linden/indra/newview/llviewerparceloverlay.cpp +++ b/linden/indra/newview/llviewerparceloverlay.cpp | |||
@@ -71,7 +71,7 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_ | |||
71 | // Use mipmaps = FALSE, clamped, NEAREST filter, for sharp edges | 71 | // Use mipmaps = FALSE, clamped, NEAREST filter, for sharp edges |
72 | mTexture = new LLImageGL(FALSE); | 72 | mTexture = new LLImageGL(FALSE); |
73 | mImageRaw = new LLImageRaw(mParcelGridsPerEdge, mParcelGridsPerEdge, OVERLAY_IMG_COMPONENTS); | 73 | mImageRaw = new LLImageRaw(mParcelGridsPerEdge, mParcelGridsPerEdge, OVERLAY_IMG_COMPONENTS); |
74 | mTexture->createGLTexture(0, mImageRaw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | 74 | mTexture->createGLTexture(0, mImageRaw, 0); |
75 | gGL.getTexUnit(0)->activate(); | 75 | gGL.getTexUnit(0)->activate(); |
76 | gGL.getTexUnit(0)->bind(mTexture); | 76 | gGL.getTexUnit(0)->bind(mTexture); |
77 | mTexture->setAddressMode(LLTexUnit::TAM_CLAMP); | 77 | mTexture->setAddressMode(LLTexUnit::TAM_CLAMP); |
@@ -593,7 +593,7 @@ void LLViewerParcelOverlay::addPropertyLine( | |||
593 | break; | 593 | break; |
594 | 594 | ||
595 | default: | 595 | default: |
596 | llerrs << "Invalid edge in addPropertyLine" << llendl; | 596 | llwarns << "Invalid edge in addPropertyLine" << llendl; |
597 | return; | 597 | return; |
598 | } | 598 | } |
599 | 599 | ||
diff --git a/linden/indra/newview/llviewershadermgr.cpp b/linden/indra/newview/llviewershadermgr.cpp index 69f7bd8..8648271 100644 --- a/linden/indra/newview/llviewershadermgr.cpp +++ b/linden/indra/newview/llviewershadermgr.cpp | |||
@@ -113,6 +113,8 @@ LLGLSLShader gDeferredAvatarProgram; | |||
113 | LLGLSLShader gDeferredAvatarAlphaProgram; | 113 | LLGLSLShader gDeferredAvatarAlphaProgram; |
114 | LLGLSLShader gDeferredLightProgram; | 114 | LLGLSLShader gDeferredLightProgram; |
115 | LLGLSLShader gDeferredMultiLightProgram; | 115 | LLGLSLShader gDeferredMultiLightProgram; |
116 | LLGLSLShader gDeferredSpotLightProgram; | ||
117 | LLGLSLShader gDeferredMultiSpotLightProgram; | ||
116 | LLGLSLShader gDeferredSunProgram; | 118 | LLGLSLShader gDeferredSunProgram; |
117 | LLGLSLShader gDeferredBlurLightProgram; | 119 | LLGLSLShader gDeferredBlurLightProgram; |
118 | LLGLSLShader gDeferredSoftenProgram; | 120 | LLGLSLShader gDeferredSoftenProgram; |
@@ -120,6 +122,12 @@ LLGLSLShader gDeferredShadowProgram; | |||
120 | LLGLSLShader gDeferredAvatarShadowProgram; | 122 | LLGLSLShader gDeferredAvatarShadowProgram; |
121 | LLGLSLShader gDeferredAlphaProgram; | 123 | LLGLSLShader gDeferredAlphaProgram; |
122 | LLGLSLShader gDeferredFullbrightProgram; | 124 | LLGLSLShader gDeferredFullbrightProgram; |
125 | LLGLSLShader gDeferredGIProgram; | ||
126 | LLGLSLShader gDeferredPostGIProgram; | ||
127 | LLGLSLShader gDeferredPostProgram; | ||
128 | |||
129 | LLGLSLShader gLuminanceGatherProgram; | ||
130 | |||
123 | 131 | ||
124 | //current avatar shader parameter pointer | 132 | //current avatar shader parameter pointer |
125 | GLint gAvatarMatrixParam; | 133 | GLint gAvatarMatrixParam; |
@@ -151,6 +159,9 @@ LLViewerShaderMgr::LLViewerShaderMgr() : | |||
151 | mShaderList.push_back(&gDeferredMultiLightProgram); | 159 | mShaderList.push_back(&gDeferredMultiLightProgram); |
152 | mShaderList.push_back(&gDeferredAlphaProgram); | 160 | mShaderList.push_back(&gDeferredAlphaProgram); |
153 | mShaderList.push_back(&gDeferredFullbrightProgram); | 161 | mShaderList.push_back(&gDeferredFullbrightProgram); |
162 | mShaderList.push_back(&gDeferredPostGIProgram); | ||
163 | mShaderList.push_back(&gDeferredPostProgram); | ||
164 | mShaderList.push_back(&gDeferredGIProgram); | ||
154 | mShaderList.push_back(&gDeferredWaterProgram); | 165 | mShaderList.push_back(&gDeferredWaterProgram); |
155 | mShaderList.push_back(&gDeferredAvatarAlphaProgram); | 166 | mShaderList.push_back(&gDeferredAvatarAlphaProgram); |
156 | } | 167 | } |
@@ -220,13 +231,32 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) | |||
220 | mReservedUniforms.push_back("shadowMap1"); | 231 | mReservedUniforms.push_back("shadowMap1"); |
221 | mReservedUniforms.push_back("shadowMap2"); | 232 | mReservedUniforms.push_back("shadowMap2"); |
222 | mReservedUniforms.push_back("shadowMap3"); | 233 | mReservedUniforms.push_back("shadowMap3"); |
234 | mReservedUniforms.push_back("shadowMap4"); | ||
235 | mReservedUniforms.push_back("shadowMap5"); | ||
236 | |||
223 | mReservedUniforms.push_back("normalMap"); | 237 | mReservedUniforms.push_back("normalMap"); |
224 | mReservedUniforms.push_back("positionMap"); | 238 | mReservedUniforms.push_back("positionMap"); |
225 | mReservedUniforms.push_back("diffuseRect"); | 239 | mReservedUniforms.push_back("diffuseRect"); |
226 | mReservedUniforms.push_back("specularRect"); | 240 | mReservedUniforms.push_back("specularRect"); |
227 | mReservedUniforms.push_back("noiseMap"); | 241 | mReservedUniforms.push_back("noiseMap"); |
242 | mReservedUniforms.push_back("lightFunc"); | ||
228 | mReservedUniforms.push_back("lightMap"); | 243 | mReservedUniforms.push_back("lightMap"); |
229 | 244 | mReservedUniforms.push_back("luminanceMap"); | |
245 | mReservedUniforms.push_back("giLightMap"); | ||
246 | mReservedUniforms.push_back("sunLightMap"); | ||
247 | mReservedUniforms.push_back("localLightMap"); | ||
248 | mReservedUniforms.push_back("projectionMap"); | ||
249 | mReservedUniforms.push_back("diffuseGIMap"); | ||
250 | mReservedUniforms.push_back("specularGIMap"); | ||
251 | mReservedUniforms.push_back("normalGIMap"); | ||
252 | mReservedUniforms.push_back("minpGIMap"); | ||
253 | mReservedUniforms.push_back("maxpGIMap"); | ||
254 | mReservedUniforms.push_back("depthGIMap"); | ||
255 | mReservedUniforms.push_back("lastDiffuseGIMap"); | ||
256 | mReservedUniforms.push_back("lastNormalGIMap"); | ||
257 | mReservedUniforms.push_back("lastMinpGIMap"); | ||
258 | mReservedUniforms.push_back("lastMaxpGIMap"); | ||
259 | |||
230 | mWLUniforms.push_back("camPosLocal"); | 260 | mWLUniforms.push_back("camPosLocal"); |
231 | 261 | ||
232 | mTerrainUniforms.reserve(5); | 262 | mTerrainUniforms.reserve(5); |
@@ -754,9 +784,9 @@ BOOL LLViewerShaderMgr::loadShadersEffects() | |||
754 | } | 784 | } |
755 | } | 785 | } |
756 | 786 | ||
757 | #if 0 | 787 | |
758 | // disabling loading of postprocess shaders until we fix | 788 | // KL enabling loading of postprocess shaders until we fix |
759 | // ATI sampler2DRect compatibility. | 789 | // ATI may still have issues |
760 | 790 | ||
761 | //load Color Filter Shader | 791 | //load Color Filter Shader |
762 | if (success) | 792 | if (success) |
@@ -797,7 +827,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() | |||
797 | gPostNightVisionProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; | 827 | gPostNightVisionProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; |
798 | success = gPostNightVisionProgram.createShader(NULL, &shaderUniforms); | 828 | success = gPostNightVisionProgram.createShader(NULL, &shaderUniforms); |
799 | } | 829 | } |
800 | #endif | 830 | |
801 | 831 | ||
802 | return success; | 832 | return success; |
803 | 833 | ||
@@ -814,6 +844,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() | |||
814 | gDeferredTerrainProgram.unload(); | 844 | gDeferredTerrainProgram.unload(); |
815 | gDeferredLightProgram.unload(); | 845 | gDeferredLightProgram.unload(); |
816 | gDeferredMultiLightProgram.unload(); | 846 | gDeferredMultiLightProgram.unload(); |
847 | gDeferredSpotLightProgram.unload(); | ||
848 | gDeferredMultiSpotLightProgram.unload(); | ||
817 | gDeferredSunProgram.unload(); | 849 | gDeferredSunProgram.unload(); |
818 | gDeferredBlurLightProgram.unload(); | 850 | gDeferredBlurLightProgram.unload(); |
819 | gDeferredSoftenProgram.unload(); | 851 | gDeferredSoftenProgram.unload(); |
@@ -823,6 +855,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() | |||
823 | gDeferredAvatarAlphaProgram.unload(); | 855 | gDeferredAvatarAlphaProgram.unload(); |
824 | gDeferredAlphaProgram.unload(); | 856 | gDeferredAlphaProgram.unload(); |
825 | gDeferredFullbrightProgram.unload(); | 857 | gDeferredFullbrightProgram.unload(); |
858 | gDeferredPostGIProgram.unload(); | ||
859 | gDeferredPostProgram.unload(); | ||
860 | gLuminanceGatherProgram.unload(); | ||
861 | gDeferredGIProgram.unload(); | ||
826 | gDeferredWaterProgram.unload(); | 862 | gDeferredWaterProgram.unload(); |
827 | return FALSE; | 863 | return FALSE; |
828 | } | 864 | } |
@@ -893,6 +929,26 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() | |||
893 | 929 | ||
894 | if (success) | 930 | if (success) |
895 | { | 931 | { |
932 | gDeferredSpotLightProgram.mName = "Deferred SpotLight Shader"; | ||
933 | gDeferredSpotLightProgram.mShaderFiles.clear(); | ||
934 | gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB)); | ||
935 | gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); | ||
936 | gDeferredSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; | ||
937 | success = gDeferredSpotLightProgram.createShader(NULL, NULL); | ||
938 | } | ||
939 | |||
940 | if (success) | ||
941 | { | ||
942 | gDeferredMultiSpotLightProgram.mName = "Deferred MultiSpotLight Shader"; | ||
943 | gDeferredMultiSpotLightProgram.mShaderFiles.clear(); | ||
944 | gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB)); | ||
945 | gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); | ||
946 | gDeferredMultiSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; | ||
947 | success = gDeferredMultiSpotLightProgram.createShader(NULL, NULL); | ||
948 | } | ||
949 | |||
950 | if (success) | ||
951 | { | ||
896 | gDeferredSunProgram.mName = "Deferred Sun Shader"; | 952 | gDeferredSunProgram.mName = "Deferred Sun Shader"; |
897 | gDeferredSunProgram.mShaderFiles.clear(); | 953 | gDeferredSunProgram.mShaderFiles.clear(); |
898 | gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB)); | 954 | gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB)); |
@@ -942,6 +998,36 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() | |||
942 | 998 | ||
943 | if (success) | 999 | if (success) |
944 | { | 1000 | { |
1001 | gDeferredPostGIProgram.mName = "Deferred Post GI Shader"; | ||
1002 | gDeferredPostGIProgram.mShaderFiles.clear(); | ||
1003 | gDeferredPostGIProgram.mShaderFiles.push_back(make_pair("deferred/postgiV.glsl", GL_VERTEX_SHADER_ARB)); | ||
1004 | gDeferredPostGIProgram.mShaderFiles.push_back(make_pair("deferred/postgiF.glsl", GL_FRAGMENT_SHADER_ARB)); | ||
1005 | gDeferredPostGIProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; | ||
1006 | success = gDeferredPostGIProgram.createShader(NULL, NULL); | ||
1007 | } | ||
1008 | |||
1009 | if (success) | ||
1010 | { | ||
1011 | gDeferredPostProgram.mName = "Deferred Post Shader"; | ||
1012 | gDeferredPostProgram.mShaderFiles.clear(); | ||
1013 | gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB)); | ||
1014 | gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER_ARB)); | ||
1015 | gDeferredPostProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; | ||
1016 | success = gDeferredPostProgram.createShader(NULL, NULL); | ||
1017 | } | ||
1018 | |||
1019 | if (success) | ||
1020 | { | ||
1021 | gDeferredGIProgram.mName = "Deferred GI Shader"; | ||
1022 | gDeferredGIProgram.mShaderFiles.clear(); | ||
1023 | gDeferredGIProgram.mShaderFiles.push_back(make_pair("deferred/giV.glsl", GL_VERTEX_SHADER_ARB)); | ||
1024 | gDeferredGIProgram.mShaderFiles.push_back(make_pair("deferred/giF.glsl", GL_FRAGMENT_SHADER_ARB)); | ||
1025 | gDeferredGIProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; | ||
1026 | success = gDeferredGIProgram.createShader(NULL, NULL); | ||
1027 | } | ||
1028 | |||
1029 | if (success) | ||
1030 | { | ||
945 | // load water shader | 1031 | // load water shader |
946 | gDeferredWaterProgram.mName = "Deferred Water Shader"; | 1032 | gDeferredWaterProgram.mName = "Deferred Water Shader"; |
947 | gDeferredWaterProgram.mFeatures.calculatesAtmospherics = true; | 1033 | gDeferredWaterProgram.mFeatures.calculatesAtmospherics = true; |
@@ -1022,6 +1108,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() | |||
1022 | success = gDeferredAvatarAlphaProgram.createShader(&mAvatarAttribs, &mAvatarUniforms); | 1108 | success = gDeferredAvatarAlphaProgram.createShader(&mAvatarAttribs, &mAvatarUniforms); |
1023 | } | 1109 | } |
1024 | 1110 | ||
1111 | if (success) | ||
1112 | { | ||
1113 | gLuminanceGatherProgram.mName = "Luminance Gather Shader"; | ||
1114 | gLuminanceGatherProgram.mShaderFiles.clear(); | ||
1115 | gLuminanceGatherProgram.mShaderFiles.push_back(make_pair("deferred/luminanceV.glsl", GL_VERTEX_SHADER_ARB)); | ||
1116 | gLuminanceGatherProgram.mShaderFiles.push_back(make_pair("deferred/luminanceF.glsl", GL_FRAGMENT_SHADER_ARB)); | ||
1117 | gLuminanceGatherProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; | ||
1118 | success = gLuminanceGatherProgram.createShader(NULL, NULL); | ||
1119 | } | ||
1120 | |||
1025 | return success; | 1121 | return success; |
1026 | } | 1122 | } |
1027 | 1123 | ||
diff --git a/linden/indra/newview/llviewershadermgr.h b/linden/indra/newview/llviewershadermgr.h index a743966..bb50779 100644 --- a/linden/indra/newview/llviewershadermgr.h +++ b/linden/indra/newview/llviewershadermgr.h | |||
@@ -116,12 +116,30 @@ public: | |||
116 | DEFERRED_SHADOW1, | 116 | DEFERRED_SHADOW1, |
117 | DEFERRED_SHADOW2, | 117 | DEFERRED_SHADOW2, |
118 | DEFERRED_SHADOW3, | 118 | DEFERRED_SHADOW3, |
119 | DEFERRED_SHADOW4, | ||
120 | DEFERRED_SHADOW5, | ||
119 | DEFERRED_NORMAL, | 121 | DEFERRED_NORMAL, |
120 | DEFERRED_POSITION, | 122 | DEFERRED_POSITION, |
121 | DEFERRED_DIFFUSE, | 123 | DEFERRED_DIFFUSE, |
122 | DEFERRED_SPECULAR, | 124 | DEFERRED_SPECULAR, |
123 | DEFERRED_NOISE, | 125 | DEFERRED_NOISE, |
126 | DEFERRED_LIGHTFUNC, | ||
124 | DEFERRED_LIGHT, | 127 | DEFERRED_LIGHT, |
128 | DEFERRED_LUMINANCE, | ||
129 | DEFERRED_GI_LIGHT, | ||
130 | DEFERRED_SUN_LIGHT, | ||
131 | DEFERRED_LOCAL_LIGHT, | ||
132 | DEFERRED_PROJECTION, | ||
133 | DEFERRED_GI_DIFFUSE, | ||
134 | DEFERRED_GI_SPECULAR, | ||
135 | DEFERRED_GI_NORMAL, | ||
136 | DEFERRED_GI_MIN_POS, | ||
137 | DEFERRED_GI_MAX_POS, | ||
138 | DEFERRED_GI_DEPTH, | ||
139 | DEFERRED_GI_LAST_DIFFUSE, | ||
140 | DEFERRED_GI_LAST_NORMAL, | ||
141 | DEFERRED_GI_LAST_MIN_POS, | ||
142 | DEFERRED_GI_LAST_MAX_POS, | ||
125 | END_RESERVED_UNIFORMS | 143 | END_RESERVED_UNIFORMS |
126 | } eGLSLReservedUniforms; | 144 | } eGLSLReservedUniforms; |
127 | 145 | ||
@@ -326,16 +344,23 @@ extern LLGLSLShader gDeferredTerrainProgram; | |||
326 | extern LLGLSLShader gDeferredTreeProgram; | 344 | extern LLGLSLShader gDeferredTreeProgram; |
327 | extern LLGLSLShader gDeferredLightProgram; | 345 | extern LLGLSLShader gDeferredLightProgram; |
328 | extern LLGLSLShader gDeferredMultiLightProgram; | 346 | extern LLGLSLShader gDeferredMultiLightProgram; |
347 | extern LLGLSLShader gDeferredSpotLightProgram; | ||
348 | extern LLGLSLShader gDeferredMultiSpotLightProgram; | ||
329 | extern LLGLSLShader gDeferredSunProgram; | 349 | extern LLGLSLShader gDeferredSunProgram; |
350 | extern LLGLSLShader gDeferredGIProgram; | ||
330 | extern LLGLSLShader gDeferredBlurLightProgram; | 351 | extern LLGLSLShader gDeferredBlurLightProgram; |
331 | extern LLGLSLShader gDeferredAvatarProgram; | 352 | extern LLGLSLShader gDeferredAvatarProgram; |
332 | extern LLGLSLShader gDeferredSoftenProgram; | 353 | extern LLGLSLShader gDeferredSoftenProgram; |
333 | extern LLGLSLShader gDeferredShadowProgram; | 354 | extern LLGLSLShader gDeferredShadowProgram; |
355 | extern LLGLSLShader gDeferredPostGIProgram; | ||
356 | extern LLGLSLShader gDeferredPostProgram; | ||
334 | extern LLGLSLShader gDeferredAvatarShadowProgram; | 357 | extern LLGLSLShader gDeferredAvatarShadowProgram; |
335 | extern LLGLSLShader gDeferredAlphaProgram; | 358 | extern LLGLSLShader gDeferredAlphaProgram; |
336 | extern LLGLSLShader gDeferredFullbrightProgram; | 359 | extern LLGLSLShader gDeferredFullbrightProgram; |
337 | extern LLGLSLShader gDeferredAvatarAlphaProgram; | 360 | extern LLGLSLShader gDeferredAvatarAlphaProgram; |
338 | 361 | ||
362 | extern LLGLSLShader gLuminanceGatherProgram; | ||
363 | |||
339 | //current avatar shader parameter pointer | 364 | //current avatar shader parameter pointer |
340 | extern GLint gAvatarMatrixParam; | 365 | extern GLint gAvatarMatrixParam; |
341 | 366 | ||
diff --git a/linden/indra/newview/llviewerstats.h b/linden/indra/newview/llviewerstats.h index b176632..9107ad6 100644 --- a/linden/indra/newview/llviewerstats.h +++ b/linden/indra/newview/llviewerstats.h | |||
@@ -196,7 +196,7 @@ private: | |||
196 | F64 mLastTimeDiff; // used for time stat updates | 196 | F64 mLastTimeDiff; // used for time stat updates |
197 | }; | 197 | }; |
198 | 198 | ||
199 | static const F32 SEND_STATS_PERIOD = 300.0f; | 199 | static const F32 SEND_STATS_PERIOD = 3000.0f; |
200 | 200 | ||
201 | // The following are from (older?) statistics code found in appviewer. | 201 | // The following are from (older?) statistics code found in appviewer. |
202 | void init_statistics(); | 202 | void init_statistics(); |
diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp index f7713c2..6f1b54c 100644 --- a/linden/indra/newview/llviewerwindow.cpp +++ b/linden/indra/newview/llviewerwindow.cpp | |||
@@ -471,6 +471,27 @@ public: | |||
471 | 471 | ||
472 | ypos += y_inc; | 472 | ypos += y_inc; |
473 | 473 | ||
474 | { | ||
475 | std::ostringstream ostr; | ||
476 | ostr << "Shadow error: " << gPipeline.mShadowError; | ||
477 | addText(xpos, ypos, ostr.str()); | ||
478 | ypos += y_inc; | ||
479 | } | ||
480 | |||
481 | { | ||
482 | std::ostringstream ostr; | ||
483 | ostr << "Shadow FOV: " << gPipeline.mShadowFOV; | ||
484 | addText(xpos, ypos, ostr.str()); | ||
485 | ypos += y_inc; | ||
486 | } | ||
487 | |||
488 | { | ||
489 | std::ostringstream ostr; | ||
490 | ostr << "Shadow Splits: " << gPipeline.mSunClipPlanes; | ||
491 | addText(xpos, ypos, ostr.str()); | ||
492 | ypos += y_inc; | ||
493 | } | ||
494 | |||
474 | LLVertexBuffer::sBindCount = LLImageGL::sBindCount = | 495 | LLVertexBuffer::sBindCount = LLImageGL::sBindCount = |
475 | LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount = | 496 | LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount = |
476 | gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0; | 497 | gPipeline.mNumVisibleNodes = LLPipeline::sVisibleLightCount = 0; |
@@ -1321,7 +1342,6 @@ LLViewerWindow::LLViewerWindow( | |||
1321 | 1342 | ||
1322 | // Init the image list. Must happen after GL is initialized and before the images that | 1343 | // Init the image list. Must happen after GL is initialized and before the images that |
1323 | // LLViewerWindow needs are requested. | 1344 | // LLViewerWindow needs are requested. |
1324 | LLImageGL::initClass(LLViewerImageBoostLevel::MAX_GL_IMAGE_CATEGORY) ; | ||
1325 | gImageList.init(); | 1345 | gImageList.init(); |
1326 | LLViewerImage::initClass(); | 1346 | LLViewerImage::initClass(); |
1327 | gBumpImageList.init(); | 1347 | gBumpImageList.init(); |
@@ -1434,7 +1454,7 @@ void LLViewerWindow::initBase() | |||
1434 | llassert( !gConsole ); | 1454 | llassert( !gConsole ); |
1435 | gConsole = new LLConsole( | 1455 | gConsole = new LLConsole( |
1436 | "console", | 1456 | "console", |
1437 | gSavedSettings.getS32("ConsoleBufferSize"), | 1457 | //gSavedSettings.getS32("ConsoleBufferSize"), |
1438 | getChatConsoleRect(), | 1458 | getChatConsoleRect(), |
1439 | gSavedSettings.getS32("ChatFontSize"), | 1459 | gSavedSettings.getS32("ChatFontSize"), |
1440 | gSavedSettings.getF32("ChatPersistTime") ); | 1460 | gSavedSettings.getF32("ChatPersistTime") ); |
@@ -2515,7 +2535,6 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
2515 | mMouseInWindow = TRUE; | 2535 | mMouseInWindow = TRUE; |
2516 | } | 2536 | } |
2517 | 2537 | ||
2518 | |||
2519 | S32 dx = lltrunc((F32) (mCurrentMousePoint.mX - mLastMousePoint.mX) * LLUI::sGLScaleFactor.mV[VX]); | 2538 | S32 dx = lltrunc((F32) (mCurrentMousePoint.mX - mLastMousePoint.mX) * LLUI::sGLScaleFactor.mV[VX]); |
2520 | S32 dy = lltrunc((F32) (mCurrentMousePoint.mY - mLastMousePoint.mY) * LLUI::sGLScaleFactor.mV[VY]); | 2539 | S32 dy = lltrunc((F32) (mCurrentMousePoint.mY - mLastMousePoint.mY) * LLUI::sGLScaleFactor.mV[VY]); |
2521 | 2540 | ||
@@ -2538,7 +2557,7 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
2538 | mCurrentMouseDelta.set(dx, dy); | 2557 | mCurrentMouseDelta.set(dx, dy); |
2539 | mouse_vel.setVec((F32) dx, (F32) dy); | 2558 | mouse_vel.setVec((F32) dx, (F32) dy); |
2540 | } | 2559 | } |
2541 | 2560 | ||
2542 | mMouseVelocityStat.addValue(mouse_vel.magVec()); | 2561 | mMouseVelocityStat.addValue(mouse_vel.magVec()); |
2543 | 2562 | ||
2544 | if (gNoRender) | 2563 | if (gNoRender) |
@@ -2727,8 +2746,8 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
2727 | { | 2746 | { |
2728 | mToolTip->setVisible( tooltip_vis ); | 2747 | mToolTip->setVisible( tooltip_vis ); |
2729 | } | 2748 | } |
2730 | } | 2749 | } |
2731 | 2750 | ||
2732 | if (tool && tool != gToolNull && tool != LLToolCompInspect::getInstance() && tool != LLToolDragAndDrop::getInstance() && !gSavedSettings.getBOOL("FreezeTime")) | 2751 | if (tool && tool != gToolNull && tool != LLToolCompInspect::getInstance() && tool != LLToolDragAndDrop::getInstance() && !gSavedSettings.getBOOL("FreezeTime")) |
2733 | { | 2752 | { |
2734 | LLMouseHandler *captor = gFocusMgr.getMouseCapture(); | 2753 | LLMouseHandler *captor = gFocusMgr.getMouseCapture(); |
@@ -2798,37 +2817,41 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
2798 | gFloaterView->setRect(floater_rect); | 2817 | gFloaterView->setRect(floater_rect); |
2799 | } | 2818 | } |
2800 | 2819 | ||
2801 | // snap floaters to top of chat bar/button strip | ||
2802 | LLView* chatbar_and_buttons = gOverlayBar->getChild<LLView>("chatbar_and_buttons", TRUE); | ||
2803 | // find top of chatbar and state buttons, if either are visible | ||
2804 | if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull()) | ||
2805 | { | 2820 | { |
2806 | // convert top/left corner of chatbar/buttons container to gFloaterView-relative coordinates | 2821 | // snap floaters to top of chat bar/button strip |
2822 | LLView* chatbar_and_buttons = gOverlayBar->getChild<LLView>("chatbar_and_buttons", TRUE); | ||
2807 | S32 top, left; | 2823 | S32 top, left; |
2808 | chatbar_and_buttons->localPointToOtherView( | 2824 | S32 chatbar_and_buttons_x = chatbar_and_buttons->getLocalBoundingRect().mLeft; |
2809 | chatbar_and_buttons->getLocalBoundingRect().mLeft, | 2825 | S32 chatbar_and_buttons_y = chatbar_and_buttons->getLocalBoundingRect().mTop; |
2810 | chatbar_and_buttons->getLocalBoundingRect().mTop, | 2826 | |
2811 | &left, | 2827 | // find top of chatbar and state buttons, if either are visible |
2812 | &top, | 2828 | if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull()) |
2813 | gFloaterView); | 2829 | { |
2814 | gFloaterView->setSnapOffsetBottom(top); | 2830 | // convert top/left corner of chatbar/buttons container to |
2815 | } | 2831 | // gFloaterView-relative coordinates |
2816 | else if (gToolBar->getVisible()) | 2832 | chatbar_and_buttons->localPointToOtherView( |
2817 | { | 2833 | chatbar_and_buttons_x, |
2818 | S32 top, left; | 2834 | chatbar_and_buttons_y, |
2819 | gToolBar->localPointToOtherView( | 2835 | &left, |
2820 | gToolBar->getLocalBoundingRect().mLeft, | 2836 | &top, |
2821 | gToolBar->getLocalBoundingRect().mTop, | 2837 | gFloaterView); |
2822 | &left, | 2838 | gFloaterView->setSnapOffsetBottom(top); |
2823 | &top, | 2839 | } |
2824 | gFloaterView); | 2840 | else if (gToolBar->getVisible()) |
2825 | gFloaterView->setSnapOffsetBottom(top); | 2841 | { |
2826 | } | 2842 | gToolBar->localPointToOtherView( |
2827 | else | 2843 | chatbar_and_buttons_x, |
2828 | { | 2844 | chatbar_and_buttons_y, |
2829 | gFloaterView->setSnapOffsetBottom(0); | 2845 | &left, |
2846 | &top, | ||
2847 | gFloaterView); | ||
2848 | gFloaterView->setSnapOffsetBottom(top); | ||
2849 | } | ||
2850 | else | ||
2851 | { | ||
2852 | gFloaterView->setSnapOffsetBottom(0); | ||
2853 | } | ||
2830 | } | 2854 | } |
2831 | |||
2832 | // Always update console | 2855 | // Always update console |
2833 | LLRect console_rect = getChatConsoleRect(); | 2856 | LLRect console_rect = getChatConsoleRect(); |
2834 | console_rect.mBottom = gHUDView->getRect().mBottom + getChatConsoleBottomPad(); | 2857 | console_rect.mBottom = gHUDView->getRect().mBottom + getChatConsoleBottomPad(); |
@@ -2836,8 +2859,8 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
2836 | gConsole->setRect(console_rect); | 2859 | gConsole->setRect(console_rect); |
2837 | } | 2860 | } |
2838 | 2861 | ||
2839 | mLastMousePoint = mCurrentMousePoint; | ||
2840 | 2862 | ||
2863 | mLastMousePoint = mCurrentMousePoint; | ||
2841 | // last ditch force of edit menu to selection manager | 2864 | // last ditch force of edit menu to selection manager |
2842 | if (LLEditMenuHandler::gEditMenuHandler == NULL && LLSelectMgr::getInstance()->getSelection()->getObjectCount()) | 2865 | if (LLEditMenuHandler::gEditMenuHandler == NULL && LLSelectMgr::getInstance()->getSelection()->getObjectCount()) |
2843 | { | 2866 | { |
@@ -2900,7 +2923,6 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
2900 | &gDebugRaycastBinormal); | 2923 | &gDebugRaycastBinormal); |
2901 | } | 2924 | } |
2902 | 2925 | ||
2903 | |||
2904 | // per frame picking - for tooltips and changing cursor over interactive objects | 2926 | // per frame picking - for tooltips and changing cursor over interactive objects |
2905 | static S32 previous_x = -1; | 2927 | static S32 previous_x = -1; |
2906 | static S32 previous_y = -1; | 2928 | static S32 previous_y = -1; |
@@ -2943,7 +2965,6 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
2943 | 2965 | ||
2944 | previous_x = x; | 2966 | previous_x = x; |
2945 | previous_y = y; | 2967 | previous_y = y; |
2946 | |||
2947 | return handled; | 2968 | return handled; |
2948 | } | 2969 | } |
2949 | 2970 | ||
@@ -4041,7 +4062,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei | |||
4041 | { | 4062 | { |
4042 | if(image_width > window_width || image_height > window_height) //need to enlarge the scene | 4063 | if(image_width > window_width || image_height > window_height) //need to enlarge the scene |
4043 | { | 4064 | { |
4044 | if (gGLManager.mHasFramebufferObject && !show_ui) | 4065 | if (!LLPipeline::sRenderDeferred && gGLManager.mHasFramebufferObject && !show_ui) |
4045 | { | 4066 | { |
4046 | GLint max_size = 0; | 4067 | GLint max_size = 0; |
4047 | glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &max_size); | 4068 | glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &max_size); |
@@ -4130,9 +4151,16 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei | |||
4130 | else | 4151 | else |
4131 | { | 4152 | { |
4132 | const U32 subfield = subimage_x+(subimage_y*llceil(scale_factor)); | 4153 | const U32 subfield = subimage_x+(subimage_y*llceil(scale_factor)); |
4133 | display(do_rebuild, scale_factor, subfield, TRUE); | 4154 | if (LLPipeline::sRenderDeferred) |
4134 | // Required for showing the GUI in snapshots? See DEV-16350 for details. JC | 4155 | { |
4135 | render_ui(scale_factor, subfield); | 4156 | display(do_rebuild, scale_factor, subfield, FALSE); |
4157 | } | ||
4158 | else | ||
4159 | { | ||
4160 | display(do_rebuild, scale_factor, subfield, TRUE); | ||
4161 | // Required for showing the GUI in snapshots? See DEV-16350 for details. JC | ||
4162 | render_ui(scale_factor, subfield); | ||
4163 | } | ||
4136 | } | 4164 | } |
4137 | 4165 | ||
4138 | S32 subimage_x_offset = llclamp(buffer_x_offset - (subimage_x * window_width), 0, window_width); | 4166 | S32 subimage_x_offset = llclamp(buffer_x_offset - (subimage_x * window_width), 0, window_width); |
diff --git a/linden/indra/newview/llvlcomposition.cpp b/linden/indra/newview/llvlcomposition.cpp index 535c504..f96665b 100644 --- a/linden/indra/newview/llvlcomposition.cpp +++ b/linden/indra/newview/llvlcomposition.cpp | |||
@@ -460,6 +460,10 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y, | |||
460 | } | 460 | } |
461 | } | 461 | } |
462 | 462 | ||
463 | if (!texturep->getHasGLTexture()) | ||
464 | { | ||
465 | texturep->createGLTexture(0, raw); | ||
466 | } | ||
463 | texturep->setSubImage(raw, tex_x_begin, tex_y_begin, tex_x_end - tex_x_begin, tex_y_end - tex_y_begin); | 467 | texturep->setSubImage(raw, tex_x_begin, tex_y_begin, tex_x_end - tex_x_begin, tex_y_end - tex_y_begin); |
464 | LLSurface::sTextureUpdateTime += gen_timer.getElapsedTimeF32(); | 468 | LLSurface::sTextureUpdateTime += gen_timer.getElapsedTimeF32(); |
465 | LLSurface::sTexelsUpdated += (tex_x_end - tex_x_begin) * (tex_y_end - tex_y_begin); | 469 | LLSurface::sTexelsUpdated += (tex_x_end - tex_x_begin) * (tex_y_end - tex_y_begin); |
diff --git a/linden/indra/newview/llvoavatar.cpp b/linden/indra/newview/llvoavatar.cpp index 14b8d3e..3b62c63 100644 --- a/linden/indra/newview/llvoavatar.cpp +++ b/linden/indra/newview/llvoavatar.cpp | |||
@@ -704,6 +704,7 @@ BOOL LLVOAvatar::sDebugInvisible = FALSE; | |||
704 | BOOL LLVOAvatar::sShowAttachmentPoints = FALSE; | 704 | BOOL LLVOAvatar::sShowAttachmentPoints = FALSE; |
705 | BOOL LLVOAvatar::sShowAnimationDebug = FALSE; | 705 | BOOL LLVOAvatar::sShowAnimationDebug = FALSE; |
706 | BOOL LLVOAvatar::sShowFootPlane = FALSE; | 706 | BOOL LLVOAvatar::sShowFootPlane = FALSE; |
707 | BOOL LLVOAvatar::sShowCollisionVolumes = FALSE; | ||
707 | BOOL LLVOAvatar::sVisibleInFirstPerson = FALSE; | 708 | BOOL LLVOAvatar::sVisibleInFirstPerson = FALSE; |
708 | F32 LLVOAvatar::sLODFactor = 1.f; | 709 | F32 LLVOAvatar::sLODFactor = 1.f; |
709 | BOOL LLVOAvatar::sUseImpostors = FALSE; | 710 | BOOL LLVOAvatar::sUseImpostors = FALSE; |
@@ -740,6 +741,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, | |||
740 | mTyping(FALSE), | 741 | mTyping(FALSE), |
741 | mMeshValid(FALSE), | 742 | mMeshValid(FALSE), |
742 | mVisible(FALSE), | 743 | mVisible(FALSE), |
744 | mMeshTexturesDirty(FALSE), | ||
743 | mWindFreq(0.f), | 745 | mWindFreq(0.f), |
744 | mRipplePhase( 0.f ), | 746 | mRipplePhase( 0.f ), |
745 | mBelowWater(FALSE), | 747 | mBelowWater(FALSE), |
@@ -800,7 +802,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, | |||
800 | mBakedTextureData[i].mLastTextureIndex = IMG_DEFAULT_AVATAR; | 802 | mBakedTextureData[i].mLastTextureIndex = IMG_DEFAULT_AVATAR; |
801 | mBakedTextureData[i].mTexLayerSet = NULL; | 803 | mBakedTextureData[i].mTexLayerSet = NULL; |
802 | mBakedTextureData[i].mIsLoaded = false; | 804 | mBakedTextureData[i].mIsLoaded = false; |
803 | mBakedTextureData[i].mIsUsed = false; | 805 | //mBakedTextureData[i].mIsUsed = false; // KL SG |
804 | mBakedTextureData[i].mMaskTexName = 0; | 806 | mBakedTextureData[i].mMaskTexName = 0; |
805 | mBakedTextureData[i].mTextureIndex = getTextureIndex((EBakedTextureIndex)i); | 807 | mBakedTextureData[i].mTextureIndex = getTextureIndex((EBakedTextureIndex)i); |
806 | } | 808 | } |
@@ -856,9 +858,11 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, | |||
856 | mRippleTimeLast = 0.f; | 858 | mRippleTimeLast = 0.f; |
857 | 859 | ||
858 | mShadowImagep = gImageList.getImageFromFile("foot_shadow.j2c"); | 860 | mShadowImagep = gImageList.getImageFromFile("foot_shadow.j2c"); |
859 | gGL.getTexUnit(0)->bind(mShadowImagep.get()); | 861 | |
860 | mShadowImagep->setAddressMode(LLTexUnit::TAM_CLAMP); | 862 | // GL NOT ACTIVE HERE |
861 | 863 | //gGL.getTexUnit(0)->bind(mShadowImagep.get()); | |
864 | //mShadowImagep->setAddressMode(LLTexUnit::TAM_CLAMP); | ||
865 | |||
862 | mInAir = FALSE; | 866 | mInAir = FALSE; |
863 | 867 | ||
864 | mStepOnLand = TRUE; | 868 | mStepOnLand = TRUE; |
@@ -1295,7 +1299,7 @@ void LLVOAvatar::resetImpostors() | |||
1295 | // static | 1299 | // static |
1296 | void LLVOAvatar::deleteCachedImages(bool clearAll) | 1300 | void LLVOAvatar::deleteCachedImages(bool clearAll) |
1297 | { | 1301 | { |
1298 | if(gAuditTexture) | 1302 | /* if(gAuditTexture) |
1299 | { | 1303 | { |
1300 | S32 total_tex_size = sScratchTexBytes ; | 1304 | S32 total_tex_size = sScratchTexBytes ; |
1301 | S32 tex_size = SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT ; | 1305 | S32 tex_size = SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT ; |
@@ -1337,7 +1341,7 @@ if(gAuditTexture) | |||
1337 | total_tex_size -= 4 * tex_size ; | 1341 | total_tex_size -= 4 * tex_size ; |
1338 | } | 1342 | } |
1339 | } | 1343 | } |
1340 | 1344 | */ | |
1341 | if (LLTexLayerSet::sHasCaches) | 1345 | if (LLTexLayerSet::sHasCaches) |
1342 | { | 1346 | { |
1343 | lldebugs << "Deleting layer set caches" << llendl; | 1347 | lldebugs << "Deleting layer set caches" << llendl; |
@@ -1862,6 +1866,11 @@ BOOL LLVOAvatar::buildSkeleton(const LLVOAvatarSkeletonInfo *info) | |||
1862 | return TRUE; | 1866 | return TRUE; |
1863 | } | 1867 | } |
1864 | 1868 | ||
1869 | LLVOAvatar* LLVOAvatar::asAvatar() // KL SD | ||
1870 | { | ||
1871 | return this; | ||
1872 | } | ||
1873 | |||
1865 | //----------------------------------------------------------------------------- | 1874 | //----------------------------------------------------------------------------- |
1866 | // LLVOAvatar::startDefaultMotions() | 1875 | // LLVOAvatar::startDefaultMotions() |
1867 | //----------------------------------------------------------------------------- | 1876 | //----------------------------------------------------------------------------- |
@@ -1924,7 +1933,7 @@ void LLVOAvatar::buildCharacter() | |||
1924 | LLTimer timer; | 1933 | LLTimer timer; |
1925 | 1934 | ||
1926 | BOOL status = loadAvatar(); | 1935 | BOOL status = loadAvatar(); |
1927 | stop_glerror(); | 1936 | // stop_glerror(); |
1928 | 1937 | ||
1929 | if (gNoRender) | 1938 | if (gNoRender) |
1930 | { | 1939 | { |
@@ -2034,7 +2043,7 @@ void LLVOAvatar::buildCharacter() | |||
2034 | processAnimationStateChanges(); | 2043 | processAnimationStateChanges(); |
2035 | 2044 | ||
2036 | mIsBuilt = TRUE; | 2045 | mIsBuilt = TRUE; |
2037 | stop_glerror(); | 2046 | // stop_glerror(); |
2038 | 2047 | ||
2039 | //------------------------------------------------------------------------- | 2048 | //------------------------------------------------------------------------- |
2040 | // build the attach and detach menus | 2049 | // build the attach and detach menus |
@@ -5022,7 +5031,7 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color) | |||
5022 | //------------------------------------------------------------------------ | 5031 | //------------------------------------------------------------------------ |
5023 | // LLVOAvatar::updateTextures() | 5032 | // LLVOAvatar::updateTextures() |
5024 | //------------------------------------------------------------------------ | 5033 | //------------------------------------------------------------------------ |
5025 | void LLVOAvatar::updateTextures() | 5034 | void LLVOAvatar::updateTextures(LLAgent &agent) // KL SD version |
5026 | { | 5035 | { |
5027 | BOOL render_avatar = TRUE; | 5036 | BOOL render_avatar = TRUE; |
5028 | 5037 | ||
@@ -5041,6 +5050,7 @@ void LLVOAvatar::updateTextures() | |||
5041 | } | 5050 | } |
5042 | 5051 | ||
5043 | std::vector<bool> layer_baked; | 5052 | std::vector<bool> layer_baked; |
5053 | // GL NOT ACTIVE HERE - *TODO | ||
5044 | for (U32 i = 0; i < mBakedTextureData.size(); i++) | 5054 | for (U32 i = 0; i < mBakedTextureData.size(); i++) |
5045 | { | 5055 | { |
5046 | layer_baked.push_back(isTextureDefined(mBakedTextureData[i].mTextureIndex)); | 5056 | layer_baked.push_back(isTextureDefined(mBakedTextureData[i].mTextureIndex)); |
@@ -5123,12 +5133,6 @@ void LLVOAvatar::updateTextures() | |||
5123 | if (texture_dict->mIsLocalTexture) | 5133 | if (texture_dict->mIsLocalTexture) |
5124 | { | 5134 | { |
5125 | addLocalTextureStats((ETextureIndex)index, imagep, texel_area_ratio, render_avatar, layer_baked[baked_index]); | 5135 | addLocalTextureStats((ETextureIndex)index, imagep, texel_area_ratio, render_avatar, layer_baked[baked_index]); |
5126 | // SNOW-8 : temporary snowglobe1.0 fix for baked textures | ||
5127 | if (render_avatar && !gGLManager.mIsDisabled ) | ||
5128 | { | ||
5129 | // bind the texture so that its boost level won't be slammed | ||
5130 | gGL.getTexUnit(0)->bind(imagep); | ||
5131 | } | ||
5132 | } | 5136 | } |
5133 | else if (texture_dict->mIsBakedTexture) | 5137 | else if (texture_dict->mIsBakedTexture) |
5134 | { | 5138 | { |
@@ -5375,7 +5379,7 @@ void LLVOAvatar::processAnimationStateChanges() | |||
5375 | } | 5379 | } |
5376 | } | 5380 | } |
5377 | 5381 | ||
5378 | stop_glerror(); | 5382 | //stop_glerror(); |
5379 | } | 5383 | } |
5380 | 5384 | ||
5381 | 5385 | ||
@@ -6360,6 +6364,15 @@ LLDrawable *LLVOAvatar::createDrawable(LLPipeline *pipeline) | |||
6360 | } | 6364 | } |
6361 | 6365 | ||
6362 | 6366 | ||
6367 | void LLVOAvatar::updateGL() | ||
6368 | { | ||
6369 | if (mMeshTexturesDirty) | ||
6370 | { | ||
6371 | updateMeshTextures(); | ||
6372 | mMeshTexturesDirty = FALSE; | ||
6373 | } | ||
6374 | } | ||
6375 | |||
6363 | //----------------------------------------------------------------------------- | 6376 | //----------------------------------------------------------------------------- |
6364 | // updateGeometry() | 6377 | // updateGeometry() |
6365 | //----------------------------------------------------------------------------- | 6378 | //----------------------------------------------------------------------------- |
@@ -7396,12 +7409,20 @@ BOOL LLVOAvatar::bindScratchTexture( LLGLenum format ) | |||
7396 | if( *last_bind_time != LLImageGL::sLastFrameTime ) | 7409 | if( *last_bind_time != LLImageGL::sLastFrameTime ) |
7397 | { | 7410 | { |
7398 | *last_bind_time = LLImageGL::sLastFrameTime; | 7411 | *last_bind_time = LLImageGL::sLastFrameTime; |
7399 | LLImageGL::updateBoundTexMemStatic(texture_bytes, SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT, LLViewerImageBoostLevel::AVATAR_SCRATCH_TEX) ; | 7412 | // #if !LL_RELEASE_FOR_DOWNLOAD |
7413 | // LLImageGL::updateBoundTexMem(texture_bytes, SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT) ; | ||
7414 | // #else | ||
7415 | LLImageGL::updateBoundTexMem(texture_bytes); | ||
7416 | // #endif | ||
7400 | } | 7417 | } |
7401 | } | 7418 | } |
7402 | else | 7419 | else |
7403 | { | 7420 | { |
7404 | LLImageGL::updateBoundTexMemStatic(texture_bytes, SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT, LLViewerImageBoostLevel::AVATAR_SCRATCH_TEX) ; | 7421 | // #if !LL_RELEASE_FOR_DOWNLOAD |
7422 | // LLImageGL::updateBoundTexMem(texture_bytes, SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT) ; | ||
7423 | // #else | ||
7424 | LLImageGL::updateBoundTexMem(texture_bytes); | ||
7425 | // #endif | ||
7405 | LLVOAvatar::sScratchTexLastBindTime.addData( format, new F32(LLImageGL::sLastFrameTime) ); | 7426 | LLVOAvatar::sScratchTexLastBindTime.addData( format, new F32(LLImageGL::sLastFrameTime) ); |
7406 | } | 7427 | } |
7407 | 7428 | ||
@@ -7423,7 +7444,8 @@ LLGLuint LLVOAvatar::getScratchTexName( LLGLenum format, U32* texture_bytes ) | |||
7423 | { | 7444 | { |
7424 | case GL_LUMINANCE: components = 1; internal_format = GL_LUMINANCE8; break; | 7445 | case GL_LUMINANCE: components = 1; internal_format = GL_LUMINANCE8; break; |
7425 | case GL_ALPHA: components = 1; internal_format = GL_ALPHA8; break; | 7446 | case GL_ALPHA: components = 1; internal_format = GL_ALPHA8; break; |
7426 | case GL_COLOR_INDEX: components = 1; internal_format = GL_COLOR_INDEX8_EXT; break; | 7447 | // Support for GL_EXT_paletted_texture is deprecated |
7448 | // case GL_COLOR_INDEX: components = 1; internal_format = GL_COLOR_INDEX8_EXT; break; | ||
7427 | case GL_LUMINANCE_ALPHA: components = 2; internal_format = GL_LUMINANCE8_ALPHA8; break; | 7449 | case GL_LUMINANCE_ALPHA: components = 2; internal_format = GL_LUMINANCE8_ALPHA8; break; |
7428 | case GL_RGB: components = 3; internal_format = GL_RGB8; break; | 7450 | case GL_RGB: components = 3; internal_format = GL_RGB8; break; |
7429 | case GL_RGBA: components = 4; internal_format = GL_RGBA8; break; | 7451 | case GL_RGBA: components = 4; internal_format = GL_RGBA8; break; |
@@ -7465,11 +7487,11 @@ LLGLuint LLVOAvatar::getScratchTexName( LLGLenum format, U32* texture_bytes ) | |||
7465 | 7487 | ||
7466 | LLVOAvatar::sScratchTexBytes += *texture_bytes; | 7488 | LLVOAvatar::sScratchTexBytes += *texture_bytes; |
7467 | LLImageGL::sGlobalTextureMemoryInBytes += *texture_bytes; | 7489 | LLImageGL::sGlobalTextureMemoryInBytes += *texture_bytes; |
7468 | 7490 | /* | |
7469 | if(gAuditTexture) | 7491 | if(gAuditTexture) |
7470 | { | 7492 | { |
7471 | LLImageGL::incTextureCounterStatic(SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT, components, LLViewerImageBoostLevel::AVATAR_SCRATCH_TEX) ; | 7493 | LLImageGL::incTextureCounterStatic(SCRATCH_TEX_WIDTH * SCRATCH_TEX_HEIGHT, components, LLViewerImageBoostLevel::AVATAR_SCRATCH_TEX) ; |
7472 | } | 7494 | }*/ |
7473 | 7495 | ||
7474 | return name; | 7496 | return name; |
7475 | } | 7497 | } |
@@ -7572,6 +7594,7 @@ void LLVOAvatar::updateMeshTextures() | |||
7572 | use_lkg_baked_layer[i] = (!is_layer_baked[i] | 7594 | use_lkg_baked_layer[i] = (!is_layer_baked[i] |
7573 | && (mBakedTextureData[i].mLastTextureIndex != IMG_DEFAULT_AVATAR) | 7595 | && (mBakedTextureData[i].mLastTextureIndex != IMG_DEFAULT_AVATAR) |
7574 | && mBakedTextureData[i].mTexLayerSet | 7596 | && mBakedTextureData[i].mTexLayerSet |
7597 | && mBakedTextureData[i].mTexLayerSet->getComposite() // KL SD | ||
7575 | && !mBakedTextureData[i].mTexLayerSet->getComposite()->isInitialized()); | 7598 | && !mBakedTextureData[i].mTexLayerSet->getComposite()->isInitialized()); |
7576 | if (use_lkg_baked_layer[i]) | 7599 | if (use_lkg_baked_layer[i]) |
7577 | { | 7600 | { |
@@ -7605,7 +7628,7 @@ void LLVOAvatar::updateMeshTextures() | |||
7605 | if (use_lkg_baked_layer[i] && !self_customizing ) | 7628 | if (use_lkg_baked_layer[i] && !self_customizing ) |
7606 | { | 7629 | { |
7607 | LLViewerImage* baked_img = gImageList.getImageFromHost( mBakedTextureData[i].mLastTextureIndex, target_host ); | 7630 | LLViewerImage* baked_img = gImageList.getImageFromHost( mBakedTextureData[i].mLastTextureIndex, target_host ); |
7608 | mBakedTextureData[i].mIsUsed = TRUE; | 7631 | //mBakedTextureData[i].mIsUsed = TRUE; |
7609 | for (U32 k=0; k < mBakedTextureData[i].mMeshes.size(); k++) | 7632 | for (U32 k=0; k < mBakedTextureData[i].mMeshes.size(); k++) |
7610 | { | 7633 | { |
7611 | mBakedTextureData[i].mMeshes[k]->setTexture( baked_img ); | 7634 | mBakedTextureData[i].mMeshes[k]->setTexture( baked_img ); |
@@ -7635,7 +7658,7 @@ void LLVOAvatar::updateMeshTextures() | |||
7635 | { | 7658 | { |
7636 | mBakedTextureData[i].mTexLayerSet->createComposite(); | 7659 | mBakedTextureData[i].mTexLayerSet->createComposite(); |
7637 | mBakedTextureData[i].mTexLayerSet->setUpdatesEnabled( TRUE ); | 7660 | mBakedTextureData[i].mTexLayerSet->setUpdatesEnabled( TRUE ); |
7638 | mBakedTextureData[i].mIsUsed = FALSE; | 7661 | // mBakedTextureData[i].mIsUsed = FALSE; |
7639 | for (U32 k=0; k < mBakedTextureData[i].mMeshes.size(); k++) | 7662 | for (U32 k=0; k < mBakedTextureData[i].mMeshes.size(); k++) |
7640 | { | 7663 | { |
7641 | mBakedTextureData[i].mMeshes[k]->setLayerSet( mBakedTextureData[i].mTexLayerSet ); | 7664 | mBakedTextureData[i].mMeshes[k]->setLayerSet( mBakedTextureData[i].mTexLayerSet ); |
@@ -7656,9 +7679,13 @@ void LLVOAvatar::updateMeshTextures() | |||
7656 | mBakedTextureData[BAKED_HAIR].mMeshes[i]->setTexture( hair_img ); | 7679 | mBakedTextureData[BAKED_HAIR].mMeshes[i]->setTexture( hair_img ); |
7657 | } | 7680 | } |
7658 | mHasBakedHair = FALSE; | 7681 | mHasBakedHair = FALSE; |
7659 | } | 7682 | } |
7660 | else | 7683 | else |
7661 | { | 7684 | { |
7685 | for (U32 i = 0; i < mBakedTextureData[BAKED_HAIR].mMeshes.size(); i++) | ||
7686 | { | ||
7687 | mBakedTextureData[BAKED_HAIR].mMeshes[i]->setColor( 1.f, 1.f, 1.f, 1.f ); | ||
7688 | } | ||
7662 | mHasBakedHair = TRUE; | 7689 | mHasBakedHair = TRUE; |
7663 | } | 7690 | } |
7664 | 7691 | ||
@@ -7790,7 +7817,7 @@ void LLVOAvatar::clearChat() | |||
7790 | S32 LLVOAvatar::getLocalDiscardLevel( ETextureIndex index ) | 7817 | S32 LLVOAvatar::getLocalDiscardLevel( ETextureIndex index ) |
7791 | { | 7818 | { |
7792 | // If the texture is not local, we don't care and treat it as fully loaded | 7819 | // If the texture is not local, we don't care and treat it as fully loaded |
7793 | if (!isIndexLocalTexture(index)) return 0; | 7820 | if (!isIndexLocalTexture(index)) return FALSE; // KL SD version |
7794 | 7821 | ||
7795 | LocalTextureData &local_tex_data = mLocalTextureData[index]; | 7822 | LocalTextureData &local_tex_data = mLocalTextureData[index]; |
7796 | if (index >= 0 | 7823 | if (index >= 0 |
@@ -7932,7 +7959,7 @@ bool LLVOAvatar::hasPendingBakedUploads() | |||
7932 | { | 7959 | { |
7933 | for (U32 i = 0; i < mBakedTextureData.size(); i++) | 7960 | for (U32 i = 0; i < mBakedTextureData.size(); i++) |
7934 | { | 7961 | { |
7935 | bool upload_pending = (mBakedTextureData[i].mTexLayerSet && mBakedTextureData[i].mTexLayerSet->getComposite()->uploadPending()); | 7962 | bool upload_pending = (mBakedTextureData[i].mTexLayerSet && mBakedTextureData[i].mTexLayerSet->getComposite() && mBakedTextureData[i].mTexLayerSet->getComposite()->uploadPending()); |
7936 | if (upload_pending) | 7963 | if (upload_pending) |
7937 | { | 7964 | { |
7938 | return true; | 7965 | return true; |
@@ -8467,7 +8494,8 @@ void LLVOAvatar::onFirstTEMessageReceived() | |||
8467 | } | 8494 | } |
8468 | } | 8495 | } |
8469 | 8496 | ||
8470 | updateMeshTextures(); | 8497 | mMeshTexturesDirty = TRUE; // updateMeshTextures(); |
8498 | gPipeline.markGLRebuild(this); | ||
8471 | } | 8499 | } |
8472 | } | 8500 | } |
8473 | 8501 | ||
@@ -8530,20 +8558,22 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) | |||
8530 | // (isTextureDefined(TEX_SKIRT_BAKED) ? "SKIRT " : "skirt " ) << (getTEImage(TEX_SKIRT_BAKED)->getID()) << std::endl << | 8558 | // (isTextureDefined(TEX_SKIRT_BAKED) ? "SKIRT " : "skirt " ) << (getTEImage(TEX_SKIRT_BAKED)->getID()) << std::endl << |
8531 | // (isTextureDefined(TEX_HAIR_BAKED) ? "HAIR" : "hair " ) << (getTEImage(TEX_HAIR_BAKED)->getID()) << std::endl << | 8559 | // (isTextureDefined(TEX_HAIR_BAKED) ? "HAIR" : "hair " ) << (getTEImage(TEX_HAIR_BAKED)->getID()) << std::endl << |
8532 | // (isTextureDefined(TEX_EYES_BAKED) ? "EYES" : "eyes" ) << (getTEImage(TEX_EYES_BAKED)->getID()) << llendl ; | 8560 | // (isTextureDefined(TEX_EYES_BAKED) ? "EYES" : "eyes" ) << (getTEImage(TEX_EYES_BAKED)->getID()) << llendl ; |
8533 | 8561 | ||
8534 | if( !mFirstTEMessageReceived ) | 8562 | if( !mFirstTEMessageReceived ) |
8535 | { | 8563 | { |
8536 | onFirstTEMessageReceived(); | 8564 | onFirstTEMessageReceived(); |
8537 | } | 8565 | } |
8538 | 8566 | ||
8539 | setCompositeUpdatesEnabled( FALSE ); | 8567 | setCompositeUpdatesEnabled( FALSE ); |
8568 | mMeshTexturesDirty = TRUE; | ||
8569 | gPipeline.markGLRebuild(this); // KL SD needing work in S19? | ||
8540 | 8570 | ||
8541 | if (!mIsSelf) | 8571 | if (!mIsSelf) |
8542 | { | 8572 | { |
8543 | releaseUnnecessaryTextures(); | 8573 | releaseUnnecessaryTextures(); |
8544 | } | 8574 | } |
8545 | 8575 | ||
8546 | updateMeshTextures(); // enables updates for laysets without baked textures. | 8576 | //updateMeshTextures(); // enables updates for laysets without baked textures. |
8547 | 8577 | ||
8548 | // parse visual params | 8578 | // parse visual params |
8549 | S32 num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_VisualParam); | 8579 | S32 num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_VisualParam); |
@@ -8829,7 +8859,7 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id ) | |||
8829 | if (id == image_baked->getID()) | 8859 | if (id == image_baked->getID()) |
8830 | { | 8860 | { |
8831 | mBakedTextureData[i].mIsLoaded = true; | 8861 | mBakedTextureData[i].mIsLoaded = true; |
8832 | mBakedTextureData[i].mIsUsed = true; | 8862 | //mBakedTextureData[i].mIsUsed = true; |
8833 | mBakedTextureData[i].mLastTextureIndex = id; | 8863 | mBakedTextureData[i].mLastTextureIndex = id; |
8834 | for (U32 k = 0; k < mBakedTextureData[i].mMeshes.size(); k++) | 8864 | for (U32 k = 0; k < mBakedTextureData[i].mMeshes.size(); k++) |
8835 | { | 8865 | { |
@@ -9738,9 +9768,9 @@ BOOL LLVOAvatar::updateLOD() | |||
9738 | 9768 | ||
9739 | LLFace* facep = mDrawable->getFace(0); | 9769 | LLFace* facep = mDrawable->getFace(0); |
9740 | if (facep->mVertexBuffer.isNull() || | 9770 | if (facep->mVertexBuffer.isNull() || |
9741 | LLVertexBuffer::sEnableVBOs && | 9771 | (LLVertexBuffer::sEnableVBOs && |
9742 | ((facep->mVertexBuffer->getUsage() == GL_STATIC_DRAW ? TRUE : FALSE) != | 9772 | ((facep->mVertexBuffer->getUsage() == GL_STATIC_DRAW ? TRUE : FALSE) != |
9743 | (facep->getPool()->getVertexShaderLevel() > 0 ? TRUE : FALSE))) | 9773 | (facep->getPool()->getVertexShaderLevel() > 0 ? TRUE : FALSE)))) |
9744 | { | 9774 | { |
9745 | mDirtyMesh = TRUE; | 9775 | mDirtyMesh = TRUE; |
9746 | } | 9776 | } |
diff --git a/linden/indra/newview/llvoavatar.h b/linden/indra/newview/llvoavatar.h index 0c32244..ff07d81 100644 --- a/linden/indra/newview/llvoavatar.h +++ b/linden/indra/newview/llvoavatar.h | |||
@@ -88,6 +88,8 @@ public: | |||
88 | /*virtual*/ void markDead(); | 88 | /*virtual*/ void markDead(); |
89 | void startDefaultMotions(); | 89 | void startDefaultMotions(); |
90 | 90 | ||
91 | /*virtual*/ LLVOAvatar* asAvatar(); // KL SD | ||
92 | |||
91 | static void updateImpostors(); | 93 | static void updateImpostors(); |
92 | 94 | ||
93 | //-------------------------------------------------------------------- | 95 | //-------------------------------------------------------------------- |
@@ -137,7 +139,7 @@ public: | |||
137 | LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point | 139 | LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point |
138 | ); | 140 | ); |
139 | 141 | ||
140 | /*virtual*/ void updateTextures(); | 142 | /*virtual*/ void updateTextures(LLAgent &agent); // KL SD |
141 | // If setting a baked texture, need to request it from a non-local sim. | 143 | // If setting a baked texture, need to request it from a non-local sim. |
142 | /*virtual*/ S32 setTETexture(const U8 te, const LLUUID& uuid); | 144 | /*virtual*/ S32 setTETexture(const U8 te, const LLUUID& uuid); |
143 | /*virtual*/ void onShift(const LLVector3& shift_vector); | 145 | /*virtual*/ void onShift(const LLVector3& shift_vector); |
@@ -155,6 +157,8 @@ public: | |||
155 | 157 | ||
156 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 158 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
157 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 159 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
160 | /*virtual*/ void updateGL(); | ||
161 | |||
158 | 162 | ||
159 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); | 163 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); |
160 | BOOL updateJointLODs(); | 164 | BOOL updateJointLODs(); |
@@ -474,6 +478,7 @@ private: | |||
474 | LLFrameTimer mTypingTimer; | 478 | LLFrameTimer mTypingTimer; |
475 | 479 | ||
476 | //-------------------------------------------------------------------- | 480 | //-------------------------------------------------------------------- |
481 | BOOL mMeshTexturesDirty; | ||
477 | // wind rippling in clothes | 482 | // wind rippling in clothes |
478 | //-------------------------------------------------------------------- | 483 | //-------------------------------------------------------------------- |
479 | public: | 484 | public: |
@@ -570,6 +575,7 @@ public: | |||
570 | static BOOL sShowAnimationDebug; // show animation debug info | 575 | static BOOL sShowAnimationDebug; // show animation debug info |
571 | static BOOL sUseImpostors; //use impostors for far away avatars | 576 | static BOOL sUseImpostors; //use impostors for far away avatars |
572 | static BOOL sShowFootPlane; // show foot collision plane reported by server | 577 | static BOOL sShowFootPlane; // show foot collision plane reported by server |
578 | static BOOL sShowCollisionVolumes; // show skeletal collision volumes // KL SD | ||
573 | static BOOL sVisibleInFirstPerson; | 579 | static BOOL sVisibleInFirstPerson; |
574 | static S32 sNumLODChangesThisFrame; | 580 | static S32 sNumLODChangesThisFrame; |
575 | static S32 sNumVisibleChatBubbles; | 581 | static S32 sNumVisibleChatBubbles; |
@@ -771,7 +777,7 @@ private: | |||
771 | LLUUID mLastTextureIndex; | 777 | LLUUID mLastTextureIndex; |
772 | LLTexLayerSet* mTexLayerSet; | 778 | LLTexLayerSet* mTexLayerSet; |
773 | bool mIsLoaded; | 779 | bool mIsLoaded; |
774 | bool mIsUsed; | 780 | //bool mIsUsed; // KL SG |
775 | LLVOAvatarDefines::ETextureIndex mTextureIndex; | 781 | LLVOAvatarDefines::ETextureIndex mTextureIndex; |
776 | U32 mMaskTexName; | 782 | U32 mMaskTexName; |
777 | // Stores pointers to the joint meshes that this baked texture deals with | 783 | // Stores pointers to the joint meshes that this baked texture deals with |
diff --git a/linden/indra/newview/llvoclouds.cpp b/linden/indra/newview/llvoclouds.cpp index a489f91..019b6b4 100644 --- a/linden/indra/newview/llvoclouds.cpp +++ b/linden/indra/newview/llvoclouds.cpp | |||
@@ -101,7 +101,7 @@ void LLVOClouds::setPixelAreaAndAngle(LLAgent &agent) | |||
101 | mPixelArea = 1500*100; | 101 | mPixelArea = 1500*100; |
102 | } | 102 | } |
103 | 103 | ||
104 | void LLVOClouds::updateTextures() | 104 | void LLVOClouds::updateTextures(LLAgent &agent) |
105 | { | 105 | { |
106 | getTEImage(0)->addTextureStats(mPixelArea); | 106 | getTEImage(0)->addTextureStats(mPixelArea); |
107 | } | 107 | } |
@@ -123,7 +123,10 @@ BOOL LLVOClouds::updateGeometry(LLDrawable *drawable) | |||
123 | return TRUE; | 123 | return TRUE; |
124 | } | 124 | } |
125 | 125 | ||
126 | dirtySpatialGroup(); | 126 | if (drawable->isVisible()) |
127 | { | ||
128 | dirtySpatialGroup(TRUE); | ||
129 | } | ||
127 | 130 | ||
128 | LLFace *facep; | 131 | LLFace *facep; |
129 | 132 | ||
diff --git a/linden/indra/newview/llvoclouds.h b/linden/indra/newview/llvoclouds.h index 52e5a68..f70ea5b 100644 --- a/linden/indra/newview/llvoclouds.h +++ b/linden/indra/newview/llvoclouds.h | |||
@@ -65,7 +65,7 @@ public: | |||
65 | /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. | 65 | /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. |
66 | F32 getPartSize(S32 idx); | 66 | F32 getPartSize(S32 idx); |
67 | 67 | ||
68 | /*virtual*/ void updateTextures(); | 68 | /*virtual*/ void updateTextures(LLAgent &agent); |
69 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area | 69 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area |
70 | 70 | ||
71 | void updateFaceSize(S32 idx) { } | 71 | void updateFaceSize(S32 idx) { } |
diff --git a/linden/indra/newview/llvograss.cpp b/linden/indra/newview/llvograss.cpp index 08f2717..c56d676 100644 --- a/linden/indra/newview/llvograss.cpp +++ b/linden/indra/newview/llvograss.cpp | |||
@@ -331,7 +331,7 @@ void LLVOGrass::setPixelAreaAndAngle(LLAgent &agent) | |||
331 | 331 | ||
332 | 332 | ||
333 | // BUG could speed this up by caching the relative_position and range calculations | 333 | // BUG could speed this up by caching the relative_position and range calculations |
334 | void LLVOGrass::updateTextures() | 334 | void LLVOGrass::updateTextures(LLAgent &agent) |
335 | { | 335 | { |
336 | if (getTEImage(0)) | 336 | if (getTEImage(0)) |
337 | { | 337 | { |
diff --git a/linden/indra/newview/llvograss.h b/linden/indra/newview/llvograss.h index 682fbdb..c55c59b 100644 --- a/linden/indra/newview/llvograss.h +++ b/linden/indra/newview/llvograss.h | |||
@@ -72,7 +72,7 @@ public: | |||
72 | LLStrider<U16>& indicesp); | 72 | LLStrider<U16>& indicesp); |
73 | 73 | ||
74 | void updateFaceSize(S32 idx) { } | 74 | void updateFaceSize(S32 idx) { } |
75 | /*virtual*/ void updateTextures(); | 75 | /*virtual*/ void updateTextures(LLAgent &agent); |
76 | /*virtual*/ BOOL updateLOD(); | 76 | /*virtual*/ BOOL updateLOD(); |
77 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area | 77 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area |
78 | 78 | ||
diff --git a/linden/indra/newview/llvoground.cpp b/linden/indra/newview/llvoground.cpp index 0ef0196..fe19e18 100644 --- a/linden/indra/newview/llvoground.cpp +++ b/linden/indra/newview/llvoground.cpp | |||
@@ -71,7 +71,7 @@ BOOL LLVOGround::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | void LLVOGround::updateTextures() | 74 | void LLVOGround::updateTextures(LLAgent &agent) |
75 | { | 75 | { |
76 | } | 76 | } |
77 | 77 | ||
diff --git a/linden/indra/newview/llvoground.h b/linden/indra/newview/llvoground.h index b58ebae..f485bd0 100644 --- a/linden/indra/newview/llvoground.h +++ b/linden/indra/newview/llvoground.h | |||
@@ -51,7 +51,7 @@ public: | |||
51 | 51 | ||
52 | // Graphical stuff for objects - maybe broken out into render class | 52 | // Graphical stuff for objects - maybe broken out into render class |
53 | // later? | 53 | // later? |
54 | /*virtual*/ void updateTextures(); | 54 | /*virtual*/ void updateTextures(LLAgent &agent); |
55 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 55 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
56 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 56 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
57 | 57 | ||
diff --git a/linden/indra/newview/llvopartgroup.cpp b/linden/indra/newview/llvopartgroup.cpp index a0f8068..b040366 100644 --- a/linden/indra/newview/llvopartgroup.cpp +++ b/linden/indra/newview/llvopartgroup.cpp | |||
@@ -108,7 +108,7 @@ void LLVOPartGroup::setPixelAreaAndAngle(LLAgent &agent) | |||
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | void LLVOPartGroup::updateTextures() | 111 | void LLVOPartGroup::updateTextures(LLAgent &agent) |
112 | { | 112 | { |
113 | // Texture stats for particles need to be updated in a different way... | 113 | // Texture stats for particles need to be updated in a different way... |
114 | } | 114 | } |
@@ -154,6 +154,11 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) | |||
154 | group = drawable->getSpatialGroup(); | 154 | group = drawable->getSpatialGroup(); |
155 | } | 155 | } |
156 | 156 | ||
157 | if (group && group->isVisible()) | ||
158 | { | ||
159 | dirtySpatialGroup(TRUE); | ||
160 | } | ||
161 | |||
157 | if (!num_parts) | 162 | if (!num_parts) |
158 | { | 163 | { |
159 | if (group && drawable->getNumFaces()) | 164 | if (group && drawable->getNumFaces()) |
@@ -186,13 +191,12 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) | |||
186 | S32 count=0; | 191 | S32 count=0; |
187 | mDepth = 0.f; | 192 | mDepth = 0.f; |
188 | S32 i = 0 ; | 193 | S32 i = 0 ; |
189 | LLVector3 camera_agent = getCameraPosition(); | ||
190 | for (i = 0 ; i < (S32)mViewerPartGroupp->mParticles.size(); i++) | 194 | for (i = 0 ; i < (S32)mViewerPartGroupp->mParticles.size(); i++) |
191 | { | 195 | { |
192 | const LLViewerPart *part = mViewerPartGroupp->mParticles[i]; | 196 | const LLViewerPart *part = mViewerPartGroupp->mParticles[i]; |
193 | 197 | ||
194 | LLVector3 part_pos_agent(part->mPosAgent); | 198 | LLVector3 part_pos_agent(part->mPosAgent); |
195 | LLVector3 at(part_pos_agent - camera_agent); | 199 | LLVector3 at(part_pos_agent - LLViewerCamera::getInstance()->getOrigin()); |
196 | 200 | ||
197 | F32 camera_dist_squared = at.lengthSquared(); | 201 | F32 camera_dist_squared = at.lengthSquared(); |
198 | F32 inv_camera_dist_squared; | 202 | F32 inv_camera_dist_squared; |
@@ -315,7 +319,7 @@ void LLVOPartGroup::getGeometry(S32 idx, | |||
315 | up *= 0.5f*part.mScale.mV[1]; | 319 | up *= 0.5f*part.mScale.mV[1]; |
316 | 320 | ||
317 | 321 | ||
318 | LLVector3 normal = -LLViewerCamera::getInstance()->getXAxis(); | 322 | const LLVector3& normal = -LLViewerCamera::getInstance()->getXAxis(); |
319 | 323 | ||
320 | *verticesp++ = part_pos_agent + up - right; | 324 | *verticesp++ = part_pos_agent + up - right; |
321 | *verticesp++ = part_pos_agent - up - right; | 325 | *verticesp++ = part_pos_agent - up - right; |
@@ -352,12 +356,12 @@ U32 LLVOPartGroup::getPartitionType() const | |||
352 | } | 356 | } |
353 | 357 | ||
354 | LLParticlePartition::LLParticlePartition() | 358 | LLParticlePartition::LLParticlePartition() |
355 | : LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK) | 359 | : LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB) |
356 | { | 360 | { |
357 | mRenderPass = LLRenderPass::PASS_ALPHA; | 361 | mRenderPass = LLRenderPass::PASS_ALPHA; |
358 | mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; | 362 | mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; |
359 | mPartitionType = LLViewerRegion::PARTITION_PARTICLE; | 363 | mPartitionType = LLViewerRegion::PARTITION_PARTICLE; |
360 | mBufferUsage = GL_DYNAMIC_DRAW_ARB; | 364 | // mBufferUsage = GL_DYNAMIC_DRAW_ARB; // KL SD hybrid code |
361 | mSlopRatio = 0.f; | 365 | mSlopRatio = 0.f; |
362 | mLODPeriod = 1; | 366 | mLODPeriod = 1; |
363 | } | 367 | } |
@@ -481,7 +485,9 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group) | |||
481 | U32 end = start + facep->getGeomCount()-1; | 485 | U32 end = start + facep->getGeomCount()-1; |
482 | U32 offset = facep->getIndicesStart(); | 486 | U32 offset = facep->getIndicesStart(); |
483 | U32 count = facep->getIndicesCount(); | 487 | U32 count = facep->getIndicesCount(); |
484 | LLDrawInfo* info = new LLDrawInfo(start,end,count,offset,facep->getTexture(), buffer, fullbright); | 488 | LLDrawInfo* info = new LLDrawInfo(start,end,count,offset,facep->getTexture(), |
489 | facep->getTexture(), | ||
490 | buffer, fullbright); | ||
485 | info->mExtents[0] = group->mObjectExtents[0]; | 491 | info->mExtents[0] = group->mObjectExtents[0]; |
486 | info->mExtents[1] = group->mObjectExtents[1]; | 492 | info->mExtents[1] = group->mObjectExtents[1]; |
487 | info->mVSize = vsize; | 493 | info->mVSize = vsize; |
diff --git a/linden/indra/newview/llvopartgroup.h b/linden/indra/newview/llvopartgroup.h index 18583b4..3dc3292 100644 --- a/linden/indra/newview/llvopartgroup.h +++ b/linden/indra/newview/llvopartgroup.h | |||
@@ -61,7 +61,7 @@ public: | |||
61 | virtual U32 getPartitionType() const; | 61 | virtual U32 getPartitionType() const; |
62 | 62 | ||
63 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); | 63 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); |
64 | /*virtual*/ void updateTextures(); | 64 | /*virtual*/ void updateTextures(LLAgent &agent); |
65 | 65 | ||
66 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 66 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
67 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 67 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
diff --git a/linden/indra/newview/llvosky.cpp b/linden/indra/newview/llvosky.cpp index d15a2dc..2200c02 100644 --- a/linden/indra/newview/llvosky.cpp +++ b/linden/indra/newview/llvosky.cpp | |||
@@ -289,7 +289,7 @@ void LLSkyTex::create(const F32 brightness) | |||
289 | 289 | ||
290 | void LLSkyTex::createGLImage(S32 which) | 290 | void LLSkyTex::createGLImage(S32 which) |
291 | { | 291 | { |
292 | mImageGL[which]->createGLTexture(0, mImageRaw[which], 0, TRUE, LLViewerImageBoostLevel::OTHER); | 292 | mImageGL[which]->createGLTexture(0, mImageRaw[which]); |
293 | mImageGL[which]->setAddressMode(LLTexUnit::TAM_CLAMP); | 293 | mImageGL[which]->setAddressMode(LLTexUnit::TAM_CLAMP); |
294 | } | 294 | } |
295 | 295 | ||
@@ -1095,10 +1095,10 @@ BOOL LLVOSky::updateSky() | |||
1095 | mLastTotalAmbient.mV[2] - mTotalAmbient.mV[2]); | 1095 | mLastTotalAmbient.mV[2] - mTotalAmbient.mV[2]); |
1096 | 1096 | ||
1097 | if ( mForceUpdate | 1097 | if ( mForceUpdate |
1098 | || ((dot_lighting < LIGHT_DIRECTION_THRESHOLD) | 1098 | || (((dot_lighting < LIGHT_DIRECTION_THRESHOLD) |
1099 | || (delta_color.length() > COLOR_CHANGE_THRESHOLD) | 1099 | || (delta_color.length() > COLOR_CHANGE_THRESHOLD) |
1100 | || !mInitialized) | 1100 | || !mInitialized) |
1101 | && !direction.isExactlyZero()) | 1101 | && !direction.isExactlyZero())) |
1102 | { | 1102 | { |
1103 | mLastLightingDirection = direction; | 1103 | mLastLightingDirection = direction; |
1104 | mLastTotalAmbient = mTotalAmbient; | 1104 | mLastTotalAmbient = mTotalAmbient; |
@@ -1180,7 +1180,7 @@ BOOL LLVOSky::updateSky() | |||
1180 | return TRUE; | 1180 | return TRUE; |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | void LLVOSky::updateTextures() | 1183 | void LLVOSky::updateTextures(LLAgent &agent) |
1184 | { | 1184 | { |
1185 | if (mSunTexturep) | 1185 | if (mSunTexturep) |
1186 | { | 1186 | { |
diff --git a/linden/indra/newview/llvosky.h b/linden/indra/newview/llvosky.h index dabf5b1..5e23065 100644 --- a/linden/indra/newview/llvosky.h +++ b/linden/indra/newview/llvosky.h | |||
@@ -147,7 +147,7 @@ protected: | |||
147 | 147 | ||
148 | static S32 getResolution() { return sResolution; } | 148 | static S32 getResolution() { return sResolution; } |
149 | static S32 getCurrent() { return sCurrent; } | 149 | static S32 getCurrent() { return sCurrent; } |
150 | static S32 stepCurrent() { sCurrent++; sCurrent&=1; return sCurrent; } | 150 | static S32 stepCurrent() { return (sCurrent = ++sCurrent % 2); } |
151 | static S32 getNext() { return ((sCurrent+1) % 2); } | 151 | static S32 getNext() { return ((sCurrent+1) % 2); } |
152 | static S32 getWhich(const BOOL curr) { return curr ? sCurrent : getNext(); } | 152 | static S32 getWhich(const BOOL curr) { return curr ? sCurrent : getNext(); } |
153 | 153 | ||
@@ -492,7 +492,7 @@ public: | |||
492 | 492 | ||
493 | // Graphical stuff for objects - maybe broken out into render class | 493 | // Graphical stuff for objects - maybe broken out into render class |
494 | // later? | 494 | // later? |
495 | /*virtual*/ void updateTextures(); | 495 | /*virtual*/ void updateTextures(LLAgent &agent); |
496 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 496 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
497 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 497 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
498 | 498 | ||
diff --git a/linden/indra/newview/llvosurfacepatch.cpp b/linden/indra/newview/llvosurfacepatch.cpp index d86f758..a6fc125 100644 --- a/linden/indra/newview/llvosurfacepatch.cpp +++ b/linden/indra/newview/llvosurfacepatch.cpp | |||
@@ -134,7 +134,7 @@ void LLVOSurfacePatch::setPixelAreaAndAngle(LLAgent &agent) | |||
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | void LLVOSurfacePatch::updateTextures() | 137 | void LLVOSurfacePatch::updateTextures(LLAgent &agent) |
138 | { | 138 | { |
139 | } | 139 | } |
140 | 140 | ||
@@ -177,11 +177,19 @@ LLDrawable *LLVOSurfacePatch::createDrawable(LLPipeline *pipeline) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | void LLVOSurfacePatch::updateGL() | ||
181 | { | ||
182 | if (mPatchp) | ||
183 | { | ||
184 | mPatchp->updateGL(); | ||
185 | } | ||
186 | } | ||
187 | |||
180 | BOOL LLVOSurfacePatch::updateGeometry(LLDrawable *drawable) | 188 | BOOL LLVOSurfacePatch::updateGeometry(LLDrawable *drawable) |
181 | { | 189 | { |
182 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_TERRAIN); | 190 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_TERRAIN); |
183 | 191 | ||
184 | dirtySpatialGroup(); | 192 | dirtySpatialGroup(TRUE); |
185 | 193 | ||
186 | S32 min_comp, max_comp, range; | 194 | S32 min_comp, max_comp, range; |
187 | min_comp = lltrunc(mPatchp->getMinComposition()); | 195 | min_comp = lltrunc(mPatchp->getMinComposition()); |
@@ -1013,12 +1021,12 @@ U32 LLVOSurfacePatch::getPartitionType() const | |||
1013 | } | 1021 | } |
1014 | 1022 | ||
1015 | LLTerrainPartition::LLTerrainPartition() | 1023 | LLTerrainPartition::LLTerrainPartition() |
1016 | : LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK) | 1024 | : LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK, FALSE, GL_DYNAMIC_DRAW_ARB) |
1017 | { | 1025 | { |
1018 | mOcclusionEnabled = FALSE; | 1026 | mOcclusionEnabled = FALSE; |
1019 | mRenderByGroup = FALSE; | 1027 | //mRenderByGroup = FALSE; // KL not for SD hybrid code |
1020 | mInfiniteFarClip = TRUE; | 1028 | mInfiniteFarClip = TRUE; |
1021 | mBufferUsage = GL_DYNAMIC_DRAW_ARB; | 1029 | //mBufferUsage = GL_DYNAMIC_DRAW_ARB; // and here too! |
1022 | mDrawableType = LLPipeline::RENDER_TYPE_TERRAIN; | 1030 | mDrawableType = LLPipeline::RENDER_TYPE_TERRAIN; |
1023 | mPartitionType = LLViewerRegion::PARTITION_TERRAIN; | 1031 | mPartitionType = LLViewerRegion::PARTITION_TERRAIN; |
1024 | } | 1032 | } |
diff --git a/linden/indra/newview/llvosurfacepatch.h b/linden/indra/newview/llvosurfacepatch.h index d3b1447..aaf4d41 100644 --- a/linden/indra/newview/llvosurfacepatch.h +++ b/linden/indra/newview/llvosurfacepatch.h | |||
@@ -64,6 +64,7 @@ public: | |||
64 | virtual U32 getPartitionType() const; | 64 | virtual U32 getPartitionType() const; |
65 | 65 | ||
66 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 66 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
67 | /*virtual*/ void updateGL(); | ||
67 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 68 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
68 | /*virtual*/ BOOL updateLOD(); | 69 | /*virtual*/ BOOL updateLOD(); |
69 | /*virtual*/ void updateFaceSize(S32 idx); | 70 | /*virtual*/ void updateFaceSize(S32 idx); |
@@ -74,7 +75,7 @@ public: | |||
74 | LLStrider<LLVector2> &texCoords1p, | 75 | LLStrider<LLVector2> &texCoords1p, |
75 | LLStrider<U16> &indicesp); | 76 | LLStrider<U16> &indicesp); |
76 | 77 | ||
77 | /*virtual*/ void updateTextures(); | 78 | /*virtual*/ void updateTextures(LLAgent &agent); |
78 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area | 79 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area |
79 | 80 | ||
80 | /*virtual*/ void updateSpatialExtents(LLVector3& newMin, LLVector3& newMax); | 81 | /*virtual*/ void updateSpatialExtents(LLVector3& newMin, LLVector3& newMax); |
diff --git a/linden/indra/newview/llvotextbubble.cpp b/linden/indra/newview/llvotextbubble.cpp index 5943f9b..de69aac 100644 --- a/linden/indra/newview/llvotextbubble.cpp +++ b/linden/indra/newview/llvotextbubble.cpp | |||
@@ -116,7 +116,7 @@ BOOL LLVOTextBubble::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | void LLVOTextBubble::updateTextures() | 119 | void LLVOTextBubble::updateTextures(LLAgent &agent) |
120 | { | 120 | { |
121 | // Update the image levels of all textures... | 121 | // Update the image levels of all textures... |
122 | 122 | ||
diff --git a/linden/indra/newview/llvotextbubble.h b/linden/indra/newview/llvotextbubble.h index 7f84dbf..45d4df2 100644 --- a/linden/indra/newview/llvotextbubble.h +++ b/linden/indra/newview/llvotextbubble.h | |||
@@ -44,7 +44,7 @@ public: | |||
44 | /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. | 44 | /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. |
45 | /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); | 45 | /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); |
46 | 46 | ||
47 | /*virtual*/ void updateTextures(); | 47 | /*virtual*/ void updateTextures(LLAgent &agent); |
48 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 48 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
49 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 49 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
50 | /*virtual*/ BOOL updateLOD(); | 50 | /*virtual*/ BOOL updateLOD(); |
diff --git a/linden/indra/newview/llvotree.cpp b/linden/indra/newview/llvotree.cpp index 208086f..89d6491 100644 --- a/linden/indra/newview/llvotree.cpp +++ b/linden/indra/newview/llvotree.cpp | |||
@@ -480,7 +480,7 @@ void LLVOTree::setPixelAreaAndAngle(LLAgent &agent) | |||
480 | #endif | 480 | #endif |
481 | } | 481 | } |
482 | 482 | ||
483 | void LLVOTree::updateTextures() | 483 | void LLVOTree::updateTextures(LLAgent &agent) |
484 | { | 484 | { |
485 | if (mTreeImagep) | 485 | if (mTreeImagep) |
486 | { | 486 | { |
@@ -1316,9 +1316,9 @@ U32 LLVOTree::getPartitionType() const | |||
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | LLTreePartition::LLTreePartition() | 1318 | LLTreePartition::LLTreePartition() |
1319 | : LLSpatialPartition(0) | 1319 | : LLSpatialPartition(0, FALSE, 0) |
1320 | { | 1320 | { |
1321 | mRenderByGroup = FALSE; | 1321 | // mRenderByGroup = FALSE; // SD hybrid |
1322 | mDrawableType = LLPipeline::RENDER_TYPE_TREE; | 1322 | mDrawableType = LLPipeline::RENDER_TYPE_TREE; |
1323 | mPartitionType = LLViewerRegion::PARTITION_TREE; | 1323 | mPartitionType = LLViewerRegion::PARTITION_TREE; |
1324 | mSlopRatio = 0.f; | 1324 | mSlopRatio = 0.f; |
diff --git a/linden/indra/newview/llvotree.h b/linden/indra/newview/llvotree.h index 855c612..7804ab3 100644 --- a/linden/indra/newview/llvotree.h +++ b/linden/indra/newview/llvotree.h | |||
@@ -69,7 +69,7 @@ public: | |||
69 | // Graphical stuff for objects - maybe broken out into render class later? | 69 | // Graphical stuff for objects - maybe broken out into render class later? |
70 | /*virtual*/ void render(LLAgent &agent); | 70 | /*virtual*/ void render(LLAgent &agent); |
71 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); | 71 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); |
72 | /*virtual*/ void updateTextures(); | 72 | /*virtual*/ void updateTextures(LLAgent &agent); |
73 | 73 | ||
74 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 74 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
75 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 75 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
diff --git a/linden/indra/newview/llvotreenew.h b/linden/indra/newview/llvotreenew.h index 4960d90..02f6d3a 100644 --- a/linden/indra/newview/llvotreenew.h +++ b/linden/indra/newview/llvotreenew.h | |||
@@ -156,7 +156,7 @@ public: | |||
156 | /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); | 156 | /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); |
157 | 157 | ||
158 | /*virtual*/ void render(LLAgent &agent); | 158 | /*virtual*/ void render(LLAgent &agent); |
159 | /*virtual*/ void updateTextures(); | 159 | /*virtual*/ void updateTextures(LLAgent &agent); |
160 | 160 | ||
161 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | 161 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); |
162 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 162 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp index 385dbe0..d4c4020 100644 --- a/linden/indra/newview/llvovolume.cpp +++ b/linden/indra/newview/llvovolume.cpp | |||
@@ -54,6 +54,7 @@ | |||
54 | #include "llspatialpartition.h" | 54 | #include "llspatialpartition.h" |
55 | #include "llhudmanager.h" | 55 | #include "llhudmanager.h" |
56 | #include "llflexibleobject.h" | 56 | #include "llflexibleobject.h" |
57 | |||
57 | #include "llsky.h" | 58 | #include "llsky.h" |
58 | #include "lltexturefetch.h" | 59 | #include "lltexturefetch.h" |
59 | #include "llviewercamera.h" | 60 | #include "llviewercamera.h" |
@@ -67,6 +68,9 @@ | |||
67 | const S32 MIN_QUIET_FRAMES_COALESCE = 30; | 68 | const S32 MIN_QUIET_FRAMES_COALESCE = 30; |
68 | const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; | 69 | const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; |
69 | const F32 FORCE_CULL_AREA = 8.f; | 70 | const F32 FORCE_CULL_AREA = 8.f; |
71 | const F32 MAX_LOD_DISTANCE = 24.f; | ||
72 | const S32 MAX_SCULPT_REZ = 128; | ||
73 | |||
70 | 74 | ||
71 | BOOL gAnimateTextures = TRUE; | 75 | BOOL gAnimateTextures = TRUE; |
72 | extern BOOL gHideSelectedObjects; | 76 | extern BOOL gHideSelectedObjects; |
@@ -91,6 +95,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re | |||
91 | mNumFaces = 0; | 95 | mNumFaces = 0; |
92 | mLODChanged = FALSE; | 96 | mLODChanged = FALSE; |
93 | mSculptChanged = FALSE; | 97 | mSculptChanged = FALSE; |
98 | mSpotLightPriority = 0.f; | ||
94 | } | 99 | } |
95 | 100 | ||
96 | LLVOVolume::~LLVOVolume() | 101 | LLVOVolume::~LLVOVolume() |
@@ -214,7 +219,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, | |||
214 | std::string mask; | 219 | std::string mask; |
215 | mask = gDirUtilp->getDirDelimiter() + "*.slc"; | 220 | mask = gDirUtilp->getDirDelimiter() + "*.slc"; |
216 | gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask); | 221 | gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask); |
217 | // llerrs << "Bogus TE data in " << getID() << ", crashing!" << llendl; | 222 | // llwarns << "Bogus TE data in " << getID() << ", crashing!" << llendl; |
218 | llwarns << "Bogus TE data in " << getID() << llendl; | 223 | llwarns << "Bogus TE data in " << getID() << llendl; |
219 | } | 224 | } |
220 | else if (res2 & (TEM_CHANGE_TEXTURE|TEM_CHANGE_COLOR)) | 225 | else if (res2 & (TEM_CHANGE_TEXTURE|TEM_CHANGE_COLOR)) |
@@ -314,11 +319,6 @@ void LLVOVolume::animateTextures() | |||
314 | te->getScale(&scale_s, &scale_t); | 319 | te->getScale(&scale_s, &scale_t); |
315 | } | 320 | } |
316 | 321 | ||
317 | LLVector3 scale(scale_s, scale_t, 1.f); | ||
318 | LLVector3 trans(off_s+0.5f, off_t+0.5f, 0.f); | ||
319 | LLQuaternion quat; | ||
320 | quat.setQuat(rot, 0, 0, -1.f); | ||
321 | |||
322 | if (!facep->mTextureMatrix) | 322 | if (!facep->mTextureMatrix) |
323 | { | 323 | { |
324 | facep->mTextureMatrix = new LLMatrix4(); | 324 | facep->mTextureMatrix = new LLMatrix4(); |
@@ -326,7 +326,43 @@ void LLVOVolume::animateTextures() | |||
326 | 326 | ||
327 | LLMatrix4& tex_mat = *facep->mTextureMatrix; | 327 | LLMatrix4& tex_mat = *facep->mTextureMatrix; |
328 | tex_mat.setIdentity(); | 328 | tex_mat.setIdentity(); |
329 | tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); | 329 | LLVector3 trans ; |
330 | |||
331 | if(facep->isAtlasInUse()) | ||
332 | { | ||
333 | // | ||
334 | //if use atlas for animated texture | ||
335 | //apply the following transform to the animation matrix. | ||
336 | // | ||
337 | |||
338 | F32 tcoord_xoffset = 0.f ; | ||
339 | F32 tcoord_yoffset = 0.f ; | ||
340 | F32 tcoord_xscale = 1.f ; | ||
341 | F32 tcoord_yscale = 1.f ; | ||
342 | if(facep->isAtlasInUse()) | ||
343 | { | ||
344 | const LLVector2* tmp = facep->getTexCoordOffset() ; | ||
345 | tcoord_xoffset = tmp->mV[0] ; | ||
346 | tcoord_yoffset = tmp->mV[1] ; | ||
347 | |||
348 | tmp = facep->getTexCoordScale() ; | ||
349 | tcoord_xscale = tmp->mV[0] ; | ||
350 | tcoord_yscale = tmp->mV[1] ; | ||
351 | } | ||
352 | trans.set(LLVector3(tcoord_xoffset + tcoord_xscale * (off_s+0.5f), tcoord_yoffset + tcoord_yscale * (off_t+0.5f), 0.f)); | ||
353 | |||
354 | tex_mat.translate(LLVector3(-(tcoord_xoffset + tcoord_xscale * 0.5f), -(tcoord_yoffset + tcoord_yscale * 0.5f), 0.f)); | ||
355 | } | ||
356 | else //non atlas | ||
357 | { | ||
358 | trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); | ||
359 | tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); | ||
360 | } | ||
361 | |||
362 | LLVector3 scale(scale_s, scale_t, 1.f); | ||
363 | LLQuaternion quat; | ||
364 | quat.setQuat(rot, 0, 0, -1.f); | ||
365 | |||
330 | tex_mat.rotate(quat); | 366 | tex_mat.rotate(quat); |
331 | 367 | ||
332 | LLMatrix4 mat; | 368 | LLMatrix4 mat; |
@@ -403,30 +439,28 @@ BOOL LLVOVolume::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
403 | return TRUE; | 439 | return TRUE; |
404 | } | 440 | } |
405 | 441 | ||
406 | void LLVOVolume::updateTextures() | 442 | void LLVOVolume::updateTextures(LLAgent &agent) // KL sd |
407 | { | 443 | { |
408 | const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds | 444 | const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds |
409 | if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) | 445 | if (mDrawable.notNull() && mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) |
410 | { | 446 | { |
411 | updateTextureVirtualSize(); | 447 | if (mDrawable->isVisible()) |
448 | { | ||
449 | updateTextures(); | ||
450 | } | ||
412 | } | 451 | } |
413 | } | 452 | } |
414 | 453 | ||
415 | void LLVOVolume::updateTextureVirtualSize() | 454 | void LLVOVolume::updateTextures() |
416 | { | 455 | { |
417 | // Update the pixel area of all faces | 456 | // Update the pixel area of all faces |
418 | 457 | ||
419 | if(mDrawable.isNull() || !mDrawable->isVisible()) | ||
420 | { | ||
421 | return ; | ||
422 | } | ||
423 | |||
424 | if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE)) | 458 | if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE)) |
425 | { | 459 | { |
426 | return; | 460 | return; |
427 | } | 461 | } |
428 | 462 | ||
429 | if (LLViewerImage::sDontLoadVolumeTextures || LLAppViewer::getTextureFetch()->mDebugPause) | 463 | if (LLViewerImage::sDontLoadVolumeTextures || mDrawable.isNull()) // || !mDrawable->isVisible()) |
430 | { | 464 | { |
431 | return; | 465 | return; |
432 | } | 466 | } |
@@ -443,15 +477,14 @@ void LLVOVolume::updateTextureVirtualSize() | |||
443 | LLFace* face = mDrawable->getFace(i); | 477 | LLFace* face = mDrawable->getFace(i); |
444 | const LLTextureEntry *te = face->getTextureEntry(); | 478 | const LLTextureEntry *te = face->getTextureEntry(); |
445 | LLViewerImage *imagep = face->getTexture(); | 479 | LLViewerImage *imagep = face->getTexture(); |
446 | if (!imagep || !te || | 480 | if (!imagep || !te || |
447 | face->mExtents[0] == face->mExtents[1]) | 481 | face->mExtents[0] == face->mExtents[1]) |
448 | { | 482 | { |
449 | continue; | 483 | continue; |
450 | } | 484 | } |
451 | 485 | ||
452 | F32 vsize; | 486 | F32 vsize; |
453 | F32 old_size = face->getVirtualSize(); | 487 | |
454 | |||
455 | if (isHUDAttachment()) | 488 | if (isHUDAttachment()) |
456 | { | 489 | { |
457 | F32 area = (F32) LLViewerCamera::getInstance()->getScreenPixelArea(); | 490 | F32 area = (F32) LLViewerCamera::getInstance()->getScreenPixelArea(); |
@@ -461,21 +494,24 @@ void LLVOVolume::updateTextureVirtualSize() | |||
461 | } | 494 | } |
462 | else | 495 | else |
463 | { | 496 | { |
464 | vsize = face->getTextureVirtualSize(); | 497 | vsize = getTextureVirtualSize(face); |
465 | } | 498 | } |
466 | 499 | ||
467 | mPixelArea = llmax(mPixelArea, face->getPixelArea()); | 500 | mPixelArea = llmax(mPixelArea, face->getPixelArea()); |
501 | |||
502 | F32 old_size = face->getVirtualSize(); | ||
468 | 503 | ||
469 | if (face->mTextureMatrix != NULL) | 504 | if (face->mTextureMatrix != NULL) |
470 | { | 505 | { |
471 | if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) || | 506 | if (vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE || |
472 | (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE)) | 507 | vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE) |
473 | { | 508 | { |
474 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, FALSE); | 509 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, FALSE); |
475 | } | 510 | } |
476 | } | 511 | } |
477 | 512 | ||
478 | face->setVirtualSize(vsize); | 513 | face->setVirtualSize(vsize); |
514 | // imagep->addTextureStats(vsize); | ||
479 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) | 515 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) |
480 | { | 516 | { |
481 | if (vsize < min_vsize) min_vsize = vsize; | 517 | if (vsize < min_vsize) min_vsize = vsize; |
@@ -503,46 +539,46 @@ void LLVOVolume::updateTextureVirtualSize() | |||
503 | mSculptTexture = gImageList.getImage(id); | 539 | mSculptTexture = gImageList.getImage(id); |
504 | if (mSculptTexture.notNull()) | 540 | if (mSculptTexture.notNull()) |
505 | { | 541 | { |
542 | S32 lod = llmin(mLOD, 3); | ||
543 | F32 lodf = ((F32)(lod + 1.0f)/4.f); | ||
544 | F32 tex_size = lodf * MAX_SCULPT_REZ; | ||
545 | mSculptTexture->addTextureStats(2.f * tex_size * tex_size); | ||
506 | mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), | 546 | mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), |
507 | (S32)LLViewerImageBoostLevel::BOOST_SCULPTED)); | 547 | (S32)LLViewerImageBoostLevel::BOOST_SCULPTED)); |
508 | mSculptTexture->setForSculpt() ; | 548 | } |
509 | |||
510 | if(!mSculptTexture->isCachedRawImageReady()) | ||
511 | { | ||
512 | S32 lod = llmin(mLOD, 3); | ||
513 | F32 lodf = ((F32)(lod + 1.0f)/4.f); | ||
514 | F32 tex_size = lodf * LLViewerImage::sMaxSculptRez ; | ||
515 | mSculptTexture->addTextureStats(2.f * tex_size * tex_size, FALSE); | ||
516 | |||
517 | //if the sculpty very close to the view point, load first | ||
518 | { | ||
519 | LLVector3 lookAt = getPositionAgent() - LLViewerCamera::getInstance()->getOrigin(); | ||
520 | F32 dist = lookAt.normVec() ; | ||
521 | F32 cos_angle_to_view_dir = lookAt * LLViewerCamera::getInstance()->getXAxis() ; | ||
522 | mSculptTexture->setAdditionalDecodePriority(0.8f * LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist)) ; | ||
523 | } | ||
524 | } | ||
525 | |||
526 | S32 texture_discard = mSculptTexture->getCachedRawImageLevel(); //try to match the texture | ||
527 | S32 current_discard = mSculptLevel; | ||
528 | 549 | ||
529 | if (texture_discard >= 0 && //texture has some data available | 550 | S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture |
530 | (texture_discard < current_discard || //texture has more data than last rebuild | 551 | S32 current_discard = mSculptLevel; |
531 | current_discard < 0)) //no previous rebuild | ||
532 | { | ||
533 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); | ||
534 | mSculptChanged = TRUE; | ||
535 | } | ||
536 | 552 | ||
537 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED)) | 553 | if (texture_discard >= 0 && //texture has some data available |
554 | (texture_discard < current_discard || //texture has more data than last rebuild | ||
555 | current_discard < 0)) //no previous rebuild | ||
556 | { | ||
557 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); | ||
558 | mSculptChanged = TRUE; | ||
559 | } | ||
560 | |||
561 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED)) | ||
538 | { | 562 | { |
539 | setDebugText(llformat("T%d C%d V%d\n%dx%d", | 563 | setDebugText(llformat("T%d C%d V%d\n%dx%d", |
540 | texture_discard, current_discard, getVolume()->getSculptLevel(), | 564 | texture_discard, current_discard, getVolume()->getSculptLevel(), |
541 | mSculptTexture->getHeight(), mSculptTexture->getWidth())); | 565 | mSculptTexture->getHeight(), mSculptTexture->getWidth())); |
542 | } | 566 | } |
543 | } | ||
544 | } | 567 | } |
545 | 568 | ||
569 | if (getLightTextureID().notNull()) | ||
570 | { | ||
571 | LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); | ||
572 | LLUUID id = params->getLightTexture(); | ||
573 | mLightTexture = gImageList.getImage(id); | ||
574 | if (mLightTexture.notNull()) | ||
575 | { | ||
576 | F32 rad = getLightRadius(); | ||
577 | mLightTexture->addTextureStats(gPipeline.calcPixelArea(getPositionAgent(), | ||
578 | LLVector3(rad,rad,rad), | ||
579 | *LLViewerCamera::getInstance())); | ||
580 | } | ||
581 | } | ||
546 | 582 | ||
547 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) | 583 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) |
548 | { | 584 | { |
@@ -563,6 +599,36 @@ void LLVOVolume::updateTextureVirtualSize() | |||
563 | } | 599 | } |
564 | } | 600 | } |
565 | 601 | ||
602 | F32 LLVOVolume::getTextureVirtualSize(LLFace* face) | ||
603 | { | ||
604 | //get area of circle around face | ||
605 | LLVector3 center = face->getPositionAgent(); | ||
606 | LLVector3 size = (face->mExtents[1] - face->mExtents[0]) * 0.5f; | ||
607 | |||
608 | F32 face_area = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance()); | ||
609 | |||
610 | face->setPixelArea(face_area); | ||
611 | |||
612 | if (face_area <= 0) | ||
613 | { | ||
614 | return 0.f; | ||
615 | } | ||
616 | |||
617 | //get area of circle in texture space | ||
618 | LLVector2 tdim = face->mTexExtents[1] - face->mTexExtents[0]; | ||
619 | F32 texel_area = (tdim * 0.5f).lengthSquared()*3.14159f; | ||
620 | if (texel_area <= 0) | ||
621 | { | ||
622 | // Probably animated, use default | ||
623 | texel_area = 1.f; | ||
624 | } | ||
625 | |||
626 | //apply texel area to face area to get accurate ratio | ||
627 | face_area /= llclamp(texel_area, 1.f/64.f, 16.f); | ||
628 | |||
629 | return face_area; | ||
630 | } | ||
631 | |||
566 | BOOL LLVOVolume::isActive() const | 632 | BOOL LLVOVolume::isActive() const |
567 | { | 633 | { |
568 | return !mStatic || mTextureAnimp || (mVolumeImpl && mVolumeImpl->isActive()); | 634 | return !mStatic || mTextureAnimp || (mVolumeImpl && mVolumeImpl->isActive()); |
@@ -699,21 +765,31 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail | |||
699 | 765 | ||
700 | // sculpt replaces generate() for sculpted surfaces | 766 | // sculpt replaces generate() for sculpted surfaces |
701 | void LLVOVolume::sculpt() | 767 | void LLVOVolume::sculpt() |
702 | { | 768 | { |
769 | U16 sculpt_height = 0; | ||
770 | U16 sculpt_width = 0; | ||
771 | S8 sculpt_components = 0; | ||
772 | const U8* sculpt_data = NULL; | ||
773 | |||
703 | if (mSculptTexture.notNull()) | 774 | if (mSculptTexture.notNull()) |
704 | { | 775 | { |
705 | U16 sculpt_height = 0; | 776 | S32 discard_level; |
706 | U16 sculpt_width = 0; | 777 | S32 desired_discard = 0; // lower discard levels have MUCH less resolution |
707 | S8 sculpt_components = 0; | 778 | |
708 | const U8* sculpt_data = NULL; | 779 | discard_level = desired_discard; |
709 | |||
710 | S32 discard_level = mSculptTexture->getCachedRawImageLevel() ; | ||
711 | LLImageRaw* raw_image = mSculptTexture->getCachedRawImage() ; | ||
712 | 780 | ||
713 | S32 max_discard = mSculptTexture->getMaxDiscardLevel(); | 781 | S32 max_discard = mSculptTexture->getMaxDiscardLevel(); |
714 | if (discard_level > max_discard) | 782 | if (discard_level > max_discard) |
715 | discard_level = max_discard; // clamp to the best we can do | 783 | discard_level = max_discard; // clamp to the best we can do |
716 | 784 | ||
785 | S32 best_discard = mSculptTexture->getDiscardLevel(); | ||
786 | if (discard_level < best_discard) | ||
787 | discard_level = best_discard; // clamp to what we have | ||
788 | |||
789 | if (best_discard == -1) | ||
790 | discard_level = -1; // and if we have nothing, set to nothing | ||
791 | |||
792 | |||
717 | S32 current_discard = getVolume()->getSculptLevel(); | 793 | S32 current_discard = getVolume()->getSculptLevel(); |
718 | if(current_discard < -2) | 794 | if(current_discard < -2) |
719 | { | 795 | { |
@@ -735,17 +811,28 @@ void LLVOVolume::sculpt() | |||
735 | if (current_discard == discard_level) // no work to do here | 811 | if (current_discard == discard_level) // no work to do here |
736 | return; | 812 | return; |
737 | 813 | ||
738 | if(!raw_image) | 814 | LLPointer<LLImageRaw> raw_image = new LLImageRaw(); |
815 | BOOL is_valid = mSculptTexture->readBackRaw(discard_level, raw_image, FALSE); | ||
816 | |||
817 | sculpt_height = raw_image->getHeight(); | ||
818 | sculpt_width = raw_image->getWidth(); | ||
819 | sculpt_components = raw_image->getComponents(); | ||
820 | |||
821 | if(is_valid) | ||
822 | { | ||
823 | is_valid = mSculptTexture->isValidForSculpt(discard_level, sculpt_width, sculpt_height, sculpt_components) ; | ||
824 | } | ||
825 | if(!is_valid) | ||
739 | { | 826 | { |
740 | sculpt_width = 0; | 827 | sculpt_width = 0; |
741 | sculpt_height = 0; | 828 | sculpt_height = 0; |
742 | sculpt_data = NULL ; | 829 | sculpt_data = NULL ; |
743 | } | 830 | } |
744 | else | 831 | else |
745 | { | 832 | { |
746 | sculpt_height = raw_image->getHeight(); | 833 | if (raw_image->getDataSize() < sculpt_height * sculpt_width * sculpt_components) |
747 | sculpt_width = raw_image->getWidth(); | 834 | llwarns << "Sculpt: image data size = " << raw_image->getDataSize() |
748 | sculpt_components = raw_image->getComponents(); | 835 | << " < " << sculpt_height << " x " << sculpt_width << " x " <<sculpt_components << llendl; |
749 | 836 | ||
750 | sculpt_data = raw_image->getData(); | 837 | sculpt_data = raw_image->getData(); |
751 | } | 838 | } |
@@ -777,7 +864,7 @@ BOOL LLVOVolume::calcLOD() | |||
777 | } | 864 | } |
778 | 865 | ||
779 | //update face texture sizes on lod calculation | 866 | //update face texture sizes on lod calculation |
780 | updateTextureVirtualSize(); | 867 | // updateTextureVirtualSize(); |
781 | 868 | ||
782 | S32 cur_detail = 0; | 869 | S32 cur_detail = 0; |
783 | 870 | ||
@@ -1231,28 +1318,15 @@ S32 LLVOVolume::setTEColor(const U8 te, const LLColor3& color) | |||
1231 | 1318 | ||
1232 | S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color) | 1319 | S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color) |
1233 | { | 1320 | { |
1234 | S32 retval = 0; | 1321 | S32 res = LLViewerObject::setTEColor(te, color); |
1235 | const LLTextureEntry *tep = getTE(te); | 1322 | if (res && mDrawable.notNull()) |
1236 | if (!tep) | ||
1237 | { | 1323 | { |
1238 | llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl; | 1324 | //gPipeline.markTextured(mDrawable); |
1325 | mDrawable->setState(LLDrawable::REBUILD_COLOR); | ||
1326 | dirtyMesh(); | ||
1327 | //mFaceMappingChanged = TRUE; | ||
1239 | } | 1328 | } |
1240 | else if (color != tep->getColor()) | 1329 | return res; |
1241 | { | ||
1242 | if (color.mV[3] != tep->getColor().mV[3]) | ||
1243 | { | ||
1244 | gPipeline.markTextured(mDrawable); | ||
1245 | } | ||
1246 | retval = LLPrimitive::setTEColor(te, color); | ||
1247 | if (mDrawable.notNull() && retval) | ||
1248 | { | ||
1249 | // These should only happen on updates which are not the initial update. | ||
1250 | mDrawable->setState(LLDrawable::REBUILD_COLOR); | ||
1251 | dirtyMesh(); | ||
1252 | } | ||
1253 | } | ||
1254 | |||
1255 | return retval; | ||
1256 | } | 1330 | } |
1257 | 1331 | ||
1258 | S32 LLVOVolume::setTEBumpmap(const U8 te, const U8 bumpmap) | 1332 | S32 LLVOVolume::setTEBumpmap(const U8 te, const U8 bumpmap) |
@@ -1318,7 +1392,7 @@ S32 LLVOVolume::setTEBumpShinyFullbright(const U8 te, const U8 bump) | |||
1318 | gPipeline.markTextured(mDrawable); | 1392 | gPipeline.markTextured(mDrawable); |
1319 | mFaceMappingChanged = TRUE; | 1393 | mFaceMappingChanged = TRUE; |
1320 | } | 1394 | } |
1321 | return res; | 1395 | return res; |
1322 | } | 1396 | } |
1323 | 1397 | ||
1324 | S32 LLVOVolume::setTEMediaFlags(const U8 te, const U8 media_flags) | 1398 | S32 LLVOVolume::setTEMediaFlags(const U8 te, const U8 media_flags) |
@@ -1387,6 +1461,40 @@ void LLVOVolume::updateTEData() | |||
1387 | 1461 | ||
1388 | //---------------------------------------------------------------------------- | 1462 | //---------------------------------------------------------------------------- |
1389 | 1463 | ||
1464 | void LLVOVolume::setLightTextureID(LLUUID id) | ||
1465 | { | ||
1466 | if (id.notNull()) | ||
1467 | { | ||
1468 | if (!hasLightTexture()) | ||
1469 | { | ||
1470 | setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE, TRUE, true); | ||
1471 | } | ||
1472 | LLLightImageParams* param_block = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); | ||
1473 | if (param_block && param_block->getLightTexture() != id) | ||
1474 | { | ||
1475 | param_block->setLightTexture(id); | ||
1476 | parameterChanged(LLNetworkData::PARAMS_LIGHT_IMAGE, true); | ||
1477 | } | ||
1478 | } | ||
1479 | else | ||
1480 | { | ||
1481 | if (hasLightTexture()) | ||
1482 | { | ||
1483 | setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE, FALSE, true); | ||
1484 | } | ||
1485 | } | ||
1486 | } | ||
1487 | |||
1488 | void LLVOVolume::setSpotLightParams(LLVector3 params) | ||
1489 | { | ||
1490 | LLLightImageParams* param_block = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); | ||
1491 | if (param_block && param_block->getParams() != params) | ||
1492 | { | ||
1493 | param_block->setParams(params); | ||
1494 | parameterChanged(LLNetworkData::PARAMS_LIGHT_IMAGE, true); | ||
1495 | } | ||
1496 | } | ||
1497 | |||
1390 | void LLVOVolume::setIsLight(BOOL is_light) | 1498 | void LLVOVolume::setIsLight(BOOL is_light) |
1391 | { | 1499 | { |
1392 | if (is_light != getIsLight()) | 1500 | if (is_light != getIsLight()) |
@@ -1513,6 +1621,77 @@ LLColor3 LLVOVolume::getLightColor() const | |||
1513 | } | 1621 | } |
1514 | } | 1622 | } |
1515 | 1623 | ||
1624 | LLUUID LLVOVolume::getLightTextureID() const | ||
1625 | { | ||
1626 | const LLLightImageParams *param_block = (const LLLightImageParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); | ||
1627 | if (param_block) | ||
1628 | { | ||
1629 | return param_block->getLightTexture(); | ||
1630 | } | ||
1631 | |||
1632 | return LLUUID::null; | ||
1633 | } | ||
1634 | |||
1635 | |||
1636 | LLVector3 LLVOVolume::getSpotLightParams() const | ||
1637 | { | ||
1638 | const LLLightImageParams *param_block = (const LLLightImageParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); | ||
1639 | if (param_block) | ||
1640 | { | ||
1641 | return param_block->getParams(); | ||
1642 | } | ||
1643 | |||
1644 | return LLVector3(); | ||
1645 | } | ||
1646 | |||
1647 | F32 LLVOVolume::getSpotLightPriority() const | ||
1648 | { | ||
1649 | return mSpotLightPriority; | ||
1650 | } | ||
1651 | |||
1652 | void LLVOVolume::updateSpotLightPriority() | ||
1653 | { | ||
1654 | LLVector3 pos = mDrawable->getPositionAgent(); | ||
1655 | LLVector3 at(0,0,-1); | ||
1656 | at *= getRenderRotation(); | ||
1657 | |||
1658 | F32 r = getLightRadius()*0.5f; | ||
1659 | |||
1660 | pos += at * r; | ||
1661 | |||
1662 | at = LLViewerCamera::getInstance()->getAtAxis(); | ||
1663 | |||
1664 | pos -= at * r; | ||
1665 | |||
1666 | mSpotLightPriority = gPipeline.calcPixelArea(pos, LLVector3(r,r,r), *LLViewerCamera::getInstance()); | ||
1667 | // KL needed for S19? | ||
1668 | if (mLightTexture.notNull()) | ||
1669 | { | ||
1670 | mLightTexture->addTextureStats(mSpotLightPriority); | ||
1671 | mLightTexture->setBoostLevel(LLViewerImageBoostLevel::BOOST_CLOUDS); | ||
1672 | } | ||
1673 | } | ||
1674 | |||
1675 | |||
1676 | LLViewerImage* LLVOVolume::getLightTexture() | ||
1677 | { | ||
1678 | LLUUID id = getLightTextureID(); | ||
1679 | |||
1680 | if (id.notNull()) | ||
1681 | { | ||
1682 | if (mLightTexture.isNull() || id != mLightTexture->getID()) | ||
1683 | { | ||
1684 | mLightTexture = gImageList.getImage(id); | ||
1685 | } | ||
1686 | } | ||
1687 | else | ||
1688 | { | ||
1689 | mLightTexture = NULL; | ||
1690 | } | ||
1691 | |||
1692 | return mLightTexture; | ||
1693 | } | ||
1694 | |||
1516 | F32 LLVOVolume::getLightIntensity() const | 1695 | F32 LLVOVolume::getLightIntensity() const |
1517 | { | 1696 | { |
1518 | const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); | 1697 | const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); |
@@ -1604,6 +1783,16 @@ BOOL LLVOVolume::isSculpted() const | |||
1604 | return FALSE; | 1783 | return FALSE; |
1605 | } | 1784 | } |
1606 | 1785 | ||
1786 | BOOL LLVOVolume::hasLightTexture() const | ||
1787 | { | ||
1788 | if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE)) | ||
1789 | { | ||
1790 | return TRUE; | ||
1791 | } | ||
1792 | |||
1793 | return FALSE; | ||
1794 | } | ||
1795 | |||
1607 | BOOL LLVOVolume::isVolumeGlobal() const | 1796 | BOOL LLVOVolume::isVolumeGlobal() const |
1608 | { | 1797 | { |
1609 | if (mVolumeImpl) | 1798 | if (mVolumeImpl) |
@@ -2056,9 +2245,9 @@ U32 LLVOVolume::getPartitionType() const | |||
2056 | } | 2245 | } |
2057 | 2246 | ||
2058 | LLVolumePartition::LLVolumePartition() | 2247 | LLVolumePartition::LLVolumePartition() |
2059 | : LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, FALSE) | 2248 | : LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB) // KL |
2060 | { | 2249 | { |
2061 | mLODPeriod = 16; | 2250 | mLODPeriod = 32; // KL 32 in SD |
2062 | mDepthMask = FALSE; | 2251 | mDepthMask = FALSE; |
2063 | mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; | 2252 | mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; |
2064 | mPartitionType = LLViewerRegion::PARTITION_VOLUME; | 2253 | mPartitionType = LLViewerRegion::PARTITION_VOLUME; |
@@ -2067,10 +2256,10 @@ LLVolumePartition::LLVolumePartition() | |||
2067 | } | 2256 | } |
2068 | 2257 | ||
2069 | LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep) | 2258 | LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep) |
2070 | : LLSpatialBridge(drawablep, LLVOVolume::VERTEX_DATA_MASK) | 2259 | : LLSpatialBridge(drawablep, TRUE, LLVOVolume::VERTEX_DATA_MASK) // KL SD |
2071 | { | 2260 | { |
2072 | mDepthMask = FALSE; | 2261 | mDepthMask = FALSE; |
2073 | mLODPeriod = 16; | 2262 | mLODPeriod = 32; // KL 32 in SD |
2074 | mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; | 2263 | mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; |
2075 | mPartitionType = LLViewerRegion::PARTITION_BRIDGE; | 2264 | mPartitionType = LLViewerRegion::PARTITION_BRIDGE; |
2076 | 2265 | ||
@@ -2125,7 +2314,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, | |||
2125 | 2314 | ||
2126 | U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0); | 2315 | U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0); |
2127 | 2316 | ||
2128 | LLViewerImage* tex = facep->getTexture(); | 2317 | LLImageGL* tex = facep->getGLTexture(); // LLViewerImage* tex = facep->getTexture(); // KL SD |
2129 | 2318 | ||
2130 | U8 glow = 0; | 2319 | U8 glow = 0; |
2131 | 2320 | ||
@@ -2136,7 +2325,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, | |||
2136 | 2325 | ||
2137 | if (facep->mVertexBuffer.isNull()) | 2326 | if (facep->mVertexBuffer.isNull()) |
2138 | { | 2327 | { |
2139 | llerrs << "WTF?" << llendl; | 2328 | llwarns << "WTF?" << llendl; |
2140 | } | 2329 | } |
2141 | 2330 | ||
2142 | if (idx >= 0 && | 2331 | if (idx >= 0 && |
@@ -2167,6 +2356,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, | |||
2167 | U32 offset = facep->getIndicesStart(); | 2356 | U32 offset = facep->getIndicesStart(); |
2168 | U32 count = facep->getIndicesCount(); | 2357 | U32 count = facep->getIndicesCount(); |
2169 | LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex, | 2358 | LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex, |
2359 | (LLImageGL*)facep->getTexture() == tex ? facep->getTexture() : NULL, | ||
2170 | facep->mVertexBuffer, fullbright, bump); | 2360 | facep->mVertexBuffer, fullbright, bump); |
2171 | draw_info->mGroup = group; | 2361 | draw_info->mGroup = group; |
2172 | draw_info->mVSize = facep->getVirtualSize(); | 2362 | draw_info->mVSize = facep->getVirtualSize(); |
@@ -2254,9 +2444,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) | |||
2254 | 2444 | ||
2255 | LLVOVolume* vobj = drawablep->getVOVolume(); | 2445 | LLVOVolume* vobj = drawablep->getVOVolume(); |
2256 | llassert_always(vobj); | 2446 | llassert_always(vobj); |
2257 | vobj->updateTextureVirtualSize(); | 2447 | vobj->updateTextures(); |
2258 | vobj->preRebuild(); | 2448 | vobj->preRebuild(); |
2259 | 2449 | ||
2450 | drawablep->clearState(LLDrawable::HAS_ALPHA); // KL SD | ||
2451 | |||
2260 | //for each face | 2452 | //for each face |
2261 | for (S32 i = 0; i < drawablep->getNumFaces(); i++) | 2453 | for (S32 i = 0; i < drawablep->getNumFaces(); i++) |
2262 | { | 2454 | { |
@@ -2325,6 +2517,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) | |||
2325 | } | 2517 | } |
2326 | else | 2518 | else |
2327 | { | 2519 | { |
2520 | drawablep->setState(LLDrawable::HAS_ALPHA); // KL SD | ||
2328 | alpha_faces.push_back(facep); | 2521 | alpha_faces.push_back(facep); |
2329 | } | 2522 | } |
2330 | } | 2523 | } |
@@ -2348,7 +2541,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) | |||
2348 | } | 2541 | } |
2349 | else | 2542 | else |
2350 | { //doesn't need normal | 2543 | { //doesn't need normal |
2351 | facep->setState(LLFace::FULLBRIGHT); | 2544 | //facep->setState(LLFace::FULLBRIGHT); |
2352 | fullbright_faces.push_back(facep); | 2545 | fullbright_faces.push_back(facep); |
2353 | } | 2546 | } |
2354 | } | 2547 | } |
@@ -2358,14 +2551,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) | |||
2358 | { //needs normal + binormal | 2551 | { //needs normal + binormal |
2359 | bump_faces.push_back(facep); | 2552 | bump_faces.push_back(facep); |
2360 | } | 2553 | } |
2361 | else if ((te->getShiny() && LLPipeline::sRenderBump) || | 2554 | else if (te->getShiny() && LLPipeline::sRenderBump || |
2362 | !te->getFullbright()) | 2555 | !te->getFullbright()) |
2363 | { //needs normal | 2556 | { //needs normal |
2364 | simple_faces.push_back(facep); | 2557 | simple_faces.push_back(facep); |
2365 | } | 2558 | } |
2366 | else | 2559 | else |
2367 | { //doesn't need normal | 2560 | { //doesn't need normal |
2368 | facep->setState(LLFace::FULLBRIGHT); | 2561 | // facep->setState(LLFace::FULLBRIGHT); |
2369 | fullbright_faces.push_back(facep); | 2562 | fullbright_faces.push_back(facep); |
2370 | } | 2563 | } |
2371 | } | 2564 | } |
@@ -2413,7 +2606,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) | |||
2413 | 2606 | ||
2414 | if (LLPipeline::sDelayVBUpdate) | 2607 | if (LLPipeline::sDelayVBUpdate) |
2415 | { | 2608 | { |
2416 | group->setState(LLSpatialGroup::MESH_DIRTY); | 2609 | group->setState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD |
2417 | } | 2610 | } |
2418 | 2611 | ||
2419 | mFaceList.clear(); | 2612 | mFaceList.clear(); |
@@ -2421,7 +2614,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) | |||
2421 | 2614 | ||
2422 | void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) | 2615 | void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) |
2423 | { | 2616 | { |
2424 | if (group->isState(LLSpatialGroup::MESH_DIRTY)) | 2617 | if (group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY)) // KL SD |
2425 | { | 2618 | { |
2426 | S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ; | 2619 | S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ; |
2427 | 2620 | ||
@@ -2499,7 +2692,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) | |||
2499 | } | 2692 | } |
2500 | } | 2693 | } |
2501 | 2694 | ||
2502 | group->clearState(LLSpatialGroup::MESH_DIRTY); | 2695 | group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD |
2503 | } | 2696 | } |
2504 | } | 2697 | } |
2505 | 2698 | ||
@@ -2524,7 +2717,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: | |||
2524 | 2717 | ||
2525 | LLSpatialGroup::buffer_map_t buffer_map; | 2718 | LLSpatialGroup::buffer_map_t buffer_map; |
2526 | 2719 | ||
2527 | LLViewerImage* last_tex = NULL; | 2720 | LLImageGL* last_tex = NULL;// LLViewerImage* last_tex = NULL; // KL SD |
2528 | S32 buffer_index = 0; | 2721 | S32 buffer_index = 0; |
2529 | 2722 | ||
2530 | if (distance_sort) | 2723 | if (distance_sort) |
@@ -2536,7 +2729,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: | |||
2536 | { | 2729 | { |
2537 | //pull off next face | 2730 | //pull off next face |
2538 | LLFace* facep = *face_iter; | 2731 | LLFace* facep = *face_iter; |
2539 | LLViewerImage* tex = facep->getTexture(); | 2732 | LLImageGL* tex = facep->getGLTexture(); // LLViewerImage* tex = facep->getTexture(); // KL SD |
2540 | 2733 | ||
2541 | if (distance_sort) | 2734 | if (distance_sort) |
2542 | { | 2735 | { |
@@ -2561,7 +2754,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: | |||
2561 | ++i; | 2754 | ++i; |
2562 | 2755 | ||
2563 | while (i != faces.end() && | 2756 | while (i != faces.end() && |
2564 | (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex))) | 2757 | (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getGLTexture() == tex))) // KL SD getTexture |
2565 | { | 2758 | { |
2566 | facep = *i; | 2759 | facep = *i; |
2567 | 2760 | ||
@@ -2644,6 +2837,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: | |||
2644 | 2837 | ||
2645 | BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA; | 2838 | BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA; |
2646 | BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); | 2839 | BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); |
2840 | if ((mask & LLVertexBuffer::MAP_NORMAL) == 0) // KL SD | ||
2841 | { //paranoia check to make sure GL doesn't try to read non-existant normals | ||
2842 | fullbright = TRUE; | ||
2843 | } | ||
2844 | |||
2647 | const LLTextureEntry* te = facep->getTextureEntry(); | 2845 | const LLTextureEntry* te = facep->getTextureEntry(); |
2648 | 2846 | ||
2649 | BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE; | 2847 | BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE; |
@@ -2695,7 +2893,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: | |||
2695 | } | 2893 | } |
2696 | else | 2894 | else |
2697 | { | 2895 | { |
2698 | llassert(mask & LLVertexBuffer::MAP_NORMAL); | 2896 | // llassert(mask & LLVertexBuffer::MAP_NORMAL); |
2699 | registerFace(group, facep, LLRenderPass::PASS_SIMPLE); | 2897 | registerFace(group, facep, LLRenderPass::PASS_SIMPLE); |
2700 | } | 2898 | } |
2701 | } | 2899 | } |
@@ -2726,7 +2924,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: | |||
2726 | } | 2924 | } |
2727 | else | 2925 | else |
2728 | { | 2926 | { |
2729 | llassert(mask & LLVertexBuffer::MAP_NORMAL); | 2927 | // llassert(mask & LLVertexBuffer::MAP_NORMAL); |
2730 | registerFace(group, facep, LLRenderPass::PASS_SIMPLE); | 2928 | registerFace(group, facep, LLRenderPass::PASS_SIMPLE); |
2731 | } | 2929 | } |
2732 | } | 2930 | } |
@@ -2739,8 +2937,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: | |||
2739 | 2937 | ||
2740 | if (!is_alpha && !LLPipeline::sRenderDeferred) | 2938 | if (!is_alpha && !LLPipeline::sRenderDeferred) |
2741 | { | 2939 | { |
2742 | llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); | 2940 | // llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); |
2743 | facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); | 2941 | facep->setPoolType(LLDrawPool::POOL_SIMPLE); // facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); |
2744 | 2942 | ||
2745 | if (!force_simple && te->getBumpmap()) | 2943 | if (!force_simple && te->getBumpmap()) |
2746 | { | 2944 | { |
@@ -2819,7 +3017,7 @@ LLHUDPartition::LLHUDPartition() | |||
2819 | mPartitionType = LLViewerRegion::PARTITION_HUD; | 3017 | mPartitionType = LLViewerRegion::PARTITION_HUD; |
2820 | mDrawableType = LLPipeline::RENDER_TYPE_HUD; | 3018 | mDrawableType = LLPipeline::RENDER_TYPE_HUD; |
2821 | mSlopRatio = 0.f; | 3019 | mSlopRatio = 0.f; |
2822 | mLODPeriod = 1; | 3020 | mLODPeriod = 32; // KL 32 in SD |
2823 | } | 3021 | } |
2824 | 3022 | ||
2825 | void LLHUDPartition::shift(const LLVector3 &offset) | 3023 | void LLHUDPartition::shift(const LLVector3 &offset) |
diff --git a/linden/indra/newview/llvovolume.h b/linden/indra/newview/llvovolume.h index a78aa37..4c6ad9a 100644 --- a/linden/indra/newview/llvovolume.h +++ b/linden/indra/newview/llvovolume.h | |||
@@ -130,7 +130,7 @@ public: | |||
130 | 130 | ||
131 | 131 | ||
132 | BOOL getVolumeChanged() const { return mVolumeChanged; } | 132 | BOOL getVolumeChanged() const { return mVolumeChanged; } |
133 | 133 | F32 getTextureVirtualSize(LLFace* face); | |
134 | /*virtual*/ F32 getRadius() const { return mVObjRadius; }; | 134 | /*virtual*/ F32 getRadius() const { return mVObjRadius; }; |
135 | const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const; | 135 | const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const; |
136 | 136 | ||
@@ -158,14 +158,14 @@ public: | |||
158 | /*virtual*/ S32 setTEBumpmap(const U8 te, const U8 bump); | 158 | /*virtual*/ S32 setTEBumpmap(const U8 te, const U8 bump); |
159 | /*virtual*/ S32 setTEShiny(const U8 te, const U8 shiny); | 159 | /*virtual*/ S32 setTEShiny(const U8 te, const U8 shiny); |
160 | /*virtual*/ S32 setTEFullbright(const U8 te, const U8 fullbright); | 160 | /*virtual*/ S32 setTEFullbright(const U8 te, const U8 fullbright); |
161 | /*virtual*/ S32 setTEBumpShinyFullbright(const U8 te, const U8 bump); | 161 | /*virtual*/ S32 setTEBumpShinyFullbright(const U8 te, const U8 bump); // KL S19? |
162 | /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); | 162 | /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); |
163 | /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); | 163 | /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); |
164 | /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); | 164 | /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); |
165 | /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); | 165 | /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); |
166 | /*virtual*/ S32 setTEScaleT(const U8 te, const F32 t); | 166 | /*virtual*/ S32 setTEScaleT(const U8 te, const F32 t); |
167 | /*virtual*/ S32 setTETexGen(const U8 te, const U8 texgen); | 167 | /*virtual*/ S32 setTETexGen(const U8 te, const U8 texgen); |
168 | /*virtual*/ S32 setTEMediaTexGen(const U8 te, const U8 media); | 168 | /*virtual*/ S32 setTEMediaTexGen(const U8 te, const U8 media); // KL S19 |
169 | /*virtual*/ BOOL setMaterial(const U8 material); | 169 | /*virtual*/ BOOL setMaterial(const U8 material); |
170 | 170 | ||
171 | void setTexture(const S32 face); | 171 | void setTexture(const S32 face); |
@@ -177,8 +177,8 @@ public: | |||
177 | /*virtual*/ void updateFaceSize(S32 idx); | 177 | /*virtual*/ void updateFaceSize(S32 idx); |
178 | /*virtual*/ BOOL updateLOD(); | 178 | /*virtual*/ BOOL updateLOD(); |
179 | void updateRadius(); | 179 | void updateRadius(); |
180 | /*virtual*/ void updateTextures(); | 180 | /*virtual*/ void updateTextures(LLAgent &agent); |
181 | void updateTextureVirtualSize(); | 181 | void updateTextures(); |
182 | 182 | ||
183 | void updateFaceFlags(); | 183 | void updateFaceFlags(); |
184 | void regenFaces(); | 184 | void regenFaces(); |
@@ -196,9 +196,18 @@ public: | |||
196 | void setLightRadius(F32 radius); | 196 | void setLightRadius(F32 radius); |
197 | void setLightFalloff(F32 falloff); | 197 | void setLightFalloff(F32 falloff); |
198 | void setLightCutoff(F32 cutoff); | 198 | void setLightCutoff(F32 cutoff); |
199 | void setLightTextureID(LLUUID id); | ||
200 | void setSpotLightParams(LLVector3 params); | ||
201 | |||
199 | BOOL getIsLight() const; | 202 | BOOL getIsLight() const; |
200 | LLColor3 getLightBaseColor() const; // not scaled by intensity | 203 | LLColor3 getLightBaseColor() const; // not scaled by intensity |
201 | LLColor3 getLightColor() const; // scaled by intensity | 204 | LLColor3 getLightColor() const; // scaled by intensity |
205 | LLUUID getLightTextureID() const; | ||
206 | LLVector3 getSpotLightParams() const; | ||
207 | void updateSpotLightPriority(); | ||
208 | F32 getSpotLightPriority() const; | ||
209 | |||
210 | LLViewerImage* getLightTexture(); | ||
202 | F32 getLightIntensity() const; | 211 | F32 getLightIntensity() const; |
203 | F32 getLightRadius() const; | 212 | F32 getLightRadius() const; |
204 | F32 getLightFalloff() const; | 213 | F32 getLightFalloff() const; |
@@ -208,6 +217,8 @@ public: | |||
208 | U32 getVolumeInterfaceID() const; | 217 | U32 getVolumeInterfaceID() const; |
209 | virtual BOOL isFlexible() const; | 218 | virtual BOOL isFlexible() const; |
210 | virtual BOOL isSculpted() const; | 219 | virtual BOOL isSculpted() const; |
220 | virtual BOOL hasLightTexture() const; | ||
221 | |||
211 | BOOL isVolumeGlobal() const; | 222 | BOOL isVolumeGlobal() const; |
212 | BOOL canBeFlexible() const; | 223 | BOOL canBeFlexible() const; |
213 | BOOL setIsFlexible(BOOL is_flexible); | 224 | BOOL setIsFlexible(BOOL is_flexible); |
@@ -233,12 +244,14 @@ private: | |||
233 | BOOL mLODChanged; | 244 | BOOL mLODChanged; |
234 | S32 mSculptLevel; | 245 | S32 mSculptLevel; |
235 | BOOL mSculptChanged; | 246 | BOOL mSculptChanged; |
247 | F32 mSpotLightPriority; | ||
236 | LLMatrix4 mRelativeXform; | 248 | LLMatrix4 mRelativeXform; |
237 | LLMatrix3 mRelativeXformInvTrans; | 249 | LLMatrix3 mRelativeXformInvTrans; |
238 | BOOL mVolumeChanged; | 250 | BOOL mVolumeChanged; |
239 | F32 mVObjRadius; | 251 | F32 mVObjRadius; |
240 | LLVolumeInterface *mVolumeImpl; | 252 | LLVolumeInterface *mVolumeImpl; |
241 | LLPointer<LLViewerImage> mSculptTexture; | 253 | LLPointer<LLViewerImage> mSculptTexture; |
254 | LLPointer<LLViewerImage> mLightTexture; | ||
242 | 255 | ||
243 | // statics | 256 | // statics |
244 | public: | 257 | public: |
diff --git a/linden/indra/newview/llvowater.cpp b/linden/indra/newview/llvowater.cpp index 5b6a949..25960de 100644 --- a/linden/indra/newview/llvowater.cpp +++ b/linden/indra/newview/llvowater.cpp | |||
@@ -101,7 +101,7 @@ void LLVOWater::setPixelAreaAndAngle(LLAgent &agent) | |||
101 | 101 | ||
102 | 102 | ||
103 | // virtual | 103 | // virtual |
104 | void LLVOWater::updateTextures() | 104 | void LLVOWater::updateTextures(LLAgent &agent) |
105 | { | 105 | { |
106 | } | 106 | } |
107 | 107 | ||
@@ -276,9 +276,9 @@ U32 LLVOWater::getPartitionType() const | |||
276 | } | 276 | } |
277 | 277 | ||
278 | LLWaterPartition::LLWaterPartition() | 278 | LLWaterPartition::LLWaterPartition() |
279 | : LLSpatialPartition(0) | 279 | : LLSpatialPartition(0, FALSE, 0) |
280 | { | 280 | { |
281 | mRenderByGroup = FALSE; | 281 | // mRenderByGroup = FALSE; // KL specified const SG branch not req here |
282 | mInfiniteFarClip = TRUE; | 282 | mInfiniteFarClip = TRUE; |
283 | mDrawableType = LLPipeline::RENDER_TYPE_WATER; | 283 | mDrawableType = LLPipeline::RENDER_TYPE_WATER; |
284 | mPartitionType = LLViewerRegion::PARTITION_WATER; | 284 | mPartitionType = LLViewerRegion::PARTITION_WATER; |
diff --git a/linden/indra/newview/llvowater.h b/linden/indra/newview/llvowater.h index 9c33e74..cdda48f 100644 --- a/linden/indra/newview/llvowater.h +++ b/linden/indra/newview/llvowater.h | |||
@@ -68,7 +68,7 @@ public: | |||
68 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | 68 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); |
69 | /*virtual*/ void updateSpatialExtents(LLVector3& newMin, LLVector3& newMax); | 69 | /*virtual*/ void updateSpatialExtents(LLVector3& newMin, LLVector3& newMax); |
70 | 70 | ||
71 | /*virtual*/ void updateTextures(); | 71 | /*virtual*/ void updateTextures(LLAgent &agent); |
72 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area | 72 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area |
73 | 73 | ||
74 | virtual U32 getPartitionType() const; | 74 | virtual U32 getPartitionType() const; |
diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index e01506e..8ef11be 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp | |||
@@ -407,8 +407,7 @@ void LLWaterParamManager::update(LLViewerCamera * cam) | |||
407 | LLFloaterWater::instance()->syncMenu(); | 407 | LLFloaterWater::instance()->syncMenu(); |
408 | } | 408 | } |
409 | 409 | ||
410 | stop_glerror(); | 410 | //stop_glerror(); |
411 | |||
412 | // only do this if we're dealing with shaders | 411 | // only do this if we're dealing with shaders |
413 | if(gPipeline.canUseVertexShaders()) | 412 | if(gPipeline.canUseVertexShaders()) |
414 | { | 413 | { |
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index 31471d7..09f7d01 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp | |||
@@ -539,8 +539,7 @@ void LLWLParamManager::update(LLViewerCamera * cam) | |||
539 | 539 | ||
540 | F32 camYaw = cam->getYaw(); | 540 | F32 camYaw = cam->getYaw(); |
541 | 541 | ||
542 | stop_glerror(); | 542 | //stop_glerror(); |
543 | |||
544 | // *TODO: potential optimization - this block may only need to be | 543 | // *TODO: potential optimization - this block may only need to be |
545 | // executed some of the time. For example for water shaders only. | 544 | // executed some of the time. For example for water shaders only. |
546 | { | 545 | { |
diff --git a/linden/indra/newview/llworld.h b/linden/indra/newview/llworld.h index 46aefd9..9abb565 100644 --- a/linden/indra/newview/llworld.h +++ b/linden/indra/newview/llworld.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * @file llworld.h | 2 | * @file llworld.h |
3 | * @brief Collection of viewer regions in the vacinity of the user. | 3 | * @brief Collection of viewer regions in the vacinity of the user. |
4 | * | 4 | * |
5 | * Represents the whole world, so far as 3D functionality is conserned. | 5 | * Represents the whole world, so far as 3D functionality is concerned. |
6 | * Always contains the region that the user's avatar is in along with | 6 | * Always contains the region that the user's avatar is in along with |
7 | * neighboring regions. As the user crosses region boundaries, new | 7 | * neighboring regions. As the user crosses region boundaries, new |
8 | * regions are added to the world and distant ones are rolled up. | 8 | * regions are added to the world and distant ones are rolled up. |
@@ -151,7 +151,8 @@ public: | |||
151 | 151 | ||
152 | public: | 152 | public: |
153 | typedef std::list<LLViewerRegion*> region_list_t; | 153 | typedef std::list<LLViewerRegion*> region_list_t; |
154 | const region_list_t& getRegionList() const { return mActiveRegionList; } | 154 | region_list_t mActiveRegionList; // KL SD branch public not private |
155 | region_list_t& getRegionList() { return mActiveRegionList; } | ||
155 | 156 | ||
156 | // Returns lists of avatar IDs and their world-space positions within a given distance of a point. | 157 | // Returns lists of avatar IDs and their world-space positions within a given distance of a point. |
157 | // All arguments are optional. Given containers will be emptied and then filled. | 158 | // All arguments are optional. Given containers will be emptied and then filled. |
@@ -162,7 +163,6 @@ public: | |||
162 | const LLVector3d& relative_to = LLVector3d(), F32 radius = FLT_MAX) const; | 163 | const LLVector3d& relative_to = LLVector3d(), F32 radius = FLT_MAX) const; |
163 | 164 | ||
164 | private: | 165 | private: |
165 | region_list_t mActiveRegionList; | ||
166 | region_list_t mRegionList; | 166 | region_list_t mRegionList; |
167 | region_list_t mVisibleRegionList; | 167 | region_list_t mVisibleRegionList; |
168 | region_list_t mCulledRegionList; | 168 | region_list_t mCulledRegionList; |
diff --git a/linden/indra/newview/pipeline.cpp b/linden/indra/newview/pipeline.cpp index 72da3c6..4bf53af 100644 --- a/linden/indra/newview/pipeline.cpp +++ b/linden/indra/newview/pipeline.cpp | |||
@@ -159,6 +159,8 @@ std::string gPoolNames[] = | |||
159 | "POOL_ALPHA", | 159 | "POOL_ALPHA", |
160 | }; | 160 | }; |
161 | 161 | ||
162 | void drawBox(const LLVector3& c, const LLVector3& r); | ||
163 | |||
162 | U32 nhpo2(U32 v) | 164 | U32 nhpo2(U32 v) |
163 | { | 165 | { |
164 | U32 r = 1; | 166 | U32 r = 1; |
@@ -267,11 +269,11 @@ static const U32 gl_cube_face[] = | |||
267 | 269 | ||
268 | void validate_framebuffer_object(); | 270 | void validate_framebuffer_object(); |
269 | 271 | ||
272 | |||
270 | void addDeferredAttachments(LLRenderTarget& target) | 273 | void addDeferredAttachments(LLRenderTarget& target) |
271 | { | 274 | { |
272 | target.addColorAttachment(GL_RGBA16F_ARB); //specular | 275 | target.addColorAttachment(GL_RGBA); //specular //target.addColorAttachment(GL_RGBA16F_ARB); //specular // KL |
273 | target.addColorAttachment(GL_RGBA16F_ARB); //normal+z | 276 | target.addColorAttachment(GL_RGBA); //normal+z //target.addColorAttachment(GL_RGBA16F_ARB); //normal+z |
274 | target.addColorAttachment(GL_RGBA16F_ARB); //position | ||
275 | } | 277 | } |
276 | 278 | ||
277 | LLPipeline::LLPipeline() : | 279 | LLPipeline::LLPipeline() : |
@@ -313,6 +315,8 @@ LLPipeline::LLPipeline() : | |||
313 | mLightingDetail(0) | 315 | mLightingDetail(0) |
314 | { | 316 | { |
315 | mNoiseMap = 0; | 317 | mNoiseMap = 0; |
318 | //mTrueNoiseMap = 0; // KL SD | ||
319 | mLightFunc = 0; // KL SD | ||
316 | } | 320 | } |
317 | 321 | ||
318 | void LLPipeline::init() | 322 | void LLPipeline::init() |
@@ -362,6 +366,11 @@ void LLPipeline::init() | |||
362 | LLViewerShaderMgr::instance()->setShaders(); | 366 | LLViewerShaderMgr::instance()->setShaders(); |
363 | 367 | ||
364 | stop_glerror(); | 368 | stop_glerror(); |
369 | |||
370 | for (U32 i = 0; i < 2; ++i) | ||
371 | { | ||
372 | mSpotLightFade[i] = 1.f; | ||
373 | } | ||
365 | } | 374 | } |
366 | 375 | ||
367 | LLPipeline::~LLPipeline() | 376 | LLPipeline::~LLPipeline() |
@@ -373,6 +382,9 @@ void LLPipeline::cleanup() | |||
373 | { | 382 | { |
374 | assertInitialized(); | 383 | assertInitialized(); |
375 | 384 | ||
385 | mGroupQ1.clear() ; | ||
386 | mGroupQ2.clear() ; | ||
387 | |||
376 | for(pool_set_t::iterator iter = mPools.begin(); | 388 | for(pool_set_t::iterator iter = mPools.begin(); |
377 | iter != mPools.end(); ) | 389 | iter != mPools.end(); ) |
378 | { | 390 | { |
@@ -469,33 +481,69 @@ void LLPipeline::resizeScreenTexture() | |||
469 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); | 481 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); |
470 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); | 482 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); |
471 | 483 | ||
472 | U32 res_mod = gSavedSettings.getU32("RenderResolutionDivisor"); | ||
473 | if (res_mod > 1 && res_mod < resX && res_mod < resY) | ||
474 | { | ||
475 | resX /= res_mod; | ||
476 | resY /= res_mod; | ||
477 | } | ||
478 | |||
479 | allocateScreenBuffer(resX,resY); | 484 | allocateScreenBuffer(resX,resY); |
480 | |||
481 | llinfos << "RESIZED SCREEN TEXTURE: " << resX << "x" << resY << llendl; | ||
482 | } | 485 | } |
483 | } | 486 | } |
484 | 487 | ||
485 | void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) | 488 | void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) |
486 | { | 489 | { |
490 | |||
487 | U32 samples = gSavedSettings.getU32("RenderFSAASamples"); | 491 | U32 samples = gSavedSettings.getU32("RenderFSAASamples"); |
492 | U32 res_mod = gSavedSettings.getU32("RenderResolutionDivisor"); | ||
493 | |||
494 | if (res_mod > 1 && res_mod < resX && res_mod < resY) | ||
495 | { | ||
496 | resX /= res_mod; | ||
497 | resY /= res_mod; | ||
498 | } | ||
499 | |||
500 | if (gSavedSettings.getBOOL("RenderUIBuffer")) | ||
501 | { | ||
502 | //mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); | ||
503 | } | ||
504 | |||
488 | if (LLPipeline::sRenderDeferred) | 505 | if (LLPipeline::sRenderDeferred) |
489 | { | 506 | { |
490 | //allocate deferred rendering color buffers | 507 | //allocate deferred rendering color buffers |
491 | mDeferredScreen.allocate(resX, resY, GL_RGBA16F_ARB, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); | 508 | mDeferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); |
509 | mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); | ||
492 | addDeferredAttachments(mDeferredScreen); | 510 | addDeferredAttachments(mDeferredScreen); |
493 | mScreen.allocate(resX, resY, GL_RGBA16F_ARB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); | 511 | |
494 | 512 | // always set viewport to desired size, since allocate resets the viewport | |
513 | |||
514 | mScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); | ||
515 | |||
516 | for (U32 i = 0; i < 3; i++) | ||
517 | { | ||
518 | mDeferredLight[i].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); | ||
519 | } | ||
520 | |||
495 | for (U32 i = 0; i < 2; i++) | 521 | for (U32 i = 0; i < 2; i++) |
496 | { | 522 | { |
497 | mDeferredLight[i].allocate(resX, resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); | 523 | mGIMapPost[i].allocate(resX,resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); |
524 | } | ||
525 | |||
526 | F32 scale = gSavedSettings.getF32("RenderShadowResolutionScale"); | ||
527 | |||
528 | for (U32 i = 0; i < 4; i++) | ||
529 | { | ||
530 | mShadow[i].allocate(U32(resX*scale),U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE); | ||
531 | } | ||
532 | |||
533 | |||
534 | U32 width = nhpo2(U32(resX*scale))/2; | ||
535 | U32 height = width; | ||
536 | |||
537 | for (U32 i = 4; i < 6; i++) | ||
538 | { | ||
539 | mShadow[i].allocate(width, height, 0, TRUE, FALSE); | ||
498 | } | 540 | } |
541 | |||
542 | |||
543 | |||
544 | width = nhpo2(resX)/2; | ||
545 | height = nhpo2(resY)/2; | ||
546 | mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE); | ||
499 | } | 547 | } |
500 | else | 548 | else |
501 | { | 549 | { |
@@ -505,25 +553,23 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) | |||
505 | 553 | ||
506 | if (gGLManager.mHasFramebufferMultisample && samples > 1) | 554 | if (gGLManager.mHasFramebufferMultisample && samples > 1) |
507 | { | 555 | { |
556 | mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples); | ||
508 | if (LLPipeline::sRenderDeferred) | 557 | if (LLPipeline::sRenderDeferred) |
509 | { | 558 | { |
510 | mSampleBuffer.allocate(resX,resY,GL_RGBA16F_ARB,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples); | ||
511 | addDeferredAttachments(mSampleBuffer); | 559 | addDeferredAttachments(mSampleBuffer); |
512 | mDeferredScreen.setSampleBuffer(&mSampleBuffer); | 560 | mDeferredScreen.setSampleBuffer(&mSampleBuffer); |
513 | } | 561 | } |
514 | else | ||
515 | { | ||
516 | mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples); | ||
517 | } | ||
518 | 562 | ||
519 | mScreen.setSampleBuffer(&mSampleBuffer); | 563 | mScreen.setSampleBuffer(&mSampleBuffer); |
564 | |||
520 | stop_glerror(); | 565 | stop_glerror(); |
521 | } | 566 | } |
522 | else if (LLPipeline::sRenderDeferred) | 567 | |
568 | if (LLPipeline::sRenderDeferred) | ||
523 | { //share depth buffer between deferred targets | 569 | { //share depth buffer between deferred targets |
524 | mDeferredScreen.shareDepthBuffer(mScreen); | 570 | mDeferredScreen.shareDepthBuffer(mScreen); |
525 | for (U32 i = 0; i < 2; i++) | 571 | for (U32 i = 0; i < 3; i++) |
526 | { | 572 | { //share stencil buffer with screen space lightmap to stencil out sky |
527 | mDeferredScreen.shareDepthBuffer(mDeferredLight[i]); | 573 | mDeferredScreen.shareDepthBuffer(mDeferredLight[i]); |
528 | } | 574 | } |
529 | } | 575 | } |
@@ -556,17 +602,40 @@ void LLPipeline::releaseGLBuffers() | |||
556 | mNoiseMap = 0; | 602 | mNoiseMap = 0; |
557 | } | 603 | } |
558 | 604 | ||
605 | /* if (mTrueNoiseMap) | ||
606 | { | ||
607 | LLImageGL::deleteTextures(1, &mTrueNoiseMap); | ||
608 | mTrueNoiseMap = 0; | ||
609 | } | ||
610 | */ | ||
611 | if (mLightFunc) | ||
612 | { | ||
613 | LLImageGL::deleteTextures(1, &mLightFunc); | ||
614 | mLightFunc = 0; | ||
615 | } | ||
616 | |||
559 | mWaterRef.release(); | 617 | mWaterRef.release(); |
560 | mWaterDis.release(); | 618 | mWaterDis.release(); |
561 | mScreen.release(); | 619 | mScreen.release(); |
562 | mSampleBuffer.releaseSampleBuffer(); | 620 | mSampleBuffer.releaseSampleBuffer(); |
563 | mDeferredScreen.release(); | 621 | mDeferredScreen.release(); |
622 | mDeferredDepth.release(); | ||
623 | for (U32 i = 0; i < 3; i++) | ||
624 | { | ||
625 | mDeferredLight[i].release(); | ||
626 | } | ||
627 | |||
628 | mGIMap.release(); | ||
629 | mGIMapPost[0].release(); | ||
630 | mGIMapPost[1].release(); | ||
631 | mHighlight.release(); | ||
632 | // mLuminanceMap.release(); | ||
564 | 633 | ||
565 | 634 | for (U32 i = 0; i < 6; i++) // KL 6 in SD | |
566 | for (U32 i = 0; i < 4; i++) | ||
567 | { | 635 | { |
568 | mSunShadow[i].release(); | 636 | mShadow[i].release(); |
569 | } | 637 | } |
638 | |||
570 | for (U32 i = 0; i < 3; i++) | 639 | for (U32 i = 0; i < 3; i++) |
571 | { | 640 | { |
572 | mGlow[i].release(); | 641 | mGlow[i].release(); |
@@ -589,9 +658,13 @@ void LLPipeline::createGLBuffers() | |||
589 | mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE); | 658 | mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE); |
590 | } | 659 | } |
591 | 660 | ||
661 | mHighlight.allocate(256,256,GL_RGBA, FALSE, FALSE); | ||
592 | 662 | ||
593 | stop_glerror(); | 663 | stop_glerror(); |
594 | 664 | ||
665 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); | ||
666 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); | ||
667 | |||
595 | if (LLPipeline::sRenderGlow) | 668 | if (LLPipeline::sRenderGlow) |
596 | { //screen space glow buffers | 669 | { //screen space glow buffers |
597 | const U32 glow_res = llmax(1, | 670 | const U32 glow_res = llmax(1, |
@@ -601,20 +674,13 @@ void LLPipeline::createGLBuffers() | |||
601 | { | 674 | { |
602 | mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE,FALSE); | 675 | mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE,FALSE); |
603 | } | 676 | } |
604 | } | ||
605 | 677 | ||
606 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); | 678 | allocateScreenBuffer(resX,resY); |
607 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); | ||
608 | |||
609 | allocateScreenBuffer(resX,resY); | ||
610 | 679 | ||
680 | } | ||
681 | |||
611 | if (sRenderDeferred) | 682 | if (sRenderDeferred) |
612 | { | 683 | { |
613 | mSunShadow[0].allocate(1024,1024, 0, TRUE, FALSE); | ||
614 | mSunShadow[1].allocate(1024,1024, 0, TRUE, FALSE); | ||
615 | mSunShadow[2].allocate(1024,1024, 0, TRUE, FALSE); | ||
616 | mSunShadow[3].allocate(1024,1024, 0, TRUE, FALSE); | ||
617 | |||
618 | if (!mNoiseMap) | 684 | if (!mNoiseMap) |
619 | { | 685 | { |
620 | const U32 noiseRes = 128; | 686 | const U32 noiseRes = 128; |
@@ -634,7 +700,83 @@ void LLPipeline::createGLBuffers() | |||
634 | LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise); | 700 | LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise); |
635 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | 701 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); |
636 | } | 702 | } |
637 | } | 703 | |
704 | /* if (!mTrueNoiseMap) | ||
705 | { | ||
706 | const U32 noiseRes = 128; | ||
707 | F32 noise[noiseRes*noiseRes*3]; | ||
708 | for (U32 i = 0; i < noiseRes*noiseRes*3; i++) | ||
709 | { | ||
710 | noise[i] = ll_frand()*2.0-1.0; | ||
711 | } | ||
712 | |||
713 | LLImageGL::generateTextures(1, &mTrueNoiseMap); | ||
714 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); | ||
715 | LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise); | ||
716 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
717 | } | ||
718 | */ | ||
719 | if (!mLightFunc) | ||
720 | { | ||
721 | U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); | ||
722 | U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); | ||
723 | U8* lg = new U8[lightResX*lightResY]; | ||
724 | |||
725 | for (U32 y = 0; y < lightResY; ++y) | ||
726 | { | ||
727 | for (U32 x = 0; x < lightResX; ++x) | ||
728 | { | ||
729 | //spec func | ||
730 | F32 sa = (F32) x/(lightResX-1); | ||
731 | F32 spec = (F32) y/(lightResY-1); | ||
732 | //lg[y*lightResX+x] = (U8) (powf(sa, 128.f*spec*spec)*255); | ||
733 | |||
734 | //F32 sp = acosf(sa)/(1.f-spec); | ||
735 | |||
736 | sa = powf(sa, gSavedSettings.getF32("RenderSpecularExponent")); | ||
737 | F32 a = acosf(sa*0.25f+0.75f); | ||
738 | F32 m = llmax(0.5f-spec*0.5f, 0.001f); | ||
739 | F32 t2 = tanf(a)/m; | ||
740 | t2 *= t2; | ||
741 | |||
742 | F32 c4a = (3.f+4.f*cosf(2.f*a)+cosf(4.f*a))/8.f; | ||
743 | F32 bd = 1.f/(4.f*m*m*c4a)*powf(F_E, -t2); | ||
744 | |||
745 | lg[y*lightResX+x] = (U8) (llclamp(bd, 0.f, 1.f)*255); | ||
746 | } | ||
747 | } | ||
748 | |||
749 | LLImageGL::generateTextures(1, &mLightFunc); | ||
750 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); | ||
751 | LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_ALPHA, lightResX, lightResY, GL_ALPHA, GL_UNSIGNED_BYTE, lg); | ||
752 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); | ||
753 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); | ||
754 | |||
755 | delete [] lg; | ||
756 | /* } | ||
757 | |||
758 | if (gSavedSettings.getBOOL("RenderDeferredGI")) | ||
759 | { */ | ||
760 | mGIMap.allocate(1024,1024,GL_RGBA, TRUE, FALSE); | ||
761 | addDeferredAttachments(mGIMap); | ||
762 | |||
763 | { | ||
764 | LLGLDepthTest depth(GL_TRUE); | ||
765 | gGL.setColorMask(true, true); | ||
766 | for (U32 i = 0; i < 2; i++) | ||
767 | { | ||
768 | mGIMapPost[i].allocate(128,128,GL_RGB16F_ARB, FALSE, FALSE); | ||
769 | mGIMapPost[i].addColorAttachment(GL_RGB16F_ARB); | ||
770 | mGIMapPost[i].addColorAttachment(GL_RGB16F_ARB); | ||
771 | mGIMapPost[i].addColorAttachment(GL_RGB16F_ARB); | ||
772 | |||
773 | mGIMapPost[i].bindTarget(); | ||
774 | mGIMapPost[i].clear(); | ||
775 | mGIMapPost[i].flush(); | ||
776 | } | ||
777 | } | ||
778 | } | ||
779 | } //mLuminanceMap.allocate(128,128, GL_RGBA, FALSE, FALSE); | ||
638 | } | 780 | } |
639 | 781 | ||
640 | void LLPipeline::restoreGL() | 782 | void LLPipeline::restoreGL() |
@@ -646,7 +788,7 @@ void LLPipeline::restoreGL() | |||
646 | LLViewerShaderMgr::instance()->setShaders(); | 788 | LLViewerShaderMgr::instance()->setShaders(); |
647 | } | 789 | } |
648 | 790 | ||
649 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 791 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
650 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 792 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
651 | { | 793 | { |
652 | LLViewerRegion* region = *iter; | 794 | LLViewerRegion* region = *iter; |
@@ -700,7 +842,7 @@ void LLPipeline::unloadShaders() | |||
700 | 842 | ||
701 | void LLPipeline::assertInitializedDoError() | 843 | void LLPipeline::assertInitializedDoError() |
702 | { | 844 | { |
703 | llerrs << "LLPipeline used when uninitialized." << llendl; | 845 | llwarns << "LLPipeline used when uninitialized." << llendl; |
704 | } | 846 | } |
705 | 847 | ||
706 | //============================================================================ | 848 | //============================================================================ |
@@ -763,7 +905,7 @@ public: | |||
763 | for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j) | 905 | for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j) |
764 | { | 906 | { |
765 | LLDrawInfo* params = *j; | 907 | LLDrawInfo* params = *j; |
766 | if (mTextures.find(params->mTexture) != mTextures.end()) | 908 | if (mTextures.find(params->mViewerTexture) != mTextures.end()) |
767 | { | 909 | { |
768 | group->setState(LLSpatialGroup::GEOM_DIRTY); | 910 | group->setState(LLSpatialGroup::GEOM_DIRTY); |
769 | } | 911 | } |
@@ -797,7 +939,7 @@ void LLPipeline::dirtyPoolObjectTextures(const std::set<LLViewerImage*>& texture | |||
797 | } | 939 | } |
798 | 940 | ||
799 | LLOctreeDirtyTexture dirty(textures); | 941 | LLOctreeDirtyTexture dirty(textures); |
800 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 942 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
801 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 943 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
802 | { | 944 | { |
803 | LLViewerRegion* region = *iter; | 945 | LLViewerRegion* region = *iter; |
@@ -876,7 +1018,7 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerImage *tex0) | |||
876 | 1018 | ||
877 | default: | 1019 | default: |
878 | llassert(0); | 1020 | llassert(0); |
879 | llerrs << "Invalid Pool Type in LLPipeline::findPool() type=" << type << llendl; | 1021 | llwarns << "Invalid Pool Type in LLPipeline::findPool() type=" << type << llendl; |
880 | break; | 1022 | break; |
881 | } | 1023 | } |
882 | 1024 | ||
@@ -991,7 +1133,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable) | |||
991 | #ifdef LL_RELEASE_FOR_DOWNLOAD | 1133 | #ifdef LL_RELEASE_FOR_DOWNLOAD |
992 | llwarns << "Couldn't remove object from spatial group!" << llendl; | 1134 | llwarns << "Couldn't remove object from spatial group!" << llendl; |
993 | #else | 1135 | #else |
994 | llerrs << "Couldn't remove object from spatial group!" << llendl; | 1136 | llwarns << "Couldn't remove object from spatial group!" << llendl; |
995 | #endif | 1137 | #endif |
996 | } | 1138 | } |
997 | } | 1139 | } |
@@ -1006,6 +1148,31 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable) | |||
1006 | break; | 1148 | break; |
1007 | } | 1149 | } |
1008 | } | 1150 | } |
1151 | |||
1152 | { | ||
1153 | HighlightItem item(drawablep); | ||
1154 | mHighlightSet.erase(item); | ||
1155 | |||
1156 | if (mHighlightObject == drawablep) | ||
1157 | { | ||
1158 | mHighlightObject = NULL; | ||
1159 | } | ||
1160 | } | ||
1161 | |||
1162 | for (U32 i = 0; i < 2; ++i) | ||
1163 | { | ||
1164 | if (mShadowSpotLight[i] == drawablep) | ||
1165 | { | ||
1166 | mShadowSpotLight[i] = NULL; | ||
1167 | } | ||
1168 | |||
1169 | if (mTargetShadowSpotLight[i] == drawablep) | ||
1170 | { | ||
1171 | mTargetShadowSpotLight[i] = NULL; | ||
1172 | } | ||
1173 | } | ||
1174 | |||
1175 | |||
1009 | } | 1176 | } |
1010 | 1177 | ||
1011 | U32 LLPipeline::addObject(LLViewerObject *vobj) | 1178 | U32 LLPipeline::addObject(LLViewerObject *vobj) |
@@ -1062,7 +1229,7 @@ void LLPipeline::createObject(LLViewerObject* vobj) | |||
1062 | } | 1229 | } |
1063 | else | 1230 | else |
1064 | { | 1231 | { |
1065 | llerrs << "Redundant drawable creation!" << llendl; | 1232 | llwarns << "Redundant drawable creation!" << llendl; |
1066 | } | 1233 | } |
1067 | 1234 | ||
1068 | llassert(drawablep); | 1235 | llassert(drawablep); |
@@ -1123,7 +1290,7 @@ void LLPipeline::updateMoveDampedAsync(LLDrawable* drawablep) | |||
1123 | } | 1290 | } |
1124 | if (!drawablep) | 1291 | if (!drawablep) |
1125 | { | 1292 | { |
1126 | llerrs << "updateMove called with NULL drawablep" << llendl; | 1293 | llwarns << "updateMove called with NULL drawablep" << llendl; |
1127 | return; | 1294 | return; |
1128 | } | 1295 | } |
1129 | if (drawablep->isState(LLDrawable::EARLY_MOVE)) | 1296 | if (drawablep->isState(LLDrawable::EARLY_MOVE)) |
@@ -1153,7 +1320,8 @@ void LLPipeline::updateMoveNormalAsync(LLDrawable* drawablep) | |||
1153 | } | 1320 | } |
1154 | if (!drawablep) | 1321 | if (!drawablep) |
1155 | { | 1322 | { |
1156 | llerrs << "updateMove called with NULL drawablep" << llendl; | 1323 | llwarns << "updateMove called with NULL drawablep" << llendl; |
1324 | return; | ||
1157 | } | 1325 | } |
1158 | if (drawablep->isState(LLDrawable::EARLY_MOVE)) | 1326 | if (drawablep->isState(LLDrawable::EARLY_MOVE)) |
1159 | { | 1327 | { |
@@ -1245,7 +1413,7 @@ void LLPipeline::updateMove() | |||
1245 | { | 1413 | { |
1246 | LLFastTimer ot(LLFastTimer::FTM_OCTREE_BALANCE); | 1414 | LLFastTimer ot(LLFastTimer::FTM_OCTREE_BALANCE); |
1247 | 1415 | ||
1248 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 1416 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
1249 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 1417 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
1250 | { | 1418 | { |
1251 | LLViewerRegion* region = *iter; | 1419 | LLViewerRegion* region = *iter; |
@@ -1272,7 +1440,6 @@ F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera | |||
1272 | F32 dist = lookAt.length(); | 1440 | F32 dist = lookAt.length(); |
1273 | 1441 | ||
1274 | //ramp down distance for nearby objects | 1442 | //ramp down distance for nearby objects |
1275 | //shrink dist by dist/16. | ||
1276 | if (dist < 16.f) | 1443 | if (dist < 16.f) |
1277 | { | 1444 | { |
1278 | dist /= 16.f; | 1445 | dist /= 16.f; |
@@ -1293,7 +1460,7 @@ void LLPipeline::grabReferences(LLCullResult& result) | |||
1293 | 1460 | ||
1294 | BOOL LLPipeline::visibleObjectsInFrustum(LLCamera& camera) | 1461 | BOOL LLPipeline::visibleObjectsInFrustum(LLCamera& camera) |
1295 | { | 1462 | { |
1296 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 1463 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
1297 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 1464 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
1298 | { | 1465 | { |
1299 | LLViewerRegion* region = *iter; | 1466 | LLViewerRegion* region = *iter; |
@@ -1325,7 +1492,7 @@ BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& | |||
1325 | 1492 | ||
1326 | BOOL res = TRUE; | 1493 | BOOL res = TRUE; |
1327 | 1494 | ||
1328 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 1495 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
1329 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 1496 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
1330 | { | 1497 | { |
1331 | LLViewerRegion* region = *iter; | 1498 | LLViewerRegion* region = *iter; |
@@ -1388,7 +1555,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl | |||
1388 | 1555 | ||
1389 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); | 1556 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); |
1390 | 1557 | ||
1391 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 1558 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
1392 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 1559 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
1393 | { | 1560 | { |
1394 | LLViewerRegion* region = *iter; | 1561 | LLViewerRegion* region = *iter; |
@@ -1465,7 +1632,7 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) | |||
1465 | 1632 | ||
1466 | group->setVisible(); | 1633 | group->setVisible(); |
1467 | 1634 | ||
1468 | if (!sSkipUpdate) | 1635 | if (!sSkipUpdate) // && !sShadowRender) KL? |
1469 | { | 1636 | { |
1470 | group->updateDistance(camera); | 1637 | group->updateDistance(camera); |
1471 | } | 1638 | } |
@@ -1556,6 +1723,78 @@ BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority) | |||
1556 | return update_complete; | 1723 | return update_complete; |
1557 | } | 1724 | } |
1558 | 1725 | ||
1726 | void LLPipeline::updateGL() // KL SD | ||
1727 | { | ||
1728 | while (!LLGLUpdate::sGLQ.empty()) | ||
1729 | { | ||
1730 | LLGLUpdate* glu = LLGLUpdate::sGLQ.front(); | ||
1731 | glu->updateGL(); | ||
1732 | glu->mInQ = FALSE; | ||
1733 | LLGLUpdate::sGLQ.pop_front(); | ||
1734 | } | ||
1735 | } // KL updateGL SD | ||
1736 | |||
1737 | void LLPipeline::rebuildPriorityGroups() | ||
1738 | { | ||
1739 | LLTimer update_timer; | ||
1740 | LLMemType mt(LLMemType::MTYPE_PIPELINE); | ||
1741 | |||
1742 | assertInitialized(); | ||
1743 | |||
1744 | // Iterate through all drawables on the priority build queue, | ||
1745 | for (LLSpatialGroup::sg_list_t::iterator iter = mGroupQ1.begin(); | ||
1746 | iter != mGroupQ1.end(); ++iter) | ||
1747 | { | ||
1748 | LLSpatialGroup* group = *iter; | ||
1749 | group->rebuildGeom(); | ||
1750 | group->clearState(LLSpatialGroup::IN_BUILD_Q1); | ||
1751 | } | ||
1752 | |||
1753 | mGroupQ1.clear(); | ||
1754 | } | ||
1755 | |||
1756 | void LLPipeline::rebuildGroups() | ||
1757 | { | ||
1758 | // Iterate through some drawables on the non-priority build queue | ||
1759 | S32 size = (S32) mGroupQ2.size(); | ||
1760 | S32 min_count = llclamp((S32) ((F32) (size * size)/4096*0.25f), 1, size); | ||
1761 | |||
1762 | S32 count = 0; | ||
1763 | |||
1764 | std::sort(mGroupQ2.begin(), mGroupQ2.end(), LLSpatialGroup::CompareUpdateUrgency()); // KL | ||
1765 | |||
1766 | LLSpatialGroup::sg_vector_t::iterator iter; | ||
1767 | for (iter = mGroupQ2.begin(); | ||
1768 | iter != mGroupQ2.end(); ++iter) | ||
1769 | { | ||
1770 | LLSpatialGroup* group = *iter; | ||
1771 | |||
1772 | if (group->isDead()) | ||
1773 | { | ||
1774 | continue; | ||
1775 | } | ||
1776 | |||
1777 | group->rebuildGeom(); | ||
1778 | |||
1779 | if (group->mSpatialPartition->mRenderByGroup) | ||
1780 | { | ||
1781 | count++; | ||
1782 | } | ||
1783 | |||
1784 | group->clearState(LLSpatialGroup::IN_BUILD_Q2); | ||
1785 | |||
1786 | if (count > min_count) | ||
1787 | { | ||
1788 | ++iter; | ||
1789 | break; | ||
1790 | } | ||
1791 | } | ||
1792 | |||
1793 | mGroupQ2.erase(mGroupQ2.begin(), iter); | ||
1794 | |||
1795 | updateMovedList(mMovedBridge); | ||
1796 | } | ||
1797 | |||
1559 | void LLPipeline::updateGeom(F32 max_dtime) | 1798 | void LLPipeline::updateGeom(F32 max_dtime) |
1560 | { | 1799 | { |
1561 | LLTimer update_timer; | 1800 | LLTimer update_timer; |
@@ -1670,6 +1909,16 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) | |||
1670 | 1909 | ||
1671 | if (drawablep->isSpatialBridge()) | 1910 | if (drawablep->isSpatialBridge()) |
1672 | { | 1911 | { |
1912 | LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable; | ||
1913 | |||
1914 | if (root && root->getParent() && root->getVObj() && root->getVObj()->isAttachment()) | ||
1915 | { | ||
1916 | LLVOAvatar* av = root->getParent()->getVObj()->asAvatar(); | ||
1917 | if (av->isImpostor()) | ||
1918 | { | ||
1919 | return; | ||
1920 | } | ||
1921 | } | ||
1673 | sCull->pushBridge((LLSpatialBridge*) drawablep); | 1922 | sCull->pushBridge((LLSpatialBridge*) drawablep); |
1674 | } | 1923 | } |
1675 | else | 1924 | else |
@@ -1686,7 +1935,7 @@ void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion) | |||
1686 | 1935 | ||
1687 | if (!drawablep) | 1936 | if (!drawablep) |
1688 | { | 1937 | { |
1689 | //llerrs << "Sending null drawable to moved list!" << llendl; | 1938 | //llwarns << "Sending null drawable to moved list!" << llendl; |
1690 | return; | 1939 | return; |
1691 | } | 1940 | } |
1692 | 1941 | ||
@@ -1771,7 +2020,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) | |||
1771 | } | 2020 | } |
1772 | mShiftList.resize(0); | 2021 | mShiftList.resize(0); |
1773 | 2022 | ||
1774 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 2023 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
1775 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 2024 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
1776 | { | 2025 | { |
1777 | LLViewerRegion* region = *iter; | 2026 | LLViewerRegion* region = *iter; |
@@ -1799,6 +2048,54 @@ void LLPipeline::markTextured(LLDrawable *drawablep) | |||
1799 | } | 2048 | } |
1800 | } | 2049 | } |
1801 | 2050 | ||
2051 | void LLPipeline::markGLRebuild(LLGLUpdate* glu) | ||
2052 | { | ||
2053 | if (glu && !glu->mInQ) | ||
2054 | { | ||
2055 | LLGLUpdate::sGLQ.push_back(glu); | ||
2056 | glu->mInQ = TRUE; | ||
2057 | } | ||
2058 | } | ||
2059 | |||
2060 | void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority) | ||
2061 | { | ||
2062 | LLMemType mt(LLMemType::MTYPE_PIPELINE); | ||
2063 | //assert_main_thread(); | ||
2064 | |||
2065 | if (group && !group->isDead() && group->mSpatialPartition) | ||
2066 | { | ||
2067 | if (priority) | ||
2068 | { | ||
2069 | if (!group->isState(LLSpatialGroup::IN_BUILD_Q1)) | ||
2070 | { | ||
2071 | mGroupQ1.push_back(group); | ||
2072 | group->setState(LLSpatialGroup::IN_BUILD_Q1); | ||
2073 | |||
2074 | if (group->isState(LLSpatialGroup::IN_BUILD_Q2)) | ||
2075 | { | ||
2076 | LLSpatialGroup::sg_vector_t::iterator iter = std::find(mGroupQ2.begin(), mGroupQ2.end(), group); | ||
2077 | if (iter != mGroupQ2.end()) | ||
2078 | { | ||
2079 | mGroupQ2.erase(iter); | ||
2080 | } | ||
2081 | group->clearState(LLSpatialGroup::IN_BUILD_Q2); | ||
2082 | } | ||
2083 | } | ||
2084 | } | ||
2085 | else if (!group->isState(LLSpatialGroup::IN_BUILD_Q2 | LLSpatialGroup::IN_BUILD_Q1)) | ||
2086 | { | ||
2087 | //llwarns << "Non-priority updates not yet supported!" << llendl; | ||
2088 | if (std::find(mGroupQ2.begin(), mGroupQ2.end(), group) != mGroupQ2.end()) | ||
2089 | { | ||
2090 | llwarns << "WTF?" << llendl; | ||
2091 | } | ||
2092 | mGroupQ2.push_back(group); | ||
2093 | group->setState(LLSpatialGroup::IN_BUILD_Q2); | ||
2094 | |||
2095 | } | ||
2096 | } | ||
2097 | } | ||
2098 | |||
1802 | void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, BOOL priority) | 2099 | void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, BOOL priority) |
1803 | { | 2100 | { |
1804 | LLMemType mt(LLMemType::MTYPE_PIPELINE); | 2101 | LLMemType mt(LLMemType::MTYPE_PIPELINE); |
@@ -1853,12 +2150,13 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) | |||
1853 | 2150 | ||
1854 | grabReferences(result); | 2151 | grabReferences(result); |
1855 | 2152 | ||
2153 | //if (!LLPipeline::sShadowRender) | ||
1856 | { | 2154 | { |
1857 | for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter) | 2155 | for (LLCullResult::sg_list_t::iterator iter = sCull->beginDrawableGroups(); iter != sCull->endDrawableGroups(); ++iter) |
1858 | { | 2156 | { |
1859 | LLSpatialGroup* group = *iter; | 2157 | LLSpatialGroup* group = *iter; |
1860 | group->checkOcclusion(); | 2158 | group->checkOcclusion(); |
1861 | if (sUseOcclusion && group->isState(LLSpatialGroup::OCCLUDED)) | 2159 | if (sUseOcclusion > 1 && group->isState(LLSpatialGroup::OCCLUDED)) |
1862 | { | 2160 | { |
1863 | markOccluder(group); | 2161 | markOccluder(group); |
1864 | } | 2162 | } |
@@ -1871,12 +2169,15 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) | |||
1871 | } | 2169 | } |
1872 | } | 2170 | } |
1873 | } | 2171 | } |
2172 | } | ||
1874 | 2173 | ||
2174 | if (!LLPipeline::sShadowRender) | ||
2175 | { | ||
1875 | for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) | 2176 | for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) |
1876 | { | 2177 | { |
1877 | LLSpatialGroup* group = *iter; | 2178 | LLSpatialGroup* group = *iter; |
1878 | group->checkOcclusion(); | 2179 | group->checkOcclusion(); |
1879 | if (sUseOcclusion && group->isState(LLSpatialGroup::OCCLUDED)) | 2180 | if (sUseOcclusion > 1 && group->isState(LLSpatialGroup::OCCLUDED)) |
1880 | { | 2181 | { |
1881 | markOccluder(group); | 2182 | markOccluder(group); |
1882 | } | 2183 | } |
@@ -1888,6 +2189,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) | |||
1888 | } | 2189 | } |
1889 | } | 2190 | } |
1890 | 2191 | ||
2192 | if (!LLPipeline::sShadowRender) | ||
1891 | { | 2193 | { |
1892 | for (LLCullResult::bridge_list_t::iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i) | 2194 | for (LLCullResult::bridge_list_t::iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i) |
1893 | { | 2195 | { |
@@ -1939,7 +2241,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) | |||
1939 | void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera) | 2241 | void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera) |
1940 | { | 2242 | { |
1941 | LLMemType mt(LLMemType::MTYPE_PIPELINE); | 2243 | LLMemType mt(LLMemType::MTYPE_PIPELINE); |
1942 | if (!sSkipUpdate && bridge->getSpatialGroup()->changeLOD()) | 2244 | if (!sSkipUpdate && !sShadowRender && bridge->getSpatialGroup()->changeLOD()) |
1943 | { | 2245 | { |
1944 | bool force_update = false; | 2246 | bool force_update = false; |
1945 | bridge->updateDistance(camera, force_update); | 2247 | bridge->updateDistance(camera, force_update); |
@@ -2001,41 +2303,46 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) | |||
2001 | } | 2303 | } |
2002 | } | 2304 | } |
2003 | 2305 | ||
2004 | LLSpatialGroup* group = drawablep->getSpatialGroup(); | 2306 | if (!sShadowRender) |
2005 | if (!group || group->changeLOD()) | ||
2006 | { | 2307 | { |
2007 | if (drawablep->isVisible() && !sSkipUpdate) | 2308 | LLSpatialGroup* group = drawablep->getSpatialGroup(); |
2309 | if (!group || group->changeLOD()) | ||
2008 | { | 2310 | { |
2009 | if (!drawablep->isActive()) | 2311 | if (drawablep->isVisible() && !sSkipUpdate) |
2010 | { | 2312 | { |
2011 | bool force_update = false; | 2313 | if (!drawablep->isActive()) |
2012 | drawablep->updateDistance(camera, force_update); | 2314 | { |
2315 | drawablep->updateDistance(camera, TRUE); | ||
2316 | } | ||
2317 | else if (drawablep->isAvatar()) | ||
2318 | { | ||
2319 | drawablep->updateDistance(camera, TRUE); // calls vobj->updateLOD() which calls LLVOAvatar::updateVisibility() | ||
2320 | } | ||
2013 | } | 2321 | } |
2014 | else if (drawablep->isAvatar()) | ||
2015 | { | ||
2016 | bool force_update = false; | ||
2017 | drawablep->updateDistance(camera, force_update); // calls vobj->updateLOD() which calls LLVOAvatar::updateVisibility() | ||
2018 | } | ||
2019 | } | 2322 | } |
2020 | } | 2323 | } |
2021 | 2324 | ||
2022 | for (LLDrawable::face_list_t::iterator iter = drawablep->mFaces.begin(); | 2325 | if (!drawablep->getVOVolume()) |
2023 | iter != drawablep->mFaces.end(); iter++) | ||
2024 | { | 2326 | { |
2025 | LLFace* facep = *iter; | 2327 | for (LLDrawable::face_list_t::iterator iter = drawablep->mFaces.begin(); |
2026 | 2328 | iter != drawablep->mFaces.end(); iter++) | |
2027 | if (facep->hasGeometry()) | ||
2028 | { | 2329 | { |
2029 | if (facep->getPool()) | 2330 | LLFace* facep = *iter; |
2030 | { | 2331 | |
2031 | facep->getPool()->enqueue(facep); | 2332 | if (facep->hasGeometry()) |
2032 | } | ||
2033 | else | ||
2034 | { | 2333 | { |
2035 | break; | 2334 | if (facep->getPool()) |
2335 | { | ||
2336 | facep->getPool()->enqueue(facep); | ||
2337 | } | ||
2338 | else | ||
2339 | { | ||
2340 | break; | ||
2341 | } | ||
2036 | } | 2342 | } |
2037 | } | 2343 | } |
2038 | } | 2344 | } |
2345 | |||
2039 | 2346 | ||
2040 | mNumVisibleFaces += drawablep->getNumFaces(); | 2347 | mNumVisibleFaces += drawablep->getNumFaces(); |
2041 | } | 2348 | } |
@@ -2201,7 +2508,7 @@ void LLPipeline::postSort(LLCamera& camera) | |||
2201 | //rebuild groups | 2508 | //rebuild groups |
2202 | sCull->assertDrawMapsEmpty(); | 2509 | sCull->assertDrawMapsEmpty(); |
2203 | 2510 | ||
2204 | LLSpatialGroup::sNoDelete = FALSE; | 2511 | /*LLSpatialGroup::sNoDelete = FALSE; |
2205 | for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) | 2512 | for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) |
2206 | { | 2513 | { |
2207 | LLSpatialGroup* group = *i; | 2514 | LLSpatialGroup* group = *i; |
@@ -2213,8 +2520,10 @@ void LLPipeline::postSort(LLCamera& camera) | |||
2213 | 2520 | ||
2214 | group->rebuildGeom(); | 2521 | group->rebuildGeom(); |
2215 | } | 2522 | } |
2216 | LLSpatialGroup::sNoDelete = TRUE; | 2523 | LLSpatialGroup::sNoDelete = TRUE;*/ |
2524 | |||
2217 | 2525 | ||
2526 | rebuildPriorityGroups(); | ||
2218 | 2527 | ||
2219 | const S32 bin_count = 1024*8; | 2528 | const S32 bin_count = 1024*8; |
2220 | 2529 | ||
@@ -2240,39 +2549,51 @@ void LLPipeline::postSort(LLCamera& camera) | |||
2240 | { | 2549 | { |
2241 | continue; | 2550 | continue; |
2242 | } | 2551 | } |
2243 | 2552 | ||
2553 | if (group->isState(LLSpatialGroup::NEW_DRAWINFO) && group->isState(LLSpatialGroup::GEOM_DIRTY)) | ||
2554 | { //no way this group is going to be drawable without a rebuild | ||
2555 | group->rebuildGeom(); | ||
2556 | } | ||
2557 | |||
2244 | for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j) | 2558 | for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j) |
2245 | { | 2559 | { |
2246 | LLSpatialGroup::drawmap_elem_t& src_vec = j->second; | 2560 | LLSpatialGroup::drawmap_elem_t& src_vec = j->second; |
2247 | 2561 | if (!hasRenderType(j->first)) | |
2562 | { | ||
2563 | continue; | ||
2564 | } | ||
2565 | |||
2248 | for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) | 2566 | for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) |
2249 | { | 2567 | { |
2250 | sCull->pushDrawInfo(j->first, *k); | 2568 | sCull->pushDrawInfo(j->first, *k); |
2251 | } | 2569 | } |
2252 | } | 2570 | } |
2253 | 2571 | ||
2254 | LLSpatialGroup::draw_map_t::iterator alpha = group->mDrawMap.find(LLRenderPass::PASS_ALPHA); | 2572 | if (hasRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA)) |
2255 | 2573 | { | |
2256 | if (alpha != group->mDrawMap.end()) | 2574 | LLSpatialGroup::draw_map_t::iterator alpha = group->mDrawMap.find(LLRenderPass::PASS_ALPHA); |
2257 | { //store alpha groups for sorting | 2575 | |
2258 | LLSpatialBridge* bridge = group->mSpatialPartition->asBridge(); | 2576 | if (alpha != group->mDrawMap.end()) |
2259 | if (!sSkipUpdate) | 2577 | { //store alpha groups for sorting |
2260 | { | 2578 | LLSpatialBridge* bridge = group->mSpatialPartition->asBridge(); |
2261 | if (bridge) | 2579 | if (!sSkipUpdate) |
2262 | { | 2580 | { |
2263 | LLCamera trans_camera = bridge->transformCamera(camera); | 2581 | if (bridge) |
2264 | group->updateDistance(trans_camera); | 2582 | { |
2583 | LLCamera trans_camera = bridge->transformCamera(camera); | ||
2584 | group->updateDistance(trans_camera); | ||
2585 | } | ||
2586 | else | ||
2587 | { | ||
2588 | group->updateDistance(camera); | ||
2589 | } | ||
2265 | } | 2590 | } |
2266 | else | 2591 | |
2592 | if (hasRenderType(LLDrawPool::POOL_ALPHA)) | ||
2267 | { | 2593 | { |
2268 | group->updateDistance(camera); | 2594 | sCull->pushAlphaGroup(group); |
2269 | } | 2595 | } |
2270 | } | 2596 | } |
2271 | |||
2272 | if (hasRenderType(LLDrawPool::POOL_ALPHA)) | ||
2273 | { | ||
2274 | sCull->pushAlphaGroup(group); | ||
2275 | } | ||
2276 | } | 2597 | } |
2277 | } | 2598 | } |
2278 | 2599 | ||
@@ -2370,7 +2691,7 @@ void LLPipeline::postSort(LLCamera& camera) | |||
2370 | } | 2691 | } |
2371 | } | 2692 | } |
2372 | 2693 | ||
2373 | LLSpatialGroup::sNoDelete = FALSE; | 2694 | //LLSpatialGroup::sNoDelete = FALSE; |
2374 | } | 2695 | } |
2375 | 2696 | ||
2376 | 2697 | ||
@@ -2431,6 +2752,103 @@ void LLPipeline::renderHighlights() | |||
2431 | LLGLEnable color_mat(GL_COLOR_MATERIAL); | 2752 | LLGLEnable color_mat(GL_COLOR_MATERIAL); |
2432 | disableLights(); | 2753 | disableLights(); |
2433 | 2754 | ||
2755 | if (!hasRenderType(LLPipeline::RENDER_TYPE_HUD) && !mHighlightSet.empty()) | ||
2756 | { //draw blurry highlight image over screen | ||
2757 | LLGLEnable blend(GL_BLEND); | ||
2758 | LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); | ||
2759 | LLGLDisable test(GL_ALPHA_TEST); | ||
2760 | |||
2761 | LLGLEnable stencil(GL_STENCIL_TEST); | ||
2762 | gGL.flush(); | ||
2763 | glStencilMask(0xFFFFFFFF); | ||
2764 | glClearStencil(1); | ||
2765 | glClear(GL_STENCIL_BUFFER_BIT); | ||
2766 | |||
2767 | glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF); | ||
2768 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); | ||
2769 | |||
2770 | gGL.setColorMask(false, false); | ||
2771 | for (std::set<HighlightItem>::iterator iter = mHighlightSet.begin(); iter != mHighlightSet.end(); ++iter) | ||
2772 | { | ||
2773 | renderHighlight(iter->mItem->getVObj(), 1.f); | ||
2774 | } | ||
2775 | gGL.setColorMask(true, false); | ||
2776 | |||
2777 | glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | ||
2778 | glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); | ||
2779 | |||
2780 | //gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); | ||
2781 | |||
2782 | gGL.pushMatrix(); | ||
2783 | glLoadIdentity(); | ||
2784 | glMatrixMode(GL_PROJECTION); | ||
2785 | gGL.pushMatrix(); | ||
2786 | glLoadIdentity(); | ||
2787 | |||
2788 | gGL.getTexUnit(0)->bind(&mHighlight); | ||
2789 | |||
2790 | LLVector2 tc1; | ||
2791 | LLVector2 tc2; | ||
2792 | |||
2793 | tc1.setVec(0,0); | ||
2794 | tc2.setVec(2,2); | ||
2795 | |||
2796 | gGL.begin(LLRender::TRIANGLES); | ||
2797 | |||
2798 | F32 scale = gSavedSettings.getF32("RenderHighlightBrightness"); | ||
2799 | LLColor4 color = gSavedSettings.getColor4("RenderHighlightColor"); | ||
2800 | F32 thickness = gSavedSettings.getF32("RenderHighlightThickness"); | ||
2801 | |||
2802 | for (S32 pass = 0; pass < 2; ++pass) | ||
2803 | { | ||
2804 | if (pass == 0) | ||
2805 | { | ||
2806 | gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); | ||
2807 | } | ||
2808 | else | ||
2809 | { | ||
2810 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | ||
2811 | } | ||
2812 | |||
2813 | for (S32 i = 0; i < 8; ++i) | ||
2814 | { | ||
2815 | for (S32 j = 0; j < 8; ++j) | ||
2816 | { | ||
2817 | LLVector2 tc(i-4+0.5f, j-4+0.5f); | ||
2818 | |||
2819 | F32 dist = 1.f-(tc.length()/sqrtf(32.f)); | ||
2820 | dist *= scale/64.f; | ||
2821 | |||
2822 | tc *= thickness; | ||
2823 | tc.mV[0] = (tc.mV[0])/mHighlight.getWidth(); | ||
2824 | tc.mV[1] = (tc.mV[1])/mHighlight.getHeight(); | ||
2825 | |||
2826 | gGL.color4f(color.mV[0], | ||
2827 | color.mV[1], | ||
2828 | color.mV[2], | ||
2829 | color.mV[3]*dist); | ||
2830 | |||
2831 | gGL.texCoord2f(tc.mV[0]+tc1.mV[0], tc.mV[1]+tc2.mV[1]); | ||
2832 | gGL.vertex2f(-1,3); | ||
2833 | |||
2834 | gGL.texCoord2f(tc.mV[0]+tc1.mV[0], tc.mV[1]+tc1.mV[1]); | ||
2835 | gGL.vertex2f(-1,-1); | ||
2836 | |||
2837 | gGL.texCoord2f(tc.mV[0]+tc2.mV[0], tc.mV[1]+tc1.mV[1]); | ||
2838 | gGL.vertex2f(3,-1); | ||
2839 | } | ||
2840 | } | ||
2841 | } | ||
2842 | |||
2843 | gGL.end(); | ||
2844 | |||
2845 | gGL.popMatrix(); | ||
2846 | glMatrixMode(GL_MODELVIEW); | ||
2847 | gGL.popMatrix(); | ||
2848 | |||
2849 | //gGL.setSceneBlendType(LLRender::BT_ALPHA); | ||
2850 | } | ||
2851 | |||
2434 | if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) | 2852 | if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) |
2435 | { | 2853 | { |
2436 | gHighlightProgram.bind(); | 2854 | gHighlightProgram.bind(); |
@@ -2453,7 +2871,7 @@ void LLPipeline::renderHighlights() | |||
2453 | LLFace *facep = mSelectedFaces[i]; | 2871 | LLFace *facep = mSelectedFaces[i]; |
2454 | if (!facep || facep->getDrawable()->isDead()) | 2872 | if (!facep || facep->getDrawable()->isDead()) |
2455 | { | 2873 | { |
2456 | llerrs << "Bad face on selection" << llendl; | 2874 | llwarns << "Bad face on selection" << llendl; |
2457 | return; | 2875 | return; |
2458 | } | 2876 | } |
2459 | 2877 | ||
@@ -2526,7 +2944,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2526 | { | 2944 | { |
2527 | if (!verify()) | 2945 | if (!verify()) |
2528 | { | 2946 | { |
2529 | llerrs << "Pipeline verification failed!" << llendl; | 2947 | llwarns << "Pipeline verification failed!" << llendl; |
2530 | } | 2948 | } |
2531 | } | 2949 | } |
2532 | 2950 | ||
@@ -2575,6 +2993,9 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2575 | stop_glerror(); | 2993 | stop_glerror(); |
2576 | 2994 | ||
2577 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDrawPools"); | 2995 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDrawPools"); |
2996 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderForSelect"); | ||
2997 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderDeferred"); | ||
2998 | |||
2578 | for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) | 2999 | for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) |
2579 | { | 3000 | { |
2580 | LLDrawPool *poolp = *iter; | 3001 | LLDrawPool *poolp = *iter; |
@@ -2586,7 +3007,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2586 | 3007 | ||
2587 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PICKING)) | 3008 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PICKING)) |
2588 | { | 3009 | { |
2589 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderForSelect"); | ||
2590 | gObjectList.renderObjectsForSelect(camera, gViewerWindow->getVirtualWindowRect()); | 3010 | gObjectList.renderObjectsForSelect(camera, gViewerWindow->getVirtualWindowRect()); |
2591 | } | 3011 | } |
2592 | else | 3012 | else |
@@ -2650,7 +3070,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2650 | glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); | 3070 | glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); |
2651 | if (depth > 3) | 3071 | if (depth > 3) |
2652 | { | 3072 | { |
2653 | llerrs << "GL matrix stack corrupted!" << llendl; | 3073 | |
3074 | llwarns << "GL matrix stack corrupted!" << llendl; | ||
2654 | } | 3075 | } |
2655 | std::string msg = llformat("%s pass %d", gPoolNames[cur_type].c_str(), i); | 3076 | std::string msg = llformat("%s pass %d", gPoolNames[cur_type].c_str(), i); |
2656 | LLGLState::checkStates(msg); | 3077 | LLGLState::checkStates(msg); |
@@ -2721,20 +3142,12 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2721 | 3142 | ||
2722 | LLVertexBuffer::unbind(); | 3143 | LLVertexBuffer::unbind(); |
2723 | 3144 | ||
2724 | if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred) | 3145 | if (!LLPipeline::sReflectionRender && !LLPipeline::sRenderDeferred && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) |
2725 | { | 3146 | { |
2726 | if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) | 3147 | // Render debugging beacons. |
2727 | { | 3148 | gObjectList.renderObjectBeacons(); |
2728 | // Render debugging beacons. | 3149 | LLHUDObject::renderAll(); |
2729 | gObjectList.renderObjectBeacons(); | 3150 | gObjectList.resetObjectBeacons(); |
2730 | LLHUDObject::renderAll(); | ||
2731 | gObjectList.resetObjectBeacons(); | ||
2732 | } | ||
2733 | else | ||
2734 | { | ||
2735 | // Make sure particle effects disappear | ||
2736 | LLHUDObject::renderAllForTimer(); | ||
2737 | } | ||
2738 | } | 3151 | } |
2739 | 3152 | ||
2740 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd"); | 3153 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomEnd"); |
@@ -2758,7 +3171,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2758 | 3171 | ||
2759 | void LLPipeline::renderGeomDeferred(LLCamera& camera) | 3172 | void LLPipeline::renderGeomDeferred(LLCamera& camera) |
2760 | { | 3173 | { |
2761 | LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); | ||
2762 | LLFastTimer t(LLFastTimer::FTM_RENDER_GEOMETRY); | 3174 | LLFastTimer t(LLFastTimer::FTM_RENDER_GEOMETRY); |
2763 | 3175 | ||
2764 | LLFastTimer t2(LLFastTimer::FTM_POOLS); | 3176 | LLFastTimer t2(LLFastTimer::FTM_POOLS); |
@@ -2825,15 +3237,18 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) | |||
2825 | poolp->endDeferredPass(i); | 3237 | poolp->endDeferredPass(i); |
2826 | LLVertexBuffer::unbind(); | 3238 | LLVertexBuffer::unbind(); |
2827 | 3239 | ||
2828 | GLint depth; | 3240 | if (gDebugGL || gDebugPipeline) |
2829 | glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); | ||
2830 | if (depth > 3) | ||
2831 | { | 3241 | { |
2832 | llerrs << "GL matrix stack corrupted!" << llendl; | 3242 | GLint depth; |
3243 | glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); | ||
3244 | if (depth > 3) | ||
3245 | { | ||
3246 | llwarns << "GL matrix stack corrupted!" << llendl; | ||
3247 | } | ||
3248 | LLGLState::checkStates(); | ||
3249 | LLGLState::checkTextureChannels(); | ||
3250 | LLGLState::checkClientArrays(); | ||
2833 | } | 3251 | } |
2834 | LLGLState::checkStates(); | ||
2835 | LLGLState::checkTextureChannels(); | ||
2836 | LLGLState::checkClientArrays(); | ||
2837 | } | 3252 | } |
2838 | } | 3253 | } |
2839 | else | 3254 | else |
@@ -2915,15 +3330,18 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) | |||
2915 | poolp->endPostDeferredPass(i); | 3330 | poolp->endPostDeferredPass(i); |
2916 | LLVertexBuffer::unbind(); | 3331 | LLVertexBuffer::unbind(); |
2917 | 3332 | ||
2918 | GLint depth; | 3333 | if (gDebugGL || gDebugPipeline) |
2919 | glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); | ||
2920 | if (depth > 3) | ||
2921 | { | 3334 | { |
2922 | llerrs << "GL matrix stack corrupted!" << llendl; | 3335 | GLint depth; |
3336 | glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); | ||
3337 | if (depth > 3) | ||
3338 | { | ||
3339 | llwarns << "GL matrix stack corrupted!" << llendl; | ||
3340 | } | ||
3341 | LLGLState::checkStates(); | ||
3342 | LLGLState::checkTextureChannels(); | ||
3343 | LLGLState::checkClientArrays(); | ||
2923 | } | 3344 | } |
2924 | LLGLState::checkStates(); | ||
2925 | LLGLState::checkTextureChannels(); | ||
2926 | LLGLState::checkClientArrays(); | ||
2927 | } | 3345 | } |
2928 | } | 3346 | } |
2929 | else | 3347 | else |
@@ -2959,11 +3377,6 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) | |||
2959 | LLHUDObject::renderAll(); | 3377 | LLHUDObject::renderAll(); |
2960 | gObjectList.resetObjectBeacons(); | 3378 | gObjectList.resetObjectBeacons(); |
2961 | } | 3379 | } |
2962 | else | ||
2963 | { | ||
2964 | // Make sure particle effects disappear | ||
2965 | LLHUDObject::renderAllForTimer(); | ||
2966 | } | ||
2967 | 3380 | ||
2968 | if (occlude) | 3381 | if (occlude) |
2969 | { | 3382 | { |
@@ -3067,7 +3480,7 @@ void LLPipeline::renderDebug() | |||
3067 | gGL.setColorMask(true, false); | 3480 | gGL.setColorMask(true, false); |
3068 | 3481 | ||
3069 | // Debug stuff. | 3482 | // Debug stuff. |
3070 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 3483 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
3071 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 3484 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
3072 | { | 3485 | { |
3073 | LLViewerRegion* region = *iter; | 3486 | LLViewerRegion* region = *iter; |
@@ -3084,7 +3497,7 @@ void LLPipeline::renderDebug() | |||
3084 | } | 3497 | } |
3085 | } | 3498 | } |
3086 | 3499 | ||
3087 | for (LLCullResult::bridge_list_t::const_iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i) | 3500 | for (LLCullResult::bridge_list_t::iterator i = sCull->beginVisibleBridge(); i != sCull->endVisibleBridge(); ++i) |
3088 | { | 3501 | { |
3089 | LLSpatialBridge* bridge = *i; | 3502 | LLSpatialBridge* bridge = *i; |
3090 | if (!bridge->isDead() && !bridge->isState(LLSpatialGroup::OCCLUDED) && hasRenderType(bridge->mDrawableType)) | 3503 | if (!bridge->isDead() && !bridge->isState(LLSpatialGroup::OCCLUDED) && hasRenderType(bridge->mDrawableType)) |
@@ -3098,93 +3511,88 @@ void LLPipeline::renderDebug() | |||
3098 | 3511 | ||
3099 | if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) | 3512 | if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) |
3100 | { | 3513 | { |
3514 | LLGLEnable blend(GL_BLEND); // kl sd | ||
3515 | LLGLDepthTest depth(TRUE, FALSE); | ||
3516 | LLGLDisable cull(GL_CULL_FACE); // kl | ||
3517 | |||
3101 | gGL.color4f(1,1,1,1); | 3518 | gGL.color4f(1,1,1,1); |
3102 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | 3519 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
3103 | 3520 | ||
3521 | F32 a = 0.1f; | ||
3522 | |||
3104 | F32 col[] = | 3523 | F32 col[] = |
3105 | { | 3524 | { |
3106 | 1,1,0, | 3525 | 1,0,0,a, |
3107 | 0,1,1, | 3526 | 0,1,0,a, |
3108 | 1,0,1, | 3527 | 0,0,1,a, |
3109 | 1,1,1, | 3528 | 1,0,1,a, |
3110 | 1,0,0, | 3529 | |
3111 | 0,1,0, | 3530 | 1,1,0,a, |
3112 | 0,0,1, | 3531 | 0,1,1,a, |
3113 | 0,0,0 | 3532 | 1,1,1,a, |
3533 | 1,0,1,a, | ||
3114 | }; | 3534 | }; |
3115 | 3535 | ||
3116 | for (U32 i = 0; i < 8; i++) | 3536 | for (U32 i = 0; i < 8; i++) |
3117 | { | 3537 | { |
3118 | gGL.color3fv(col+i*3); | 3538 | if (i > 3) |
3119 | 3539 | { | |
3120 | gGL.begin(LLRender::LINES); | 3540 | gGL.color4fv(col+(i-4)*4); |
3121 | |||
3122 | LLVector3* frust = mShadowCamera[i].mAgentFrustum; | ||
3123 | |||
3124 | gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV); | ||
3125 | gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV); | ||
3126 | gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV); | ||
3127 | gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV); | ||
3128 | |||
3129 | gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV); | ||
3130 | gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV); | ||
3131 | gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV); | ||
3132 | gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV); | ||
3133 | |||
3134 | gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV); | ||
3135 | gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV); | ||
3136 | gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV); | ||
3137 | gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV); | ||
3138 | 3541 | ||
3542 | LLVector3* frust = mShadowCamera[i].mAgentFrustum; | ||
3543 | |||
3544 | gGL.begin(LLRender::TRIANGLE_STRIP); | ||
3545 | gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV); | ||
3546 | gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV); | ||
3547 | gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV); | ||
3548 | gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV); | ||
3549 | gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV); | ||
3550 | gGL.end(); | ||
3551 | |||
3552 | |||
3553 | gGL.begin(LLRender::TRIANGLE_STRIP); | ||
3554 | gGL.vertex3fv(frust[0].mV); | ||
3555 | gGL.vertex3fv(frust[1].mV); | ||
3556 | gGL.vertex3fv(frust[3].mV); | ||
3557 | gGL.vertex3fv(frust[2].mV); | ||
3558 | gGL.end(); | ||
3559 | |||
3560 | gGL.begin(LLRender::TRIANGLE_STRIP); | ||
3561 | gGL.vertex3fv(frust[4].mV); | ||
3562 | gGL.vertex3fv(frust[5].mV); | ||
3563 | gGL.vertex3fv(frust[7].mV); | ||
3564 | gGL.vertex3fv(frust[6].mV); | ||
3565 | gGL.end(); | ||
3566 | } | ||
3567 | |||
3568 | |||
3139 | if (i < 4) | 3569 | if (i < 4) |
3140 | { | 3570 | { |
3141 | LLVector3* ext = mShadowExtents[i]; | 3571 | gGL.begin(LLRender::LINES); |
3142 | 3572 | ||
3143 | LLVector3 box[] = | 3573 | F32* c = col+i*4; |
3574 | for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j) | ||
3144 | { | 3575 | { |
3145 | LLVector3(ext[0][0], ext[0][1], ext[0][2]), | ||
3146 | LLVector3(ext[1][0], ext[0][1], ext[0][2]), | ||
3147 | LLVector3(ext[1][0], ext[1][1], ext[0][2]), | ||
3148 | LLVector3(ext[0][0], ext[1][1], ext[0][2]), | ||
3149 | LLVector3(ext[0][0], ext[0][1], ext[1][2]), | ||
3150 | LLVector3(ext[1][0], ext[0][1], ext[1][2]), | ||
3151 | LLVector3(ext[1][0], ext[1][1], ext[1][2]), | ||
3152 | LLVector3(ext[0][0], ext[1][1], ext[1][2]), | ||
3153 | }; | ||
3154 | 3576 | ||
3155 | gGL.vertex3fv(box[0].mV); gGL.vertex3fv(box[1].mV); | 3577 | gGL.color3fv(c); |
3156 | gGL.vertex3fv(box[1].mV); gGL.vertex3fv(box[2].mV); | ||
3157 | gGL.vertex3fv(box[2].mV); gGL.vertex3fv(box[3].mV); | ||
3158 | gGL.vertex3fv(box[3].mV); gGL.vertex3fv(box[0].mV); | ||
3159 | |||
3160 | gGL.vertex3fv(box[4].mV); gGL.vertex3fv(box[5].mV); | ||
3161 | gGL.vertex3fv(box[5].mV); gGL.vertex3fv(box[6].mV); | ||
3162 | gGL.vertex3fv(box[6].mV); gGL.vertex3fv(box[7].mV); | ||
3163 | gGL.vertex3fv(box[7].mV); gGL.vertex3fv(box[4].mV); | ||
3164 | |||
3165 | gGL.vertex3fv(box[0].mV); gGL.vertex3fv(box[4].mV); | ||
3166 | gGL.vertex3fv(box[1].mV); gGL.vertex3fv(box[5].mV); | ||
3167 | gGL.vertex3fv(box[2].mV); gGL.vertex3fv(box[6].mV); | ||
3168 | gGL.vertex3fv(box[3].mV); gGL.vertex3fv(box[7].mV); | ||
3169 | } | ||
3170 | 3578 | ||
3171 | gGL.end(); | 3579 | for (U32 k = 0; k < mShadowFrustPoints[i].size(); ++k) |
3172 | |||
3173 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | ||
3174 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | ||
3175 | { | ||
3176 | LLViewerRegion* region = *iter; | ||
3177 | for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++) | ||
3178 | { | ||
3179 | LLSpatialPartition* part = region->getSpatialPartition(j); | ||
3180 | if (part) | ||
3181 | { | 3580 | { |
3182 | if (hasRenderType(part->mDrawableType)) | 3581 | if (j != k) |
3183 | { | 3582 | { |
3184 | part->renderIntersectingBBoxes(&mShadowCamera[i]); | 3583 | gGL.vertex3fv(mShadowFrustPoints[i][j].mV); |
3584 | gGL.vertex3fv(mShadowFrustPoints[i][k].mV); | ||
3185 | } | 3585 | } |
3186 | } | 3586 | } |
3587 | |||
3588 | if (!mShadowFrustOrigin[i].isExactlyZero()) | ||
3589 | { | ||
3590 | gGL.vertex3fv(mShadowFrustPoints[i][j].mV); | ||
3591 | gGL.color4f(1,1,1,1); | ||
3592 | gGL.vertex3fv(mShadowFrustOrigin[i].mV); | ||
3593 | } | ||
3187 | } | 3594 | } |
3595 | gGL.end(); | ||
3188 | } | 3596 | } |
3189 | } | 3597 | } |
3190 | } | 3598 | } |
@@ -3222,6 +3630,55 @@ void LLPipeline::renderDebug() | |||
3222 | } | 3630 | } |
3223 | } | 3631 | } |
3224 | 3632 | ||
3633 | if (mRenderDebugMask & LLPipeline::RENDER_DEBUG_BUILD_QUEUE) | ||
3634 | { | ||
3635 | U32 count = 0; | ||
3636 | U32 size = mBuildQ2.size(); | ||
3637 | LLColor4 col; | ||
3638 | |||
3639 | LLGLEnable blend(GL_BLEND); | ||
3640 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); | ||
3641 | gGL.getTexUnit(0)->bind(LLViewerImage::sWhiteImagep); | ||
3642 | |||
3643 | for (LLSpatialGroup::sg_vector_t::iterator iter = mGroupQ2.begin(); iter != mGroupQ2.end(); ++iter) | ||
3644 | { | ||
3645 | LLSpatialGroup* group = *iter; | ||
3646 | if (group->isDead()) | ||
3647 | { | ||
3648 | continue; | ||
3649 | } | ||
3650 | |||
3651 | LLSpatialBridge* bridge = group->mSpatialPartition->asBridge(); | ||
3652 | |||
3653 | if (bridge && (!bridge->mDrawable || bridge->mDrawable->isDead())) | ||
3654 | { | ||
3655 | continue; | ||
3656 | } | ||
3657 | |||
3658 | if (bridge) | ||
3659 | { | ||
3660 | gGL.pushMatrix(); | ||
3661 | glMultMatrixf((F32*)bridge->mDrawable->getRenderMatrix().mMatrix); | ||
3662 | } | ||
3663 | |||
3664 | F32 alpha = (F32) (size-count)/size; | ||
3665 | |||
3666 | |||
3667 | LLVector2 c(1.f-alpha, alpha); | ||
3668 | c.normVec(); | ||
3669 | |||
3670 | |||
3671 | ++count; | ||
3672 | col.set(c.mV[0], c.mV[1], 0, alpha*0.5f+0.1f); | ||
3673 | group->drawObjectBox(col); | ||
3674 | |||
3675 | if (bridge) | ||
3676 | { | ||
3677 | gGL.popMatrix(); | ||
3678 | } | ||
3679 | } | ||
3680 | } | ||
3681 | |||
3225 | gGL.flush(); | 3682 | gGL.flush(); |
3226 | } | 3683 | } |
3227 | 3684 | ||
@@ -4650,7 +5107,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, | |||
4650 | 5107 | ||
4651 | sPickAvatar = FALSE; //LLToolMgr::getInstance()->inBuildMode() ? FALSE : TRUE; | 5108 | sPickAvatar = FALSE; //LLToolMgr::getInstance()->inBuildMode() ? FALSE : TRUE; |
4652 | 5109 | ||
4653 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 5110 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
4654 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 5111 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
4655 | { | 5112 | { |
4656 | LLViewerRegion* region = *iter; | 5113 | LLViewerRegion* region = *iter; |
@@ -4707,7 +5164,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, | |||
4707 | 5164 | ||
4708 | //check against avatars | 5165 | //check against avatars |
4709 | sPickAvatar = TRUE; | 5166 | sPickAvatar = TRUE; |
4710 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 5167 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
4711 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 5168 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
4712 | { | 5169 | { |
4713 | LLViewerRegion* region = *iter; | 5170 | LLViewerRegion* region = *iter; |
@@ -4784,7 +5241,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, co | |||
4784 | { | 5241 | { |
4785 | LLDrawable* drawable = NULL; | 5242 | LLDrawable* drawable = NULL; |
4786 | 5243 | ||
4787 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 5244 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
4788 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 5245 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
4789 | { | 5246 | { |
4790 | LLViewerRegion* region = *iter; | 5247 | LLViewerRegion* region = *iter; |
@@ -4847,7 +5304,7 @@ void LLPipeline::resetVertexBuffers() | |||
4847 | { | 5304 | { |
4848 | sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); | 5305 | sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); |
4849 | 5306 | ||
4850 | for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 5307 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
4851 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 5308 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
4852 | { | 5309 | { |
4853 | LLViewerRegion* region = *iter; | 5310 | LLViewerRegion* region = *iter; |
@@ -4958,18 +5415,18 @@ void validate_framebuffer_object() | |||
4958 | break; | 5415 | break; |
4959 | case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: | 5416 | case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: |
4960 | // frame buffer not OK: probably means unsupported depth buffer format | 5417 | // frame buffer not OK: probably means unsupported depth buffer format |
4961 | llerrs << "Framebuffer Incomplete Dimensions." << llendl; | 5418 | llwarns << "Framebuffer Incomplete Dimensions." << llendl; |
4962 | break; | 5419 | break; |
4963 | case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: | 5420 | case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: |
4964 | // frame buffer not OK: probably means unsupported depth buffer format | 5421 | // frame buffer not OK: probably means unsupported depth buffer format |
4965 | llerrs << "Framebuffer Incomplete Attachment." << llendl; | 5422 | llwarns << "Framebuffer Incomplete Attachment." << llendl; |
4966 | break; | 5423 | break; |
4967 | case GL_FRAMEBUFFER_UNSUPPORTED_EXT: | 5424 | case GL_FRAMEBUFFER_UNSUPPORTED_EXT: |
4968 | /* choose different formats */ | 5425 | /* choose different formats */ |
4969 | llerrs << "Framebuffer unsupported." << llendl; | 5426 | llwarns << "Framebuffer unsupported." << llendl; |
4970 | break; | 5427 | break; |
4971 | default: | 5428 | default: |
4972 | llerrs << "Unknown framebuffer status." << llendl; | 5429 | llwarns << "Unknown framebuffer status." << llendl; |
4973 | break; | 5430 | break; |
4974 | } | 5431 | } |
4975 | } | 5432 | } |
@@ -5287,46 +5744,202 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) | |||
5287 | 5744 | ||
5288 | } | 5745 | } |
5289 | 5746 | ||
5290 | void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index) | 5747 | void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRenderTarget* gi_source, LLRenderTarget* last_gi_post) //, U32 noise_map) |
5291 | { | 5748 | { |
5749 | /* if (noise_map == 0xFFFFFFFF) | ||
5750 | { | ||
5751 | noise_map = mNoiseMap; | ||
5752 | } | ||
5753 | */ | ||
5754 | LLFastTimer ftm(LLFastTimer::FTM_TEMP3); | ||
5755 | LLGLState::checkTextureChannels(); | ||
5756 | |||
5292 | shader.bind(); | 5757 | shader.bind(); |
5293 | S32 channel = 0; | 5758 | S32 channel = 0; |
5294 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE); | 5759 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE); |
5295 | if (channel > -1) | 5760 | if (channel > -1) |
5296 | { | 5761 | { |
5297 | mDeferredScreen.bindTexture(0,channel); | 5762 | mDeferredScreen.bindTexture(0,channel); |
5298 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 5763 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); |
5299 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||
5300 | } | 5764 | } |
5301 | 5765 | ||
5302 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE); | 5766 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE); |
5303 | if (channel > -1) | 5767 | if (channel > -1) |
5304 | { | 5768 | { |
5305 | mDeferredScreen.bindTexture(1, channel); | 5769 | mDeferredScreen.bindTexture(1, channel); |
5770 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5306 | } | 5771 | } |
5307 | 5772 | ||
5308 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE); | 5773 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE); |
5309 | if (channel > -1) | 5774 | if (channel > -1) |
5310 | { | 5775 | { |
5311 | mDeferredScreen.bindTexture(2, channel); | 5776 | mDeferredScreen.bindTexture(2, channel); |
5777 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5312 | } | 5778 | } |
5313 | 5779 | ||
5314 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_POSITION, LLTexUnit::TT_RECT_TEXTURE); | 5780 | if (gi_source) |
5315 | if (channel > -1) | ||
5316 | { | 5781 | { |
5317 | mDeferredScreen.bindTexture(3, channel); | 5782 | BOOL has_gi = FALSE; |
5783 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_DIFFUSE); | ||
5784 | if (channel > -1) | ||
5785 | { | ||
5786 | has_gi = TRUE; | ||
5787 | gi_source->bindTexture(0, channel); | ||
5788 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5789 | } | ||
5790 | |||
5791 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_SPECULAR); | ||
5792 | if (channel > -1) | ||
5793 | { | ||
5794 | has_gi = TRUE; | ||
5795 | gi_source->bindTexture(1, channel); | ||
5796 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5797 | } | ||
5798 | |||
5799 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_NORMAL); | ||
5800 | if (channel > -1) | ||
5801 | { | ||
5802 | has_gi = TRUE; | ||
5803 | gi_source->bindTexture(2, channel); | ||
5804 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5805 | } | ||
5806 | |||
5807 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_MIN_POS); | ||
5808 | if (channel > -1) | ||
5809 | { | ||
5810 | has_gi = TRUE; | ||
5811 | gi_source->bindTexture(1, channel); | ||
5812 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5813 | } | ||
5814 | |||
5815 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_MAX_POS); | ||
5816 | if (channel > -1) | ||
5817 | { | ||
5818 | has_gi = TRUE; | ||
5819 | gi_source->bindTexture(3, channel); | ||
5820 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5821 | } | ||
5822 | |||
5823 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_DIFFUSE); | ||
5824 | if (channel > -1) | ||
5825 | { | ||
5826 | has_gi = TRUE; | ||
5827 | last_gi_post->bindTexture(0, channel); | ||
5828 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5829 | } | ||
5830 | |||
5831 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_NORMAL); | ||
5832 | if (channel > -1) | ||
5833 | { | ||
5834 | has_gi = TRUE; | ||
5835 | last_gi_post->bindTexture(2, channel); | ||
5836 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5837 | } | ||
5838 | |||
5839 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_MAX_POS); | ||
5840 | if (channel > -1) | ||
5841 | { | ||
5842 | has_gi = TRUE; | ||
5843 | last_gi_post->bindTexture(1, channel); | ||
5844 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5845 | } | ||
5846 | |||
5847 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_MIN_POS); | ||
5848 | if (channel > -1) | ||
5849 | { | ||
5850 | has_gi = TRUE; | ||
5851 | last_gi_post->bindTexture(3, channel); | ||
5852 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5853 | } | ||
5854 | |||
5855 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_DEPTH); | ||
5856 | if (channel > -1) | ||
5857 | { | ||
5858 | has_gi = TRUE; | ||
5859 | gGL.getTexUnit(channel)->bind(gi_source, TRUE); | ||
5860 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5861 | stop_glerror(); | ||
5862 | |||
5863 | glTexParameteri(LLTexUnit::getInternalType(mGIMap.getUsage()), GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); | ||
5864 | glTexParameteri(LLTexUnit::getInternalType(mGIMap.getUsage()), GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); | ||
5865 | |||
5866 | stop_glerror(); | ||
5867 | } | ||
5868 | |||
5869 | if (has_gi) | ||
5870 | { | ||
5871 | U32 gi_samples = llclamp(gSavedSettings.getU32("RenderGISamples"), (U32) 1, (U32) 8); | ||
5872 | |||
5873 | F32 range_x = llmin(mGIRange.mV[0], 1.f); | ||
5874 | F32 range_y = llmin(mGIRange.mV[1], 1.f); | ||
5875 | |||
5876 | LLVector2 scale(range_x,range_y); | ||
5877 | |||
5878 | LLVector2 kern[25]; | ||
5879 | |||
5880 | for (S32 i = 0; i < 5; ++i) | ||
5881 | { | ||
5882 | for (S32 j = 0; j < 5; ++j) | ||
5883 | { | ||
5884 | S32 idx = i*5+j; | ||
5885 | kern[idx].mV[0] = (i-2)*0.5f; | ||
5886 | kern[idx].mV[1] = (j-2)*0.5f; | ||
5887 | kern[idx].scaleVec(scale); | ||
5888 | } | ||
5889 | } | ||
5890 | |||
5891 | F32 gi_radius = mGILightRadius; //gSavedSettings.getF32("RenderGILightRadius"); | ||
5892 | |||
5893 | shader.uniform2f("gi_scale", scale.mV[0], scale.mV[1]); | ||
5894 | shader.uniform2fv("gi_kern", 25, (F32*) kern); | ||
5895 | shader.uniformMatrix4fv("gi_mat", 1, FALSE, mGIMatrix.m); | ||
5896 | shader.uniformMatrix4fv("gi_mat_proj", 1, FALSE, mGIMatrixProj.m); | ||
5897 | shader.uniformMatrix4fv("gi_inv_proj", 1, FALSE, mGIInvProj.m); | ||
5898 | shader.uniformMatrix4fv("gi_norm_mat", 1, FALSE, mGINormalMatrix.m); | ||
5899 | shader.uniform1f("gi_radius", gi_radius); | ||
5900 | shader.uniform1i("gi_samples", (GLint) gSavedSettings.getU32("RenderGISamples")); | ||
5901 | shader.uniform1f("gi_intensity", gSavedSettings.getF32("RenderGIIntensity")/(gi_samples*gi_samples)); | ||
5902 | shader.uniform3fv("gi_quad", 1, gSavedSettings.getVector3("RenderGIColorCurve").mV); | ||
5903 | shader.uniform3fv("gi_spec", 1, gSavedSettings.getVector3("RenderGISpecularCurve").mV); | ||
5904 | shader.uniform1f("gi_direction_weight", gSavedSettings.getF32("RenderGIDirectionWeight")); | ||
5905 | shader.uniform1f("gi_light_offset", gSavedSettings.getF32("RenderGILightOffset")); | ||
5906 | shader.uniform1f("gi_blend", gFrameIntervalSeconds); | ||
5907 | } | ||
5318 | } | 5908 | } |
5319 | 5909 | ||
5320 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE); | 5910 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE); |
5321 | if (channel > -1) | 5911 | if (channel > -1) |
5322 | { | 5912 | { |
5323 | gGL.getTexUnit(channel)->bind(&mDeferredScreen, TRUE); | 5913 | gGL.getTexUnit(channel)->bind(&mDeferredDepth, TRUE); |
5914 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5915 | stop_glerror(); | ||
5916 | |||
5917 | glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); | ||
5918 | glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); | ||
5919 | |||
5920 | stop_glerror(); | ||
5921 | |||
5922 | glh::matrix4f projection = glh_get_current_projection(); | ||
5923 | glh::matrix4f inv_proj = projection.inverse(); | ||
5924 | |||
5925 | shader.uniformMatrix4fv("inv_proj", 1, FALSE, inv_proj.m); | ||
5926 | shader.uniform4f("viewport", (F32) gGLViewport[0], | ||
5927 | (F32) gGLViewport[1], | ||
5928 | (F32) gGLViewport[2], | ||
5929 | (F32) gGLViewport[3]); | ||
5324 | } | 5930 | } |
5325 | 5931 | ||
5326 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NOISE); | 5932 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NOISE); |
5327 | if (channel > -1) | 5933 | if (channel > -1) |
5328 | { | 5934 | { |
5329 | gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); | 5935 | gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); // was noise_map KL |
5936 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5937 | } | ||
5938 | |||
5939 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LIGHTFUNC); | ||
5940 | if (channel > -1) | ||
5941 | { | ||
5942 | gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); | ||
5330 | } | 5943 | } |
5331 | 5944 | ||
5332 | stop_glerror(); | 5945 | stop_glerror(); |
@@ -5335,19 +5948,68 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index) | |||
5335 | if (channel > -1) | 5948 | if (channel > -1) |
5336 | { | 5949 | { |
5337 | mDeferredLight[light_index].bindTexture(0, channel); | 5950 | mDeferredLight[light_index].bindTexture(0, channel); |
5951 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5952 | } | ||
5953 | |||
5954 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LUMINANCE); | ||
5955 | if (channel > -1) | ||
5956 | { | ||
5957 | gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLuminanceMap.getTexture(), true); | ||
5958 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); | ||
5338 | } | 5959 | } |
5339 | 5960 | ||
5961 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE); | ||
5962 | if (channel > -1) | ||
5963 | { | ||
5964 | gi_source->bindTexture(0, channel); | ||
5965 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5966 | } | ||
5967 | |||
5968 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SUN_LIGHT, LLTexUnit::TT_RECT_TEXTURE); | ||
5969 | if (channel > -1) | ||
5970 | { | ||
5971 | mDeferredLight[1].bindTexture(0, channel); | ||
5972 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5973 | } | ||
5974 | |||
5975 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LOCAL_LIGHT, LLTexUnit::TT_RECT_TEXTURE); | ||
5976 | if (channel > -1) | ||
5977 | { | ||
5978 | mDeferredLight[2].bindTexture(0, channel); | ||
5979 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | ||
5980 | } | ||
5981 | |||
5982 | |||
5340 | stop_glerror(); | 5983 | stop_glerror(); |
5341 | 5984 | ||
5342 | for (U32 i = 0; i < 4; i++) | 5985 | for (U32 i = 0; i < 4; i++) |
5343 | { | 5986 | { |
5987 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_RECT_TEXTURE); | ||
5988 | stop_glerror(); | ||
5989 | if (channel > -1) | ||
5990 | { | ||
5991 | stop_glerror(); | ||
5992 | gGL.getTexUnit(channel)->bind(&mShadow[i], TRUE); | ||
5993 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | ||
5994 | gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); | ||
5995 | stop_glerror(); | ||
5996 | |||
5997 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); | ||
5998 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); | ||
5999 | stop_glerror(); | ||
6000 | } | ||
6001 | } | ||
6002 | |||
6003 | for (U32 i = 4; i < 6; i++) | ||
6004 | { | ||
5344 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i); | 6005 | channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i); |
5345 | stop_glerror(); | 6006 | stop_glerror(); |
5346 | if (channel > -1) | 6007 | if (channel > -1) |
5347 | { | 6008 | { |
5348 | stop_glerror(); | 6009 | stop_glerror(); |
5349 | gGL.getTexUnit(channel)->bind(&mSunShadow[i], TRUE); | 6010 | gGL.getTexUnit(channel)->bind(&mShadow[i], TRUE); |
5350 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); | 6011 | gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); |
6012 | gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); | ||
5351 | stop_glerror(); | 6013 | stop_glerror(); |
5352 | 6014 | ||
5353 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); | 6015 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); |
@@ -5358,17 +6020,19 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index) | |||
5358 | 6020 | ||
5359 | stop_glerror(); | 6021 | stop_glerror(); |
5360 | 6022 | ||
5361 | F32 mat[64]; | 6023 | F32 mat[16*6]; |
5362 | for (U32 i = 0; i < 16; i++) | 6024 | for (U32 i = 0; i < 16; i++) |
5363 | { | 6025 | { |
5364 | mat[i] = mSunShadowMatrix[0].m[i]; | 6026 | mat[i] = mSunShadowMatrix[0].m[i]; |
5365 | mat[i+16] = mSunShadowMatrix[1].m[i]; | 6027 | mat[i+16] = mSunShadowMatrix[1].m[i]; |
5366 | mat[i+32] = mSunShadowMatrix[2].m[i]; | 6028 | mat[i+32] = mSunShadowMatrix[2].m[i]; |
5367 | mat[i+48] = mSunShadowMatrix[3].m[i]; | 6029 | mat[i+48] = mSunShadowMatrix[3].m[i]; |
6030 | mat[i+64] = mSunShadowMatrix[4].m[i]; | ||
6031 | mat[i+80] = mSunShadowMatrix[5].m[i]; | ||
5368 | } | 6032 | } |
5369 | 6033 | ||
5370 | shader.uniformMatrix4fv("shadow_matrix[0]", 4, FALSE, mat); | 6034 | shader.uniformMatrix4fv("shadow_matrix[0]", 6, FALSE, mat); |
5371 | shader.uniformMatrix4fv("shadow_matrix", 4, FALSE, mat); | 6035 | shader.uniformMatrix4fv("shadow_matrix", 6, FALSE, mat); |
5372 | 6036 | ||
5373 | stop_glerror(); | 6037 | stop_glerror(); |
5374 | 6038 | ||
@@ -5417,8 +6081,23 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index) | |||
5417 | shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); | 6081 | shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); |
5418 | shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f); | 6082 | shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f); |
5419 | shader.uniform1f("alpha_soften", gSavedSettings.getF32("RenderDeferredAlphaSoften")); | 6083 | shader.uniform1f("alpha_soften", gSavedSettings.getF32("RenderDeferredAlphaSoften")); |
6084 | shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset")); | ||
6085 | shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias")); | ||
6086 | /* shader.uniform3fv("gi_quad", 1, gSavedSettings.getVector3("RenderGIColorCurve").mV); | ||
6087 | shader.uniform3fv("lum_quad", 1, gSavedSettings.getVector3("RenderLuminanceColorCurve").mV); | ||
6088 | shader.uniform3fv("gi_lum_quad", 1, gSavedSettings.getVector3("RenderGILuminanceColorCurve").mV); | ||
6089 | shader.uniform3fv("sun_lum_quad", 1, gSavedSettings.getVector3("RenderSunLuminanceColorCurve").mV); | ||
6090 | shader.uniform1f("lum_lod", gSavedSettings.getF32("RenderLuminanceDetail")); | ||
6091 | shader.uniform1f("gi_range", gSavedSettings.getF32("RenderGIRange")); | ||
6092 | |||
6093 | if (shader.getUniformLocation("norm_mat") >= 0) | ||
6094 | { | ||
6095 | glh::matrix4f norm_mat = glh_get_current_modelview().inverse().transpose(); | ||
6096 | shader.uniformMatrix4fv("norm_mat", 1, FALSE, norm_mat.m); | ||
6097 | } */ | ||
5420 | } | 6098 | } |
5421 | 6099 | ||
6100 | // KL The Deffered Pipeline begins here! | ||
5422 | void LLPipeline::renderDeferredLighting() | 6101 | void LLPipeline::renderDeferredLighting() |
5423 | { | 6102 | { |
5424 | if (!sCull) | 6103 | if (!sCull) |
@@ -5426,6 +6105,12 @@ void LLPipeline::renderDeferredLighting() | |||
5426 | return; | 6105 | return; |
5427 | } | 6106 | } |
5428 | 6107 | ||
6108 | { | ||
6109 | LLGLDepthTest depth(GL_TRUE); | ||
6110 | mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), | ||
6111 | 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); | ||
6112 | } | ||
6113 | |||
5429 | LLGLEnable multisample(GL_MULTISAMPLE_ARB); | 6114 | LLGLEnable multisample(GL_MULTISAMPLE_ARB); |
5430 | 6115 | ||
5431 | if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) | 6116 | if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) |
@@ -5439,16 +6124,10 @@ void LLPipeline::renderDeferredLighting() | |||
5439 | glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | 6124 | glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); |
5440 | 6125 | ||
5441 | gGL.setColorMask(true, true); | 6126 | gGL.setColorMask(true, true); |
5442 | |||
5443 | mDeferredLight[0].bindTarget(); | ||
5444 | |||
5445 | //mDeferredLight[0].copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), | ||
5446 | // 0, 0, mDeferredLight[0].getWidth(), mDeferredLight[0].getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); | ||
5447 | 6127 | ||
5448 | //draw a cube around every light | 6128 | //draw a cube around every light |
5449 | LLVertexBuffer::unbind(); | 6129 | LLVertexBuffer::unbind(); |
5450 | 6130 | ||
5451 | glBlendFunc(GL_ONE, GL_ONE); | ||
5452 | LLGLEnable cull(GL_CULL_FACE); | 6131 | LLGLEnable cull(GL_CULL_FACE); |
5453 | LLGLEnable blend(GL_BLEND); | 6132 | LLGLEnable blend(GL_BLEND); |
5454 | 6133 | ||
@@ -5460,126 +6139,271 @@ void LLPipeline::renderDeferredLighting() | |||
5460 | -1,-3, | 6139 | -1,-3, |
5461 | 3,1, | 6140 | 3,1, |
5462 | }; | 6141 | }; |
6142 | glVertexPointer(2, GL_FLOAT, 0, vert); | ||
6143 | glColor3f(1,1,1); | ||
6144 | //Set mSunDir KL This makes sense to have it here. Still calculated EVEN if Deferred Sun is FALSE! | ||
6145 | { | ||
6146 | setupHWLights(NULL); //to set mSunDir; | ||
6147 | LLVector4 dir(mSunDir, 0.f); | ||
6148 | glh::vec4f tc(dir.mV); | ||
6149 | mat.mult_matrix_vec(tc); | ||
6150 | glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0); | ||
6151 | } | ||
6152 | |||
6153 | if (gSavedSettings.getBOOL("RenderDeferredShadow")) | ||
6154 | { | ||
6155 | glPushMatrix(); | ||
6156 | glLoadIdentity(); | ||
6157 | glMatrixMode(GL_PROJECTION); | ||
6158 | glPushMatrix(); | ||
6159 | glLoadIdentity(); | ||
5463 | 6160 | ||
5464 | bindDeferredShader(gDeferredSunProgram); | 6161 | mDeferredLight[0].bindTarget(); |
6162 | // KL Bind to 0 next section Deferred Sun ! | ||
6163 | if (gSavedSettings.getBOOL("RenderDeferredSun")) | ||
6164 | { //paint shadow/SSAO light map (direct lighting lightmap) | ||
6165 | bindDeferredShader(gDeferredSunProgram, 0); | ||
5465 | 6166 | ||
5466 | glh::matrix4f inv_trans = glh_get_current_modelview().inverse().transpose(); | 6167 | glClearColor(1,1,1,1); |
6168 | mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT); | ||
6169 | glClearColor(0,0,0,0); | ||
5467 | 6170 | ||
5468 | const U32 slice = 32; | 6171 | glh::matrix4f inv_trans = glh_get_current_modelview().inverse().transpose(); |
5469 | F32 offset[slice*3]; | 6172 | |
5470 | for (U32 i = 0; i < 4; i++) | 6173 | const U32 slice = 32; |
5471 | { | 6174 | F32 offset[slice*3]; |
5472 | for (U32 j = 0; j < 8; j++) | 6175 | for (U32 i = 0; i < 4; i++) |
6176 | { | ||
6177 | for (U32 j = 0; j < 8; j++) | ||
6178 | { | ||
6179 | glh::vec3f v; | ||
6180 | v.set_value(sinf(6.284f/8*j), cosf(6.284f/8*j), -(F32) i); | ||
6181 | v.normalize(); | ||
6182 | inv_trans.mult_matrix_vec(v); | ||
6183 | v.normalize(); | ||
6184 | offset[(i*8+j)*3+0] = v.v[0]; | ||
6185 | offset[(i*8+j)*3+1] = v.v[2]; | ||
6186 | offset[(i*8+j)*3+2] = v.v[1]; | ||
6187 | } | ||
6188 | } | ||
6189 | |||
6190 | gDeferredSunProgram.uniform3fv("offset", slice, offset); | ||
6191 | gDeferredSunProgram.uniform2f("screenRes", mDeferredLight[0].getWidth(), mDeferredLight[0].getHeight()); | ||
6192 | |||
5473 | { | 6193 | { |
5474 | glh::vec3f v; | 6194 | LLGLDisable blend(GL_BLEND); |
5475 | v.set_value(sinf(6.284f/8*j), cosf(6.284f/8*j), -(F32) i); | 6195 | LLGLDepthTest depth(GL_FALSE); |
5476 | v.normalize(); | 6196 | stop_glerror(); |
5477 | inv_trans.mult_matrix_vec(v); | 6197 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); |
5478 | v.normalize(); | 6198 | stop_glerror(); |
5479 | offset[(i*8+j)*3+0] = v.v[0]; | ||
5480 | offset[(i*8+j)*3+1] = v.v[2]; | ||
5481 | offset[(i*8+j)*3+2] = v.v[1]; | ||
5482 | } | 6199 | } |
6200 | |||
6201 | unbindDeferredShader(gDeferredSunProgram); | ||
6202 | } | ||
6203 | else | ||
6204 | { | ||
6205 | mDeferredLight[0].clear(); | ||
5483 | } | 6206 | } |
5484 | 6207 | ||
5485 | gDeferredSunProgram.uniform3fv("offset", slice, offset); | 6208 | mDeferredLight[0].flush(); |
5486 | gDeferredSunProgram.uniform2f("screenRes", mDeferredLight[0].getWidth(), mDeferredLight[0].getHeight()); | 6209 | mDeferredLight[1].bindTarget(); |
6210 | } | ||
6211 | // KL Bind to 1 next section GI | ||
6212 | /* if (gSavedSettings.getBOOL("RenderDeferredGI")) | ||
6213 | { | ||
6214 | { //get luminance map from previous frame's light map | ||
6215 | LLGLEnable blend(GL_BLEND); | ||
6216 | LLGLDisable test(GL_ALPHA_TEST); | ||
6217 | LLGLDepthTest depth(GL_FALSE); | ||
6218 | LLGLDisable stencil(GL_STENCIL_TEST); | ||
5487 | 6219 | ||
5488 | setupHWLights(NULL); //to set mSunDir; | 6220 | //static F32 fade = 1.f; |
5489 | 6221 | ||
5490 | glPushMatrix(); | 6222 | F32 fade = gSavedSettings.getF32("RenderLuminanceFade"); |
5491 | glLoadIdentity(); | 6223 | { |
5492 | glMatrixMode(GL_PROJECTION); | 6224 | gGL.setSceneBlendType(LLRender::BT_ALPHA); |
5493 | glPushMatrix(); | 6225 | gLuminanceGatherProgram.bind(); |
5494 | glLoadIdentity(); | 6226 | gLuminanceGatherProgram.uniform2f("screen_res", mDeferredLight[0].getWidth(), mDeferredLight[0].getHeight()); |
6227 | gLuminanceGatherProgram.uniform1f("fade", llclamp(fade, 0.f, 1.f)); | ||
6228 | mLuminanceMap.bindTarget(); | ||
6229 | gGL.getTexUnit(0)->bind(&mDeferredLight[0]); | ||
6230 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | ||
6231 | gLuminanceGatherProgram.unbind(); | ||
6232 | mLuminanceMap.flush(); | ||
6233 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLuminanceMap.getTexture(), true); | ||
6234 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); | ||
6235 | glGenerateMipmapEXT(GL_TEXTURE_2D); | ||
6236 | } | ||
5495 | 6237 | ||
5496 | LLVector4 dir(mSunDir, 0.f); | 6238 | } |
5497 | 6239 | ||
5498 | glh::vec4f tc(dir.mV); | 6240 | { //paint noisy GI map (bounce lighting lightmap) |
5499 | mat.mult_matrix_vec(tc); | 6241 | LLGLDisable blend(GL_BLEND); |
5500 | glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0); | 6242 | LLGLDepthTest depth(GL_FALSE); |
5501 | glColor3f(1,1,1); | 6243 | LLGLDisable test(GL_ALPHA_TEST); |
5502 | 6244 | ||
5503 | glVertexPointer(2, GL_FLOAT, 0, vert); | 6245 | mGIMapPost[0].bindTarget(); |
5504 | { | ||
5505 | LLGLDisable blend(GL_BLEND); | ||
5506 | LLGLDepthTest depth(GL_FALSE); | ||
5507 | stop_glerror(); | ||
5508 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | ||
5509 | stop_glerror(); | ||
5510 | } | ||
5511 | |||
5512 | unbindDeferredShader(gDeferredSunProgram); | ||
5513 | 6246 | ||
5514 | mDeferredLight[0].flush(); | 6247 | bindDeferredShader(gDeferredGIProgram, 0, &mGIMap, 0);//, mTrueNoiseMap); |
6248 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | ||
6249 | unbindDeferredShader(gDeferredGIProgram); | ||
6250 | mGIMapPost[0].flush(); | ||
5515 | 6251 | ||
5516 | //blur lightmap | ||
5517 | mDeferredLight[1].bindTarget(); | ||
5518 | 6252 | ||
5519 | //mDeferredLight[1].copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), | 6253 | } |
5520 | // 0, 0, mDeferredLight[0].getWidth(), mDeferredLight[0].getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); | ||
5521 | |||
5522 | bindDeferredShader(gDeferredBlurLightProgram); | ||
5523 | 6254 | ||
5524 | LLVector3 gauss[32]; // xweight, yweight, offset | 6255 | U32 pass_count = 0; |
6256 | if (gSavedSettings.getBOOL("RenderDeferredBlurLight")) | ||
6257 | { | ||
6258 | pass_count = llclamp(gSavedSettings.getU32("RenderGIBlurPasses"), (U32) 1, (U32) 128); | ||
6259 | } | ||
5525 | 6260 | ||
5526 | LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian"); | 6261 | for (U32 i = 0; i < pass_count; ++i) |
5527 | U32 kern_length = llclamp(gSavedSettings.getU32("RenderShadowBlurSamples"), (U32) 1, (U32) 16)*2 - 1; | 6262 | { //gather/soften indirect lighting map |
5528 | F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize"); | 6263 | bindDeferredShader(gDeferredPostGIProgram, 0, &mGIMapPost[0], NULL); //, mTrueNoiseMap); |
5529 | 6264 | ||
5530 | // sample symmetrically with the middle sample falling exactly on 0.0 | 6265 | LLVector2 gauss[32]; // xweight, yweight, offset |
5531 | F32 x = -(kern_length/2.0f) + 0.5f; | ||
5532 | 6266 | ||
5533 | for (U32 i = 0; i < kern_length; i++) | 6267 | F32 sc = 1.f; |
5534 | { | ||
5535 | gauss[i].mV[0] = llgaussian(x, go.mV[0]); | ||
5536 | gauss[i].mV[1] = llgaussian(x, go.mV[1]); | ||
5537 | gauss[i].mV[2] = x; | ||
5538 | x += 1.f; | ||
5539 | } | ||
5540 | /* swap the x=0 position to the start of gauss[] so we can | ||
5541 | treat it specially as an optimization. */ | ||
5542 | LLVector3 swap; | ||
5543 | swap = gauss[kern_length/2]; | ||
5544 | gauss[kern_length/2] = gauss[0]; | ||
5545 | gauss[0] = swap; | ||
5546 | llassert(gauss[0].mV[2] == 0.0f); | ||
5547 | 6268 | ||
5548 | gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f); | 6269 | F32 go = gSavedSettings.getF32("RenderGIGaussian"); |
5549 | gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV); | 6270 | U32 kern_length = llclamp(gSavedSettings.getU32("RenderGIBlurSamples"), (U32) 1, (U32) 16)*2 - 1; |
5550 | gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV); | 6271 | F32 blur_size = gSavedSettings.getF32("RenderGIBlurSize")*sc; |
5551 | gDeferredBlurLightProgram.uniform1i("kern_length", kern_length); | 6272 | F32 dist_factor = gSavedSettings.getF32("RenderGIBlurDistFactor"); |
5552 | gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); | ||
5553 | 6273 | ||
5554 | { | 6274 | // sample symmetrically with the middle sample falling exactly on 0.0 |
5555 | LLGLDisable blend(GL_BLEND); | 6275 | F32 x = -(kern_length/2.0f) + 0.5f; |
5556 | LLGLDepthTest depth(GL_FALSE); | 6276 | |
5557 | stop_glerror(); | 6277 | for (U32 i = 0; i < kern_length; i++) |
5558 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | 6278 | { |
5559 | stop_glerror(); | 6279 | gauss[i].mV[0] = llgaussian(x, go); |
5560 | } | 6280 | gauss[i].mV[1] = x; |
5561 | 6281 | x += 1.f; | |
5562 | mDeferredLight[1].flush(); | 6282 | } |
5563 | unbindDeferredShader(gDeferredBlurLightProgram); | 6283 | // swap the x=0 position to the start of gauss[] so we can |
6284 | // treat it specially as an optimization. | ||
6285 | LLVector2 swap; | ||
6286 | swap = gauss[kern_length/2]; | ||
6287 | gauss[kern_length/2] = gauss[0]; | ||
6288 | gauss[0] = swap; | ||
6289 | llassert(gauss[0].mV[2] == 0.0f); | ||
6290 | |||
6291 | gDeferredPostGIProgram.uniform2f("delta", 1.f, 0.f); | ||
6292 | gDeferredPostGIProgram.uniform1f("dist_factor", dist_factor); | ||
6293 | gDeferredPostGIProgram.uniform2fv("kern[0]", kern_length, gauss[0].mV); | ||
6294 | gDeferredPostGIProgram.uniform2fv("kern", kern_length, gauss[0].mV); | ||
6295 | gDeferredPostGIProgram.uniform1i("kern_length", kern_length); | ||
6296 | gDeferredPostGIProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); | ||
6297 | gDeferredPostGIProgram.uniform3fv("blur_quad", 1, gSavedSettings.getVector3("RenderGIBlurColorCurve").mV); | ||
6298 | |||
6299 | mGIMapPost[1].bindTarget(); | ||
6300 | { | ||
6301 | LLGLDisable blend(GL_BLEND); | ||
6302 | LLGLDepthTest depth(GL_FALSE); | ||
6303 | stop_glerror(); | ||
6304 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | ||
6305 | stop_glerror(); | ||
6306 | } | ||
6307 | |||
6308 | mGIMapPost[1].flush(); | ||
6309 | unbindDeferredShader(gDeferredPostGIProgram); | ||
5564 | 6310 | ||
5565 | bindDeferredShader(gDeferredBlurLightProgram, 1); | 6311 | bindDeferredShader(gDeferredPostGIProgram, 0, &mGIMapPost[1], NULL);//, mTrueNoiseMap); |
5566 | mDeferredLight[0].bindTarget(); | 6312 | mGIMapPost[0].bindTarget(); |
5567 | 6313 | ||
5568 | gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f); | 6314 | gDeferredPostGIProgram.uniform2f("delta", 0.f, 1.f); |
5569 | gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV); | 6315 | gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor); |
5570 | gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV); | 6316 | gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV); |
5571 | gDeferredBlurLightProgram.uniform1i("kern_length", kern_length); | 6317 | gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV); |
5572 | gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); | 6318 | gDeferredBlurLightProgram.uniform1i("kern_length", kern_length); |
6319 | gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); | ||
5573 | 6320 | ||
5574 | { | 6321 | { |
5575 | LLGLDisable blend(GL_BLEND); | 6322 | LLGLDisable blend(GL_BLEND); |
5576 | LLGLDepthTest depth(GL_FALSE); | 6323 | LLGLDepthTest depth(GL_FALSE); |
5577 | stop_glerror(); | 6324 | stop_glerror(); |
5578 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 6325 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
5579 | stop_glerror(); | 6326 | stop_glerror(); |
5580 | } | 6327 | } |
6328 | mGIMapPost[0].flush(); | ||
6329 | unbindDeferredShader(gDeferredPostGIProgram); | ||
6330 | } | ||
6331 | } */ | ||
6332 | |||
6333 | if (gSavedSettings.getBOOL("RenderDeferredBlurLight")) | ||
6334 | { //soften direct lighting lightmap | ||
6335 | //blur lightmap | ||
6336 | mDeferredLight[1].bindTarget(); | ||
6337 | |||
6338 | glClearColor(1,1,1,1); | ||
6339 | mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT); | ||
6340 | glClearColor(0,0,0,0); | ||
6341 | |||
6342 | bindDeferredShader(gDeferredBlurLightProgram); | ||
6343 | |||
6344 | LLVector3 gauss[32]; // xweight, yweight, offset | ||
6345 | |||
6346 | LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian"); | ||
6347 | U32 kern_length = llclamp(gSavedSettings.getU32("RenderShadowBlurSamples"), (U32) 1, (U32) 16)*2 - 1; | ||
6348 | F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize"); | ||
6349 | F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); | ||
6350 | |||
6351 | // sample symmetrically with the middle sample falling exactly on 0.0 | ||
6352 | F32 x = -(kern_length/2.0f) + 0.5f; | ||
6353 | |||
6354 | for (U32 i = 0; i < kern_length; i++) | ||
6355 | { | ||
6356 | gauss[i].mV[0] = llgaussian(x, go.mV[0]); | ||
6357 | gauss[i].mV[1] = llgaussian(x, go.mV[1]); | ||
6358 | gauss[i].mV[2] = x; | ||
6359 | x += 1.f; | ||
6360 | } | ||
6361 | /* swap the x=0 position to the start of gauss[] so we can | ||
6362 | treat it specially as an optimization. */ | ||
6363 | LLVector3 swap; | ||
6364 | swap = gauss[kern_length/2]; | ||
6365 | gauss[kern_length/2] = gauss[0]; | ||
6366 | gauss[0] = swap; | ||
6367 | llassert(gauss[0].mV[2] == 0.0f); | ||
6368 | |||
6369 | gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f); | ||
6370 | gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor); | ||
6371 | gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV); | ||
6372 | gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV); | ||
6373 | gDeferredBlurLightProgram.uniform1i("kern_length", kern_length); | ||
6374 | gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); | ||
6375 | |||
6376 | { | ||
6377 | LLGLDisable blend(GL_BLEND); | ||
6378 | LLGLDepthTest depth(GL_FALSE); | ||
6379 | stop_glerror(); | ||
6380 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | ||
6381 | stop_glerror(); | ||
6382 | } | ||
6383 | |||
6384 | mDeferredLight[1].flush(); | ||
6385 | unbindDeferredShader(gDeferredBlurLightProgram); | ||
6386 | |||
6387 | bindDeferredShader(gDeferredBlurLightProgram, 1); | ||
6388 | mDeferredLight[0].bindTarget(); | ||
6389 | |||
6390 | gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f); | ||
6391 | gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor); | ||
6392 | gDeferredBlurLightProgram.uniform3fv("kern[0]", kern_length, gauss[0].mV); | ||
6393 | gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV); | ||
6394 | gDeferredBlurLightProgram.uniform1i("kern_length", kern_length); | ||
6395 | gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f)); | ||
6396 | |||
6397 | { | ||
6398 | LLGLDisable blend(GL_BLEND); | ||
6399 | LLGLDepthTest depth(GL_FALSE); | ||
6400 | stop_glerror(); | ||
6401 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); // KL 4? | ||
6402 | stop_glerror(); | ||
6403 | } | ||
5581 | mDeferredLight[0].flush(); | 6404 | mDeferredLight[0].flush(); |
5582 | unbindDeferredShader(gDeferredBlurLightProgram); | 6405 | unbindDeferredShader(gDeferredBlurLightProgram); |
6406 | } | ||
5583 | 6407 | ||
5584 | stop_glerror(); | 6408 | stop_glerror(); |
5585 | glPopMatrix(); | 6409 | glPopMatrix(); |
@@ -5588,15 +6412,26 @@ void LLPipeline::renderDeferredLighting() | |||
5588 | stop_glerror(); | 6412 | stop_glerror(); |
5589 | glPopMatrix(); | 6413 | glPopMatrix(); |
5590 | stop_glerror(); | 6414 | stop_glerror(); |
6415 | // } | ||
5591 | 6416 | ||
5592 | //copy depth and stencil from deferred screen | 6417 | //copy depth and stencil from deferred screen |
5593 | //mScreen.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), | 6418 | //mScreen.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), |
5594 | // 0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); | 6419 | // 0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
5595 | 6420 | ||
5596 | mScreen.bindTarget(); | 6421 | /* if (gSavedSettings.getBOOL("RenderDeferredGI")) |
5597 | mScreen.clear(GL_COLOR_BUFFER_BIT); | 6422 | { |
5598 | 6423 | mDeferredLight[1].bindTarget(); | |
5599 | bindDeferredShader(gDeferredSoftenProgram); | 6424 | mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT); |
6425 | } | ||
6426 | else | ||
6427 | { */ | ||
6428 | mScreen.bindTarget(); | ||
6429 | mScreen.clear(GL_COLOR_BUFFER_BIT); | ||
6430 | // } | ||
6431 | |||
6432 | if (gSavedSettings.getBOOL("RenderDeferredAtmospheric")) | ||
6433 | { //apply sunlight contribution | ||
6434 | bindDeferredShader(gDeferredSoftenProgram, 0, &mGIMapPost[0]); // may not be using GI but still need this KL | ||
5600 | { | 6435 | { |
5601 | LLGLDepthTest depth(GL_FALSE); | 6436 | LLGLDepthTest depth(GL_FALSE); |
5602 | LLGLDisable blend(GL_BLEND); | 6437 | LLGLDisable blend(GL_BLEND); |
@@ -5619,130 +6454,330 @@ void LLPipeline::renderDeferredLighting() | |||
5619 | } | 6454 | } |
5620 | 6455 | ||
5621 | unbindDeferredShader(gDeferredSoftenProgram); | 6456 | unbindDeferredShader(gDeferredSoftenProgram); |
6457 | } | ||
6458 | // KL this code is a tad buggered atm it obliterates local lights...... | ||
6459 | /* { //render sky/water/hair/skirts | ||
6460 | LLGLDisable blend(GL_BLEND); | ||
6461 | LLGLDisable stencil(GL_STENCIL_TEST); | ||
6462 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | ||
5622 | 6463 | ||
5623 | bindDeferredShader(gDeferredLightProgram); | 6464 | U32 render_mask = mRenderTypeMask; |
5624 | 6465 | mRenderTypeMask = mRenderTypeMask & | |
5625 | std::list<LLVector4> fullscreen_lights; | 6466 | ((1 << LLPipeline::RENDER_TYPE_SKY) | |
5626 | std::list<LLVector4> light_colors; | 6467 | (1 << LLPipeline::RENDER_TYPE_CLOUDS) | |
6468 | (1 << LLPipeline::RENDER_TYPE_WL_SKY) | | ||
6469 | (1 << LLPipeline::RENDER_TYPE_AVATAR) | | ||
6470 | (1 << LLPipeline::RENDER_TYPE_WATER)); | ||
6471 | |||
6472 | renderGeomPostDeferred(*LLViewerCamera::getInstance()); | ||
6473 | mRenderTypeMask = render_mask; | ||
6474 | } */ | ||
5627 | 6475 | ||
5628 | F32 v[24]; | 6476 | BOOL render_local = gSavedSettings.getBOOL("RenderDeferredLocalLights"); |
5629 | glVertexPointer(3, GL_FLOAT, 0, v); | 6477 | BOOL render_fullscreen = gSavedSettings.getBOOL("RenderDeferredFullscreenLights"); |
6478 | |||
6479 | /* | ||
6480 | if (gSavedSettings.getBOOL("RenderDeferredGI")) | ||
5630 | { | 6481 | { |
5631 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); | 6482 | mDeferredLight[1].flush(); |
5632 | for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) | 6483 | mDeferredLight[2].bindTarget(); |
6484 | mDeferredLight[2].clear(GL_COLOR_BUFFER_BIT); | ||
6485 | } | ||
6486 | */ | ||
6487 | if (render_local || render_fullscreen) | ||
6488 | { | ||
6489 | gGL.setSceneBlendType(LLRender::BT_ADD); | ||
6490 | std::list<LLVector4> fullscreen_lights; | ||
6491 | LLDrawable::drawable_list_t spot_lights; | ||
6492 | LLDrawable::drawable_list_t fullscreen_spot_lights; | ||
6493 | |||
6494 | for (U32 i = 0; i < 2; i++) | ||
5633 | { | 6495 | { |
5634 | LLDrawable* drawablep = *iter; | 6496 | mTargetShadowSpotLight[i] = NULL; |
5635 | 6497 | } | |
5636 | LLVOVolume* volume = drawablep->getVOVolume(); | 6498 | |
5637 | if (!volume) | 6499 | std::list<LLVector4> light_colors; |
6500 | |||
6501 | F32 v[24]; | ||
6502 | glVertexPointer(3, GL_FLOAT, 0, v); | ||
6503 | BOOL render_local = gSavedSettings.getBOOL("RenderDeferredLocalLights"); | ||
6504 | |||
6505 | { | ||
6506 | bindDeferredShader(gDeferredLightProgram); | ||
6507 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); | ||
6508 | for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) | ||
5638 | { | 6509 | { |
5639 | continue; | 6510 | LLDrawable* drawablep = *iter; |
6511 | |||
6512 | LLVOVolume* volume = drawablep->getVOVolume(); | ||
6513 | if (!volume) | ||
6514 | { | ||
6515 | continue; | ||
6516 | } | ||
6517 | |||
6518 | LLVector3 center = drawablep->getPositionAgent(); | ||
6519 | F32* c = center.mV; | ||
6520 | F32 s = volume->getLightRadius()*1.5f; | ||
6521 | |||
6522 | LLColor3 col = volume->getLightColor(); | ||
6523 | col *= volume->getLightIntensity(); | ||
6524 | |||
6525 | if (col.magVecSquared() < 0.001f) | ||
6526 | { | ||
6527 | continue; | ||
6528 | } | ||
6529 | |||
6530 | if (s <= 0.001f) | ||
6531 | { | ||
6532 | continue; | ||
6533 | } | ||
6534 | |||
6535 | if (LLViewerCamera::getInstance()->AABBInFrustumNoFarClip(center, LLVector3(s,s,s)) == 0) | ||
6536 | { | ||
6537 | continue; | ||
6538 | } | ||
6539 | |||
6540 | sVisibleLightCount++; | ||
6541 | |||
6542 | glh::vec3f tc(c); | ||
6543 | mat.mult_matrix_vec(tc); | ||
6544 | |||
6545 | //vertex positions are encoded so the 3 bits of their vertex index | ||
6546 | //correspond to their axis facing, with bit position 3,2,1 matching | ||
6547 | //axis facing x,y,z, bit set meaning positive facing, bit clear | ||
6548 | //meaning negative facing | ||
6549 | v[0] = c[0]-s; v[1] = c[1]-s; v[2] = c[2]-s; // 0 - 0000 | ||
6550 | v[3] = c[0]-s; v[4] = c[1]-s; v[5] = c[2]+s; // 1 - 0001 | ||
6551 | v[6] = c[0]-s; v[7] = c[1]+s; v[8] = c[2]-s; // 2 - 0010 | ||
6552 | v[9] = c[0]-s; v[10] = c[1]+s; v[11] = c[2]+s; // 3 - 0011 | ||
6553 | |||
6554 | v[12] = c[0]+s; v[13] = c[1]-s; v[14] = c[2]-s; // 4 - 0100 | ||
6555 | v[15] = c[0]+s; v[16] = c[1]-s; v[17] = c[2]+s; // 5 - 0101 | ||
6556 | v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110 | ||
6557 | v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111 | ||
6558 | |||
6559 | if (LLViewerCamera::getInstance()->getOrigin().mV[0] > c[0] + s + 0.2f || | ||
6560 | LLViewerCamera::getInstance()->getOrigin().mV[0] < c[0] - s - 0.2f || | ||
6561 | LLViewerCamera::getInstance()->getOrigin().mV[1] > c[1] + s + 0.2f || | ||
6562 | LLViewerCamera::getInstance()->getOrigin().mV[1] < c[1] - s - 0.2f || | ||
6563 | LLViewerCamera::getInstance()->getOrigin().mV[2] > c[2] + s + 0.2f || | ||
6564 | LLViewerCamera::getInstance()->getOrigin().mV[2] < c[2] - s - 0.2f) | ||
6565 | { //draw box if camera is outside box | ||
6566 | if (render_local) | ||
6567 | { | ||
6568 | if (volume->getLightTexture()) | ||
6569 | { | ||
6570 | drawablep->getVOVolume()->updateSpotLightPriority(); | ||
6571 | spot_lights.push_back(drawablep); | ||
6572 | continue; | ||
6573 | } | ||
6574 | |||
6575 | glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); | ||
6576 | glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); | ||
6577 | glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, | ||
6578 | GL_UNSIGNED_BYTE, get_box_fan_indices(LLViewerCamera::getInstance(), center)); | ||
6579 | } | ||
6580 | } | ||
6581 | else if (render_fullscreen) | ||
6582 | { | ||
6583 | if (volume->getLightTexture()) | ||
6584 | { | ||
6585 | drawablep->getVOVolume()->updateSpotLightPriority(); | ||
6586 | fullscreen_spot_lights.push_back(drawablep); | ||
6587 | continue; | ||
6588 | } | ||
6589 | |||
6590 | fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s*s)); | ||
6591 | light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); | ||
6592 | } | ||
5640 | } | 6593 | } |
6594 | unbindDeferredShader(gDeferredLightProgram); | ||
6595 | } | ||
6596 | |||
6597 | if (!spot_lights.empty()) | ||
6598 | { | ||
6599 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); | ||
6600 | bindDeferredShader(gDeferredSpotLightProgram); | ||
5641 | 6601 | ||
5642 | LLVector3 center = drawablep->getPositionAgent(); | 6602 | gDeferredSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); |
5643 | F32* c = center.mV; | ||
5644 | F32 s = volume->getLightRadius()*1.5f; | ||
5645 | 6603 | ||
5646 | if (LLViewerCamera::getInstance()->AABBInFrustumNoFarClip(center, LLVector3(s,s,s)) == 0) | 6604 | for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) |
5647 | { | 6605 | { |
5648 | continue; | 6606 | LLDrawable* drawablep = *iter; |
5649 | } | 6607 | |
6608 | LLVOVolume* volume = drawablep->getVOVolume(); | ||
6609 | |||
6610 | LLVector3 center = drawablep->getPositionAgent(); | ||
6611 | F32* c = center.mV; | ||
6612 | F32 s = volume->getLightRadius()*1.5f; | ||
6613 | |||
6614 | sVisibleLightCount++; | ||
6615 | |||
6616 | glh::vec3f tc(c); | ||
6617 | mat.mult_matrix_vec(tc); | ||
6618 | |||
6619 | setupSpotLight(gDeferredSpotLightProgram, drawablep); | ||
6620 | |||
6621 | LLColor3 col = volume->getLightColor(); | ||
6622 | col *= volume->getLightIntensity(); | ||
6623 | |||
6624 | //vertex positions are encoded so the 3 bits of their vertex index | ||
6625 | //correspond to their axis facing, with bit position 3,2,1 matching | ||
6626 | //axis facing x,y,z, bit set meaning positive facing, bit clear | ||
6627 | //meaning negative facing | ||
6628 | v[0] = c[0]-s; v[1] = c[1]-s; v[2] = c[2]-s; // 0 - 0000 | ||
6629 | v[3] = c[0]-s; v[4] = c[1]-s; v[5] = c[2]+s; // 1 - 0001 | ||
6630 | v[6] = c[0]-s; v[7] = c[1]+s; v[8] = c[2]-s; // 2 - 0010 | ||
6631 | v[9] = c[0]-s; v[10] = c[1]+s; v[11] = c[2]+s; // 3 - 0011 | ||
6632 | |||
6633 | v[12] = c[0]+s; v[13] = c[1]-s; v[14] = c[2]-s; // 4 - 0100 | ||
6634 | v[15] = c[0]+s; v[16] = c[1]-s; v[17] = c[2]+s; // 5 - 0101 | ||
6635 | v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110 | ||
6636 | v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111 | ||
5650 | 6637 | ||
5651 | sVisibleLightCount++; | ||
5652 | glh::vec3f tc(c); | ||
5653 | mat.mult_matrix_vec(tc); | ||
5654 | |||
5655 | LLColor3 col = volume->getLightColor(); | ||
5656 | col *= volume->getLightIntensity(); | ||
5657 | |||
5658 | //vertex positions are encoded so the 3 bits of their vertex index | ||
5659 | //correspond to their axis facing, with bit position 3,2,1 matching | ||
5660 | //axis facing x,y,z, bit set meaning positive facing, bit clear | ||
5661 | //meaning negative facing | ||
5662 | v[0] = c[0]-s; v[1] = c[1]-s; v[2] = c[2]-s; // 0 - 0000 | ||
5663 | v[3] = c[0]-s; v[4] = c[1]-s; v[5] = c[2]+s; // 1 - 0001 | ||
5664 | v[6] = c[0]-s; v[7] = c[1]+s; v[8] = c[2]-s; // 2 - 0010 | ||
5665 | v[9] = c[0]-s; v[10] = c[1]+s; v[11] = c[2]+s; // 3 - 0011 | ||
5666 | |||
5667 | v[12] = c[0]+s; v[13] = c[1]-s; v[14] = c[2]-s; // 4 - 0100 | ||
5668 | v[15] = c[0]+s; v[16] = c[1]-s; v[17] = c[2]+s; // 5 - 0101 | ||
5669 | v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110 | ||
5670 | v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111 | ||
5671 | |||
5672 | if (LLViewerCamera::getInstance()->getOrigin().mV[0] > c[0] + s + 0.2f || | ||
5673 | LLViewerCamera::getInstance()->getOrigin().mV[0] < c[0] - s - 0.2f || | ||
5674 | LLViewerCamera::getInstance()->getOrigin().mV[1] > c[1] + s + 0.2f || | ||
5675 | LLViewerCamera::getInstance()->getOrigin().mV[1] < c[1] - s - 0.2f || | ||
5676 | LLViewerCamera::getInstance()->getOrigin().mV[2] > c[2] + s + 0.2f || | ||
5677 | LLViewerCamera::getInstance()->getOrigin().mV[2] < c[2] - s - 0.2f) | ||
5678 | { //draw box if camera is outside box | ||
5679 | glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); | 6638 | glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); |
5680 | glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); | 6639 | glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); |
5681 | glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, | 6640 | glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, |
5682 | GL_UNSIGNED_BYTE, get_box_fan_indices(LLViewerCamera::getInstance(), center)); | 6641 | GL_UNSIGNED_BYTE, get_box_fan_indices(LLViewerCamera::getInstance(), center)); |
5683 | } | ||
5684 | else | ||
5685 | { | ||
5686 | fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s*s)); | ||
5687 | light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); | ||
5688 | } | 6642 | } |
6643 | gDeferredSpotLightProgram.disableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); | ||
6644 | unbindDeferredShader(gDeferredSpotLightProgram); | ||
5689 | } | 6645 | } |
5690 | } | ||
5691 | 6646 | ||
5692 | unbindDeferredShader(gDeferredLightProgram); | 6647 | { |
6648 | bindDeferredShader(gDeferredMultiLightProgram); | ||
6649 | |||
6650 | LLGLDepthTest depth(GL_FALSE); | ||
5693 | 6651 | ||
5694 | if (!fullscreen_lights.empty()) | 6652 | //full screen blit |
5695 | { | 6653 | glPushMatrix(); |
5696 | bindDeferredShader(gDeferredMultiLightProgram); | 6654 | glLoadIdentity(); |
5697 | LLGLDepthTest depth(GL_FALSE); | 6655 | glMatrixMode(GL_PROJECTION); |
6656 | glPushMatrix(); | ||
6657 | glLoadIdentity(); | ||
5698 | 6658 | ||
5699 | //full screen blit | 6659 | U32 count = 0; |
5700 | glPushMatrix(); | ||
5701 | glLoadIdentity(); | ||
5702 | glMatrixMode(GL_PROJECTION); | ||
5703 | glPushMatrix(); | ||
5704 | glLoadIdentity(); | ||
5705 | 6660 | ||
5706 | U32 count = 0; | 6661 | const U32 max_count = 8; // KL poss 16? |
6662 | LLVector4 light[max_count]; | ||
6663 | LLVector4 col[max_count]; | ||
5707 | 6664 | ||
5708 | LLVector4 light[16]; | 6665 | glVertexPointer(2, GL_FLOAT, 0, vert); |
5709 | LLVector4 col[16]; | ||
5710 | 6666 | ||
5711 | glVertexPointer(2, GL_FLOAT, 0, vert); | 6667 | F32 far_z = 0.f; |
5712 | 6668 | ||
5713 | while (!fullscreen_lights.empty()) | 6669 | while (!fullscreen_lights.empty()) |
5714 | { | 6670 | { |
5715 | light[count] = fullscreen_lights.front(); | 6671 | light[count] = fullscreen_lights.front(); |
5716 | fullscreen_lights.pop_front(); | 6672 | fullscreen_lights.pop_front(); |
5717 | col[count] = light_colors.front(); | 6673 | col[count] = light_colors.front(); |
5718 | light_colors.pop_front(); | 6674 | light_colors.pop_front(); |
5719 | 6675 | ||
5720 | count++; | 6676 | far_z = llmin(light[count].mV[2]-sqrtf(light[count].mV[3]), far_z); |
5721 | if (count == 16 || fullscreen_lights.empty()) | 6677 | |
6678 | count++; | ||
6679 | if (count == max_count || fullscreen_lights.empty()) | ||
6680 | { | ||
6681 | gDeferredMultiLightProgram.uniform1i("light_count", count); | ||
6682 | gDeferredMultiLightProgram.uniform4fv("light[0]", count, (GLfloat*) light); | ||
6683 | gDeferredMultiLightProgram.uniform4fv("light", count, (GLfloat*) light); | ||
6684 | gDeferredMultiLightProgram.uniform4fv("light_col[0]", count, (GLfloat*) col); | ||
6685 | gDeferredMultiLightProgram.uniform4fv("light_col", count, (GLfloat*) col); | ||
6686 | gDeferredMultiLightProgram.uniform1f("far_z", far_z); | ||
6687 | far_z = 0.f; | ||
6688 | count = 0; | ||
6689 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | ||
6690 | } | ||
6691 | } | ||
6692 | |||
6693 | unbindDeferredShader(gDeferredMultiLightProgram); | ||
6694 | |||
6695 | bindDeferredShader(gDeferredMultiSpotLightProgram); | ||
6696 | |||
6697 | gDeferredMultiSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); | ||
6698 | |||
6699 | for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) | ||
5722 | { | 6700 | { |
5723 | gDeferredMultiLightProgram.uniform1i("light_count", count); | 6701 | LLDrawable* drawablep = *iter; |
5724 | gDeferredMultiLightProgram.uniform4fv("light[0]", count, (GLfloat*) light); | 6702 | |
5725 | gDeferredMultiLightProgram.uniform4fv("light", count, (GLfloat*) light); | 6703 | LLVOVolume* volume = drawablep->getVOVolume(); |
5726 | gDeferredMultiLightProgram.uniform4fv("light_col[0]", count, (GLfloat*) col); | 6704 | |
5727 | gDeferredMultiLightProgram.uniform4fv("light_col", count, (GLfloat*) col); | 6705 | LLVector3 center = drawablep->getPositionAgent(); |
5728 | count = 0; | 6706 | F32* c = center.mV; |
6707 | F32 s = volume->getLightRadius()*1.5f; | ||
6708 | |||
6709 | sVisibleLightCount++; | ||
6710 | |||
6711 | glh::vec3f tc(c); | ||
6712 | mat.mult_matrix_vec(tc); | ||
6713 | |||
6714 | setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); | ||
6715 | |||
6716 | LLColor3 col = volume->getLightColor(); | ||
6717 | col *= volume->getLightIntensity(); | ||
6718 | |||
6719 | glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); | ||
6720 | glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); | ||
5729 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); | 6721 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); |
5730 | } | 6722 | } |
5731 | } | ||
5732 | |||
5733 | |||
5734 | glPopMatrix(); | ||
5735 | glMatrixMode(GL_MODELVIEW); | ||
5736 | glPopMatrix(); | ||
5737 | 6723 | ||
5738 | unbindDeferredShader(gDeferredMultiLightProgram); | 6724 | gDeferredMultiSpotLightProgram.disableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); |
6725 | unbindDeferredShader(gDeferredMultiSpotLightProgram); | ||
6726 | |||
6727 | glPopMatrix(); | ||
6728 | glMatrixMode(GL_MODELVIEW); | ||
6729 | glPopMatrix(); | ||
6730 | } | ||
5739 | } | 6731 | } |
6732 | |||
5740 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 6733 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
6734 | gGL.setColorMask(true, true); | ||
6735 | /* | ||
6736 | if (gSavedSettings.getBOOL("RenderDeferredGI")) | ||
6737 | { | ||
6738 | mDeferredLight[2].flush(); | ||
6739 | mScreen.bindTarget(); | ||
6740 | mScreen.clear(GL_COLOR_BUFFER_BIT); | ||
6741 | |||
6742 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | ||
6743 | |||
6744 | { //mix various light maps (local, sun, gi) | ||
6745 | LLGLDisable blend(GL_BLEND); | ||
6746 | LLGLDisable test(GL_ALPHA_TEST); | ||
6747 | LLGLDepthTest depth(GL_FALSE); | ||
6748 | LLGLDisable stencil(GL_STENCIL_TEST); | ||
6749 | |||
6750 | gViewerWindow->setupViewport(); | ||
6751 | |||
6752 | bindDeferredShader(gDeferredPostProgram, 0, &mGIMapPost[0]); | ||
6753 | |||
6754 | gDeferredPostProgram.bind(); | ||
6755 | |||
6756 | LLVertexBuffer::unbind(); | ||
6757 | |||
6758 | glVertexPointer(2, GL_FLOAT, 0, vert); | ||
6759 | glColor3f(1,1,1); | ||
5741 | 6760 | ||
5742 | { //render non-deferred geometry | 6761 | glPushMatrix(); |
6762 | glLoadIdentity(); | ||
6763 | glMatrixMode(GL_PROJECTION); | ||
6764 | glPushMatrix(); | ||
6765 | glLoadIdentity(); | ||
6766 | |||
6767 | glDrawArrays(GL_TRIANGLES, 0, 3); | ||
6768 | |||
6769 | glPopMatrix(); | ||
6770 | glMatrixMode(GL_MODELVIEW); | ||
6771 | glPopMatrix(); | ||
6772 | |||
6773 | unbindDeferredShader(gDeferredPostProgram); | ||
6774 | } | ||
6775 | } | ||
6776 | */ | ||
6777 | { //render non-deferred geometry (alpha, fullbright, glow) KL issues with render pipeline merge needs work.. here | ||
5743 | LLGLDisable blend(GL_BLEND); | 6778 | LLGLDisable blend(GL_BLEND); |
5744 | LLGLDisable stencil(GL_STENCIL_TEST); | 6779 | LLGLDisable stencil(GL_STENCIL_TEST); |
5745 | 6780 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | |
5746 | U32 render_mask = mRenderTypeMask; | 6781 | U32 render_mask = mRenderTypeMask; |
5747 | mRenderTypeMask = mRenderTypeMask & | 6782 | mRenderTypeMask = mRenderTypeMask & |
5748 | ((1 << LLPipeline::RENDER_TYPE_SKY) | | 6783 | ((1 << LLPipeline::RENDER_TYPE_SKY) | |
@@ -5754,18 +6789,161 @@ void LLPipeline::renderDeferredLighting() | |||
5754 | (1 << LLPipeline::RENDER_TYPE_FULLBRIGHT) | | 6789 | (1 << LLPipeline::RENDER_TYPE_FULLBRIGHT) | |
5755 | (1 << LLPipeline::RENDER_TYPE_VOLUME) | | 6790 | (1 << LLPipeline::RENDER_TYPE_VOLUME) | |
5756 | (1 << LLPipeline::RENDER_TYPE_GLOW) | | 6791 | (1 << LLPipeline::RENDER_TYPE_GLOW) | |
5757 | (1 << LLPipeline::RENDER_TYPE_BUMP)); | 6792 | (1 << LLPipeline::RENDER_TYPE_BUMP) | |
6793 | (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) | | ||
6794 | (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) | | ||
6795 | (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) | | ||
6796 | (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) | | ||
6797 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) | | ||
6798 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) | | ||
6799 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) | | ||
6800 | (1 << LLPipeline::RENDER_TYPE_PASS_GLOW) | | ||
6801 | (1 << LLPipeline::RENDER_TYPE_PASS_GRASS) | | ||
6802 | (1 << LLPipeline::RENDER_TYPE_PASS_SHINY) | | ||
6803 | (1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) | | ||
6804 | (1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY)); | ||
5758 | 6805 | ||
5759 | renderGeomPostDeferred(*LLViewerCamera::getInstance()); | 6806 | renderGeomPostDeferred(*LLViewerCamera::getInstance()); |
5760 | mRenderTypeMask = render_mask; | 6807 | mRenderTypeMask = render_mask; |
5761 | } | 6808 | } |
5762 | 6809 | ||
5763 | mScreen.flush(); | 6810 | mScreen.flush(); // We are FLUSHED alright ! end of deferred render YAY! |
5764 | 6811 | ||
5765 | } | 6812 | } |
5766 | 6813 | ||
6814 | void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) | ||
6815 | { | ||
6816 | //construct frustum | ||
6817 | LLVOVolume* volume = drawablep->getVOVolume(); | ||
6818 | LLVector3 params = volume->getSpotLightParams(); | ||
6819 | |||
6820 | F32 fov = params.mV[0]; | ||
6821 | F32 focus = params.mV[1]; | ||
6822 | |||
6823 | LLVector3 pos = drawablep->getPositionAgent(); | ||
6824 | LLQuaternion quat = volume->getRenderRotation(); | ||
6825 | LLVector3 scale = volume->getScale(); | ||
6826 | |||
6827 | //get near clip plane | ||
6828 | LLVector3 at_axis(0,0,-scale.mV[2]*0.5f); | ||
6829 | at_axis *= quat; | ||
6830 | |||
6831 | LLVector3 np = pos+at_axis; | ||
6832 | at_axis.normVec(); | ||
6833 | |||
6834 | //get origin that has given fov for plane np, at_axis, and given scale | ||
6835 | F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f); | ||
6836 | |||
6837 | LLVector3 origin = np - at_axis*dist; | ||
6838 | |||
6839 | //matrix from volume space to agent space | ||
6840 | LLMatrix4 light_mat(quat, LLVector4(origin,1.f)); | ||
6841 | |||
6842 | glh::matrix4f light_to_agent((F32*) light_mat.mMatrix); | ||
6843 | glh::matrix4f light_to_screen = glh_get_current_modelview() * light_to_agent; | ||
6844 | |||
6845 | glh::matrix4f screen_to_light = light_to_screen.inverse(); | ||
6846 | |||
6847 | F32 s = volume->getLightRadius()*1.5f; | ||
6848 | F32 near_clip = dist; | ||
6849 | F32 width = scale.mV[VX]; | ||
6850 | F32 height = scale.mV[VY]; | ||
6851 | F32 far_clip = s+dist-scale.mV[VZ]; | ||
6852 | |||
6853 | F32 fovy = fov * RAD_TO_DEG; | ||
6854 | F32 aspect = width/height; | ||
6855 | |||
6856 | glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, | ||
6857 | 0.f, 0.5f, 0.f, 0.5f, | ||
6858 | 0.f, 0.f, 0.5f, 0.5f, | ||
6859 | 0.f, 0.f, 0.f, 1.f); | ||
6860 | |||
6861 | glh::vec3f p1(0, 0, -(near_clip+0.01f)); | ||
6862 | glh::vec3f p2(0, 0, -(near_clip+1.f)); | ||
6863 | |||
6864 | glh::vec3f screen_origin(0, 0, 0); | ||
6865 | |||
6866 | light_to_screen.mult_matrix_vec(p1); | ||
6867 | light_to_screen.mult_matrix_vec(p2); | ||
6868 | light_to_screen.mult_matrix_vec(screen_origin); | ||
6869 | |||
6870 | glh::vec3f n = p2-p1; | ||
6871 | n.normalize(); | ||
6872 | |||
6873 | F32 proj_range = far_clip - near_clip; | ||
6874 | glh::matrix4f light_proj = gl_perspective(fovy, aspect, near_clip, far_clip); | ||
6875 | screen_to_light = trans * light_proj * screen_to_light; | ||
6876 | shader.uniformMatrix4fv("proj_mat", 1, FALSE, screen_to_light.m); | ||
6877 | shader.uniform1f("proj_near", near_clip); | ||
6878 | shader.uniform3fv("proj_p", 1, p1.v); | ||
6879 | shader.uniform3fv("proj_n", 1, n.v); | ||
6880 | shader.uniform3fv("proj_origin", 1, screen_origin.v); | ||
6881 | shader.uniform1f("proj_range", proj_range); | ||
6882 | shader.uniform1f("proj_ambiance", params.mV[2]); | ||
6883 | S32 s_idx = -1; | ||
6884 | |||
6885 | for (U32 i = 0; i < 2; i++) | ||
6886 | { | ||
6887 | if (mShadowSpotLight[i] == drawablep) | ||
6888 | { | ||
6889 | s_idx = i; | ||
6890 | } | ||
6891 | } | ||
6892 | |||
6893 | shader.uniform1i("proj_shadow_idx", s_idx); | ||
6894 | |||
6895 | if (s_idx >= 0) | ||
6896 | { | ||
6897 | shader.uniform1f("shadow_fade", 1.f-mSpotLightFade[s_idx]); | ||
6898 | } | ||
6899 | else | ||
6900 | { | ||
6901 | shader.uniform1f("shadow_fade", 1.f); | ||
6902 | } | ||
6903 | |||
6904 | { | ||
6905 | LLDrawable* potential = drawablep; | ||
6906 | //determine if this is a good light for casting shadows | ||
6907 | F32 m_pri = volume->getSpotLightPriority(); | ||
6908 | |||
6909 | for (U32 i = 0; i < 2; i++) | ||
6910 | { | ||
6911 | F32 pri = 0.f; | ||
6912 | |||
6913 | if (mTargetShadowSpotLight[i].notNull()) | ||
6914 | { | ||
6915 | pri = mTargetShadowSpotLight[i]->getVOVolume()->getSpotLightPriority(); | ||
6916 | } | ||
6917 | |||
6918 | if (m_pri > pri) | ||
6919 | { | ||
6920 | LLDrawable* temp = mTargetShadowSpotLight[i]; | ||
6921 | mTargetShadowSpotLight[i] = potential; | ||
6922 | potential = temp; | ||
6923 | m_pri = pri; | ||
6924 | } | ||
6925 | } | ||
6926 | } | ||
6927 | |||
6928 | LLViewerImage* img = volume->getLightTexture(); | ||
6929 | |||
6930 | S32 channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); | ||
6931 | |||
6932 | if (channel > -1 && img) | ||
6933 | { | ||
6934 | gGL.getTexUnit(channel)->bind(img); | ||
6935 | |||
6936 | F32 lod_range = logf(img->getWidth())/logf(2.f); | ||
6937 | |||
6938 | shader.uniform1f("proj_focus", focus); | ||
6939 | shader.uniform1f("proj_lod", lod_range); | ||
6940 | shader.uniform1f("proj_ambient_lod", llclamp((proj_range-focus)/proj_range*lod_range, 0.f, 1.f)); | ||
6941 | } | ||
6942 | } | ||
6943 | |||
5767 | void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) | 6944 | void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) |
5768 | { | 6945 | { |
6946 | LLFastTimer ftm(LLFastTimer::FTM_TEMP4); | ||
5769 | stop_glerror(); | 6947 | stop_glerror(); |
5770 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_POSITION, LLTexUnit::TT_RECT_TEXTURE); | 6948 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_POSITION, LLTexUnit::TT_RECT_TEXTURE); |
5771 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE); | 6949 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE); |
@@ -5773,14 +6951,40 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) | |||
5773 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE); | 6951 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE); |
5774 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE); | 6952 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE); |
5775 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, LLTexUnit::TT_RECT_TEXTURE); | 6953 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, LLTexUnit::TT_RECT_TEXTURE); |
6954 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE); | ||
6955 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_SUN_LIGHT, LLTexUnit::TT_RECT_TEXTURE); | ||
6956 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_LOCAL_LIGHT, LLTexUnit::TT_RECT_TEXTURE); | ||
6957 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_LUMINANCE); | ||
6958 | shader.disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); | ||
6959 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_NORMAL); | ||
6960 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_DIFFUSE); | ||
6961 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_SPECULAR); | ||
6962 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_DEPTH); | ||
6963 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_MIN_POS); | ||
6964 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_MAX_POS); | ||
6965 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_NORMAL); | ||
6966 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_DIFFUSE); | ||
6967 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_MIN_POS); | ||
6968 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_LAST_MAX_POS); | ||
6969 | |||
5776 | for (U32 i = 0; i < 4; i++) | 6970 | for (U32 i = 0; i < 4; i++) |
5777 | { | 6971 | { |
6972 | if (shader.disableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_RECT_TEXTURE) > -1) | ||
6973 | { | ||
6974 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); | ||
6975 | } | ||
6976 | } | ||
6977 | |||
6978 | for (U32 i = 4; i < 6; i++) | ||
6979 | { | ||
5778 | if (shader.disableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i) > -1) | 6980 | if (shader.disableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i) > -1) |
5779 | { | 6981 | { |
5780 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); | 6982 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); |
5781 | } | 6983 | } |
5782 | } | 6984 | } |
6985 | |||
5783 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_NOISE); | 6986 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_NOISE); |
6987 | shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHTFUNC); | ||
5784 | 6988 | ||
5785 | S32 channel = shader.disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); | 6989 | S32 channel = shader.disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); |
5786 | if (channel > -1) | 6990 | if (channel > -1) |
@@ -5794,6 +6998,8 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) | |||
5794 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | 6998 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
5795 | gGL.getTexUnit(0)->activate(); | 6999 | gGL.getTexUnit(0)->activate(); |
5796 | shader.unbind(); | 7000 | shader.unbind(); |
7001 | |||
7002 | LLGLState::checkTextureChannels(); | ||
5797 | } | 7003 | } |
5798 | 7004 | ||
5799 | inline float sgn(float a) | 7005 | inline float sgn(float a) |
@@ -5932,15 +7138,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) | |||
5932 | } | 7138 | } |
5933 | } | 7139 | } |
5934 | 7140 | ||
5935 | LLSpatialPartition::sFreezeState = TRUE; | 7141 | //LLSpatialPartition::sFreezeState = TRUE; |
5936 | LLPipeline::sSkipUpdate = TRUE; | 7142 | //LLPipeline::sSkipUpdate = TRUE; |
5937 | LLGLUserClipPlane clip_plane(plane, mat, projection); | 7143 | LLGLUserClipPlane clip_plane(plane, mat, projection); |
5938 | static LLCullResult result; | 7144 | static LLCullResult result; |
5939 | updateCull(camera, result, 1); | 7145 | updateCull(camera, result, 1); |
5940 | stateSort(camera, result); | 7146 | stateSort(camera, result); |
5941 | renderGeom(camera); | 7147 | renderGeom(camera); |
5942 | LLSpatialPartition::sFreezeState = FALSE; | 7148 | //LLSpatialPartition::sFreezeState = FALSE; |
5943 | LLPipeline::sSkipUpdate = FALSE; | 7149 | //LLPipeline::sSkipUpdate = FALSE; |
5944 | } | 7150 | } |
5945 | } | 7151 | } |
5946 | glCullFace(GL_BACK); | 7152 | glCullFace(GL_BACK); |
@@ -6039,7 +7245,6 @@ glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) | |||
6039 | 7245 | ||
6040 | dirN = dir; | 7246 | dirN = dir; |
6041 | dirN.normVec(); | 7247 | dirN.normVec(); |
6042 | |||
6043 | 7248 | ||
6044 | ret.m[ 0] = lftN[0]; | 7249 | ret.m[ 0] = lftN[0]; |
6045 | ret.m[ 1] = upN[0]; | 7250 | ret.m[ 1] = upN[0]; |
@@ -6090,14 +7295,465 @@ glh::matrix4f scale_translate_to_fit(const LLVector3 min, const LLVector3 max) | |||
6090 | return ret; | 7295 | return ret; |
6091 | } | 7296 | } |
6092 | 7297 | ||
6093 | void LLPipeline::generateSunShadow(LLCamera& camera) | 7298 | void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, BOOL use_shader) |
7299 | { | ||
7300 | LLFastTimer t(LLFastTimer::FTM_SHADOW_RENDER); | ||
7301 | |||
7302 | //clip out geometry on the same side of water as the camera | ||
7303 | static LLCullResult result; | ||
7304 | S32 occlude = LLPipeline::sUseOcclusion; | ||
7305 | LLPipeline::sUseOcclusion = 1; | ||
7306 | LLPipeline::sShadowRender = TRUE; | ||
7307 | |||
7308 | updateCull(shadow_cam, result); | ||
7309 | stateSort(shadow_cam, result); | ||
7310 | |||
7311 | U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_FULLBRIGHT, LLRenderPass::PASS_SHINY, LLRenderPass::PASS_BUMP }; | ||
7312 | LLGLEnable cull(GL_CULL_FACE); | ||
7313 | |||
7314 | //generate shadow map | ||
7315 | glMatrixMode(GL_PROJECTION); | ||
7316 | glPushMatrix(); | ||
7317 | glLoadMatrixf(proj.m); | ||
7318 | glMatrixMode(GL_MODELVIEW); | ||
7319 | glPushMatrix(); | ||
7320 | glLoadMatrixf(view.m); | ||
7321 | |||
7322 | stop_glerror(); | ||
7323 | gGLLastMatrix = NULL; | ||
7324 | |||
7325 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
7326 | |||
7327 | glColor4f(1,1,1,1); | ||
7328 | |||
7329 | stop_glerror(); | ||
7330 | |||
7331 | gGL.setColorMask(false, false); | ||
7332 | |||
7333 | if (use_shader) | ||
7334 | { | ||
7335 | gDeferredShadowProgram.bind(); | ||
7336 | } | ||
7337 | |||
7338 | //glCullFace(GL_FRONT); | ||
7339 | |||
7340 | { | ||
7341 | LLFastTimer ftm(LLFastTimer::FTM_SHADOW_SIMPLE); | ||
7342 | LLGLDisable test(GL_ALPHA_TEST); | ||
7343 | gGL.getTexUnit(0)->disable(); | ||
7344 | for (U32 i = 0; i < sizeof(types)/sizeof(U32); ++i) | ||
7345 | { | ||
7346 | renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); | ||
7347 | } | ||
7348 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); | ||
7349 | } | ||
7350 | |||
7351 | if (use_shader) | ||
7352 | { | ||
7353 | gDeferredShadowProgram.unbind(); | ||
7354 | renderGeomShadow(shadow_cam); | ||
7355 | gDeferredShadowProgram.bind(); | ||
7356 | } | ||
7357 | else | ||
7358 | { | ||
7359 | renderGeomShadow(shadow_cam); | ||
7360 | } | ||
7361 | |||
7362 | { | ||
7363 | LLFastTimer ftm(LLFastTimer::FTM_SHADOW_ALPHA); | ||
7364 | LLGLEnable test(GL_ALPHA_TEST); | ||
7365 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.6f); | ||
7366 | renderObjects(LLRenderPass::PASS_ALPHA_SHADOW, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR, TRUE); | ||
7367 | glColor4f(1,1,1,1); | ||
7368 | renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); | ||
7369 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | ||
7370 | } | ||
7371 | |||
7372 | //glCullFace(GL_BACK); | ||
7373 | |||
7374 | if (use_shader) | ||
7375 | { | ||
7376 | gDeferredShadowProgram.unbind(); | ||
7377 | } | ||
7378 | |||
7379 | gGL.setColorMask(true, true); | ||
7380 | |||
7381 | |||
7382 | glMatrixMode(GL_PROJECTION); | ||
7383 | glPopMatrix(); | ||
7384 | glMatrixMode(GL_MODELVIEW); | ||
7385 | glPopMatrix(); | ||
7386 | gGLLastMatrix = NULL; | ||
7387 | |||
7388 | LLPipeline::sUseOcclusion = occlude; | ||
7389 | LLPipeline::sShadowRender = FALSE; | ||
7390 | } | ||
7391 | |||
7392 | |||
7393 | BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir) | ||
7394 | { | ||
7395 | LLFastTimer ftm(LLFastTimer::FTM_TEMP2); | ||
7396 | //get point cloud of intersection of frust and min, max | ||
7397 | |||
7398 | //get set of planes | ||
7399 | std::vector<LLPlane> ps; | ||
7400 | |||
7401 | if (getVisibleExtents(camera, min, max)) | ||
7402 | { | ||
7403 | return FALSE; | ||
7404 | } | ||
7405 | |||
7406 | ps.push_back(LLPlane(min, LLVector3(-1,0,0))); | ||
7407 | ps.push_back(LLPlane(min, LLVector3(0,-1,0))); | ||
7408 | ps.push_back(LLPlane(min, LLVector3(0,0,-1))); | ||
7409 | ps.push_back(LLPlane(max, LLVector3(1,0,0))); | ||
7410 | ps.push_back(LLPlane(max, LLVector3(0,1,0))); | ||
7411 | ps.push_back(LLPlane(max, LLVector3(0,0,1))); | ||
7412 | |||
7413 | if (!light_dir.isExactlyZero()) | ||
7414 | { | ||
7415 | LLPlane ucp; | ||
7416 | LLPlane mcp; | ||
7417 | |||
7418 | F32 maxd = -1.f; | ||
7419 | F32 mind = 1.f; | ||
7420 | |||
7421 | for (U32 i = 0; i < ps.size(); ++i) | ||
7422 | { //pick the plane most aligned to lightDir for user clip plane | ||
7423 | LLVector3 n(ps[i].mV); | ||
7424 | F32 da = n*light_dir; | ||
7425 | if (da > maxd) | ||
7426 | { | ||
7427 | maxd = da; | ||
7428 | ucp = ps[i]; | ||
7429 | } | ||
7430 | |||
7431 | if (da < mind) | ||
7432 | { | ||
7433 | mind = da; | ||
7434 | mcp = ps[i]; | ||
7435 | } | ||
7436 | } | ||
7437 | |||
7438 | camera.setUserClipPlane(ucp); | ||
7439 | |||
7440 | ps.clear(); | ||
7441 | ps.push_back(ucp); | ||
7442 | ps.push_back(mcp); | ||
7443 | } | ||
7444 | |||
7445 | for (U32 i = 0; i < 6; i++) | ||
7446 | { | ||
7447 | ps.push_back(camera.getAgentPlane(i)); | ||
7448 | } | ||
7449 | |||
7450 | //get set of points where planes intersect and points are not above any plane | ||
7451 | fp.clear(); | ||
7452 | |||
7453 | for (U32 i = 0; i < ps.size(); ++i) | ||
7454 | { | ||
7455 | for (U32 j = 0; j < ps.size(); ++j) | ||
7456 | { | ||
7457 | for (U32 k = 0; k < ps.size(); ++k) | ||
7458 | { | ||
7459 | if (i == j || | ||
7460 | i == k || | ||
7461 | k == j) | ||
7462 | { | ||
7463 | continue; | ||
7464 | } | ||
7465 | |||
7466 | LLVector3 n1,n2,n3; | ||
7467 | F32 d1,d2,d3; | ||
7468 | |||
7469 | n1.setVec(ps[i].mV); | ||
7470 | n2.setVec(ps[j].mV); | ||
7471 | n3.setVec(ps[k].mV); | ||
7472 | |||
7473 | d1 = ps[i].mV[3]; | ||
7474 | d2 = ps[j].mV[3]; | ||
7475 | d3 = ps[k].mV[3]; | ||
7476 | |||
7477 | //get point of intersection of 3 planes "p" | ||
7478 | LLVector3 p = (-d1*(n2%n3)-d2*(n3%n1)-d3*(n1%n2))/(n1*(n2%n3)); | ||
7479 | |||
7480 | if (llround(p*n1+d1, 0.0001f) == 0.f && | ||
7481 | llround(p*n2+d2, 0.0001f) == 0.f && | ||
7482 | llround(p*n3+d3, 0.0001f) == 0.f) | ||
7483 | { //point is on all three planes | ||
7484 | BOOL found = TRUE; | ||
7485 | for (U32 l = 0; l < ps.size() && found; ++l) | ||
7486 | { | ||
7487 | if (llround(ps[l].dist(p), 0.0001f) > 0.0f) | ||
7488 | { //point is above some plane, not contained | ||
7489 | found = FALSE; | ||
7490 | } | ||
7491 | } | ||
7492 | |||
7493 | if (found) | ||
7494 | { | ||
7495 | fp.push_back(p); | ||
7496 | } | ||
7497 | } | ||
7498 | } | ||
7499 | } | ||
7500 | } | ||
7501 | |||
7502 | if (fp.empty()) | ||
7503 | { | ||
7504 | return FALSE; | ||
7505 | } | ||
7506 | |||
7507 | return TRUE; | ||
7508 | } | ||
7509 | |||
7510 | void LLPipeline::generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<LLVector3>& vpc) | ||
7511 | { | ||
7512 | /* if (!gSavedSettings.getBOOL("RenderDeferredGI")) | ||
7513 | { | ||
7514 | return; | ||
7515 | } */ | ||
7516 | |||
7517 | LLVector3 up; | ||
7518 | |||
7519 | if (lightDir.mV[2] > 0.5f) | ||
7520 | { | ||
7521 | up = LLVector3(1,0,0); | ||
7522 | } | ||
7523 | else | ||
7524 | { | ||
7525 | up = LLVector3(0, 0, 1); | ||
7526 | } | ||
7527 | |||
7528 | |||
7529 | F32 lrad = gSavedSettings.getF32("RenderGILightRadius"); | ||
7530 | |||
7531 | F32 samples = (F32) gSavedSettings.getU32("RenderGISamples"); | ||
7532 | |||
7533 | F32 gi_range = gSavedSettings.getF32("RenderGIRange"); | ||
7534 | |||
7535 | U32 res = 1024; | ||
7536 | |||
7537 | lrad = samples*gi_range/(res-samples)*0.5f; | ||
7538 | |||
7539 | F32 lrange = lrad+gi_range*0.5f; | ||
7540 | |||
7541 | LLVector3 pad(lrange,lrange,lrange); | ||
7542 | |||
7543 | glh::matrix4f view = look(LLVector3(128.f,128.f,128.f), lightDir, up); | ||
7544 | |||
7545 | LLVector3 cp = camera.getOrigin()+camera.getAtAxis()*(gi_range*0.5f); | ||
7546 | |||
7547 | glh::vec3f scp(cp.mV); | ||
7548 | view.mult_matrix_vec(scp); | ||
7549 | cp.setVec(scp.v); | ||
7550 | |||
7551 | F32 pix_width = lrange/(res*0.5f); | ||
7552 | |||
7553 | //lrad = llround(lrad, pix_width); | ||
7554 | |||
7555 | //move cp to the nearest pix_width | ||
7556 | for (U32 i = 0; i < 3; i++) | ||
7557 | { | ||
7558 | cp.mV[i] = llround(cp.mV[i], pix_width); | ||
7559 | } | ||
7560 | |||
7561 | LLVector3 min = cp-pad; | ||
7562 | LLVector3 max = cp+pad; | ||
7563 | |||
7564 | //set mGIRange to range in tc space[0,1] that covers texture block of intersecting lights around a point | ||
7565 | mGIRange.mV[0] = (max.mV[0]-min.mV[0])/res; | ||
7566 | mGIRange.mV[1] = (max.mV[1]-min.mV[1])/res; | ||
7567 | mGILightRadius = lrad; | ||
7568 | |||
7569 | glh::matrix4f proj = gl_ortho(min.mV[0], max.mV[0], | ||
7570 | min.mV[1], max.mV[1], | ||
7571 | -max.mV[2], -min.mV[2]); | ||
7572 | |||
7573 | LLCamera sun_cam = camera; | ||
7574 | |||
7575 | glh::matrix4f eye_view = glh_get_current_modelview(); | ||
7576 | |||
7577 | //get eye space to camera space matrix | ||
7578 | mGIMatrix = view*eye_view.inverse(); | ||
7579 | mGINormalMatrix = mGIMatrix.inverse().transpose(); | ||
7580 | mGIInvProj = proj.inverse(); | ||
7581 | mGIMatrixProj = proj*mGIMatrix; | ||
7582 | |||
7583 | //translate and scale to [0,1] | ||
7584 | glh::matrix4f trans(.5f, 0.f, 0.f, .5f, | ||
7585 | 0.f, 0.5f, 0.f, 0.5f, | ||
7586 | 0.f, 0.f, 0.5f, 0.5f, | ||
7587 | 0.f, 0.f, 0.f, 1.f); | ||
7588 | |||
7589 | mGIMatrixProj = trans*mGIMatrixProj; | ||
7590 | |||
7591 | glh_set_current_modelview(view); | ||
7592 | glh_set_current_projection(proj); | ||
7593 | |||
7594 | LLViewerCamera::updateFrustumPlanes(sun_cam, TRUE, FALSE, TRUE); | ||
7595 | |||
7596 | sun_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR); | ||
7597 | static LLCullResult result; | ||
7598 | |||
7599 | U32 type_mask = mRenderTypeMask; | ||
7600 | |||
7601 | mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) | | ||
7602 | (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) | | ||
7603 | (1<<LLPipeline::RENDER_TYPE_BUMP) | | ||
7604 | (1<<LLPipeline::RENDER_TYPE_VOLUME) | | ||
7605 | (1<<LLPipeline::RENDER_TYPE_TREE) | | ||
7606 | (1<<LLPipeline::RENDER_TYPE_TERRAIN) | | ||
7607 | (1<<LLPipeline::RENDER_TYPE_WATER) | | ||
7608 | (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) | | ||
7609 | (1<<LLPipeline::RENDER_TYPE_AVATAR) | | ||
7610 | (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) | | ||
7611 | (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) | | ||
7612 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) | | ||
7613 | (1 << LLPipeline::RENDER_TYPE_PASS_SHINY)); | ||
7614 | |||
7615 | |||
7616 | |||
7617 | S32 occlude = LLPipeline::sUseOcclusion; | ||
7618 | LLPipeline::sUseOcclusion = 0; | ||
7619 | LLPipeline::sShadowRender = TRUE; | ||
7620 | |||
7621 | updateCull(sun_cam, result); | ||
7622 | stateSort(sun_cam, result); | ||
7623 | |||
7624 | LLGLEnable cull(GL_CULL_FACE); | ||
7625 | |||
7626 | //generate GI map | ||
7627 | glMatrixMode(GL_PROJECTION); | ||
7628 | glPushMatrix(); | ||
7629 | glLoadMatrixf(proj.m); | ||
7630 | glMatrixMode(GL_MODELVIEW); | ||
7631 | glPushMatrix(); | ||
7632 | glLoadMatrixf(view.m); | ||
7633 | |||
7634 | stop_glerror(); | ||
7635 | gGLLastMatrix = NULL; | ||
7636 | |||
7637 | mGIMap.clear(); | ||
7638 | |||
7639 | { | ||
7640 | LLGLEnable enable(GL_DEPTH_CLAMP_NV); | ||
7641 | renderGeomDeferred(camera); | ||
7642 | } | ||
7643 | |||
7644 | mGIMap.flush(); | ||
7645 | |||
7646 | glMatrixMode(GL_PROJECTION); | ||
7647 | glPopMatrix(); | ||
7648 | glMatrixMode(GL_MODELVIEW); | ||
7649 | glPopMatrix(); | ||
7650 | gGLLastMatrix = NULL; | ||
7651 | |||
7652 | LLPipeline::sUseOcclusion = occlude; | ||
7653 | LLPipeline::sShadowRender = FALSE; | ||
7654 | |||
7655 | |||
7656 | mRenderTypeMask = type_mask; | ||
7657 | |||
7658 | } | ||
7659 | |||
7660 | void LLPipeline::renderHighlight(const LLViewerObject* obj, F32 fade) | ||
6094 | { | 7661 | { |
7662 | if (!gSavedSettings.getBOOL("renderhighlights")) // KL need this to make the mouseover Highlights toggle ^^ | ||
7663 | { | ||
7664 | return; | ||
7665 | } | ||
7666 | |||
7667 | if (obj && obj->getVolume()) | ||
7668 | { | ||
7669 | for (LLViewerObject::child_list_t::const_iterator iter = obj->getChildren().begin(); iter != obj->getChildren().end(); ++iter) | ||
7670 | { | ||
7671 | renderHighlight(*iter, fade); | ||
7672 | } | ||
7673 | |||
7674 | LLDrawable* drawable = obj->mDrawable; | ||
7675 | if (drawable) | ||
7676 | { | ||
7677 | for (S32 i = 0; i < drawable->getNumFaces(); ++i) | ||
7678 | { | ||
7679 | LLFace* face = drawable->getFace(i); | ||
7680 | if (face) | ||
7681 | { | ||
7682 | face->renderSelected(LLViewerImage::sNullImagep, LLColor4(1,1,1,fade)); | ||
7683 | } | ||
7684 | } | ||
7685 | } | ||
7686 | } | ||
7687 | } | ||
6095 | 7688 | ||
7689 | void LLPipeline::generateHighlight(LLCamera& camera) | ||
7690 | { | ||
7691 | if (!gSavedSettings.getBOOL("renderhighlights")) // KL need this to make the mouseover Highlights toggle ^^ | ||
7692 | { | ||
7693 | return; | ||
7694 | } | ||
7695 | //render highlighted object as white into offscreen render target | ||
7696 | |||
7697 | if (mHighlightObject.notNull()) | ||
7698 | { | ||
7699 | mHighlightSet.insert(HighlightItem(mHighlightObject)); | ||
7700 | } | ||
7701 | |||
7702 | if (!mHighlightSet.empty()) | ||
7703 | { | ||
7704 | F32 transition = gFrameIntervalSeconds/gSavedSettings.getF32("RenderHighlightFadeTime"); | ||
7705 | |||
7706 | LLGLDisable test(GL_ALPHA_TEST); | ||
7707 | LLGLDepthTest depth(GL_FALSE); | ||
7708 | mHighlight.bindTarget(); | ||
7709 | disableLights(); | ||
7710 | gGL.setColorMask(true, true); | ||
7711 | mHighlight.clear(); | ||
7712 | |||
7713 | gGL.getTexUnit(0)->bind(LLViewerImage::sWhiteImagep); | ||
7714 | for (std::set<HighlightItem>::iterator iter = mHighlightSet.begin(); iter != mHighlightSet.end(); ) | ||
7715 | { | ||
7716 | std::set<HighlightItem>::iterator cur_iter = iter++; | ||
7717 | |||
7718 | if (cur_iter->mItem.isNull()) | ||
7719 | { | ||
7720 | mHighlightSet.erase(cur_iter); | ||
7721 | continue; | ||
7722 | } | ||
7723 | |||
7724 | if (cur_iter->mItem == mHighlightObject) | ||
7725 | { | ||
7726 | cur_iter->incrFade(transition); | ||
7727 | } | ||
7728 | else | ||
7729 | { | ||
7730 | cur_iter->incrFade(-transition); | ||
7731 | if (cur_iter->mFade <= 0.f) | ||
7732 | { | ||
7733 | mHighlightSet.erase(cur_iter); | ||
7734 | continue; | ||
7735 | } | ||
7736 | } | ||
7737 | |||
7738 | renderHighlight(cur_iter->mItem->getVObj(), cur_iter->mFade); | ||
7739 | } | ||
7740 | |||
7741 | mHighlight.flush(); | ||
7742 | gGL.setColorMask(true, false); | ||
7743 | gViewerWindow->setupViewport(); | ||
7744 | } | ||
7745 | } | ||
7746 | |||
7747 | |||
7748 | void LLPipeline::generateSunShadow(LLCamera& camera) | ||
7749 | { | ||
6096 | if (!sRenderDeferred) | 7750 | if (!sRenderDeferred) |
6097 | { | 7751 | { |
6098 | return; | 7752 | return; |
6099 | } | 7753 | } |
6100 | 7754 | ||
7755 | LLFastTimer ftm(LLFastTimer::FTM_TEMP1); | ||
7756 | |||
6101 | //temporary hack to disable shadows but keep local lights | 7757 | //temporary hack to disable shadows but keep local lights |
6102 | static BOOL clear = TRUE; | 7758 | static BOOL clear = TRUE; |
6103 | BOOL gen_shadow = gSavedSettings.getBOOL("RenderDeferredSunShadow"); | 7759 | BOOL gen_shadow = gSavedSettings.getBOOL("RenderDeferredSunShadow"); |
@@ -6106,98 +7762,162 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6106 | if (clear) | 7762 | if (clear) |
6107 | { | 7763 | { |
6108 | clear = FALSE; | 7764 | clear = FALSE; |
6109 | for (U32 i = 0; i < 4; i++) | 7765 | for (U32 i = 0; i < 6; i++) |
6110 | { | 7766 | { |
6111 | mSunShadow[i].bindTarget(); | 7767 | mShadow[i].bindTarget(); |
6112 | mSunShadow[i].clear(); | 7768 | mShadow[i].clear(); |
6113 | mSunShadow[i].flush(); | 7769 | mShadow[i].flush(); |
6114 | } | 7770 | } |
6115 | } | 7771 | } |
6116 | return; | 7772 | return; |
6117 | } | 7773 | } |
6118 | clear = TRUE; | 7774 | clear = TRUE; |
6119 | 7775 | ||
7776 | U32 type_mask = mRenderTypeMask; | ||
7777 | mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) | | ||
7778 | (1<<LLPipeline::RENDER_TYPE_ALPHA) | | ||
7779 | (1<<LLPipeline::RENDER_TYPE_GRASS) | | ||
7780 | (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) | | ||
7781 | (1<<LLPipeline::RENDER_TYPE_BUMP) | | ||
7782 | (1<<LLPipeline::RENDER_TYPE_VOLUME) | | ||
7783 | (1<<LLPipeline::RENDER_TYPE_AVATAR) | | ||
7784 | (1<<LLPipeline::RENDER_TYPE_TREE) | | ||
7785 | (1<<LLPipeline::RENDER_TYPE_TERRAIN) | | ||
7786 | (1<<LLPipeline::RENDER_TYPE_WATER) | | ||
7787 | (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) | | ||
7788 | (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) | | ||
7789 | (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) | | ||
7790 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) | | ||
7791 | (1 << LLPipeline::RENDER_TYPE_PASS_SHINY)); | ||
7792 | |||
6120 | gGL.setColorMask(false, false); | 7793 | gGL.setColorMask(false, false); |
6121 | 7794 | ||
6122 | //get sun view matrix | 7795 | //get sun view matrix |
6123 | 7796 | ||
6124 | F32 range = 128.f; | ||
6125 | |||
6126 | //store current projection/modelview matrix | 7797 | //store current projection/modelview matrix |
6127 | glh::matrix4f saved_proj = glh_get_current_projection(); | 7798 | glh::matrix4f saved_proj = glh_get_current_projection(); |
6128 | glh::matrix4f saved_view = glh_get_current_modelview(); | 7799 | glh::matrix4f saved_view = glh_get_current_modelview(); |
6129 | glh::matrix4f inv_view = saved_view.inverse(); | 7800 | glh::matrix4f inv_view = saved_view.inverse(); |
6130 | 7801 | ||
6131 | glh::matrix4f view[4]; | 7802 | glh::matrix4f view[6]; |
6132 | glh::matrix4f proj[4]; | 7803 | glh::matrix4f proj[6]; |
6133 | LLVector3 up; | 7804 | |
6134 | |||
6135 | //clip contains parallel split distances for 3 splits | 7805 | //clip contains parallel split distances for 3 splits |
6136 | LLVector3 clip = gSavedSettings.getVector3("RenderShadowClipPlanes"); | 7806 | LLVector3 clip = gSavedSettings.getVector3("RenderShadowClipPlanes"); |
6137 | 7807 | ||
7808 | //F32 slope_threshold = gSavedSettings.getF32("RenderShadowSlopeThreshold"); | ||
7809 | |||
6138 | //far clip on last split is minimum of camera view distance and 128 | 7810 | //far clip on last split is minimum of camera view distance and 128 |
6139 | mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]); | 7811 | mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]); |
6140 | 7812 | ||
6141 | const LLPickInfo& pick_info = gViewerWindow->getLastPick(); | 7813 | clip = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); |
6142 | 7814 | mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); | |
6143 | if (!pick_info.mPosGlobal.isExactlyZero()) | ||
6144 | { //squish nearest frustum based on alt-zoom (tighten up nearest frustum when focusing on tiny object | ||
6145 | F32 focus_dist = (F32) (pick_info.mPosGlobal + LLVector3d(pick_info.mObjectOffset) - gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin())).magVec(); | ||
6146 | mSunClipPlanes.mV[0] = llclamp(focus_dist*focus_dist, 2.f, mSunClipPlanes.mV[0]); | ||
6147 | } | ||
6148 | |||
6149 | // convenience array of 4 near clip plane distances | ||
6150 | F32 dist[] = { 0.1f, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; | ||
6151 | 7815 | ||
6152 | //currently used for amount to extrude frusta corners for constructing shadow frusta | 7816 | //currently used for amount to extrude frusta corners for constructing shadow frusta |
6153 | LLVector3 n = gSavedSettings.getVector3("RenderShadowNearDist"); | 7817 | LLVector3 n = gSavedSettings.getVector3("RenderShadowNearDist"); |
6154 | F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; | 7818 | //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; |
6155 | 7819 | ||
6156 | for (S32 j = 0; j < 4; j++) | 7820 | LLVector3 lightDir = -mSunDir; |
6157 | { | 7821 | lightDir.normVec(); |
6158 | //restore render matrices | ||
6159 | glh_set_current_modelview(saved_view); | ||
6160 | glh_set_current_projection(saved_proj); | ||
6161 | 7822 | ||
6162 | //get center of far clip plane (for point of interest later) | 7823 | glh::vec3f light_dir(lightDir.mV); |
6163 | LLVector3 center = camera.getOrigin() + camera.getAtAxis() * range; | ||
6164 | 7824 | ||
6165 | LLVector3 eye = camera.getOrigin(); | 7825 | //create light space camera matrix |
7826 | |||
7827 | LLVector3 at = lightDir; | ||
6166 | 7828 | ||
6167 | //camera used for shadow cull/render | 7829 | LLVector3 up = camera.getAtAxis(); |
6168 | LLCamera shadow_cam; | 7830 | |
6169 | 7831 | if (fabsf(up*lightDir) > 0.75f) | |
6170 | // perspective shadow map | 7832 | { |
6171 | glh::vec3f p[16]; //point cloud to be contained by shadow projection (light camera space) | 7833 | up = camera.getUpAxis(); |
6172 | glh::vec3f wp[16]; //point cloud to be contained by shadow projection (world space) | 7834 | } |
6173 | 7835 | ||
6174 | LLVector3 lightDir = -mSunDir; | 7836 | /*LLVector3 left = up%at; |
6175 | glh::vec3f light_dir(lightDir.mV); | 7837 | up = at%left;*/ |
7838 | |||
7839 | up.normVec(); | ||
7840 | at.normVec(); | ||
7841 | |||
7842 | |||
7843 | F32 near_clip = 0.f; | ||
7844 | { | ||
7845 | //get visible point cloud | ||
7846 | std::vector<LLVector3> fp; | ||
6176 | 7847 | ||
6177 | //create light space camera matrix | 7848 | LLVector3 min,max; |
6178 | LLVector3 at; | 7849 | getVisiblePointCloud(camera,min,max,fp); |
6179 | F32 dl = camera.getLeftAxis() * lightDir; | ||
6180 | F32 du = camera.getUpAxis() * lightDir; | ||
6181 | 7850 | ||
6182 | //choose an at axis such that up will be most aligned with lightDir | 7851 | if (fp.empty()) |
6183 | if (dl*dl < du*du) | ||
6184 | { | 7852 | { |
6185 | at = lightDir%camera.getLeftAxis(); | 7853 | mRenderTypeMask = type_mask; |
7854 | return; | ||
6186 | } | 7855 | } |
6187 | else | 7856 | |
7857 | generateGI(camera, lightDir, fp); | ||
7858 | |||
7859 | //get good split distances for frustum | ||
7860 | for (U32 i = 0; i < fp.size(); ++i) | ||
6188 | { | 7861 | { |
6189 | at = lightDir%camera.getUpAxis(); | 7862 | glh::vec3f v(fp[i].mV); |
7863 | saved_view.mult_matrix_vec(v); | ||
7864 | fp[i].setVec(v.v); | ||
6190 | } | 7865 | } |
6191 | 7866 | ||
6192 | if (at * camera.getAtAxis() < 0) | 7867 | min = fp[0]; |
7868 | max = fp[0]; | ||
7869 | |||
7870 | //get camera space bounding box | ||
7871 | for (U32 i = 1; i < fp.size(); ++i) | ||
6193 | { | 7872 | { |
6194 | at = -at; | 7873 | update_min_max(min, max, fp[i]); |
6195 | } | 7874 | } |
7875 | |||
7876 | near_clip = -max.mV[2]; | ||
7877 | F32 far_clip = -min.mV[2]*2.f; | ||
7878 | |||
7879 | far_clip = llmin(far_clip, 128.f); | ||
7880 | far_clip = llmin(far_clip, camera.getFar()); | ||
7881 | |||
7882 | F32 range = far_clip-near_clip; | ||
7883 | |||
7884 | LLVector3 split_exp = gSavedSettings.getVector3("RenderShadowSplitExponent"); | ||
7885 | |||
7886 | F32 da = 1.f-llmax( fabsf(lightDir*up), fabsf(lightDir*camera.getLeftAxis()) ); | ||
6196 | 7887 | ||
6197 | LLVector3 left = lightDir%at; | 7888 | da = powf(da, split_exp.mV[2]); |
6198 | up = left%lightDir; | 7889 | |
6199 | up.normVec(); | 7890 | |
7891 | F32 sxp = split_exp.mV[1] + (split_exp.mV[0]-split_exp.mV[1])*da; | ||
7892 | |||
7893 | |||
7894 | for (U32 i = 0; i < 4; ++i) | ||
7895 | { | ||
7896 | F32 x = (F32)(i+1)/4.f; | ||
7897 | x = powf(x, sxp); | ||
7898 | mSunClipPlanes.mV[i] = near_clip+range*x; | ||
7899 | } | ||
7900 | } | ||
7901 | |||
7902 | // convenience array of 4 near clip plane distances | ||
7903 | F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; | ||
7904 | |||
7905 | for (S32 j = 0; j < 4; j++) | ||
7906 | { | ||
7907 | if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) | ||
7908 | { | ||
7909 | mShadowFrustPoints[j].clear(); | ||
7910 | } | ||
7911 | |||
7912 | //restore render matrices | ||
7913 | glh_set_current_modelview(saved_view); | ||
7914 | glh_set_current_projection(saved_proj); | ||
6200 | 7915 | ||
7916 | LLVector3 eye = camera.getOrigin(); | ||
7917 | |||
7918 | //camera used for shadow cull/render | ||
7919 | LLCamera shadow_cam; | ||
7920 | |||
6201 | //create world space camera frustum for this split | 7921 | //create world space camera frustum for this split |
6202 | shadow_cam = camera; | 7922 | shadow_cam = camera; |
6203 | shadow_cam.setFar(16.f); | 7923 | shadow_cam.setFar(16.f); |
@@ -6208,8 +7928,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6208 | 7928 | ||
6209 | LLVector3 pn = shadow_cam.getAtAxis(); | 7929 | LLVector3 pn = shadow_cam.getAtAxis(); |
6210 | 7930 | ||
6211 | LLVector3 frust_center; | ||
6212 | |||
6213 | LLVector3 min, max; | 7931 | LLVector3 min, max; |
6214 | 7932 | ||
6215 | //construct 8 corners of split frustum section | 7933 | //construct 8 corners of split frustum section |
@@ -6220,21 +7938,19 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6220 | F32 dp = delta*pn; | 7938 | F32 dp = delta*pn; |
6221 | frust[i] = eye + (delta*dist[j])/dp; | 7939 | frust[i] = eye + (delta*dist[j])/dp; |
6222 | frust[i+4] = eye + (delta*dist[j+1])/dp; | 7940 | frust[i+4] = eye + (delta*dist[j+1])/dp; |
6223 | frust_center += frust[i] + frust[i+4]; | ||
6224 | } | 7941 | } |
6225 | |||
6226 | //get frustum center | ||
6227 | frust_center /= 8.f; | ||
6228 | 7942 | ||
6229 | shadow_cam.calcAgentFrustumPlanes(frust); | 7943 | shadow_cam.calcAgentFrustumPlanes(frust); |
6230 | 7944 | shadow_cam.mFrustumCornerDist = 0.f; | |
6231 | 7945 | ||
6232 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) | 7946 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) |
6233 | { | 7947 | { |
6234 | mShadowCamera[j] = shadow_cam; | 7948 | mShadowCamera[j] = shadow_cam; |
6235 | } | 7949 | } |
6236 | 7950 | ||
6237 | if (gPipeline.getVisibleExtents(shadow_cam, min, max)) | 7951 | std::vector<LLVector3> fp; |
7952 | |||
7953 | if (!gPipeline.getVisiblePointCloud(shadow_cam, min, max, fp, lightDir)) | ||
6238 | { | 7954 | { |
6239 | //no possible shadow receivers | 7955 | //no possible shadow receivers |
6240 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) | 7956 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) |
@@ -6244,6 +7960,16 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6244 | mShadowCamera[j+4] = shadow_cam; | 7960 | mShadowCamera[j+4] = shadow_cam; |
6245 | } | 7961 | } |
6246 | 7962 | ||
7963 | mShadow[j].bindTarget(); | ||
7964 | { | ||
7965 | LLGLDepthTest depth(GL_TRUE); | ||
7966 | mShadow[j].clear(); | ||
7967 | } | ||
7968 | mShadow[j].flush(); | ||
7969 | |||
7970 | mShadowError.mV[j] = 0.f; | ||
7971 | mShadowFOV.mV[j] = 0.f; | ||
7972 | |||
6247 | continue; | 7973 | continue; |
6248 | } | 7974 | } |
6249 | 7975 | ||
@@ -6251,42 +7977,252 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6251 | { | 7977 | { |
6252 | mShadowExtents[j][0] = min; | 7978 | mShadowExtents[j][0] = min; |
6253 | mShadowExtents[j][1] = max; | 7979 | mShadowExtents[j][1] = max; |
7980 | mShadowFrustPoints[j] = fp; | ||
6254 | } | 7981 | } |
6255 | 7982 | ||
6256 | view[j] = look(frust_center-lightDir*nearDist[j], lightDir, up); | ||
6257 | F32 shadow_dist = nearDist[j]; | ||
6258 | 7983 | ||
6259 | for (U32 i = 0; i < 8; i++) | 7984 | //find a good origin for shadow projection |
7985 | LLVector3 origin; | ||
7986 | |||
7987 | //get a temporary view projection | ||
7988 | view[j] = look(camera.getOrigin(), lightDir, -up); | ||
7989 | |||
7990 | std::vector<LLVector3> wpf; | ||
7991 | |||
7992 | for (U32 i = 0; i < fp.size(); i++) | ||
6260 | { | 7993 | { |
6261 | //points in worldspace (wp) and light camera space (p) | 7994 | glh::vec3f p = glh::vec3f(fp[i].mV); |
6262 | //that must be included in shadow generation | 7995 | view[j].mult_matrix_vec(p); |
6263 | wp[i] = glh::vec3f(frust[i].mV); | 7996 | wpf.push_back(LLVector3(p.v)); |
6264 | wp[i+8] = wp[i] - light_dir*shadow_dist; | ||
6265 | view[j].mult_matrix_vec(wp[i], p[i]); | ||
6266 | view[j].mult_matrix_vec(wp[i+8], p[i+8]); | ||
6267 | } | 7997 | } |
6268 | |||
6269 | min = LLVector3(p[0].v); | ||
6270 | max = LLVector3(p[0].v); | ||
6271 | 7998 | ||
6272 | LLVector3 fmin = min; | 7999 | min = wpf[0]; |
6273 | LLVector3 fmax = max; | 8000 | max = wpf[0]; |
6274 | 8001 | ||
6275 | for (U32 i = 1; i < 16; i++) | 8002 | for (U32 i = 0; i < fp.size(); ++i) |
6276 | { //find camera space AABB of frustum in light camera space | 8003 | { //get AABB in camera space |
6277 | update_min_max(min, max, LLVector3(p[i].v)); | 8004 | update_min_max(min, max, wpf[i]); |
6278 | if (i < 8) | 8005 | } |
6279 | { | 8006 | |
6280 | update_min_max(fmin, fmax, LLVector3(p[i].v)); | 8007 | // Construct a perspective transform with perspective along y-axis that contains |
8008 | // points in wpf | ||
8009 | //Known: | ||
8010 | // - far clip plane | ||
8011 | // - near clip plane | ||
8012 | // - points in frustum | ||
8013 | //Find: | ||
8014 | // - origin | ||
8015 | |||
8016 | //get some "interesting" points of reference | ||
8017 | LLVector3 center = (min+max)*0.5f; | ||
8018 | LLVector3 size = (max-min)*0.5f; | ||
8019 | LLVector3 near_center = center; | ||
8020 | near_center.mV[1] += size.mV[1]*2.f; | ||
8021 | |||
8022 | |||
8023 | //put all points in wpf in quadrant 0, reletive to center of min/max | ||
8024 | //get the best fit line using least squares | ||
8025 | F32 bfm = 0.f; | ||
8026 | F32 bfb = 0.f; | ||
8027 | |||
8028 | for (U32 i = 0; i < wpf.size(); ++i) | ||
8029 | { | ||
8030 | wpf[i] -= center; | ||
8031 | wpf[i].mV[0] = fabsf(wpf[i].mV[0]); | ||
8032 | wpf[i].mV[2] = fabsf(wpf[i].mV[2]); | ||
8033 | } | ||
8034 | |||
8035 | if (!wpf.empty()) | ||
8036 | { | ||
8037 | F32 sx = 0.f; | ||
8038 | F32 sx2 = 0.f; | ||
8039 | F32 sy = 0.f; | ||
8040 | F32 sxy = 0.f; | ||
8041 | |||
8042 | for (U32 i = 0; i < wpf.size(); ++i) | ||
8043 | { | ||
8044 | sx += wpf[i].mV[0]; | ||
8045 | sx2 += wpf[i].mV[0]*wpf[i].mV[0]; | ||
8046 | sy += wpf[i].mV[1]; | ||
8047 | sxy += wpf[i].mV[0]*wpf[i].mV[1]; | ||
6281 | } | 8048 | } |
8049 | |||
8050 | bfm = (sy*sx-wpf.size()*sxy)/(sx*sx-wpf.size()*sx2); | ||
8051 | bfb = (sx*sxy-sy*sx2)/(sx*sx-bfm*sx2); | ||
6282 | } | 8052 | } |
8053 | |||
8054 | { | ||
8055 | // best fit line is y=bfm*x+bfb | ||
8056 | |||
8057 | //find point that is furthest to the right of line | ||
8058 | F32 off_x = -1.f; | ||
8059 | LLVector3 lp; | ||
8060 | |||
8061 | for (U32 i = 0; i < wpf.size(); ++i) | ||
8062 | { | ||
8063 | //y = bfm*x+bfb | ||
8064 | //x = (y-bfb)/bfm | ||
8065 | F32 lx = (wpf[i].mV[1]-bfb)/bfm; | ||
8066 | |||
8067 | lx = wpf[i].mV[0]-lx; | ||
8068 | |||
8069 | if (off_x < lx) | ||
8070 | { | ||
8071 | off_x = lx; | ||
8072 | lp = wpf[i]; | ||
8073 | } | ||
8074 | } | ||
8075 | |||
8076 | //get line with slope bfm through lp | ||
8077 | // bfb = y-bfm*x | ||
8078 | bfb = lp.mV[1]-bfm*lp.mV[0]; | ||
8079 | |||
8080 | //calculate error | ||
8081 | mShadowError.mV[j] = 0.f; | ||
8082 | |||
8083 | for (U32 i = 0; i < wpf.size(); ++i) | ||
8084 | { | ||
8085 | F32 lx = (wpf[i].mV[1]-bfb)/bfm; | ||
8086 | mShadowError.mV[j] += fabsf(wpf[i].mV[0]-lx); | ||
8087 | } | ||
8088 | |||
8089 | mShadowError.mV[j] /= wpf.size(); | ||
8090 | mShadowError.mV[j] /= size.mV[0]; | ||
8091 | |||
8092 | if (mShadowError.mV[j] > gSavedSettings.getF32("RenderShadowErrorCutoff")) | ||
8093 | { //just use ortho projection | ||
8094 | mShadowFOV.mV[j] = -1.f; | ||
8095 | origin.clearVec(); | ||
8096 | proj[j] = gl_ortho(min.mV[0], max.mV[0], | ||
8097 | min.mV[1], max.mV[1], | ||
8098 | -max.mV[2], -min.mV[2]); | ||
8099 | } | ||
8100 | else | ||
8101 | { | ||
8102 | //origin is where line x = 0; | ||
8103 | origin.setVec(0,bfb,0); | ||
8104 | |||
8105 | F32 fovz = 1.f; | ||
8106 | F32 fovx = 1.f; | ||
8107 | |||
8108 | LLVector3 zp; | ||
8109 | LLVector3 xp; | ||
8110 | |||
8111 | for (U32 i = 0; i < wpf.size(); ++i) | ||
8112 | { | ||
8113 | LLVector3 atz = wpf[i]-origin; | ||
8114 | atz.mV[0] = 0.f; | ||
8115 | atz.normVec(); | ||
8116 | if (fovz > -atz.mV[1]) | ||
8117 | { | ||
8118 | zp = wpf[i]; | ||
8119 | fovz = -atz.mV[1]; | ||
8120 | } | ||
8121 | |||
8122 | LLVector3 atx = wpf[i]-origin; | ||
8123 | atx.mV[2] = 0.f; | ||
8124 | atx.normVec(); | ||
8125 | if (fovx > -atx.mV[1]) | ||
8126 | { | ||
8127 | fovx = -atx.mV[1]; | ||
8128 | xp = wpf[i]; | ||
8129 | } | ||
8130 | } | ||
8131 | |||
8132 | fovx = acos(fovx); | ||
8133 | fovz = acos(fovz); | ||
8134 | |||
8135 | F32 cutoff = llmin(gSavedSettings.getF32("RenderShadowFOVCutoff"), 1.4f); | ||
8136 | |||
8137 | mShadowFOV.mV[j] = fovx; | ||
8138 | |||
8139 | if (fovx < cutoff && fovz > cutoff) | ||
8140 | { | ||
8141 | //x is a good fit, but z is too big, move away from zp enough so that fovz matches cutoff | ||
8142 | F32 d = zp.mV[2]/tan(cutoff); | ||
8143 | F32 ny = zp.mV[1] + fabsf(d); | ||
8144 | |||
8145 | origin.mV[1] = ny; | ||
8146 | |||
8147 | fovz = 1.f; | ||
8148 | fovx = 1.f; | ||
8149 | |||
8150 | for (U32 i = 0; i < wpf.size(); ++i) | ||
8151 | { | ||
8152 | LLVector3 atz = wpf[i]-origin; | ||
8153 | atz.mV[0] = 0.f; | ||
8154 | atz.normVec(); | ||
8155 | fovz = llmin(fovz, -atz.mV[1]); | ||
8156 | |||
8157 | LLVector3 atx = wpf[i]-origin; | ||
8158 | atx.mV[2] = 0.f; | ||
8159 | atx.normVec(); | ||
8160 | fovx = llmin(fovx, -atx.mV[1]); | ||
8161 | } | ||
6283 | 8162 | ||
6284 | //generate perspective matrix that contains frustum | 8163 | fovx = acos(fovx); |
6285 | //proj[j] = matrix_perspective(min, max); | 8164 | fovz = acos(fovz); |
6286 | proj[j] = gl_ortho(min.mV[0], max.mV[0], | 8165 | |
8166 | if (fovx > cutoff || llround(fovz, 0.01f) > cutoff) | ||
8167 | { | ||
8168 | // llwarns << "WTF?" << llendl; | ||
8169 | } | ||
8170 | |||
8171 | mShadowFOV.mV[j] = cutoff; | ||
8172 | } | ||
8173 | |||
8174 | |||
8175 | origin += center; | ||
8176 | |||
8177 | F32 ynear = -(max.mV[1]-origin.mV[1]); | ||
8178 | F32 yfar = -(min.mV[1]-origin.mV[1]); | ||
8179 | |||
8180 | if (ynear < 0.1f) //keep a sensible near clip plane | ||
8181 | { | ||
8182 | F32 diff = 0.1f-ynear; | ||
8183 | origin.mV[1] += diff; | ||
8184 | ynear += diff; | ||
8185 | yfar += diff; | ||
8186 | } | ||
8187 | |||
8188 | if (fovx > cutoff) | ||
8189 | { //just use ortho projection | ||
8190 | origin.clearVec(); | ||
8191 | mShadowError.mV[j] = -1.f; | ||
8192 | proj[j] = gl_ortho(min.mV[0], max.mV[0], | ||
6287 | min.mV[1], max.mV[1], | 8193 | min.mV[1], max.mV[1], |
6288 | -max.mV[2], -min.mV[2]); | 8194 | -max.mV[2], -min.mV[2]); |
6289 | 8195 | } | |
8196 | else | ||
8197 | { | ||
8198 | //get perspective projection | ||
8199 | view[j] = view[j].inverse(); | ||
8200 | |||
8201 | glh::vec3f origin_agent(origin.mV); | ||
8202 | |||
8203 | //translate view to origin | ||
8204 | view[j].mult_matrix_vec(origin_agent); | ||
8205 | |||
8206 | eye = LLVector3(origin_agent.v); | ||
8207 | |||
8208 | if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) | ||
8209 | { | ||
8210 | mShadowFrustOrigin[j] = eye; | ||
8211 | } | ||
8212 | |||
8213 | view[j] = look(LLVector3(origin_agent.v), lightDir, -up); | ||
8214 | |||
8215 | F32 fx = 1.f/tanf(fovx); | ||
8216 | F32 fz = 1.f/tanf(fovz); | ||
8217 | |||
8218 | proj[j] = glh::matrix4f(-fx, 0, 0, 0, | ||
8219 | 0, (yfar+ynear)/(ynear-yfar), 0, (2.f*yfar*ynear)/(ynear-yfar), | ||
8220 | 0, 0, -fz, 0, | ||
8221 | 0, -1.f, 0, 0); | ||
8222 | } | ||
8223 | } | ||
8224 | } | ||
8225 | |||
6290 | shadow_cam.setFar(128.f); | 8226 | shadow_cam.setFar(128.f); |
6291 | shadow_cam.setOriginAndLookAt(eye, up, center); | 8227 | shadow_cam.setOriginAndLookAt(eye, up, center); |
6292 | 8228 | ||
@@ -6295,9 +8231,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6295 | 8231 | ||
6296 | LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); | 8232 | LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); |
6297 | 8233 | ||
6298 | proj[j] = gl_ortho(fmin.mV[0], fmax.mV[0], | 8234 | shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR); |
6299 | fmin.mV[1], fmax.mV[1], | ||
6300 | -fmax.mV[2], -fmin.mV[2]); | ||
6301 | 8235 | ||
6302 | //translate and scale to from [-1, 1] to [0, 1] | 8236 | //translate and scale to from [-1, 1] to [0, 1] |
6303 | glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, | 8237 | glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, |
@@ -6310,111 +8244,155 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6310 | 8244 | ||
6311 | mSunShadowMatrix[j] = trans*proj[j]*view[j]*inv_view; | 8245 | mSunShadowMatrix[j] = trans*proj[j]*view[j]*inv_view; |
6312 | 8246 | ||
6313 | U32 type_mask = mRenderTypeMask; | ||
6314 | mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) | | ||
6315 | (1<<LLPipeline::RENDER_TYPE_ALPHA) | | ||
6316 | (1<<LLPipeline::RENDER_TYPE_GRASS) | | ||
6317 | (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) | | ||
6318 | (1<<LLPipeline::RENDER_TYPE_BUMP) | | ||
6319 | (1<<LLPipeline::RENDER_TYPE_VOLUME) | | ||
6320 | (1<<LLPipeline::RENDER_TYPE_AVATAR) | | ||
6321 | (1<<LLPipeline::RENDER_TYPE_TREE) | | ||
6322 | (1<<LLPipeline::RENDER_TYPE_TERRAIN) | | ||
6323 | 0); | ||
6324 | |||
6325 | //clip out geometry on the same side of water as the camera | ||
6326 | static LLCullResult result; | ||
6327 | S32 occlude = LLPipeline::sUseOcclusion; | ||
6328 | LLPipeline::sUseOcclusion = 1; | ||
6329 | LLPipeline::sShadowRender = TRUE; | ||
6330 | //hack to prevent LOD updates from using sun camera origin | 8247 | //hack to prevent LOD updates from using sun camera origin |
6331 | shadow_cam.setOrigin(camera.getOrigin()); | 8248 | shadow_cam.setOrigin(camera.getOrigin()); |
6332 | updateCull(shadow_cam, result); | ||
6333 | stateSort(shadow_cam, result); | ||
6334 | |||
6335 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) | ||
6336 | { | ||
6337 | LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); | ||
6338 | mShadowCamera[j+4] = shadow_cam; | ||
6339 | } | ||
6340 | |||
6341 | LLFastTimer t(LLFastTimer::FTM_SHADOW_RENDER); | ||
6342 | 8249 | ||
6343 | stop_glerror(); | 8250 | stop_glerror(); |
6344 | 8251 | ||
6345 | mSunShadow[j].bindTarget(); | 8252 | mShadow[j].bindTarget(); |
6346 | mSunShadow[j].getViewport(gGLViewport); | 8253 | mShadow[j].getViewport(gGLViewport); |
6347 | 8254 | ||
6348 | { | 8255 | { |
6349 | LLGLDepthTest depth(GL_TRUE); | 8256 | LLGLDepthTest depth(GL_TRUE); |
6350 | mSunShadow[j].clear(); | 8257 | mShadow[j].clear(); |
6351 | } | 8258 | } |
6352 | 8259 | ||
6353 | U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_FULLBRIGHT, LLRenderPass::PASS_SHINY, LLRenderPass::PASS_BUMP }; | 8260 | { |
6354 | LLGLEnable cull(GL_CULL_FACE); | 8261 | LLGLEnable enable(GL_DEPTH_CLAMP_NV); |
8262 | renderShadow(view[j], proj[j], shadow_cam, FALSE); | ||
8263 | } | ||
6355 | 8264 | ||
6356 | //generate sun shadow map | 8265 | mShadow[j].flush(); |
6357 | glMatrixMode(GL_PROJECTION); | 8266 | |
6358 | glPushMatrix(); | 8267 | if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) |
6359 | glLoadMatrixf(proj[j].m); | 8268 | { |
6360 | glMatrixMode(GL_MODELVIEW); | 8269 | LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); |
6361 | glPushMatrix(); | 8270 | mShadowCamera[j+4] = shadow_cam; |
6362 | glLoadMatrixf(view[j].m); | 8271 | } |
8272 | } | ||
6363 | 8273 | ||
6364 | stop_glerror(); | 8274 | //llinfos << "Shadow error: " << error << " Slope: " << best_fit_slope << llendl; |
6365 | gGLLastMatrix = NULL; | 8275 | |
6366 | 8276 | ||
6367 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | 8277 | F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f); |
6368 | |||
6369 | glColor4f(1,1,1,1); | ||
6370 | |||
6371 | glCullFace(GL_FRONT); | ||
6372 | 8278 | ||
6373 | stop_glerror(); | 8279 | //update shadow targets |
8280 | for (U32 i = 0; i < 2; i++) | ||
8281 | { //for each current shadow | ||
8282 | if (mShadowSpotLight[i].notNull() && | ||
8283 | (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || | ||
8284 | mShadowSpotLight[i] == mTargetShadowSpotLight[1])) | ||
8285 | { //keep this spotlight | ||
8286 | mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); | ||
8287 | } | ||
8288 | else | ||
8289 | { //fade out this light | ||
8290 | mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); | ||
8291 | |||
8292 | if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) | ||
8293 | { //faded out, grab one of the pending spots (whichever one isn't already taken) | ||
8294 | if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) | ||
8295 | { | ||
8296 | mShadowSpotLight[i] = mTargetShadowSpotLight[0]; | ||
8297 | } | ||
8298 | else | ||
8299 | { | ||
8300 | mShadowSpotLight[i] = mTargetShadowSpotLight[1]; | ||
8301 | } | ||
8302 | } | ||
8303 | } | ||
8304 | } | ||
6374 | 8305 | ||
6375 | gGL.setColorMask(false, false); | 8306 | for (S32 i = 0; i < 2; i++) |
8307 | { | ||
8308 | glh_set_current_modelview(saved_view); | ||
8309 | glh_set_current_projection(saved_proj); | ||
6376 | 8310 | ||
6377 | gDeferredShadowProgram.bind(); | 8311 | if (mShadowSpotLight[i].isNull()) |
6378 | { | 8312 | { |
6379 | LLFastTimer ftm(LLFastTimer::FTM_SHADOW_SIMPLE); | 8313 | continue; |
6380 | LLGLDisable test(GL_ALPHA_TEST); | ||
6381 | gGL.getTexUnit(0)->disable(); | ||
6382 | for (U32 i = 0; i < sizeof(types)/sizeof(U32); ++i) | ||
6383 | { | ||
6384 | renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); | ||
6385 | } | ||
6386 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); | ||
6387 | } | 8314 | } |
6388 | 8315 | ||
8316 | LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); | ||
8317 | |||
8318 | if (!volume) | ||
6389 | { | 8319 | { |
6390 | LLFastTimer ftm(LLFastTimer::FTM_SHADOW_ALPHA); | 8320 | mShadowSpotLight[i] = NULL; |
6391 | LLGLEnable test(GL_ALPHA_TEST); | 8321 | continue; |
6392 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.6f); | ||
6393 | renderObjects(LLRenderPass::PASS_ALPHA_SHADOW, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR, TRUE); | ||
6394 | glColor4f(1,1,1,1); | ||
6395 | renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); | ||
6396 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | ||
6397 | } | 8322 | } |
8323 | |||
8324 | LLDrawable* drawable = mShadowSpotLight[i]; | ||
8325 | |||
8326 | LLVector3 params = volume->getSpotLightParams(); | ||
8327 | F32 fov = params.mV[0]; | ||
8328 | |||
8329 | //get agent->light space matrix (modelview) | ||
8330 | LLVector3 center = drawable->getPositionAgent(); | ||
8331 | LLQuaternion quat = volume->getRenderRotation(); | ||
8332 | |||
8333 | //get near clip plane | ||
8334 | LLVector3 scale = volume->getScale(); | ||
8335 | LLVector3 at_axis(0,0,-scale.mV[2]*0.5f); | ||
8336 | at_axis *= quat; | ||
8337 | |||
8338 | LLVector3 np = center+at_axis; | ||
8339 | at_axis.normVec(); | ||
8340 | |||
8341 | //get origin that has given fov for plane np, at_axis, and given scale | ||
8342 | F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f); | ||
8343 | |||
8344 | LLVector3 origin = np - at_axis*dist; | ||
8345 | |||
8346 | LLMatrix4 mat(quat, LLVector4(origin, 1.f)); | ||
8347 | |||
8348 | view[i+4] = glh::matrix4f((F32*) mat.mMatrix); | ||
8349 | |||
8350 | view[i+4] = view[i+4].inverse(); | ||
8351 | |||
8352 | //get perspective matrix | ||
8353 | F32 near_clip = dist+0.01f; | ||
8354 | F32 width = scale.mV[VX]; | ||
8355 | F32 height = scale.mV[VY]; | ||
8356 | F32 far_clip = dist+volume->getLightRadius()*1.5f; | ||
8357 | |||
8358 | F32 fovy = fov * RAD_TO_DEG; | ||
8359 | F32 aspect = width/height; | ||
6398 | 8360 | ||
6399 | gDeferredShadowProgram.unbind(); | 8361 | proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip); |
6400 | 8362 | ||
6401 | renderGeomShadow(shadow_cam); | 8363 | //translate and scale to from [-1, 1] to [0, 1] |
8364 | glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, | ||
8365 | 0.f, 0.5f, 0.f, 0.5f, | ||
8366 | 0.f, 0.f, 0.5f, 0.5f, | ||
8367 | 0.f, 0.f, 0.f, 1.f); | ||
6402 | 8368 | ||
6403 | gGL.setColorMask(true, true); | 8369 | glh_set_current_modelview(view[i+4]); |
8370 | glh_set_current_projection(proj[i+4]); | ||
6404 | 8371 | ||
6405 | glCullFace(GL_BACK); | 8372 | mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view; |
6406 | LLPipeline::sUseOcclusion = occlude; | ||
6407 | LLPipeline::sShadowRender = FALSE; | ||
6408 | mRenderTypeMask = type_mask; | ||
6409 | 8373 | ||
6410 | glMatrixMode(GL_PROJECTION); | 8374 | LLCamera shadow_cam = camera; |
6411 | glPopMatrix(); | 8375 | shadow_cam.setFar(far_clip); |
6412 | glMatrixMode(GL_MODELVIEW); | 8376 | shadow_cam.setOrigin(origin); |
6413 | glPopMatrix(); | ||
6414 | gGLLastMatrix = NULL; | ||
6415 | 8377 | ||
6416 | mSunShadow[j].flush(); | 8378 | LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); |
6417 | } | 8379 | |
8380 | shadow_cam.setOrigin(camera.getOrigin()); | ||
8381 | |||
8382 | stop_glerror(); | ||
8383 | |||
8384 | mShadow[i+4].bindTarget(); | ||
8385 | mShadow[i+4].getViewport(gGLViewport); | ||
8386 | |||
8387 | { | ||
8388 | LLGLDepthTest depth(GL_TRUE); | ||
8389 | mShadow[i+4].clear(); | ||
8390 | } | ||
8391 | |||
8392 | renderShadow(view[i+4], proj[i+4], shadow_cam, FALSE); | ||
8393 | |||
8394 | mShadow[i+4].flush(); | ||
8395 | } | ||
6418 | 8396 | ||
6419 | if (!gSavedSettings.getBOOL("CameraOffset")) | 8397 | if (!gSavedSettings.getBOOL("CameraOffset")) |
6420 | { | 8398 | { |
@@ -6431,6 +8409,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) | |||
6431 | glMatrixMode(GL_MODELVIEW); | 8409 | glMatrixMode(GL_MODELVIEW); |
6432 | } | 8410 | } |
6433 | gGL.setColorMask(true, false); | 8411 | gGL.setColorMask(true, false); |
8412 | |||
8413 | mRenderTypeMask = type_mask; | ||
6434 | } | 8414 | } |
6435 | 8415 | ||
6436 | void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture) | 8416 | void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture) |
@@ -6470,7 +8450,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
6470 | 8450 | ||
6471 | if (muted) | 8451 | if (muted) |
6472 | { | 8452 | { |
6473 | mask = 1 << LLPipeline::RENDER_TYPE_AVATAR; | 8453 | mask = 1 << LLPipeline::RENDER_TYPE_INVISIBLE; // Peachy ;) |
6474 | } | 8454 | } |
6475 | else | 8455 | else |
6476 | { | 8456 | { |
@@ -6481,7 +8461,16 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
6481 | (1<<LLPipeline::RENDER_TYPE_SIMPLE) | | 8461 | (1<<LLPipeline::RENDER_TYPE_SIMPLE) | |
6482 | (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) | | 8462 | (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) | |
6483 | (1<<LLPipeline::RENDER_TYPE_ALPHA) | | 8463 | (1<<LLPipeline::RENDER_TYPE_ALPHA) | |
6484 | (1<<LLPipeline::RENDER_TYPE_INVISIBLE); | 8464 | (1<<LLPipeline::RENDER_TYPE_INVISIBLE) | |
8465 | (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) | | ||
8466 | (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) | | ||
8467 | (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) | | ||
8468 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) | | ||
8469 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) | | ||
8470 | (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) | | ||
8471 | (1 << LLPipeline::RENDER_TYPE_PASS_SHINY) | | ||
8472 | (1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) | | ||
8473 | (1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY); | ||
6485 | } | 8474 | } |
6486 | 8475 | ||
6487 | mask = mask & gPipeline.getRenderTypeMask(); | 8476 | mask = mask & gPipeline.getRenderTypeMask(); |
@@ -6491,6 +8480,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
6491 | S32 occlusion = sUseOcclusion; | 8480 | S32 occlusion = sUseOcclusion; |
6492 | sUseOcclusion = 0; | 8481 | sUseOcclusion = 0; |
6493 | sReflectionRender = sRenderDeferred ? FALSE : TRUE; | 8482 | sReflectionRender = sRenderDeferred ? FALSE : TRUE; |
8483 | sShadowRender = TRUE; | ||
6494 | sImpostorRender = TRUE; | 8484 | sImpostorRender = TRUE; |
6495 | 8485 | ||
6496 | markVisible(avatar->mDrawable, *LLViewerCamera::getInstance()); | 8486 | markVisible(avatar->mDrawable, *LLViewerCamera::getInstance()); |
@@ -6570,7 +8560,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
6570 | if (LLPipeline::sRenderDeferred) | 8560 | if (LLPipeline::sRenderDeferred) |
6571 | { | 8561 | { |
6572 | avatar->mImpostor.allocate(resX,resY,GL_RGBA16F_ARB,TRUE,TRUE); | 8562 | avatar->mImpostor.allocate(resX,resY,GL_RGBA16F_ARB,TRUE,TRUE); |
6573 | addDeferredAttachments(avatar->mImpostor); | 8563 | //addDeferredAttachments(avatar->mImpostor); |
6574 | } | 8564 | } |
6575 | else | 8565 | else |
6576 | { | 8566 | { |
@@ -6649,6 +8639,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
6649 | sUseOcclusion = occlusion; | 8639 | sUseOcclusion = occlusion; |
6650 | sReflectionRender = FALSE; | 8640 | sReflectionRender = FALSE; |
6651 | sImpostorRender = FALSE; | 8641 | sImpostorRender = FALSE; |
8642 | sShadowRender = FALSE; | ||
6652 | gPipeline.mRenderTypeMask = saved_mask; | 8643 | gPipeline.mRenderTypeMask = saved_mask; |
6653 | 8644 | ||
6654 | glMatrixMode(GL_PROJECTION); | 8645 | glMatrixMode(GL_PROJECTION); |
diff --git a/linden/indra/newview/pipeline.h b/linden/indra/newview/pipeline.h index 1a32b30..a85877d 100644 --- a/linden/indra/newview/pipeline.h +++ b/linden/indra/newview/pipeline.h | |||
@@ -129,6 +129,8 @@ public: | |||
129 | void markMoved(LLDrawable *drawablep, BOOL damped_motion = FALSE); | 129 | void markMoved(LLDrawable *drawablep, BOOL damped_motion = FALSE); |
130 | void markShift(LLDrawable *drawablep); | 130 | void markShift(LLDrawable *drawablep); |
131 | void markTextured(LLDrawable *drawablep); | 131 | void markTextured(LLDrawable *drawablep); |
132 | void markGLRebuild(LLGLUpdate* glu); | ||
133 | void markRebuild(LLSpatialGroup* group, BOOL priority = FALSE); | ||
132 | void markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL, BOOL priority = FALSE); | 134 | void markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL, BOOL priority = FALSE); |
133 | 135 | ||
134 | //get the object between start and end that's closest to start. | 136 | //get the object between start and end that's closest to start. |
@@ -179,10 +181,14 @@ public: | |||
179 | void updateMove(); | 181 | void updateMove(); |
180 | BOOL visibleObjectsInFrustum(LLCamera& camera); | 182 | BOOL visibleObjectsInFrustum(LLCamera& camera); |
181 | BOOL getVisibleExtents(LLCamera& camera, LLVector3 &min, LLVector3& max); | 183 | BOOL getVisibleExtents(LLCamera& camera, LLVector3 &min, LLVector3& max); |
184 | BOOL getVisiblePointCloud(LLCamera& camera, LLVector3 &min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir = LLVector3(0,0,0)); | ||
182 | void updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip = 0); //if water_clip is 0, ignore water plane, 1, cull to above plane, -1, cull to below plane | 185 | void updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip = 0); //if water_clip is 0, ignore water plane, 1, cull to above plane, -1, cull to below plane |
183 | void createObjects(F32 max_dtime); | 186 | void createObjects(F32 max_dtime); |
184 | void createObject(LLViewerObject* vobj); | 187 | void createObject(LLViewerObject* vobj); |
185 | void updateGeom(F32 max_dtime); | 188 | void updateGeom(F32 max_dtime); |
189 | void updateGL(); | ||
190 | void rebuildPriorityGroups(); | ||
191 | void rebuildGroups(); | ||
186 | 192 | ||
187 | //calculate pixel area of given box from vantage point of given camera | 193 | //calculate pixel area of given box from vantage point of given camera |
188 | static F32 calcPixelArea(LLVector3 center, LLVector3 size, LLCamera& camera); | 194 | static F32 calcPixelArea(LLVector3 center, LLVector3 size, LLCamera& camera); |
@@ -203,12 +209,21 @@ public: | |||
203 | void renderGeomDeferred(LLCamera& camera); | 209 | void renderGeomDeferred(LLCamera& camera); |
204 | void renderGeomPostDeferred(LLCamera& camera); | 210 | void renderGeomPostDeferred(LLCamera& camera); |
205 | void renderGeomShadow(LLCamera& camera); | 211 | void renderGeomShadow(LLCamera& camera); |
206 | void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0); | 212 | void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, LLRenderTarget* gi_source = NULL, LLRenderTarget* last_gi_post = NULL); |
213 | void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep); | ||
214 | |||
207 | void unbindDeferredShader(LLGLSLShader& shader); | 215 | void unbindDeferredShader(LLGLSLShader& shader); |
208 | void renderDeferredLighting(); | 216 | void renderDeferredLighting(); |
209 | 217 | ||
210 | void generateWaterReflection(LLCamera& camera); | 218 | void generateWaterReflection(LLCamera& camera); |
211 | void generateSunShadow(LLCamera& camera); | 219 | void generateSunShadow(LLCamera& camera); |
220 | void generateHighlight(LLCamera& camera); | ||
221 | void renderHighlight(const LLViewerObject* obj, F32 fade); | ||
222 | void setHighlightObject(LLDrawable* obj) { mHighlightObject = obj; } | ||
223 | |||
224 | |||
225 | void renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& camera, BOOL use_shader = TRUE); | ||
226 | void generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<LLVector3>& vpc); // KL sd | ||
212 | void renderHighlights(); | 227 | void renderHighlights(); |
213 | void renderDebug(); | 228 | void renderDebug(); |
214 | 229 | ||
@@ -303,27 +318,39 @@ public: | |||
303 | enum LLRenderTypeMask | 318 | enum LLRenderTypeMask |
304 | { | 319 | { |
305 | // Following are pool types (some are also object types) | 320 | // Following are pool types (some are also object types) |
306 | RENDER_TYPE_SKY = LLDrawPool::POOL_SKY, | 321 | RENDER_TYPE_SKY = LLDrawPool::POOL_SKY, |
307 | RENDER_TYPE_WL_SKY = LLDrawPool::POOL_WL_SKY, | 322 | RENDER_TYPE_WL_SKY = LLDrawPool::POOL_WL_SKY, |
308 | RENDER_TYPE_GROUND = LLDrawPool::POOL_GROUND, | 323 | RENDER_TYPE_GROUND = LLDrawPool::POOL_GROUND, |
309 | RENDER_TYPE_TERRAIN = LLDrawPool::POOL_TERRAIN, | 324 | RENDER_TYPE_TERRAIN = LLDrawPool::POOL_TERRAIN, |
310 | RENDER_TYPE_SIMPLE = LLDrawPool::POOL_SIMPLE, | 325 | RENDER_TYPE_SIMPLE = LLDrawPool::POOL_SIMPLE, |
311 | RENDER_TYPE_GRASS = LLDrawPool::POOL_GRASS, | 326 | RENDER_TYPE_GRASS = LLDrawPool::POOL_GRASS, |
312 | RENDER_TYPE_FULLBRIGHT = LLDrawPool::POOL_FULLBRIGHT, | 327 | RENDER_TYPE_FULLBRIGHT = LLDrawPool::POOL_FULLBRIGHT, |
313 | RENDER_TYPE_BUMP = LLDrawPool::POOL_BUMP, | 328 | RENDER_TYPE_BUMP = LLDrawPool::POOL_BUMP, |
314 | RENDER_TYPE_AVATAR = LLDrawPool::POOL_AVATAR, | 329 | RENDER_TYPE_AVATAR = LLDrawPool::POOL_AVATAR, |
315 | RENDER_TYPE_TREE = LLDrawPool::POOL_TREE, | 330 | RENDER_TYPE_TREE = LLDrawPool::POOL_TREE, |
316 | RENDER_TYPE_INVISIBLE = LLDrawPool::POOL_INVISIBLE, | 331 | RENDER_TYPE_INVISIBLE = LLDrawPool::POOL_INVISIBLE, |
317 | RENDER_TYPE_WATER = LLDrawPool::POOL_WATER, | 332 | RENDER_TYPE_WATER = LLDrawPool::POOL_WATER, |
318 | RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA, | 333 | RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA, |
319 | RENDER_TYPE_GLOW = LLDrawPool::POOL_GLOW, | 334 | RENDER_TYPE_GLOW = LLDrawPool::POOL_GLOW, |
320 | 335 | RENDER_TYPE_PASS_SIMPLE = LLRenderPass::PASS_SIMPLE, | |
336 | RENDER_TYPE_PASS_GRASS = LLRenderPass::PASS_GRASS, | ||
337 | RENDER_TYPE_PASS_FULLBRIGHT = LLRenderPass::PASS_FULLBRIGHT, | ||
338 | RENDER_TYPE_PASS_INVISIBLE = LLRenderPass::PASS_INVISIBLE, | ||
339 | RENDER_TYPE_PASS_INVISI_SHINY = LLRenderPass::PASS_INVISI_SHINY, | ||
340 | RENDER_TYPE_PASS_FULLBRIGHT_SHINY = LLRenderPass::PASS_FULLBRIGHT_SHINY, | ||
341 | RENDER_TYPE_PASS_SHINY = LLRenderPass::PASS_SHINY, | ||
342 | RENDER_TYPE_PASS_BUMP = LLRenderPass::PASS_BUMP, | ||
343 | RENDER_TYPE_PASS_GLOW = LLRenderPass::PASS_GLOW, | ||
344 | RENDER_TYPE_PASS_ALPHA = LLRenderPass::PASS_ALPHA, | ||
345 | RENDER_TYPE_PASS_ALPHA_MASK = LLRenderPass::PASS_ALPHA_MASK, | ||
346 | RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK = LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, | ||
347 | RENDER_TYPE_PASS_ALPHA_SHADOW = LLRenderPass::PASS_ALPHA_SHADOW, | ||
321 | // Following are object types (only used in drawable mRenderType) | 348 | // Following are object types (only used in drawable mRenderType) |
322 | RENDER_TYPE_HUD = LLDrawPool::NUM_POOL_TYPES, | 349 | RENDER_TYPE_HUD = LLRenderPass::NUM_RENDER_TYPES, |
323 | RENDER_TYPE_VOLUME, | 350 | RENDER_TYPE_VOLUME, |
324 | RENDER_TYPE_PARTICLES, | 351 | RENDER_TYPE_PARTICLES, |
325 | RENDER_TYPE_CLOUDS, | 352 | RENDER_TYPE_CLOUDS, |
326 | RENDER_TYPE_HUD_PARTICLES | 353 | RENDER_TYPE_HUD_PARTICLES // KL S19? |
327 | }; | 354 | }; |
328 | 355 | ||
329 | enum LLRenderDebugFeatureMask | 356 | enum LLRenderDebugFeatureMask |
@@ -361,8 +388,7 @@ public: | |||
361 | RENDER_DEBUG_SHAME = 0x0020000, | 388 | RENDER_DEBUG_SHAME = 0x0020000, |
362 | RENDER_DEBUG_SHADOW_FRUSTA = 0x0040000, | 389 | RENDER_DEBUG_SHADOW_FRUSTA = 0x0040000, |
363 | RENDER_DEBUG_SCULPTED = 0x0080000, | 390 | RENDER_DEBUG_SCULPTED = 0x0080000, |
364 | RENDER_DEBUG_AVATAR_VOLUME = 0x0100000, | 391 | RENDER_DEBUG_BUILD_QUEUE = 0x0100000, |
365 | RENDER_DEBUG_AGENT_TARGET = 0x0200000, | ||
366 | }; | 392 | }; |
367 | 393 | ||
368 | public: | 394 | public: |
@@ -421,15 +447,36 @@ public: | |||
421 | //screen texture | 447 | //screen texture |
422 | LLRenderTarget mScreen; | 448 | LLRenderTarget mScreen; |
423 | LLRenderTarget mDeferredScreen; | 449 | LLRenderTarget mDeferredScreen; |
424 | LLRenderTarget mDeferredLight[2]; | 450 | LLRenderTarget mDeferredDepth; |
451 | LLRenderTarget mDeferredLight[3]; | ||
425 | LLMultisampleBuffer mSampleBuffer; | 452 | LLMultisampleBuffer mSampleBuffer; |
453 | LLRenderTarget mGIMap; | ||
454 | LLRenderTarget mGIMapPost[2]; | ||
455 | LLRenderTarget mLuminanceMap; | ||
456 | LLRenderTarget mHighlight; | ||
426 | 457 | ||
427 | //sun shadow map | 458 | //sun shadow map |
428 | LLRenderTarget mSunShadow[4]; | 459 | LLRenderTarget mShadow[6]; |
460 | std::vector<LLVector3> mShadowFrustPoints[4]; | ||
461 | LLVector4 mShadowError; | ||
462 | LLVector4 mShadowFOV; | ||
463 | LLVector3 mShadowFrustOrigin[4]; | ||
429 | LLCamera mShadowCamera[8]; | 464 | LLCamera mShadowCamera[8]; |
430 | LLVector3 mShadowExtents[4][2]; | 465 | LLVector3 mShadowExtents[4][2]; |
431 | glh::matrix4f mSunShadowMatrix[4]; | 466 | glh::matrix4f mSunShadowMatrix[6]; |
467 | glh::matrix4f mGIMatrix; | ||
468 | glh::matrix4f mGIMatrixProj; | ||
469 | glh::matrix4f mGINormalMatrix; | ||
470 | glh::matrix4f mGIInvProj; | ||
471 | LLVector2 mGIRange; | ||
472 | F32 mGILightRadius; | ||
473 | |||
474 | LLPointer<LLDrawable> mShadowSpotLight[2]; | ||
475 | F32 mSpotLightFade[2]; | ||
476 | LLPointer<LLDrawable> mTargetShadowSpotLight[2]; | ||
477 | |||
432 | LLVector4 mSunClipPlanes; | 478 | LLVector4 mSunClipPlanes; |
479 | LLVector4 mSunOrthoClipPlanes; | ||
433 | 480 | ||
434 | LLVector2 mScreenScale; | 481 | LLVector2 mScreenScale; |
435 | 482 | ||
@@ -444,6 +491,8 @@ public: | |||
444 | 491 | ||
445 | //noise map | 492 | //noise map |
446 | U32 mNoiseMap; | 493 | U32 mNoiseMap; |
494 | U32 mTrueNoiseMap; | ||
495 | U32 mLightFunc; | ||
447 | 496 | ||
448 | LLColor4 mSunDiffuse; | 497 | LLColor4 mSunDiffuse; |
449 | LLVector3 mSunDir; | 498 | LLVector3 mSunDir; |
@@ -504,12 +553,45 @@ protected: | |||
504 | // | 553 | // |
505 | LLDrawable::drawable_list_t mBuildQ1; // priority | 554 | LLDrawable::drawable_list_t mBuildQ1; // priority |
506 | LLDrawable::drawable_list_t mBuildQ2; // non-priority | 555 | LLDrawable::drawable_list_t mBuildQ2; // non-priority |
556 | LLSpatialGroup::sg_list_t mGroupQ1; //priority | ||
557 | LLSpatialGroup::sg_vector_t mGroupQ2; // non-priority | ||
558 | |||
507 | LLViewerObject::vobj_list_t mCreateQ; | 559 | LLViewerObject::vobj_list_t mCreateQ; |
508 | 560 | ||
509 | LLDrawable::drawable_set_t mActiveQ; | 561 | LLDrawable::drawable_set_t mActiveQ; |
510 | 562 | ||
511 | LLDrawable::drawable_set_t mRetexturedList; | 563 | LLDrawable::drawable_set_t mRetexturedList; |
512 | 564 | ||
565 | class HighlightItem | ||
566 | { | ||
567 | public: | ||
568 | const LLPointer<LLDrawable> mItem; | ||
569 | mutable F32 mFade; | ||
570 | |||
571 | HighlightItem(LLDrawable* item) | ||
572 | : mItem(item), mFade(0) | ||
573 | { | ||
574 | } | ||
575 | |||
576 | bool operator<(const HighlightItem& rhs) const | ||
577 | { | ||
578 | return mItem < rhs.mItem; | ||
579 | } | ||
580 | |||
581 | bool operator==(const HighlightItem& rhs) const | ||
582 | { | ||
583 | return mItem == rhs.mItem; | ||
584 | } | ||
585 | |||
586 | void incrFade(F32 val) const | ||
587 | { | ||
588 | mFade = llclamp(mFade+val, 0.f, 1.f); | ||
589 | } | ||
590 | }; | ||
591 | |||
592 | std::set<HighlightItem> mHighlightSet; | ||
593 | LLPointer<LLDrawable> mHighlightObject; | ||
594 | |||
513 | ////////////////////////////////////////////////// | 595 | ////////////////////////////////////////////////// |
514 | // | 596 | // |
515 | // Draw pools are responsible for storing all rendered data, | 597 | // Draw pools are responsible for storing all rendered data, |
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_hardware_settings.xml b/linden/indra/newview/skins/default/xui/en-us/floater_hardware_settings.xml index 24a895b..e85eaa8 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_hardware_settings.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_hardware_settings.xml | |||
@@ -64,7 +64,35 @@ | |||
64 | tool_tip="Enabling this on modern hardware gives a performance gain. However, older hardware often has poor implementations of VBOs and you may get crashes when this is enabled." | 64 | tool_tip="Enabling this on modern hardware gives a performance gain. However, older hardware often has poor implementations of VBOs and you may get crashes when this is enabled." |
65 | width="315" /> | 65 | width="315" /> |
66 | 66 | ||
67 | <slider bottom_delta="-21" can_edit_text="false" control_name="TextureMemory" | 67 | <text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false" |
68 | bottom_delta="-20" drop_shadow_visible="true" enabled="true" follows="left|top" | ||
69 | font="SansSerifSmall" h_pad="0" halign="left" height="12" | ||
70 | left="10" mouse_opaque="true" name="Enable FBO:" v_pad="0" | ||
71 | width="128"> | ||
72 | Enable FBO: | ||
73 | </text> | ||
74 | <check_box bottom_delta="-5" control_name="RenderUseFBO" enabled="true" follows="left|top" | ||
75 | font="SansSerifSmall" height="16" initial_value="true" | ||
76 | label="Enable OpenGL Framebuffer Objects" left="148" | ||
77 | mouse_opaque="true" name="fbo" radio_style="false" | ||
78 | tool_tip="Enabling this will use OpenGL Framebuffer objects for some dynamic textures. Prerequisite for deferred rendering." | ||
79 | width="315" /> | ||
80 | |||
81 | <text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false" | ||
82 | bottom_delta="-20" drop_shadow_visible="true" enabled="true" follows="left|top" | ||
83 | font="SansSerifSmall" h_pad="0" halign="left" height="12" | ||
84 | left="10" mouse_opaque="true" name="Deferred Rendering:" v_pad="0" | ||
85 | width="128"> | ||
86 | Deferred Rendering: | ||
87 | </text> | ||
88 | <check_box bottom_delta="-5" control_name="RenderDeferred" enabled="true" follows="left|top" | ||
89 | font="SansSerifSmall" height="16" initial_value="true" | ||
90 | label="Enable per-pixel lighting and shadows" left="148" | ||
91 | mouse_opaque="true" name="deferred" radio_style="false" | ||
92 | tool_tip="Enabling this will perform lighting calculations in screen space, enabling per pixel lighting for all lights and shadows from the sun/moon. Requires a fast graphics card. Might not be compatible with FSAA." | ||
93 | width="315" /> | ||
94 | |||
95 | <slider bottom_delta="-21" can_edit_text="false" control_name="TextureMemory" | ||
68 | decimal_digits="0" enabled="true" | 96 | decimal_digits="0" enabled="true" |
69 | follows="left|top" height="16" increment="16" | 97 | follows="left|top" height="16" increment="16" |
70 | initial_val="32" label="Texture Memory (MB):" label_width="135" left="10" | 98 | initial_val="32" label="Texture Memory (MB):" label_width="135" left="10" |
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml b/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml index 0cb4a59..1be2e58 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml | |||
@@ -1036,25 +1036,47 @@ | |||
1036 | <text bg_visible="false" border_drop_shadow_visible="false" border_visible="false" | 1036 | <text bg_visible="false" border_drop_shadow_visible="false" border_visible="false" |
1037 | bottom_delta="-21" drop_shadow_visible="true" follows="left|top" | 1037 | bottom_delta="-21" drop_shadow_visible="true" follows="left|top" |
1038 | font="SansSerifSmall" h_pad="0" halign="left" height="10" left_delta="0" | 1038 | font="SansSerifSmall" h_pad="0" halign="left" height="10" left_delta="0" |
1039 | mouse_opaque="true" name="label color" v_pad="0" width="58"> | 1039 | mouse_opaque="true" name="label color" v_pad="0" width="57"> |
1040 | Color: | 1040 | Color: |
1041 | </text> | 1041 | </text> |
1042 | <color_swatch border_color="0.45098, 0.517647, 0.607843, 1" bottom_delta="-28" | 1042 | <color_swatch border_color="0.45098, 0.517647, 0.607843, 1" bottom_delta="-28" |
1043 | can_apply_immediately="true" color="0.5, 0.5, 0.5, 1" follows="left|top" | 1043 | can_apply_immediately="true" color="0.5, 0.5, 0.5, 1" follows="left|top" |
1044 | height="48" label="" left_delta="67" mouse_opaque="true" name="colorswatch" | 1044 | height="48" label="" left_delta="57" mouse_opaque="true" name="colorswatch" |
1045 | tool_tip="Click to open Color Picker" width="32" /> | 1045 | tool_tip="Click to open Color Picker" width="32" /> |
1046 | <text bg_visible="false" border_drop_shadow_visible="false" border_visible="false" | ||
1047 | bottom_delta="28" drop_shadow_visible="true" follows="left|top" | ||
1048 | font="SansSerifSmall" h_pad="0" height="10" left="144" | ||
1049 | mouse_opaque="true" name="label texture" v_pad="0" width="58"> | ||
1050 | Texture | ||
1051 | </text> | ||
1052 | <texture_picker allow_no_texture="true" bottom_delta="-28" can_apply_immediately="true" | ||
1053 | default_image_name="Default" follows="left|top" height="48" label="" | ||
1054 | left_delta="57" mouse_opaque="true" name="light texture control" | ||
1055 | tool_tip="Click to choose a projection image (only has effect with deferred rendering enabled)" width="32" /> | ||
1046 | <spinner bottom_delta="-4" decimal_digits="3" follows="left|top" height="16" | 1056 | <spinner bottom_delta="-4" decimal_digits="3" follows="left|top" height="16" |
1047 | increment="0.1" initial_val="0.5" label="Intensity:" label_width="65" | 1057 | increment="0.1" initial_val="0.5" label="Intensity:" label_width="55" |
1048 | left="10" max_val="1" min_val="0" mouse_opaque="true" | 1058 | left="10" max_val="1" min_val="0" mouse_opaque="true" |
1049 | name="Light Intensity" width="128" /> | 1059 | name="Light Intensity" width="120" /> |
1060 | <spinner bottom_delta="0" decimal_digits="3" follows="left|top" height="16" | ||
1061 | increment="0.1" initial_val="0.5" label="FOV" label_width="55" | ||
1062 | left="144" max_val="3" min_val="0" mouse_opaque="true" | ||
1063 | name="Light FOV" width="120" /> | ||
1050 | <spinner bottom_delta="-20" decimal_digits="3" follows="left|top" height="16" | 1064 | <spinner bottom_delta="-20" decimal_digits="3" follows="left|top" height="16" |
1051 | increment="0.1" initial_val="5" label="Radius:" label_width="65" | 1065 | increment="0.1" initial_val="5" label="Radius" label_width="55" |
1052 | left_delta="0" max_val="20" min_val="0" mouse_opaque="true" | 1066 | left="10" max_val="20" min_val="0" mouse_opaque="true" |
1053 | name="Light Radius" width="128" /> | 1067 | name="Light Radius" width="120" /> |
1068 | <spinner bottom_delta="0" decimal_digits="3" follows="left|top" height="16" | ||
1069 | increment="0.5" initial_val="0.5" label="Focus" label_width="55" | ||
1070 | left="144" max_val="20" min_val="-20" mouse_opaque="true" | ||
1071 | name="Light Focus" width="120" /> | ||
1054 | <spinner bottom_delta="-20" decimal_digits="3" follows="left|top" height="16" | 1072 | <spinner bottom_delta="-20" decimal_digits="3" follows="left|top" height="16" |
1055 | increment="0.25" initial_val="1" label="Falloff:" label_width="65" | 1073 | increment="0.25" initial_val="1" label="Falloff" label_width="55" |
1056 | left_delta="0" max_val="2" min_val="0" mouse_opaque="true" | 1074 | left="10" max_val="2" min_val="0" mouse_opaque="true" |
1057 | name="Light Falloff" width="128" /> | 1075 | name="Light Falloff" width="120" /> |
1076 | <spinner bottom_delta="0" decimal_digits="3" follows="left|top" height="16" | ||
1077 | increment="0.05" initial_val="1" label="Ambiance" label_width="55" | ||
1078 | left="144" max_val="1" min_val="0" mouse_opaque="true" | ||
1079 | name="Light Ambiance" width="120" /> | ||
1058 | </panel> | 1080 | </panel> |
1059 | 1081 | ||
1060 | <!-- Texture sub-tab --> | 1082 | <!-- Texture sub-tab --> |