diff options
Diffstat (limited to 'indra/newview')
611 files changed, 41349 insertions, 24521 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 99f99834f3..9933713911 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -170,7 +170,6 @@ set(viewer_SOURCE_FILES llcurrencyuimanager.cpp llcylinder.cpp lldateutil.cpp - lldaycyclemanager.cpp lldebugmessagebox.cpp lldebugview.cpp lldeferredsounds.cpp @@ -193,7 +192,7 @@ set(viewer_SOURCE_FILES lldrawpoolwlsky.cpp lldynamictexture.cpp llemote.cpp - llenvmanager.cpp + llenvironment.cpp llestateinfomodel.cpp lleventnotifier.cpp lleventpoll.cpp @@ -233,18 +232,15 @@ set(viewer_SOURCE_FILES llfloatercolorpicker.cpp llfloaterconversationlog.cpp llfloaterconversationpreview.cpp - llfloaterdeleteenvpreset.cpp llfloaterdeleteprefpreset.cpp llfloaterdestinations.cpp - llfloatereditdaycycle.cpp - llfloatereditsky.cpp - llfloatereditwater.cpp - llfloaterenvironmentsettings.cpp + llfloatereditextdaycycle.cpp llfloaterevent.cpp llfloaterexperiencepicker.cpp llfloaterexperienceprofile.cpp llfloaterexperiences.cpp llfloaterfacebook.cpp + llfloaterfixedenvironment.cpp llfloaterflickr.cpp llfloaterfonttest.cpp llfloatergesture.cpp @@ -275,6 +271,7 @@ set(viewer_SOURCE_FILES llfloatermemleak.cpp llfloatermodelpreview.cpp llfloatermodeluploadbase.cpp + llfloatermyenvironment.cpp llfloaternamedesc.cpp llfloaternotificationsconsole.cpp llfloaternotificationstabbed.cpp @@ -330,6 +327,7 @@ set(viewer_SOURCE_FILES llfolderviewmodelinventory.cpp llfollowcam.cpp llfriendcard.cpp + llflyoutcombobtn.cpp llgesturelistener.cpp llgesturemgr.cpp llgiveinventory.cpp @@ -377,6 +375,7 @@ set(viewer_SOURCE_FILES lljoystickbutton.cpp lllandmarkactions.cpp lllandmarklist.cpp + lllegacyatmospherics.cpp lllistbrowser.cpp lllistcontextmenu.cpp lllistview.cpp @@ -432,7 +431,10 @@ set(viewer_SOURCE_FILES llpanelblockedlist.cpp llpanelclassified.cpp llpanelcontents.cpp + llpaneleditsky.cpp + llpaneleditwater.cpp llpaneleditwearable.cpp + llpanelenvironment.cpp llpanelexperiencelisteditor.cpp llpanelexperiencelog.cpp llpanelexperiencepicker.cpp @@ -547,6 +549,8 @@ set(viewer_SOURCE_FILES llsecapi.cpp llsechandler_basic.cpp llselectmgr.cpp + llsettingspicker.cpp + llsettingsvo.cpp llshareavatarhandler.cpp llsidepanelappearance.cpp llsidepanelinventory.cpp @@ -611,6 +615,7 @@ set(viewer_SOURCE_FILES lltoolselectland.cpp lltoolselectrect.cpp lltracker.cpp + lltrackpicker.cpp lltransientdockablefloater.cpp lltransientfloatermgr.cpp lltranslate.cpp @@ -702,19 +707,13 @@ set(viewer_SOURCE_FILES llvowater.cpp llvowlsky.cpp llwatchdog.cpp - llwaterparammanager.cpp - llwaterparamset.cpp llwearableitemslist.cpp llwearablelist.cpp llweb.cpp llwebprofile.cpp llwind.cpp llwindowlistener.cpp - llwlanimator.cpp - llwldaycycle.cpp llwlhandlers.cpp - llwlparammanager.cpp - llwlparamset.cpp llworld.cpp llworldmap.cpp llworldmapmessage.cpp @@ -794,7 +793,6 @@ set(viewer_HEADER_FILES llcurrencyuimanager.h llcylinder.h lldateutil.h - lldaycyclemanager.h lldebugmessagebox.h lldebugview.h lldeferredsounds.h @@ -817,7 +815,7 @@ set(viewer_HEADER_FILES lldrawpoolwlsky.h lldynamictexture.h llemote.h - llenvmanager.h + llenvironment.h llestateinfomodel.h lleventnotifier.h lleventpoll.h @@ -858,17 +856,14 @@ set(viewer_HEADER_FILES llfloaterconversationlog.h llfloaterconversationpreview.h llfloaterdeleteprefpreset.h - llfloaterdeleteenvpreset.h llfloaterdestinations.h - llfloatereditdaycycle.h - llfloatereditsky.h - llfloatereditwater.h - llfloaterenvironmentsettings.h + llfloatereditextdaycycle.h llfloaterevent.h llfloaterexperiencepicker.h llfloaterexperienceprofile.h llfloaterexperiences.h llfloaterfacebook.h + llfloaterfixedenvironment.h llfloaterflickr.h llfloaterfonttest.h llfloatergesture.h @@ -902,6 +897,7 @@ set(viewer_HEADER_FILES llfloatermemleak.h llfloatermodelpreview.h llfloatermodeluploadbase.h + llfloatermyenvironment.h llfloaternamedesc.h llfloaternotificationsconsole.h llfloaternotificationstabbed.h @@ -957,6 +953,7 @@ set(viewer_HEADER_FILES llfolderviewmodelinventory.h llfollowcam.h llfriendcard.h + llflyoutcombobtn.h llgesturelistener.h llgesturemgr.h llgiveinventory.h @@ -1049,7 +1046,10 @@ set(viewer_HEADER_FILES llpanelblockedlist.h llpanelclassified.h llpanelcontents.h + llpaneleditsky.h + llpaneleditwater.h llpaneleditwearable.h + llpanelenvironment.h llpanelexperiencelisteditor.h llpanelexperiencelog.h llpanelexperiencepicker.h @@ -1163,6 +1163,8 @@ set(viewer_HEADER_FILES llsecapi.h llsechandler_basic.h llselectmgr.h + llsettingspicker.h + llsettingsvo.h llsidepanelappearance.h llsidepanelinventory.h llsidepanelinventorysubpanel.h @@ -1228,6 +1230,7 @@ set(viewer_HEADER_FILES lltoolselectland.h lltoolselectrect.h lltracker.h + lltrackpicker.h lltransientdockablefloater.h lltransientfloatermgr.h lltranslate.h @@ -1320,19 +1323,13 @@ set(viewer_HEADER_FILES llvowater.h llvowlsky.h llwatchdog.h - llwaterparammanager.h - llwaterparamset.h llwearableitemslist.h llwearablelist.h llweb.h llwebprofile.h llwind.h llwindowlistener.h - llwlanimator.h - llwldaycycle.h llwlhandlers.h - llwlparammanager.h - llwlparamset.h llworld.h llworldmap.h llworldmapmessage.h @@ -2512,7 +2509,6 @@ if (LL_TESTS) include(LLAddBuildTest) SET(viewer_TEST_SOURCE_FILES llagentaccess.cpp - llwlparammanager.cpp ) set_source_files_properties( ${viewer_TEST_SOURCE_FILES} diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt index f3b5af39e4..6abaeb2f90 100644 --- a/indra/newview/VIEWER_VERSION.txt +++ b/indra/newview/VIEWER_VERSION.txt @@ -1 +1 @@ -6.1.1 +6.2.0 diff --git a/indra/newview/app_settings/cmd_line.xml b/indra/newview/app_settings/cmd_line.xml index e4e1cdcf44..4e186292f7 100644 --- a/indra/newview/app_settings/cmd_line.xml +++ b/indra/newview/app_settings/cmd_line.xml @@ -407,5 +407,14 @@ <integer>1</integer> <!-- Special case. Mapped to settings procedurally. --> </map> + + <key>skipupdatecheck</key> + <map> + <key>desc</key> + <string>Skips update check at startup.</string> + <key>map-to</key> + <string>CmdLineSkipUpdater</string> + </map> + </map> </llsd> diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 6e7ddd0bf4..088bc3dfac 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1252,6 +1252,17 @@ <key>Value</key> <integer>1</integer> </map> + <key>BulkChangeIncludeSettings</key> + <map> + <key>Comment</key> + <string>Bulk permission changes affect environment settings</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>BulkChangeEveryoneCopy</key> <map> <key>Comment</key> @@ -1929,7 +1940,18 @@ <key>Value</key> <string/> </map> - <key>ConnectAsGod</key> + <key>CmdLineSkipUpdater</key> + <map> + <key>Comment</key> + <string>Command line skip updater check.</string> + <key>Persist</key> + <integer>0</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>ConnectAsGod</key> <map> <key>Comment</key> <string>Log in a god if you have god access.</string> @@ -6716,6 +6738,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>MouseMoon</key> + <map> + <key>Comment</key> + <string /> + <key>Persist</key> + <integer>0</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>MuteAmbient</key> <map> <key>Comment</key> @@ -8984,6 +9017,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>RenderDebugSH</key> + <map> + <key>Comment</key> + <string>Enable SH indirect lighting visualization.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>RenderMaxTextureIndex</key> <map> <key>Comment</key> @@ -9143,7 +9187,7 @@ <key>Type</key> <string>F32</string> <key>Value</key> - <real>-0.008</real> + <real>-0.004</real> </map> <key>RenderShadowOffset</key> <map> @@ -10244,6 +10288,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>RenderUseAdvancedAtmospherics</key> + <map> + <key>Comment</key> + <string>Use fancy precomputed atmospherics and stuff.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>RenderUseTriStrips</key> <map> <key>Comment</key> @@ -11937,6 +11992,21 @@ <key>Value</key> <real>0.300000011921</real> </map> + <key>SkyMoonDefaultPosition</key> + <map> + <key>Comment</key> + <string>Default position of sun in sky (direction in world coordinates)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Vector3</string> + <key>Value</key> + <array> + <real>-1.0</real> + <real>0.0</real> + <real>-0.1</real> + </array> + </map> <key>SkyNightColorShift</key> <map> <key>Comment</key> @@ -14772,6 +14842,28 @@ <key>Value</key> <integer>1</integer> </map> + <key>sunbeacon</key> + <map> + <key>Comment</key> + <string>Show direction to the Sun</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>moonbeacon</key> + <map> + <key>Comment</key> + <string>Show direction to the Moon</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>ShowDeviceSettings</key> <map> <key>Comment</key> @@ -15734,6 +15826,28 @@ <key>Value</key> <integer>0</integer> </map> + <key>SettingsNextOwnerModify</key> + <map> + <key>Comment</key> + <string>Newly created Environment setting can be modified by next owner</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>SettingsNextOwnerTransfer</key> + <map> + <key>Comment</key> + <string>Newly created Environment setting can be resold or given away by next owner</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>DefaultUploadPermissionsConverted</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b9c8f34cb0..fdbf5ec840 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -39,37 +39,11 @@ out vec4 frag_color; uniform float display_gamma; uniform vec4 gamma; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 ambient; -uniform vec4 blue_horizon; -uniform vec4 blue_density; -uniform float haze_horizon; -uniform float haze_density; -uniform float cloud_shadow; -uniform float density_multiplier; -uniform float distance_multiplier; -uniform float max_y; -uniform vec4 glow; -uniform float scene_light_strength; uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; - -#if HAS_SHADOW -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; - -uniform vec2 shadow_res; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform float shadow_bias; - -#endif +uniform vec3 moon_dir; #ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; @@ -84,548 +58,182 @@ VARYING vec3 vary_norm; VARYING vec4 vertex_color; #endif -vec3 vary_PositionEye; -vec3 vary_SunlitColor; -vec3 vary_AmblitColor; -vec3 vary_AdditiveColor; -vec3 vary_AtmosAttenuation; - uniform mat4 inv_proj; uniform vec2 screen_res; - +uniform int sun_up_factor; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; +uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - a = pow(a, 1.0/1.3); - return vec3(a,a,a); -} - -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = length(lv); - - float da = 1.0; - - vec3 col = vec3(0); - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist = d/la; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - - float lit = max(da * dist_atten,0.0); - - col = light_col * lit * diffuse; - - // no spec for alpha shader... - } - - return max(col, vec3(0.0,0.0,0.0)); -} - -#if HAS_SHADOW -float pcfShadow(sampler2DShadow shadowMap, vec4 stc) -{ - stc.xyz /= stc.w; - stc.z += shadow_bias; - - stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here - - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - return shadow*0.2; -} -#endif - #ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} +vec4 applyWaterFogView(vec3 pos, vec4 color); #endif -vec3 getSunlitColor() -{ - return vary_SunlitColor; -} -vec3 getAmblitColor() -{ - return vary_AmblitColor; -} -vec3 getAdditiveColor() -{ - return vary_AdditiveColor; -} -vec3 getAtmosAttenuation() -{ - return vary_AtmosAttenuation; -} +vec3 srgb_to_linear(vec3 c); +vec3 linear_to_srgb(vec3 c); -void setPositionEye(vec3 v) -{ - vary_PositionEye = v; -} +vec2 encode_normal (vec3 n); +vec3 scaleSoftClipFrag(vec3 l); +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -void setSunlitColor(vec3 v) -{ - vary_SunlitColor = v; -} +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); -void setAmblitColor(vec3 v) -{ - vary_AmblitColor = v; -} +#ifdef HAS_SHADOW +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +#endif -void setAdditiveColor(vec3 v) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) { - vary_AdditiveColor = v; -} + //get light vector + vec3 lv = lp.xyz-v; + + //get distance + float d = length(lv); + float da = 1.0; + vec3 col = vec3(0); -void setAtmosAttenuation(vec3 v) -{ - vary_AtmosAttenuation = v; -} + if (d > 0.0 && fa > 0.0) + { + //normalize light vector + lv = normalize(lv); + vec3 norm = normalize(n); -void calcAtmospherics(vec3 inPositionEye, float ambFactor) { - - vec3 P = inPositionEye; - setPositionEye(P); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = sunlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); - */ - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - - //haze color - setAdditiveColor( - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient))); - - //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); -} + da = max(0.0, dot(norm, lv)); + da = clamp(da, 0.0, 1.0); + + //distance attenuation + float dist = d/la; + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; -vec3 atmosLighting(vec3 light) -{ - light *= getAtmosAttenuation().r; - light += getAdditiveColor(); - return (2.0 * light); -} + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 -vec3 atmosTransport(vec3 light) { - light *= getAtmosAttenuation().r; - light += getAdditiveColor() * 2.0; - return light; -} -vec3 atmosGetDiffuseSunlightColor() -{ - return getSunlitColor(); -} + // to match spotLight (but not multiSpotLight) *sigh* + float lit = max(da * dist_atten,0.0); + col = lit * light_col * diffuse; -vec3 scaleDownLight(vec3 light) -{ - return (light / vec3(scene_light_strength, scene_light_strength, scene_light_strength)); -} + float amb_da = ambiance; + amb_da *= dist_atten; + amb_da += (da*0.5) * ambiance; + amb_da += (da*da*0.5 + 0.25) * ambiance; + amb_da = min(amb_da, 1.0f - lit); -vec3 scaleUpLight(vec3 light) -{ - return (light * vec3(scene_light_strength, scene_light_strength, scene_light_strength)); + col.rgb += amb_da * light_col * diffuse; + // no spec for alpha shader... + } + col = max(col, vec3(0)); + return col; } -vec3 atmosAmbient(vec3 light) -{ - return getAmblitColor() + (light * vec3(0.5f, 0.5f, 0.5f)); -} - -vec3 atmosAffectDirectionalLight(float lightIntensity) -{ - return getSunlitColor() * vec3(lightIntensity, lightIntensity, lightIntensity); -} - -vec3 scaleSoftClip(vec3 light) +void main() { - //soft clip effect: - vec3 zeroes = vec3(0.0f, 0.0f, 0.0f); - vec3 ones = vec3(1.0f, 1.0f, 1.0f); - - light = ones - clamp(light, zeroes, ones); - light = ones - pow(light, gamma.xxx); + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; + frag *= screen_res; + + vec4 pos = vec4(vary_position, 1.0); + vec3 norm = vary_norm; - return light; -} + float shadow = 1.0f; -vec3 fullbrightAtmosTransport(vec3 light) { - float brightness = dot(light.rgb, vec3(0.33333)); - - return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); -} - -vec3 fullbrightScaleSoftClip(vec3 light) -{ - //soft clip effect: - return light; -} - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - vec4 pos = vec4(vary_position, 1.0); - - float shadow = 1.0; - -#if HAS_SHADOW - vec4 spos = pos; - - if (spos.z > -shadow_clip.w) - { - shadow = 0.0; - - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadow(shadowMap0, lpos)*w; - weight += w; - } - - - shadow /= weight; - } - else - { - shadow = 1.0; - } +#ifdef HAS_SHADOW + shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); #endif #ifdef USE_INDEXED_TEX - vec4 diff = diffuseLookup(vary_texcoord0.xy); + vec4 diff = diffuseLookup(vary_texcoord0.xy); #else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif #ifdef FOR_IMPOSTOR - vec4 color; - color.rgb = diff.rgb; - color.a = 1.0; + vec4 color; + color.rgb = diff.rgb; + color.a = 1.0; #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diff.a * vertex_color.a; + diff.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diff.a; #endif - - // Insure we don't pollute depth with invis pixels in impostor rendering - // - if (final_alpha < 0.01) - { - discard; - } + + // Insure we don't pollute depth with invis pixels in impostor rendering + // + if (final_alpha < 0.01) + { + discard; + } #else - + #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diff.a * vertex_color.a; + diff.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diff.a; #endif + diff.rgb = srgb_to_linear(diff.rgb); - vec4 gamma_diff = diff; - diff.rgb = srgb_to_linear(diff.rgb); - - vec3 norm = vary_norm; - - calcAtmospherics(pos.xyz, 1.0); + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; - vec2 abnormal = encode_normal(norm.xyz); - norm.xyz = decode_normal(abnormal.xy); + calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); - float da = dot(norm.xyz, sun_dir.xyz); + vec2 abnormal = encode_normal(norm.xyz); - float final_da = da; - final_da = min(final_da, shadow); - final_da = max(final_da, 0.0f); - final_da = min(final_da, 1.0f); - final_da = pow(final_da, 1.0/1.3); + vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; + float da = dot(norm.xyz, light_dir.xyz); + da = clamp(da, 0.0, 1.0); - vec4 color = vec4(0,0,0,0); + vec4 color = vec4(0,0,0,0); - color.rgb = atmosAmbient(color.rgb); - color.a = final_alpha; + color.rgb = amblit; + color.a = final_alpha; - float ambient = abs(da); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); + float ambient = abs(da); + ambient *= 0.5; + ambient *= ambient; + ambient = 1.0 - ambient; - color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(final_da); - color.rgb *= gamma_diff.rgb; + vec3 sun_contrib = min(da, shadow) * sunlit; - //color.rgb = mix(diff.rgb, color.rgb, final_alpha); - - color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); + color.rgb *= ambient; + color.rgb += sun_contrib; + color.rgb *= diff.rgb; - vec4 light = vec4(0,0,0,0); + //color.rgb = mix(diff.rgb, color.rgb, final_alpha); + + color.rgb = atmosFragLighting(color.rgb, additive, atten); + color.rgb = scaleSoftClipFrag(color.rgb); - color.rgb = srgb_to_linear(color.rgb); - - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + vec4 light = vec4(0,0,0,0); - LIGHT_LOOP(1) - LIGHT_LOOP(2) - LIGHT_LOOP(3) - LIGHT_LOOP(4) - LIGHT_LOOP(5) - LIGHT_LOOP(6) - LIGHT_LOOP(7) + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, shadow); - // keep it linear - // - color.rgb += light.rgb; + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) - // straight to display gamma, we're post-deferred - // - color.rgb = linear_to_srgb(color.rgb); + // keep it linear + // + color.rgb += light.rgb; -#ifdef WATER_FOG - color = applyWaterFogDeferred(pos.xyz, color); + color.rgb = linear_to_srgb(color.rgb); #endif +#ifdef WATER_FOG + color = applyWaterFogView(pos.xyz, color); #endif - frag_color = color; + frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl new file mode 100644 index 0000000000..23adbded5e --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl @@ -0,0 +1,123 @@ +/** + * @file class1/deferred/aoUtil.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform sampler2D noiseMap; +uniform sampler2DRect normalMap; +uniform sampler2DRect depthMap; + +uniform float ssao_radius; +uniform float ssao_max_radius; +uniform float ssao_factor; +uniform float ssao_factor_inv; + +uniform mat4 inv_proj; +uniform vec2 screen_res; + +vec2 getScreenCoordinateAo(vec2 screenpos) +{ + vec2 sc = screenpos.xy * 2.0; + if (screen_res.x > 0 && screen_res.y > 0) + { + sc /= screen_res; + } + return sc - vec2(1.0, 1.0); +} + +float getDepthAo(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen).r; + return depth; +} + +vec4 getPositionAo(vec2 pos_screen) +{ + float depth = getDepthAo(pos_screen); + vec2 sc = getScreenCoordinateAo(pos_screen); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +vec2 getKern(int i) +{ + vec2 kern[8]; + // exponentially (^2) distant occlusion samples spread around origin + kern[0] = vec2(-1.0, 0.0) * 0.125*0.125; + kern[1] = vec2(1.0, 0.0) * 0.250*0.250; + kern[2] = vec2(0.0, 1.0) * 0.375*0.375; + kern[3] = vec2(0.0, -1.0) * 0.500*0.500; + kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625; + kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750; + kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; + kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; + + return kern[i]; +} + +//calculate decreases in ambient lighting when crowded out (SSAO) +float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) +{ + float ret = 1.0; + vec3 pos_world = pos.xyz; + vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy/128.0).xy; + + float angle_hidden = 0.0; + float points = 0; + + float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); + + // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?) + for (int i = 0; i < 8; i++) + { + vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect); + vec3 samppos_world = getPositionAo(samppos_screen).xyz; + + vec3 diff = pos_world - samppos_world; + float dist2 = dot(diff, diff); + + // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area + // --> solid angle shrinking by the square of distance + //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2 + //(k should vary inversely with # of samples, but this is taken care of later) + + float funky_val = (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) ? 1.0 : 0.0; + angle_hidden = angle_hidden + funky_val * min(1.0/dist2, ssao_factor_inv); + + // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" + float diffz_val = (diff.z > -1.0) ? 1.0 : 0.0; + points = points + diffz_val; + } + + angle_hidden = min(ssao_factor*angle_hidden/points, 1.0); + + float points_val = (points > 0.0) ? 1.0 : 0.0; + ret = (1.0 - (points_val * angle_hidden)); + + ret = max(ret, 0.0); + return min(ret, 1.0); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl index 22c9a4d14e..8e9a5fcd41 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl @@ -22,6 +22,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl index 3f90600ace..0fa0edfd67 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl @@ -41,7 +41,7 @@ void main() vec4 p = projection_matrix * vec4(pos, 1.0); -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) p.z = max(p.z, -p.w+0.01); gl_Position = p; #else diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl index c8ddefac26..e68b082d43 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl @@ -34,12 +34,9 @@ mat4 getSkinnedTransform(); void calcAtmospherics(vec3 inPositionEye); float calcDirectionalLight(vec3 n, vec3 l); -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight); vec3 atmosAmbient(vec3 light); vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); VARYING vec3 vary_position; VARYING vec3 vary_ambient; @@ -59,12 +56,6 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index 662c762bca..60d83cc623 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -36,11 +38,7 @@ uniform float minimum_alpha; VARYING vec3 vary_normal; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index b809b73973..50020a50d8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl @@ -22,7 +22,9 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -31,7 +33,7 @@ out vec4 frag_color; uniform sampler2D diffuseMap; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) VARYING vec4 post_pos; #endif @@ -39,7 +41,7 @@ void main() { frag_color = vec4(1,1,1,1); -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); #endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl index bde1ad4e9f..91b25613e0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl @@ -31,7 +31,7 @@ ATTRIBUTE vec3 position; ATTRIBUTE vec3 normal; ATTRIBUTE vec2 texcoord0; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) VARYING vec4 post_pos; #endif @@ -53,7 +53,7 @@ void main() norm = normalize(norm); pos = projection_matrix * pos; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) post_pos = pos; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index cbd8d2ebfc..596d0274af 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl @@ -33,7 +33,6 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect depthMap; uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; @@ -45,100 +44,68 @@ uniform float kern_scale; VARYING vec2 vary_fragcoord; -uniform mat4 inv_proj; -uniform vec2 screen_res; - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} +vec4 getPosition(vec2 pos_screen); +vec3 getNorm(vec2 pos_screen); void main() { vec2 tc = vary_fragcoord.xy; - vec3 norm = texture2DRect(normalMap, tc).xyz; - norm = decode_normal(norm.xy); // unpack norm - - vec3 pos = getPosition(tc).xyz; - vec4 ccol = texture2DRect(lightMap, tc).rgba; - - vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); - dlt /= max(-pos.z*dist_factor, 1.0); - - 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' - vec4 col = defined_weight.xyxx * ccol; - - // relax tolerance according to distance to avoid speckling artifacts, as angles and distances are a lot more abrupt within a small screen area at larger distances - float pointplanedist_tolerance_pow2 = pos.z*pos.z*0.00005; - - // perturb sampling origin slightly in screen-space to hide edge-ghosting artifacts where smoothing radius is quite large - float tc_mod = 0.5*(tc.x + tc.y); // mod(tc.x+tc.y,2) - tc_mod -= floor(tc_mod); - tc_mod *= 2.0; - tc += ( (tc_mod - 0.5) * kern[1].z * dlt * 0.5 ); - - for (int i = 1; i < 4; i++) - { - vec2 samptc = tc + kern[i].z*dlt; - vec3 samppos = getPosition(samptc).xyz; - - float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane - - if (d*d <= pointplanedist_tolerance_pow2) - { - col += texture2DRect(lightMap, samptc)*kern[i].xyxx; - defined_weight += kern[i].xy; - } - } - - for (int i = 1; i < 4; i++) - { - vec2 samptc = tc - kern[i].z*dlt; - vec3 samppos = getPosition(samptc).xyz; - - float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane - - if (d*d <= pointplanedist_tolerance_pow2) - { - col += texture2DRect(lightMap, samptc)*kern[i].xyxx; - defined_weight += kern[i].xy; - } - } - - col /= defined_weight.xyxx; - col.y *= col.y; - - frag_color = col; + vec3 norm = getNorm(tc); + vec3 pos = getPosition(tc).xyz; + vec4 ccol = texture2DRect(lightMap, tc).rgba; + + vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); + dlt /= max(-pos.z*dist_factor, 1.0); + + 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' + vec4 col = defined_weight.xyxx * ccol; + + // relax tolerance according to distance to avoid speckling artifacts, as angles and distances are a lot more abrupt within a small screen area at larger distances + float pointplanedist_tolerance_pow2 = pos.z*pos.z*0.00005; + + // perturb sampling origin slightly in screen-space to hide edge-ghosting artifacts where smoothing radius is quite large + float tc_mod = 0.5*(tc.x + tc.y); // mod(tc.x+tc.y,2) + tc_mod -= floor(tc_mod); + tc_mod *= 2.0; + tc += ( (tc_mod - 0.5) * kern[1].z * dlt * 0.5 ); + + for (int i = 1; i < 4; i++) + { + vec2 samptc = tc + kern[i].z*dlt; + vec3 samppos = getPosition(samptc).xyz; + + float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane + + if (d*d <= pointplanedist_tolerance_pow2) + { + col += texture2DRect(lightMap, samptc)*kern[i].xyxx; + defined_weight += kern[i].xy; + } + } + + for (int i = 1; i < 4; i++) + { + vec2 samptc = tc - kern[i].z*dlt; + vec3 samppos = getPosition(samptc).xyz; + + float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane + + if (d*d <= pointplanedist_tolerance_pow2) + { + col += texture2DRect(lightMap, samptc)*kern[i].xyxx; + defined_weight += kern[i].xy; + } + } + + col /= defined_weight.xyxx; + col.y *= col.y; + + frag_color = col; #ifdef IS_AMD_CARD - // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts. - vec3 dummy1 = kern[0]; - vec3 dummy2 = kern[3]; + // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts. + vec3 dummy1 = kern[0]; + vec3 dummy2 = kern[3]; #endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl index 58fb01d200..b5677a07ee 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl @@ -22,6 +22,8 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ + +/*[EXTRA_CODE_HERE]*/ #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -40,11 +42,7 @@ VARYING vec3 vary_mat2; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl new file mode 100644 index 0000000000..035e979827 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl @@ -0,0 +1,128 @@ +/** + * @file class3/deferred/cloudsF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING float vary_CloudDensity; +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; +VARYING vec2 vary_texcoord3; + +uniform sampler2D cloud_noise_texture; +uniform sampler2D cloud_noise_texture_next; +uniform float blend_factor; +uniform vec4 cloud_pos_density1; +uniform vec4 cloud_pos_density2; +uniform vec4 sunlight_color; +uniform vec4 cloud_color; +uniform float cloud_shadow; +uniform float cloud_scale; +uniform float cloud_variance; +uniform vec3 ambient; +uniform vec3 camPosLocal; +uniform vec3 sun_dir; +uniform float sun_size; +uniform float far_z; + +#if !defined(DEPTH_CLAMP) +VARYING vec4 post_pos; +#endif + +vec4 cloudNoise(vec2 uv) +{ + vec4 a = texture2D(cloud_noise_texture, uv); + vec4 b = texture2D(cloud_noise_texture_next, uv); + vec4 cloud_noise_sample = mix(a, b, blend_factor); + return normalize(cloud_noise_sample); +} + +void main() +{ + // Set variables + vec2 uv1 = vary_texcoord0.xy; + vec2 uv2 = vary_texcoord1.xy; + vec2 uv3 = vary_texcoord2.xy; + float cloudDensity = 2.0 * (cloud_shadow - 0.25); + + if (cloud_scale >= 0.0001) + { + vec2 uv4 = vary_texcoord3.xy; + + vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + + // Offset texture coords + uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); + + cloudDensity *= 1.0 - (density_variance * density_variance); + + // Compute alpha1, the main cloud opacity + float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + if (alpha1 < 0.001f) + { + discard; + } + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (cloudNoise(uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + frag_color = vec4(alpha1, alpha1, alpha1, 1); + } + else + { + frag_color = vec4(1); + } + +#if !defined(DEPTH_CLAMP) + gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); +#endif + +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl new file mode 100644 index 0000000000..effb070f93 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl @@ -0,0 +1,63 @@ +/** + * @file cloudShadowV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING vec2 vary_texcoord0; +VARYING vec4 vertex_color; + +void passTextureIndex(); + +void main() +{ + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + pos = modelview_projection_matrix * pre_pos; + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + +#if !defined(DEPTH_CLAMP) + pos_zd2 = pos.z * 0.5; + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + + passTextureIndex(); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + vertex_color = diffuse_color; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 1d8ca04ccd..60ccfa64db 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -22,7 +22,7 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - +/*[EXTRA_CODE_HERE]*/ #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -39,9 +39,13 @@ VARYING vec4 vary_CloudColorAmbient; VARYING float vary_CloudDensity; uniform sampler2D cloud_noise_texture; +uniform sampler2D cloud_noise_texture_next; +uniform float blend_factor; uniform vec4 cloud_pos_density1; uniform vec4 cloud_pos_density2; uniform vec4 gamma; +uniform float cloud_scale; +uniform float cloud_variance; VARYING vec2 vary_texcoord0; VARYING vec2 vary_texcoord1; @@ -49,59 +53,77 @@ VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord3; /// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); +vec3 scaleSoftClip(vec3 light); - return light; +vec4 cloudNoise(vec2 uv) +{ + vec4 a = texture2D(cloud_noise_texture, uv); + vec4 b = texture2D(cloud_noise_texture_next, uv); + vec4 cloud_noise_sample = mix(a, b, blend_factor); + return cloud_noise_sample; } void main() { - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - - vec4 cloudColorSun = vary_CloudColorSun; - vec4 cloudColorAmbient = vary_CloudColorAmbient; - float cloudDensity = vary_CloudDensity; - vec2 uv3 = vary_texcoord2.xy; - vec2 uv4 = vary_texcoord3.xy; - - // Offset texture coords - uv1 += cloud_pos_density1.xy; //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - uv3 += cloud_pos_density2.xy; //small texture, visible density - uv4 += cloud_pos_density2.xy; //small texture, self shadow - - - // Compute alpha1, the main cloud opacity - float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, uv3).x - 0.5) * cloud_pos_density2.z; - alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.); - - // And smooth - alpha1 = 1. - alpha1 * alpha1; - alpha1 = 1. - alpha1 * alpha1; - - - // Compute alpha2, for self shadowing effect - // (1 - alpha2) will later be used as percentage of incoming sunlight - float alpha2 = (texture2D(cloud_noise_texture, uv2).x - 0.5); - alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - // Combine - vec4 color; - color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); - color *= 2.; - - /// Gamma correct for WL (soft clip effect). - frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1); - frag_data[1] = vec4(0.0,0.0,0.0,0.0); - frag_data[2] = vec4(0,0,1,0); + // Set variables + vec2 uv1 = vary_texcoord0.xy; + vec2 uv2 = vary_texcoord1.xy; + + vec4 cloudColorSun = vary_CloudColorSun; + vec4 cloudColorAmbient = vary_CloudColorAmbient; + float cloudDensity = vary_CloudDensity; + vec2 uv3 = vary_texcoord2.xy; + vec2 uv4 = vary_texcoord3.xy; + + if (cloud_scale < 0.001) + { + discard; + } + + vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + + // Offset texture coords + uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); + + cloudDensity *= 1.0 - (density_variance * density_variance); + + // Compute alpha1, the main cloud opacity + + float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + if (alpha1 < 0.001f) + { + discard; + } + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (cloudNoise(uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + // Combine + vec4 color; + color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); + color *= 2.; + + /// Gamma correct for WL (soft clip effect). + frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1); + frag_data[1] = vec4(0.0,0.0,0.0,0.0); + frag_data[2] = vec4(0,0,1,0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 17f425475c..4beb334f5a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -47,6 +47,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -58,6 +60,7 @@ uniform float density_multiplier; uniform float max_y; uniform vec4 glow; +uniform float sun_moon_glow_factor; uniform vec4 cloud_color; @@ -93,7 +96,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; @@ -131,6 +134,8 @@ void main() temp2.x = pow(temp2.x, glow.z); // glow.z should be negative, so we're doing a sort of (1 / "angle") function + temp2.x *= sun_moon_glow_factor; + // Add "minimum anti-solar illumination" temp2.x += .25; @@ -170,7 +175,7 @@ void main() // Texture coords vary_texcoord0 = texcoord0; vary_texcoord0.xy -= 0.5; - vary_texcoord0.xy /= cloud_scale; + vary_texcoord0.xy /= max(0.001, cloud_scale); vary_texcoord0.xy += 0.5; vary_texcoord1 = vary_texcoord0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl index fef1c5a584..079d8458c9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl @@ -50,15 +50,6 @@ uniform vec2 screen_res; VARYING vec2 vary_fragcoord; -float getDepth(vec2 pos_screen) -{ - float z = texture2DRect(depthMap, pos_screen.xy).r; - z = z*2.0-1.0; - vec4 ndc = vec4(0.0, 0.0, z, 1.0); - vec4 p = inv_proj*ndc; - return p.z/p.w; -} - float calc_cof(float depth) { float sc = (depth-focal_distance)/-depth*blur_constant; @@ -77,8 +68,12 @@ float calc_cof(float depth) void main() { vec2 tc = vary_fragcoord.xy; - - float depth = getDepth(tc); + + float z = texture2DRect(depthMap, tc).r; + z = z*2.0-1.0; + vec4 ndc = vec4(0.0, 0.0, z, 1.0); + vec4 p = inv_proj*ndc; + float depth = p.z/p.w; vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy); diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl new file mode 100644 index 0000000000..e27bbce094 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -0,0 +1,79 @@ +/** + * @file class1/deferred/deferredUtil.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform sampler2DRect normalMap; +uniform sampler2DRect depthMap; + +uniform mat4 inv_proj; +uniform vec2 screen_res; + +vec2 getScreenCoordinate(vec2 screenpos) +{ + vec2 sc = screenpos.xy * 2.0; + if (screen_res.x > 0 && screen_res.y > 0) + { + sc /= screen_res; + } + return sc - vec2(1.0, 1.0); +} + +vec3 getNorm(vec2 screenpos) +{ + vec2 enc = texture2DRect(normalMap, screenpos.xy).xy; + vec2 fenc = enc*4-2; + float f = dot(fenc,fenc); + float g = sqrt(1-f/4); + vec3 n; + n.xy = fenc*g; + n.z = 1-f/2; + return n; +} + +float getDepth(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen).r; + return depth; +} + +vec4 getPosition(vec2 pos_screen) +{ + float depth = getDepth(pos_screen); + vec2 sc = getScreenCoordinate(pos_screen); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +vec4 getPositionWithDepth(vec2 pos_screen, float depth) +{ + vec2 sc = getScreenCoordinate(pos_screen); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl index 7930b5d18b..b328ee9483 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -37,11 +39,7 @@ VARYING vec3 vary_normal; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl index 8525e13333..fc5c86b4d6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -36,11 +38,7 @@ uniform float minimum_alpha; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl index 37d70a2412..1bb8eb8bd0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl @@ -23,6 +23,7 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -37,11 +38,7 @@ uniform sampler2D diffuseMap; VARYING vec3 vary_normal; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl index 6befb1bd8b..8319e61242 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl @@ -22,6 +22,8 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ + +/*[EXTRA_CODE_HERE]*/ #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -35,11 +37,7 @@ VARYING vec3 vary_normal; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index adc361d7a2..828c325c9d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -33,12 +35,7 @@ VARYING vec3 vary_normal; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl index 115b04797f..7fec3e03e7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl @@ -36,9 +36,6 @@ void calcAtmospherics(vec3 inPositionEye); vec3 atmosAmbient(vec3 light); vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); - VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 756e625d07..08ddaeceb3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -1,5 +1,5 @@ /** - * @file fullbrightF.glsl + * @file deferred/fullbrightF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -33,7 +33,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if !HAS_DIFFUSE_LOOKUP +#if !defined(HAS_DIFFUSE_LOOKUP) uniform sampler2D diffuseMap; #endif @@ -41,44 +41,10 @@ VARYING vec3 vary_position; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; - -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 color); #endif -} - vec3 fullbrightAtmosTransportDeferred(vec3 light) { return light; @@ -94,55 +60,9 @@ vec3 fullbrightScaleSoftClipDeferred(vec3 light) uniform float minimum_alpha; #endif -#ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} -#endif - void main() { -#if HAS_DIFFUSE_LOOKUP +#ifdef HAS_DIFFUSE_LOOKUP vec4 color = diffuseLookup(vary_texcoord0.xy); #else vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); @@ -158,15 +78,12 @@ void main() #endif color.rgb *= vertex_color.rgb; - color.rgb = srgb_to_linear(color.rgb); color.rgb = fullbrightAtmosTransportDeferred(color.rgb); color.rgb = fullbrightScaleSoftClipDeferred(color.rgb); - color.rgb = linear_to_srgb(color.rgb); - #ifdef WATER_FOG vec3 pos = vary_position; - vec4 fogged = applyWaterFogDeferred(pos, vec4(color.rgb, final_alpha)); + vec4 fogged = applyWaterFogView(pos, vec4(color.rgb, final_alpha)); color.rgb = fogged.rgb; color.a = fogged.a; #else diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl index b0db9876d3..4005d5064d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl @@ -23,7 +23,7 @@ * $/LicenseInfo$ */ - +/*[EXTRA_CODE_HERE]*/ #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; @@ -31,7 +31,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#ifndef diffuseLookup +#ifndef HAS_DIFFUSE_LOOKUP uniform sampler2D diffuseMap; #endif @@ -46,7 +46,7 @@ vec3 fullbrightScaleSoftClip(vec3 light); void main() { -#if HAS_DIFFUSE_LOOKUP +#ifdef HAS_DIFFUSE_LOOKUP vec4 color = diffuseLookup(vary_texcoord0.xy); #else vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl index 8e899e3e0f..816bd0bf3e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl @@ -37,8 +37,6 @@ void calcAtmospherics(vec3 inPositionEye); vec3 atmosAmbient(vec3 light); vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); #ifdef WATER_FOG VARYING vec3 vary_position; diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index f8fdde43f9..d29e8a9423 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -38,42 +40,6 @@ uniform sampler2D specularMap; VARYING vec2 vary_texcoord0; -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - void main() { vec4 col = texture2D(diffuseMap, vary_texcoord0.xy); @@ -86,8 +52,6 @@ void main() vec4 norm = texture2D(normalMap, vary_texcoord0.xy); vec4 spec = texture2D(specularMap, vary_texcoord0.xy); - col.rgb = linear_to_srgb(col.rgb); - frag_data[0] = vec4(col.rgb, 0.0); frag_data[1] = spec; frag_data[2] = vec4(norm.xy,0,0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/indirect.glsl b/indra/newview/app_settings/shaders/class1/deferred/indirect.glsl new file mode 100644 index 0000000000..49bfa660f8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/indirect.glsl @@ -0,0 +1,30 @@ +/** + * @file class1/deferred/indirect.glsl + * + * $LicenseInfo:firstyear=2018&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +vec3 getIndirect(vec3 ambient, vec3 norm, vec3 pos, vec2 pos_screen) +{ + return ambient; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl index dcf474824d..be1003a7e0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl @@ -22,8 +22,8 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - -uniform sampler2DRect diffuseMap; + +/*[EXTRA_CODE_HERE]*/ #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; @@ -31,6 +31,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +uniform sampler2DRect diffuseMap; VARYING vec2 vary_fragcoord; void main() diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 07d28ed4cd..ae2dd24b19 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -23,50 +23,28 @@ * $/LicenseInfo$ */ -#define DIFFUSE_ALPHA_MODE_IGNORE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 +/*[EXTRA_CODE_HERE]*/ + +#define DIFFUSE_ALPHA_MODE_IGNORE 0 +#define DIFFUSE_ALPHA_MODE_BLEND 1 +#define DIFFUSE_ALPHA_MODE_MASK 2 #define DIFFUSE_ALPHA_MODE_EMISSIVE 3 uniform float emissive_brightness; uniform float display_gamma; +uniform int sun_up_factor; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 color); #endif -} +vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); +vec3 scaleSoftClipFrag(vec3 l); -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cs); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -76,404 +54,106 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if HAS_SUN_SHADOW - -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform vec2 shadow_res; -uniform float shadow_bias; - -float pcfShadow(sampler2DShadow shadowMap, vec4 stc) -{ - stc.xyz /= stc.w; - stc.z += shadow_bias; - - stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here - - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - return shadow*0.2; -} - +#ifdef HAS_SUN_SHADOW +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); #endif uniform samplerCube environmentMap; -uniform sampler2D lightFunc; +uniform sampler2D lightFunc; // Inputs uniform vec4 morphFactor; uniform vec3 camPosLocal; //uniform vec4 camPosWorld; uniform vec4 gamma; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 ambient; -uniform vec4 blue_horizon; -uniform vec4 blue_density; -uniform float haze_horizon; -uniform float haze_density; -uniform float cloud_shadow; -uniform float density_multiplier; -uniform float distance_multiplier; -uniform float max_y; -uniform vec4 glow; -uniform float scene_light_strength; uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; VARYING vec2 vary_fragcoord; VARYING vec3 vary_position; -vec3 vary_PositionEye; - -vec3 vary_SunlitColor; -vec3 vary_AmblitColor; -vec3 vary_AdditiveColor; -vec3 vary_AtmosAttenuation; - uniform mat4 inv_proj; uniform vec2 screen_res; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; +uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; -#ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} -#endif - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return vec3(a,a,a); -} - - -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = length(lv); - - float da = 1.0; - - vec3 col = vec3(0,0,0); - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - float dist = d/la; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - - float lit = max(da * dist_atten, 0.0); - - col = light_col*lit*diffuse; - - if (spec.a > 0.0) - { - //vec3 ref = dot(pos+lv, norm); - vec3 h = normalize(lv+npos); - float nh = dot(n, h); - float nv = dot(n, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; - - float gtdenom = 2 * nh; - float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - vec3 speccol = lit*scol*light_col.rgb*spec.rgb; - col += speccol; - - float cur_glare = max(speccol.r, speccol.g); - cur_glare = max(cur_glare, speccol.b); - glare = max(glare, speccol.r); - glare += max(cur_glare, 0.0); - //col += spec.rgb; - } - } - } - - return max(col, vec3(0.0,0.0,0.0)); - -} - -vec4 getPosition_d(vec2 pos_screen, float depth) -{ - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -#ifndef WATER_FOG -vec3 getPositionEye() -{ - return vary_PositionEye; -} -#endif - -vec3 getSunlitColor() -{ - return vary_SunlitColor; -} -vec3 getAmblitColor() -{ - return vary_AmblitColor; -} -vec3 getAdditiveColor() +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance, float shadow) { - return vary_AdditiveColor; -} -vec3 getAtmosAttenuation() -{ - return vary_AtmosAttenuation; -} + //get light vector + vec3 lv = lp.xyz-v; + + //get distance + float d = length(lv); + + float da = 1.0; + + vec3 col = vec3(0,0,0); + + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv = normalize(lv); + + //distance attenuation + float dist = d/la; + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; + + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + + //angular attenuation + da = dot(n, lv); + da *= clamp(da, 0.0, 1.0); + + float lit = max(da * dist_atten, 0.0); + + col = light_col*lit*diffuse; + + float amb_da = ambiance; + amb_da *= dist_atten; + amb_da += (da*0.5) * ambiance; + amb_da += (da*da*0.5 + 0.25) * ambiance; + amb_da = min(amb_da, 1.0f - lit); + + col.rgb += amb_da * light_col * diffuse; + + if (spec.a > 0.0) + { + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(n, h); + float nv = dot(n, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + vec3 speccol = lit*scol*light_col.rgb*spec.rgb; + col += speccol; + + float cur_glare = max(speccol.r, speccol.g); + cur_glare = max(cur_glare, speccol.b); + glare = max(glare, speccol.r); + glare += max(cur_glare, 0.0); + } + } + } + + return max(col, vec3(0.0,0.0,0.0)); -void setPositionEye(vec3 v) -{ - vary_PositionEye = v; -} - -void setSunlitColor(vec3 v) -{ - vary_SunlitColor = v; -} - -void setAmblitColor(vec3 v) -{ - vary_AmblitColor = v; -} - -void setAdditiveColor(vec3 v) -{ - vary_AdditiveColor = v; -} - -void setAtmosAttenuation(vec3 v) -{ - vary_AtmosAttenuation = v; -} - -void calcAtmospherics(vec3 inPositionEye, float ambFactor) { - - vec3 P = inPositionEye; - setPositionEye(P); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = sunlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); - */ - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - - //haze color - setAdditiveColor( - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient))); - - //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); -} - -vec3 atmosLighting(vec3 light) -{ - light *= getAtmosAttenuation().r; - light += getAdditiveColor(); - return (2.0 * light); -} - -vec3 atmosTransport(vec3 light) { - light *= getAtmosAttenuation().r; - light += getAdditiveColor() * 2.0; - return light; -} -vec3 atmosGetDiffuseSunlightColor() -{ - return getSunlitColor(); -} - -vec3 scaleDownLight(vec3 light) -{ - return (light / vec3(scene_light_strength, scene_light_strength, scene_light_strength)); -} - -vec3 scaleUpLight(vec3 light) -{ - return (light * vec3(scene_light_strength, scene_light_strength, scene_light_strength)); -} - -vec3 atmosAmbient(vec3 light) -{ - return getAmblitColor() + (light * vec3(0.5f, 0.5f, 0.5f)); -} - -vec3 atmosAffectDirectionalLight(float lightIntensity) -{ - return getSunlitColor() * vec3(lightIntensity, lightIntensity, lightIntensity); -} - -vec3 scaleSoftClip(vec3 light) -{ - //soft clip effect: - vec3 zeroes = vec3(0.0f, 0.0f, 0.0f); - vec3 ones = vec3(1.0f, 1.0f, 1.0f); - - light = ones - clamp(light, zeroes, ones); - light = ones - pow(light, gamma.xxx); - - return light; -} - -vec3 fullbrightAtmosTransport(vec3 light) { - float brightness = dot(light.rgb, vec3(0.33333)); - - return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); -} - -vec3 fullbrightScaleSoftClip(vec3 light) -{ - //soft clip effect: - return light; } #else @@ -486,11 +166,11 @@ out vec4 frag_data[3]; uniform sampler2D diffuseMap; -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP uniform sampler2D bumpMap; #endif -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP uniform sampler2D specularMap; VARYING vec2 vary_texcoord2; @@ -503,7 +183,7 @@ uniform vec4 specular_color; // specular color RGB and specular exponent (gloss uniform float minimum_alpha; #endif -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP VARYING vec3 vary_mat0; VARYING vec3 vary_mat1; VARYING vec3 vary_mat2; @@ -515,274 +195,195 @@ VARYING vec3 vary_normal; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} +vec2 encode_normal(vec3 n); void main() { - vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy); - diffcol.rgb *= vertex_color.rgb; + vec2 pos_screen = vary_texcoord0.xy; + + vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy); + diffcol.rgb *= vertex_color.rgb; #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) - if (diffcol.a < minimum_alpha) - { - discard; - } + if (diffcol.a < minimum_alpha) + { + discard; + } #endif #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - vec3 gamma_diff = diffcol.rgb; - diffcol.rgb = srgb_to_linear(diffcol.rgb); + vec3 gamma_diff = diffcol.rgb; #endif -#if HAS_SPECULAR_MAP - vec4 spec = texture2D(specularMap, vary_texcoord2.xy); - spec.rgb *= specular_color.rgb; +#ifdef HAS_SPECULAR_MAP + vec4 spec = texture2D(specularMap, vary_texcoord2.xy); + spec.rgb *= specular_color.rgb; #else - vec4 spec = vec4(specular_color.rgb, 1.0); + vec4 spec = vec4(specular_color.rgb, 1.0); #endif -#if HAS_NORMAL_MAP - vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); +#ifdef HAS_NORMAL_MAP + vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); - norm.xyz = norm.xyz * 2 - 1; + norm.xyz = norm.xyz * 2 - 1; - vec3 tnorm = vec3(dot(norm.xyz,vary_mat0), - dot(norm.xyz,vary_mat1), - dot(norm.xyz,vary_mat2)); + vec3 tnorm = vec3(dot(norm.xyz,vary_mat0), + dot(norm.xyz,vary_mat1), + dot(norm.xyz,vary_mat2)); #else - vec4 norm = vec4(0,0,0,1.0); - vec3 tnorm = vary_normal; + vec4 norm = vec4(0,0,0,1.0); + vec3 tnorm = vary_normal; #endif norm.xyz = tnorm; norm.xyz = normalize(norm.xyz); - vec2 abnormal = encode_normal(norm.xyz); - norm.xyz = decode_normal(abnormal.xy); + vec2 abnormal = encode_normal(norm.xyz); - vec4 final_color = diffcol; - + vec4 final_color = diffcol; + #if (DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE) - final_color.a = emissive_brightness; + final_color.a = emissive_brightness; #else - final_color.a = max(final_color.a, emissive_brightness); + final_color.a = max(final_color.a, emissive_brightness); #endif - vec4 final_specular = spec; -#if HAS_SPECULAR_MAP - vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity * spec.a, 0.0); - final_specular.a = specular_color.a * norm.a; + vec4 final_specular = spec; +#ifdef HAS_SPECULAR_MAP + vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity * spec.a, 0.0); + final_specular.a = specular_color.a * norm.a; #else - vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity, 0.0); - final_specular.a = specular_color.a; + vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity, 0.0); + final_specular.a = specular_color.a; #endif - + #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - //forward rendering, output just lit RGBA - vec3 pos = vary_position; - -#if HAS_SUN_SHADOW - float shadow = 0.0; - - vec4 spos = vec4(pos,1.0); - - if (spos.z > -shadow_clip.w) - { - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadow(shadowMap0, lpos)*w; - weight += w; - } - - - shadow /= weight; - } - else - { - shadow = 1.0; - } -#else - float shadow = 1.0; -#endif + //forward rendering, output just lit RGBA + vec3 pos = vary_position; - spec = final_specular; - vec4 diffuse = final_color; - float envIntensity = final_normal.z; + float shadow = 1.0f; - vec3 col = vec3(0.0f,0.0f,0.0f); +#ifdef HAS_SUN_SHADOW + shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, pos_screen); +#endif + + spec = final_specular; + vec4 diffuse = final_color; - float bloom = 0.0; - calcAtmospherics(pos.xyz, 1.0); - - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + diffuse.rgb = srgb_to_linear(diffuse.rgb); - float da =dot(norm.xyz, sun_dir.xyz); + float envIntensity = final_normal.z; - float final_da = da; - final_da = min(final_da, shadow); - //final_da = max(final_da, diffuse.a); - final_da = max(final_da, 0.0f); - final_da = min(final_da, 1.0f); - final_da = pow(final_da, 1.0/1.3); + vec3 col = vec3(0.0f,0.0f,0.0f); - col.rgb = atmosAmbient(col); - - float ambient = min(abs(da), 1.0); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); + float bloom = 0.0; + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; - col.rgb *= ambient; + calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); - col.rgb = col.rgb + atmosAffectDirectionalLight(final_da); + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - col.rgb *= gamma_diff.rgb; - + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float glare = 0.0; + float da = dot(norm.xyz, light_dir.xyz); + da = clamp(da, 0.0, 1.0); + da = pow(da, 1.0 / 1.3); - if (spec.a > 0.0) // specular reflection - { - // the old infinite-sky shiny reflection - // - - float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*shadow*(texture2D(lightFunc, vec2(sa, spec.a)).r); - - // add the two types of shiny together - vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib) / 6; + float ambient = abs(da); + ambient *= 0.5; + ambient *= ambient; + ambient = 1.0 - ambient; - glare = max(spec_contrib.r, spec_contrib.g); - glare = max(glare, spec_contrib.b); + float final_da = min(da, shadow); + vec3 sun_contrib = final_da * sunlit; + + col.rgb = amblit; + col.rgb *= ambient; + col.rgb += sun_contrib; + col.rgb *= diffuse.rgb; + + float glare = 0.0; - col += spec_contrib; - } + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + // + + float sa = dot(refnormpersp, light_dir.xyz); + vec3 dumbshiny = sunlit*shadow*(texture2D(lightFunc, vec2(sa, spec.a)).r); + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib) / 6; - col = mix(col.rgb, diffcol.rgb, diffuse.a); + glare = max(spec_contrib.r, spec_contrib.g); + glare = max(glare, spec_contrib.b); - if (envIntensity > 0.0) - { - //add environmentmap - vec3 env_vec = env_mat * refnormpersp; - - vec3 refcol = textureCube(environmentMap, env_vec).rgb; + col += spec_contrib; + } - col = mix(col.rgb, refcol, - envIntensity); +vec3 post_spec = col.rgb; - float cur_glare = max(refcol.r, refcol.g); - cur_glare = max(cur_glare, refcol.b); - cur_glare *= envIntensity*4.0; - glare += cur_glare; - } + col = mix(col.rgb, diffuse.rgb, diffuse.a); - //col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - //col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + if (envIntensity > 0.0) + { + //add environmentmap + vec3 env_vec = env_mat * refnormpersp; + + vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = atmosLighting(col); - col = scaleSoftClip(col); + col = mix(col.rgb, refcol, + envIntensity); - //convert to linear space before adding local lights - col = srgb_to_linear(col); + float cur_glare = max(refcol.r, refcol.g); + cur_glare = max(cur_glare, refcol.b); + cur_glare *= envIntensity*4.0; + glare += cur_glare; + } - vec3 npos = normalize(-pos.xyz); - - vec3 light = vec3(0,0,0); + col = atmosFragLighting(col, additive, atten); + col = scaleSoftClipFrag(col); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare); + vec3 npos = normalize(-pos.xyz); + + vec3 light = vec3(0,0,0); - LIGHT_LOOP(1) - LIGHT_LOOP(2) - LIGHT_LOOP(3) - LIGHT_LOOP(4) - LIGHT_LOOP(5) - LIGHT_LOOP(6) - LIGHT_LOOP(7) + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w, shadow); - col.rgb += light.rgb; + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) - glare = min(glare, 1.0); - float al = max(diffcol.a,glare)*vertex_color.a; + col.rgb += light.rgb; - //convert to gamma space for display on screen - col.rgb = linear_to_srgb(col.rgb); + glare = min(glare, 1.0); + float al = max(diffcol.a,glare)*vertex_color.a; #ifdef WATER_FOG - vec4 temp = applyWaterFogDeferred(pos, vec4(col.rgb, al)); - col.rgb = temp.rgb; - al = temp.a; + vec4 temp = applyWaterFogView(pos, vec4(col.rgb, al)); + col.rgb = temp.rgb; + al = temp.a; #endif - frag_color.rgb = col.rgb; - frag_color.a = al; + col.rgb = linear_to_srgb(col.rgb); + + frag_color.rgb = col.rgb; + frag_color.a = al; #else - frag_data[0] = final_color; - frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. - frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. + frag_data[0] = final_color; + frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. + frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. #endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index 393d1e69da..7e29ada205 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -28,7 +28,7 @@ #define DIFFUSE_ALPHA_MODE_MASK 2 #define DIFFUSE_ALPHA_MODE_EMISSIVE 3 -#if HAS_SKIN +#ifdef HAS_SKIN uniform mat4 modelview_matrix; uniform mat4 projection_matrix; mat4 getObjectSkinnedTransform(); @@ -39,7 +39,7 @@ uniform mat4 modelview_projection_matrix; #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) -#if !HAS_SKIN +#if !defined(HAS_SKIN) uniform mat4 modelview_matrix; #endif @@ -55,7 +55,7 @@ ATTRIBUTE vec3 normal; ATTRIBUTE vec2 texcoord0; -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP ATTRIBUTE vec4 tangent; ATTRIBUTE vec2 texcoord1; @@ -68,7 +68,7 @@ VARYING vec2 vary_texcoord1; VARYING vec3 vary_normal; #endif -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP ATTRIBUTE vec2 texcoord2; VARYING vec2 vary_texcoord2; #endif @@ -78,7 +78,7 @@ VARYING vec2 vary_texcoord0; void main() { -#if HAS_SKIN +#ifdef HAS_SKIN mat4 mat = getObjectSkinnedTransform(); mat = modelview_matrix * mat; @@ -99,17 +99,17 @@ void main() vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; #endif -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; #endif -#if HAS_SKIN +#ifdef HAS_SKIN vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz); -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); vec3 b = cross(n, t)*tangent.w; @@ -121,7 +121,7 @@ vary_normal = n; #endif //HAS_NORMAL_MAP #else //HAS_SKIN vec3 n = normalize(normal_matrix * normal); -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP vec3 t = normalize(normal_matrix * tangent.xyz); vec3 b = cross(n,t)*tangent.w; //vec3 t = cross(b,n) * binormal.w; @@ -137,7 +137,7 @@ vary_normal = n; vertex_color = diffuse_color; #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) -#if !HAS_SKIN +#if !defined(HAS_SKIN) vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; #endif #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl new file mode 100644 index 0000000000..d964ce8eee --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -0,0 +1,69 @@ +/** + * @file moonF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +uniform vec4 color; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform vec3 lumWeights; +uniform float moon_brightness; +uniform float minLuminance; +uniform sampler2D diffuseMap; +uniform sampler2D altDiffuseMap; +uniform float blend_factor; // interp factor between moon A/B +VARYING vec2 vary_texcoord0; + +void main() +{ + vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); + vec4 c = mix(moonA, moonB, blend_factor); + + // mix factor which blends when sunlight is brighter + // and shows true moon color at night + vec3 luma_weights = vec3(0.2, 0.3, 0.2); + + float mix = 1.0 - dot(normalize(sunlight_color.rgb), luma_weights); + + vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; + c.rgb = pow(c.rgb, exp); + //c.rgb *= moonlight_color.rgb; + + frag_data[0] = vec4(c.rgb, c.a); + frag_data[1] = vec4(0.0); + frag_data[2] = vec4(0.0f); + + gl_FragDepth = 0.9996f; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl new file mode 100644 index 0000000000..e1bac4f248 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl @@ -0,0 +1,49 @@ +/** + * @file moonV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_matrix; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; + +void calcAtmospherics(vec3 eye_pos); + +void main() +{ + //transform vertex + vec3 offset = vec3(0, 0, 50); + vec4 vert = vec4(position.xyz - offset, 1.0); + vec4 pos = (modelview_matrix * vert); + + gl_Position = modelview_projection_matrix*vert; + + calcAtmospherics(pos.xyz); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 9974f8f31b..29298d7c07 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -36,7 +36,6 @@ out vec4 frag_color; uniform sampler2DRect depthMap; uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; -uniform sampler2DRect normalMap; uniform samplerCube environmentMap; uniform sampler2D noiseMap; uniform sampler2D lightFunc; @@ -57,35 +56,8 @@ uniform float far_z; uniform mat4 inv_proj; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); +vec3 getNorm(vec2 pos_screen); void main() { @@ -96,9 +68,8 @@ void main() discard; } - vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = decode_normal(norm.xy); // unpack norm - norm = normalize(norm); + vec3 norm = getNorm(frag.xy); + vec4 spec = texture2DRect(specularRect, frag.xy); vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 3a3e871ade..2569e49743 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -30,14 +30,14 @@ #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else #define frag_color gl_FragColor #endif -/*[EXTRA_CODE_HERE]*/ - uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect depthMap; @@ -71,65 +71,11 @@ VARYING vec4 vary_fragcoord; uniform vec2 screen_res; uniform mat4 inv_proj; - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - +vec3 getNorm(vec2 pos_screen); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -149,7 +95,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -167,7 +112,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = tc-vec2(0.5); @@ -178,19 +122,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) return ret; } - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); void main() { @@ -208,12 +140,9 @@ void main() discard; } - vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - float envIntensity = norm.z; + float envIntensity = texture2DRect(normalMap, frag.xy).z; + vec3 norm = getNorm(frag.xy); - norm = decode_normal(norm.xy); - - norm = normalize(norm); float l_dist = -dot(lv, proj_n); vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index aba4a01754..f8264d971c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -56,103 +56,75 @@ uniform vec2 screen_res; uniform mat4 inv_proj; uniform vec4 viewport; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = (pos_screen.xy-viewport.xy)*2.0; - sc /= viewport.zw; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec3 getNorm(vec2 pos_screen); +vec4 getPosition(vec2 pos_screen); void main() { - vec4 frag = vary_fragcoord; - frag.xyz /= frag.w; - frag.xyz = frag.xyz*0.5+0.5; - frag.xy *= screen_res; - - vec3 pos = getPosition(frag.xy).xyz; - vec3 lv = trans_center.xyz-pos; - float dist = length(lv); - dist /= size; - if (dist > 1.0) - { - discard; - } - - vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = decode_normal(norm.xy); // unpack norm - float da = dot(norm, lv); - if (da < 0.0) - { - discard; - } - - norm = normalize(norm); - lv = normalize(lv); - da = dot(norm, lv); - - float noise = texture2D(noiseMap, frag.xy/128.0).b; - - vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = falloff+1.0; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; - - float lit = da * dist_atten * noise; - - col = color.rgb*lit*col; - - vec4 spec = texture2DRect(specularRect, frag.xy); - if (spec.a > 0.0) - { - lit = min(da*6.0, 1.0) * dist_atten; - - vec3 npos = -normalize(pos); - vec3 h = normalize(lv+npos); - float nh = dot(norm, h); - float nv = dot(norm, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5; - float gtdenom = 2 * nh; - float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); - - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb; - } - } - - if (dot(col, col) <= 0.0) - { - discard; - } - - frag_color.rgb = col; - frag_color.a = 0.0; + vec4 frag = vary_fragcoord; + frag.xyz /= frag.w; + frag.xyz = frag.xyz*0.5+0.5; + frag.xy *= screen_res; + + vec3 pos = getPosition(frag.xy).xyz; + vec3 lv = trans_center.xyz-pos; + float dist = length(lv); + dist /= size; + if (dist > 1.0) + { + discard; + } + + vec3 norm = getNorm(frag.xy); + + float da = dot(norm, lv); + if (da < 0.0) + { + discard; + } + + lv = normalize(lv); + da = dot(norm, lv); + + float noise = texture2D(noiseMap, frag.xy/128.0).b; + + vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; + float fa = falloff+1.0; + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; + + float lit = da * dist_atten * noise; + + col = color.rgb*lit*col; + + vec4 spec = texture2DRect(specularRect, frag.xy); + if (spec.a > 0.0) + { + lit = min(da*6.0, 1.0) * dist_atten; + + vec3 npos = -normalize(pos); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5; + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*color.rgb*spec.rgb; + } + } + + if (dot(col, col) <= 0.0) + { + discard; + } + + frag_color.rgb = col; + frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl index a5625fbc16..3da8531442 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl @@ -1,5 +1,5 @@ /** - * @file pointLightF.glsl + * @file pointLightV.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 6669947d1b..058e939ec8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -40,30 +40,12 @@ VARYING vec2 vary_fragcoord; uniform float display_gamma; -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - +vec3 linear_to_srgb(vec3 cl); void main() { - vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); - diff.rgb = linear_to_srgb(diff.rgb); - frag_color = diff; + vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); + diff.rgb = linear_to_srgb(diff.rgb); + frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl index 018ced4cad..cf994d3547 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -47,18 +49,7 @@ VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl new file mode 100644 index 0000000000..44f2a73e1f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl @@ -0,0 +1,55 @@ +/** + * @file shadowAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING float pos_w; + +VARYING float target_pos_x; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a; + + frag_color = vec4(alpha, alpha, alpha, 1); + +#if !defined(DEPTH_CLAMP) + gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); +#endif +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl new file mode 100644 index 0000000000..f45c343066 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl @@ -0,0 +1,67 @@ +/** + * @file shadowAlphaMaskV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING float pos_w; + +VARYING float target_pos_x; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void passTextureIndex(); + +void main() +{ + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + vec4 pos = modelview_projection_matrix * pre_pos; + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + + pos_w = pos.w; + +#if !defined(DEPTH_CLAMP) + pos_zd2 = pos.z * 0.5; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + + passTextureIndex(); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + vertex_color = diffuse_color; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl index 91a96977f0..1791d3e315 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -31,7 +33,7 @@ out vec4 frag_color; uniform sampler2D diffuseMap; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) VARYING float pos_zd2; #endif @@ -60,7 +62,7 @@ void main() frag_color = vec4(1,1,1,1); -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); #endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl index 11411a605c..f45c343066 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl @@ -31,7 +31,7 @@ ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec2 texcoord0; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) VARYING float pos_zd2; #endif @@ -52,7 +52,7 @@ void main() pos_w = pos.w; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) pos_zd2 = pos.z * 0.5; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl index ef153dfc5b..0e74d2eb8a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowCubeV.glsl @@ -27,7 +27,7 @@ uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) VARYING vec4 post_pos; #endif @@ -40,7 +40,7 @@ void main() vec3 p = position*box_size+box_center; vec4 pos = modelview_projection_matrix*vec4(p.xyz, 1.0); -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) post_pos = pos; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl index 3d1b182875..22d42d38c1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl @@ -23,13 +23,15 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else #define frag_color gl_FragColor #endif -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) VARYING vec4 post_pos; #endif @@ -37,7 +39,7 @@ void main() { frag_color = vec4(1,1,1,1); -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl new file mode 100644 index 0000000000..6ff49c7dac --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -0,0 +1,203 @@ +/** + * @file class1/deferred/shadowUtil.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform sampler2DRect normalMap; +uniform sampler2DRect depthMap; +uniform sampler2DShadow shadowMap0; +uniform sampler2DShadow shadowMap1; +uniform sampler2DShadow shadowMap2; +uniform sampler2DShadow shadowMap3; +uniform sampler2DShadow shadowMap4; +uniform sampler2DShadow shadowMap5; + +uniform vec3 sun_dir; +uniform vec3 moon_dir; +uniform vec2 shadow_res; +uniform vec2 proj_shadow_res; +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform float shadow_bias; +uniform float shadow_offset; +uniform float spot_shadow_bias; +uniform float spot_shadow_offset; +uniform mat4 inv_proj; +uniform vec2 screen_res; +uniform int sun_up_factor; + +float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) +{ + stc.xyz /= stc.w; + stc.z += shadow_bias * bias_mul * 2.0; + stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here + + float cs = shadow2D(shadowMap, stc.xyz).x; + float shadow = cs * 4.0; + + shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; + + return shadow * 0.125; +} + +float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen) +{ + stc.xyz /= stc.w; + stc.z += spot_shadow_bias * bias_scale; + stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap + + float cs = shadow2D(shadowMap, stc.xyz).x; + float shadow = cs; + + vec2 off = 1.0/proj_shadow_res; + off.y *= 1.5; + + shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x*2.0, off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x*2.0, -off.y, 0.0)).x; + return shadow*0.2; +} +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) +{ + float shadow = 0.0f; + vec3 light_dir = normalize((sun_up_factor == 1) ? sun_dir : moon_dir); + + float dp_directional_light = max(0.0, dot(norm.xyz, light_dir)); + dp_directional_light = clamp(dp_directional_light, 0.0, 1.0); + + vec3 shadow_pos = pos.xyz; + + vec3 offset = light_dir.xyz * (1.0 - dp_directional_light); + + shadow_pos += offset * shadow_offset; + + vec4 spos = vec4(shadow_pos.xyz, 1.0); + + if (spos.z > -shadow_clip.w) + { + vec4 lpos; + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + vec4 transition_domain = near_split-far_split; + float weight = 0.0; + + if (spos.z < near_split.z) + { + lpos = shadow_matrix[3]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap3, norm, lpos, 1.0, pos_screen, light_dir)*w; + weight += w; + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + + if (spos.z < near_split.y && spos.z > far_split.z) + { + lpos = shadow_matrix[2]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; + w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap2, norm, lpos, 1.0, pos_screen, light_dir)*w; + weight += w; + } + + if (spos.z < near_split.x && spos.z > far_split.y) + { + lpos = shadow_matrix[1]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; + w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; + shadow += pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w; + weight += w; + } + + if (spos.z > far_split.x) + { + lpos = shadow_matrix[0]*spos; + + float w = 1.0; + w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; + + shadow += pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w; + weight += w; + } + + shadow /= weight; + } + else + { + return 1.0f; // lit beyond the far split... + } + //shadow = min(dp_directional_light,shadow); + return shadow; +} + +float sampleSpotShadow(vec3 pos, vec3 norm, int index, vec2 pos_screen) +{ + float shadow = 0.0f; + pos += norm * spot_shadow_offset; + + vec4 spos = vec4(pos,1.0); + if (spos.z > -shadow_clip.w) + { + vec4 lpos; + + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + vec4 transition_domain = near_split-far_split; + float weight = 0.0; + + { + float w = 1.0; + w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; + + if (index == 0) + { + lpos = shadow_matrix[4]*spos; + shadow += pcfSpotShadow(shadowMap4, lpos, 0.8, spos.xy)*w; + } + else + { + lpos = shadow_matrix[5]*spos; + shadow += pcfSpotShadow(shadowMap5, lpos, 0.8, spos.xy)*w; + } + weight += w; + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + + shadow /= weight; + } + else + { + shadow = 1.0f; + } + return shadow; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl index cc77a4cea0..41a89fb8b4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl @@ -27,7 +27,7 @@ uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) VARYING vec4 post_pos; #endif @@ -36,7 +36,7 @@ void main() //transform vertex vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0); -#if !DEPTH_CLAMP +#if !defined(DEPTH_CLAMP) post_pos = pos; gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl index 22f4729e2e..f8172cae17 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl @@ -1,5 +1,5 @@ /** - * @file WLSkyF.glsl + * @file class1/deferred/skyF.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -35,32 +37,27 @@ out vec4 frag_data[3]; VARYING vec4 vary_HazeColor; -uniform sampler2D cloud_noise_texture; uniform vec4 gamma; /// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); - - return light; -} +vec3 scaleSoftClip(vec3 light); void main() { - // Potential Fill-rate optimization. Add cloud calculation - // back in and output alpha of 0 (so that alpha culling kills - // the fragment) if the sky wouldn't show up because the clouds - // are fully opaque. + // Potential Fill-rate optimization. Add cloud calculation + // back in and output alpha of 0 (so that alpha culling kills + // the fragment) if the sky wouldn't show up because the clouds + // are fully opaque. + + vec4 color; + color = vary_HazeColor; + color *= 2.; - vec4 color; - color = vary_HazeColor; - color *= 2.; + /// Gamma correct for WL (soft clip effect). + frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0); + frag_data[1] = vec4(0.0,0.0,0.0,0.0); + frag_data[2] = vec4(0.5,0.5,0.0,1.0); //1.0 in norm.w masks off fog - /// Gamma correct for WL (soft clip effect). - frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0); - frag_data[1] = vec4(0.0,0.0,0.0,0.0); - frag_data[2] = vec4(0.5,0.5,0.0,1.0); //1.0 in norm.w masks off fog + gl_FragDepth = 0.999f; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 7c02d31d43..83dd9da091 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -39,6 +39,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -82,7 +84,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 03bdb754b5..a39a73f1b6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -1,5 +1,5 @@ /** - * @file softenLightF.glsl + * @file class1/deferred/softenLightF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -41,7 +41,7 @@ uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; uniform samplerCube environmentMap; -uniform sampler2D lightFunc; +uniform sampler2D lightFunc; uniform float blur_size; uniform float blur_fidelity; @@ -51,427 +51,111 @@ uniform vec4 morphFactor; uniform vec3 camPosLocal; //uniform vec4 camPosWorld; uniform vec4 gamma; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 ambient; -uniform vec4 blue_horizon; -uniform vec4 blue_density; -uniform float haze_horizon; -uniform float haze_density; -uniform float cloud_shadow; -uniform float density_multiplier; -uniform float distance_multiplier; -uniform float max_y; -uniform vec4 glow; uniform float global_gamma; -uniform float scene_light_strength; uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; +uniform int sun_up_factor; VARYING vec2 vary_fragcoord; -vec3 vary_PositionEye; - -vec3 vary_SunlitColor; -vec3 vary_AmblitColor; -vec3 vary_AdditiveColor; -vec3 vary_AtmosAttenuation; - uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 getPosition_d(vec2 pos_screen, float depth) -{ - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -vec4 getPosition(vec2 pos_screen) -{ //get position in screen space (world units) given window coordinate and depth map - float depth = texture2DRect(depthMap, pos_screen.xy).a; - return getPosition_d(pos_screen, depth); -} - -vec3 getPositionEye() -{ - return vary_PositionEye; -} -vec3 getSunlitColor() -{ - return vary_SunlitColor; -} -vec3 getAmblitColor() -{ - return vary_AmblitColor; -} -vec3 getAdditiveColor() -{ - return vary_AdditiveColor; -} -vec3 getAtmosAttenuation() -{ - return vary_AtmosAttenuation; -} - -void setPositionEye(vec3 v) -{ - vary_PositionEye = v; -} - -void setSunlitColor(vec3 v) -{ - vary_SunlitColor = v; -} - -void setAmblitColor(vec3 v) -{ - vary_AmblitColor = v; -} - -void setAdditiveColor(vec3 v) -{ - vary_AdditiveColor = v; -} - -void setAtmosAttenuation(vec3 v) -{ - vary_AtmosAttenuation = v; -} - - #ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} +vec4 applyWaterFogView(vec3 pos, vec4 color); #endif -void calcAtmospherics(vec3 inPositionEye, float ambFactor) { +vec3 getNorm(vec2 pos_screen); +vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); +vec3 fullbrightAtmosTransportFrag(vec3 l, vec3 additive, vec3 atten); - vec3 P = inPositionEye; - setPositionEye(P); - - vec3 tmpLightnorm = lightnorm.xyz; +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); - vec3 Pn = normalize(P); - float Plen = length(P); +vec3 scaleSoftClip(vec3 l); +vec3 fullbrightScaleSoftClip(vec3 l); - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = sunlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); - */ - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - - //haze color - setAdditiveColor( - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient))); - - //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); -} - -vec3 atmosLighting(vec3 light) -{ - light *= getAtmosAttenuation().r; - light += getAdditiveColor(); - return (2.0 * light); -} - -vec3 atmosTransport(vec3 light) { - light *= getAtmosAttenuation().r; - light += getAdditiveColor() * 2.0; - return light; -} - -vec3 fullbrightAtmosTransport(vec3 light) { - float brightness = dot(light.rgb, vec3(0.33333)); - - return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); -} - - - -vec3 atmosGetDiffuseSunlightColor() -{ - return getSunlitColor(); -} - -vec3 scaleDownLight(vec3 light) -{ - return (light / scene_light_strength ); -} - -vec3 scaleUpLight(vec3 light) -{ - return (light * scene_light_strength); -} - -vec3 atmosAmbient(vec3 light) -{ - return getAmblitColor() + light / 2.0; -} - -vec3 atmosAffectDirectionalLight(float lightIntensity) -{ - return getSunlitColor() * lightIntensity; -} - -vec3 scaleSoftClip(vec3 light) -{ - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); - - return light; -} - - -vec3 fullbrightScaleSoftClip(vec3 light) -{ - //soft clip effect: - return light; -} +vec4 getPositionWithDepth(vec2 pos_screen, float depth); void main() { - vec2 tc = vary_fragcoord.xy; - float depth = texture2DRect(depthMap, tc.xy).r; - vec3 pos = getPosition_d(tc, depth).xyz; - vec4 norm = texture2DRect(normalMap, tc); - float envIntensity = norm.z; - norm.xyz = decode_normal(norm.xy); // unpack norm - - float da = dot(norm.xyz, sun_dir.xyz); - - float final_da = max(0.0,da); - final_da = min(final_da, 1.0f); - final_da = pow(final_da, 1.0/1.3); - - vec4 diffuse = texture2DRect(diffuseRect, tc); - - //convert to gamma space - diffuse.rgb = linear_to_srgb(diffuse.rgb); - - vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - vec3 col; - float bloom = 0.0; - { - calcAtmospherics(pos.xyz, 1.0); - - col = atmosAmbient(vec3(0)); - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); - - col.rgb *= ambient; - - col += atmosAffectDirectionalLight(final_da); - - col *= diffuse.rgb; - - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - - if (spec.a > 0.0) // specular reflection - { - // the old infinite-sky shiny reflection - // - - float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*(texture2D(lightFunc, vec2(sa, spec.a)).r); - - // add the two types of shiny together - vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib) / 6; - col += spec_contrib; - } - - - col = mix(col.rgb, diffuse.rgb, diffuse.a); - - if (envIntensity > 0.0) - { //add environmentmap - vec3 env_vec = env_mat * refnormpersp; - - - vec3 refcol = textureCube(environmentMap, env_vec).rgb; - - col = mix(col.rgb, refcol, - envIntensity); - } - - if (norm.w < 0.5) - { - col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); - } - - #ifdef WATER_FOG - vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); - col = fogged.rgb; - bloom = fogged.a; - #endif - - col = srgb_to_linear(col); - - //col = vec3(1,0,1); - //col.g = envIntensity; - } - - frag_color.rgb = col.rgb; - frag_color.a = bloom; + vec2 tc = vary_fragcoord.xy; + float depth = texture2DRect(depthMap, tc.xy).r; + vec4 pos = getPositionWithDepth(tc, depth); + vec4 norm = texture2DRect(normalMap, tc); + float envIntensity = norm.z; + norm.xyz = getNorm(tc); + + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + + float da = dot(normalize(norm.xyz), light_dir.xyz); + da = clamp(da, 0.0, 1.0); + + float light_gamma = 1.0/1.3; + da = pow(da, light_gamma); + + vec4 diffuse = texture2DRect(diffuseRect, tc); + + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); + vec3 col; + float bloom = 0.0; + { + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; + + calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); + + float ambient = min(abs(da), 1.0); + ambient *= 0.5; + ambient *= ambient; + ambient = 1.0 - ambient; + + vec3 sun_contrib = da * sunlit; + + col.rgb = amblit; + col.rgb *= ambient; + col.rgb += sun_contrib; + col.rgb *= diffuse.rgb; + + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + float sa = dot(refnormpersp, light_dir.xyz); + vec3 dumbshiny = sunlit*(texture2D(lightFunc, vec2(sa, spec.a)).r); + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib) / 6; + col += spec_contrib; + } + + col = mix(col.rgb, diffuse.rgb, diffuse.a); + + if (envIntensity > 0.0) + { //add environmentmap + vec3 env_vec = env_mat * refnormpersp; + vec3 refcol = textureCube(environmentMap, env_vec).rgb; + col = mix(col.rgb, refcol, envIntensity); + } + + if (norm.w < 0.5) + { + col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + } + + #ifdef WATER_FOG + vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + } + + frag_color.rgb = col.rgb; + frag_color.a = bloom; } - diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl index b59fcbe017..e992776cb4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl @@ -1,5 +1,5 @@ /** - * @file softenLightF.glsl + * @file softenLightV.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index f1aec315cc..d09bc25334 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -70,69 +70,11 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - -vec4 correctWithGamma(vec4 col) -{ - return vec4(srgb_to_linear(col.rgb), col.a); -} +vec3 getNorm(vec2 pos_screen); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -152,7 +94,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -170,7 +111,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -181,19 +121,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) return ret; } - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); void main() { @@ -214,7 +142,7 @@ void main() vec3 norm = texture2DRect(normalMap, frag.xy).xyz; float envIntensity = norm.z; - norm = decode_normal(norm.xy); + norm = getNorm(frag.xy); norm = normalize(norm); float l_dist = -dot(lv, proj_n); diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 821058804c..8a98d6a489 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -31,14 +33,35 @@ out vec4 frag_data[3]; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +VARYING vec2 screenpos; uniform sampler2D diffuseMap; +uniform sampler2D altDiffuseMap; +uniform float blend_factor; +uniform float custom_alpha; +uniform float time; + +float twinkle(){ + float d = fract(screenpos.x + screenpos.y); + return abs(d); +} void main() { - vec4 col = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy); - - frag_data[0] = col; - frag_data[1] = vec4(0,0,0,0); - frag_data[2] = vec4(0,0,1,0); + vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 col = mix(col_b, col_a, blend_factor); + col.rgb *= vertex_color.rgb; + + float factor = smoothstep(0.0f, 0.9f, custom_alpha); + + col.a = (col.a * factor) * 32.0f; + col.a *= twinkle(); + + frag_data[0] = col; + frag_data[1] = vec4(0.0f); + frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); + + gl_FragDepth = 0.9998; } + diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl index 8bc5b06379..bb2a2ee72b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl @@ -25,6 +25,7 @@ uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; +uniform float time; ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; @@ -32,11 +33,20 @@ ATTRIBUTE vec2 texcoord0; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +VARYING vec2 screenpos; void main() { //transform vertex - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vec4 pos = modelview_projection_matrix * vec4(position, 1.0); + +// bias z to fix SL-9806 and get stars to depth test against clouds + pos.z += 0.001f; + + gl_Position = pos; + + float t = mod(time, 1.25f); + screenpos = position.xy * vec2(t, t); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; vertex_color = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl new file mode 100644 index 0000000000..1fb337498c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl @@ -0,0 +1,64 @@ +/** + * @file sunDiscF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +uniform sampler2D diffuseMap; +uniform sampler2D altDiffuseMap; +uniform float blend_factor; // interp factor between sunDisc A/B +VARYING vec2 vary_texcoord0; +VARYING float sun_fade; + +void main() +{ + vec4 sunDiscA = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 sunDiscB = texture2D(altDiffuseMap, vary_texcoord0.xy); + vec4 c = mix(sunDiscA, sunDiscB, blend_factor); + c.rgb = clamp(c.rgb, vec3(0), vec3(1)); + c.rgb = pow(c.rgb, vec3(0.7f)); + c.rgb = fullbrightAtmosTransport(c.rgb); + c.rgb = fullbrightScaleSoftClip(c.rgb); + + // SL-9806 stars poke through + //c.a *= sun_fade; + + frag_data[0] = c; + frag_data[1] = vec4(0.0f); + frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); + + gl_FragDepth = 0.9997f; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl new file mode 100644 index 0000000000..0d117c6bc7 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl @@ -0,0 +1,52 @@ +/** + * @file sunDiscV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_matrix; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; +VARYING float sun_fade; + +void calcAtmospherics(vec3 eye_pos); + +void main() +{ + //transform vertex + vec3 offset = vec3(0, 0, 50); + vec4 vert = vec4(position.xyz - offset, 1.0); + vec4 pos = modelview_projection_matrix*vert; + + sun_fade = smoothstep(0.3, 1.0, (position.z + 50) / 512.0f); + + gl_Position = pos; + + calcAtmospherics(pos.xyz); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl index 930255729b..15f141cbe5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl @@ -35,103 +35,16 @@ out vec4 frag_color; //class 1 -- no shadow, SSAO only -uniform sampler2DRect depthMap; uniform sampler2DRect normalMap; -uniform sampler2D noiseMap; - // Inputs -uniform float ssao_radius; -uniform float ssao_max_radius; -uniform float ssao_factor; -uniform float ssao_factor_inv; - VARYING vec2 vary_fragcoord; -uniform mat4 inv_proj; -uniform vec2 screen_res; - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec3 getNorm(vec2 pos_screen); +vec4 getPosition(vec2 pos_screen); //calculate decreases in ambient lighting when crowded out (SSAO) -float calcAmbientOcclusion(vec4 pos, vec3 norm) -{ - float ret = 1.0; - - vec2 kern[8]; - // exponentially (^2) distant occlusion samples spread around origin - kern[0] = vec2(-1.0, 0.0) * 0.125*0.125; - kern[1] = vec2(1.0, 0.0) * 0.250*0.250; - kern[2] = vec2(0.0, 1.0) * 0.375*0.375; - kern[3] = vec2(0.0, -1.0) * 0.500*0.500; - kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625; - kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750; - kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; - kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; - - vec2 pos_screen = vary_fragcoord.xy; - vec3 pos_world = pos.xyz; - vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy; - - float angle_hidden = 0.0; - int points = 0; - - float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); - - // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations unrolling?) - for (int i = 0; i < 8; i++) - { - vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect); - vec3 samppos_world = getPosition(samppos_screen).xyz; - - vec3 diff = pos_world - samppos_world; - float dist2 = dot(diff, diff); - - // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area - // --> solid angle shrinking by the square of distance - //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2 - //(k should vary inversely with # of samples, but this is taken care of later) - - angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv); - - // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" - points = points + int(diff.z > -1.0); - } - - angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); - - ret = (1.0 - (float(points != 0) * angle_hidden)); - - return min(ret, 1.0); -} +float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen); void main() { @@ -139,13 +52,11 @@ void main() //try doing an unproject here - vec4 pos = getPosition(pos_screen); - - vec3 norm = texture2DRect(normalMap, pos_screen).xyz; - norm = decode_normal(norm.xy); - + vec4 pos = getPosition(pos_screen); + vec3 norm = getNorm(pos_screen); + frag_color[0] = 1.0; - frag_color[1] = calcAmbientOcclusion(pos, norm); + frag_color[1] = calcAmbientOcclusion(pos, norm, pos_screen); frag_color[2] = 1.0; frag_color[3] = 1.0; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index 52a429465f..d7b2a9cc8e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -35,33 +37,38 @@ uniform sampler2D detail_2; uniform sampler2D detail_3; uniform sampler2D alpha_ramp; +VARYING vec3 pos; VARYING vec3 vary_normal; VARYING vec4 vary_texcoord0; VARYING vec4 vary_texcoord1; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); + +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 c); +#endif void main() { - /// Note: This should duplicate the blending functionality currently used for the terrain rendering. - - vec4 color0 = texture2D(detail_0, vary_texcoord0.xy); - vec4 color1 = texture2D(detail_1, vary_texcoord0.xy); - vec4 color2 = texture2D(detail_2, vary_texcoord0.xy); - vec4 color3 = texture2D(detail_3, vary_texcoord0.xy); + /// Note: This should duplicate the blending functionality currently used for the terrain rendering. + + vec4 color0 = texture2D(detail_0, vary_texcoord0.xy); + vec4 color1 = texture2D(detail_1, vary_texcoord0.xy); + vec4 color2 = texture2D(detail_2, vary_texcoord0.xy); + vec4 color3 = texture2D(detail_3, vary_texcoord0.xy); + + float alpha1 = texture2D(alpha_ramp, vary_texcoord0.zw).a; + float alpha2 = texture2D(alpha_ramp,vary_texcoord1.xy).a; + float alphaFinal = texture2D(alpha_ramp, vary_texcoord1.zw).a; + vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); + +#ifdef WATER_FOG + outColor = applyWaterFogView(pos.xyz, outColor); +#endif - float alpha1 = texture2D(alpha_ramp, vary_texcoord0.zw).a; - float alpha2 = texture2D(alpha_ramp,vary_texcoord1.xy).a; - float alphaFinal = texture2D(alpha_ramp, vary_texcoord1.zw).a; - vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); - - frag_data[0] = vec4(outColor.rgb, 0.0); - frag_data[1] = vec4(0,0,0,0); - vec3 nvn = normalize(vary_normal); - frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0); + frag_data[0] = vec4(outColor.rgb, 0.0); + frag_data[1] = vec4(0,0,0,0); + vec3 nvn = normalize(vary_normal); + frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl index 5effee4e4e..04fdc18b78 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl @@ -33,8 +33,8 @@ ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec2 texcoord0; ATTRIBUTE vec2 texcoord1; +VARYING vec3 pos; VARYING vec3 vary_normal; - VARYING vec4 vary_texcoord0; VARYING vec4 vary_texcoord1; @@ -43,31 +43,35 @@ uniform vec4 object_plane_t; vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) { - vec4 tcoord; - - tcoord.x = dot(vpos, tp0); - tcoord.y = dot(vpos, tp1); - tcoord.z = tc.z; - tcoord.w = tc.w; - - tcoord = mat * tcoord; - - return tcoord; + vec4 tcoord; + + tcoord.x = dot(vpos, tp0); + tcoord.y = dot(vpos, tp1); + tcoord.z = tc.z; + tcoord.w = tc.w; + + tcoord = mat * tcoord; + + return tcoord; } void main() { - //transform vertex - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - - vary_normal = normalize(normal_matrix * normal); - - // Transform and pass tex coords - vary_texcoord0.xy = texgen_object(vec4(position, 1.0), vec4(texcoord0,0,1), texture_matrix0, object_plane_s, object_plane_t).xy; - - vec4 t = vec4(texcoord1,0,1); - - vary_texcoord0.zw = t.xy; - vary_texcoord1.xy = t.xy-vec2(2.0, 0.0); - vary_texcoord1.zw = t.xy-vec2(1.0, 0.0); + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + vec4 t_pos = modelview_projection_matrix * pre_pos; + + gl_Position = t_pos; + pos = t_pos.xyz; + + vary_normal = normalize(normal_matrix * normal); + + // Transform and pass tex coords + vary_texcoord0.xy = texgen_object(vec4(position, 1.0), vec4(texcoord0,0,1), texture_matrix0, object_plane_s, object_plane_t).xy; + + vec4 t = vec4(texcoord1,0,1); + + vary_texcoord0.zw = t.xy; + vary_texcoord1.xy = t.xy-vec2(2.0, 0.0); + vary_texcoord1.zw = t.xy-vec2(1.0, 0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl index 808750496f..89e354558a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -37,11 +39,7 @@ VARYING vec2 vary_texcoord0; uniform float minimum_alpha; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); void main() { diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl index d4d2f5f571..e34d75ba1d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else diff --git a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl index 78f841c733..e95a688e1f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -56,48 +58,7 @@ VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} +vec2 encode_normal(vec3 n); vec4 applyWaterFog(vec4 color, vec3 viewVec) { @@ -151,7 +112,7 @@ void main() vec4 fb = texture2D(screenTex, distort); - frag_data[0] = vec4(linear_to_srgb(fb.rgb), 1.0); // diffuse + frag_data[0] = vec4(fb.rgb, 1.0); // diffuse frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec frag_data[2] = vec4(encode_normal(wavef), 0.0, 0.0); // normalxyz, displace } diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 37dcd3ad34..be5e3538a7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -1,5 +1,5 @@ /** - * @file waterF.glsl + * @file class1/deferred/waterF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -37,17 +37,10 @@ vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); uniform sampler2D bumpMap; +uniform sampler2D bumpMap2; +uniform float blend_factor; uniform sampler2D screenTex; uniform sampler2D refTex; -uniform sampler2DRectShadow shadowMap0; -uniform sampler2DRectShadow shadowMap1; -uniform sampler2DRectShadow shadowMap2; -uniform sampler2DRectShadow shadowMap3; -uniform sampler2D noiseMap; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; - uniform float sunAngle; uniform float sunAngle2; uniform vec3 lightDir; @@ -62,6 +55,7 @@ uniform float fresnelOffset; uniform float blurMultiplier; uniform vec2 screen_res; uniform mat4 norm_mat; //region space to screen space +uniform int water_edge; //bigWave is (refCoord.w, view.w); VARYING vec4 refCoord; @@ -69,136 +63,111 @@ VARYING vec4 littleWave; VARYING vec4 view; VARYING vec4 vary_position; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} +vec2 encode_normal(vec3 n); +vec3 scaleSoftClipFrag(vec3 l); -vec2 encode_normal(vec3 n) +vec3 BlendNormal(vec3 bump1, vec3 bump2) { - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; + vec3 n = mix(bump1, bump2, blend_factor); + return n; } void main() { - vec4 color; - float dist = length(view.xy); - - //normalize view vector - vec3 viewVec = normalize(view.xyz); - - //get wave normals - vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; - vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; - vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; - //get base fresnel components - - vec3 df = vec3( - dot(viewVec, wave1), - dot(viewVec, (wave2 + wave3) * 0.5), - dot(viewVec, wave3) - ) * fresnelScale + fresnelOffset; - df *= df; - - vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; - - float dist2 = dist; - dist = max(dist, 5.0); - - float dmod = sqrt(dist); - - vec2 dmod_scale = vec2(dmod*dmod, dmod); - - //get reflected color - vec2 refdistort1 = wave1.xy*normScale.x; - vec2 refvec1 = distort+refdistort1/dmod_scale; - vec4 refcol1 = texture2D(refTex, refvec1); - - vec2 refdistort2 = wave2.xy*normScale.y; - vec2 refvec2 = distort+refdistort2/dmod_scale; - vec4 refcol2 = texture2D(refTex, refvec2); - - vec2 refdistort3 = wave3.xy*normScale.z; - vec2 refvec3 = distort+refdistort3/dmod_scale; - vec4 refcol3 = texture2D(refTex, refvec3); - - vec4 refcol = refcol1 + refcol2 + refcol3; - float df1 = df.x + df.y + df.z; - refcol *= df1 * 0.333; - - vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; - wavef.z *= max(-viewVec.z, 0.1); - wavef = normalize(wavef); - - float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; - - vec2 refdistort4 = wavef.xy*0.125; - refdistort4.y -= abs(refdistort4.y); - vec2 refvec4 = distort+refdistort4/dmod; - float dweight = min(dist2*blurMultiplier, 1.0); - vec4 baseCol = texture2D(refTex, refvec4); - - refcol = mix(baseCol*df2, refcol, dweight); - - //get specular component - float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); - - //harden specular - spec = pow(spec, 128.0); - - //figure out distortion vector (ripply) - vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); - - vec4 fb = texture2D(screenTex, distort2); - - //mix with reflection - // Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug - color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); - - vec4 pos = vary_position; - - color.rgb += spec * specular; - - color.rgb = atmosTransport(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - color.a = spec * sunAngle2; - - vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); - - frag_data[0] = vec4(color.rgb, color); // diffuse - frag_data[1] = vec4(0); // speccolor, spec - frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), 0.05, 0);// normalxy, 0, 0 + vec4 color; + float dist = length(view.xy); + + //normalize view vector + vec3 viewVec = normalize(view.xyz); + + //get wave normals + vec3 wave1_a = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_a = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_a = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + + + vec3 wave1_b = texture2D(bumpMap2, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_b = texture2D(bumpMap2, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_b = texture2D(bumpMap2, littleWave.zw).xyz*2.0-1.0; + + vec3 wave1 = BlendNormal(wave1_a, wave1_b); + vec3 wave2 = BlendNormal(wave2_a, wave2_b); + vec3 wave3 = BlendNormal(wave3_a, wave3_b); + + //get base fresnel components + + vec3 df = vec3( + dot(viewVec, wave1), + dot(viewVec, (wave2 + wave3) * 0.5), + dot(viewVec, wave3) + ) * fresnelScale + fresnelOffset; + df *= df; + + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + + float dist2 = dist; + dist = max(dist, 5.0); + + float dmod = sqrt(dist); + + vec2 dmod_scale = vec2(dmod*dmod, dmod); + + //get reflected color + vec2 refdistort1 = wave1.xy*normScale.x; + vec2 refvec1 = distort+refdistort1/dmod_scale; + vec4 refcol1 = texture2D(refTex, refvec1); + + vec2 refdistort2 = wave2.xy*normScale.y; + vec2 refvec2 = distort+refdistort2/dmod_scale; + vec4 refcol2 = texture2D(refTex, refvec2); + + vec2 refdistort3 = wave3.xy*normScale.z; + vec2 refvec3 = distort+refdistort3/dmod_scale; + vec4 refcol3 = texture2D(refTex, refvec3); + + vec4 refcol = refcol1 + refcol2 + refcol3; + float df1 = df.x + df.y + df.z; + refcol *= df1 * 0.333; + + vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; + wavef.z *= max(-viewVec.z, 0.1); + wavef = normalize(wavef); + + float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; + + vec2 refdistort4 = wavef.xy*0.125; + refdistort4.y -= abs(refdistort4.y); + vec2 refvec4 = distort+refdistort4/dmod; + float dweight = min(dist2*blurMultiplier, 1.0); + vec4 baseCol = texture2D(refTex, refvec4); + + refcol = mix(baseCol*df2, refcol, dweight); + + //get specular component + float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); + + //harden specular + spec = pow(spec, 128.0); + + //figure out distortion vector (ripply) + vec2 distort2 = distort+wavef.xy*refScale * 0.33/max(dmod*df1, 1.0); + + vec4 fb = texture2D(screenTex, distort2); + + //mix with reflection + // Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug + color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); + + vec4 pos = vary_position; + + color.rgb += spec * specular; + + color.rgb = atmosTransport(color.rgb); + color.rgb = scaleSoftClipFrag(color.rgb); + + vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); + + frag_data[0] = vec4(color.rgb, 1); // diffuse + frag_data[1] = vec4(0); // speccolor, spec + frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), 0.05, 0);// normalxy, 0, 0 } diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl index 9734acf005..8863869e44 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl @@ -31,8 +31,8 @@ ATTRIBUTE vec3 position; void calcAtmospherics(vec3 inPositionEye); -uniform vec2 d1; -uniform vec2 d2; +uniform vec2 waveDir1; +uniform vec2 waveDir2; uniform float time; uniform vec3 eyeVec; uniform float waterHeight; @@ -88,10 +88,10 @@ void main() calcAtmospherics(pos.xyz); //pass wave parameters to pixel shader - vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055; + vec2 bigWave = (v.xy) * vec2(0.04,0.04) + waveDir1 * time * 0.055; //get two normal map (detail map) texture coordinates - littleWave.xy = (v.xy) * vec2(0.45, 0.9) + d2 * time * 0.13; - littleWave.zw = (v.xy) * vec2(0.1, 0.2) + d1 * time * 0.1; + littleWave.xy = (v.xy) * vec2(0.45, 0.9) + waveDir2 * time * 0.13; + littleWave.zw = (v.xy) * vec2(0.1, 0.2) + waveDir1 * time * 0.1; view.w = bigWave.y; refCoord.w = bigWave.x; diff --git a/indra/newview/app_settings/shaders/class1/environment/encodeNormF.glsl b/indra/newview/app_settings/shaders/class1/environment/encodeNormF.glsl new file mode 100644 index 0000000000..50e781fa78 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/encodeNormF.glsl @@ -0,0 +1,31 @@ +/** + * @file encodeNormF.glsl + * + * $LicenseInfo:firstyear=2018&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2018, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +vec2 encode_normal(vec3 n) +{ + float f = sqrt(8 * n.z + 8); + return n.xy / f + 0.5; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb_mac.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 6cc1e6e798..4a8b892c3a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/srgb_mac.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -1,5 +1,5 @@ /** - * @file srgb.glsl + * @file srgbF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -27,14 +27,18 @@ vec3 srgb_to_linear(vec3 cs) { vec3 low_range = cs / vec3(12.92); vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); +#ifdef OLD_SELECT vec3 result; result.r = lte.r ? low_range.r : high_range.r; result.g = lte.g ? low_range.g : high_range.g; result.b = lte.b ? low_range.b : high_range.b; return result; +#else + return mix(high_range, low_range, lte); +#endif + } vec3 linear_to_srgb(vec3 cl) @@ -42,13 +46,39 @@ vec3 linear_to_srgb(vec3 cl) cl = clamp(cl, vec3(0), vec3(1)); vec3 low_range = cl * 12.92; vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); +#ifdef OLD_SELECT vec3 result; result.r = lt.r ? low_range.r : high_range.r; result.g = lt.g ? low_range.g : high_range.g; result.b = lt.b ? low_range.b : high_range.b; - return result; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} + +vec3 ColorFromRadiance(vec3 radiance) +{ + return vec3(1.0) - exp(-radiance * 0.0001); } +vec3 rgb2hsv(vec3 c) +{ + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 1.0e-10; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +vec3 hsv2rgb(vec3 c) +{ + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); +} diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl index d09c5f9247..4d6f0c67a5 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl @@ -71,7 +71,7 @@ void main() /// Potentially better without it for water. pos /= pos.w; - vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0)); + vec4 color = calcLighting(pos.xyz, norm, vec4(1), vec4(0)); vertex_color = color; diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl index 0d8dab0a41..20280ab1c5 100644 --- a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl @@ -47,7 +47,6 @@ uniform float kd; uniform vec4 waterPlane; uniform vec3 eyeVec; uniform vec4 waterFogColor; -uniform float waterFogDensity; uniform float waterFogKS; uniform vec2 screenRes; @@ -56,41 +55,7 @@ VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; -vec4 applyWaterFog(vec4 color, vec3 viewVec) -{ - //normalize view vector - vec3 view = normalize(viewVec); - float es = -view.z; - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - //get object depth - float depth = length(viewVec); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - //return vec4(1.0, 0.0, 1.0, 1.0); - return color * D + kc * L; - //depth /= 10.0; - //return vec4(depth,depth,depth,0.0); -} +vec4 applyWaterFogView(vec3 pos, vec4 color); void main() { @@ -108,5 +73,5 @@ void main() vec4 fb = texture2D(screenTex, distort); - frag_color = applyWaterFog(fb,view.xyz); + frag_color = applyWaterFogView(view.xyz, fb); } diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 79bffab745..a4e3f94816 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -1,5 +1,5 @@ /** - * @file waterF.glsl + * @file class1/environment/waterF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -33,6 +33,8 @@ vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); uniform sampler2D bumpMap; +uniform sampler2D bumpMap2; +uniform float blend_factor; uniform sampler2D screenTex; uniform sampler2D refTex; @@ -48,94 +50,116 @@ uniform vec3 normScale; uniform float fresnelScale; uniform float fresnelOffset; uniform float blurMultiplier; - +uniform int water_edge; //bigWave is (refCoord.w, view.w); VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; +vec3 BlendNormal(vec3 bump1, vec3 bump2) +{ + //vec3 normal = bump1.xyz * vec3( 2.0, 2.0, 2.0) - vec3(1.0, 1.0, 0.0); + //vec3 normal2 = bump2.xyz * vec3(-2.0, -2.0, 2.0) + vec3(1.0, 1.0, -1.0); + //vec3 n = normalize(normal * dot(normal, normal2) - (normal2 * normal.z)); + vec3 n = normalize(mix(bump1, bump2, blend_factor)); + return n; +} + void main() { - vec4 color; - - float dist = length(view.xy); - - //normalize view vector - vec3 viewVec = normalize(view.xyz); - - //get wave normals - vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; - vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; - vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; - //get base fresnel components - - vec3 df = vec3( - dot(viewVec, wave1), - dot(viewVec, (wave2 + wave3) * 0.5), - dot(viewVec, wave3) - ) * fresnelScale + fresnelOffset; - df *= df; - - vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; - - float dist2 = dist; - dist = max(dist, 5.0); - - float dmod = sqrt(dist); - - vec2 dmod_scale = vec2(dmod*dmod, dmod); - - //get reflected color - vec2 refdistort1 = wave1.xy*normScale.x; - vec2 refvec1 = distort+refdistort1/dmod_scale; - vec4 refcol1 = texture2D(refTex, refvec1); - - vec2 refdistort2 = wave2.xy*normScale.y; - vec2 refvec2 = distort+refdistort2/dmod_scale; - vec4 refcol2 = texture2D(refTex, refvec2); - - vec2 refdistort3 = wave3.xy*normScale.z; - vec2 refvec3 = distort+refdistort3/dmod_scale; - vec4 refcol3 = texture2D(refTex, refvec3); + vec4 color; + + float dist = length(view.xy); + + //normalize view vector + vec3 viewVec = normalize(view.xyz); + + //get wave normals + vec3 wave1_a = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_a = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_a = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + + vec3 wave1_b = texture2D(bumpMap2, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_b = texture2D(bumpMap2, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_b = texture2D(bumpMap2, littleWave.zw).xyz*2.0-1.0; - vec4 refcol = refcol1 + refcol2 + refcol3; - float df1 = df.x + df.y + df.z; - refcol *= df1 * 0.333; - - vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; - - wavef.z *= max(-viewVec.z, 0.1); - wavef = normalize(wavef); - - float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; - - vec2 refdistort4 = wavef.xy*0.125; - refdistort4.y -= abs(refdistort4.y); - vec2 refvec4 = distort+refdistort4/dmod; - float dweight = min(dist2*blurMultiplier, 1.0); - vec4 baseCol = texture2D(refTex, refvec4); - refcol = mix(baseCol*df2, refcol, dweight); + vec3 wave1 = BlendNormal(wave1_a, wave1_b); + vec3 wave2 = BlendNormal(wave2_a, wave2_b); + vec3 wave3 = BlendNormal(wave3_a, wave3_b); - //get specular component - float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); - - //harden specular - spec = pow(spec, 128.0); + //get base fresnel components + + vec3 df = vec3( + dot(viewVec, wave1), + dot(viewVec, (wave2 + wave3) * 0.5), + dot(viewVec, wave3) + ) * fresnelScale + fresnelOffset; + df *= df; + + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + + float dist2 = dist; + dist = max(dist, 5.0); + + float dmod = sqrt(dist); + + vec2 dmod_scale = vec2(dmod*dmod, dmod); + + //get reflected color + vec2 refdistort1 = wave1.xy*normScale.x; + vec2 refvec1 = distort+refdistort1/dmod_scale; + vec4 refcol1 = texture2D(refTex, refvec1); + + vec2 refdistort2 = wave2.xy*normScale.y; + vec2 refvec2 = distort+refdistort2/dmod_scale; + vec4 refcol2 = texture2D(refTex, refvec2); + + vec2 refdistort3 = wave3.xy*normScale.z; + vec2 refvec3 = distort+refdistort3/dmod_scale; + vec4 refcol3 = texture2D(refTex, refvec3); - //figure out distortion vector (ripply) - vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); - - vec4 fb = texture2D(screenTex, distort2); - - //mix with reflection - // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug - color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); - color.rgb += spec * specular; - - color.rgb = atmosTransport(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - color.a = spec * sunAngle2; + vec4 refcol = refcol1 + refcol2 + refcol3; + float df1 = df.x + df.y + df.z; + refcol *= df1 * 0.333; + + vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; + + wavef.z *= max(-viewVec.z, 0.1); + wavef = normalize(wavef); + + float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; + + vec2 refdistort4 = wavef.xy*0.125; + refdistort4.y -= abs(refdistort4.y); + vec2 refvec4 = distort+refdistort4/dmod; + float dweight = min(dist2*blurMultiplier, 1.0); + vec4 baseCol = texture2D(refTex, refvec4); + refcol = mix(baseCol*df2, refcol, dweight); + + //get specular component + float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); + + //harden specular + spec = pow(spec, 128.0); + + //figure out distortion vector (ripply) + vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); + + vec4 fb = texture2D(screenTex, distort2); + + //mix with reflection + // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug + color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); + color.rgb += spec * specular; + + color.rgb = atmosTransport(color.rgb); + color.rgb = scaleSoftClip(color.rgb); + color.a = spec * sunAngle2; + +#if defined(WATER_EDGE) + gl_FragDepth = 0.9999847f; +#endif - frag_color = color; + frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl index 4bdfce9260..856924b1e5 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl @@ -25,7 +25,6 @@ -uniform vec4 lightnorm; uniform vec4 waterPlane; uniform vec4 waterFogColor; uniform float waterFogDensity; @@ -33,42 +32,48 @@ uniform float waterFogKS; vec3 getPositionEye(); -vec4 applyWaterFog(vec4 color) +vec4 applyWaterFogView(vec3 pos, vec4 color) { - //normalize view vector - vec3 view = normalize(getPositionEye()); - float es = -(dot(view, waterPlane.xyz)); + vec3 view = normalize(pos); + //normalize view vector + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(getPositionEye() - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); + return color; +} - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; +vec4 applyWaterFog(vec4 color) +{ + //normalize view vector + return applyWaterFogView(getPositionEye(), color); } diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl index 352cea7aaa..1fe98a9575 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl @@ -31,8 +31,8 @@ ATTRIBUTE vec3 position; void calcAtmospherics(vec3 inPositionEye); -uniform vec2 d1; -uniform vec2 d2; +uniform vec2 waveDir1; +uniform vec2 waveDir2; uniform float time; uniform vec3 eyeVec; uniform float waterHeight; @@ -86,10 +86,10 @@ void main() //pass wave parameters to pixel shader - vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055; + vec2 bigWave = (v.xy) * vec2(0.04,0.04) + waveDir1 * time * 0.055; //get two normal map (detail map) texture coordinates - littleWave.xy = (v.xy) * vec2(0.45, 0.9) + d2 * time * 0.13; - littleWave.zw = (v.xy) * vec2(0.1, 0.2) + d1 * time * 0.1; + littleWave.xy = (v.xy) * vec2(0.45, 0.9) + waveDir2 * time * 0.13; + littleWave.zw = (v.xy) * vec2(0.1, 0.2) + waveDir1 * time * 0.1; view.w = bigWave.y; refCoord.w = bigWave.x; diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl index a96d04cc39..f6b31a5956 100644 --- a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl @@ -38,7 +38,9 @@ VARYING vec2 vary_texcoord0; void main() { - vec4 color = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy); - color.a *= custom_alpha; + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); + color.rgb = pow(color.rgb, vec3(0.45)); + color.rgb *= vertex_color.rgb; + color.a *= max(custom_alpha, vertex_color.a); frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index 5c088b3a3c..b5bbbb5c73 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -25,14 +25,14 @@ #extension GL_ARB_texture_rectangle : enable +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else #define frag_color gl_FragColor #endif -/*[EXTRA_CODE_HERE]*/ - uniform sampler2D glowMap; uniform sampler2DRect screenMap; diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl index 85cddc647d..20e44d74d5 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl @@ -23,14 +23,6 @@ * $/LicenseInfo$ */ - - -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l) { return pow(max(dot(reflect(view, n),l), 0.0),8.0); diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl index a54c0caf81..31a262f1db 100644 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl @@ -1,5 +1,5 @@ /** - * @file fullbrightF.glsl + * @file objects/fullbrightF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl index aacc503e13..4f0e2a6cb6 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl @@ -1,5 +1,5 @@ /** - * @file atmosphericsF.glsl + * @file class1\windlight\atmosphericsF.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -23,11 +23,31 @@ * $/LicenseInfo$ */ +vec3 atmosFragAmbient(vec3 light, vec3 sunlit) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} +vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit) +{ + return light * sunlit; +} vec3 atmosLighting(vec3 light) { - /* stub function for fallback compatibility on class1 hardware */ - return light; + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive) +{ + /* stub function for fallback compatibility on class1 hardware */ } diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl new file mode 100644 index 0000000000..10407eeb02 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl @@ -0,0 +1,51 @@ +/** + * @file atmosphericsHelpersF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform vec4 sunlight_color; +uniform vec4 light_ambient; +uniform int no_atmo; + +vec3 atmosAmbient(vec3 light) +{ + if (no_atmo == 1) return light + vec3(0.66); + return light + light_ambient.rgb; +} + +vec3 atmosAffectDirectionalLight(float lightIntensity) +{ + return sunlight_color.rgb * lightIntensity; +} + +vec3 atmosGetDiffuseSunlightColor() +{ + return sunlight_color.rgb; +} + +vec3 scaleDownLight(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl index 6ff860362c..14034bccae 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl @@ -23,33 +23,35 @@ * $/LicenseInfo$ */ -uniform vec4 sunlight_color_copy; +uniform vec4 sunlight_color; uniform vec4 light_ambient; +uniform int no_atmo; vec3 atmosAmbient(vec3 light) { - return light + light_ambient.rgb; + if (no_atmo == 1) return light + vec3(0.66); + return light + light_ambient.rgb; } vec3 atmosAffectDirectionalLight(float lightIntensity) { - return sunlight_color_copy.rgb * lightIntensity; + return sunlight_color.rgb * lightIntensity; } vec3 atmosGetDiffuseSunlightColor() { - return sunlight_color_copy.rgb; + return sunlight_color.rgb; } vec3 scaleDownLight(vec3 light) { - /* stub function for fallback compatibility on class1 hardware */ - return light; + /* stub function for fallback compatibility on class1 hardware */ + return light; } vec3 scaleUpLight(vec3 light) { - /* stub function for fallback compatibility on class1 hardware */ - return light; + /* stub function for fallback compatibility on class1 hardware */ + return light; } diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl index 76d7d5059d..b749e1a7a2 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl @@ -29,7 +29,7 @@ void setPositionEye(vec3 v); void calcAtmospherics(vec3 inPositionEye) { - /* stub function for fallback compatibility on class1 hardware */ - setPositionEye(inPositionEye); + /* stub function for fallback compatibility on class1 hardware */ + setPositionEye(inPositionEye); } diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl new file mode 100644 index 0000000000..69a3c59cb3 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl @@ -0,0 +1,128 @@ +/** + * @file class3/deferred/cloudsF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING float vary_CloudDensity; +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; +VARYING vec2 vary_texcoord3; + +uniform sampler2D cloud_noise_texture; +uniform sampler2D cloud_noise_texture_next; +uniform float blend_factor; +uniform vec4 cloud_pos_density1; +uniform vec4 cloud_pos_density2; +uniform vec4 sunlight_color; +uniform vec4 cloud_color; +uniform float cloud_shadow; +uniform float cloud_scale; +uniform float cloud_variance; +uniform vec3 ambient; +uniform vec3 camPosLocal; +uniform vec3 sun_dir; +uniform float sun_size; +uniform float far_z; + +#if !defined(DEPTH_CLAMP) +VARYING vec4 post_pos; +#endif + +vec4 cloudNoise(vec2 uv) +{ + vec4 a = texture2D(cloud_noise_texture, uv); + vec4 b = texture2D(cloud_noise_texture_next, uv); + vec4 cloud_noise_sample = mix(a, b, blend_factor); + return normalize(cloud_noise_sample); +} + +void main() +{ + if (cloud_scale >= 0.0001) + { + // Set variables + vec2 uv1 = vary_texcoord0.xy; + vec2 uv2 = vary_texcoord1.xy; + vec2 uv3 = vary_texcoord2.xy; + float cloudDensity = 2.0 * (cloud_shadow - 0.25); + + vec2 uv4 = vary_texcoord3.xy; + + vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + + // Offset texture coords + uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); + + cloudDensity *= 1.0 - (density_variance * density_variance); + + // Compute alpha1, the main cloud opacity + float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + if (alpha1 < 0.001f) + { + discard; + } + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (cloudNoise(uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + frag_color = vec4(alpha1, alpha1, alpha1, 1); + } + else + { + frag_color = vec4(1); + } + +#if !defined(DEPTH_CLAMP) + gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); +#endif + +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl new file mode 100644 index 0000000000..1c2fbaf25d --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl @@ -0,0 +1,61 @@ +/** + * @file cloudShadowV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING vec2 vary_texcoord0; + +void passTextureIndex(); + +void main() +{ + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + pos = modelview_projection_matrix * pre_pos; + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + +#if !defined(DEPTH_CLAMP) + pos_zd2 = pos.z * 0.5; + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + + passTextureIndex(); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl index 62f4e51449..667301443a 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl @@ -23,17 +23,31 @@ * $/LicenseInfo$ */ - - +uniform int no_atmo; uniform vec4 gamma; -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { +vec3 scaleSoftClipFrag(vec3 light) +{ // For compatibility with lower cards. Do nothing. return light; } -vec3 fullbrightScaleSoftClip(vec3 light) { - return scaleSoftClip(light); +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) +{ + // For compatibility with lower cards. Do nothing + return light; +} + +vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 additive, vec3 atten) +{ + // For compatibility with lower cards. Do nothing + return light; +} + +vec3 fullbrightScaleSoftClip(vec3 light) +{ + // For compatibility with lower cards. Do nothing + return light; } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl new file mode 100644 index 0000000000..947c301110 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -0,0 +1,64 @@ +/** + * @file moonF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform vec4 color; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform vec3 lumWeights; +uniform float moon_brightness; +uniform float minLuminance; +uniform sampler2D diffuseMap; +uniform sampler2D altDiffuseMap; +uniform float blend_factor; // interp factor between moon A/B +VARYING vec2 vary_texcoord0; + +void main() +{ + vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); + vec4 c = mix(moonA, moonB, blend_factor); + + // mix factor which blends when sunlight is brighter + // and shows true moon color at night + vec3 luma_weights = vec3(0.2, 0.3, 0.2); + float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights); + + vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; + c.rgb = pow(c.rgb, exp); + //c.rgb *= moonlight_color.rgb; + + frag_color = vec4(c.rgb, c.a); +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonV.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonV.glsl new file mode 100644 index 0000000000..1c43a7332e --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/moonV.glsl @@ -0,0 +1,49 @@ +/** + * @file moonV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_matrix; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +void calcAtmospherics(vec3 inPositionEye); + +VARYING vec2 vary_texcoord0; + +void main() +{ + //transform vertex + vec3 offset = vec3(0, 0, 50); + vec4 vert = vec4(position.xyz - offset, 1.0); + vec4 pos = (modelview_matrix * vert); + + gl_Position = modelview_projection_matrix*vert; + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + + calcAtmospherics(pos.xyz); +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl new file mode 100644 index 0000000000..d85ce004a5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl @@ -0,0 +1,59 @@ +/** + * @file sunDiscF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +uniform sampler2D diffuseMap; +uniform sampler2D altDiffuseMap; +uniform float blend_factor; // interp factor between sun A/B +VARYING vec2 vary_texcoord0; +VARYING float sun_fade; + +void main() +{ + vec4 sunA = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 sunB = texture2D(altDiffuseMap, vary_texcoord0.xy); + vec4 c = mix(sunA, sunB, blend_factor); + +// SL-9806 stars poke through +// c.a *= sun_fade; + + c.rgb = pow(c.rgb, vec3(0.7f)); + c.rgb = fullbrightAtmosTransport(c.rgb); + c.rgb = fullbrightScaleSoftClip(c.rgb); + frag_color = c; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl b/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl new file mode 100644 index 0000000000..ca116628f1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl @@ -0,0 +1,51 @@ +/** + * @file sunDiscV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_matrix; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; +VARYING float sun_fade; + +void calcAtmospherics(vec3 eye_pos); + +void main() +{ + //transform vertex + vec3 offset = vec3(0, 0, 50); + vec4 vert = vec4(position.xyz - offset, 1.0); + vec4 pos = modelview_projection_matrix*vert; + + sun_fade = smoothstep(0.3, 1.0, (position.z + 50) / 512.0f); + gl_Position = pos; + + calcAtmospherics(pos.xyz); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl index 7c95ecdb14..e2b391cb7a 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl @@ -1,5 +1,5 @@ /** - * @file transportF.glsl + * @file class1/windlight/transportF.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -22,25 +22,41 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - +uniform int no_atmo; -vec3 atmosTransport(vec3 light) +vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { - /* stub function for fallback compatibility on class1 hardware */ + /* stub function for fallback compatibility on class1 hardware */ return light; } -vec3 fullbrightAtmosTransport(vec3 light) +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { - /* stub function for fallback compatibility on class1 hardware */ - return light; + /* stub function for fallback compatibility on class1 hardware */ + return light; } +vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 atten, vec3 additive) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} -vec3 fullbrightShinyAtmosTransport(vec3 light) +vec3 atmosTransport(vec3 light) { /* stub function for fallback compatibility on class1 hardware */ - return light; + return light; +} + +vec3 fullbrightAtmosTransport(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; } +vec3 fullbrightShinyAtmosTransport(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} diff --git a/indra/newview/app_settings/shaders/class2/deferred/indirect.glsl b/indra/newview/app_settings/shaders/class2/deferred/indirect.glsl new file mode 100644 index 0000000000..67b98e0fb1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/deferred/indirect.glsl @@ -0,0 +1,32 @@ +/** + * @file class2/deferred/indirect.glsl + * + * $LicenseInfo:firstyear=2018&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen); + +vec3 getIndirect(vec3 ambient, vec3 norm, vec4 pos, vec2 pos_screen) +{ + return ambient * calcAmbientOcclusion(pos, norm, pos_screen); +} + diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index b9bb522842..275bc829a7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -71,69 +71,11 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 correctWithGamma(vec4 col) -{ - return vec4(srgb_to_linear(col.rgb), col.a); -} +vec3 getNorm(vec2 pos_screen); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -153,7 +95,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -171,7 +112,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -182,19 +122,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) return ret; } - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); void main() { @@ -227,7 +155,7 @@ void main() float envIntensity = norm.z; - norm = decode_normal(norm.xy); + norm = getNorm(frag.xy); norm = normalize(norm); float l_dist = -dot(lv, proj_n); @@ -283,7 +211,10 @@ void main() dlit = color.rgb * plcol.rgb * plcol.a; col = dlit*lit*diff_tex*shadow; - amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; + amb_da += (da*0.5) * proj_ambiance; + amb_da += (da*da*0.5 + 0.5) * proj_ambiance; + //amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; + //amb_da = min(amb_da,shadow); } //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl new file mode 100644 index 0000000000..26f8095dc1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl @@ -0,0 +1,202 @@ +/** + * @file class2/deferred/skyF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +// SKY //////////////////////////////////////////////////////////////////////// +// The vertex shader for creating the atmospheric sky +/////////////////////////////////////////////////////////////////////////////// + +// Inputs +uniform vec3 camPosLocal; + +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform float haze_horizon; +uniform float haze_density; + +uniform float cloud_shadow; +uniform float density_multiplier; +uniform float max_y; + +uniform vec4 glow; +uniform float sun_moon_glow_factor; + +uniform vec4 cloud_color; + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +VARYING vec3 pos; + +///////////////////////////////////////////////////////////////////////// +// The fragment shader for the sky +///////////////////////////////////////////////////////////////////////// + +uniform vec4 gamma; +uniform sampler2D rainbow_map; +uniform sampler2D halo_map; + +uniform float moisture_level; +uniform float droplet_radius; +uniform float ice_level; + +vec3 rainbow(float d) +{ + d = clamp(d, -1.0, 0.0); + float rad = (droplet_radius - 5.0f) / 1024.0f; + return pow(texture2D(rainbow_map, vec2(rad, d)).rgb, vec3(1.8)) * moisture_level; +} + +vec3 halo22(float d) +{ + d = clamp(d, 0.1, 1.0); + float v = sqrt(clamp(1 - (d * d), 0, 1)); + return texture2D(halo_map, vec2(0, v)).rgb * ice_level; +} + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light); + +void main() +{ + + // World / view / projection + // Get relative position + vec3 P = pos.xyz - camPosLocal.xyz + vec3(0,50,0); + + // Set altitude + if (P.y > 0.) + { + P *= (max_y / P.y); + } + else + { + P *= (-32000. / P.y); + } + + // Can normalize then + vec3 Pn = normalize(P); + float Plen = length(P); + + // Initialize temp variables + vec4 temp1 = vec4(0.); + vec4 temp2 = vec4(0.); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + + // Calculate relative weights + temp1 = blue_density + haze_density; + blue_weight = blue_density / temp1; + haze_weight = haze_density / temp1; + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Distance + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z); + + + // Compute haze glow + temp2.x = dot(Pn, lightnorm.xyz); + temp2.x = 1. - temp2.x; + // temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .001); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // Add "minimum anti-solar illumination" + temp2.x += .25; + + temp2.x *= sun_moon_glow_factor; + + // Haze color above cloud + vec4 color = ( blue_horizon * blue_weight * (sunlight + ambient) + + (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient) + ); + + + // Increase ambient when there are more clouds + vec4 tmpAmbient = ambient; + tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5; + + // Dim sunlight by cloud shadow percentage + sunlight *= (1. - cloud_shadow); + + // Haze color below cloud + vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight * temp2.x + tmpAmbient) + ); + + // Final atmosphere additive + color *= (1. - temp1); + + // Attenuate cloud color by atmosphere + temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds + + // At horizon, blend high altitude sky color towards the darker color below the clouds + color += (additiveColorBelowCloud - color) * (1. - sqrt(temp1)); + + float optic_d = dot(Pn, lightnorm.xyz); + + vec3 halo_22 = halo22(optic_d); + + color.rgb += rainbow(optic_d); + + color.rgb += halo_22; + + color *= 2.; + + /// Gamma correct for WL (soft clip effect). + frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0); + frag_data[1] = vec4(0.0,0.0,0.0,0.0); + frag_data[2] = vec4(0.5,0.5,0.0,1.0); //1.0 in norm.w masks off fog +} + diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyV.glsl new file mode 100644 index 0000000000..bcf775577a --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/deferred/skyV.glsl @@ -0,0 +1,42 @@ +/** + * @file WLSkyV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; + +// SKY //////////////////////////////////////////////////////////////////////// +// The vertex shader for creating the atmospheric sky +/////////////////////////////////////////////////////////////////////////////// + +VARYING vec3 pos; + +void main() +{ + + // World / view / projection + pos = position.xyz; + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index f7832521fa..27532ce458 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -1,5 +1,5 @@ /** - * @file softenLightF.glsl + * @file class2/deferred/softenLightF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -39,7 +39,7 @@ uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; uniform samplerCube environmentMap; -uniform sampler2D lightFunc; +uniform sampler2D lightFunc; uniform float blur_size; uniform float blur_fidelity; @@ -48,447 +48,129 @@ uniform float blur_fidelity; uniform vec4 morphFactor; uniform vec3 camPosLocal; //uniform vec4 camPosWorld; -uniform vec4 gamma; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 ambient; -uniform vec4 blue_horizon; -uniform vec4 blue_density; -uniform float haze_horizon; -uniform float haze_density; uniform float cloud_shadow; -uniform float density_multiplier; -uniform float distance_multiplier; uniform float max_y; -uniform vec4 glow; uniform float global_gamma; -uniform float scene_light_strength; +uniform float display_gamma; uniform mat3 env_mat; uniform vec4 shadow_clip; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; -VARYING vec2 vary_fragcoord; - -vec3 vary_PositionEye; +uniform vec3 moon_dir; +uniform int sun_up_factor; -vec3 vary_SunlitColor; -vec3 vary_AmblitColor; -vec3 vary_AdditiveColor; -vec3 vary_AtmosAttenuation; +VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 getPosition_d(vec2 pos_screen, float depth) -{ - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -vec4 getPosition(vec2 pos_screen) -{ //get position in screen space (world units) given window coordinate and depth map - float depth = texture2DRect(depthMap, pos_screen.xy).r; - return getPosition_d(pos_screen, depth); -} - -vec3 getPositionEye() -{ - return vary_PositionEye; -} -vec3 getSunlitColor() -{ - return vary_SunlitColor; -} -vec3 getAmblitColor() -{ - return vary_AmblitColor; -} -vec3 getAdditiveColor() -{ - return vary_AdditiveColor; -} -vec3 getAtmosAttenuation() -{ - return vary_AtmosAttenuation; -} - -void setPositionEye(vec3 v) -{ - vary_PositionEye = v; -} - -void setSunlitColor(vec3 v) -{ - vary_SunlitColor = v; -} - -void setAmblitColor(vec3 v) -{ - vary_AmblitColor = v; -} - -void setAdditiveColor(vec3 v) -{ - vary_AdditiveColor = v; -} - -void setAtmosAttenuation(vec3 v) -{ - vary_AtmosAttenuation = v; -} - -void calcAtmospherics(vec3 inPositionEye, float ambFactor) { - - vec3 P = inPositionEye; - setPositionEye(P); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = sunlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); +vec3 getNorm(vec2 pos_screen); - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); +vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); +vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 add, vec3 atten); +vec3 scaleSoftClipFrag(vec3 l); - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); +vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten); +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); +vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); - */ - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - - //haze color - setAdditiveColor( - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient))); - - //brightness of surface both sunlight and ambient - /*setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * global_gamma); - setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * global_gamma); - setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * global_gamma);*/ - - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); -} +vec4 getPositionWithDepth(vec2 pos_screen, float depth); +vec4 getPosition(vec2 pos_screen); #ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} +vec4 applyWaterFogView(vec3 pos, vec4 color); #endif -vec3 atmosLighting(vec3 light) -{ - light *= getAtmosAttenuation().r; - light += getAdditiveColor(); - return (2.0 * light); -} - -vec3 atmosTransport(vec3 light) { - light *= getAtmosAttenuation().r; - light += getAdditiveColor() * 2.0; - return light; -} - -vec3 fullbrightAtmosTransport(vec3 light) { - float brightness = dot(light.rgb, vec3(0.33333)); - - return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); -} - - - -vec3 atmosGetDiffuseSunlightColor() -{ - return getSunlitColor(); -} - -vec3 scaleDownLight(vec3 light) -{ - return (light / scene_light_strength ); -} - -vec3 scaleUpLight(vec3 light) -{ - return (light * scene_light_strength); -} - -vec3 atmosAmbient(vec3 light) -{ - return getAmblitColor() + light / 2.0; -} - -vec3 atmosAffectDirectionalLight(float lightIntensity) -{ - return getSunlitColor() * lightIntensity; -} - -vec3 scaleSoftClip(vec3 light) -{ - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); - - return light; -} - - -vec3 fullbrightScaleSoftClip(vec3 light) -{ - //soft clip effect: - return light; -} - void main() { - vec2 tc = vary_fragcoord.xy; - float depth = texture2DRect(depthMap, tc.xy).r; - vec3 pos = getPosition_d(tc, depth).xyz; - vec4 norm = texture2DRect(normalMap, tc); - float envIntensity = norm.z; - norm.xyz = decode_normal(norm.xy); // unpack norm - - float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - - float light_gamma = 1.0/1.3; - da = pow(da, light_gamma); - - - vec4 diffuse = texture2DRect(diffuseRect, tc); - - //convert to gamma space - diffuse.rgb = linear_to_srgb(diffuse.rgb); - - vec3 col; - float bloom = 0.0; - { - vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - - vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); - - float scol = max(scol_ambocc.r, diffuse.a); - - - - float ambocc = scol_ambocc.g; - - calcAtmospherics(pos.xyz, ambocc); - - col = atmosAmbient(vec3(0)); - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); - - col.rgb *= ambient; - - col += atmosAffectDirectionalLight(max(min(da, scol), 0.0)); - - col *= diffuse.rgb; - - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - - if (spec.a > 0.0) // specular reflection - { - // the old infinite-sky shiny reflection - // - - float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); - - // add the two types of shiny together - vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib) / 6; - col += spec_contrib; - } - - - col = mix(col, diffuse.rgb, diffuse.a); - - if (envIntensity > 0.0) - { //add environmentmap - vec3 env_vec = env_mat * refnormpersp; - - vec3 refcol = textureCube(environmentMap, env_vec).rgb; - - col = mix(col.rgb, refcol, - envIntensity); - - } - - if (norm.w < 0.5) - { - col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); - } - - #ifdef WATER_FOG - vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); - col = fogged.rgb; - bloom = fogged.a; - #endif - - col = srgb_to_linear(col); - - //col = vec3(1,0,1); - //col.g = envIntensity; - } - - frag_color.rgb = col; - frag_color.a = bloom; + vec2 tc = vary_fragcoord.xy; + float depth = texture2DRect(depthMap, tc.xy).r; + vec4 pos = getPositionWithDepth(tc, depth); + vec4 norm = texture2DRect(normalMap, tc); + float envIntensity = norm.z; + norm.xyz = getNorm(tc); // unpack norm + + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + + float scol = 1.0; + vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; + + float da = dot(normalize(norm.xyz), light_dir.xyz); + da = clamp(da, 0.0, 1.0); + + float light_gamma = 1.0/1.3; + da = pow(da, light_gamma); + + vec4 diffuse = texture2DRect(diffuseRect, tc); + + scol = max(scol_ambocc.r, diffuse.a); + + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); + vec3 col; + float bloom = 0.0; + { + float ambocc = scol_ambocc.g; + + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; + + calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); + + float ambient = abs(da); + ambient *= 0.5; + ambient *= ambient; + ambient = 1.0 - ambient; + + vec3 sun_contrib = min(da,scol) * sunlit; + + col.rgb = amblit; + col.rgb *= ambient; + col.rgb += sun_contrib; + col.rgb *= diffuse.rgb; + + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + float sa = dot(refnormpersp, light_dir.xyz); + vec3 dumbshiny = sunlit*scol*(texture2D(lightFunc, vec2(sa, spec.a)).r); + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib) / 6; + col += spec_contrib; + } + + col = mix(col.rgb, diffuse.rgb, diffuse.a); + + if (envIntensity > 0.0) + { //add environmentmap + vec3 env_vec = env_mat * refnormpersp; + vec3 refcol = textureCube(environmentMap, env_vec).rgb; + col = mix(col.rgb, refcol, envIntensity); + } + + +vec3 a = col.rgb; + if (norm.w < 0.5) + { + col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); + col = mix(scaleSoftClipFrag(col), fullbrightScaleSoftClipFrag(col, additive, atten), diffuse.a); + } + + #ifdef WATER_FOG + vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + +//col.rgb = a; + } + frag_color.rgb = col.rgb; + frag_color.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl index c840d72784..8b8b338f68 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl @@ -36,7 +36,5 @@ void main() //transform vertex vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); gl_Position = pos; - - vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 81af1fdc8a..9b69d8d855 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -71,69 +71,11 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} - -vec4 correctWithGamma(vec4 col) -{ - return vec4(srgb_to_linear(col.rgb), col.a); -} +vec3 getNorm(vec2 pos_screen); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -153,7 +95,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -171,7 +112,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -182,19 +122,7 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) return ret; } - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); void main() { @@ -225,7 +153,7 @@ void main() vec3 norm = texture2DRect(normalMap, frag.xy).xyz; float envIntensity = norm.z; - norm = decode_normal(norm.xy); + norm = getNorm(frag.xy); norm = normalize(norm); float l_dist = -dot(lv, proj_n); @@ -238,8 +166,8 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff+1.0; - float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); + float fa = falloff + 1.0; + float dist_atten = min(1.0 - (dist - 1.0 * (1.0 - fa)) / fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 265da8df99..8abdeae5ae 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -35,228 +35,26 @@ out vec4 frag_color; //class 2, shadows, no SSAO -uniform sampler2DRect depthMap; -uniform sampler2DRect normalMap; -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; -uniform sampler2DShadow shadowMap4; -uniform sampler2DShadow shadowMap5; - - // Inputs -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform float ssao_radius; -uniform float ssao_max_radius; -uniform float ssao_factor; -uniform float ssao_factor_inv; - VARYING vec2 vary_fragcoord; -uniform mat4 inv_proj; -uniform vec2 screen_res; -uniform vec2 proj_shadow_res; uniform vec3 sun_dir; - -uniform vec2 shadow_res; uniform float shadow_bias; -uniform float shadow_offset; - -uniform float spot_shadow_bias; -uniform float spot_shadow_offset; - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) -{ - stc.xyz /= stc.w; - stc.z += shadow_bias; - - stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x; // add some jitter to X sample pos according to Y to disguise the snapping going on here - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs; +vec3 getNorm(vec2 pos_screen); +vec4 getPosition(vec2 pos_screen); - shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - - return shadow*0.2; -} - -float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) -{ - stc.xyz /= stc.w; - stc.z += spot_shadow_bias*scl; - stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap - - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs; - - vec2 off = 1.0/proj_shadow_res; - off.y *= 1.5; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x*2.0, off.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x*2.0, -off.y, 0.0)).x; - - return shadow*0.2; -} +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +float sampleSpotShadow(vec3 pos, vec3 norm, int index, vec2 pos_screen); void main() { - vec2 pos_screen = vary_fragcoord.xy; - - //try doing an unproject here - - vec4 pos = getPosition(pos_screen); - - vec3 norm = texture2DRect(normalMap, pos_screen).xyz; - norm = decode_normal(norm.xy); // unpack norm - - /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL - { - frag_color = vec4(0.0); // doesn't matter - return; - }*/ - - float shadow = 0.0; - float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); - - vec3 shadow_pos = pos.xyz; - vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); - - vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); - - if (spos.z > -shadow_clip.w) - { - if (dp_directional_light == 0.0) - { - // 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 - shadow = 0.0; - } - else - { - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos, 0.25, pos_screen)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos, 0.5, pos_screen)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos, 0.75, pos_screen)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadow(shadowMap0, lpos, 1.0, pos_screen)*w; - weight += w; - } - - - shadow /= weight; - - // take the most-shadowed value out of these two: - // * the blurred sun shadow in the light (shadow) map - // * an unblurred dot product between the sun and this norm - // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting - shadow = min(shadow, dp_directional_light); - - //lpos.xy /= lpos.w*32.0; - //if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1) - //{ - // shadow = 0.0; - //} - - } - } - else - { - // more distant than the shadow map covers - shadow = 1.0; - } - - frag_color[0] = shadow; - frag_color[1] = 1.0; - - spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0); - - //spotlight shadow 1 - vec4 lpos = shadow_matrix[4]*spos; - frag_color[2] = pcfSpotShadow(shadowMap4, lpos, 0.8, pos_screen); - - //spotlight shadow 2 - lpos = shadow_matrix[5]*spos; - frag_color[3] = pcfSpotShadow(shadowMap5, lpos, 0.8, pos_screen); - - //frag_color.rgb = pos.xyz; - //frag_color.b = shadow; + vec2 pos_screen = vary_fragcoord.xy; + vec4 pos = getPosition(pos_screen); + vec3 norm = getNorm(pos_screen); + + frag_color.r = sampleDirectionalShadow(pos.xyz, norm, pos_screen); + frag_color.g = 1.0f; + frag_color.b = sampleSpotShadow(pos.xyz, norm, 0, pos_screen); + frag_color.a = sampleSpotShadow(pos.xyz, norm, 1, pos_screen); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 5c6fe30daa..64d99bae2c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -1,5 +1,5 @@ /** - * @file sunLightSSAOF.glsl + * @file class2/deferred/sunLightSSAOF.glsl * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2007, Linden Research, Inc. @@ -34,290 +34,24 @@ out vec4 frag_color; //class 2 -- shadows and SSAO -uniform sampler2DRect depthMap; -uniform sampler2DRect normalMap; -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; -uniform sampler2DShadow shadowMap4; -uniform sampler2DShadow shadowMap5; -uniform sampler2D noiseMap; - - // Inputs -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform float ssao_radius; -uniform float ssao_max_radius; -uniform float ssao_factor; -uniform float ssao_factor_inv; - VARYING vec2 vary_fragcoord; -uniform mat4 inv_proj; -uniform vec2 screen_res; -uniform vec2 proj_shadow_res; -uniform vec3 sun_dir; - -uniform vec2 shadow_res; - -uniform float shadow_bias; -uniform float shadow_offset; - -uniform float spot_shadow_bias; -uniform float spot_shadow_offset; - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} - -vec2 getKern(int i) -{ - vec2 kern[8]; - // exponentially (^2) distant occlusion samples spread around origin - kern[0] = vec2(-1.0, 0.0) * 0.125*0.125; - kern[1] = vec2(1.0, 0.0) * 0.250*0.250; - kern[2] = vec2(0.0, 1.0) * 0.375*0.375; - kern[3] = vec2(0.0, -1.0) * 0.500*0.500; - kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625; - kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750; - kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; - kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; - - return kern[i]; -} - -//calculate decreases in ambient lighting when crowded out (SSAO) -float calcAmbientOcclusion(vec4 pos, vec3 norm) -{ - float ret = 1.0; - - vec2 pos_screen = vary_fragcoord.xy; - vec3 pos_world = pos.xyz; - vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy; - - float angle_hidden = 0.0; - float points = 0; - - float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); - - // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?) - for (int i = 0; i < 8; i++) - { - vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect); - vec3 samppos_world = getPosition(samppos_screen).xyz; - - vec3 diff = pos_world - samppos_world; - float dist2 = dot(diff, diff); - - // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area - // --> solid angle shrinking by the square of distance - //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2 - //(k should vary inversely with # of samples, but this is taken care of later) - - float funky_val = (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) ? 1.0 : 0.0; - angle_hidden = angle_hidden + funky_val * min(1.0/dist2, ssao_factor_inv); - - // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" - float diffz_val = (diff.z > -1.0) ? 1.0 : 0.0; - points = points + diffz_val; - } - - angle_hidden = min(ssao_factor*angle_hidden/points, 1.0); - - float points_val = (points > 0.0) ? 1.0 : 0.0; - ret = (1.0 - (points_val * angle_hidden)); - - ret = max(ret, 0.0); - return min(ret, 1.0); -} - -float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) -{ - stc.xyz /= stc.w; - stc.z += shadow_bias; - - stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x; - float cs = shadow2D(shadowMap, stc.xyz).x; - - float shadow = cs; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - return shadow*0.2; -} - -float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) -{ - stc.xyz /= stc.w; - stc.z += spot_shadow_bias*scl; - stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap - - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs; +vec4 getPosition(vec2 pos_screen); +vec3 getNorm(vec2 pos_screen); - vec2 off = 1.0/proj_shadow_res; - off.y *= 1.5; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x*2.0, off.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x*2.0, -off.y, 0.0)).x; - - return shadow*0.2; -} +float sampleDirectionalShadow(vec3 shadow_pos, vec3 norm, vec2 pos_screen); +float sampleSpotShadow(vec3 shadow_pos, vec3 norm, int index, vec2 pos_screen); +float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen); void main() { - vec2 pos_screen = vary_fragcoord.xy; - - //try doing an unproject here - - vec4 pos = getPosition(pos_screen); - - vec3 norm = texture2DRect(normalMap, pos_screen).xyz; - norm = decode_normal(norm.xy); // unpack norm - - /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL - { - frag_color = vec4(0.0); // doesn't matter - return; - }*/ - - float shadow = 0.0; - float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); - - vec3 shadow_pos = pos.xyz; - vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); - - vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); - - if (spos.z > -shadow_clip.w) - { - if (dp_directional_light == 0.0) - { - // 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 - shadow = 0.0; - } - else - { - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos, 0.25, pos_screen)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos, 0.5, pos_screen)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos, 0.75, pos_screen)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadow(shadowMap0, lpos, 1.0, pos_screen)*w; - weight += w; - } - - - shadow /= weight; - - // take the most-shadowed value out of these two: - // * the blurred sun shadow in the light (shadow) map - // * an unblurred dot product between the sun and this norm - // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting - shadow = min(shadow, dp_directional_light); - - //lpos.xy /= lpos.w*32.0; - //if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1) - //{ - // shadow = 0.0; - //} - - } - } - else - { - // more distant than the shadow map covers - shadow = 1.0; - } - - frag_color[0] = shadow; - frag_color[1] = calcAmbientOcclusion(pos, norm); - - spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0); - - //spotlight shadow 1 - vec4 lpos = shadow_matrix[4]*spos; - frag_color[2] = pcfSpotShadow(shadowMap4, lpos, 0.8, pos_screen); - - //spotlight shadow 2 - lpos = shadow_matrix[5]*spos; - frag_color[3] = pcfSpotShadow(shadowMap5, lpos, 0.8, pos_screen); + vec2 pos_screen = vary_fragcoord.xy; + vec4 pos = getPosition(pos_screen); + vec3 norm = getNorm(pos_screen); - //frag_color.rgb = pos.xyz; - //frag_color.b = shadow; + frag_color.r = sampleDirectionalShadow(pos.xyz, norm, pos_screen); + frag_color.g = calcAmbientOcclusion(pos, norm, pos_screen); + frag_color.b = sampleSpotShadow(pos.xyz, norm, 0, pos_screen); + frag_color.a = sampleSpotShadow(pos.xyz, norm, 1, pos_screen); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index fea3cbf69b..14af657e67 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -22,23 +22,138 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - - - -////////////////////////////////////////////////////////// -// The fragment shader for the terrain atmospherics -////////////////////////////////////////////////////////// vec3 getAdditiveColor(); vec3 getAtmosAttenuation(); -uniform sampler2D cloudMap; -uniform vec4 cloud_pos_density1; +uniform vec4 gamma; +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform float haze_horizon; +uniform float haze_density; +uniform float cloud_shadow; +uniform float density_multiplier; +uniform float distance_multiplier; +uniform float max_y; +uniform vec4 glow; +uniform float scene_light_strength; +uniform mat3 ssao_effect_mat; +uniform int no_atmo; +uniform float sun_moon_glow_factor; + +vec3 scaleSoftClipFrag(vec3 light); + +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) +{ + if (no_atmo == 1) + { + return light; + } + light *= atten.r; + light += additive; + return light * 2.0; +} vec3 atmosLighting(vec3 light) { - light *= getAtmosAttenuation().r; - light += getAdditiveColor(); - return (2.0 * light); + return atmosFragLighting(light, getAdditiveColor(), getAtmosAttenuation()); +} + +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) { + + vec3 P = inPositionEye; + + //(TERRAIN) limit altitude + if (P.y > max_y) P *= (max_y / P.y); + if (P.y < -max_y) P *= (-max_y / P.y); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + if (temp2.y > 0.001f) + { + temp2.y = 1. / temp2.y; + } + temp2.y = max(0.001f, temp2.y); + sunlight *= exp(-light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + atten = temp1.rgb; + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + temp2.x *= sun_moon_glow_factor; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + /* decrease value and saturation (that in HSV, not HSL) for occluded areas + * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html + * // The following line of code performs the equivalent of: + * float ambAlpha = tmpAmbient.a; + * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis + * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); + * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); + */ + tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + + //haze color + additive = + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient)); + + //brightness of surface both sunlight and ambient + sunlit = vec3(sunlight * .5); + amblit = vec3(tmpAmbient * .25); + additive = normalize(additive); + additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl new file mode 100644 index 0000000000..86743dc306 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl @@ -0,0 +1,46 @@ +/** + * @file atmosphericsHelpersV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// Output variables + +uniform float scene_light_strength; +uniform int no_atmo; + +vec3 atmosFragAmbient(vec3 light, vec3 amblit) +{ + if (no_atmo == 1) return light; + return amblit + light / 2.0; +} + +vec3 atmosFragAffectDirectionalLight(float lightIntensity, vec3 sunlit) +{ + return sunlit * lightIntensity; +} + +vec3 scaleDownLightFrag(vec3 light) +{ + return (light / scene_light_strength ); +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl index 62a034ce05..95b4a76880 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl @@ -33,29 +33,31 @@ vec3 getAtmosAttenuation(); vec3 getPositionEye(); uniform float scene_light_strength; +uniform int no_atmo; vec3 atmosAmbient(vec3 light) { - return getAmblitColor() + light / 2.0; + if (no_atmo == 1) return light + vec3(0.66); + return getAmblitColor() + light / 2.0; } vec3 atmosAffectDirectionalLight(float lightIntensity) { - return getSunlitColor() * lightIntensity; + return getSunlitColor() * lightIntensity; } vec3 atmosGetDiffuseSunlightColor() { - return getSunlitColor(); + return getSunlitColor(); } vec3 scaleDownLight(vec3 light) { - return (light / scene_light_strength ); + return (light / scene_light_strength ); } vec3 scaleUpLight(vec3 light) { - return (light * scene_light_strength); + return (light * scene_light_strength); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl index d174805cc0..6c4098b9fb 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl @@ -44,6 +44,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -54,104 +56,106 @@ uniform float density_multiplier; uniform float distance_multiplier; uniform float max_y; uniform vec4 glow; +uniform float sun_moon_glow_factor; void calcAtmospherics(vec3 inPositionEye) { - vec3 P = inPositionEye; - setPositionEye(P); - - //(TERRAIN) limit altitude - if (P.y > max_y) P *= (max_y / P.y); - if (P.y < -max_y) P *= (-max_y / P.y); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = sunlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - //vary_AtmosAttenuation = distance_multiplier / 10000.; - //vary_AtmosAttenuation = density_multiplier * 100.; - //vary_AtmosAttenuation = vec4(Plen / 100000., 0., 0., 1.); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - //haze color - setAdditiveColor( - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient))); - - //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); - - // vary_SunlitColor = vec3(0); - // vary_AmblitColor = vec3(0); - // vary_AdditiveColor = vec4(Pn, 1.0); - - /* - const float cloudShadowScale = 100.; - // Get cloud uvs for shadowing - vec3 cloudPos = inPositionEye + camPosWorld - cloudShadowScale / 2.; - vary_CloudUVs.xy = cloudPos.xz / cloudShadowScale; - - // We can take uv1 and multiply it by (TerrainSpan / CloudSpan) -// cloudUVs *= (((worldMaxZ - worldMinZ) * 20) /40000.); - vary_CloudUVs *= (10000./40000.); - - // Offset by sun vector * (CloudAltitude / CloudSpan) - vary_CloudUVs.x += tmpLightnorm.x / tmpLightnorm.y * (3000./40000.); - vary_CloudUVs.y += tmpLightnorm.z / tmpLightnorm.y * (3000./40000.); - */ + vec3 P = inPositionEye; + setPositionEye(P); + + //(TERRAIN) limit altitude + if (P.y > max_y) P *= (max_y / P.y); + if (P.y < -max_y) P *= (-max_y / P.y); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + if (temp2.y > 0.001f) + { + temp2.y = 1. / temp2.y; + } + temp2.y = max(0.001f, temp2.y); + sunlight *= exp( - light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + setAtmosAttenuation(temp1.rgb); + //vary_AtmosAttenuation = distance_multiplier / 10000.; + //vary_AtmosAttenuation = density_multiplier * 100.; + //vary_AtmosAttenuation = vec4(Plen / 100000., 0., 0., 1.); + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + temp2.x *= sun_moon_glow_factor; + + //add "minimum anti-solar illumination" + temp2.x += .25; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + vec3 additive = + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient)); + additive = normalize(additive); + + //brightness of surface both sunlight and ambient + setSunlitColor(vec3(sunlight * .5)); + setAmblitColor(vec3(tmpAmbient * .25)); + setAdditiveColor(additive * vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5); + + /* + const float cloudShadowScale = 100.; + // Get cloud uvs for shadowing + vec3 cloudPos = inPositionEye + camPosWorld - cloudShadowScale / 2.; + vary_CloudUVs.xy = cloudPos.xz / cloudShadowScale; + + // We can take uv1 and multiply it by (TerrainSpan / CloudSpan) +// cloudUVs *= (((worldMaxZ - worldMinZ) * 20) /40000.); + vary_CloudUVs *= (10000./40000.); + + // Offset by sun vector * (CloudAltitude / CloudSpan) + vary_CloudUVs.x += tmpLightnorm.x / tmpLightnorm.y * (3000./40000.); + vary_CloudUVs.y += tmpLightnorm.z / tmpLightnorm.y * (3000./40000.); + */ } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 96c70651b1..93024bf4e7 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -22,11 +22,13 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; +out vec4 frag_data[3]; #else -#define frag_color gl_FragColor +#define frag_data gl_FragData #endif ///////////////////////////////////////////////////////////////////////// @@ -36,69 +38,93 @@ out vec4 frag_color; VARYING vec4 vary_CloudColorSun; VARYING vec4 vary_CloudColorAmbient; VARYING float vary_CloudDensity; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; uniform sampler2D cloud_noise_texture; +uniform sampler2D cloud_noise_texture_next; +uniform float blend_factor; uniform vec4 cloud_pos_density1; uniform vec4 cloud_pos_density2; uniform vec4 gamma; +uniform float cloud_scale; +uniform float cloud_variance; + +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; +VARYING vec2 vary_texcoord3; /// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); +vec3 scaleSoftClip(vec3 light); - return light; +vec4 cloudNoise(vec2 uv) +{ + vec4 a = texture2D(cloud_noise_texture, uv); + vec4 b = texture2D(cloud_noise_texture_next, uv); + vec4 cloud_noise_sample = mix(a, b, blend_factor); + return cloud_noise_sample; } void main() { - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - - vec4 cloudColorSun = vary_CloudColorSun; - vec4 cloudColorAmbient = vary_CloudColorAmbient; - float cloudDensity = vary_CloudDensity; - vec2 uv3 = vary_texcoord2.xy; - vec2 uv4 = vary_texcoord3.xy; - - // Offset texture coords - uv1 += cloud_pos_density1.xy; //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - uv3 += cloud_pos_density2.xy; //small texture, visible density - uv4 += cloud_pos_density2.xy; //small texture, self shadow - - - // Compute alpha1, the main cloud opacity - float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, uv3).x - 0.5) * cloud_pos_density2.z; - alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.); - - // And smooth - alpha1 = 1. - alpha1 * alpha1; - alpha1 = 1. - alpha1 * alpha1; - - - // Compute alpha2, for self shadowing effect - // (1 - alpha2) will later be used as percentage of incoming sunlight - float alpha2 = (texture2D(cloud_noise_texture, uv2).x - 0.5); - alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - // Combine - vec4 color; - color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); - color *= 2.; - - /// Gamma correct for WL (soft clip effect). - frag_color.rgb = scaleSoftClip(color.rgb); - frag_color.a = alpha1; + // Set variables + vec2 uv1 = vary_texcoord0.xy; + vec2 uv2 = vary_texcoord1.xy; + + vec4 cloudColorSun = vary_CloudColorSun; + vec4 cloudColorAmbient = vary_CloudColorAmbient; + float cloudDensity = vary_CloudDensity; + vec2 uv3 = vary_texcoord2.xy; + vec2 uv4 = vary_texcoord3.xy; + + if (cloud_scale < 0.001) + { + discard; + } + + vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + + // Offset texture coords + uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); + + cloudDensity *= 1.0 - (density_variance * density_variance); + + // Compute alpha1, the main cloud opacity + + float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + if (alpha1 < 0.001f) + { + discard; + } + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (cloudNoise(uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + // Combine + vec4 color; + color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); + color *= 2.; + + /// Gamma correct for WL (soft clip effect). + frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1); + frag_data[1] = vec4(0.0,0.0,0.0,0.0); + frag_data[2] = vec4(0,0,1,0); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index c1dd45cd67..fb978691da 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -46,6 +46,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -57,6 +59,7 @@ uniform float density_multiplier; uniform float max_y; uniform vec4 glow; +uniform float sun_moon_glow_factor; uniform vec4 cloud_color; @@ -65,126 +68,128 @@ uniform float cloud_scale; void main() { - // World / view / projection - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - - vary_texcoord0 = texcoord0; - - // Get relative position - vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); - - // Set altitude - if (P.y > 0.) - { - P *= (max_y / P.y); - } - else - { - P *= (-32000. / P.y); - } - - // Can normalize then - vec3 Pn = normalize(P); - float Plen = length(P); - - // Initialize temp variables - vec4 temp1 = vec4(0.); - vec4 temp2 = vec4(0.); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = sunlight_color; - vec4 light_atten; - - - // Sunlight attenuation effect (hue and brightness) due to atmosphere - // this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - - // Calculate relative weights - temp1 = blue_density + haze_density; - blue_weight = blue_density / temp1; - haze_weight = haze_density / temp1; - - // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // Distance - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z); - - - // Compute haze glow - temp2.x = dot(Pn, lightnorm.xyz); - temp2.x = 1. - temp2.x; - // temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .001); - // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - // Higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - // glow.z should be negative, so we're doing a sort of (1 / "angle") function - - // Add "minimum anti-solar illumination" - temp2.x += .25; - - // Increase ambient when there are more clouds - vec4 tmpAmbient = ambient; - tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5; - - // Dim sunlight by cloud shadow percentage - sunlight *= (1. - cloud_shadow); - - // Haze color below cloud - vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight * temp2.x + tmpAmbient) - ); - - // CLOUDS - - sunlight = sunlight_color; - temp2.y = max(0., lightnorm.y * 2.); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // Cloud color out - vary_CloudColorSun = (sunlight * temp2.x) * cloud_color; - vary_CloudColorAmbient = tmpAmbient * cloud_color; - - // Attenuate cloud color by atmosphere - temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds - vary_CloudColorSun *= temp1; - vary_CloudColorAmbient *= temp1; - vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1); - - // Make a nice cloud density based on the cloud_shadow value that was passed in. - vary_CloudDensity = 2. * (cloud_shadow - 0.25); - - - // Texture coords - vary_texcoord0 = texcoord0; - vary_texcoord0.xy -= 0.5; - vary_texcoord0.xy /= cloud_scale; - vary_texcoord0.xy += 0.5; - - vary_texcoord1 = vary_texcoord0; - vary_texcoord1.x += lightnorm.x * 0.0125; - vary_texcoord1.y += lightnorm.z * 0.0125; - - vary_texcoord2 = vary_texcoord0 * 16.; - vary_texcoord3 = vary_texcoord1 * 16.; - - // Combine these to minimize register use - vary_CloudColorAmbient += oHazeColorBelowCloud; - - // needs this to compile on mac - //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); - - // END CLOUDS + // World / view / projection + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + + vary_texcoord0 = texcoord0; + + // Get relative position + vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); + + // Set altitude + if (P.y > 0.) + { + P *= (max_y / P.y); + } + else + { + P *= (-32000. / P.y); + } + + // Can normalize then + vec3 Pn = normalize(P); + float Plen = length(P); + + // Initialize temp variables + vec4 temp1 = vec4(0.); + vec4 temp2 = vec4(0.); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + + // Calculate relative weights + temp1 = blue_density + haze_density; + blue_weight = blue_density / temp1; + haze_weight = haze_density / temp1; + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Distance + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z); + + + // Compute haze glow + temp2.x = dot(Pn, lightnorm.xyz); + temp2.x = 1. - temp2.x; + // temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .001); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + temp2.x *= sun_moon_glow_factor; + + // Add "minimum anti-solar illumination" + temp2.x += .25; + + // Increase ambient when there are more clouds + vec4 tmpAmbient = ambient; + tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5; + + // Dim sunlight by cloud shadow percentage + sunlight *= (1. - cloud_shadow); + + // Haze color below cloud + vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight * temp2.x + tmpAmbient) + ); + + // CLOUDS + + sunlight = sunlight_color; + temp2.y = max(0., lightnorm.y * 2.); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Cloud color out + vary_CloudColorSun = (sunlight * temp2.x) * cloud_color; + vary_CloudColorAmbient = tmpAmbient * cloud_color; + + // Attenuate cloud color by atmosphere + temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds + vary_CloudColorSun *= temp1; + vary_CloudColorAmbient *= temp1; + vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1); + + // Make a nice cloud density based on the cloud_shadow value that was passed in. + vary_CloudDensity = 2. * (cloud_shadow - 0.25); + + + // Texture coords + vary_texcoord0 = texcoord0; + vary_texcoord0.xy -= 0.5; + vary_texcoord0.xy /= max(0.001, cloud_scale); + vary_texcoord0.xy += 0.5; + + vary_texcoord1 = vary_texcoord0; + vary_texcoord1.x += lightnorm.x * 0.0125; + vary_texcoord1.y += lightnorm.z * 0.0125; + + vary_texcoord2 = vary_texcoord0 * 16.; + vary_texcoord3 = vary_texcoord1 * 16.; + + // Combine these to minimize register use + vary_CloudColorAmbient += oHazeColorBelowCloud; + + // needs this to compile on mac + //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); + + // END CLOUDS } diff --git a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl index 478373d729..c0439006f7 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl @@ -26,19 +26,36 @@ uniform vec4 gamma; +uniform int no_atmo; vec3 getAtmosAttenuation(); +vec3 getAdditiveColor(); -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); +vec3 scaleSoftClipFrag(vec3 light) +{ + if (no_atmo == 1) + { + return light; + } + //soft clip effect: + light = 1. - clamp(light, vec3(0.), vec3(1.)); + light = 1. - pow(light, gamma.xxx); + return light; +} + +vec3 scaleSoftClip(vec3 light) +{ + return scaleSoftClipFrag(light); +} - return light; +vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 add, vec3 atten) +{ + //return mix(scaleSoftClipFrag(light.rgb), add, atten); + return scaleSoftClipFrag(light.rgb); } -vec3 fullbrightScaleSoftClip(vec3 light) { - return mix(scaleSoftClip(light.rgb), light.rgb, getAtmosAttenuation()); +vec3 fullbrightScaleSoftClip(vec3 light) +{ + return fullbrightScaleSoftClipFrag(light, getAdditiveColor(), getAtmosAttenuation()); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl index e2a2367626..28d185b9af 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl @@ -1,5 +1,5 @@ /** - * @file WLSkyF.glsl + * @file class2/windlight/skyF.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -35,17 +35,10 @@ out vec4 frag_color; VARYING vec4 vary_HazeColor; -uniform sampler2D cloud_noise_texture; uniform vec4 gamma; /// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); - - return light; -} +vec3 scaleSoftClip(vec3 light); void main() { diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index 3788ddaf2d..a65cc09c73 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -39,6 +39,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -50,7 +52,7 @@ uniform float density_multiplier; uniform float max_y; uniform vec4 glow; - +uniform float sun_moon_glow_factor; uniform vec4 cloud_color; void main() @@ -82,7 +84,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere @@ -119,6 +121,8 @@ void main() temp2.x = pow(temp2.x, glow.z); // glow.z should be negative, so we're doing a sort of (1 / "angle") function + temp2.x *= sun_moon_glow_factor; + // Add "minimum anti-solar illumination" temp2.x += .25; diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index 8a8e4cb0f6..df731662e8 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -30,24 +30,49 @@ vec3 getAdditiveColor(); vec3 getAtmosAttenuation(); -uniform sampler2D cloudMap; -uniform vec4 cloud_pos_density1; +uniform int no_atmo; -vec3 atmosTransport(vec3 light) { - light *= getAtmosAttenuation().r; - light += getAdditiveColor() * 2.0; - return light; +vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) +{ + if (no_atmo == 1) + { + return light; + } + light *= atten.r; + light += additive * 2.0; + return light; } -vec3 fullbrightAtmosTransport(vec3 light) { - float brightness = dot(light.rgb, vec3(0.33333)); +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) +{ + if (no_atmo == 1) + { + return light; + } + float brightness = dot(light.rgb, vec3(0.33333)); + return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive.rgb, brightness * brightness); +} - return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); +vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { + if (no_atmo == 1) + { + return light; + } + float brightness = dot(light.rgb, vec3(0.33333)); + return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness); } -vec3 fullbrightShinyAtmosTransport(vec3 light) { - float brightness = dot(light.rgb, vec3(0.33333)); +vec3 atmosTransport(vec3 light) +{ + return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); +} - return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness); +vec3 fullbrightAtmosTransport(vec3 light) +{ + return fullbrightAtmosTransportFrag(light,getAdditiveColor(), getAtmosAttenuation()); } +vec3 fullbrightShinyAtmosTransport(vec3 light) +{ + return fullbrightShinyAtmosTransportFrag(light,getAdditiveColor(), getAtmosAttenuation()); +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class3/deferred/attachmentShadowF.glsl new file mode 100644 index 0000000000..d973326f93 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/attachmentShadowF.glsl @@ -0,0 +1,44 @@ +/** + * @file avatarShadowF.glsl + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +VARYING vec4 pos; +VARYING vec2 vary_texcoord0; + +vec4 computeMoments(float depth, float a); + +void main() +{ + frag_color = computeMoments(length(pos), 1.0); +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class3/deferred/attachmentShadowV.glsl new file mode 100644 index 0000000000..1a655e6467 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/attachmentShadowV.glsl @@ -0,0 +1,49 @@ +/** + * @file attachmentShadowV.glsl + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 projection_matrix; +uniform mat4 modelview_matrix; +uniform mat4 texture_matrix0; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +mat4 getObjectSkinnedTransform(); + +VARYING vec4 pos; + +void main() +{ + //transform vertex + mat4 mat = getObjectSkinnedTransform(); + + mat = modelview_matrix * mat; + pos = (mat*vec4(position.xyz, 1.0)); + pos = projection_matrix * vec4(pos.xyz, 1.0); + +#if !defined(DEPTH_CLAMP) + pos.z = max(pos.z, -pos.w+0.01); +#endif + gl_Position = pos; +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class3/deferred/avatarShadowF.glsl index 587f3d5a94..48eefc7a73 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/avatarShadowF.glsl @@ -1,5 +1,5 @@ /** - * @file srgb.glsl + * @file avatarShadowF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -23,24 +23,30 @@ * $/LicenseInfo$ */ -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +/*[EXTRA_CODE_HERE]*/ - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - return mix(high_range, low_range, lte); +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif -} +uniform sampler2D diffuseMap; -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; +#if !defined(DEPTH_CLAMP) +VARYING vec4 post_pos; +#endif - bvec3 lt = lessThan(cl,vec3(0.0031308)); - return mix(high_range, low_range, lt); +VARYING vec4 pos; + +vec4 computeMoments(float depth, float a); + +void main() +{ + frag_color = computeMoments(length(pos), 1.0); +#if !defined(DEPTH_CLAMP) + gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); +#endif } diff --git a/indra/newview/app_settings/shaders/class3/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class3/deferred/avatarShadowV.glsl new file mode 100644 index 0000000000..164b355f20 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/avatarShadowV.glsl @@ -0,0 +1,68 @@ +/** + * @file avatarShadowV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 projection_matrix; + +mat4 getSkinnedTransform(); + +ATTRIBUTE vec3 position; +ATTRIBUTE vec3 normal; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING vec4 post_pos; +#endif + +VARYING vec4 pos; + +void main() +{ + vec3 norm; + + vec4 pos_in = vec4(position.xyz, 1.0); + mat4 trans = getSkinnedTransform(); + + pos.x = dot(trans[0], pos_in); + pos.y = dot(trans[1], pos_in); + pos.z = dot(trans[2], pos_in); + pos.w = 1.0; + + norm.x = dot(trans[0].xyz, normal); + norm.y = dot(trans[1].xyz, normal); + norm.z = dot(trans[2].xyz, normal); + norm = normalize(norm); + + pos = projection_matrix * pos; + +#if !defined(DEPTH_CLAMP) + post_pos = pos; + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + +} + + diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl new file mode 100644 index 0000000000..c0ba804a30 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl @@ -0,0 +1,120 @@ +/** + * @file class3/deferred/cloudsF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING float vary_CloudDensity; +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; +VARYING vec2 vary_texcoord3; + +uniform sampler2D cloud_noise_texture; +uniform sampler2D cloud_noise_texture_next; +uniform float blend_factor; +uniform vec4 cloud_pos_density1; +uniform vec4 cloud_pos_density2; +uniform vec4 cloud_color; +uniform float cloud_shadow; +uniform float cloud_scale; +uniform float cloud_variance; +uniform vec3 ambient; +uniform vec3 camPosLocal; +uniform vec3 sun_dir; +uniform float sun_size; +uniform float far_z; + +vec4 cloudNoise(vec2 uv) +{ + vec4 a = texture2D(cloud_noise_texture, uv); + vec4 b = texture2D(cloud_noise_texture_next, uv); + vec4 cloud_noise_sample = mix(a, b, blend_factor); + return normalize(cloud_noise_sample); +} + +vec4 computeMoments(float depth, float alpha); + +void main() +{ + if (cloud_scale >= 0.001) + { + // Set variables + vec2 uv1 = vary_texcoord0.xy; + vec2 uv2 = vary_texcoord1.xy; + vec2 uv3 = vary_texcoord2.xy; + float cloudDensity = 2.0 * (cloud_shadow - 0.25); + + vec2 uv4 = vary_texcoord3.xy; + + vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + + // Offset texture coords + uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); + + cloudDensity *= 1.0 - (density_variance * density_variance); + + // Compute alpha1, the main cloud opacity + float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + if (alpha1 < 0.001f) + { + discard; + } + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (cloudNoise(uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + frag_color = computeMoments(length(pos), alpha1); + } + else + { + frag_color = vec4(0); + } +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowV.glsl new file mode 100644 index 0000000000..effb070f93 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowV.glsl @@ -0,0 +1,63 @@ +/** + * @file cloudShadowV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING vec2 vary_texcoord0; +VARYING vec4 vertex_color; + +void passTextureIndex(); + +void main() +{ + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + pos = modelview_projection_matrix * pre_pos; + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + +#if !defined(DEPTH_CLAMP) + pos_zd2 = pos.z * 0.5; + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + + passTextureIndex(); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + vertex_color = diffuse_color; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl new file mode 100644 index 0000000000..cc7a86f35c --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl @@ -0,0 +1,167 @@ +/** + * @file class3/deferred/cloudsF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +///////////////////////////////////////////////////////////////////////// +// The fragment shader for the sky +///////////////////////////////////////////////////////////////////////// + +VARYING vec4 vary_CloudColorSun; +VARYING vec4 vary_CloudColorAmbient; +VARYING float vary_CloudDensity; +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; +VARYING vec2 vary_texcoord3; +VARYING vec3 vary_pos; + +uniform sampler2D cloud_noise_texture; +uniform sampler2D cloud_noise_texture_next; +uniform float blend_factor; +uniform vec4 cloud_pos_density1; +uniform vec4 cloud_pos_density2; +uniform vec4 cloud_color; +uniform float cloud_shadow; +uniform float cloud_scale; +uniform float cloud_variance; +uniform vec3 ambient; +uniform vec3 camPosLocal; +uniform vec3 sun_dir; +uniform float sun_size; +uniform float far_z; + +uniform sampler2D transmittance_texture; +uniform sampler3D scattering_texture; +uniform sampler3D single_mie_scattering_texture; +uniform sampler2D irradiance_texture; +uniform sampler2D sh_input_r; +uniform sampler2D sh_input_g; +uniform sampler2D sh_input_b; + +vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance); + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light); + +vec4 cloudNoise(vec2 uv) +{ + vec4 a = texture2D(cloud_noise_texture, uv); + vec4 b = texture2D(cloud_noise_texture_next, uv); + vec4 cloud_noise_sample = mix(a, b, blend_factor); + return cloud_noise_sample; +} + +void main() +{ + // Set variables + vec2 uv1 = vary_texcoord0.xy; + vec2 uv2 = vary_texcoord1.xy; + vec2 uv3 = vary_texcoord2.xy; + float cloudDensity = 2.0 * (cloud_shadow - 0.25); + + if (cloud_scale < 0.001) + { + discard; + } + + vec2 uv4 = vary_texcoord3.xy; + + vec2 disturbance = vec2(cloudNoise(uv1 / 16.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + + // Offset texture coords + uv1 += cloud_pos_density1.xy + disturbance; //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy + disturbance; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0)); + + cloudDensity *= 1.0 - (density_variance * density_variance); + + // Compute alpha1, the main cloud opacity + float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + if (alpha1 < 0.001f) + { + discard; + } + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (cloudNoise(uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + vec3 view_ray = vary_pos.xyz + camPosLocal; + + vec3 view_direction = normalize(view_ray); + vec3 sun_direction = normalize(sun_dir); + vec3 earth_center = vec3(0, 0, -6360.0f); + vec3 camPos = (camPosLocal / 1000.0f) - earth_center; + + vec3 transmittance; + vec3 radiance_sun = GetSkyLuminance(camPos, view_direction, 1.0 - alpha1, sun_direction, transmittance); + + vec3 sun_color = vec3(1.0) - exp(-radiance_sun * 0.0001); + + // Combine + vec4 color; + + vec4 l1tap = vec4(1.0/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265)); + + vec4 l1r = texture2D(sh_input_r, vec2(0,0)); + vec4 l1g = texture2D(sh_input_g, vec2(0,0)); + vec4 l1b = texture2D(sh_input_b, vec2(0,0)); + + vec3 sun_indir = vec3(-view_direction.xy, view_direction.z); + vec3 amb = vec3(dot(l1r, l1tap * vec4(1, sun_indir)), + dot(l1g, l1tap * vec4(1, sun_indir)), + dot(l1b, l1tap * vec4(1, sun_indir))); + + + amb = max(vec3(0), amb); + + color.rgb = sun_color * cloud_color.rgb * (1. - alpha2); + color.rgb = pow(color.rgb, vec3(1.0 / 2.2)); + color.rgb += amb; + + frag_data[0] = vec4(color.rgb, alpha1); + frag_data[1] = vec4(0); + frag_data[2] = vec4(0,1,0,1); +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl new file mode 100644 index 0000000000..71e422ddf0 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudsV.glsl @@ -0,0 +1,70 @@ +/** + * @file WLCloudsV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; +uniform mat4 modelview_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +////////////////////////////////////////////////////////////////////////// +// The vertex shader for creating the atmospheric sky +/////////////////////////////////////////////////////////////////////////////// + +// Output parameters +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; +VARYING vec2 vary_texcoord3; +VARYING vec3 vary_pos; + +// Inputs +uniform float cloud_scale; +uniform vec4 lightnorm; +uniform vec3 camPosLocal; + +void main() +{ + vary_pos = position; + + // World / view / projection + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + + // Texture coords + vary_texcoord0 = texcoord0; + vary_texcoord0.xy -= 0.5; + vary_texcoord0.xy /= max(0.001, cloud_scale); + vary_texcoord0.xy += 0.5; + + vary_texcoord1 = vary_texcoord0; + vary_texcoord1.x += lightnorm.x * 0.0125; + vary_texcoord1.y += lightnorm.z * 0.0125; + + vary_texcoord2 = vary_texcoord0 * 16.; + vary_texcoord3 = vary_texcoord1 * 16.; + + // END CLOUDS +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/deferredUtil.glsl new file mode 100644 index 0000000000..e27bbce094 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/deferredUtil.glsl @@ -0,0 +1,79 @@ +/** + * @file class1/deferred/deferredUtil.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform sampler2DRect normalMap; +uniform sampler2DRect depthMap; + +uniform mat4 inv_proj; +uniform vec2 screen_res; + +vec2 getScreenCoordinate(vec2 screenpos) +{ + vec2 sc = screenpos.xy * 2.0; + if (screen_res.x > 0 && screen_res.y > 0) + { + sc /= screen_res; + } + return sc - vec2(1.0, 1.0); +} + +vec3 getNorm(vec2 screenpos) +{ + vec2 enc = texture2DRect(normalMap, screenpos.xy).xy; + vec2 fenc = enc*4-2; + float f = dot(fenc,fenc); + float g = sqrt(1-f/4); + vec3 n; + n.xy = fenc*g; + n.z = 1-f/2; + return n; +} + +float getDepth(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen).r; + return depth; +} + +vec4 getPosition(vec2 pos_screen) +{ + float depth = getDepth(pos_screen); + vec2 sc = getScreenCoordinate(pos_screen); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +vec4 getPositionWithDepth(vec2 pos_screen, float depth) +{ + vec2 sc = getScreenCoordinate(pos_screen); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/depthToShadowVolumeG.glsl b/indra/newview/app_settings/shaders/class3/deferred/depthToShadowVolumeG.glsl new file mode 100644 index 0000000000..cdaff4b09f --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/depthToShadowVolumeG.glsl @@ -0,0 +1,202 @@ +/** + * @file depthToShadowVolumeG.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#extension GL_ARB_geometry_shader4 : enable +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +layout (triangles) in; +layout (triangle_strip, max_vertices = 128) out; + +uniform sampler2DRect depthMap; +uniform mat4 shadowMatrix[6]; +uniform vec4 lightpos; + +VARYING vec2 vary_texcoord0; + +out vec3 to_vec; + +void cross_products(out vec4 ns[3], int a, int b, int c) +{ + ns[0] = cross(gl_PositionIn[b].xyz - gl_PositionIn[a].xyz, gl_PositionIn[c].xyz - gl_PositionIn[a].xyz); + ns[1] = cross(gl_PositionIn[c].xyz - gl_PositionIn[b].xyz, gl_PositionIn[a].xyz - gl_PositionIn[b].xyz); + ns[2] = cross(gl_PositionIn[a].xyz - gl_PositionIn[c].xyz, gl_PositionIn[b].xyz - gl_PositionIn[c].xyz); +} + +vec3 getLightDirection(vec4 lightpos, vec3 pos) +{ + + vec3 lightdir = lightpos.xyz - lightpos.w * pos; + return lightdir; +} + +void emitTri(vec4 v[3]) +{ + gl_Position = proj_matrix * v[0]; + EmitVertex(); + + gl_Position = proj_matrix * v[1]; + EmitVertex(); + + gl_Position = proj_matrix * v[2]; + EmitVertex(); + + EndPrimitive(); +} + +void emitQuad(vec4 v[4] +{ + // Emit a quad as a triangle strip. + gl_Position = proj_matrix*v[0]; + EmitVertex(); + + gl_Position = proj_matrix*v[1]; + EmitVertex(); + + gl_Position = proj_matrix*v[2]; + EmitVertex(); + + gl_Position = proj_matrix*v[3]; + EmitVertex(); + + EndPrimitive(); +} + +void emitPrimitives(int layer) +{ + int i = layer; + gl_Layer = i; + + vec4 depth1 = vec4(texture2DRect(depthMap, tc0).rg, texture2DRect(depthMap, tc1).rg)); + vec3 depth2 = vec4(texture2DRect(depthMap, tc2).rg, texture2DRect(depthMap, tc3).rg)); + vec3 depth3 = vec4(texture2DRect(depthMap, tc4).rg, texture2DRect(depthMap, tc5).rg)); + vec3 depth4 = vec4(texture2DRect(depthMap, tc6).rg, texture2DRect(depthMap, tc7).rg)); + + depth1 = min(depth1, depth2); + depth1 = min(depth1, depth3); + depth1 = min(depth1, depth4); + + vec2 depth = min(depth1.xy, depth1.zw); + + int side = sqrt(gl_VerticesIn); + + for (int j = 0; j < side; j++) + { + for (int k = 0; k < side; ++k) + { + vec3 pos = gl_PositionIn[(j * side) + k].xyz; + vec4 v = shadowMatrix[i] * vec4(pos, 1.0); + gl_Position = v; + to_vec = pos - light_position.xyz * depth; + EmitVertex(); + } + + EndPrimitive(); + } + + vec3 norms[3]; // Normals + vec3 lightdir3]; // Directions toward light + + vec4 v[4]; // Temporary vertices + + vec4 or_pos[3] = + { // Triangle oriented toward light source + gl_PositionIn[0], + gl_PositionIn[2], + gl_PositionIn[4] + }; + + // Compute normal at each vertex. + cross_products(n, 0, 2, 4); + + // Compute direction from vertices to light. + lightdir[0] = getLightDirection(lightpos, gl_PositionIn[0].xyz); + lightdir[1] = getLightDirection(lightpos, gl_PositionIn[2].xyz); + lightdir[2] = getLightDirection(lightpos, gl_PositionIn[4].xyz); + + // Check if the main triangle faces the light. + bool faces_light = true; + if (!(dot(ns[0],d[0]) > 0 + |dot(ns[1],d[1]) > 0 + |dot(ns[2],d[2]) > 0)) + { + // Flip vertex winding order in or_pos. + or_pos[1] = gl_PositionIn[4]; + or_pos[2] = gl_PositionIn[2]; + faces_light = false; + } + + // Near cap: simply render triangle. + emitTri(or_pos); + + // Far cap: extrude positions to infinity. + v[0] =vec4(lightpos.w * or_pos[0].xyz - lightpos.xyz,0); + v[1] =vec4(lightpos.w * or_pos[2].xyz - lightpos.xyz,0); + v[2] =vec4(lightpos.w * or_pos[1].xyz - lightpos.xyz,0); + + emitTri(v); + + // Loop over all edges and extrude if needed. + for ( int i=0; i<3; i++ ) + { + // Compute indices of neighbor triangle. + int v0 = i*2; + int nb = (i*2+1); + int v1 = (i*2+2) % 6; + cross_products(n, v0, nb, v1); + + // Compute direction to light, again as above. + d[0] =lightpos.xyz-lightpos.w*gl_PositionIn[v0].xyz; + d[1] =lightpos.xyz-lightpos.w*gl_PositionIn[nb].xyz; + d[2] =lightpos.xyz-lightpos.w*gl_PositionIn[v1].xyz; + + bool is_parallel = gl_PositionIn[nb].w < 1e-5; + + // Extrude the edge if it does not have a + // neighbor, or if it's a possible silhouette. + if (is_parallel || + ( faces_light != (dot(ns[0],d[0])>0 || + dot(ns[1],d[1])>0 || + dot(ns[2],d[2])>0) )) + { + // Make sure sides are oriented correctly. + int i0 = faces_light ? v0 : v1; + int i1 = faces_light ? v1 : v0; + + v[0] = gl_PositionIn[i0]; + v[1] = vec4(lightpos.w*gl_PositionIn[i0].xyz - lightpos.xyz, 0); + v[2] = gl_PositionIn[i1]; + v[3] = vec4(lightpos.w*gl_PositionIn[i1].xyz - lightpos.xyz, 0); + + emitQuad(v); + } + } +} + +void main() +{ + // Output + emitPrimitives(0); +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShF.glsl b/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShF.glsl new file mode 100644 index 0000000000..34d26cddea --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShF.glsl @@ -0,0 +1,70 @@ +/** + * @file class3/deferred/gatherSkyShF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +VARYING vec2 vary_frag; + +uniform vec2 screen_res; +uniform sampler2D sh_input_r; +uniform sampler2D sh_input_g; +uniform sampler2D sh_input_b; + +void main() +{ + vec2 offset = vec2(2.0) / screen_res; + + vec4 r = vec4(0); + vec4 g = vec4(0); + vec4 b = vec4(0); + + vec2 tc = vary_frag * 2.0; + + r += texture2D(sh_input_r, tc + vec2(0, 0)); + r += texture2D(sh_input_r, tc + vec2(offset.x, 0)); + r += texture2D(sh_input_r, tc + vec2(0, offset.y)); + r += texture2D(sh_input_r, tc + vec2(offset.x, offset.y)); + r /= 4.0f; + + g += texture2D(sh_input_g, tc + vec2(0, 0)); + g += texture2D(sh_input_g, tc + vec2(offset.x, 0)); + g += texture2D(sh_input_g, tc + vec2(0, offset.y)); + g += texture2D(sh_input_g, tc + vec2(offset.x, offset.y)); + g /= 4.0f; + + b += texture2D(sh_input_b, tc + vec2(0, 0)); + b += texture2D(sh_input_b, tc + vec2(offset.x, 0)); + b += texture2D(sh_input_b, tc + vec2(0, offset.y)); + b += texture2D(sh_input_b, tc + vec2(offset.x, offset.y)); + b /= 4.0f; + + frag_data[0] = r; + frag_data[1] = g; + frag_data[2] = b; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShV.glsl b/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShV.glsl new file mode 100644 index 0000000000..337c8a50fe --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShV.glsl @@ -0,0 +1,40 @@ +/** + * @file gatherSkyShV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_frag; +uniform vec2 screen_res; + +void main() +{ + // pass through untransformed fullscreen pos + float oo_divisor = screen_res.x / 64.0; + vec3 pos = (position.xyz * oo_divisor) + vec3(oo_divisor - 1, oo_divisor - 1, 0); + gl_Position = vec4(pos.xyz, 1.0); + vary_frag = texcoord0 * oo_divisor; +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/genSkyShF.glsl b/indra/newview/app_settings/shaders/class3/deferred/genSkyShF.glsl new file mode 100644 index 0000000000..c02e6d1e57 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/genSkyShF.glsl @@ -0,0 +1,112 @@ +/** + * @file class3/deferred/genSkyShF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +VARYING vec2 vary_frag; + +uniform vec3 sun_dir; + +uniform sampler2D transmittance_texture; +uniform sampler3D scattering_texture; +uniform sampler3D single_mie_scattering_texture; +uniform sampler2D irradiance_texture; +uniform vec4 gamma; + +vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance); + +vec3 calcDirection(vec2 tc) +{ + float phi = tc.y * 2.0 * 3.14159265; + float cosTheta = sqrt(1.0 - tc.x); + float sinTheta = sqrt(1.0 - cosTheta * cosTheta); + return vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta); +} + +// reverse mapping above to convert a hemisphere direction into phi/theta values +void getPhiAndThetaFromDirection(vec3 dir, out float phi, out float theta) +{ + float sin_theta; + float cos_theta; + cos_theta = dir.z; + theta = acos(cos_theta); + sin_theta = sin(theta); + phi = abs(sin_theta) > 0.0001 ? acos(dir.x / sin_theta) : 1.0; +} + +// reverse mapping above to convert a hemisphere direction into an SH texture sample pos +vec2 calcShUvFromDirection(vec3 dir) +{ + vec2 uv; + float phi; + float theta; + getPhiAndThetaFromDirection(dir, phi, theta); + uv.y = phi / 2.0 * 3.14159265; + uv.x = theta / 2.0 * 3.14159265; + return uv; +} + +void projectToL1(vec3 n, vec3 c, vec4 basis, out vec4 coeffs[3]) +{ + coeffs[0] = vec4(basis.x, n * basis.yzw * c.r); + coeffs[1] = vec4(basis.x, n * basis.yzw * c.g); + coeffs[2] = vec4(basis.x, n * basis.yzw * c.b); +} + +void main() +{ + float Y00 = sqrt(1.0 / 3.14159265) * 0.5; + float Y1x = sqrt(3.0 / 3.14159265) * 0.5; + float Y1y = Y1x; + float Y1z = Y1x; + + vec4 L1 = vec4(Y00, Y1x, Y1y, Y1z); + + vec3 view_direction = calcDirection(vary_frag); + vec3 sun_direction = normalize(sun_dir); + vec3 cam_pos = vec3(0, 0, 6360); + + vec3 transmittance; + vec3 radiance = GetSkyLuminance(cam_pos, view_direction, 0.0f, sun_direction, transmittance); + + vec3 color = vec3(1.0) - exp(-radiance * 0.0001); + + color = pow(color, vec3(1.0/2.2)); + + vec4 coeffs[3]; + coeffs[0] = vec4(0); + coeffs[1] = vec4(0); + coeffs[2] = vec4(0); + + projectToL1(view_direction, color.rgb, L1, coeffs); + + frag_data[0] = coeffs[0]; + frag_data[1] = coeffs[1]; + frag_data[2] = coeffs[2]; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/genSkyShV.glsl b/indra/newview/app_settings/shaders/class3/deferred/genSkyShV.glsl new file mode 100644 index 0000000000..b466883dc7 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/genSkyShV.glsl @@ -0,0 +1,37 @@ +/** + * @file genSkyShV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_frag; + +void main() +{ + // pass through untransformed fullscreen pos + gl_Position = vec4(position.xyz, 1.0); + vary_frag = texcoord0; +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/indirect.glsl b/indra/newview/app_settings/shaders/class3/deferred/indirect.glsl new file mode 100644 index 0000000000..33c5667cae --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/indirect.glsl @@ -0,0 +1,44 @@ +/** + * @file class3/deferred/indirect.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +uniform sampler2D sh_input_r; +uniform sampler2D sh_input_g; +uniform sampler2D sh_input_b; + +vec3 GetIndirect(vec3 norm) +{ + vec4 l1tap = vec4(1.0/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265)); + vec4 l1r = texture2D(sh_input_r, vec2(0,0)); + vec4 l1g = texture2D(sh_input_g, vec2(0,0)); + vec4 l1b = texture2D(sh_input_b, vec2(0,0)); + vec3 indirect = vec3(dot(l1r, l1tap * vec4(1, norm.xyz)), + dot(l1g, l1tap * vec4(1, norm.xyz)), + dot(l1b, l1tap * vec4(1, norm.xyz))); + indirect = clamp(indirect, vec3(0), vec3(1.0)); + return indirect; +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl new file mode 100644 index 0000000000..8bb3f07fc6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl @@ -0,0 +1,117 @@ +/** + * @file lightInfo.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +struct DirectionalLightInfo +{ + vec4 pos; + float depth; + vec4 normal; + vec3 normalizedLightDirection; + vec3 normalizedToLight; + float lightIntensity; + vec3 lightDiffuseColor; + float specExponent; + float shadow; +}; + +struct SpotLightInfo +{ + vec4 pos; + float depth; + vec4 normal; + vec3 normalizedLightDirection; + vec3 normalizedToLight; + float lightIntensity; + float attenuation; + float distanceToLight; + vec3 lightDiffuseColor; + float innerHalfAngleCos; + float outerHalfAngleCos; + float spotExponent; + float specExponent; + float shadow; +}; + +struct PointLightInfo +{ + vec4 pos; + float depth; + vec4 normal; + vec3 normalizedToLight; + float lightIntensity; + float attenuation; + float distanceToLight; + vec3 lightDiffuseColor; + float lightRadius; + float specExponent; + vec3 worldspaceLightDirection; + float shadow; +}; + +float attenuate(float attenuationSelection, float distanceToLight) +{ +// LLRENDER_REVIEW +// sh/could eventually consume attenuation func defined in texture + return (attenuationSelection == 0.0f) ? 1.0f : // none + (attenuationSelection < 1.0f) ? (1.0f / distanceToLight) : // linear atten + (attenuationSelection < 2.0f) ? (1.0f / (distanceToLight*distanceToLight)) // quadratic atten + : (1.0f / (distanceToLight*distanceToLight*distanceToLight)); // cubic atten +} + + +vec3 lightDirectional(struct DirectionalLightInfo dli) +{ + float lightIntensity = dli.lightIntensity; + lightIntensity *= dot(dli.normal.xyz, dli.normalizedLightDirection); + //lightIntensity *= directionalShadowSample(vec4(dli.pos.xyz, 1.0f), dli.depth, dli.directionalShadowMap, dli.directionalShadowMatrix); + return lightIntensity * dli.lightDiffuseColor; +} + + +vec3 lightSpot(struct SpotLightInfo sli) +{ + float penumbraRange = (sli.outerHalfAngleCos - sli.innerHalfAngleCos); + float coneAngleCos = max(dot(sli.normalizedLightDirection, sli.normalizedToLight), 0.0); + float coneAttenFactor = (coneAngleCos <= sli.outerHalfAngleCos) ? 1.0f : pow(smoothstep(1,0, sli.outerHalfAngleCos / penumbraRange), sli.spotExponent); + float distanceAttenuation = attenuate(sli.attenuation, sli.distanceToLight); + float lightIntensity = sli.lightIntensity; + lightIntensity *= distanceAttenuation; + lightIntensity *= max(dot(sli.normal.xyz, sli.normalizedLightDirection), 0.0); + lightIntensity *= coneAttenFactor; + lightIntensity *= sli.shadow; + return lightIntensity * sli.lightDiffuseColor; +} + +vec3 lightPoint(struct PointLightInfo pli) +{ + float padRadius = pli.lightRadius * 0.1; // distance for which to perform smoothed dropoff past light radius + float distanceAttenuation = attenuate(pli.attenuation, pli.distanceToLight); + float lightIntensity = pli.lightIntensity; + lightIntensity*= distanceAttenuation; + lightIntensity *= clamp((padRadius - pli.distanceToLight + pli.lightRadius) / padRadius, 0.0, 1.0); + lightIntensity *= pli.shadow; + lightIntensity *= max(dot(pli.normal.xyz, pli.normalizedToLight), 0.0); + return lightIntensity * pli.lightDiffuseColor; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl new file mode 100644 index 0000000000..72bccc5627 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -0,0 +1,303 @@ +/** + * @file multiSpotLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable +#extension GL_ARB_shader_texture_lod : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect diffuseRect; +uniform sampler2DRect specularRect; +uniform sampler2DRect depthMap; +uniform sampler2DRect normalMap; +uniform samplerCube environmentMap; +uniform sampler2DRect lightMap; +uniform sampler2D noiseMap; +uniform sampler2D projectionMap; +uniform sampler2D lightFunc; + +uniform mat4 proj_mat; //screen space to light space +uniform float proj_near; //near clip for projection +uniform vec3 proj_p; //plane projection is emitting from (in screen space) +uniform vec3 proj_n; +uniform float proj_focus; //distance from plane to begin blurring +uniform float proj_lod; //(number of mips in proj map) +uniform float proj_range; //range between near clip and far clip plane of projection +uniform float proj_ambient_lod; +uniform float proj_ambiance; +uniform float near_clip; +uniform float far_clip; + +uniform vec3 proj_origin; //origin of projection to be used for angular attenuation +uniform float sun_wash; +uniform int proj_shadow_idx; +uniform float shadow_fade; + +uniform vec3 center; +uniform float size; +uniform vec3 color; +uniform float falloff; + +VARYING vec4 vary_fragcoord; +uniform vec2 screen_res; + +uniform mat4 inv_proj; + +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); +vec3 getNorm(vec2 pos_screen); + +vec4 correctWithGamma(vec4 col) +{ + return vec4(srgb_to_linear(col.rgb), col.a); +} + +vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = srgb_to_linear(ret.rgb); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + d *= min(1, d * (proj_lod - lod)); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = tc-vec2(0.5); + + float d = dot(dist,dist); + + ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0); + + return ret; +} + + +vec4 getPosition(vec2 pos_screen); + +void main() +{ + vec4 frag = vary_fragcoord; + frag.xyz /= frag.w; + frag.xyz = frag.xyz*0.5+0.5; + frag.xy *= screen_res; + + vec3 pos = getPosition(frag.xy).xyz; + vec3 lv = center.xyz-pos.xyz; + float dist = length(lv); + dist /= size; + if (dist > 1.0) + { + discard; + } + + float shadow = 1.0; + + if (proj_shadow_idx >= 0) + { + vec4 shd = texture2DRect(lightMap, frag.xy); + float sh[2]; + sh[0] = shd.b; + sh[1] = shd.a; + shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); + } + + vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + + float envIntensity = norm.z; + + norm = getNorm(frag.xy); + + norm = normalize(norm); + float l_dist = -dot(lv, proj_n); + + vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); + if (proj_tc.z < 0.0) + { + discard; + } + + proj_tc.xyz /= proj_tc.w; + + float fa = falloff+1.0; + float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; + if (dist_atten <= 0.0) + { + discard; + } + + lv = proj_origin-pos.xyz; + lv = normalize(lv); + float da = dot(norm, lv); + + vec3 col = vec3(0,0,0); + + vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + + vec4 spec = texture2DRect(specularRect, frag.xy); + + vec3 dlit = vec3(0, 0, 0); + + float noise = texture2D(noiseMap, frag.xy/128.0).b; + if (proj_tc.z > 0.0 && + proj_tc.x < 1.0 && + proj_tc.y < 1.0 && + proj_tc.x > 0.0 && + proj_tc.y > 0.0) + { + float amb_da = proj_ambiance; + float lit = 0.0; + + if (da > 0.0) + { + lit = da * dist_atten * noise; + + float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); + float lod = diff * proj_lod; + + vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); + + dlit = color.rgb * plcol.rgb * plcol.a; + + col = dlit*lit*diff_tex*shadow; + amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; + } + + //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); + vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod); + + amb_da += (da*da*0.5+0.5)*proj_ambiance; + + amb_da *= dist_atten * noise; + + amb_da = min(amb_da, 1.0-lit); + + col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; + } + + + if (spec.a > 0.0) + { + vec3 npos = -normalize(pos); + dlit *= min(da*6.0, 1.0) * dist_atten; + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += dlit*scol*spec.rgb*shadow; + //col += spec.rgb; + } + } + + + + + + if (envIntensity > 0.0) + { + vec3 ref = reflect(normalize(pos), norm); + + //project from point pos in direction ref to plane proj_p, proj_n + vec3 pdelta = proj_p-pos; + float ds = dot(ref, proj_n); + + if (ds < 0.0) + { + vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; + + vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); + + if (stc.z > 0.0) + { + stc /= stc.w; + + if (stc.x < 1.0 && + stc.y < 1.0 && + stc.x > 0.0 && + stc.y > 0.0) + { + col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity; + } + } + } + } + + //not sure why, but this line prevents MATBUG-194 + col = max(col, vec3(0.0)); + + frag_color.rgb = col; + frag_color.a = 0.0; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointShadowBlurF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointShadowBlurF.glsl new file mode 100644 index 0000000000..ca9ce3a2e1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/pointShadowBlurF.glsl @@ -0,0 +1,37 @@ +/** + * @file pointShadowBlur.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform samplerCube cube_map; + +in vec3 to_vec; + +out vec4 fragColor; + +void main() +{ + vec4 vcol = texture(cube_map, to_vec); + fragColor = vec4(vcol.rgb, 1.0); +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/shVisF.glsl b/indra/newview/app_settings/shaders/class3/deferred/shVisF.glsl new file mode 100644 index 0000000000..c8991f7a18 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shVisF.glsl @@ -0,0 +1,73 @@ +/** + * @file class3/deferred/shVisF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR + out vec4 frag_color; +#else + #define frag_color gl_FragColor +#endif + +///////////////////////////////////////////////////////////////////////// +// Fragment shader for L1 SH debug rendering +///////////////////////////////////////////////////////////////////////// + +uniform sampler2D sh_input_r; +uniform sampler2D sh_input_g; +uniform sampler2D sh_input_b; + +uniform mat3 inv_modelviewprojection; + +VARYING vec4 vary_pos; + +void main(void) +{ + vec2 coord = vary_pos.xy + vec2(0.5,0.5); + + coord.x *= (1.6/0.9); + + if (dot(coord, coord) > 0.25) + { + discard; + } + + vec4 n = vec4(coord*2.0, 0.0, 1); + //n.y = -n.y; + n.z = sqrt(max(1.0-n.x*n.x-n.y*n.y, 0.0)); + //n.xyz = inv_modelviewprojection * n.xyz; + + vec4 l1tap = vec4(1.0/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265)); + vec4 l1r = texture2D(sh_input_r, vec2(0,0)); + vec4 l1g = texture2D(sh_input_g, vec2(0,0)); + vec4 l1b = texture2D(sh_input_b, vec2(0,0)); + vec3 indirect = vec3( + dot(l1r, l1tap * n), + dot(l1g, l1tap * n), + dot(l1b, l1tap * n)); + + //indirect = pow(indirect, vec3(0.45)); + indirect *= 3.0; + + frag_color = vec4(indirect, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shVisV.glsl b/indra/newview/app_settings/shaders/class3/deferred/shVisV.glsl new file mode 100644 index 0000000000..8f32dfde79 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shVisV.glsl @@ -0,0 +1,33 @@ +/** + * @file class3/deferred/shVisV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +ATTRIBUTE vec3 position; +VARYING vec4 vary_pos; + +void main() +{ + // Output + vary_pos = vec4(position, 1); + gl_Position = vary_pos; +} diff --git a/indra/newview/llfloaterdeleteenvpreset.h b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendF.glsl index 1211505273..345c07a354 100644 --- a/indra/newview/llfloaterdeleteenvpreset.h +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendF.glsl @@ -1,6 +1,5 @@ /** - * @file llfloaterdeleteenvpreset.h - * @brief Floater to delete a water / sky / day cycle preset. + * @file shadowAlphaMaskF.glsl * * $LicenseInfo:firstyear=2011&license=viewerlgpl$ * Second Life Viewer Source Code @@ -24,39 +23,36 @@ * $/LicenseInfo$ */ -#ifndef LL_LLFLOATERDELETEENVPRESET_H -#define LL_LLFLOATERDELETEENVPRESET_H +/*[EXTRA_CODE_HERE]*/ -#include "llfloater.h" +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif -class LLComboBox; +uniform sampler2D diffuseMap; -class LLFloaterDeleteEnvPreset : public LLFloater -{ - LOG_CLASS(LLFloaterDeleteEnvPreset); - -public: - LLFloaterDeleteEnvPreset(const LLSD &key); +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); +VARYING float pos_w; - void onBtnDelete(); - void onBtnCancel(); +VARYING float target_pos_x; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; +VARYING vec3 pos; -private: - void populatePresetsList(); - void populateWaterPresetsList(); - void populateSkyPresetsList(); - void populateDayCyclesList(); +vec4 computeMoments(float depth, float a); - void postPopulate(); - - void onDeleteDayCycleConfirmation(); - void onDeleteSkyPresetConfirmation(); - void onDeleteWaterPresetConfirmation(); +void main() +{ + float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a; - LLComboBox* mPresetCombo; -}; + frag_color = computeMoments(length(pos), float a); -#endif // LL_LLFLOATERDELETEENVPRESET_H +#if !defined(DEPTH_CLAMP) + gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); +#endif +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendV.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendV.glsl new file mode 100644 index 0000000000..af1461c297 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendV.glsl @@ -0,0 +1,66 @@ +/** + * @file shadowAlphaMaskV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING float target_pos_x; +VARYING vec4 pos; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void passTextureIndex(); + +void main() +{ + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + vec4 pos = modelview_projection_matrix * pre_pos; + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + + pos_w = pos.w; + +#if !defined(DEPTH_CLAMP) + pos_zd2 = pos.z * 0.5; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + + passTextureIndex(); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + vertex_color = diffuse_color; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaMaskF.glsl new file mode 100644 index 0000000000..50f1ffd626 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaMaskF.glsl @@ -0,0 +1,74 @@ +/** + * @file class3/deferred/shadowAlphaMaskF.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING float pos_w; + +VARYING float target_pos_x; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +vec4 getPosition(vec2 screen_coord); +vec4 computeMoments(float depth, float a); + +void main() +{ + vec4 pos = getPosition(vary_texcoord0.xy); + + float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a; + + if (alpha < 0.05) // treat as totally transparent + { + discard; + } + + if (alpha < 0.88) // treat as semi-transparent + { + if (fract(0.5*floor(target_pos_x / pos_w )) < 0.25) + { + discard; + } + } + + frag_color = computeMoments(length(pos.xyz), alpha); + +#if !defined(DEPTH_CLAMP) + gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); +#endif + +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaMaskV.glsl new file mode 100644 index 0000000000..6a646f5e9e --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaMaskV.glsl @@ -0,0 +1,67 @@ +/** + * @file class3/deferred/shadowAlphaMaskV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void passTextureIndex(); + +void main() +{ + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + + pos = modelview_projection_matrix * pre_pos; + + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + +#if !defined(DEPTH_CLAMP) + pos_zd2 = pos.z * 0.5; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + + passTextureIndex(); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + + vertex_color = diffuse_color; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowCubeV.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowCubeV.glsl new file mode 100644 index 0000000000..db8c75fb8a --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowCubeV.glsl @@ -0,0 +1,50 @@ +/** + * @file class3/deferred/shadowCubeV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; + +#if !defined(DEPTH_CLAMP) +VARYING vec4 post_pos; +#endif + +uniform vec3 box_center; +uniform vec3 box_size; + +void main() +{ + //transform vertex + vec3 p = position*box_size+box_center; + vec4 pos = modelview_projection_matrix*vec4(p.xyz, 1.0); + +#if !defined(DEPTH_CLAMP) + post_pos = pos; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowF.glsl new file mode 100644 index 0000000000..3350267130 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowF.glsl @@ -0,0 +1,49 @@ +/** + * @file class3/deferred/shadowF.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING vec4 pos; +VARYING float target_pos_x; + +vec4 computeMoments(float depth, float a); + +void main() +{ + frag_color = computeMoments(length(pos), 1.0); +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowUtil.glsl new file mode 100644 index 0000000000..2f69a353e8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowUtil.glsl @@ -0,0 +1,157 @@ +/** + * @file class3/deferred/shadowUtil.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform sampler2D shadowMap0; +uniform sampler2D shadowMap1; +uniform sampler2D shadowMap2; +uniform sampler2D shadowMap3; +uniform sampler2D shadowMap4; +uniform sampler2D shadowMap5; + +uniform vec3 sun_dir; +uniform vec3 moon_dir; +uniform vec2 shadow_res; +uniform vec2 proj_shadow_res; +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform float shadow_bias; + +uniform float spot_shadow_bias; +uniform float spot_shadow_offset; + +float getDepth(vec2 screenpos); +vec3 getNorm(vec2 screenpos); +vec4 getPosition(vec2 pos_screen); + +float ReduceLightBleeding(float p_max, float Amount) +{ + return smoothstep(Amount, 1, p_max); +} + +float ChebyshevUpperBound(vec2 m, float t, float min_v, float Amount) +{ + float p = (t <= m.x) ? 1.0 : 0.0; + + float v = m.y - (m.x*m.x); + v = max(v, min_v); + + float d = t - m.x; + + float p_max = v / (v + d*d); + + p_max = ReduceLightBleeding(p_max, Amount); + + return max(p, p_max); +} + +vec4 computeMoments(float depth, float a) +{ + float m1 = depth; + float dx = dFdx(depth); + float dy = dFdy(depth); + float m2 = m1*m1 + 0.25 * a * (dx*dx + dy*dy); + return vec4(m1, m2, a, max(dx, dy)); +} + +float vsmDirectionalSample(vec4 stc, float depth, sampler2D shadowMap, mat4 shadowMatrix) +{ + vec4 lpos = shadowMatrix * stc; + vec4 moments = texture2D(shadowMap, lpos.xy); + return ChebyshevUpperBound(moments.rg, depth - shadow_bias * 256.0f, 0.125, 0.9); +} + +float vsmSpotSample(vec4 stc, float depth, sampler2D shadowMap, mat4 shadowMatrix) +{ + vec4 lpos = shadowMatrix * stc; + vec4 moments = texture2D(shadowMap, lpos.xy); + lpos.xyz /= lpos.w; + lpos.xy *= 0.5; + lpos.xy += 0.5; + return ChebyshevUpperBound(moments.rg, depth - spot_shadow_bias * 16.0f, 0.125, 0.9); +} + +#if VSM_POINT_SHADOWS +float vsmPointSample(float lightDistance, vec3 lightDirection, samplerCube shadow_cube_map) +{ + vec4 moments = textureCube(shadow_cube_map, light_direction); + return ChebyshevUpperBound(moments.rg, light_distance, 0.01, 0.25); +} +#endif + +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) +{ + if (pos.z < -shadow_clip.w) + { + discard; + } + + float depth = getDepth(pos_screen); + + vec4 spos = vec4(pos,1.0); + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + + float shadow = 0.0f; + float weight = 1.0; + + if (spos.z < near_split.z) + { + shadow += vsmDirectionalSample(spos, depth, shadowMap3, shadow_matrix[3]); + weight += 1.0f; + } + if (spos.z < near_split.y) + { + shadow += vsmDirectionalSample(spos, depth, shadowMap2, shadow_matrix[2]); + weight += 1.0f; + } + if (spos.z < near_split.x) + { + shadow += vsmDirectionalSample(spos, depth, shadowMap1, shadow_matrix[1]); + weight += 1.0f; + } + if (spos.z > far_split.x) + { + shadow += vsmDirectionalSample(spos, depth, shadowMap0, shadow_matrix[0]); + weight += 1.0f; + } + + shadow /= weight; + + return shadow; +} + +float sampleSpotShadow(vec3 pos, vec3 norm, int index, vec2 pos_screen) +{ + if (pos.z < -shadow_clip.w) + { + discard; + } + + float depth = getDepth(pos_screen); + + pos += norm * spot_shadow_offset; + return vsmSpotSample(vec4(pos, 1.0), depth, (index == 0) ? shadowMap4 : shadowMap5, shadow_matrix[4 + index]); +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowV.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowV.glsl new file mode 100644 index 0000000000..6577fe0ecf --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/shadowV.glsl @@ -0,0 +1,62 @@ +/** + * @file class3/deferred/shadowV.glsl + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; +uniform mat4 texture_matrix0; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +#if !defined(DEPTH_CLAMP) +VARYING float pos_zd2; +#endif + +VARYING vec4 pos; +VARYING float target_pos_x; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void passTextureIndex(); + +void main() +{ + //transform vertex + vec4 pre_pos = vec4(position.xyz, 1.0); + + pos = modelview_projection_matrix * pre_pos; + + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + +#if !defined(DEPTH_CLAMP) + pos_zd2 = pos.z * 0.5; + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); +#else + gl_Position = pos; +#endif + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl new file mode 100644 index 0000000000..d0514f7d23 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -0,0 +1,112 @@ +/** + * @file class3/deferred/skyF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +VARYING vec2 vary_frag; + +uniform vec3 camPosLocal; +uniform vec3 sun_dir; +uniform float sun_size; +uniform float far_z; +uniform mat4 inv_proj; +uniform mat4 inv_modelview; + +uniform sampler2D transmittance_texture; +uniform sampler3D scattering_texture; +uniform sampler3D single_mie_scattering_texture; +uniform sampler2D irradiance_texture; +uniform sampler2D rainbow_map; +uniform sampler2D halo_map; +uniform vec4 gamma; + +uniform float moisture_level; +uniform float droplet_radius; +uniform float ice_level; + +vec3 GetSolarLuminance(); +vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance); +vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 dir, out vec3 transmittance); + +vec3 ColorFromRadiance(vec3 radiance); +vec3 rainbow(float d) +{ + float rad = (droplet_radius - 5.0f) / 1024.0f; + return pow(texture2D(rainbow_map, vec2(rad, d)).rgb, vec3(1.8)) * moisture_level; +} + +vec3 halo22(float d) +{ + float v = sqrt(max(0, 1 - (d*d))); + return texture2D(halo_map, vec2(0, v)).rgb * ice_level; +} + +void main() +{ + vec3 pos = vec3((vary_frag * 2.0) - vec2(1.0, 1.0f), 1.0); + vec4 view_pos = (inv_proj * vec4(pos, 1.0f)); + + view_pos /= view_pos.w; + + vec3 view_ray = (inv_modelview * vec4(view_pos.xyz, 0.0f)).xyz + camPosLocal; + + vec3 view_direction = normalize(view_ray); + vec3 sun_direction = normalize(sun_dir); + vec3 earth_center = vec3(0, 0, -6360.0f); + vec3 camPos = (camPosLocal / 1000.0f) - earth_center; + + vec3 transmittance; + vec3 radiance_sun = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); + vec3 solar_luminance = GetSolarLuminance(); + + // If the view ray intersects the Sun, add the Sun radiance. + float s = dot(view_direction, sun_direction); + + // cheesy solar disc... + if (s >= (sun_size * 0.999)) + { + radiance_sun += pow(smoothstep(0.0, 1.3, (s - (sun_size * 0.9))), 2.0) * solar_luminance * transmittance; + } + s = smoothstep(0.9, 1.0, s) * 16.0f; + + vec3 color = ColorFromRadiance(radiance_sun); + + float optic_d = dot(view_direction, sun_direction); + vec3 halo_22 = halo22(optic_d); + + color.rgb += rainbow(optic_d) * optic_d; + color.rgb += halo_22; + + color = pow(color, vec3(1.0/2.2)); + + frag_data[0] = vec4(color, 1.0 + s); + frag_data[1] = vec4(0.0); + frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl new file mode 100644 index 0000000000..2eb222ada4 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl @@ -0,0 +1,37 @@ +/** + * @file class3/deferred/skyV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_frag; + +void main() +{ + // pass through untransformed fullscreen pos at back of frustum for proper sky depth testing + gl_Position = vec4(position.xy, 1.0f, 1.0); + vary_frag = texcoord0; +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl new file mode 100644 index 0000000000..ad721a80d6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -0,0 +1,179 @@ +/** + * @file class3/deferred/softenLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect diffuseRect; +uniform sampler2DRect specularRect; +uniform sampler2DRect normalMap; +uniform sampler2DRect lightMap; +uniform sampler2DRect depthMap; +uniform sampler2D lightFunc; + +uniform samplerCube environmentMap; +uniform float blur_size; +uniform float blur_fidelity; + +// Inputs +uniform vec4 morphFactor; +uniform vec3 camPosLocal; +uniform float cloud_shadow; +uniform float max_y; +uniform vec4 glow; +uniform float global_gamma; +uniform mat3 env_mat; +uniform vec4 shadow_clip; +uniform mat3 ssao_effect_mat; + +uniform vec3 sun_dir; +VARYING vec2 vary_fragcoord; + +uniform mat4 inv_proj; +uniform mat4 inv_modelview; + +uniform vec2 screen_res; + +uniform sampler2D transmittance_texture; +uniform sampler3D scattering_texture; +uniform sampler3D single_mie_scattering_texture; +uniform sampler2D irradiance_texture; + +uniform sampler2D sh_input_r; +uniform sampler2D sh_input_g; +uniform sampler2D sh_input_b; + +vec3 GetSunAndSkyIrradiance(vec3 camPos, vec3 norm, vec3 dir, out vec3 sky_irradiance); +vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance); +vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 dir, out vec3 transmittance); + +vec3 ColorFromRadiance(vec3 radiance); +vec4 getPositionWithDepth(vec2 pos_screen, float depth); +vec4 getPosition(vec2 pos_screen); +vec3 getNorm(vec2 pos_screen); + +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 color); +#endif + +void main() +{ + vec2 tc = vary_fragcoord.xy; + float depth = texture2DRect(depthMap, tc.xy).r; + vec3 pos = getPositionWithDepth(tc, depth).xyz; + vec4 norm = texture2DRect(normalMap, tc); + float envIntensity = norm.z; + norm.xyz = getNorm(tc); + + float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); + da = pow(da, global_gamma + 0.3); + + vec4 diffuse = texture2DRect(diffuseRect, tc); // linear + + vec3 col; + float bloom = 0.0; + { + vec3 camPos = (camPosLocal / 1000.0f) + vec3(0, 0, 6360.0f); + + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); + + vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; +// scol_ambocc = pow(scol_ambocc, vec3(global_gamma + 0.3)); + + float scol = max(scol_ambocc.r, diffuse.a); + + float ambocc = scol_ambocc.g; + + vec4 l1tap = vec4(1.0/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265)); + vec4 l1r = texture2D(sh_input_r, vec2(0,0)); + vec4 l1g = texture2D(sh_input_g, vec2(0,0)); + vec4 l1b = texture2D(sh_input_b, vec2(0,0)); + + vec3 indirect = vec3(dot(l1r, l1tap * vec4(1, norm.xyz)), + dot(l1g, l1tap * vec4(1, norm.xyz)), + dot(l1b, l1tap * vec4(1, norm.xyz))); + + indirect = clamp(indirect, vec3(0), vec3(1.0)); + + vec3 transmittance; + vec3 sky_irradiance; + vec3 sun_irradiance = GetSunAndSkyIrradiance(camPos, norm.xyz, sun_dir, sky_irradiance); + vec3 inscatter = GetSkyLuminanceToPoint(camPos, (pos / 1000.f) + vec3(0, 0, 6360.0f), scol, sun_dir, transmittance); + + vec3 radiance = scol * (sun_irradiance + sky_irradiance) + inscatter; + vec3 atmo_color = ColorFromRadiance(radiance); + + col = atmo_color + indirect; + col *= transmittance; + col *= diffuse.rgb; + + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + // + float sa = dot(refnormpersp, sun_dir.xyz); + vec3 dumbshiny = scol * texture2D(lightFunc, vec2(sa, spec.a)).r * atmo_color; + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib) / 6; + col += spec_contrib; + } + + col = mix(col, diffuse.rgb, diffuse.a); + + if (envIntensity > 0.0) + { //add environmentmap + vec3 env_vec = env_mat * refnormpersp; + vec3 sun_direction = (inv_modelview * vec4(sun_dir, 1.0)).xyz; + vec3 radiance_sun = GetSkyLuminance(camPos, env_vec, 0.0f, sun_direction, transmittance); + vec3 refcol = ColorFromRadiance(radiance_sun); + col = mix(col.rgb, refcol, envIntensity); + } + + /*if (norm.w < 0.5) + { + col = scaleSoftClipFrag(col); + }*/ + + #ifdef WATER_FOG + vec4 fogged = applyWaterFogView(pos,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + } + + frag_color.rgb = col; + frag_color.a = bloom; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl new file mode 100644 index 0000000000..9d872b8df8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl @@ -0,0 +1,38 @@ +/** + * @file class3/deferred/softenLightV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +ATTRIBUTE vec3 position; + +VARYING vec2 vary_fragcoord; + +uniform mat4 modelview_projection_matrix; +uniform vec2 screen_res; + +void main() +{ + //transform vertex + vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = pos; + vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl new file mode 100644 index 0000000000..3b2b0d5718 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -0,0 +1,302 @@ +/** + * @file spotLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable +#extension GL_ARB_shader_texture_lod : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect diffuseRect; +uniform sampler2DRect specularRect; +uniform sampler2DRect depthMap; +uniform sampler2DRect normalMap; +uniform samplerCube environmentMap; +uniform sampler2DRect lightMap; +uniform sampler2D noiseMap; +uniform sampler2D projectionMap; +uniform sampler2D lightFunc; + +uniform mat4 proj_mat; //screen space to light space +uniform float proj_near; //near clip for projection +uniform vec3 proj_p; //plane projection is emitting from (in screen space) +uniform vec3 proj_n; +uniform float proj_focus; //distance from plane to begin blurring +uniform float proj_lod; //(number of mips in proj map) +uniform float proj_range; //range between near clip and far clip plane of projection +uniform float proj_ambient_lod; +uniform float proj_ambiance; +uniform float near_clip; +uniform float far_clip; + +uniform vec3 proj_origin; //origin of projection to be used for angular attenuation +uniform float sun_wash; +uniform int proj_shadow_idx; +uniform float shadow_fade; + +uniform float size; +uniform vec3 color; +uniform float falloff; + +VARYING vec3 trans_center; +VARYING vec4 vary_fragcoord; +uniform vec2 screen_res; + +uniform mat4 inv_proj; + +vec3 getNorm(vec2 pos_screen); +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + +vec4 correctWithGamma(vec4 col) +{ + return vec4(srgb_to_linear(col.rgb), col.a); +} + +vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = srgb_to_linear(ret.rgb); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + d *= min(1, d * (proj_lod - lod)); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = tc-vec2(0.5); + + float d = dot(dist,dist); + + ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0); + + return ret; +} + + +vec4 getPosition(vec2 pos_screen); + +void main() +{ + vec4 frag = vary_fragcoord; + frag.xyz /= frag.w; + frag.xyz = frag.xyz*0.5+0.5; + frag.xy *= screen_res; + + vec3 pos = getPosition(frag.xy).xyz; + vec3 lv = trans_center.xyz-pos.xyz; + float dist = length(lv); + dist /= size; + if (dist > 1.0) + { + discard; + } + + float shadow = 1.0; + + if (proj_shadow_idx >= 0) + { + vec4 shd = texture2DRect(lightMap, frag.xy); + float sh[2]; + sh[0] = shd.b; + sh[1] = shd.a; + shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); + } + + vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + float envIntensity = norm.z; + norm = getNorm(frag.xy); + + norm = normalize(norm); + float l_dist = -dot(lv, proj_n); + + vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); + if (proj_tc.z < 0.0) + { + discard; + } + + proj_tc.xyz /= proj_tc.w; + + float fa = falloff + 1.0; + float dist_atten = min(1.0 - (dist - 1.0 * (1.0 - fa)) / fa, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; + + if (dist_atten <= 0.0) + { + discard; + } + + lv = proj_origin-pos.xyz; + lv = normalize(lv); + float da = dot(norm, lv); + + vec3 col = vec3(0,0,0); + + vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + + vec4 spec = texture2DRect(specularRect, frag.xy); + + vec3 dlit = vec3(0, 0, 0); + + float noise = texture2D(noiseMap, frag.xy/128.0).b; + if (proj_tc.z > 0.0 && + proj_tc.x < 1.0 && + proj_tc.y < 1.0 && + proj_tc.x > 0.0 && + proj_tc.y > 0.0) + { + float amb_da = proj_ambiance; + float lit = 0.0; + + if (da > 0.0) + { + lit = da * dist_atten * noise; + + float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); + float lod = diff * proj_lod; + + vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); + + dlit = color.rgb * plcol.rgb * plcol.a; + + col = dlit*lit*diff_tex*shadow; + amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; + } + + //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); + vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod); + + amb_da += (da*da*0.5+0.5)*proj_ambiance; + + amb_da *= dist_atten * noise; + + amb_da = min(amb_da, 1.0-lit); + + col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; + } + + + if (spec.a > 0.0) + { + dlit *= min(da*6.0, 1.0) * dist_atten; + vec3 npos = -normalize(pos); + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += dlit*scol*spec.rgb*shadow; + //col += spec.rgb; + } + } + + + + + + if (envIntensity > 0.0) + { + vec3 ref = reflect(normalize(pos), norm); + + //project from point pos in direction ref to plane proj_p, proj_n + vec3 pdelta = proj_p-pos; + float ds = dot(ref, proj_n); + + if (ds < 0.0) + { + vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; + + vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); + + if (stc.z > 0.0) + { + stc /= stc.w; + + if (stc.x < 1.0 && + stc.y < 1.0 && + stc.x > 0.0 && + stc.y > 0.0) + { + col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity; + } + } + } + } + + //not sure why, but this line prevents MATBUG-194 + col = max(col, vec3(0.0)); + + frag_color.rgb = col; + frag_color.a = 0.0; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl new file mode 100644 index 0000000000..112b498c90 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl @@ -0,0 +1,57 @@ +/** + * @file class3\deferred\sunLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +//class 2, shadows, no SSAO + +// Inputs +VARYING vec2 vary_fragcoord; + +vec4 getPosition(vec2 pos_screen); +vec3 getNorm(vec2 pos_screen); + +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +float sampleSpotShadow(vec3 pos, vec3 norm, int index, vec2 pos_screen); + +void main() +{ + vec2 pos_screen = vary_fragcoord.xy; + vec4 pos = getPosition(pos_screen); + vec3 norm = getNorm(pos_screen); + + frag_color.r = sampleDirectionalShadow(pos.xyz, norm, pos_screen); + frag_color.g = 1.0f; + frag_color.b = sampleSpotShadow(pos.xyz, norm, 0, pos_screen); + frag_color.a = sampleSpotShadow(pos.xyz, norm, 1, pos_screen); +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl new file mode 100644 index 0000000000..342a2ff3ed --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl @@ -0,0 +1,61 @@ +/** + * @file class3\deferred\sunLightSSAOF.glsl + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +//class 2 -- shadows and SSAO + +// Inputs +VARYING vec2 vary_fragcoord; + +uniform vec3 sun_dir; + +vec4 getPosition(vec2 pos_screen); +vec3 getNorm(vec2 pos_screen); + +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +float sampleSpotShadow(vec3 pos, vec3 norm, int index, vec2 pos_screen); + +//calculate decreases in ambient lighting when crowded out (SSAO) +float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen); + +void main() +{ + vec2 pos_screen = vary_fragcoord.xy; + vec4 pos = getPosition(pos_screen); + vec3 norm = getNorm(pos_screen); + + frag_color.r = sampleDirectionalShadow(pos.xyz, norm, pos_screen); + frag_color.b = calcAmbientOcclusion(pos, norm, pos_screen); + frag_color.b = sampleSpotShadow(pos.xyz, norm, 0, pos_screen); + frag_color.a = sampleSpotShadow(pos.xyz, norm, 1, pos_screen); +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightV.glsl new file mode 100644 index 0000000000..bc5eb5181d --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightV.glsl @@ -0,0 +1,41 @@ +/** + * @file sunLightV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; + +VARYING vec2 vary_fragcoord; + +uniform vec2 screen_res; + +void main() +{ + //transform vertex + vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = pos; + + vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/treeShadowF.glsl b/indra/newview/app_settings/shaders/class3/deferred/treeShadowF.glsl new file mode 100644 index 0000000000..41673d1669 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/treeShadowF.glsl @@ -0,0 +1,59 @@ +/** + * @file treeShadowF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform float minimum_alpha; + +uniform sampler2D diffuseMap; + +VARYING vec4 pos; +VARYING vec2 vary_texcoord0; + +vec4 computeMoments(float d, float a); + +void main() +{ + float alpha = texture2D(diffuseMap, vary_texcoord0.xy).a; + + if (alpha < minimum_alpha) + { + discard; + } + + frag_color = computeMoments(length(pos), 1.0); + +#if !defined(DEPTH_CLAMP) + gl_FragDepth = max(pos.z/pos.w*0.5+0.5, 0.0); +#endif + +} + diff --git a/indra/newview/app_settings/shaders/class3/deferred/treeShadowV.glsl b/indra/newview/app_settings/shaders/class3/deferred/treeShadowV.glsl new file mode 100644 index 0000000000..15e769ac10 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/treeShadowV.glsl @@ -0,0 +1,43 @@ +/** + * @file treeShadowV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 pos; +VARYING vec2 vary_texcoord0; + +void main() +{ + //transform vertex + pos = modelview_projection_matrix*vec4(position.xyz, 1.0); + + gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/deferred/underWaterF.glsl new file mode 100644 index 0000000000..9d18d1afd8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/underWaterF.glsl @@ -0,0 +1,118 @@ +/** + * @file underWaterF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +uniform sampler2D diffuseMap; +uniform sampler2D bumpMap; +uniform sampler2D screenTex; +uniform sampler2D refTex; +uniform sampler2D screenDepth; + +uniform vec4 fogCol; +uniform vec3 lightDir; +uniform vec3 specular; +uniform float lightExp; +uniform vec2 fbScale; +uniform float refScale; +uniform float znear; +uniform float zfar; +uniform float kd; +uniform vec4 waterPlane; +uniform vec3 eyeVec; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; +uniform vec2 screenRes; + +//bigWave is (refCoord.w, view.w); +VARYING vec4 refCoord; +VARYING vec4 littleWave; +VARYING vec4 view; + +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + +vec2 encode_normal(vec3 n); + +vec4 applyWaterFog(vec4 color, vec3 viewVec) +{ + //normalize view vector + vec3 view = normalize(viewVec); + float es = -view.z; + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + //get object depth + float depth = length(viewVec); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + return color * D + kc * L; +} + +void main() +{ + vec4 color; + + //get detail normals + vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + vec3 wavef = normalize(wave1+wave2+wave3); + + //figure out distortion vector (ripply) + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + distort = distort+wavef.xy*refScale; + + vec4 fb = texture2D(screenTex, distort); + + frag_data[0] = vec4(fb.rgb, 1.0); // diffuse + frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec + frag_data[2] = vec4(encode_normal(wavef), 0.0, 0.0); // normalxyz, displace +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl new file mode 100644 index 0000000000..2a144ba23a --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl @@ -0,0 +1,175 @@ +/** + * @file waterF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_data[3]; +#else +#define frag_data gl_FragData +#endif + +uniform sampler2D bumpMap; +uniform sampler2D bumpMap2; +uniform float blend_factor; +uniform sampler2D screenTex; +uniform sampler2D refTex; + +uniform float sunAngle; +uniform float sunAngle2; +uniform vec3 lightDir; +uniform vec3 specular; +uniform float lightExp; +uniform float refScale; +uniform float kd; +uniform vec2 screenRes; +uniform vec3 normScale; +uniform float fresnelScale; +uniform float fresnelOffset; +uniform float blurMultiplier; +uniform vec2 screen_res; +uniform mat4 norm_mat; //region space to screen space + +//bigWave is (refCoord.w, view.w); +VARYING vec4 refCoord; +VARYING vec4 littleWave; +VARYING vec4 view; +VARYING vec4 vary_position; + +vec3 scaleSoftClip(vec3 c); +vec3 srgb_to_linear(vec3 cs); +vec2 encode_normal(vec3 n); + +vec3 BlendNormal(vec3 bump1, vec3 bump2) +{ + //vec3 normal = bump1.xyz * vec3( 2.0, 2.0, 2.0) - vec3(1.0, 1.0, 0.0); + //vec3 normal2 = bump2.xyz * vec3(-2.0, -2.0, 2.0) + vec3(1.0, 1.0, -1.0); + //vec3 n = normalize(normal * dot(normal, normal2) - (normal2 * normal.z)); + vec3 n = normalize(mix(bump1, bump2, blend_factor)); + return n; +} + +void main() +{ + vec4 color; + float dist = length(view.xy); + + //normalize view vector + vec3 viewVec = normalize(view.xyz); + + //get wave normals + vec3 wave1_a = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_a = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_a = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + + + vec3 wave1_b = texture2D(bumpMap2, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_b = texture2D(bumpMap2, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_b = texture2D(bumpMap2, littleWave.zw).xyz*2.0-1.0; + + vec3 wave1 = BlendNormal(wave1_a, wave1_b); + vec3 wave2 = BlendNormal(wave2_a, wave2_b); + vec3 wave3 = BlendNormal(wave3_a, wave3_b); + + //get base fresnel components + + vec3 df = vec3( + dot(viewVec, wave1), + dot(viewVec, (wave2 + wave3) * 0.5), + dot(viewVec, wave3) + ) * fresnelScale + fresnelOffset; + df *= df; + + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + + float dist2 = dist; + dist = max(dist, 5.0); + + float dmod = sqrt(dist); + + vec2 dmod_scale = vec2(dmod*dmod, dmod); + + //get reflected color + vec2 refdistort1 = wave1.xy*normScale.x; + vec2 refvec1 = distort+refdistort1/dmod_scale; + vec4 refcol1 = texture2D(refTex, refvec1); + + vec2 refdistort2 = wave2.xy*normScale.y; + vec2 refvec2 = distort+refdistort2/dmod_scale; + vec4 refcol2 = texture2D(refTex, refvec2); + + vec2 refdistort3 = wave3.xy*normScale.z; + vec2 refvec3 = distort+refdistort3/dmod_scale; + vec4 refcol3 = texture2D(refTex, refvec3); + + vec4 refcol = refcol1 + refcol2 + refcol3; + float df1 = df.x + df.y + df.z; + refcol *= df1 * 0.333; + + vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; + wavef.z *= max(-viewVec.z, 0.1); + wavef = normalize(wavef); + + float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; + + vec2 refdistort4 = wavef.xy*0.125; + refdistort4.y -= abs(refdistort4.y); + vec2 refvec4 = distort+refdistort4/dmod; + float dweight = min(dist2*blurMultiplier, 1.0); + vec4 baseCol = texture2D(refTex, refvec4); + + refcol = mix(baseCol*df2, refcol, dweight); + + //get specular component + float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); + + //harden specular + spec = pow(spec, 128.0); + + //figure out distortion vector (ripply) + vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); + + vec4 fb = texture2D(screenTex, distort2); + + //mix with reflection + // Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug + color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); + + color.rgb *= 2.0f; + color.rgb = scaleSoftClip(color.rgb); + + vec4 pos = vary_position; + + color.rgb += spec * specular; + color.a = spec * sunAngle2; + + vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); + + frag_data[0] = vec4(color.rgb, color); // diffuse + frag_data[1] = vec4(spec * specular, spec); // speccolor, spec + frag_data[2] = vec4(encode_normal(wavef.xyz), 0.05, 0);// normalxy, 0, 0 +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl new file mode 100644 index 0000000000..02000d90ca --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl @@ -0,0 +1,95 @@ +/** + * @file waterV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_matrix; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; + + +uniform vec2 d1; +uniform vec2 d2; +uniform float time; +uniform vec3 eyeVec; +uniform float waterHeight; + +VARYING vec4 refCoord; +VARYING vec4 littleWave; +VARYING vec4 view; + +VARYING vec4 vary_position; + +float wave(vec2 v, float t, float f, vec2 d, float s) +{ + return (dot(d, v)*f + t*s)*f; +} + +void main() +{ + //transform vertex + vec4 pos = vec4(position.xyz, 1.0); + mat4 modelViewProj = modelview_projection_matrix; + + vec4 oPosition; + + //get view vector + vec3 oEyeVec; + oEyeVec.xyz = pos.xyz-eyeVec; + + float d = length(oEyeVec.xy); + float ld = min(d, 2560.0); + + pos.xy = eyeVec.xy + oEyeVec.xy/d*ld; + view.xyz = oEyeVec; + + d = clamp(ld/1536.0-0.5, 0.0, 1.0); + d *= d; + + oPosition = vec4(position, 1.0); + oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); + vary_position = modelview_matrix * oPosition; + oPosition = modelViewProj * oPosition; + + refCoord.xyz = oPosition.xyz + vec3(0,0,0.2); + + //get wave position parameter (create sweeping horizontal waves) + vec3 v = pos.xyz; + v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0; + + //push position for further horizon effect. + pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z); + pos.w = 1.0; + pos = modelview_matrix*pos; + + //pass wave parameters to pixel shader + vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055; + //get two normal map (detail map) texture coordinates + littleWave.xy = (v.xy) * vec2(0.45, 0.9) + d2 * time * 0.13; + littleWave.zw = (v.xy) * vec2(0.1, 0.2) + d1 * time * 0.1; + view.w = bigWave.y; + refCoord.w = bigWave.x; + + gl_Position = oPosition; +} diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl index dadff40933..9842d9ba93 100644 --- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl +++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl @@ -29,8 +29,6 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa vec3 atmosAmbient(vec3 light); vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); -vec3 scaleUpLight(vec3 light); uniform vec4 light_position[8]; uniform vec3 light_direction[8]; @@ -51,7 +49,6 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].z); col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].z); col.rgb += light_diffuse[1].rgb*calcDirectionalLight(norm, light_position[1].xyz); - col.rgb = scaleDownLight(col.rgb); // Add windlight lights col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, light_position[0].xyz)); diff --git a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl new file mode 100644 index 0000000000..fed3edf7de --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl @@ -0,0 +1,73 @@ +/** + * @file advancedAtmoF.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +in vec3 view_dir; + +uniform vec3 cameraPosLocal; +uniform vec3 sun_dir; +uniform float sun_size; + +uniform sampler2D transmittance_texture; +uniform sampler3D scattering_texture; +uniform sampler3D mie_scattering_texture; +uniform sampler2D irradiance_texture; + +vec3 GetSolarLuminance(); +vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 sun_dir, out vec3 transmittance); +vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 sun_dir, out vec3 transmittance); +vec3 GetSunAndSkyIlluminance(vec3 pos, vec3 norm, vec3 sun_dir, out vec3 sky_irradiance); + +void main() +{ + vec3 view_direction = normalize(view_dir); + + vec3 camPos = cameraPosLocal; + vec3 transmittance; + vec3 sky_illum; + vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_dir, transmittance); + vec3 radiance2 = GetSunAndSkyIlluminance(camPos, view_direction, sun_dir, sky_illum); + + //radiance *= transmittance; + + // If the view ray intersects the Sun, add the Sun radiance. + if (dot(view_direction, sun_dir) >= sun_size) + { + radiance = radiance + transmittance * GetSolarLuminance(); + } + + //vec3 color = vec3(1.0) - exp(-radiance); + //color = pow(color, vec3(1.0 / 2.2)); + + frag_color.rgb = radiance; + + frag_color.a = 1.0; +} + diff --git a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoV.glsl b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoV.glsl new file mode 100644 index 0000000000..52a7595379 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoV.glsl @@ -0,0 +1,43 @@ +/** + * @file advancedAtmoV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; + +// Inputs +uniform vec3 camPosLocal; + +out vec3 view_dir; + +void main() +{ + // World / view / projection + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + + // this will be normalized in the frag shader... + view_dir = position.xyz - camPosLocal.xyz; +} + diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl new file mode 100644 index 0000000000..852c2478bc --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl @@ -0,0 +1,142 @@ +/** + * @file atmosphericsF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); + +uniform vec4 gamma; +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform float haze_horizon; +uniform float haze_density; +uniform float cloud_shadow; +uniform float density_multiplier; +uniform float distance_multiplier; +uniform float max_y; +uniform vec4 glow; +uniform float scene_light_strength; +uniform mat3 ssao_effect_mat; + +vec3 scaleSoftClipFrag(vec3 light); + +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) +{ + light *= atten.r; + light += additive; + return (2.0 * light); +} + +vec3 atmosLighting(vec3 light) +{ + return atmosFragLighting(light, getAdditiveColor(), getAtmosAttenuation()); +} + +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) { + + vec3 P = inPositionEye; + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + atten = temp1.rgb; + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + /* decrease value and saturation (that in HSV, not HSL) for occluded areas + * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html + * // The following line of code performs the equivalent of: + * float ambAlpha = tmpAmbient.a; + * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis + * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); + * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); + */ + tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + + //haze color + additive = + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient)); + + //brightness of surface both sunlight and ambient + sunlit = vec3(sunlight * .5); + amblit = vec3(tmpAmbient * .25); + additive *= vec3(1.0 - temp1); +} + diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl new file mode 100644 index 0000000000..9bd75cf118 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl @@ -0,0 +1,135 @@ +/** + * @file atmosphericsV.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2005, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// VARYING param funcs +void setSunlitColor(vec3 v); +void setAmblitColor(vec3 v); +void setAdditiveColor(vec3 v); +void setAtmosAttenuation(vec3 v); +void setPositionEye(vec3 v); + +vec3 getAdditiveColor(); + +// Inputs +uniform vec4 morphFactor; +uniform vec3 camPosLocal; + +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform float haze_horizon; +uniform float haze_density; +uniform float cloud_shadow; +uniform float density_multiplier; +uniform float distance_multiplier; +uniform float max_y; +uniform vec4 glow; + +void calcAtmospherics(vec3 inPositionEye) { + + vec3 P = inPositionEye; + setPositionEye(P); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + setAtmosAttenuation(temp1.rgb); + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + /* decrease value and saturation (that in HSV, not HSL) for occluded areas + * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html + * // The following line of code performs the equivalent of: + * float ambAlpha = tmpAmbient.a; + * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis + * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); + * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); + */ + //tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + + //haze color + setAdditiveColor( + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient))); + + //brightness of surface both sunlight and ambient + setSunlitColor(vec3(sunlight * .5)); + setAmblitColor(vec3(tmpAmbient * .25)); + setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); +} diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl new file mode 100644 index 0000000000..90ab5d2793 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl @@ -0,0 +1,77 @@ +/** + * @file transportF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +////////////////////////////////////////////////////////// +// The fragment shader for the terrain atmospherics +////////////////////////////////////////////////////////// + +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); + +uniform int no_atmo; + +vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) +{ + if (no_atmo == 1) + { + return light; + } + return (light + additive) * atten * 2.0; +} + +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) +{ + if (no_atmo == 1) + { + return light; + } + float brightness = dot(light.rgb, vec3(0.33333)); + return mix(atmosTransportFrag(light.rgb, additive,atten), light.rgb + additive.rgb, brightness * brightness); +} + +vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) +{ + if (no_atmo == 1) + { + return light; + } + float brightness = dot(light.rgb, vec3(0.33333)); + return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness); +} + +vec3 atmosTransport(vec3 light) +{ + return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); +} + +vec3 fullbrightAtmosTransport(vec3 light) +{ + return fullbrightAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); +} + +vec3 fullbrightShinyAtmosTransport(vec3 light) +{ + return fullbrightShinyAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); +} diff --git a/indra/newview/app_settings/shaders/shader_hierarchy.txt b/indra/newview/app_settings/shaders/shader_hierarchy.txt index d8bbf69b38..ebccaddd55 100644 --- a/indra/newview/app_settings/shaders/shader_hierarchy.txt +++ b/indra/newview/app_settings/shaders/shader_hierarchy.txt @@ -7,7 +7,6 @@ avatar/avatarV.glsl - gAvatarProgram, gAvatarWaterProgram sumLights() - lighting/sumLightsV.glsl calcDirectionalLight() - lighting/lightFuncV.glsl calcPointLight() - lighting/lightFuncV.glsl - scaleDownLight() - windlight/atmosphericsHelpersV.glsl atmosAmbient() - windlight/atmosphericsHelpersV.glsl atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -28,7 +27,6 @@ avatar/eyeballV.glsl - gAvatarEyeballProgram atmosAmbient() - windlight/atmosphericsHelpersV.glsl atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl atmosGetDiffuseSunlightColor() - windlight/atmosphericsHelpersV.glsl - scaleDownLight() - windlight/atmosphericsHelpersV.glsl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ avatar/eyeballF.glsl - gAvatarEyeballProgram main() - avatar/eyeballF.glsl @@ -53,7 +51,6 @@ environment/terrainV.glsl - gTerrainProgram, gTerrainWaterProgram sumLights() - lighting/sumLightsV.glsl calcDirectionalLight() - lighting/lightFuncV.glsl calcPointLight() - lighting/lightFuncV.glsl - scaleDownLight() - windlight/atmosphericsHelpersV.glsl atmosAmbient() - windlight/atmosphericsHelpersV.glsl atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -120,7 +117,6 @@ objects/shinyV.glsl - gObjectShinyProgram, gObjectShinyWaterProgram sumLights() - lighting/sumLightsV.glsl calcDirectionalLight() - lighting/lightFuncV.glsl calcPointLight() - lighting/lightFuncV.glsl - scaleDownLight() - windlight/atmosphericsHelpersV.glsl atmosAmbient() - windlight/atmosphericsHelpersV.glsl atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -143,7 +139,6 @@ objects/simpleV.glsl - gObjectSimpleProgram, gObjectSimpleWaterProgram sumLights() - lighting/sumLightsV.glsl calcDirectionalLight() - lighting/lightFuncV.glsl calcPointLight() - lighting/lightFuncV.glsl - scaleDownLight() - windlight/atmosphericsHelpersV.glsl atmosAmbient() - windlight/atmosphericsHelpersV.glsl atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index e99b94f150..e6ee458719 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -66,6 +66,7 @@ RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 @@ -98,6 +99,7 @@ VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -129,6 +131,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -159,6 +162,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -189,6 +193,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -219,6 +224,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -249,6 +255,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -279,6 +286,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -309,6 +317,7 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderFSAASamples 1 2 @@ -320,6 +329,7 @@ RenderVBOEnable 1 0 RenderShadowDetail 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 // // Class 0 Hardware (just old) @@ -375,6 +385,7 @@ WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 RenderShadowDetail 0 0 +RenderUseAdvancedAtmospherics 0 0 // // No Vertex Shaders available @@ -388,6 +399,7 @@ WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 RenderShadowDetail 0 0 +RenderUseAdvancedAtmospherics 0 0 // // GL_ARB_map_buffer_range exists diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt index 801a622e93..bc836a99ca 100644 --- a/indra/newview/featuretable_linux.txt +++ b/indra/newview/featuretable_linux.txt @@ -66,6 +66,7 @@ RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderFSAASamples 1 16 RenderMaxTextureIndex 1 16 @@ -97,6 +98,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -128,6 +130,7 @@ VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -158,6 +161,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -188,6 +192,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -217,6 +222,7 @@ RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 @@ -248,6 +254,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -278,6 +285,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -308,6 +316,7 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderFSAASamples 1 2 @@ -319,6 +328,7 @@ RenderVBOEnable 1 0 RenderShadowDetail 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 // // Class 0 Hardware (just old) @@ -373,6 +383,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -386,6 +397,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -413,6 +425,7 @@ RenderReflectionDetail 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 1f891ee4d7..68202a571f 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -66,6 +66,7 @@ RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 @@ -98,6 +99,7 @@ VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -129,6 +131,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -159,6 +162,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -189,6 +193,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -219,6 +224,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -249,6 +255,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -280,6 +287,7 @@ WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 +RenderUseAdvancedAtmospherics 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -309,6 +317,7 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderFSAASamples 1 2 @@ -320,6 +329,7 @@ RenderVBOEnable 1 0 RenderShadowDetail 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 // // Class 0 Hardware (just old) @@ -368,6 +378,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -381,6 +392,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -407,6 +419,7 @@ RenderReflectionDetail 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index ba250fa471..e23827cf12 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -42,7 +42,6 @@ #include "llchicletbar.h" #include "llconsole.h" #include "lldonotdisturbnotificationstorage.h" -#include "llenvmanager.h" #include "llfirstuse.h" #include "llfloatercamera.h" #include "llfloaterimcontainer.h" @@ -382,6 +381,7 @@ LLAgent::LLAgent() : mAgentOriginGlobal(), mPositionGlobal(), + mLastTestGlobal(), mDistanceTraveled(0.F), mLastPositionGlobal(LLVector3d::zero), @@ -1081,6 +1081,13 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent) pos_agent_d.setVec(pos_agent); mPositionGlobal = pos_agent_d + mAgentOriginGlobal; } + + if (((mLastTestGlobal - mPositionGlobal).lengthSquared() > 1.0) && !mOnPositionChanged.empty()) + { // If the position has changed my more than 1 meter since the last time we triggered. + // filters out some noise. + mLastTestGlobal = mPositionGlobal; + mOnPositionChanged(mFrameAgent.getOrigin(), mPositionGlobal); + } } //----------------------------------------------------------------------------- @@ -1121,6 +1128,12 @@ const LLVector3 &LLAgent::getPositionAgent() return mFrameAgent.getOrigin(); } +boost::signals2::connection LLAgent::whenPositionChanged(position_signal_t::slot_type fn) +{ + return mOnPositionChanged.connect(fn); +} + + //----------------------------------------------------------------------------- // getRegionsVisited() //----------------------------------------------------------------------------- diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index b1b39b637e..ad35c26dc6 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -189,6 +189,8 @@ private: // Position //-------------------------------------------------------------------- public: + typedef boost::signals2::signal<void(const LLVector3 &position_local, const LLVector3d &position_global)> position_signal_t; + LLVector3 getPosAgentFromGlobal(const LLVector3d &pos_global) const; LLVector3d getPosGlobalFromAgent(const LLVector3 &pos_agent) const; const LLVector3d &getPositionGlobal() const; @@ -196,10 +198,16 @@ public: // Call once per frame to update position, angles (radians). void updateAgentPosition(const F32 dt, const F32 yaw, const S32 mouse_x, const S32 mouse_y); void setPositionAgent(const LLVector3 ¢er); + + boost::signals2::connection whenPositionChanged(position_signal_t::slot_type fn); + protected: void propagate(const F32 dt); // ! BUG ! Should roll into updateAgentPosition private: - mutable LLVector3d mPositionGlobal; + mutable LLVector3d mPositionGlobal; + + position_signal_t mOnPositionChanged; + LLVector3d mLastTestGlobal; //-------------------------------------------------------------------- // Velocity diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 170e4063a1..2b865a1ae2 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -799,14 +799,13 @@ void LLAgentWearables::createStandardWearables() ((OnWearableItemCreatedCB*)(&(*cb)))->addPendingWearable(wearable); // no need to update here... LLUUID category_id = LLUUID::null; - create_inventory_item(gAgent.getID(), + create_inventory_wearable(gAgent.getID(), gAgent.getSessionID(), category_id, wearable->getTransactionID(), wearable->getName(), wearable->getDescription(), wearable->getAssetType(), - LLInventoryType::IT_WEARABLE, wearable->getType(), wearable->getPermissions().getMaskNextOwner(), cb); @@ -868,14 +867,13 @@ void LLAgentWearables::addWearableToAgentInventory(LLPointer<LLInventoryCallback const LLUUID& category_id, BOOL notify) { - create_inventory_item(gAgent.getID(), + create_inventory_wearable(gAgent.getID(), gAgent.getSessionID(), category_id, wearable->getTransactionID(), wearable->getName(), wearable->getDescription(), wearable->getAssetType(), - LLInventoryType::IT_WEARABLE, wearable->getType(), wearable->getPermissions().getMaskNextOwner(), cb); @@ -1540,7 +1538,6 @@ void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, con LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp); LLAssetType::EType asset_type = wearable->getAssetType(); - LLInventoryType::EType inv_type = LLInventoryType::IT_WEARABLE; LLPointer<LLInventoryCallback> cb; if(wear) { @@ -1563,13 +1560,13 @@ void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, con folder_id = gInventory.findCategoryUUIDForType(folder_type); } - create_inventory_item(gAgent.getID(), + create_inventory_wearable(gAgent.getID(), gAgent.getSessionID(), folder_id, wearable->getTransactionID(), wearable->getName(), wearable->getDescription(), - asset_type, inv_type, + asset_type, wearable->getType(), LLFloaterPerms::getNextOwnerPerms("Wearables"), cb); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 08daeb0f59..2bdffec7fb 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1029,14 +1029,13 @@ void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); LLPointer<LLInventoryCallback> cb = new LLBoostFuncInventoryCallback(boost::bind(recovered_item_cb,_1,type,wearable,this)); - create_inventory_item(gAgent.getID(), + create_inventory_wearable(gAgent.getID(), gAgent.getSessionID(), lost_and_found_id, wearable->getTransactionID(), wearable->getName(), wearable->getDescription(), wearable->getAssetType(), - LLInventoryType::IT_WEARABLE, wearable->getType(), wearable->getPermissions().getMaskNextOwner(), cb); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d3577d50a1..22b3ce5128 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -172,8 +172,6 @@ #include "llviewerparcelmgr.h" #include "llworldmapview.h" #include "llpostprocess.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" #include "lldebugview.h" #include "llconsole.h" @@ -209,6 +207,7 @@ #include "llfloateroutfitsnapshot.h" #include "llfloatersnapshot.h" #include "llsidepanelinventory.h" +#include "llatmosphere.h" // includes for idle() idleShutdown() #include "llviewercontrol.h" @@ -766,7 +765,9 @@ bool LLAppViewer::init() // initialize LLWearableType translation bridge. // Memory will be cleaned up in ::cleanupClass() - LLWearableType::initClass(new LLUITranslationBridge()); + LLTranslationBridge::ptr_t trans = std::make_shared<LLUITranslationBridge>(); + LLWearableType::initClass(trans); + LLSettingsType::initClass(trans); // initialize SSE options LLVector4a::initClass(); @@ -1134,33 +1135,40 @@ bool LLAppViewer::init() gGLActive = FALSE; - LLProcess::Params updater; - updater.desc = "updater process"; - // Because it's the updater, it MUST persist beyond the lifespan of the - // viewer itself. - updater.autokill = false; + if (!gSavedSettings.getBOOL("CmdLineSkipUpdater")) + { + LLProcess::Params updater; + updater.desc = "updater process"; + // Because it's the updater, it MUST persist beyond the lifespan of the + // viewer itself. + updater.autokill = false; #if LL_WINDOWS - updater.executable = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "SLVersionChecker.exe"); + updater.executable = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "SLVersionChecker.exe"); #elif LL_DARWIN - // explicitly run the system Python interpreter on SLVersionChecker.py - updater.executable = "python"; - updater.args.add(gDirUtilp->add(gDirUtilp->getAppRODataDir(), "updater", "SLVersionChecker.py")); + // explicitly run the system Python interpreter on SLVersionChecker.py + updater.executable = "python"; + updater.args.add(gDirUtilp->add(gDirUtilp->getAppRODataDir(), "updater", "SLVersionChecker.py")); #else - updater.executable = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "SLVersionChecker"); + updater.executable = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "SLVersionChecker"); #endif - // add LEAP mode command-line argument to whichever of these we selected - updater.args.add("leap"); - // UpdaterServiceSettings - updater.args.add(stringize(gSavedSettings.getU32("UpdaterServiceSetting"))); - // channel - updater.args.add(LLVersionInfo::getChannel()); - // testok - updater.args.add(stringize(gSavedSettings.getBOOL("UpdaterWillingToTest"))); - // ForceAddressSize - updater.args.add(stringize(gSavedSettings.getU32("ForceAddressSize"))); - - // Run the updater. An exception from launching the updater should bother us. - LLLeap::create(updater, true); + // add LEAP mode command-line argument to whichever of these we selected + updater.args.add("leap"); + // UpdaterServiceSettings + updater.args.add(stringize(gSavedSettings.getU32("UpdaterServiceSetting"))); + // channel + updater.args.add(LLVersionInfo::getChannel()); + // testok + updater.args.add(stringize(gSavedSettings.getBOOL("UpdaterWillingToTest"))); + // ForceAddressSize + updater.args.add(stringize(gSavedSettings.getU32("ForceAddressSize"))); + + // Run the updater. An exception from launching the updater should bother us. + LLLeap::create(updater, true); + } + else + { + LL_WARNS("InitInfo") << "Skipping updater check." << LL_ENDL; + } // Iterate over --leap command-line options. But this is a bit tricky: if // there's only one, it won't be an array at all. @@ -1306,6 +1314,8 @@ static LLTrace::BlockTimerStatHandle FTM_YIELD("Yield"); static LLTrace::BlockTimerStatHandle FTM_TEXTURE_CACHE("Texture Cache"); static LLTrace::BlockTimerStatHandle FTM_DECODE("Image Decode"); +static LLTrace::BlockTimerStatHandle FTM_FETCH("Image Fetch"); + static LLTrace::BlockTimerStatHandle FTM_VFS("VFS Thread"); static LLTrace::BlockTimerStatHandle FTM_LFS("LFS Thread"); static LLTrace::BlockTimerStatHandle FTM_PAUSE_THREADS("Pause Threads"); @@ -1620,7 +1630,7 @@ S32 LLAppViewer::updateTextureThreads(F32 max_time) work_pending += LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread } { - LL_RECORD_BLOCK_TIME(FTM_DECODE); + LL_RECORD_BLOCK_TIME(FTM_FETCH); work_pending += LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread } return work_pending; @@ -1643,6 +1653,8 @@ void LLAppViewer::flushVFSIO() bool LLAppViewer::cleanup() { + LLAtmosphere::cleanupClass(); + //ditch LLVOAvatarSelf instance gAgentAvatarp = NULL; @@ -4892,7 +4904,6 @@ void LLAppViewer::idle() // // Update weather effects // - gSky.propagateHeavenlyBodies(gFrameDTClamped); // moves sun, moon, and planets // Update wind vector LLVector3 wind_position_region; diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index e607b4a994..51d2d98485 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -390,8 +390,6 @@ extern LLVector3 gRelativeWindVec; extern U32 gPacketsIn; extern BOOL gPrintMessagesThisFrame; -extern LLUUID gSunTextureID; -extern LLUUID gMoonTextureID; extern LLUUID gBlackSquareID; extern BOOL gRandomizeFramerate; diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index d3fd5813a0..fb61ad4b07 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -35,8 +35,6 @@ #include "llviewerregion.h" #include "llskinningutil.h" -//#pragma optimize("", off) - const F32 LLControlAvatar::MAX_LEGAL_OFFSET = 3.0f; const F32 LLControlAvatar::MAX_LEGAL_SIZE = 64.0f; diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp deleted file mode 100644 index 803e2b2fb2..0000000000 --- a/indra/newview/lldaycyclemanager.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/** - * @file lldaycyclemanager.cpp - * @brief Implementation for the LLDayCycleManager class. - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "lldaycyclemanager.h" - -#include "lldiriterator.h" - -void LLDayCycleManager::getPresetNames(preset_name_list_t& names) const -{ - names.clear(); - - for (dc_map_t::const_iterator it = mDayCycleMap.begin(); it != mDayCycleMap.end(); ++it) - { - names.push_back(it->first); - } -} - -void LLDayCycleManager::getPresetNames(preset_name_list_t& user, preset_name_list_t& sys) const -{ - user.clear(); - sys.clear(); - - for (dc_map_t::const_iterator it = mDayCycleMap.begin(); it != mDayCycleMap.end(); ++it) - { - const std::string& name = it->first; - - if (isSystemPreset(name)) - { - sys.push_back(name); - } - else - { - user.push_back(name); - } - } -} - -void LLDayCycleManager::getUserPresetNames(preset_name_list_t& user) const -{ - preset_name_list_t sys; // unused - getPresetNames(user, sys); -} - -bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycle) const -{ - dc_map_t::const_iterator it = mDayCycleMap.find(name); - if (it == mDayCycleMap.end()) - { - return false; - } - - day_cycle = it->second; - return true; -} - -bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) const -{ - LLWLDayCycle dc; - if (!getPreset(name, dc)) - { - return false; - } - - day_cycle = dc.asLLSD(); - return true; -} - -bool LLDayCycleManager::presetExists(const std::string name) const -{ - LLWLDayCycle dummy; - return getPreset(name, dummy); -} - -bool LLDayCycleManager::isSystemPreset(const std::string& name) const -{ - return gDirUtilp->fileExists(getSysDir() + LLURI::escape(name) + ".xml"); -} - -bool LLDayCycleManager::savePreset(const std::string& name, const LLSD& data) -{ - // Save given preset. - LLWLDayCycle day; - day.loadDayCycle(data, LLEnvKey::SCOPE_LOCAL); - day.save(getUserDir() + LLURI::escape(name) + ".xml"); - - // Add it to our map. - addPreset(name, data); - mModifySignal(); - return true; -} - -bool LLDayCycleManager::deletePreset(const std::string& name) -{ - // Remove it from the map. - dc_map_t::iterator it = mDayCycleMap.find(name); - if (it == mDayCycleMap.end()) - { - LL_WARNS("Windlight") << "No day cycle named " << name << LL_ENDL; - return false; - } - mDayCycleMap.erase(it); - - // Remove from the filesystem. - std::string filename = LLURI::escape(name) + ".xml"; - if (gDirUtilp->fileExists(getUserDir() + filename)) - { - gDirUtilp->deleteFilesInDir(getUserDir(), filename); - } - - // Signal interested parties. - mModifySignal(); - return true; -} - -bool LLDayCycleManager::isSkyPresetReferenced(const std::string& preset_name) const -{ - // We're traversing local day cycles, they can only reference local skies. - LLWLParamKey key(preset_name, LLEnvKey::SCOPE_LOCAL); - - for (dc_map_t::const_iterator it = mDayCycleMap.begin(); it != mDayCycleMap.end(); ++it) - { - if (it->second.hasReferencesTo(key)) - { - return true; - } - } - - return false; -} - -boost::signals2::connection LLDayCycleManager::setModifyCallback(const modify_signal_t::slot_type& cb) -{ - return mModifySignal.connect(cb); -} - -// virtual -void LLDayCycleManager::initSingleton() -{ - LL_DEBUGS("Windlight") << "Loading all day cycles" << LL_ENDL; - loadAllPresets(); -} - -void LLDayCycleManager::loadAllPresets() -{ - mDayCycleMap.clear(); - - // First, load system (coming out of the box) day cycles. - loadPresets(getSysDir()); - - // Then load user presets. Note that user day cycles will modify any system ones already loaded. - loadPresets(getUserDir()); -} - -void LLDayCycleManager::loadPresets(const std::string& dir) -{ - LLDirIterator dir_iter(dir, "*.xml"); - - while (1) - { - std::string file; - if (!dir_iter.next(file)) break; // no more files - loadPreset(gDirUtilp->add(dir, file)); - } -} - -bool LLDayCycleManager::loadPreset(const std::string& path) -{ - LLSD data = LLWLDayCycle::loadDayCycleFromPath(path); - if (data.isUndefined()) - { - LL_WARNS() << "Error loading day cycle from " << path << LL_ENDL; - return false; - } - - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - addPreset(name, data); - - return true; -} - -bool LLDayCycleManager::addPreset(const std::string& name, const LLSD& data) -{ - if (name.empty()) - { - //llassert(name.empty()); - return false; - } - - LLWLDayCycle day; - day.loadDayCycle(data, LLEnvKey::SCOPE_LOCAL); - mDayCycleMap[name] = day; - return true; -} - -// static -std::string LLDayCycleManager::getSysDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", ""); -} - -// static -std::string LLDayCycleManager::getUserDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/days", ""); -} diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h deleted file mode 100644 index 04db9d5dac..0000000000 --- a/indra/newview/lldaycyclemanager.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @file lldaycyclemanager.h - * @brief Implementation for the LLDayCycleManager class. - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLDAYCYCLEMANAGER_H -#define LL_LLDAYCYCLEMANAGER_H - -#include <map> -#include <string> - -#include "llwldaycycle.h" -#include "llwlparammanager.h" - -/** - * WindLight day cycles manager class - * - * Provides interface for accessing, loading and saving day cycles. - */ -class LLDayCycleManager : public LLSingleton<LLDayCycleManager> -{ - LLSINGLETON_EMPTY_CTOR(LLDayCycleManager); - LOG_CLASS(LLDayCycleManager); - -public: - typedef std::list<std::string> preset_name_list_t; - - typedef std::map<std::string, LLWLDayCycle> dc_map_t; - typedef boost::signals2::signal<void()> modify_signal_t; - - void getPresetNames(preset_name_list_t& names) const; - void getPresetNames(preset_name_list_t& user, preset_name_list_t& sys) const; - void getUserPresetNames(preset_name_list_t& user) const; - - bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const; - bool getPreset(const std::string name, LLSD& day_cycle) const; - bool presetExists(const std::string name) const; - bool isSystemPreset(const std::string& name) const; - bool savePreset(const std::string& name, const LLSD& data); - bool deletePreset(const std::string& name); - - /// @return true if there is a day cycle that refers to the sky preset. - bool isSkyPresetReferenced(const std::string& preset_name) const; - - /// Emitted when a preset gets added or deleted. - boost::signals2::connection setModifyCallback(const modify_signal_t::slot_type& cb); - -private: - /*virtual*/ void initSingleton(); - - void loadAllPresets(); - void loadPresets(const std::string& dir); - bool loadPreset(const std::string& path); - bool addPreset(const std::string& name, const LLSD& data); - - static std::string getSysDir(); - static std::string getUserDir(); - - dc_map_t mDayCycleMap; - modify_signal_t mModifySignal; -}; - -#endif // LL_LLDAYCYCLEMANAGER_H diff --git a/indra/newview/lldensityctrl.cpp b/indra/newview/lldensityctrl.cpp new file mode 100644 index 0000000000..298a309e7c --- /dev/null +++ b/indra/newview/lldensityctrl.cpp @@ -0,0 +1,225 @@ +/** +* @file lldensityctrl.cpp +* @brief Control for specifying density over a height range for sky settings. +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "lldensityctrl.h" + +#include "llslider.h" +#include "llsliderctrl.h" +#include "llsettingssky.h" + +static LLDefaultChildRegistry::Register<LLDensityCtrl> register_density_control("densityctrl"); + +const std::string LLDensityCtrl::DENSITY_RAYLEIGH("density_rayleigh"); +const std::string LLDensityCtrl::DENSITY_MIE("density_mie"); +const std::string LLDensityCtrl::DENSITY_ABSORPTION("density_absorption"); + +namespace +{ + const std::string FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL("level_exponential"); + const std::string FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE("exponential_scale"); + const std::string FIELD_SKY_DENSITY_PROFILE_LINEAR("level_linear"); + const std::string FIELD_SKY_DENSITY_PROFILE_CONSTANT("level_constant"); + const std::string FIELD_SKY_DENSITY_MAX_ALTITUDE("max_altitude"); + const std::string FIELD_SKY_DENSITY_ANISO_FACTOR("aniso_factor"); + const std::string FIELD_SKY_DENSITY_ANISO_FACTOR_LABEL("aniso_factor_label"); +} + +const std::string& LLDensityCtrl::NameForDensityProfileType(DensityProfileType t) +{ + switch (t) + { + case Rayleigh: return DENSITY_RAYLEIGH; + case Mie: return DENSITY_MIE; + case Absorption: return DENSITY_ABSORPTION; + default: + break; + } + + llassert(false); + return DENSITY_RAYLEIGH; +} + +LLDensityCtrl::Params::Params() +: image_density_feedback("image_density_feedback") +, lbl_exponential("label_exponential") +, lbl_exponential_scale("label_exponential_scale") +, lbl_linear("label_linear") +, lbl_constant("label_constant") +, lbl_max_altitude("label_max_altitude") +, lbl_aniso_factor("label_aniso_factor") +, profile_type(LLDensityCtrl::Rayleigh) +{ +} + +LLDensityCtrl::LLDensityCtrl(const Params& params) +: mProfileType(params.profile_type) +, mImgDensityFeedback(params.image_density_feedback) +{ + +} + +LLSD LLDensityCtrl::getProfileConfig() +{ + LLSD config; + switch (mProfileType) + { + case Rayleigh: return mSkySettings->getRayleighConfigs(); + case Mie: return mSkySettings->getMieConfigs(); + case Absorption: return mSkySettings->getAbsorptionConfigs(); + default: + break; + } + llassert(false); + return config; +} + +BOOL LLDensityCtrl::postBuild() +{ + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onExponentialChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onExponentialScaleFactorChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLinearChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onConstantChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMaxAltitudeChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ANISO_FACTOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAnisoFactorChanged(); }); + + if (mProfileType != Mie) + { + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ANISO_FACTOR_LABEL)->setValue(false); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ANISO_FACTOR)->setVisible(false); + } + + return TRUE; +} + +void LLDensityCtrl::setEnabled(BOOL enabled) +{ + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_LINEAR)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setEnabled(enabled); + + if (mProfileType == Mie) + { + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ANISO_FACTOR)->setEnabled(enabled); + } +} + +void LLDensityCtrl::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + LLSD config = getProfileConfig(); + + getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); + getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); + getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_LINEAR)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); + getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); + getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH]); + + if (mProfileType == Mie) + { + getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_ANISO_FACTOR)->setValue(config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR]); + } +} + +void LLDensityCtrl::updateProfile() +{ + F32 exponential_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->getValueF32(); + F32 exponential_scale = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->getValueF32(); + F32 linear_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_LINEAR)->getValueF32(); + F32 constant_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->getValueF32(); + F32 max_alt = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MAX_ALTITUDE)->getValueF32(); + F32 aniso_factor = 0.0f; + + if (mProfileType == Mie) + { + aniso_factor = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_ANISO_FACTOR)->getValueF32(); + } + + LLSD profile = LLSettingsSky::createSingleLayerDensityProfile(max_alt, exponential_term, exponential_scale, linear_term, constant_term, aniso_factor); + + switch (mProfileType) + { + case Rayleigh: mSkySettings->setRayleighConfigs(profile); break; + case Mie: mSkySettings->setMieConfigs(profile); break; + case Absorption: mSkySettings->setAbsorptionConfigs(profile); break; + default: + break; + } +} + +void LLDensityCtrl::onExponentialChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onExponentialScaleFactorChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onLinearChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onConstantChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onMaxAltitudeChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onAnisoFactorChanged() +{ + updateProfile(); +} + +void LLDensityCtrl::updatePreview() +{ + // AdvancedAtmospherics TODO + // Generate image according to current density profile +} + diff --git a/indra/newview/lldensityctrl.h b/indra/newview/lldensityctrl.h new file mode 100644 index 0000000000..789022803c --- /dev/null +++ b/indra/newview/lldensityctrl.h @@ -0,0 +1,104 @@ +/** +* @file lldensityctrl.h +* @brief Control for specifying density over a height range for sky settings. +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LLDENSITY_CTRL_H +#define LLDENSITY_CTRL_H + +#include "lluictrl.h" +#include "llsettingssky.h" +#include "lltextbox.h" +#include "llsliderctrl.h" + +class LLDensityCtrl : public LLUICtrl +{ +public: + static const std::string DENSITY_RAYLEIGH; + static const std::string DENSITY_MIE; + static const std::string DENSITY_ABSORPTION; + + // Type of density profile this tab is updating + enum DensityProfileType + { + Rayleigh, + Mie, + Absorption + }; + + static const std::string& NameForDensityProfileType(DensityProfileType t); + + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> + { + Optional<LLTextBox::Params> lbl_exponential, + lbl_exponential_scale, + lbl_linear, + lbl_constant, + lbl_max_altitude, + lbl_aniso_factor; + + Optional<LLSliderCtrl::Params> exponential_slider, + exponential_scale_slider, + linear_slider, + constant_slider, + aniso_factor_slider; + + Optional<LLUIImage*> image_density_feedback; + + DensityProfileType profile_type; + Params(); + }; + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + + void setProfileType(DensityProfileType t) { mProfileType = t; } + + void refresh(); + void updateProfile(); + + LLSettingsSky::ptr_t getSky() const { return mSkySettings; } + void setSky(const LLSettingsSky::ptr_t &sky) { mSkySettings = sky; refresh(); } + +protected: + friend class LLUICtrlFactory; + LLDensityCtrl(const Params&); + + LLSD getProfileConfig(); + void updatePreview(); + +private: + void onExponentialChanged(); + void onExponentialScaleFactorChanged(); + void onLinearChanged(); + void onConstantChanged(); + void onMaxAltitudeChanged(); + void onAnisoFactorChanged(); + + DensityProfileType mProfileType = Rayleigh; + LLUIImage* mImgDensityFeedback = nullptr; + LLSettingsSky::ptr_t mSkySettings; +}; + +#endif LLDENSITY_CTRL_H diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 82888b2df6..9c072bb0aa 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -127,7 +127,7 @@ LLDrawPool::LLDrawPool(const U32 type) mType = type; sNumDrawPools++; mId = sNumDrawPools; - mVertexShaderLevel = 0; + mShaderLevel = 0; mSkipRender = false; } @@ -141,7 +141,7 @@ LLViewerTexture *LLDrawPool::getDebugTexture() return NULL; } -//virtuals +//virtual void LLDrawPool::beginRenderPass( S32 pass ) { } @@ -449,10 +449,10 @@ void LLRenderPass::applyModelMatrix(const LLDrawInfo& params) if (params.mModelMatrix != gGLLastMatrix) { gGLLastMatrix = params.mModelMatrix; + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(gGLModelView); if (params.mModelMatrix) { - llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW); gGL.multMatrix((GLfloat*) params.mModelMatrix->mMatrix); } gPipeline.mMatrixOpCount++; @@ -515,6 +515,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba if (tex_setup) { + gGL.matrixMode(LLRender::MM_TEXTURE0); gGL.loadIdentity(); gGL.matrixMode(LLRender::MM_MODELVIEW); } diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index bc299cc89f..df86d78a89 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -107,7 +107,7 @@ public: virtual void prerender() = 0; virtual U32 getVertexDataMask() = 0; virtual BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct! - virtual S32 getVertexShaderLevel() const { return mVertexShaderLevel; } + virtual S32 getShaderLevel() const { return mShaderLevel; } static LLDrawPool* createPool(const U32 type, LLViewerTexture *tex0 = NULL); virtual LLDrawPool *instancePool() = 0; // Create an empty new instance of the pool. @@ -116,7 +116,7 @@ public: virtual void resetDrawOrders() = 0; protected: - S32 mVertexShaderLevel; + S32 mShaderLevel; S32 mId; U32 mType; // Type of draw pool BOOL mSkipRender; diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 0873300cd2..9f65a70a86 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -49,10 +49,30 @@ #include "llspatialpartition.h" #include "llglcommonfunc.h" +// These optimizations can and will induce lighting, texturing, and/or GL state bugs +#define BATCH_FULLBRIGHTS 0 +#define BATCH_EMISSIVES 0 + BOOL LLDrawPoolAlpha::sShowDebugAlpha = FALSE; static BOOL deferred_render = FALSE; +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_SETUP("Alpha Setup"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_GROUP_LOOP("Alpha Group"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_PUSH("Alpha Push Verts"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_DEFERRED("Alpha Deferred"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_SETBUFFER("Alpha SetBuffer"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_DRAW("Alpha Draw"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_TEX_BINDS("Alpha Tex Binds"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_MATS("Alpha Mat Tex Binds"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_GLOW("Alpha Glow Binds"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_SHADER_BINDS("Alpha Shader Binds"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_DEFERRED_SHADER_BINDS("Alpha Def Binds"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_DEFERRED_TEX_BINDS("Alpha Def Tex Binds"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_MESH_REBUILD("Alpha Mesh Rebuild"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_EMISSIVE("Alpha Emissive"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_LIGHT_SETUP("Alpha Light Setup"); + LLDrawPoolAlpha::LLDrawPoolAlpha(U32 type) : LLRenderPass(type), current_shader(NULL), target_shader(NULL), simple_shader(NULL), fullbright_shader(NULL), emissive_shader(NULL), @@ -69,7 +89,7 @@ LLDrawPoolAlpha::~LLDrawPoolAlpha() void LLDrawPoolAlpha::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } S32 LLDrawPoolAlpha::getNumPostDeferredPasses() @@ -90,37 +110,37 @@ S32 LLDrawPoolAlpha::getNumPostDeferredPasses() void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) { - LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA); + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED); + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + + emissive_shader = (LLPipeline::sRenderDeferred) ? &gDeferredEmissiveProgram : + (LLPipeline::sUnderWaterRender) ? &gObjectEmissiveWaterProgram : &gObjectEmissiveProgram; + + emissive_shader->bind(); + emissive_shader->uniform1i(LLShaderMgr::NO_ATMO, (LLPipeline::sRenderingHUDs) ? 1 : 0); + emissive_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + emissive_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); if (pass == 0) { - if (LLPipeline::sImpostorRender) - { - simple_shader = &gDeferredAlphaImpostorProgram; - fullbright_shader = &gDeferredFullbrightProgram; - } - else if (LLPipeline::sUnderWaterRender) - { - simple_shader = &gDeferredAlphaWaterProgram; - fullbright_shader = &gDeferredFullbrightWaterProgram; - } - else - { - simple_shader = &gDeferredAlphaProgram; - fullbright_shader = &gDeferredFullbrightProgram; - } - - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + fullbright_shader = (LLPipeline::sImpostorRender) ? &gDeferredFullbrightProgram : + (LLPipeline::sUnderWaterRender) ? &gDeferredFullbrightWaterProgram : &gDeferredFullbrightProgram; fullbright_shader->bind(); fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); fullbright_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + fullbright_shader->uniform1i(LLShaderMgr::NO_ATMO, LLPipeline::sRenderingHUDs ? 1 : 0); fullbright_shader->unbind(); + simple_shader = (LLPipeline::sImpostorRender) ? &gDeferredAlphaImpostorProgram : + (LLPipeline::sUnderWaterRender) ? &gDeferredAlphaWaterProgram : &gDeferredAlphaProgram; + //prime simple shader (loads shadow relevant uniforms) gPipeline.bindDeferredShader(*simple_shader); simple_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, LLPipeline::sRenderingHUDs ? 1 : 0); } else if (!LLPipeline::sImpostorRender) { @@ -134,25 +154,8 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) gObjectFullbrightAlphaMaskProgram.setMinimumAlpha(0.33f); } - - if (LLPipeline::sRenderDeferred) - { - emissive_shader = &gDeferredEmissiveProgram; - } - else - { - if (LLPipeline::sUnderWaterRender) - { - emissive_shader = &gObjectEmissiveWaterProgram; - } - else - { - emissive_shader = &gObjectEmissiveProgram; - } - } - deferred_render = TRUE; - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { // Start out with no shaders. current_shader = target_shader = NULL; @@ -162,6 +165,8 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) void LLDrawPoolAlpha::endPostDeferredPass(S32 pass) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED); + if (pass == 1 && !LLPipeline::sImpostorRender) { gPipeline.mDeferredDepth.flush(); @@ -175,44 +180,61 @@ void LLDrawPoolAlpha::endPostDeferredPass(S32 pass) void LLDrawPoolAlpha::renderPostDeferred(S32 pass) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED); render(pass); } void LLDrawPoolAlpha::beginRenderPass(S32 pass) { - LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA); + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_SETUP); - if (LLPipeline::sImpostorRender) - { - simple_shader = &gObjectSimpleImpostorProgram; - fullbright_shader = &gObjectFullbrightProgram; - emissive_shader = &gObjectEmissiveProgram; - } - else if (LLPipeline::sUnderWaterRender) - { - simple_shader = &gObjectSimpleWaterProgram; - fullbright_shader = &gObjectFullbrightWaterProgram; - emissive_shader = &gObjectEmissiveWaterProgram; - } - else - { - simple_shader = &gObjectSimpleProgram; - fullbright_shader = &gObjectFullbrightProgram; - emissive_shader = &gObjectEmissiveProgram; - } + simple_shader = (LLPipeline::sImpostorRender) ? &gObjectSimpleImpostorProgram : + (LLPipeline::sUnderWaterRender) ? &gObjectSimpleWaterProgram : &gObjectSimpleProgram; + + fullbright_shader = (LLPipeline::sImpostorRender) ? &gObjectFullbrightProgram : + (LLPipeline::sUnderWaterRender) ? &gObjectFullbrightWaterProgram : &gObjectFullbrightProgram; - if (mVertexShaderLevel > 0) + emissive_shader = (LLPipeline::sImpostorRender) ? &gObjectEmissiveProgram : + (LLPipeline::sUnderWaterRender) ? &gObjectEmissiveWaterProgram : &gObjectEmissiveProgram; + + if (LLPipeline::sImpostorRender) { - // Start out with no shaders. - current_shader = target_shader = NULL; - LLGLSLShader::bindNoShader(); + if (mShaderLevel > 0) + { + fullbright_shader->bind(); + fullbright_shader->setMinimumAlpha(0.5f); + fullbright_shader->uniform1i(LLShaderMgr::NO_ATMO, LLPipeline::sRenderingHUDs ? 1 : 0); + simple_shader->bind(); + simple_shader->setMinimumAlpha(0.5f); + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, LLPipeline::sRenderingHUDs ? 1 : 0); + } + else + { + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); //OK + } } + else + { + if (mShaderLevel > 0) + { + fullbright_shader->bind(); + fullbright_shader->setMinimumAlpha(0.f); + fullbright_shader->uniform1i(LLShaderMgr::NO_ATMO, LLPipeline::sRenderingHUDs ? 1 : 0); + simple_shader->bind(); + simple_shader->setMinimumAlpha(0.f); + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, LLPipeline::sRenderingHUDs ? 1 : 0); + } + else + { + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK + } + } gPipeline.enableLightsDynamic(); } void LLDrawPoolAlpha::endRenderPass( S32 pass ) { - LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA); + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_SETUP); LLRenderPass::endRenderPass(pass); if(gPipeline.canUseWindLightShaders()) @@ -255,38 +277,9 @@ void LLDrawPoolAlpha::render(S32 pass) mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); - - if (mVertexShaderLevel > 0) - { - if (LLPipeline::sImpostorRender) - { - fullbright_shader->bind(); - fullbright_shader->setMinimumAlpha(0.5f); - simple_shader->bind(); - simple_shader->setMinimumAlpha(0.5f); - } - else - { - fullbright_shader->bind(); - fullbright_shader->setMinimumAlpha(0.f); - simple_shader->bind(); - simple_shader->setMinimumAlpha(0.f); - } - } - else - { - if (LLPipeline::sImpostorRender) - { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); //OK - } - else - { - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK - } - } } - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, pass); } @@ -370,8 +363,252 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) } } -static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_GROUP_LOOP("Alpha Group"); -static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_PUSH("Alpha Push Verts"); +inline bool IsFullbright(LLDrawInfo& params) +{ + return params.mFullbright; +} + +inline bool IsMaterial(LLDrawInfo& params) +{ + return params.mMaterial != nullptr; +} + +inline bool IsEmissive(LLDrawInfo& params) +{ + return params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE); +} + +inline void Draw(LLDrawInfo* draw, U32 mask) +{ + draw->mVertexBuffer->setBuffer(mask); + LLRenderPass::applyModelMatrix(*draw); + draw->mVertexBuffer->drawRange(draw->mDrawMode, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + gPipeline.addTrianglesDrawn(draw->mCount, draw->mDrawMode); +} + +bool LLDrawPoolAlpha::TexSetup(LLDrawInfo* draw, bool use_shaders, bool use_material, LLGLSLShader* current_shader) +{ + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_TEX_BINDS); + + bool tex_setup = false; + + if (use_shaders && use_material && current_shader) + { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED_TEX_BINDS); + if (draw->mNormalMap) + { + draw->mNormalMap->addTextureStats(draw->mVSize); + current_shader->bindTexture(LLShaderMgr::BUMP_MAP, draw->mNormalMap); + } + + if (draw->mSpecularMap) + { + draw->mSpecularMap->addTextureStats(draw->mVSize); + current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, draw->mSpecularMap); + } + } + else if (current_shader == simple_shader) + { + LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(draw->mVSize); + LLViewerFetchedTexture::sWhiteImagep->addTextureStats(draw->mVSize); + current_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); + current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); + } + if (use_shaders && draw->mTextureList.size() > 1) + { + for (U32 i = 0; i < draw->mTextureList.size(); ++i) + { + if (draw->mTextureList[i].notNull()) + { + gGL.getTexUnit(i)->bind(draw->mTextureList[i], TRUE); + } + } + } + else + { //not batching textures or batch has only 1 texture -- might need a texture matrix + if (draw->mTexture.notNull()) + { + draw->mTexture->addTextureStats(draw->mVSize); + if (use_shaders && use_material) + { + current_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, draw->mTexture); + } + else + { + gGL.getTexUnit(0)->bind(draw->mTexture, TRUE) ; + } + + if (draw->mTextureMatrix) + { + tex_setup = true; + gGL.getTexUnit(0)->activate(); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadMatrix((GLfloat*) draw->mTextureMatrix->mMatrix); + gPipeline.mTextureMatrixOps++; + } + } + else + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + } + + return tex_setup; +} + +void LLDrawPoolAlpha::RestoreTexSetup(bool tex_setup) +{ + if (tex_setup) + { + gGL.getTexUnit(0)->activate(); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + } +} + +void LLDrawPoolAlpha::renderSimples(U32 mask, std::vector<LLDrawInfo*>& simples) +{ + gPipeline.enableLightsDynamic(); + simple_shader->bind(); + simple_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); + simple_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); + simple_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, 1.0f, 1.0f, 1.0f, 1.0f); + simple_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, 0.0f); + simple_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 0.0f); + bool use_shaders = gPipeline.canUseVertexShaders(); + for (LLDrawInfo* draw : simples) + { + bool tex_setup = TexSetup(draw, use_shaders, false, simple_shader); + LLGLEnableFunc stencil_test(GL_STENCIL_TEST, draw->mSelected, &LLGLCommonFunc::selected_stencil_test); + gGL.blendFunc((LLRender::eBlendFactor) draw->mBlendFuncSrc, (LLRender::eBlendFactor) draw->mBlendFuncDst, mAlphaSFactor, mAlphaDFactor); + + Draw(draw, mask); + RestoreTexSetup(tex_setup); + } + simple_shader->unbind(); +} + +void LLDrawPoolAlpha::renderFullbrights(U32 mask, std::vector<LLDrawInfo*>& fullbrights) +{ + gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); + fullbright_shader->bind(); + fullbright_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 1.0f); + bool use_shaders = gPipeline.canUseVertexShaders(); + for (LLDrawInfo* draw : fullbrights) + { + bool tex_setup = TexSetup(draw, use_shaders, false, fullbright_shader); + + LLGLEnableFunc stencil_test(GL_STENCIL_TEST, draw->mSelected, &LLGLCommonFunc::selected_stencil_test); + gGL.blendFunc((LLRender::eBlendFactor) draw->mBlendFuncSrc, (LLRender::eBlendFactor) draw->mBlendFuncDst, mAlphaSFactor, mAlphaDFactor); + + Draw(draw, mask & ~(LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2)); + RestoreTexSetup(tex_setup); + } + fullbright_shader->unbind(); +} + +void LLDrawPoolAlpha::renderMaterials(U32 mask, std::vector<LLDrawInfo*>& materials) +{ + LLGLSLShader::bindNoShader(); + current_shader = NULL; + + gPipeline.enableLightsDynamic(); + bool use_shaders = gPipeline.canUseVertexShaders(); + for (LLDrawInfo* draw : materials) + { + U32 mask = draw->mShaderMask; + + llassert(mask < LLMaterial::SHADER_COUNT); + target_shader = (LLPipeline::sUnderWaterRender) ? &(gDeferredMaterialWaterProgram[mask]) : &(gDeferredMaterialProgram[mask]); + + if (current_shader != target_shader) + { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED_SHADER_BINDS); + if (current_shader) + { + gPipeline.unbindDeferredShader(*current_shader); + } + gPipeline.bindDeferredShader(*target_shader); + current_shader = target_shader; + } + + bool tex_setup = TexSetup(draw, use_shaders, true, current_shader); + + current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, draw->mSpecColor.mV[0], draw->mSpecColor.mV[1], draw->mSpecColor.mV[2], draw->mSpecColor.mV[3]); + current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, draw->mEnvIntensity); + current_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, draw->mFullbright ? 1.f : 0.f); + + { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED_TEX_BINDS); + if (draw->mNormalMap) + { + draw->mNormalMap->addTextureStats(draw->mVSize); + current_shader->bindTexture(LLShaderMgr::BUMP_MAP, draw->mNormalMap); + } + + if (draw->mSpecularMap) + { + draw->mSpecularMap->addTextureStats(draw->mVSize); + current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, draw->mSpecularMap); + } + } + + LLGLEnableFunc stencil_test(GL_STENCIL_TEST, draw->mSelected, &LLGLCommonFunc::selected_stencil_test); + gGL.blendFunc((LLRender::eBlendFactor) draw->mBlendFuncSrc, (LLRender::eBlendFactor) draw->mBlendFuncDst, mAlphaSFactor, mAlphaDFactor); + + Draw(draw, mask); + RestoreTexSetup(tex_setup); + } +} + +void LLDrawPoolAlpha::drawEmissive(U32 mask, LLDrawInfo* draw) +{ + draw->mVertexBuffer->setBuffer((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); + draw->mVertexBuffer->drawRange(draw->mDrawMode, draw->mStart, draw->mEnd, draw->mCount, draw->mOffset); + gPipeline.addTrianglesDrawn(draw->mCount, draw->mDrawMode); +} + +void LLDrawPoolAlpha::drawEmissiveInline(U32 mask, LLDrawInfo* draw) +{ + // install glow-accumulating blend mode + gGL.blendFunc( + LLRender::BF_ZERO, LLRender::BF_ONE, // don't touch color + LLRender::BF_ONE, LLRender::BF_ONE); // add to alpha (glow) + + emissive_shader->bind(); + + drawEmissive(mask, draw); + + // restore our alpha blend mode + gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); + + current_shader->bind(); +} + +void LLDrawPoolAlpha::renderEmissives(U32 mask, std::vector<LLDrawInfo*>& emissives) +{ + emissive_shader->bind(); + emissive_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 1.f); + + gPipeline.enableLightsDynamic(); + + // install glow-accumulating blend mode + // don't touch color, add to alpha (glow) + gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE, LLRender::BF_ONE, LLRender::BF_ONE); + bool use_shaders = gPipeline.canUseVertexShaders(); + for (LLDrawInfo* draw : emissives) + { + bool tex_setup = TexSetup(draw, use_shaders, false, emissive_shader); + drawEmissive(mask, draw); + RestoreTexSetup(tex_setup); + } + + // restore our alpha blend mode + gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); + + emissive_shader->unbind(); +} void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) { @@ -389,10 +626,13 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) if (group->getSpatialPartition()->mRenderByGroup && !group->isDead()) { + std::vector<LLDrawInfo*> emissives; + std::vector<LLDrawInfo*> fullbrights; + bool is_particle_or_hud_particle = group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_PARTICLE || group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_HUD_PARTICLE; - bool draw_glow_for_this_partition = mVertexShaderLevel > 0; // no shaders = no glow. + bool draw_glow_for_this_partition = mShaderLevel > 0; // no shaders = no glow. LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_GROUP_LOOP); @@ -405,11 +645,11 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; - - if ((params.mVertexBuffer->getTypeMask() & mask) != mask) + U32 have_mask = params.mVertexBuffer->getTypeMask() & mask; + if (have_mask != mask) { //FIXME! LL_WARNS_ONCE() << "Missing required components, expected mask: " << mask - << " present: " << (params.mVertexBuffer->getTypeMask() & mask) + << " present: " << have_mask << ". Skipping render batch." << LL_ENDL; continue; } @@ -431,6 +671,14 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) } } + #if BATCH_FULLBRIGHTS + if (params.mFullbright) + { + fullbrights.push_back(¶ms); + continue; + } + #endif + LLRenderPass::applyModelMatrix(params); LLMaterial* mat = NULL; @@ -445,6 +693,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) // Turn off lighting if it hasn't already been so. if (light_enabled || !initialized_lighting) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_LIGHT_SETUP); + initialized_lighting = TRUE; if (use_shaders) { @@ -460,6 +710,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) // Turn on lighting if it isn't already. else if (!light_enabled || !initialized_lighting) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_LIGHT_SETUP); + initialized_lighting = TRUE; if (use_shaders) { @@ -486,7 +738,9 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) if (current_shader != target_shader) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED_SHADER_BINDS); gPipeline.bindDeferredShader(*target_shader); + current_shader = target_shader; } } else if (!params.mFullbright) @@ -501,6 +755,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) if(use_shaders && (current_shader != target_shader)) {// If we need shaders, and we're not ALREADY using the proper shader, then bind it // (this way we won't rebind shaders unnecessarily). + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_SHADER_BINDS); current_shader = target_shader; current_shader->bind(); } @@ -510,83 +765,31 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) current_shader = NULL; } - if (use_shaders && mat) - { - // We have a material. Supply the appropriate data here. - if (LLPipeline::sRenderDeferred) - { - current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, params.mSpecColor.mV[0], params.mSpecColor.mV[1], params.mSpecColor.mV[2], params.mSpecColor.mV[3]); - current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, params.mEnvIntensity); - current_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, params.mFullbright ? 1.f : 0.f); + LLVector4 spec_color(1, 1, 1, 1); + F32 env_intensity = 0.0f; + F32 brightness = 1.0f; - if (params.mNormalMap) - { - params.mNormalMap->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap); - } - - if (params.mSpecularMap) - { - params.mSpecularMap->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap); - } - } - - } else if (LLPipeline::sRenderDeferred && current_shader && (current_shader == simple_shader)) + // We have a material. Supply the appropriate data here. + if (use_shaders && mat && LLPipeline::sRenderDeferred) { - current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, 1.0f, 1.0f, 1.0f, 1.0f); - current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, 0.0f); - LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); - LLViewerFetchedTexture::sWhiteImagep->addTextureStats(params.mVSize); - current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); - } + spec_color = params.mSpecColor; + env_intensity = params.mEnvIntensity; + brightness = params.mFullbright ? 1.f : 0.f; + } + + if (current_shader) + { + current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, spec_color.mV[0], spec_color.mV[1], spec_color.mV[2], spec_color.mV[3]); + current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, env_intensity); + current_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, brightness); + } if (params.mGroup) { params.mGroup->rebuildMesh(); } - bool tex_setup = false; - - if (use_shaders && params.mTextureList.size() > 1) - { - for (U32 i = 0; i < params.mTextureList.size(); ++i) - { - if (params.mTextureList[i].notNull()) - { - gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE); - } - } - } - else - { //not batching textures or batch has only 1 texture -- might need a texture matrix - if (params.mTexture.notNull()) - { - params.mTexture->addTextureStats(params.mVSize); - if (use_shaders && mat) - { - current_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, params.mTexture); - } - else - { - gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ; - } - - if (params.mTextureMatrix) - { - tex_setup = true; - gGL.getTexUnit(0)->activate(); - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix); - gPipeline.mTextureMatrixOps++; - } - } - else - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - } + bool tex_setup = TexSetup(¶ms, use_shaders, mat != nullptr, current_shader); { LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_PUSH); @@ -596,41 +799,50 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass) gGL.blendFunc((LLRender::eBlendFactor) params.mBlendFuncSrc, (LLRender::eBlendFactor) params.mBlendFuncDst, mAlphaSFactor, mAlphaDFactor); params.mVertexBuffer->setBuffer(mask & ~(params.mFullbright ? (LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2) : 0)); - params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); - gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); + { + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DRAW); + params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); + gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); + } } - + // If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha. if (current_shader && draw_glow_for_this_partition && params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE)) { - // install glow-accumulating blend mode - gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE, // don't touch color - LLRender::BF_ONE, LLRender::BF_ONE); // add to alpha (glow) - - emissive_shader->bind(); - - params.mVertexBuffer->setBuffer((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE); - - // do the actual drawing, again - params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset); - gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode); - - // restore our alpha blend mode - gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); - - current_shader->bind(); + LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_EMISSIVE); + #if BATCH_EMISSIVES + emissives.push_back(¶ms); + #else + drawEmissiveInline(mask, ¶ms); + #endif } if (tex_setup) { gGL.getTexUnit(0)->activate(); + gGL.matrixMode(LLRender::MM_TEXTURE); gGL.loadIdentity(); gGL.matrixMode(LLRender::MM_MODELVIEW); } } - } + + #if BATCH_FULLBRIGHTS + light_enabled = false; + renderFullbrights(mask, fullbrights); + #endif + + #if BATCH_EMISSIVES + light_enabled = true; + renderEmissives(mask, emissives); + #endif + + if (current_shader) + { + current_shader->bind(); + } + } } gGL.setSceneBlendType(LLRender::BT_ALPHA); diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h index d064a3a324..a069f805e8 100644 --- a/indra/newview/lldrawpoolalpha.h +++ b/indra/newview/lldrawpoolalpha.h @@ -75,6 +75,17 @@ private: LLGLSLShader* fullbright_shader; LLGLSLShader* emissive_shader; + void renderSimples(U32 mask, std::vector<LLDrawInfo*>& simples); + void renderFullbrights(U32 mask, std::vector<LLDrawInfo*>& fullbrights); + void renderMaterials(U32 mask, std::vector<LLDrawInfo*>& fullbrights); + void renderEmissives(U32 mask, std::vector<LLDrawInfo*>& emissives); + + void drawEmissive(U32 mask, LLDrawInfo* draw); + void drawEmissiveInline(U32 mask, LLDrawInfo* draw); + + bool TexSetup(LLDrawInfo* draw, bool use_shaders, bool use_material, LLGLSLShader* current_shader); + void RestoreTexSetup(bool tex_setup); + // our 'normal' alpha blend function for this pass LLRender::eBlendFactor mColorSFactor; LLRender::eBlendFactor mColorDFactor; diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index d5e86143f1..f0a0851b2e 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -144,16 +144,16 @@ LLDrawPool *LLDrawPoolAvatar::instancePool() } -S32 LLDrawPoolAvatar::getVertexShaderLevel() const +S32 LLDrawPoolAvatar::getShaderLevel() const { - return (S32) LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); + return (S32) LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); } void LLDrawPoolAvatar::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; if (sShaderLevel > 0) { @@ -304,7 +304,7 @@ void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass) void LLDrawPoolAvatar::beginPostDeferredAlpha() { sSkipOpaque = TRUE; - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; sVertexProgram = &gDeferredAvatarAlphaProgram; sRenderingSkinned = TRUE; @@ -395,7 +395,7 @@ void LLDrawPoolAvatar::endPostDeferredAlpha() gPipeline.unbindDeferredShader(*sVertexProgram); sDiffuseChannel = 0; - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; } void LLDrawPoolAvatar::renderPostDeferred(S32 pass) @@ -696,6 +696,14 @@ void LLDrawPoolAvatar::beginRigid() { //eyeballs render with the specular shader sVertexProgram->bind(); sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } } else @@ -706,7 +714,7 @@ void LLDrawPoolAvatar::beginRigid() void LLDrawPoolAvatar::endRigid() { - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; if (sVertexProgram != NULL) { sVertexProgram->unbind(); @@ -731,7 +739,7 @@ void LLDrawPoolAvatar::beginDeferredImpostor() void LLDrawPoolAvatar::endDeferredImpostor() { - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL); sVertexProgram->disableTexture(LLViewerShaderMgr::SPECULAR_MAP); sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -746,11 +754,19 @@ void LLDrawPoolAvatar::beginDeferredRigid() sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); sVertexProgram->bind(); sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } void LLDrawPoolAvatar::endDeferredRigid() { - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); sVertexProgram->unbind(); gGL.getTexUnit(0)->activate(); @@ -789,6 +805,14 @@ void LLDrawPoolAvatar::beginSkinned() sVertexProgram->bind(); sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } gGL.getTexUnit(0)->activate(); } else @@ -798,6 +822,14 @@ void LLDrawPoolAvatar::beginSkinned() // software skinning, use a basic shader for windlight. // TODO: find a better fallback method for software skinning. sVertexProgram->bind(); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } } @@ -816,7 +848,7 @@ void LLDrawPoolAvatar::endSkinned() sVertexProgram->disableTexture(LLViewerShaderMgr::BUMP_MAP); gGL.getTexUnit(0)->activate(); sVertexProgram->unbind(); - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; } else { @@ -860,6 +892,14 @@ void LLDrawPoolAvatar::beginRiggedSimple() { sDiffuseChannel = 0; sVertexProgram->bind(); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } } @@ -925,6 +965,16 @@ void LLDrawPoolAvatar::beginRiggedGlow() sVertexProgram->bind(); sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, LLPipeline::sRenderDeferred ? 2.2f : 1.1f); + + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } @@ -972,16 +1022,22 @@ void LLDrawPoolAvatar::beginRiggedFullbright() sDiffuseChannel = 0; sVertexProgram->bind(); - if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else if (LLPipeline::sRenderDeferred) { - sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } else { - sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); - - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); } } } @@ -1024,6 +1080,14 @@ void LLDrawPoolAvatar::beginRiggedShinySimple() if (sShaderLevel > 0 || gPipeline.canUseVertexShaders()) { sVertexProgram->bind(); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false); } } @@ -1074,17 +1138,32 @@ void LLDrawPoolAvatar::beginRiggedFullbrightShiny() if (sShaderLevel > 0 || gPipeline.canUseVertexShaders()) { sVertexProgram->bind(); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } LLDrawPoolBump::bindCubeMap(sVertexProgram, 2, sDiffuseChannel, cube_channel, false); - if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderingHUDs) { sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); - } - else + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else if (LLPipeline::sRenderDeferred) { - sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); sVertexProgram->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + else + { + sVertexProgram->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); } } } @@ -1106,6 +1185,14 @@ void LLDrawPoolAvatar::beginDeferredRiggedSimple() sVertexProgram = &gDeferredSkinnedDiffuseProgram; sDiffuseChannel = 0; sVertexProgram->bind(); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } void LLDrawPoolAvatar::endDeferredRiggedSimple() @@ -1119,6 +1206,14 @@ void LLDrawPoolAvatar::beginDeferredRiggedBump() { sVertexProgram = &gDeferredSkinnedBumpProgram; sVertexProgram->bind(); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); } @@ -1151,6 +1246,14 @@ void LLDrawPoolAvatar::beginDeferredRiggedMaterial(S32 pass) } sVertexProgram->bind(); + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP); specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP); sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -1178,13 +1281,21 @@ void LLDrawPoolAvatar::endDeferredRiggedMaterial(S32 pass) void LLDrawPoolAvatar::beginDeferredSkinned() { - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; sVertexProgram = &gDeferredAvatarProgram; sRenderingSkinned = TRUE; sVertexProgram->bind(); sVertexProgram->setMinimumAlpha(LLDrawPoolAvatar::sMinimumAlpha); - + if (LLPipeline::sRenderingHUDs) + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + sVertexProgram->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); gGL.getTexUnit(0)->activate(); } @@ -1197,7 +1308,7 @@ void LLDrawPoolAvatar::endDeferredSkinned() sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - sShaderLevel = mVertexShaderLevel; + sShaderLevel = mShaderLevel; gGL.getTexUnit(0)->activate(); } @@ -1888,12 +1999,24 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) if (face->mTextureMatrix && vobj->mTexAnimMode) { - gGL.matrixMode(LLRender::MM_TEXTURE); - gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix); + U32 tex_index = gGL.getCurrentTexUnitIndex(); + + if (tex_index <= 1) + { + gGL.matrixMode(LLRender::eMatrixMode(LLRender::MM_TEXTURE0 + tex_index)); + gGL.pushMatrix(); + gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix); + } + buff->setBuffer(data_mask); buff->drawRange(LLRender::TRIANGLES, start, end, count, offset); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); + + if (tex_index <= 1) + { + gGL.matrixMode(LLRender::eMatrixMode(LLRender::MM_TEXTURE0 + tex_index)); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + } } else { diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index 45b6d71110..8292279042 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -57,7 +57,7 @@ public: virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } - virtual S32 getVertexShaderLevel() const; + virtual S32 getShaderLevel() const; LLDrawPoolAvatar(); ~LLDrawPoolAvatar(); diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 7b9fd5c6c6..14069fa6c2 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -193,7 +193,7 @@ LLDrawPoolBump::LLDrawPoolBump() void LLDrawPoolBump::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } // static @@ -201,7 +201,7 @@ S32 LLDrawPoolBump::numBumpPasses() { if (gSavedSettings.getBOOL("RenderObjectBump")) { - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { if (LLPipeline::sImpostorRender) { @@ -241,7 +241,7 @@ void LLDrawPoolBump::beginRenderPass(S32 pass) beginShiny(); break; case 1: - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { beginFullbrightShiny(); } @@ -274,7 +274,7 @@ void LLDrawPoolBump::render(S32 pass) renderShiny(); break; case 1: - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { renderFullbrightShiny(); } @@ -301,7 +301,7 @@ void LLDrawPoolBump::endRenderPass(S32 pass) endShiny(); break; case 1: - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { endFullbrightShiny(); } @@ -335,12 +335,12 @@ void LLDrawPoolBump::beginShiny(bool invisible) mShiny = TRUE; sVertexMask = VERTEX_MASK_SHINY; // Second pass: environment map - if (!invisible && mVertexShaderLevel > 1) + if (!invisible && mShaderLevel > 1) { sVertexMask = VERTEX_MASK_SHINY | LLVertexBuffer::MAP_TEXCOORD0; } - if (getVertexShaderLevel() > 0) + if (getShaderLevel() > 0) { if (LLPipeline::sUnderWaterRender) { @@ -351,15 +351,23 @@ void LLDrawPoolBump::beginShiny(bool invisible) shader = &gObjectShinyProgram; } shader->bind(); + if (LLPipeline::sRenderingHUDs) + { + shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } else { shader = NULL; } - bindCubeMap(shader, mVertexShaderLevel, diffuse_channel, cube_channel, invisible); + bindCubeMap(shader, mShaderLevel, diffuse_channel, cube_channel, invisible); - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { //indexed texture rendering, channel 0 is always diffuse diffuse_channel = 0; } @@ -428,7 +436,7 @@ void LLDrawPoolBump::renderShiny(bool invisible) if( gSky.mVOSkyp->getCubeMap() ) { LLGLEnable blend_enable(GL_BLEND); - if (!invisible && mVertexShaderLevel > 1) + if (!invisible && mShaderLevel > 1) { LLRenderPass::pushBatches(LLRenderPass::PASS_SHINY, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } @@ -453,7 +461,7 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& { shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); - if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0) + if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0) { if (diffuse_channel != 0) { @@ -486,7 +494,7 @@ void LLDrawPoolBump::endShiny(bool invisible) return; } - unbindCubeMap(shader, mVertexShaderLevel, diffuse_channel, cube_channel, invisible); + unbindCubeMap(shader, mShaderLevel, diffuse_channel, cube_channel, invisible); if (shader) { shader->unbind(); @@ -534,6 +542,15 @@ void LLDrawPoolBump::beginFullbrightShiny() LLVector4(gGLModelView+8), LLVector4(gGLModelView+12)); shader->bind(); + if (LLPipeline::sRenderingHUDs) + { + shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + LLVector3 vec = LLVector3(gShinyOrigin) * mat; LLVector4 vec4(vec, gShinyOrigin.mV[3]); shader->uniform4fv(LLViewerShaderMgr::SHINY_ORIGIN, 1, vec4.mV); @@ -551,7 +568,7 @@ void LLDrawPoolBump::beginFullbrightShiny() gGL.getTexUnit(0)->activate(); } - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { //indexed texture rendering, channel 0 is always diffuse diffuse_channel = 0; } @@ -571,7 +588,7 @@ void LLDrawPoolBump::renderFullbrightShiny() { LLGLEnable blend_enable(GL_BLEND); - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { LLRenderPass::pushBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } @@ -1524,7 +1541,7 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL tex_setup = true; } - if (mShiny && mVertexShaderLevel > 1 && texture) + if (mShiny && mShaderLevel > 1 && texture) { if (params.mTexture.notNull()) { diff --git a/indra/newview/lldrawpoolground.cpp b/indra/newview/lldrawpoolground.cpp index 59c3fbf7a1..6bd2631d3b 100644 --- a/indra/newview/lldrawpoolground.cpp +++ b/indra/newview/lldrawpoolground.cpp @@ -53,7 +53,7 @@ LLDrawPool *LLDrawPoolGround::instancePool() void LLDrawPoolGround::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); } void LLDrawPoolGround::render(S32 pass) @@ -63,13 +63,9 @@ void LLDrawPoolGround::render(S32 pass) return; } - LLGLSPipelineSkyBox gls_skybox; + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - - LLGLSquashToFarClip far_clip(glh_get_current_projection()); - F32 water_height = gAgent.getRegion()->getWaterHeight(); gGL.pushMatrix(); LLVector3 origin = LLViewerCamera::getInstance()->getOrigin(); @@ -77,8 +73,6 @@ void LLDrawPoolGround::render(S32 pass) LLFace *facep = mDrawFace[0]; - gPipeline.disableLights(); - LLOverrideFaceColor col(this, gSky.mVOSkyp->getGLFogColor()); facep->renderIndexed(); diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index 63e96a93b5..05b0c1f1a9 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -42,7 +42,7 @@ LLDrawPoolMaterials::LLDrawPoolMaterials() void LLDrawPoolMaterials::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } S32 LLDrawPoolMaterials::getNumDeferredPasses() @@ -81,6 +81,15 @@ void LLDrawPoolMaterials::beginDeferredPass(S32 pass) mShader->bind(); + if (LLPipeline::sRenderingHUDs) + { + mShader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + mShader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + diffuse_channel = mShader->enableTexture(LLShaderMgr::DIFFUSE_MAP); LL_RECORD_BLOCK_TIME(FTM_RENDER_MATERIALS); @@ -194,7 +203,7 @@ void LLDrawPoolMaterials::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, tex_setup = true; } - if (mVertexShaderLevel > 1 && texture) + if (mShaderLevel > 1 && texture) { if (params.mTexture.notNull()) { diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index bd180de6c6..f653920662 100644 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -47,6 +47,14 @@ void LLDrawPoolGlow::beginPostDeferredPass(S32 pass) { gDeferredEmissiveProgram.bind(); gDeferredEmissiveProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + if (LLPipeline::sRenderingHUDs) + { + gDeferredEmissiveProgram.uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + gDeferredEmissiveProgram.uniform1i(LLShaderMgr::NO_ATMO, 0); + } } static LLTrace::BlockTimerStatHandle FTM_RENDER_GLOW_PUSH("Glow Push"); @@ -82,7 +90,7 @@ void LLDrawPoolGlow::endPostDeferredPass(S32 pass) S32 LLDrawPoolGlow::getNumPasses() { - if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0) + if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0) { return 1; } @@ -103,7 +111,7 @@ void LLDrawPoolGlow::render(S32 pass) glPolygonOffset(-1.0f, -1.0f); gGL.setSceneBlendType(LLRender::BT_ADD); - U32 shader_level = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + U32 shader_level = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); //should never get here without basic shaders enabled llassert(shader_level > 0); @@ -119,6 +127,15 @@ void LLDrawPoolGlow::render(S32 pass) shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.f); } + if (LLPipeline::sRenderingHUDs) + { + shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + LLGLDepthTest depth(GL_TRUE, GL_FALSE); gGL.setColorMask(false, true); @@ -147,7 +164,7 @@ LLDrawPoolSimple::LLDrawPoolSimple() : void LLDrawPoolSimple::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } void LLDrawPoolSimple::beginRenderPass(S32 pass) @@ -167,9 +184,18 @@ void LLDrawPoolSimple::beginRenderPass(S32 pass) simple_shader = &gObjectSimpleProgram; } - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->bind(); + + if (LLPipeline::sRenderingHUDs) + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } else { @@ -187,7 +213,7 @@ void LLDrawPoolSimple::endRenderPass(S32 pass) stop_glerror(); LLRenderPass::endRenderPass(pass); stop_glerror(); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->unbind(); } @@ -201,7 +227,7 @@ void LLDrawPoolSimple::render(S32 pass) LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE); gPipeline.enableLightsDynamic(); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX; @@ -244,7 +270,7 @@ LLDrawPoolAlphaMask::LLDrawPoolAlphaMask() : void LLDrawPoolAlphaMask::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } void LLDrawPoolAlphaMask::beginRenderPass(S32 pass) @@ -260,9 +286,18 @@ void LLDrawPoolAlphaMask::beginRenderPass(S32 pass) simple_shader = &gObjectSimpleAlphaMaskProgram; } - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->bind(); + + if (LLPipeline::sRenderingHUDs) + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } else { @@ -280,7 +315,7 @@ void LLDrawPoolAlphaMask::endRenderPass(S32 pass) stop_glerror(); LLRenderPass::endRenderPass(pass); stop_glerror(); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->unbind(); } @@ -291,11 +326,20 @@ void LLDrawPoolAlphaMask::render(S32 pass) LLGLDisable blend(GL_BLEND); LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->bind(); simple_shader->setMinimumAlpha(0.33f); + if (LLPipeline::sRenderingHUDs) + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); pushMaskBatches(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); pushMaskBatches(LLRenderPass::PASS_SPECMAP_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); @@ -317,7 +361,7 @@ LLDrawPoolFullbrightAlphaMask::LLDrawPoolFullbrightAlphaMask() : void LLDrawPoolFullbrightAlphaMask::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } void LLDrawPoolFullbrightAlphaMask::beginRenderPass(S32 pass) @@ -333,9 +377,18 @@ void LLDrawPoolFullbrightAlphaMask::beginRenderPass(S32 pass) simple_shader = &gObjectFullbrightAlphaMaskProgram; } - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->bind(); + + if (LLPipeline::sRenderingHUDs) + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } else { @@ -353,7 +406,7 @@ void LLDrawPoolFullbrightAlphaMask::endRenderPass(S32 pass) stop_glerror(); LLRenderPass::endRenderPass(pass); stop_glerror(); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->unbind(); } @@ -363,18 +416,30 @@ void LLDrawPoolFullbrightAlphaMask::render(S32 pass) { LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { if (simple_shader) { simple_shader->bind(); simple_shader->setMinimumAlpha(0.33f); - if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) - { - simple_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); - } else { - simple_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); - } + + if (LLPipeline::sRenderingHUDs) + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + simple_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + } + else + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + if (LLPipeline::sRenderDeferred) + { + simple_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } + else + { + simple_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + } + } } pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); //LLGLSLShader::bindNoShader(); @@ -397,6 +462,15 @@ void LLDrawPoolSimple::beginDeferredPass(S32 pass) { LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE_DEFERRED); gDeferredDiffuseProgram.bind(); + + if (LLPipeline::sRenderingHUDs) + { + gDeferredDiffuseProgram.uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + gDeferredDiffuseProgram.uniform1i(LLShaderMgr::NO_ATMO, 0); + } } void LLDrawPoolSimple::endDeferredPass(S32 pass) @@ -435,6 +509,16 @@ void LLDrawPoolAlphaMask::renderDeferred(S32 pass) LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK_DEFERRED); gDeferredDiffuseAlphaMaskProgram.bind(); gDeferredDiffuseAlphaMaskProgram.setMinimumAlpha(0.33f); + + if (LLPipeline::sRenderingHUDs) + { + gDeferredDiffuseAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + gDeferredDiffuseAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 0); + } + pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); gDeferredDiffuseAlphaMaskProgram.unbind(); } @@ -449,7 +533,7 @@ LLDrawPoolGrass::LLDrawPoolGrass() : void LLDrawPoolGrass::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } @@ -467,10 +551,18 @@ void LLDrawPoolGrass::beginRenderPass(S32 pass) simple_shader = &gObjectAlphaMaskNonIndexedProgram; } - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->bind(); simple_shader->setMinimumAlpha(0.5f); + if (LLPipeline::sRenderingHUDs) + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + simple_shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } } else { @@ -488,7 +580,7 @@ void LLDrawPoolGrass::endRenderPass(S32 pass) LL_RECORD_BLOCK_TIME(FTM_RENDER_GRASS); LLRenderPass::endRenderPass(pass); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { simple_shader->unbind(); } @@ -527,6 +619,16 @@ void LLDrawPoolGrass::renderDeferred(S32 pass) LL_RECORD_BLOCK_TIME(FTM_RENDER_GRASS_DEFERRED); gDeferredNonIndexedDiffuseAlphaMaskProgram.bind(); gDeferredNonIndexedDiffuseAlphaMaskProgram.setMinimumAlpha(0.5f); + + if (LLPipeline::sRenderingHUDs) + { + gDeferredNonIndexedDiffuseAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + gDeferredNonIndexedDiffuseAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 0); + } + //render grass LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask()); } @@ -541,7 +643,7 @@ LLDrawPoolFullbright::LLDrawPoolFullbright() : void LLDrawPoolFullbright::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } void LLDrawPoolFullbright::beginPostDeferredPass(S32 pass) @@ -553,6 +655,15 @@ void LLDrawPoolFullbright::beginPostDeferredPass(S32 pass) else { gDeferredFullbrightProgram.bind(); + + if (LLPipeline::sRenderingHUDs) + { + gDeferredFullbrightProgram.uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + gDeferredFullbrightProgram.uniform1i(LLShaderMgr::NO_ATMO, 0); + } } } @@ -600,7 +711,7 @@ void LLDrawPoolFullbright::endRenderPass(S32 pass) stop_glerror(); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { fullbright_shader->unbind(); } @@ -615,12 +726,21 @@ void LLDrawPoolFullbright::render(S32 pass) stop_glerror(); - if (mVertexShaderLevel > 0) + if (mShaderLevel > 0) { fullbright_shader->bind(); fullbright_shader->uniform1f(LLViewerShaderMgr::FULLBRIGHT, 1.f); fullbright_shader->uniform1f(LLViewerShaderMgr::TEXTURE_GAMMA, 1.f); + if (LLPipeline::sRenderingHUDs) + { + fullbright_shader->uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else + { + fullbright_shader->uniform1i(LLShaderMgr::NO_ATMO, 0); + } + U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX; pushBatches(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask, TRUE, TRUE); pushBatches(LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE, fullbright_mask, TRUE, TRUE); @@ -651,23 +771,32 @@ S32 LLDrawPoolFullbright::getNumPasses() void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass) { - if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) - { - gObjectFullbrightAlphaMaskProgram.bind(); + if (LLPipeline::sRenderingHUDs) + { + gObjectFullbrightAlphaMaskProgram.bind(); gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); - } - else - { - if (LLPipeline::sUnderWaterRender) + gObjectFullbrightAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 1); + } + else if (LLPipeline::sRenderDeferred) + { + if (LLPipeline::sUnderWaterRender) { gDeferredFullbrightAlphaMaskWaterProgram.bind(); gDeferredFullbrightAlphaMaskWaterProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + gDeferredFullbrightAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 1); } else { gDeferredFullbrightAlphaMaskProgram.bind(); gDeferredFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + gDeferredFullbrightAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 0); } + } + else + { + gObjectFullbrightAlphaMaskProgram.bind(); + gObjectFullbrightAlphaMaskProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + gObjectFullbrightAlphaMaskProgram.uniform1i(LLShaderMgr::NO_ATMO, 0); } } diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index bdb16abc78..516302676d 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -55,7 +55,7 @@ LLDrawPool *LLDrawPoolSky::instancePool() void LLDrawPoolSky::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); } @@ -75,7 +75,7 @@ void LLDrawPoolSky::render(S32 pass) } // don't render sky under water (background just gets cleared to fog color) - if(mVertexShaderLevel > 0 && LLPipeline::sUnderWaterRender) + if(mShaderLevel > 0 && LLPipeline::sUnderWaterRender) { return; } @@ -98,18 +98,10 @@ void LLDrawPoolSky::render(S32 pass) } - LLGLSPipelineSkyBox gls_skybox; + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - - LLGLSquashToFarClip far_clip(glh_get_current_projection()); - - LLGLEnable fog_enable( (mVertexShaderLevel < 1 && LLViewerCamera::getInstance()->cameraUnderWater()) ? GL_FOG : 0); - - gPipeline.disableLights(); + LLGLEnable fog_enable( (mShaderLevel < 1 && LLViewerCamera::getInstance()->cameraUnderWater()) ? GL_FOG : 0); - LLGLDisable clip(GL_CLIP_PLANE0); - gGL.pushMatrix(); LLVector3 origin = LLViewerCamera::getInstance()->getOrigin(); gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index b716a76543..e676b8d9f9 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -48,6 +48,7 @@ #include "pipeline.h" #include "llviewershadermgr.h" #include "llrender.h" +#include "llenvironment.h" const F32 DETAIL_SCALE = 1.f/16.f; int DebugDetailMap = 0; @@ -110,7 +111,7 @@ U32 LLDrawPoolTerrain::getVertexDataMask() void LLDrawPoolTerrain::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); sDetailMode = gSavedSettings.getS32("RenderTerrainDetail"); } @@ -123,7 +124,7 @@ void LLDrawPoolTerrain::beginRenderPass( S32 pass ) &gTerrainWaterProgram : &gTerrainProgram; - if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0) + if (mShaderLevel > 1 && sShader->mShaderLevel > 0) { sShader->bind(); } @@ -134,7 +135,7 @@ void LLDrawPoolTerrain::endRenderPass( S32 pass ) LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN); //LLFacePool::endRenderPass(pass); - if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0) { + if (mShaderLevel > 1 && sShader->mShaderLevel > 0) { sShader->unbind(); } } @@ -145,6 +146,18 @@ S32 LLDrawPoolTerrain::getDetailMode() return sDetailMode; } +void LLDrawPoolTerrain::boostTerrainDetailTextures() +{ + // Hack! Get the region that this draw pool is rendering from! + LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); + LLVLComposition *compp = regionp->getComposition(); + for (S32 i = 0; i < 4; i++) + { + compp->mDetailTextures[i]->setBoostLevel(LLGLTexture::BOOST_TERRAIN); + compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area + } +} + void LLDrawPoolTerrain::render(S32 pass) { LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN); @@ -154,14 +167,7 @@ void LLDrawPoolTerrain::render(S32 pass) return; } - // Hack! Get the region that this draw pool is rendering from! - LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); - LLVLComposition *compp = regionp->getComposition(); - for (S32 i = 0; i < 4; i++) - { - compp->mDetailTextures[i]->setBoostLevel(LLGLTexture::BOOST_TERRAIN); - compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area - } + boostTerrainDetailTextures(); LLOverrideFaceColor override(this, 1.f, 1.f, 1.f, 1.f); @@ -180,7 +186,7 @@ void LLDrawPoolTerrain::render(S32 pass) LLGLSPipeline gls; - if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0) + if (mShaderLevel > 1 && sShader->mShaderLevel > 0) { gPipeline.enableLightsDynamic(); @@ -216,7 +222,7 @@ void LLDrawPoolTerrain::beginDeferredPass(S32 pass) LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN); LLFacePool::beginRenderPass(pass); - sShader = &gDeferredTerrainProgram; + sShader = LLPipeline::sUnderWaterRender ? &gDeferredTerrainWaterProgram : &gDeferredTerrainProgram; sShader->bind(); } @@ -236,6 +242,8 @@ void LLDrawPoolTerrain::renderDeferred(S32 pass) return; } + boostTerrainDetailTextures(); + renderFullShader(); // Special-case for land ownership feedback @@ -252,6 +260,9 @@ void LLDrawPoolTerrain::beginShadowPass(S32 pass) LLFacePool::beginRenderPass(pass); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gDeferredShadowProgram.bind(); + + LLEnvironment& environment = LLEnvironment::instance(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); } void LLDrawPoolTerrain::endShadowPass(S32 pass) @@ -434,7 +445,7 @@ void LLDrawPoolTerrain::renderFullShader() void LLDrawPoolTerrain::hilightParcelOwners() { - if (mVertexShaderLevel > 1) + if (mShaderLevel > 1) { //use fullbright shader for highlighting LLGLSLShader* old_shader = sShader; sShader->unbind(); diff --git a/indra/newview/lldrawpoolterrain.h b/indra/newview/lldrawpoolterrain.h index 55f75e2644..b4ef7881a8 100644 --- a/indra/newview/lldrawpoolterrain.h +++ b/indra/newview/lldrawpoolterrain.h @@ -78,6 +78,8 @@ public: static F32 sDetailScale; // meters per texture protected: + void boostTerrainDetailTextures(); + void renderSimple(); void renderOwnership(); diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index b1f40781f7..aa8812ab9d 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -38,6 +38,7 @@ #include "llrender.h" #include "llviewercontrol.h" #include "llviewerregion.h" +#include "llenvironment.h" S32 LLDrawPoolTree::sDiffTex = 0; static LLGLSLShader* shader = NULL; @@ -57,7 +58,7 @@ LLDrawPool *LLDrawPoolTree::instancePool() void LLDrawPoolTree::prerender() { - mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); + mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); } void LLDrawPoolTree::beginRenderPass(S32 pass) @@ -138,7 +139,7 @@ void LLDrawPoolTree::endRenderPass(S32 pass) shader->unbind(); } - if (mVertexShaderLevel <= 0) + if (mShaderLevel <= 0) { gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } @@ -178,7 +179,10 @@ void LLDrawPoolTree::beginShadowPass(S32 pass) glPolygonOffset(gSavedSettings.getF32("RenderDeferredTreeShadowOffset"), gSavedSettings.getF32("RenderDeferredTreeShadowBias")); + LLEnvironment& environment = LLEnvironment::instance(); + gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); gDeferredTreeShadowProgram.setMinimumAlpha(0.5f); } diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index df06ad31e6..abda2d45fb 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -46,10 +46,9 @@ #include "llworld.h" #include "pipeline.h" #include "llviewershadermgr.h" -#include "llwaterparammanager.h" - -const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004"); -const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055"); +#include "llenvironment.h" +#include "llsettingssky.h" +#include "llsettingswater.h" static float sTime; @@ -58,42 +57,51 @@ BOOL deferred_render = FALSE; BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE; BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE; BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; -LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f); F32 LLDrawPoolWater::sWaterFogEnd = 0.f; -LLVector3 LLDrawPoolWater::sLightDir; - -LLDrawPoolWater::LLDrawPoolWater() : - LLFacePool(POOL_WATER) +LLDrawPoolWater::LLDrawPoolWater() : LLFacePool(POOL_WATER) { - mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - gGL.getTexUnit(0)->bind(mHBTex[0]) ; - mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP); - - mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - gGL.getTexUnit(0)->bind(mHBTex[1]); - mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP); +} +LLDrawPoolWater::~LLDrawPoolWater() +{ +} - mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE); - llassert(mWaterImagep); - mWaterImagep->setNoDelete(); - mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE); - llassert(mOpaqueWaterImagep); - mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL); - mWaterNormp->setNoDelete(); +void LLDrawPoolWater::setTransparentTextures(const LLUUID& transparentTextureId, const LLUUID& nextTransparentTextureId) +{ + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mWaterImagep[0] = LLViewerTextureManager::getFetchedTexture(!transparentTextureId.isNull() ? transparentTextureId : pwater->GetDefaultTransparentTextureAssetId()); + mWaterImagep[1] = LLViewerTextureManager::getFetchedTexture(!nextTransparentTextureId.isNull() ? nextTransparentTextureId : (!transparentTextureId.isNull() ? transparentTextureId : pwater->GetDefaultTransparentTextureAssetId())); + mWaterImagep[0]->addTextureStats(1024.f*1024.f); + mWaterImagep[1]->addTextureStats(1024.f*1024.f); +} - restoreGL(); +void LLDrawPoolWater::setOpaqueTexture(const LLUUID& opaqueTextureId) +{ + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(opaqueTextureId); + mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); } -LLDrawPoolWater::~LLDrawPoolWater() +void LLDrawPoolWater::setNormalMaps(const LLUUID& normalMapId, const LLUUID& nextNormalMapId) { + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mWaterNormp[0] = LLViewerTextureManager::getFetchedTexture(!normalMapId.isNull() ? normalMapId : pwater->GetDefaultWaterNormalAssetId()); + mWaterNormp[1] = LLViewerTextureManager::getFetchedTexture(!nextNormalMapId.isNull() ? nextNormalMapId : (!normalMapId.isNull() ? normalMapId : pwater->GetDefaultWaterNormalAssetId())); + mWaterNormp[0]->addTextureStats(1024.f*1024.f); + mWaterNormp[1]->addTextureStats(1024.f*1024.f); } //static void LLDrawPoolWater::restoreGL() { - + /*LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + if (pwater) + { + setTransparentTextures(pwater->getTransparentTextureID(), pwater->getNextTransparentTextureID()); + setOpaqueTexture(pwater->GetDefaultOpaqueTextureAssetId()); + setNormalMaps(pwater->getNormalMapID(), pwater->getNextNormalMapID()); + }*/ } LLDrawPool *LLDrawPoolWater::instancePool() @@ -105,14 +113,7 @@ LLDrawPool *LLDrawPoolWater::instancePool() void LLDrawPoolWater::prerender() { - mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; - - // got rid of modulation by light color since it got a little too - // green at sunset and sl-57047 (underwater turns black at 8:00) - sWaterFogColor = LLWaterParamManager::instance().getFogColor(); - sWaterFogColor.mV[3] = 0; - + mShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; } S32 LLDrawPoolWater::getNumPasses() @@ -178,7 +179,7 @@ void LLDrawPoolWater::render(S32 pass) LLGLEnable blend(GL_BLEND); - if ((mVertexShaderLevel > 0) && !sSkipScreenCopy) + if ((mShaderLevel > 0) && !sSkipScreenCopy) { shade(); return; @@ -203,10 +204,13 @@ void LLDrawPoolWater::render(S32 pass) LLGLDisable cullFace(GL_CULL_FACE); // Set up second pass first - mWaterImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(1)->activate(); gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->bind(mWaterImagep) ; + gGL.getTexUnit(1)->bind(mWaterImagep[0]) ; + + gGL.getTexUnit(2)->activate(); + gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->bind(mWaterImagep[1]) ; LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); F32 up_dot = camera_up * LLVector3::z_axis; @@ -263,6 +267,14 @@ void LLDrawPoolWater::render(S32 pass) gGL.getTexUnit(1)->activate(); gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->disable(); + + glDisable(GL_TEXTURE_GEN_S); //texture unit 1 + glDisable(GL_TEXTURE_GEN_T); //texture unit 1 + + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); + glDisable(GL_TEXTURE_GEN_S); //texture unit 1 glDisable(GL_TEXTURE_GEN_T); //texture unit 1 @@ -362,8 +374,6 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() gPipeline.disableLights(); - mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); - // Activate the texture binding and bind one // texture since all images will have the same texture gGL.getTexUnit(0)->activate(); @@ -461,97 +471,32 @@ void LLDrawPoolWater::renderReflection(LLFace* face) LLGLSNoFog noFog; - gGL.getTexUnit(0)->bind(mHBTex[dr]); + gGL.getTexUnit(0)->bind((dr == 0) ? voskyp->getSunTex() : voskyp->getMoonTex()); LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV)); face->renderIndexed(); } -void LLDrawPoolWater::shade() +void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& light_diffuse, const LLVector3& light_dir, F32 light_exp) { - if (!deferred_render) - { - gGL.setColorMask(true, true); - } + F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight(); - LLVOSky *voskyp = gSky.mVOSkyp; + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsWater::ptr_t pwater = environment.getCurrentWater(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); - if(voskyp == NULL) - { - return; - } + shader->bind(); - LLGLDisable blend(GL_BLEND); - - LLColor3 light_diffuse(0,0,0); - F32 light_exp = 0.0f; - LLVector3 light_dir; - LLColor3 light_color; - - if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) - { - light_dir = gSky.getSunDirection(); - light_dir.normVec(); - light_color = gSky.getSunDiffuseColor(); - if(gSky.mVOSkyp) { - light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); - light_diffuse.normVec(); - } - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); - light_diffuse *= light_exp + 0.25f; - } - else - { - light_dir = gSky.getMoonDirection(); - light_dir.normVec(); - light_color = gSky.getMoonDiffuseColor(); - light_diffuse = gSky.mVOSkyp->getMoon().getColorCached(); - light_diffuse.normVec(); - light_diffuse *= 0.5f; - light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); - } - - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= light_exp; - light_exp *= 256.f; - light_exp = light_exp > 32.f ? light_exp : 32.f; - - LLGLSLShader* shader; - - F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); - - if (eyedepth < 0.f && LLPipeline::sWaterReflections) - { if (deferred_render) { - shader = &gDeferredUnderWaterProgram; - } - else - { - shader = &gUnderWaterProgram; - } - } - else if (deferred_render) - { - shader = &gDeferredWaterProgram; - } - else - { - shader = &gWaterProgram; + if (shader->getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) + { + glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); + shader->uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); + } } - if (deferred_render) - { - gPipeline.bindDeferredShader(*shader); - } - else - { - shader->bind(); - } - - sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; + sTime = (F32)LLFrameTimer::getElapsedSeconds() * 0.5f; S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX); @@ -563,45 +508,49 @@ void LLDrawPoolWater::shade() } //bind normal map - S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); + S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); + S32 bumpTex2 = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP2); - LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); - - // change mWaterNormp if needed - if (mWaterNormp->getID() != param_mgr->getNormalMapID()) - { - mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); - } + LLViewerTexture* tex_a = mWaterNormp[0]; + LLViewerTexture* tex_b = mWaterNormp[1]; - mWaterNormp->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; - if (gSavedSettings.getBOOL("RenderWaterMipNormal")) - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - } - else - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT); - } + F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); - S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX); - - if (screentex > -1) - { - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); - shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, - param_mgr->getFogDensity()); - gPipeline.mWaterDis.bindTexture(0, screentex); - } - - stop_glerror(); + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + gGL.getTexUnit(bumpTex)->bind(tex_a); + gGL.getTexUnit(bumpTex2)->unbind(LLTexUnit::TT_TEXTURE); + blend_factor = 0; // only one tex provided, no blending + } + else if (tex_b && !tex_a) + { + gGL.getTexUnit(bumpTex)->bind(tex_b); + gGL.getTexUnit(bumpTex2)->unbind(LLTexUnit::TT_TEXTURE); + blend_factor = 0; // only one tex provided, no blending + } + else if (tex_b != tex_a) + { + gGL.getTexUnit(bumpTex)->bind(tex_a); + gGL.getTexUnit(bumpTex2)->bind(tex_b); + } + + shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + + shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR, 1, pwater->getWaterFogColor().mV); + + F32 fog_density = pwater->getModifiedWaterFogDensity(LLPipeline::sUnderWaterRender || (eyedepth <= 0.0f)); + + shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, fog_density); + // bind reflection texture from RenderTarget + S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX); gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis); - if (mVertexShaderLevel == 1) + if (mShaderLevel == 1) { - sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); + LLColor4 fog_color(pwater->getWaterFogColor(), 0.f); + fog_color[3] = fog_density; + shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV); } F32 screenRes[] = @@ -615,25 +564,30 @@ void LLDrawPoolWater::shade() S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP); stop_glerror(); - light_dir.normVec(); - sLightDir = light_dir; - - light_diffuse *= 6.f; - //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix); shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth); shader->uniform1f(LLShaderMgr::WATER_TIME, sTime); shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp); - shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); - shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); + if (LLEnvironment::instance().isCloudScrollPaused()) + { + static const std::array<F32, 2> zerowave{ {0.0f, 0.0f} }; + + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, zerowave.data()); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, zerowave.data()); + } + else + { + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, pwater->getWave1Dir().mV); + shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, pwater->getWave2Dir().mV); + } shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); - shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV); - shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale()); - shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset()); - shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier()); + shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, pwater->getNormalScale().mV); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, pwater->getFresnelScale()); + shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, pwater->getFresnelOffset()); + shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, pwater->getBlurMultiplier()); F32 sunAngle = llmax(0.f, light_dir.mV[2]); F32 scaledAngle = 1.f - sunAngle; @@ -641,6 +595,7 @@ void LLDrawPoolWater::shade() shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle); shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle); shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle); + shader->uniform1i(LLShaderMgr::WATER_EDGE_FACTOR, edge ? 1 : 0); LLColor4 water_color; LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); @@ -648,12 +603,12 @@ void LLDrawPoolWater::shade() if (LLViewerCamera::getInstance()->cameraUnderWater()) { water_color.setVec(1.f, 1.f, 1.f, 0.4f); - shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleBelow()); } else { water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); + shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleAbove()); } if (water_color.mV[3] > 0.9f) @@ -661,41 +616,56 @@ void LLDrawPoolWater::shade() water_color.mV[3] = 0.9f; } - { - LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0); + { LLGLDisable cullface(GL_CULL_FACE); - for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *face = *iter; - - if (voskyp->isReflFace(face)) - { - continue; - } - LLVOWater* water = (LLVOWater*) face->getViewerObject(); - gGL.getTexUnit(diffTex)->bind(face->getTexture()); + if (edge) + { + for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (face) + { + LLVOWater* water = (LLVOWater*) face->getViewerObject(); + gGL.getTexUnit(diffTex)->bind(face->getTexture()); + + if (water) + { + bool edge_patch = water->getIsEdgePatch(); + if (edge_patch) + { + //sNeedsReflectionUpdate = TRUE; + face->renderIndexed(); + } + } + } + } + } + else + { + for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++) + { + LLFace *face = *iter; + if (face) + { + LLVOWater* water = (LLVOWater*) face->getViewerObject(); + gGL.getTexUnit(diffTex)->bind(face->getTexture()); + + if (water) + { + bool edge_patch = water->getIsEdgePatch(); + if (!edge_patch) + { + sNeedsReflectionUpdate = TRUE; + sNeedsDistortionUpdate = TRUE; + face->renderIndexed(); + } + } + } + } + } + } - sNeedsReflectionUpdate = TRUE; - - if (water->getUseTexture() || !water->getIsEdgePatch()) - { - sNeedsDistortionUpdate = TRUE; - face->renderIndexed(); - } - else if (gGLManager.mHasDepthClamp || deferred_render) - { - face->renderIndexed(); - } - else - { - LLGLSquashToFarClip far_clip(glh_get_current_projection()); - face->renderIndexed(); - } - } - } - shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); shader->disableTexture(LLShaderMgr::WATER_SCREENTEX); shader->disableTexture(LLShaderMgr::BUMP_MAP); @@ -703,15 +673,118 @@ void LLDrawPoolWater::shade() shader->disableTexture(LLShaderMgr::WATER_REFTEX); shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH); - if (deferred_render) + shader->unbind(); +} + +void LLDrawPoolWater::shade() +{ + if (!deferred_render) { - gPipeline.unbindDeferredShader(*shader); + gGL.setColorMask(true, true); } - else + + LLVOSky *voskyp = gSky.mVOSkyp; + + if(voskyp == NULL) { - shader->unbind(); + return; } + LLGLDisable blend(GL_BLEND); + + LLColor3 light_diffuse(0,0,0); + F32 light_exp = 0.0f; + LLVector3 light_dir; + + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsWater::ptr_t pwater = environment.getCurrentWater(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); + + light_dir = environment.getLightDirection(); + light_dir.normalize(); + + bool sun_up = environment.getIsSunUp(); + bool moon_up = environment.getIsMoonUp(); + + if (sun_up) + { + light_diffuse += voskyp->getSun().getColorCached(); + } + // moonlight is several orders of magnitude less bright than sunlight, + // so only use this color when the moon alone is showing + else if (moon_up) + { + light_diffuse += psky->getMoonDiffuse(); + } + + light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f); + + light_diffuse.normalize(); + light_diffuse *= (light_exp + 0.25f); + + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= light_exp; + light_exp *= 256.f; + light_exp = light_exp > 32.f ? light_exp : 32.f; + + light_diffuse *= 6.f; + + LLGLSLShader* shader = nullptr; + LLGLSLShader* edge_shader = nullptr; + + F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight(); + + if (eyedepth < 0.f && LLPipeline::sWaterReflections) + { + if (deferred_render) + { + shader = &gDeferredUnderWaterProgram; + } + else + { + shader = &gUnderWaterProgram; + } + } + else if (deferred_render) + { + shader = &gDeferredWaterProgram; + edge_shader = nullptr; + } + else + { + shader = &gWaterProgram; + edge_shader = &gWaterEdgeProgram; + } + + if (mWaterNormp[0]) + { + if (gSavedSettings.getBOOL("RenderWaterMipNormal")) + { + mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + } + else + { + mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_POINT); + } + } + + if (mWaterNormp[1]) + { + if (gSavedSettings.getBOOL("RenderWaterMipNormal")) + { + mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + } + else + { + mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_POINT); + } + } + + shade2(false, shader, light_diffuse, light_dir, light_exp); + shade2(true, edge_shader ? edge_shader : shader, light_diffuse, light_dir, light_exp); + gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); if (!deferred_render) diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h index aeeba179d6..d436557e1c 100644 --- a/indra/newview/lldrawpoolwater.h +++ b/indra/newview/lldrawpoolwater.h @@ -33,22 +33,20 @@ class LLFace; class LLHeavenBody; class LLWaterSurface; +class LLGLSLShader; class LLDrawPoolWater: public LLFacePool { protected: - LLPointer<LLViewerTexture> mHBTex[2]; - LLPointer<LLViewerTexture> mWaterImagep; - LLPointer<LLViewerTexture> mOpaqueWaterImagep; - LLPointer<LLViewerTexture> mWaterNormp; + LLPointer<LLViewerTexture> mWaterImagep[2]; + LLPointer<LLViewerTexture> mWaterNormp[2]; + + LLPointer<LLViewerTexture> mOpaqueWaterImagep; public: static BOOL sSkipScreenCopy; static BOOL sNeedsReflectionUpdate; static BOOL sNeedsDistortionUpdate; - static LLVector3 sLightDir; - - static LLColor4 sWaterFogColor; static F32 sWaterFogEnd; enum @@ -82,6 +80,11 @@ public: void renderReflection(LLFace* face); void shade(); + void shade2(bool edge, LLGLSLShader* shader, const LLColor3& light_diffuse, const LLVector3& light_dir, F32 light_exp); + + void setTransparentTextures(const LLUUID& transparentTextureId, const LLUUID& nextTransparentTextureId); + void setOpaqueTexture(const LLUUID& opaqueTextureId); + void setNormalMaps(const LLUUID& normalMapId, const LLUUID& nextNormalMapId); protected: void renderOpaqueLegacyWater(); diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 309f535c39..e608f6eaf2 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -29,66 +29,38 @@ #include "lldrawpoolwlsky.h" #include "llerror.h" -#include "llgl.h" -#include "pipeline.h" -#include "llviewercamera.h" +#include "llface.h" #include "llimage.h" -#include "llwlparammanager.h" -#include "llviewershadermgr.h" +#include "llrender.h" +#include "llatmosphere.h" +#include "llenvironment.h" #include "llglslshader.h" +#include "llgl.h" + +#include "llviewerregion.h" +#include "llviewershadermgr.h" +#include "llviewercamera.h" +#include "pipeline.h" #include "llsky.h" #include "llvowlsky.h" -#include "llviewerregion.h" -#include "llface.h" -#include "llrender.h" - -LLPointer<LLViewerTexture> LLDrawPoolWLSky::sCloudNoiseTexture = NULL; -LLPointer<LLImageRaw> LLDrawPoolWLSky::sCloudNoiseRawImage = NULL; +static LLStaticHashedString sCamPosLocal("camPosLocal"); +static LLStaticHashedString sCustomAlpha("custom_alpha"); static LLGLSLShader* cloud_shader = NULL; -static LLGLSLShader* sky_shader = NULL; +static LLGLSLShader* sky_shader = NULL; +static LLGLSLShader* sun_shader = NULL; +static LLGLSLShader* moon_shader = NULL; +static float sStarTime; LLDrawPoolWLSky::LLDrawPoolWLSky(void) : LLDrawPool(POOL_WL_SKY) { - const std::string cloudNoiseFilename(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", "clouds2.tga")); - LL_INFOS() << "loading WindLight cloud noise from " << cloudNoiseFilename << LL_ENDL; - - LLPointer<LLImageFormatted> cloudNoiseFile(LLImageFormatted::createFromExtension(cloudNoiseFilename)); - - if(cloudNoiseFile.isNull()) { - LL_ERRS() << "Error: Failed to load cloud noise image " << cloudNoiseFilename << LL_ENDL; - } - - if(cloudNoiseFile->load(cloudNoiseFilename)) - { - sCloudNoiseRawImage = new LLImageRaw(); - - if(cloudNoiseFile->decode(sCloudNoiseRawImage, 0.0f)) - { - //debug use - LL_DEBUGS() << "cloud noise raw image width: " << sCloudNoiseRawImage->getWidth() << " : height: " << sCloudNoiseRawImage->getHeight() << " : components: " << - (S32)sCloudNoiseRawImage->getComponents() << " : data size: " << sCloudNoiseRawImage->getDataSize() << LL_ENDL ; - llassert_always(sCloudNoiseRawImage->getData()) ; - - sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); - } - else - { - sCloudNoiseRawImage = NULL ; - } - } - - LLWLParamManager::getInstance()->propagateParameters(); } LLDrawPoolWLSky::~LLDrawPoolWLSky() { - //LL_INFOS() << "destructing wlsky draw pool." << LL_ENDL; - sCloudNoiseTexture = NULL; - sCloudNoiseRawImage = NULL; } LLViewerTexture *LLDrawPoolWLSky::getDebugTexture() @@ -107,39 +79,70 @@ void LLDrawPoolWLSky::beginRenderPass( S32 pass ) LLPipeline::sUnderWaterRender ? &gObjectFullbrightNoColorWaterProgram : &gWLCloudProgram; + + sun_shader = + LLPipeline::sUnderWaterRender ? + &gObjectFullbrightNoColorWaterProgram : + &gWLSunProgram; + + moon_shader = + LLPipeline::sUnderWaterRender ? + &gObjectFullbrightNoColorWaterProgram : + &gWLMoonProgram; } void LLDrawPoolWLSky::endRenderPass( S32 pass ) { + sky_shader = nullptr; + cloud_shader = nullptr; + sun_shader = nullptr; + moon_shader = nullptr; } void LLDrawPoolWLSky::beginDeferredPass(S32 pass) { sky_shader = &gDeferredWLSkyProgram; cloud_shader = &gDeferredWLCloudProgram; + + sun_shader = + LLPipeline::sUnderWaterRender ? + &gObjectFullbrightNoColorWaterProgram : + &gDeferredWLSunProgram; + + moon_shader = + LLPipeline::sUnderWaterRender ? + &gObjectFullbrightNoColorWaterProgram : + &gDeferredWLMoonProgram; } void LLDrawPoolWLSky::endDeferredPass(S32 pass) { - + sky_shader = nullptr; + cloud_shader = nullptr; + sun_shader = nullptr; + moon_shader = nullptr; } -void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) const +void LLDrawPoolWLSky::renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const { - LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + gSky.mVOWLSkyp->drawFsSky(); +} - llassert_always(NULL != shader); +void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const +{ + llassert_always(NULL != shader); + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); //chop off translation - if (LLPipeline::sReflectionRender && origin.mV[2] > 256.f) + if (LLPipeline::sReflectionRender && camPosLocal.mV[2] > 256.f) { - gGL.translatef(origin.mV[0], origin.mV[1], 256.f-origin.mV[2]*0.5f); + gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], 256.f-camPosLocal.mV[2]*0.5f); } else { - gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); + gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); } @@ -151,64 +154,111 @@ void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) cons gGL.translatef(0.f,-camHeightLocal, 0.f); - // Draw WL Sky - static LLStaticHashedString sCamPosLocal("camPosLocal"); + // Draw WL Sky shader->uniform3f(sCamPosLocal, 0.f, camHeightLocal, 0.f); - gSky.mVOWLSkyp->drawDome(); + gSky.mVOWLSkyp->drawDome(); + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); } -void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const +void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const { + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) { - LLGLDisable blend(GL_BLEND); + LLGLSPipelineDepthTestSkyBox sky(true, true); - sky_shader->bind(); + sky_shader->bind(); - /// Render the skydome - renderDome(camHeightLocal, sky_shader); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLViewerTexture* rainbow_tex = gSky.mVOSkyp->getRainbowTex(); + LLViewerTexture* halo_tex = gSky.mVOSkyp->getHaloTex(); + + sky_shader->bindTexture(LLShaderMgr::RAINBOW_MAP, rainbow_tex); + sky_shader->bindTexture(LLShaderMgr::HALO_MAP, halo_tex); + + F32 moisture_level = (float)psky->getSkyMoistureLevel(); + F32 droplet_radius = (float)psky->getSkyDropletRadius(); + F32 ice_level = (float)psky->getSkyIceLevel(); + + sky_shader->uniform1f(LLShaderMgr::MOISTURE_LEVEL, moisture_level); + sky_shader->uniform1f(LLShaderMgr::DROPLET_RADIUS, droplet_radius); + sky_shader->uniform1f(LLShaderMgr::ICE_LEVEL, ice_level); + + sky_shader->uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, psky->getSunMoonGlowFactor()); + + sky_shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, psky->getIsSunUp() ? 1 : 0); + + /// Render the skydome + renderDome(origin, camHeightLocal, sky_shader); sky_shader->unbind(); - } + } +} + +void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const +{ + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) + { + LLGLSPipelineDepthTestSkyBox sky(true, false); + sky_shader->bind(); + sky_shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, 1); + sky_shader->uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, 1.0f); + renderDome(origin, camHeightLocal, sky_shader); + sky_shader->unbind(); + } } void LLDrawPoolWLSky::renderStars(void) const { - LLGLSPipelineSkyBox gls_sky; - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); + LLGLSPipelineBlendSkyBox gls_skybox(true, false); // *NOTE: have to have bound the cloud noise texture already since register // combiners blending below requires something to be bound // and we might as well only bind once. gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gPipeline.disableLights(); - // *NOTE: we divide by two here and GL_ALPHA_SCALE by two below to avoid // clamping and allow the star_alpha param to brighten the stars. - bool error; LLColor4 star_alpha(LLColor4::black); - star_alpha.mV[3] = LLWLParamManager::getInstance()->mCurParams.getFloat("star_brightness", error) / 2.f; - // If start_brightness is not set, exit - if( error ) + star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 512.f; + + // If star brightness is not set, exit + if( star_alpha.mV[3] < 0.001 ) { - LL_WARNS() << "star_brightness missing in mCurParams" << LL_ENDL; + LL_DEBUGS("SKY") << "star_brightness below threshold." << LL_ENDL; return; } - gGL.getTexUnit(0)->bind(gSky.mVOSkyp->getBloomTex()); + LLViewerTexture* tex_a = gSky.mVOSkyp->getBloomTex(); + LLViewerTexture* tex_b = gSky.mVOSkyp->getBloomTexNext(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + gGL.getTexUnit(0)->bind(tex_a); + } + else if (tex_b && !tex_a) + { + gGL.getTexUnit(0)->bind(tex_b); + } + else if (tex_b != tex_a) + { + gGL.getTexUnit(0)->bind(tex_a); + } gGL.pushMatrix(); gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); if (LLGLSLShader::sNoFixedFunction) { gCustomAlphaProgram.bind(); - static LLStaticHashedString sCustomAlpha("custom_alpha"); gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); } else @@ -220,6 +270,8 @@ void LLDrawPoolWLSky::renderStars(void) const gSky.mVOWLSkyp->drawStars(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.popMatrix(); if (LLGLSLShader::sNoFixedFunction) @@ -233,123 +285,294 @@ void LLDrawPoolWLSky::renderStars(void) const } } -void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const +void LLDrawPoolWLSky::renderStarsDeferred(void) const { - if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull()) - { - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - gGL.getTexUnit(0)->bind(sCloudNoiseTexture); + LLGLSPipelineBlendSkyBox gls_sky(true, false); - cloud_shader->bind(); + gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - /// Render the skydome - renderDome(camHeightLocal, cloud_shader); + F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 500.0f; - cloud_shader->unbind(); + // If start_brightness is not set, exit + if(star_alpha < 0.001f) + { + LL_DEBUGS("SKY") << "star_brightness below threshold." << LL_ENDL; + return; } -} -void LLDrawPoolWLSky::renderHeavenlyBodies() -{ - LLGLSPipelineSkyBox gls_skybox; - LLGLEnable blend_on(GL_BLEND); - gPipeline.disableLights(); + gDeferredStarProgram.bind(); -#if 0 // when we want to re-add a texture sun disc, here's where to do it. - LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN]; - if (gSky.mVOSkyp->getSun().getDraw() && face->getGeomCount()) - { - LLViewerTexture * tex = face->getTexture(); - gGL.getTexUnit(0)->bind(tex); - LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); - LLFacePool::LLOverrideFaceColor color_override(this, color); - face->renderIndexed(); - } -#endif + LLViewerTexture* tex_a = gSky.mVOSkyp->getBloomTex(); + LLViewerTexture* tex_b = gSky.mVOSkyp->getBloomTexNext(); - LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]; + F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + gGL.getTexUnit(0)->bind(tex_a); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b && !tex_a) + { + gGL.getTexUnit(0)->bind(tex_b); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b != tex_a) + { + gGL.getTexUnit(0)->bind(tex_a); + gGL.getTexUnit(1)->bind(tex_b); + } + + gDeferredStarProgram.uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + + if (LLPipeline::sReflectionRender) + { + star_alpha = 1.0f; + } + gDeferredStarProgram.uniform1f(sCustomAlpha, star_alpha); + + sStarTime = (F32)LLFrameTimer::getElapsedSeconds() * 0.5f; + + gDeferredStarProgram.uniform1f(LLShaderMgr::WATER_TIME, sStarTime); + + gSky.mVOWLSkyp->drawStars(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - if (gSky.mVOSkyp->getMoon().getDraw() && face->getGeomCount()) + gDeferredStarProgram.unbind(); +} + +void LLDrawPoolWLSky::renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const +{ + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) { - // *NOTE: even though we already bound this texture above for the - // stars register combiners, we bind again here for defensive reasons, - // since LLImageGL::bind detects that it's a noop, and optimizes it out. - gGL.getTexUnit(0)->bind(face->getTexture()); - LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); - F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2]; - if (a > 0.f) - { - a = a*a*4.f; - } - - color.mV[3] = llclamp(a, 0.f, 1.f); - - if (gPipeline.canUseVertexShaders()) - { - gHighlightProgram.bind(); - } + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLFacePool::LLOverrideFaceColor color_override(this, color); + LLGLSPipelineBlendSkyBox pipeline(true, true); - face->renderIndexed(); + cloudshader->bind(); + + LLPointer<LLViewerTexture> cloud_noise = gSky.mVOSkyp->getCloudNoiseTex(); + LLPointer<LLViewerTexture> cloud_noise_next = gSky.mVOSkyp->getCloudNoiseTexNext(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + F32 cloud_variance = psky ? psky->getCloudVariance() : 0.0f; + F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f; + + // if we even have sun disc textures to work with... + if (cloud_noise || cloud_noise_next) + { + if (cloud_noise && (!cloud_noise_next || (cloud_noise == cloud_noise_next))) + { + // Bind current and next sun textures + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next && !cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise_next, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next != cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, cloud_noise_next, LLTexUnit::TT_TEXTURE); + } + } + + cloudshader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + cloudshader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance); + cloudshader->uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, psky->getSunMoonGlowFactor()); + + /// Render the skydome + renderDome(camPosLocal, camHeightLocal, cloudshader); + + cloudshader->unbind(); - if (gPipeline.canUseVertexShaders()) - { - gHighlightProgram.unbind(); - } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); } } -void LLDrawPoolWLSky::renderDeferred(S32 pass) +void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const { - if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) { - return; - } - LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius(); + LLGLSPipelineBlendSkyBox pipeline(true, true); + + cloudshader->bind(); + + LLPointer<LLViewerTexture> cloud_noise = gSky.mVOSkyp->getCloudNoiseTex(); + LLPointer<LLViewerTexture> cloud_noise_next = gSky.mVOSkyp->getCloudNoiseTexNext(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + F32 cloud_variance = psky ? psky->getCloudVariance() : 0.0f; + F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f; + + // if we even have sun disc textures to work with... + if (cloud_noise || cloud_noise_next) + { + if (cloud_noise && (!cloud_noise_next || (cloud_noise == cloud_noise_next))) + { + // Bind current and next sun textures + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next && !cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise_next, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next != cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, cloud_noise_next, LLTexUnit::TT_TEXTURE); + } + } + + cloudshader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + cloudshader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance); - LLGLSNoFog disableFog; - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - LLGLDisable clip(GL_CLIP_PLANE0); + /// Render the skydome + renderDome(camPosLocal, camHeightLocal, cloudshader); - gGL.setColorMask(true, false); + cloudshader->unbind(); - LLGLSquashToFarClip far_clip(glh_get_current_projection()); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + } +} - renderSkyHaze(camHeightLocal); +void LLDrawPoolWLSky::renderHeavenlyBodies() +{ + LLGLSPipelineBlendSkyBox gls_skybox(true, false); - LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); + gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); - - gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); + LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN]; - gDeferredStarProgram.bind(); - // *NOTE: have to bind a texture here since register combiners blending in - // renderStars() requires something to be bound and we might as well only - // bind the moon's texture once. - gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture()); + F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); + bool can_use_vertex_shaders = gPipeline.canUseVertexShaders(); + bool can_use_windlight_shaders = gPipeline.canUseWindLightShaders(); - renderHeavenlyBodies(); - renderStars(); - - gDeferredStarProgram.unbind(); + if (gSky.mVOSkyp->getSun().getDraw() && face && face->getGeomCount()) + { + LLPointer<LLViewerTexture> tex_a = face->getTexture(LLRender::DIFFUSE_MAP); + LLPointer<LLViewerTexture> tex_b = face->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + // if we even have sun disc textures to work with... + if (tex_a || tex_b) + { + // if and only if we have a texture defined, render the sun disc + if (can_use_vertex_shaders && can_use_windlight_shaders) + { + sun_shader->bind(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b && !tex_a) + { + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b != tex_a) + { + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + sun_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + } + + LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); + + sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); + sun_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + + LLFacePool::LLOverrideFaceColor color_override(this, color); + face->renderIndexed(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + sun_shader->unbind(); + } + } + } - gGL.popMatrix(); + blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); - renderSkyClouds(camHeightLocal); + face = gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]; - gGL.setColorMask(true, true); - //gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + if (gSky.mVOSkyp->getMoon().getDraw() && face && face->getTexture(LLRender::DIFFUSE_MAP) && face->getGeomCount() && moon_shader) + { + LLViewerTexture* tex_a = face->getTexture(LLRender::DIFFUSE_MAP); + LLViewerTexture* tex_b = face->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP); + LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); + + if (can_use_vertex_shaders && can_use_windlight_shaders) + { + moon_shader->bind(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b && !tex_a) + { + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b != tex_a) + { + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + moon_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + } + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + F32 moon_brightness = (float)psky->getMoonBrightness(); + + moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness); + moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV); + + moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); + moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + + LLFacePool::LLOverrideFaceColor color_override(this, color); + face->renderIndexed(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + moon_shader->unbind(); + } + } + + gGL.popMatrix(); } -void LLDrawPoolWLSky::render(S32 pass) +void LLDrawPoolWLSky::renderDeferred(S32 pass) { if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) { @@ -357,34 +580,37 @@ void LLDrawPoolWLSky::render(S32 pass) } LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); - const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius(); - - LLGLSNoFog disableFog; - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - LLGLDisable clip(GL_CLIP_PLANE0); - - LLGLSquashToFarClip far_clip(glh_get_current_projection()); - - renderSkyHaze(camHeightLocal); - - LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - gGL.pushMatrix(); + const F32 camHeightLocal = LLEnvironment::instance().getCamHeight(); - gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); - - // *NOTE: have to bind a texture here since register combiners blending in - // renderStars() requires something to be bound and we might as well only - // bind the moon's texture once. - gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture()); + gGL.setColorMask(true, false); - renderHeavenlyBodies(); + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - renderStars(); - + if (gPipeline.canUseWindLightShaders()) + { + renderSkyHazeDeferred(origin, camHeightLocal); + renderStarsDeferred(); + renderHeavenlyBodies(); + renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); + } + gGL.setColorMask(true, true); +} - gGL.popMatrix(); +void LLDrawPoolWLSky::render(S32 pass) +{ + if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) + { + return; + } + LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); - renderSkyClouds(camHeightLocal); + const F32 camHeightLocal = LLEnvironment::instance().getCamHeight(); + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + + renderSkyHaze(origin, camHeightLocal); + renderStars(); + renderHeavenlyBodies(); + renderSkyClouds(origin, camHeightLocal, cloud_shader); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } @@ -411,15 +637,9 @@ void LLDrawPoolWLSky::resetDrawOrders() //static void LLDrawPoolWLSky::cleanupGL() { - sCloudNoiseTexture = NULL; } //static void LLDrawPoolWLSky::restoreGL() { - if(sCloudNoiseRawImage.notNull()) - { - sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); - } } - diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h index cd15c991ee..3acfda4eee 100644 --- a/indra/newview/lldrawpoolwlsky.h +++ b/indra/newview/lldrawpoolwlsky.h @@ -38,7 +38,8 @@ public: LLVertexBuffer::MAP_TEXCOORD0; static const U32 STAR_VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD0; - + static const U32 ADV_ATMO_SKY_VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX + | LLVertexBuffer::MAP_TEXCOORD0; LLDrawPoolWLSky(void); /*virtual*/ ~LLDrawPoolWLSky(); @@ -57,7 +58,7 @@ public: /*virtual*/ void prerender(); /*virtual*/ U32 getVertexDataMask() { return SKY_VERTEX_DATA_MASK; } /*virtual*/ BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct! - /*virtual*/ S32 getVertexShaderLevel() const { return mVertexShaderLevel; } + /*virtual*/ S32 getShaderLevel() const { return mShaderLevel; } //static LLDrawPool* createPool(const U32 type, LLViewerTexture *tex0 = NULL); @@ -70,15 +71,18 @@ public: static void cleanupGL(); static void restoreGL(); private: - void renderDome(F32 camHeightLocal, LLGLSLShader * shader) const; - void renderSkyHaze(F32 camHeightLocal) const; - void renderStars(void) const; - void renderSkyClouds(F32 camHeightLocal) const; - void renderHeavenlyBodies(); + void renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const; + void renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const; -private: - static LLPointer<LLViewerTexture> sCloudNoiseTexture; - static LLPointer<LLImageRaw> sCloudNoiseRawImage; + void renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const; + void renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const; + + void renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const; + void renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const; + + void renderStarsDeferred(void) const; + void renderStars(void) const; + void renderHeavenlyBodies(); }; #endif // LL_DRAWPOOLWLSKY_H diff --git a/indra/newview/llenvadapters.cpp b/indra/newview/llenvadapters.cpp new file mode 100644 index 0000000000..fdbcf68fa4 --- /dev/null +++ b/indra/newview/llenvadapters.cpp @@ -0,0 +1,67 @@ +/** + * @file llenvadapters.cpp + * @brief Declaration of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llenvadapters.h" + +#include "llsettingssky.h" +#include "llsettingswater.h" +//========================================================================= + +LLSkySettingsAdapter::LLSkySettingsAdapter(): + mWLGamma(1.0f, LLSettingsSky::SETTING_GAMMA), + + // Lighting + mLightnorm(LLColor4(0.f, 0.707f, -0.707f, 1.f), LLSettingsSky::SETTING_LIGHT_NORMAL), + mSunlight(LLColor4(0.5f, 0.5f, 0.5f, 1.0f), LLSettingsSky::SETTING_SUNLIGHT_COLOR, "WLSunlight"), + + mGlow(LLColor4(18.0f, 0.0f, -0.01f, 1.0f), LLSettingsSky::SETTING_GLOW), + // Clouds + mCloudColor(LLColor4(0.5f, 0.5f, 0.5f, 1.0f), LLSettingsSky::SETTING_CLOUD_COLOR, "WLCloudColor"), + mCloudMain(LLColor4(0.5f, 0.5f, 0.125f, 1.0f), LLSettingsSky::SETTING_CLOUD_POS_DENSITY1), + mCloudCoverage(0.0f, LLSettingsSky::SETTING_CLOUD_SHADOW), + mCloudDetail(LLColor4(0.0f, 0.0f, 0.0f, 1.0f), LLSettingsSky::SETTING_CLOUD_POS_DENSITY2), + mCloudScale(0.42f, LLSettingsSky::SETTING_CLOUD_SCALE) +{ + +} + +LLWatterSettingsAdapter::LLWatterSettingsAdapter(): + mFogColor(LLColor4((22.f / 255.f), (43.f / 255.f), (54.f / 255.f), (0.0f)), LLSettingsWater::SETTING_FOG_COLOR, "WaterFogColor"), + mFogDensity(4, LLSettingsWater::SETTING_FOG_DENSITY, 2), + mUnderWaterFogMod(0.25, LLSettingsWater::SETTING_FOG_MOD), + mNormalScale(LLVector3(2.f, 2.f, 2.f), LLSettingsWater::SETTING_NORMAL_SCALE), + mFresnelScale(0.5f, LLSettingsWater::SETTING_FRESNEL_SCALE), + mFresnelOffset(0.4f, LLSettingsWater::SETTING_FRESNEL_OFFSET), + mScaleAbove(0.025f, LLSettingsWater::SETTING_SCALE_ABOVE), + mScaleBelow(0.2f, LLSettingsWater::SETTING_SCALE_BELOW), + mBlurMultiplier(0.1f, LLSettingsWater::SETTING_BLUR_MULTIPILER), + mWave1Dir(LLVector2(0.5f, 0.5f), LLSettingsWater::SETTING_WAVE1_DIR), + mWave2Dir(LLVector2(0.5f, 0.5f), LLSettingsWater::SETTING_WAVE2_DIR) + +{ + +} diff --git a/indra/newview/llenvadapters.h b/indra/newview/llenvadapters.h new file mode 100644 index 0000000000..bd58db0589 --- /dev/null +++ b/indra/newview/llenvadapters.h @@ -0,0 +1,459 @@ +/** + * @file llenvadapters.h + * @brief Declaration of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_ENVADAPTERS_H +#define LL_ENVADAPTERS_H + +#include "v3math.h" +#include "v3color.h" +#include "v4math.h" +#include "llsettingsbase.h" +#include "llsettingssky.h" + +class WLColorControl +{ +public: + inline WLColorControl(LLColor4 color, const std::string& n, const std::string& slider_name = std::string()): + mColor(color), + mName(n), + mSliderName(slider_name), + mHasSliderName(false), + mIsSunOrAmbientColor(false), + mIsBlueHorizonOrDensity(false) + { + // if there's a slider name, say we have one + mHasSliderName = !mSliderName.empty(); + + // if it's the sun controller + mIsSunOrAmbientColor = (mSliderName == "WLSunlight" || mSliderName == "WLAmbient"); + mIsBlueHorizonOrDensity = (mSliderName == "WLBlueHorizon" || mSliderName == "WLBlueDensity"); + } + + inline void setColor4(const LLColor4 & val) + { + mColor = val; + } + + inline void setColor3(const LLColor3 & val) + { + mColor = val; + } + + inline LLColor4 getColor4() const + { + return mColor; + } + + inline LLColor3 getColor3(void) const + { + return vec4to3(mColor); + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, mColor); + } + + inline bool getHasSliderName() const + { + return mHasSliderName; + } + + inline std::string getSliderName() const + { + return mSliderName; + } + + inline bool getIsSunOrAmbientColor() const + { + return mIsSunOrAmbientColor; + } + + inline bool getIsBlueHorizonOrDensity() const + { + return mIsBlueHorizonOrDensity; + } + + inline F32 getRed() const + { + return mColor[0]; + } + + inline F32 getGreen() const + { + return mColor[1]; + } + + inline F32 getBlue() const + { + return mColor[2]; + } + + inline F32 getIntensity() const + { + return mColor[3]; + } + + inline void setRed(F32 red) + { + mColor[0] = red; + } + + inline void setGreen(F32 green) + { + mColor[1] = green; + } + + inline void setBlue(F32 blue) + { + mColor[2] = blue; + } + + inline void setIntensity(F32 intensity) + { + mColor[3] = intensity; + } + +private: + LLColor4 mColor; /// [3] is intensity, not alpha + std::string mName; /// name to use to dereference params + std::string mSliderName; /// name of the slider in menu + bool mHasSliderName; /// only set slider name for true color types + bool mIsSunOrAmbientColor; /// flag for if it's the sun or ambient color controller + bool mIsBlueHorizonOrDensity; /// flag for if it's the Blue Horizon or Density color controller + +}; + +// float slider control +class WLFloatControl +{ +public: + inline WLFloatControl(F32 val, const std::string& n, F32 m = 1.0f): + x(val), + mName(n), + mult(m) + { + } + + inline WLFloatControl &operator = (F32 val) + { + x = val; + return *this; + } + + inline operator F32 (void) const + { + return x; + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, x); + } + + inline F32 getMult() const + { + return mult; + } + + inline void setValue(F32 val) + { + x = val; + } + +private: + F32 x; + std::string mName; + F32 mult; +}; + +class WLXFloatControl +{ +public: + inline WLXFloatControl(F32 val, const std::string& n, F32 b): + mExp(val), + mBase(b), + mName(n) + { + } + + inline WLXFloatControl & operator = (F32 val) + { + mExp = log(val) / log(mBase); + + return *this; + } + + inline operator F32 (void) const + { + return pow(mBase, mExp); + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, pow(mBase, mExp)); + } + + inline F32 getExp() const + { + return mExp; + } + + inline void setExp(F32 val) + { + mExp = val; + } + + inline F32 getBase() const + { + return mBase; + } + + inline void setBase(F32 val) + { + mBase = val; + } + +private: + F32 mExp; + F32 mBase; + std::string mName; +}; + +class WLVect2Control +{ +public: + inline WLVect2Control(LLVector2 val, const std::string& n): + mU(val.mV[0]), + mV(val.mV[1]), + mName(n) + { + } + + inline WLVect2Control & operator = (const LLVector2 & val) + { + mU = val.mV[0]; + mV = val.mV[1]; + + return *this; + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, LLVector2(mU, mV)); + } + + inline F32 getU() const + { + return mU; + } + + inline void setU(F32 val) + { + mU = val; + } + + inline F32 getV() const + { + return mV; + } + + inline void setV(F32 val) + { + mV = val; + } + +private: + F32 mU; + F32 mV; + std::string mName; +}; + +class WLVect3Control +{ +public: + inline WLVect3Control(LLVector3 val, const std::string& n): + mX(val.mV[0]), + mY(val.mV[1]), + mZ(val.mV[2]), + mName(n) + { + } + + inline WLVect3Control & operator = (const LLVector3 & val) + { + mX = val.mV[0]; + mY = val.mV[1]; + mZ = val.mV[2]; + + return *this; + } + + inline void update(const LLSettingsBase::ptr_t &psetting) const + { + psetting->setValue(mName, LLVector3(mX, mY, mZ)); + } + + inline F32 getX() const + { + return mX; + } + + inline void setX(F32 val) + { + mX = val; + } + + inline F32 getY() const + { + return mY; + } + + inline void setY(F32 val) + { + mY = val; + } + + inline F32 getZ() const + { + return mZ; + } + + inline void setZ(F32 val) + { + mZ = val; + } + +private: + F32 mX; + F32 mY; + F32 mZ; + std::string mName; +}; + +class LLDensityProfileSettingsAdapter +{ +public: + LLDensityProfileSettingsAdapter(const std::string& config, int layerIndex = 0) + : mConfig(config) + , mLayerIndex(layerIndex) + , mLayerWidth(1.0f, LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH) + , mExpTerm(1.0f, LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM) + , mExpScale(1.0f, LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR) + , mLinTerm(1.0f, LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM) + , mConstantTerm(1.0f, LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM) + {} + +protected: + std::string mConfig; + int mLayerIndex; + WLFloatControl mLayerWidth; // 0.0 -> to top of atmosphere, however big that may be. + WLFloatControl mExpTerm; + WLFloatControl mExpScale; + WLFloatControl mLinTerm; + WLFloatControl mConstantTerm; +}; + +class LLRayleighDensityProfileSettingsAdapter : public LLDensityProfileSettingsAdapter +{ +public: + LLRayleighDensityProfileSettingsAdapter(int layerIndex = 0) + : LLDensityProfileSettingsAdapter(LLSettingsSky::SETTING_RAYLEIGH_CONFIG, layerIndex) + { + } +}; + +class LLMieDensityProfileSettingsAdapter : public LLDensityProfileSettingsAdapter +{ +public: + LLMieDensityProfileSettingsAdapter(int layerIndex = 0) + : LLDensityProfileSettingsAdapter(LLSettingsSky::SETTING_MIE_CONFIG, layerIndex) + , mAnisotropy(0.8f, LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR) + { + } + +protected: + WLFloatControl mAnisotropy; +}; + +class LLAbsorptionDensityProfileSettingsAdapter : public LLDensityProfileSettingsAdapter +{ +public: + LLAbsorptionDensityProfileSettingsAdapter(int layerIndex = 0) + : LLDensityProfileSettingsAdapter(LLSettingsSky::SETTING_ABSORPTION_CONFIG, layerIndex) + { + } +}; + +//------------------------------------------------------------------------- +class LLSkySettingsAdapter +{ +public: + typedef std::shared_ptr<LLSkySettingsAdapter> ptr_t; + + LLSkySettingsAdapter(); + + WLFloatControl mWLGamma; + + /// Lighting + WLColorControl mLightnorm; + WLColorControl mSunlight; + WLColorControl mGlow; + + /// Clouds + WLColorControl mCloudColor; + WLColorControl mCloudMain; + WLFloatControl mCloudCoverage; + WLColorControl mCloudDetail; + WLFloatControl mCloudScale; +}; + +class LLWatterSettingsAdapter +{ +public: + typedef std::shared_ptr<LLWatterSettingsAdapter> ptr_t; + + LLWatterSettingsAdapter(); + + WLColorControl mFogColor; + WLXFloatControl mFogDensity; + WLFloatControl mUnderWaterFogMod; + + /// wavelet scales and directions + WLVect3Control mNormalScale; + WLVect2Control mWave1Dir; + WLVect2Control mWave2Dir; + + // controls how water is reflected and refracted + WLFloatControl mFresnelScale; + WLFloatControl mFresnelOffset; + WLFloatControl mScaleAbove; + WLFloatControl mScaleBelow; + WLFloatControl mBlurMultiplier; + +}; + +#endif // LL_ENVIRONMENT_H diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp new file mode 100644 index 0000000000..3defe68a0e --- /dev/null +++ b/indra/newview/llenvironment.cpp @@ -0,0 +1,3162 @@ +/** + * @file llenvmanager.cpp + * @brief Implementation of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llenvironment.h" + +#include <algorithm> + +#include "llagent.h" +#include "llviewercontrol.h" // for gSavedSettings +#include "llviewerregion.h" +#include "llwlhandlers.h" +#include "lltrans.h" +#include "lltrace.h" +#include "llfasttimer.h" +#include "llviewercamera.h" +#include "pipeline.h" +#include "llsky.h" + +#include "llviewershadermgr.h" + +#include "llparcel.h" +#include "llviewerparcelmgr.h" + +#include "llsdserialize.h" +#include "lldiriterator.h" + +#include "llsettingsvo.h" +#include "llnotificationsutil.h" + +#include "llregioninfomodel.h" + +#include <boost/make_shared.hpp> + +#include "llatmosphere.h" +#include "llagent.h" +#include "roles_constants.h" +#include "llestateinfomodel.h" + +#include "lldispatcher.h" +#include "llviewergenericmessage.h" +#include "llexperiencelog.h" + +//========================================================================= +namespace +{ + const std::string KEY_ENVIRONMENT("environment"); + const std::string KEY_DAYASSET("day_asset"); + const std::string KEY_DAYCYCLE("day_cycle"); + const std::string KEY_DAYHASH("day_hash"); + const std::string KEY_DAYLENGTH("day_length"); + const std::string KEY_DAYNAME("day_name"); + const std::string KEY_DAYNAMES("day_names"); + const std::string KEY_DAYOFFSET("day_offset"); + const std::string KEY_ENVVERSION("env_version"); + const std::string KEY_ISDEFAULT("is_default"); + const std::string KEY_PARCELID("parcel_id"); + const std::string KEY_REGIONID("region_id"); + const std::string KEY_TRACKALTS("track_altitudes"); + + const std::string MESSAGE_PUSHENVIRONMENT("PushExpEnvironment"); + + const std::string ACTION_CLEARENVIRONMENT("ClearEnvironment"); + const std::string ACTION_PUSHFULLENVIRONMENT("PushFullEnvironment"); + const std::string ACTION_PUSHPARTIALENVIRONMENT("PushPartialEnvironment"); + + const std::string KEY_ASSETID("asset_id"); + const std::string KEY_TRANSITIONTIME("transition_time"); + const std::string KEY_ACTION("action"); + const std::string KEY_ACTIONDATA("action_data"); + const std::string KEY_EXPERIENCEID("public_id"); + const std::string KEY_OBJECTNAME("ObjectName"); // some of these do not conform to the '_' format. + const std::string KEY_PARCELNAME("ParcelName"); // But changing these would also alter the Experience Log requirements. + const std::string KEY_COUNT("Count"); + + const std::string LISTENER_NAME("LLEnvironmentSingleton"); + const std::string PUMP_EXPERIENCE("experience_permission"); + + //--------------------------------------------------------------------- + LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); + LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); + + LLSettingsBase::Seconds DEFAULT_UPDATE_THRESHOLD(10.0); + const LLSettingsBase::Seconds MINIMUM_SPANLENGTH(0.01f); + + //--------------------------------------------------------------------- + inline LLSettingsBase::TrackPosition get_wrapping_distance(LLSettingsBase::TrackPosition begin, LLSettingsBase::TrackPosition end) + { + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return LLSettingsBase::TrackPosition(1.0) - (begin - end); + } + + return 1.0f; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); + + if (it == collection.end()) + { // wrap around + it = collection.begin(); + } + + return it; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); + + if (it == collection.end()) + { // all keyframes are lower, take the last one. + --it; // we know the range is not empty + } + else if ((*it).first > key) + { // the keyframe we are interested in is smaller than the found. + if (it == collection.begin()) + it = collection.end(); + --it; + } + + return it; + } + + LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe) + { + return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); + } + + // Find normalized track position of given time along full length of cycle + inline LLSettingsBase::TrackPosition convert_time_to_position(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len) + { + LLSettingsBase::TrackPosition position = LLSettingsBase::TrackPosition(fmod((F64)time, (F64)len) / (F64)len); + return llclamp(position, 0.0f, 1.0f); + } + + inline LLSettingsBase::BlendFactor convert_time_to_blend_factor(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len, LLSettingsDay::CycleTrack_t &track) + { + LLSettingsBase::TrackPosition position = convert_time_to_position(time, len); + LLSettingsDay::TrackBound_t bounds(get_bounding_entries(track, position)); + + LLSettingsBase::TrackPosition spanlength(get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); + if (position < (*bounds.first).first) + position += 1.0; + + LLSettingsBase::TrackPosition start = position - (*bounds.first).first; + + return static_cast<LLSettingsBase::BlendFactor>(start / spanlength); + } + + //--------------------------------------------------------------------- + class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta + { + public: + LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, + LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset, LLSettingsBase::Seconds updateThreshold) : + LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), LLSettingsBase::Seconds(1.0)), + mDay(day), + mTrackNo(0), + mCycleLength(cyclelength), + mCycleOffset(cycleoffset) + { + setTimeDeltaThreshold(updateThreshold); + // must happen prior to getBoundingEntries call... + mTrackNo = selectTrackNumber(trackno); + + LLSettingsBase::Seconds now(getAdjustedNow()); + LLSettingsDay::TrackBound_t initial = getBoundingEntries(now); + + mInitial = (*initial.first).second; + mFinal = (*initial.second).second; + mBlendSpan = getSpanTime(initial); + + initializeTarget(now); + setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); + } + + void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition&) override + { + S32 use_trackno = selectTrackNumber(trackno); + + if (use_trackno == mTrackNo) + { // results in no change + return; + } + + LLSettingsBase::ptr_t pstartsetting = mTarget->buildDerivedClone(); + mTrackNo = use_trackno; + + LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; + LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); + + LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); + LLSettingsBase::TrackPosition targetpos = convert_time_to_position(now, mCycleLength) - (*bounds.first).first; + LLSettingsBase::TrackPosition targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); + pendsetting->blend((*bounds.second).second, blendf); + + setIgnoreTimeDeltaThreshold(true); // for the next span ignore the time delta threshold. + reset(pstartsetting, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); + } + + protected: + S32 selectTrackNumber(S32 trackno) + { + if (trackno == 0) + { // We are dealing with the water track. There is only ever one. + return trackno; + } + + for (S32 test = trackno; test != 0; --test) + { // Find the track below the requested one with data. + LLSettingsDay::CycleTrack_t &track = mDay->getCycleTrack(test); + + if (!track.empty()) + return test; + } + + return 1; + } + + LLSettingsDay::TrackBound_t getBoundingEntries(LLSettingsBase::Seconds time) + { + LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); + LLSettingsBase::TrackPosition position = convert_time_to_position(time, mCycleLength); + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); + return bounds; + } + + void initializeTarget(LLSettingsBase::Seconds time) + { + LLSettingsBase::BlendFactor blendf(convert_time_to_blend_factor(time, mCycleLength, mDay->getCycleTrack(mTrackNo))); + + blendf = llclamp(blendf, 0.0, 0.999); + setTimeSpent(LLSettingsBase::Seconds(blendf * mBlendSpan)); + + setBlendFactor(blendf); + } + + LLSettingsBase::Seconds getAdjustedNow() const + { + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); + + return (now + mCycleOffset); + } + + LLSettingsBase::Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const + { + LLSettingsBase::Seconds span = mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + if (span < MINIMUM_SPANLENGTH) // for very short spans set a minimum length. + span = MINIMUM_SPANLENGTH; + return span; + } + + private: + LLSettingsDay::ptr_t mDay; + S32 mTrackNo; + LLSettingsBase::Seconds mCycleLength; + LLSettingsBase::Seconds mCycleOffset; + + void onFinishedSpan() + { + LLSettingsBase::Seconds adjusted_now = getAdjustedNow(); + LLSettingsDay::TrackBound_t next = getBoundingEntries(adjusted_now); + LLSettingsBase::Seconds nextspan = getSpanTime(next); + + reset((*next.first).second, (*next.second).second, nextspan); + + // Recalculate (reinitialize) position. Because: + // - 'delta' from applyTimeDelta accumulates errors (probably should be fixed/changed to absolute time) + // - freezes and lag can result in reset being called too late, so we need to add missed time + // - occasional time corrections can happen + // - some transition switches can happen outside applyTimeDelta thus causing 'desync' from 'delta' (can be fixed by getting rid of delta) + initializeTarget(adjusted_now); + } + }; + + class LLEnvironmentPushDispatchHandler : public LLDispatchHandler + { + public: + virtual bool operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override + { + LLSD message; + sparam_t::const_iterator it = strings.begin(); + + if (it != strings.end()) + { + const std::string& llsdRaw = *it++; + std::istringstream llsdData(llsdRaw); + if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length())) + { + LL_WARNS() << "LLExperienceLogDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; + } + } + + message[KEY_EXPERIENCEID] = invoice; + // Object Name + if (it != strings.end()) + { + message[KEY_OBJECTNAME] = *it++; + } + + // parcel Name + if (it != strings.end()) + { + message[KEY_PARCELNAME] = *it++; + } + message[KEY_COUNT] = 1; + + LLEnvironment::instance().handleEnvironmentPush(message); + return true; + } + }; + + LLEnvironmentPushDispatchHandler environment_push_dispatch_handler; + + template<class SETTINGT> + class LLSettingsInjected : public SETTINGT + { + public: + typedef std::shared_ptr<LLSettingsInjected<SETTINGT> > ptr_t; + + LLSettingsInjected(typename SETTINGT::ptr_t source) : + SETTINGT(), + mSource(source), + mLastSourceHash(0), + mLastHash(0) + {} + + virtual ~LLSettingsInjected() {}; + + typename SETTINGT::ptr_t getSource() const { return this->mSource; } + void setSource(const typename SETTINGT::ptr_t &source) + { + if (source.get() == this) // do not set a source to itself. + return; + this->mSource = source; + this->setDirtyFlag(true); + this->mLastSourceHash = 0; + } + + virtual bool isDirty() const override { return SETTINGT::isDirty() || (this->mSource->isDirty()); } + virtual bool isVeryDirty() const override { return SETTINGT::isVeryDirty() || (this->mSource->isVeryDirty()); } + + void injectSetting(const std::string keyname, LLSD value, LLUUID experience_id, F32Seconds transition) + { + if (transition > 0.1) + { + typename Injection::ptr_t injection = std::make_shared<Injection>(transition, keyname, value, true, experience_id); + + mInjections.push_back(injection); + std::stable_sort(mInjections.begin(), mInjections.end(), [](const typename Injection::ptr_t &a, const typename Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); + } + else + { + mOverrideValues[keyname] = value; + mOverrideExps[keyname] = experience_id; + this->setDirtyFlag(true); + } + } + + void removeInjection(const std::string keyname, LLUUID experience, LLSettingsBase::Seconds transition) + { + auto it = mInjections.begin(); + while (it != mInjections.end()) + { + if ((keyname.empty() || ((*it)->mKeyName == keyname)) && + (experience.isNull() || (experience == (*it)->mExperience))) + { + if (transition != LLEnvironment::TRANSITION_INSTANT) + { + typename Injection::ptr_t injection = std::make_shared<Injection>(transition, keyname, (*it)->mLastValue, false, LLUUID::null); + mInjections.push_front(injection); // push them in at the front so we don't check them again. + } + mInjections.erase(it++); + } + else + ++it; + } + + for (auto itexp = mOverrideExps.begin(); itexp != mOverrideExps.end();) + { + if (experience.isNull() || ((*itexp).second == experience)) + { + if (transition != LLEnvironment::TRANSITION_INSTANT) + { + typename Injection::ptr_t injection = std::make_shared<Injection>(transition, (*itexp).first, mOverrideValues[(*itexp).first], false, LLUUID::null); + mInjections.push_front(injection); + } + mOverrideValues.erase((*itexp).first); + mOverrideExps.erase(itexp++); + } + else + ++itexp; + } + std::stable_sort(mInjections.begin(), mInjections.end(), [](const typename Injection::ptr_t &a, const typename Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); + } + + void removeInjections(LLUUID experience_id, LLSettingsBase::Seconds transition) + { + removeInjection(std::string(), experience_id, transition); + } + + void injectExperienceValues(LLSD values, LLUUID experience_id, typename LLSettingsBase::Seconds transition) + { + for (auto it = values.beginMap(); it != values.endMap(); ++it) + { + injectSetting((*it).first, (*it).second, experience_id, transition); + } + this->setDirtyFlag(true); + } + + void applyInjections(LLSettingsBase::Seconds delta) + { + this->mSettings = this->mSource->getSettings(); + + for (auto ito = mOverrideValues.beginMap(); ito != mOverrideValues.endMap(); ++ito) + { + this->mSettings[(*ito).first] = (*ito).second; + } + + const LLSettingsBase::stringset_t &slerps = this->getSlerpKeys(); + const LLSettingsBase::stringset_t &skips = this->getSkipInterpolateKeys(); + const LLSettingsBase::stringset_t &specials = this->getSpecialKeys(); + + typename injections_t::iterator it; + for (it = mInjections.begin(); it != mInjections.end(); ++it) + { + std::string key_name = (*it)->mKeyName; + + LLSD value = this->mSettings[key_name]; + LLSD target = (*it)->mValue; + + if ((*it)->mFirstTime) + (*it)->mFirstTime = false; + else + (*it)->mTimeRemaining -= delta; + + typename LLSettingsBase::BlendFactor mix = 1.0f - ((*it)->mTimeRemaining.value() / (*it)->mTransition.value()); + + if (mix >= 1.0) + { + if ((*it)->mBlendIn) + { + mOverrideValues[key_name] = target; + mOverrideExps[key_name] = (*it)->mExperience; + this->mSettings[key_name] = target; + } + else + { + this->mSettings.erase(key_name); + } + } + else if (specials.find(key_name) != specials.end()) + { + updateSpecial(*it, mix); + } + else if (skips.find(key_name) == skips.end()) + { + if (!(*it)->mBlendIn) + mix = 1.0 - mix; + (*it)->mLastValue = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, slerps); + this->mSettings[key_name] = (*it)->mLastValue; + } + } + + size_t hash = this->getHash(); + + if (hash != mLastHash) + { + this->setDirtyFlag(true); + mLastHash = hash; + } + + it = mInjections.begin(); + it = std::find_if(mInjections.begin(), mInjections.end(), [](const typename Injection::ptr_t &a) { return a->mTimeRemaining > 0.0f; }); + + if (it != mInjections.begin()) + { + mInjections.erase(mInjections.begin(), mInjections.end()); + } + + } + + bool hasInjections() const + { + return (!mInjections.empty() || (mOverrideValues.size() > 0)); + } + + protected: + struct Injection + { + Injection(typename LLSettingsBase::Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : + mTransition(transition), + mTimeRemaining(transition), + mKeyName(keyname), + mValue(value), + mExperience(experince), + mIndex(index), + mBlendIn(blendin), + mFirstTime(true) + {} + + typename LLSettingsBase::Seconds mTransition; + typename LLSettingsBase::Seconds mTimeRemaining; + std::string mKeyName; + LLSD mValue; + LLSD mLastValue; + LLUUID mExperience; + S32 mIndex; + bool mBlendIn; + bool mFirstTime; + + typedef std::shared_ptr<Injection> ptr_t; + }; + + + virtual void updateSettings() override + { + static LLFrameTimer timer; + + if (!this->mSource) + return; + + // clears the dirty flag on this object. Need to prevent triggering + // more calls into this updateSettings + LLSettingsBase::updateSettings(); + + resetSpecial(); + + if (this->mSource->isDirty()) + { + this->mSource->updateSettings(); + } + + typename LLSettingsBase::Seconds delta(timer.getElapsedTimeAndResetF32()); + + + SETTINGT::updateSettings(); + + if (!mInjections.empty()) + this->setDirtyFlag(true); + } + + LLSettingsBase::stringset_t getSpecialKeys() const; + void resetSpecial(); + void updateSpecial(const typename Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix); + + private: + typedef std::map<std::string, LLUUID> key_to_expid_t; + typedef std::deque<typename Injection::ptr_t> injections_t; + + size_t mLastSourceHash; + size_t mLastHash; + typename SETTINGT::ptr_t mSource; + injections_t mInjections; + LLSD mOverrideValues; + key_to_expid_t mOverrideExps; + }; + + template<> + LLSettingsBase::stringset_t LLSettingsInjected<LLSettingsVOSky>::getSpecialKeys() const + { + static LLSettingsBase::stringset_t specialSet; + + if (specialSet.empty()) + { + specialSet.insert(SETTING_BLOOM_TEXTUREID); + specialSet.insert(SETTING_RAINBOW_TEXTUREID); + specialSet.insert(SETTING_HALO_TEXTUREID); + specialSet.insert(SETTING_CLOUD_TEXTUREID); + specialSet.insert(SETTING_MOON_TEXTUREID); + specialSet.insert(SETTING_SUN_TEXTUREID); + } + return specialSet; + } + + template<> + LLSettingsBase::stringset_t LLSettingsInjected<LLSettingsVOWater>::getSpecialKeys() const + { + static stringset_t specialSet; + + if (specialSet.empty()) + { + specialSet.insert(SETTING_TRANSPARENT_TEXTURE); + specialSet.insert(SETTING_NORMAL_MAP); + } + return specialSet; + } + + template<> + void LLSettingsInjected<LLSettingsVOSky>::resetSpecial() + { + mNextSunTextureId.setNull(); + mNextMoonTextureId.setNull(); + mNextCloudTextureId.setNull(); + mNextBloomTextureId.setNull(); + mNextRainbowTextureId.setNull(); + mNextHaloTextureId.setNull(); + setBlendFactor(0.0f); + } + + template<> + void LLSettingsInjected<LLSettingsVOWater>::resetSpecial() + { + mNextNormalMapID.setNull(); + mNextTransparentTextureID.setNull(); + setBlendFactor(0.0f); + } + + template<> + void LLSettingsInjected<LLSettingsVOSky>::updateSpecial(const typename LLSettingsInjected<LLSettingsVOSky>::Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix) + { + if (injection->mKeyName == SETTING_SUN_TEXTUREID) + { + mNextSunTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_MOON_TEXTUREID) + { + mNextMoonTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_CLOUD_TEXTUREID) + { + mNextCloudTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_BLOOM_TEXTUREID) + { + mNextBloomTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_RAINBOW_TEXTUREID) + { + mNextRainbowTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_HALO_TEXTUREID) + { + mNextHaloTextureId = injection->mValue.asUUID(); + } + + // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. + if (getBlendFactor() < mix) + { + setBlendFactor(mix); + } + } + + template<> + void LLSettingsInjected<LLSettingsVOWater>::updateSpecial(const typename LLSettingsInjected<LLSettingsVOWater>::Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix) + { + if (injection->mKeyName == SETTING_NORMAL_MAP) + { + mNextNormalMapID = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_TRANSPARENT_TEXTURE) + { + mNextTransparentTextureID = injection->mValue.asUUID(); + } + + // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. + if (getBlendFactor() < mix) + { + setBlendFactor(mix); + } + } + + typedef LLSettingsInjected<LLSettingsVOSky> LLSettingsInjectedSky; + typedef LLSettingsInjected<LLSettingsVOWater> LLSettingsInjectedWater; + + //===================================================================== + class DayInjection : public LLEnvironment::DayInstance + { + friend class InjectedTransition; + + public: + typedef std::shared_ptr<DayInjection> ptr_t; + typedef std::weak_ptr<DayInjection> wptr_t; + + DayInjection(LLEnvironment::EnvSelection_t env); + virtual ~DayInjection(); + + virtual bool applyTimeDelta(const LLSettingsBase::Seconds& delta) override; + + void setInjectedDay(const LLSettingsDay::ptr_t &pday, LLUUID experience_id, LLSettingsBase::Seconds transition); + void setInjectedSky(const LLSettingsSky::ptr_t &psky, LLUUID experience_id, LLSettingsBase::Seconds transition); + void setInjectedWater(const LLSettingsWater::ptr_t &pwater, LLUUID experience_id, LLSettingsBase::Seconds transition); + + void injectSkySettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition); + void injectWaterSettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition); + + void clearInjections(LLUUID experience_id, LLSettingsBase::Seconds transition_time); + + virtual void animate() override; + + LLEnvironment::DayInstance::ptr_t getBaseDayInstance() const { return mBaseDayInstance; } + void setBaseDayInstance(const LLEnvironment::DayInstance::ptr_t &baseday); + + S32 countExperiencesActive() const { return mActiveExperiences.size(); } + + bool isOverriddenSky() const { return !mSkyExperience.isNull(); } + bool isOverriddenWater() const { return !mWaterExperience.isNull(); } + + bool hasInjections() const; + + void testExperiencesOnParcel(S32 parcel_id); + private: + static void testExperiencesOnParcelCoro(wptr_t that, S32 parcel_id); + + + void animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition); + void animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition); + + void onEnvironmentChanged(LLEnvironment::EnvSelection_t env); + void onParcelChange(); + + void checkExperience(); + + + LLEnvironment::DayInstance::ptr_t mBaseDayInstance; + + LLSettingsInjectedSky::ptr_t mInjectedSky; + LLSettingsInjectedWater::ptr_t mInjectedWater; + std::set<LLUUID> mActiveExperiences; + LLUUID mDayExperience; + LLUUID mSkyExperience; + LLUUID mWaterExperience; + LLEnvironment::connection_t mEnvChangeConnection; + boost::signals2::connection mParcelChangeConnection; + }; + + class InjectedTransition : public LLEnvironment::DayTransition + { + public: + InjectedTransition(const DayInjection::ptr_t &injection, const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, LLSettingsDay::Seconds time): + LLEnvironment::DayTransition(skystart, waterstart, end, time), + mInjection(injection) + { } + virtual ~InjectedTransition() { }; + + virtual void animate() override; + + protected: + DayInjection::ptr_t mInjection; + }; + +} + +//========================================================================= +const F32Seconds LLEnvironment::TRANSITION_INSTANT(0.0f); +const F32Seconds LLEnvironment::TRANSITION_FAST(1.0f); +const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); +const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); +const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); + +const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("01e41537-ff51-2f1f-8ef7-17e4df760bfb"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("6c83e853-e7f8-cad7-8ee6-5f31c453721c"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("084e26cd-a900-28e8-08d0-64a9de5c15e2"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("8a01b97a-cb20-c1ea-ac63-f7ea84ad0090"); + +const S32 LLEnvironment::NO_TRACK(-1); +const S32 LLEnvironment::NO_VERSION(-3); // For viewer sided change, like ENV_LOCAL. -3 since -1 and -2 are taken by parcel initial server/viewer version +const S32 LLEnvironment::VERSION_CLEANUP(-4); // for cleanups + +const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg + +//------------------------------------------------------------------------- +LLEnvironment::LLEnvironment(): + mCloudScrollDelta(), + mCloudScrollPaused(false), + mSelectedSky(), + mSelectedWater(), + mSelectedDay(), + mSelectedEnvironment(LLEnvironment::ENV_LOCAL), + mCurrentTrack(1) +{ +} + +void LLEnvironment::initSingleton() +{ + LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); + LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater(); + + mCurrentEnvironment = std::make_shared<DayInstance>(ENV_DEFAULT); + mCurrentEnvironment->setSky(p_default_sky); + mCurrentEnvironment->setWater(p_default_water); + + mEnvironments[ENV_DEFAULT] = mCurrentEnvironment; + + requestRegion(); + + gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); + + //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. + // We need to know new env version to fix this, without it we can only do full re-request + // Happens: on updates, on opening LLFloaterRegionInfo, on region crossing if info floater is open + LLRegionInfoModel::instance().setUpdateCallback([this]() { requestRegion(); }); + gAgent.addRegionChangedCallback([this]() { onRegionChange(); }); + + gAgent.whenPositionChanged([this](const LLVector3 &localpos, const LLVector3d &) { onAgentPositionHasChanged(localpos); }); + + if (!gGenericDispatcher.isHandlerPresent(MESSAGE_PUSHENVIRONMENT)) + { + gGenericDispatcher.addHandler(MESSAGE_PUSHENVIRONMENT, &environment_push_dispatch_handler); + } + + LLEventPumps::instance().obtain(PUMP_EXPERIENCE).listen(LISTENER_NAME, [this](LLSD message) { listenExperiencePump(message); return false; }); +} + +void LLEnvironment::cleanupSingleton() +{ + LLEventPumps::instance().obtain(PUMP_EXPERIENCE).stopListening(LISTENER_NAME); +} + +LLEnvironment::~LLEnvironment() +{ +} + +bool LLEnvironment::canEdit() const +{ + return true; +} + +LLSettingsSky::ptr_t LLEnvironment::getCurrentSky() const +{ + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + + if (!psky && mCurrentEnvironment->getEnvironmentSelection() >= ENV_EDIT) + { + for (int idx = 0; idx < ENV_END; ++idx) + { + if (mEnvironments[idx]->getSky()) + { + psky = mEnvironments[idx]->getSky(); + break; + } + } + } + return psky; +} + +LLSettingsWater::ptr_t LLEnvironment::getCurrentWater() const +{ + LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater(); + + if (!pwater && mCurrentEnvironment->getEnvironmentSelection() >= ENV_EDIT) + { + for (int idx = 0; idx < ENV_END; ++idx) + { + if (mEnvironments[idx]->getWater()) + { + pwater = mEnvironments[idx]->getWater(); + break; + } + } + } + return pwater; +} + +void LayerConfigToDensityLayer(const LLSD& layerConfig, DensityLayer& layerOut) +{ + layerOut.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + layerOut.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + layerOut.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + layerOut.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + layerOut.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); +} + +void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky) +{ + settingsOut.m_skyBottomRadius = psky->getSkyBottomRadius(); + settingsOut.m_skyTopRadius = psky->getSkyTopRadius(); + settingsOut.m_sunArcRadians = psky->getSunArcRadians(); + settingsOut.m_mieAnisotropy = psky->getMieAnisotropy(); + + LLSD rayleigh = psky->getRayleighConfigs(); + settingsOut.m_rayleighProfile.clear(); + for (LLSD::array_iterator itf = rayleigh.beginArray(); itf != rayleigh.endArray(); ++itf) + { + DensityLayer layer; + LLSD& layerConfig = (*itf); + LayerConfigToDensityLayer(layerConfig, layer); + settingsOut.m_rayleighProfile.push_back(layer); + } + + LLSD mie = psky->getMieConfigs(); + settingsOut.m_mieProfile.clear(); + for (LLSD::array_iterator itf = mie.beginArray(); itf != mie.endArray(); ++itf) + { + DensityLayer layer; + LLSD& layerConfig = (*itf); + LayerConfigToDensityLayer(layerConfig, layer); + settingsOut.m_mieProfile.push_back(layer); + } + settingsOut.m_mieAnisotropy = psky->getMieAnisotropy(); + + LLSD absorption = psky->getAbsorptionConfigs(); + settingsOut.m_absorptionProfile.clear(); + for (LLSD::array_iterator itf = absorption.beginArray(); itf != absorption.endArray(); ++itf) + { + DensityLayer layer; + LLSD& layerConfig = (*itf); + LayerConfigToDensityLayer(layerConfig, layer); + settingsOut.m_absorptionProfile.push_back(layer); + } +} + +bool LLEnvironment::canAgentUpdateParcelEnvironment() const +{ + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + + return canAgentUpdateParcelEnvironment(parcel); +} + + +bool LLEnvironment::canAgentUpdateParcelEnvironment(LLParcel *parcel) const +{ + if (!parcel) + return false; + + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + return false; + + if (gAgent.isGodlike()) + return true; + + if (!parcel->getRegionAllowEnvironmentOverride()) + return false; + + return LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_ALLOW_ENVIRONMENT); +} + +bool LLEnvironment::canAgentUpdateRegionEnvironment() const +{ + if (gAgent.isGodlike()) + return true; + + return gAgent.getRegion()->canManageEstate(); +} + +bool LLEnvironment::isExtendedEnvironmentEnabled() const +{ + return !gAgent.getRegionCapability("ExtEnvironment").empty(); +} + +bool LLEnvironment::isInventoryEnabled() const +{ + return (!gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty() && + !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); +} + +void LLEnvironment::onRegionChange() +{ +// if (gAgent.getRegionCapability("ExperienceQuery").empty()) +// { +// // for now environmental experiences do not survive region crossings + clearExperienceEnvironment(LLUUID::null, TRANSITION_DEFAULT); +// } + + LLViewerRegion* cur_region = gAgent.getRegion(); + if (!cur_region) + { + return; + } + if (!cur_region->capabilitiesReceived()) + { + cur_region->setCapabilitiesReceivedCallback([](LLUUID region_id) { LLEnvironment::instance().requestRegion(); }); + return; + } + requestRegion(); +} + +void LLEnvironment::onParcelChange() +{ + S32 parcel_id(INVALID_PARCEL_ID); + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (parcel) + { + parcel_id = parcel->getLocalID(); + } + + requestParcel(parcel_id); +} + +//------------------------------------------------------------------------- +F32 LLEnvironment::getCamHeight() const +{ + return (mCurrentEnvironment->getSky()->getDomeOffset() * mCurrentEnvironment->getSky()->getDomeRadius()); +} + +F32 LLEnvironment::getWaterHeight() const +{ + return gAgent.getRegion()->getWaterHeight(); +} + +bool LLEnvironment::getIsSunUp() const +{ + if (!mCurrentEnvironment || !mCurrentEnvironment->getSky()) + return false; + return mCurrentEnvironment->getSky()->getIsSunUp(); +} + +bool LLEnvironment::getIsMoonUp() const +{ + if (!mCurrentEnvironment || !mCurrentEnvironment->getSky()) + return false; + return mCurrentEnvironment->getSky()->getIsMoonUp(); +} + +//------------------------------------------------------------------------- +void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, LLSettingsBase::Seconds transition, bool forced) +{ + mSelectedEnvironment = env; + updateEnvironment(transition, forced); +} + +bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT) || (!mEnvironments[env])) + { + return false; + } + + return true; +} + +LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnvironment::EnvSelection_t env, bool create /*= false*/) +{ + DayInstance::ptr_t environment = mEnvironments[env]; + if (create) + { + if (environment) + environment = environment->clone(); + else + { + if (env == ENV_PUSH) + environment = std::make_shared<DayInjection>(env); + else + environment = std::make_shared<DayInstance>(env); + } + mEnvironments[env] = environment; + } + + return environment; +} + + +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 env_version) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + + environment->clear(); + environment->setDay(pday, daylength, dayoffset); + environment->setSkyTrack(mCurrentTrack); + environment->animate(); + + if (!mSignalEnvChanged.empty()) + mSignalEnvChanged(env, env_version); +} + + +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironment::fixedEnvironment_t fixed, S32 env_version) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + +// LLSettingsSky::ptr_t prev_sky = mEnvironments[ENV_DEFAULT]->getSky(); +// LLSettingsWater::ptr_t prev_water = mEnvironments[ENV_DEFAULT]->getWater(); +// if (mCurrentEnvironment && (ENV_EDIT == env)) +// { +// prev_sky = mCurrentEnvironment->getSky() ? mCurrentEnvironment->getSky() : prev_sky; +// prev_water = mCurrentEnvironment->getWater() ? mCurrentEnvironment->getWater() : prev_water; +// } + +// environment->clear(); +// environment->setSky((fixed.first) ? fixed.first : prev_sky); +// environment->setWater((fixed.second) ? fixed.second : prev_water); + if (fixed.first) + environment->setSky(fixed.first); + else if (!environment->getSky()) + environment->setSky(mCurrentEnvironment->getSky()); + + if (fixed.second) + environment->setWater(fixed.second); + else if (!environment->getWater()) + environment->setWater(mCurrentEnvironment->getWater()); + + + + if (!mSignalEnvChanged.empty()) + mSignalEnvChanged(env, env_version); + + /*TODO: readjust environment*/ +} + +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsBase::ptr_t &settings, S32 env_version) +{ + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (env == ENV_DEFAULT) + { + LL_WARNS("ENVIRONMENT") << "Attempt to set default environment. Not allowed." << LL_ENDL; + return; + } + + if (!settings) + { + clearEnvironment(env); + return; + } + + if (settings->getSettingsType() == "daycycle") + { + LLSettingsDay::Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + LLSettingsDay::Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + if (environment) + { + daylength = environment->getDayLength(); + dayoffset = environment->getDayOffset(); + } + setEnvironment(env, std::static_pointer_cast<LLSettingsDay>(settings), daylength, dayoffset); + } + else if (settings->getSettingsType() == "sky") + { + fixedEnvironment_t fixedenv(std::static_pointer_cast<LLSettingsSky>(settings), LLSettingsWater::ptr_t()); + setEnvironment(env, fixedenv); + } + else if (settings->getSettingsType() == "water") + { + fixedEnvironment_t fixedenv(LLSettingsSky::ptr_t(), std::static_pointer_cast<LLSettingsWater>(settings)); + setEnvironment(env, fixedenv); + } +} + +void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId, S32 env_version) +{ + setEnvironment(env, assetId, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); +} + + +void LLEnvironment::setEnvironment(EnvSelection_t env, + const LLUUID &assetId, + LLSettingsDay::Seconds daylength, + LLSettingsDay::Seconds dayoffset, + S32 env_version) +{ + LLSettingsVOBase::getSettingsAsset(assetId, + [this, env, daylength, dayoffset, env_version](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) + { + onSetEnvAssetLoaded(env, asset_id, settings, daylength, dayoffset, TRANSITION_DEFAULT, status, env_version); + }); +} + +void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, + LLUUID asset_id, + LLSettingsBase::ptr_t settings, + LLSettingsDay::Seconds daylength, + LLSettingsDay::Seconds dayoffset, + LLSettingsBase::Seconds transition, + S32 status, + S32 env_version) +{ + if (!settings || status) + { + LLSD args; + args["DESC"] = asset_id.asString(); + LLNotificationsUtil::add("FailedToFindSettings", args); + return; + } + + setEnvironment(env, settings); + updateEnvironment(transition); +} + +void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + mEnvironments[env].reset(); + + if (!mSignalEnvChanged.empty()) + mSignalEnvChanged(env, VERSION_CLEANUP); + + /*TODO: readjust environment*/ +} + +LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return environment->getDayCycle(); + + return LLSettingsDay::ptr_t(); +} + +LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return LLSettingsDay::Seconds(0); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return environment->getDayLength(); + + return LLSettingsDay::Seconds(0); +} + +LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return LLSettingsDay::Seconds(0); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + if (environment) + return environment->getDayOffset(); + + return LLSettingsDay::Seconds(0); +} + + +LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env, bool resolve) +{ + if ((env == ENV_CURRENT) || resolve) + { + fixedEnvironment_t fixed; + for (S32 idx = ((resolve) ? env : mSelectedEnvironment); idx < ENV_END; ++idx) + { + if (fixed.first && fixed.second) + break; + + if (idx == ENV_EDIT) + continue; // skip the edit environment. + + DayInstance::ptr_t environment = getEnvironmentInstance(static_cast<EnvSelection_t>(idx)); + if (environment) + { + if (!fixed.first) + fixed.first = environment->getSky(); + if (!fixed.second) + fixed.second = environment->getWater(); + } + } + + if (!fixed.first || !fixed.second) + LL_WARNS("ENVIRONMENT") << "Can not construct complete fixed environment. Missing Sky and/or Water." << LL_ENDL; + + return fixed; + } + + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return fixedEnvironment_t(); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return fixedEnvironment_t(environment->getSky(), environment->getWater()); + + return fixedEnvironment_t(); +} + +LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance() +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_DEFAULT; ++idx) + { + if (mEnvironments[idx]) + return mEnvironments[idx]; + } + + return mEnvironments[ENV_DEFAULT]; +} + +LLEnvironment::DayInstance::ptr_t LLEnvironment::getSharedEnvironmentInstance() +{ + for (S32 idx = ENV_PARCEL; idx < ENV_DEFAULT; ++idx) + { + if (mEnvironments[idx]) + return mEnvironments[idx]; + } + + return mEnvironments[ENV_DEFAULT]; +} + +void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool forced) +{ + DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); + + if ((mCurrentEnvironment != pinstance) || forced) + { + if (transition != TRANSITION_INSTANT) + { + DayInstance::ptr_t trans = std::make_shared<DayTransition>( + mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition); + + trans->animate(); + + mCurrentEnvironment = trans; + } + else + { + mCurrentEnvironment = pinstance; + } + } +} + +LLVector4 LLEnvironment::toCFR(const LLVector3 vec) const +{ + LLVector4 vec_cfr(vec.mV[1], vec.mV[0], vec.mV[2], 0.0f); + return vec_cfr; +} + +LLVector4 LLEnvironment::toLightNorm(const LLVector3 vec) const +{ + LLVector4 vec_ogl(vec.mV[1], vec.mV[2], vec.mV[0], 0.0f); + return vec_ogl; +} + +LLVector3 LLEnvironment::getLightDirection() const +{ + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, 1); + } + return psky->getLightDirection(); +} + +LLVector3 LLEnvironment::getSunDirection() const +{ + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, 1); + } + return psky->getSunDirection(); +} + +LLVector3 LLEnvironment::getMoonDirection() const +{ + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, -1); + } + return psky->getMoonDirection(); +} + +LLVector4 LLEnvironment::getLightDirectionCFR() const +{ + LLVector3 light_direction = getLightDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + +LLVector4 LLEnvironment::getSunDirectionCFR() const +{ + LLVector3 light_direction = getSunDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + +LLVector4 LLEnvironment::getMoonDirectionCFR() const +{ + LLVector3 light_direction = getMoonDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + +LLVector4 LLEnvironment::getClampedLightNorm() const +{ + LLVector3 light_direction = getLightDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + +LLVector4 LLEnvironment::getClampedSunNorm() const +{ + LLVector3 light_direction = getSunDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + +LLVector4 LLEnvironment::getClampedMoonNorm() const +{ + LLVector3 light_direction = getMoonDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + +LLVector4 LLEnvironment::getRotatedLightNorm() const +{ + LLVector3 light_direction = getLightDirection(); + light_direction *= LLQuaternion(-mLastCamYaw, LLVector3(0.f, 1.f, 0.f)); + return toLightNorm(light_direction); +} + +//------------------------------------------------------------------------- +void LLEnvironment::update(const LLViewerCamera * cam) +{ + LL_RECORD_BLOCK_TIME(FTM_ENVIRONMENT_UPDATE); + //F32Seconds now(LLDate::now().secondsSinceEpoch()); + static LLFrameTimer timer; + + F32Seconds delta(timer.getElapsedTimeAndResetF32()); + + { + DayInstance::ptr_t keeper = mCurrentEnvironment; + // make sure the current environment does not go away until applyTimeDelta is done. + mCurrentEnvironment->applyTimeDelta(delta); + + } + // update clouds, sun, and general + updateCloudScroll(); + + // cache this for use in rotating the rotated light vec for shader param updates later... + mLastCamYaw = cam->getYaw() + SUN_DELTA_YAW; + + stop_glerror(); + + // *TODO: potential optimization - this block may only need to be + // executed some of the time. For example for water shaders only. + { + LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; + end_shaders = LLViewerShaderMgr::instance()->endShaders(); + for (shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) + { + if ((shaders_iter->mProgramObject != 0) + && (gPipeline.canUseWindLightShaders() + || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) + { + shaders_iter->mUniformsDirty = TRUE; + } + } + } +} + +void LLEnvironment::updateCloudScroll() +{ + // This is a function of the environment rather than the sky, since it should + // persist through sky transitions. + static LLTimer s_cloud_timer; + + F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); + + if (mCurrentEnvironment->getSky() && !mCloudScrollPaused) + { + LLVector2 cloud_delta = static_cast<F32>(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate()) / 100.0; + mCloudScrollDelta += cloud_delta; + } + +} + +// static +void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting) +{ + LL_RECORD_BLOCK_TIME(FTM_SHADER_PARAM_UPDATE); + + //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + LLSettingsBase::parammapping_t params = psetting->getParameterMap(); + for (auto &it: params) + { + LLSD value; + // legacy first since it contains ambient color and we prioritize value from legacy, see getAmbientColor() + if (psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first)) + { + value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first]; + } + else if (psetting->mSettings.has(it.first)) + { + value = psetting->mSettings[it.first]; + } + else + { + // We need to reset shaders, use defaults + value = it.second.getDefaultValue(); + } + + LLSD::Type setting_type = value.type(); + stop_glerror(); + switch (setting_type) + { + case LLSD::TypeInteger: + shader->uniform1i(it.second.getShaderKey(), value.asInteger()); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + case LLSD::TypeReal: + shader->uniform1f(it.second.getShaderKey(), value.asReal()); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + + case LLSD::TypeBoolean: + shader->uniform1i(it.second.getShaderKey(), value.asBoolean() ? 1 : 0); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + + case LLSD::TypeArray: + { + LLVector4 vect4(value); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; + shader->uniform4fv(it.second.getShaderKey(), 1, vect4.mV); + break; + } + + // case LLSD::TypeMap: + // case LLSD::TypeString: + // case LLSD::TypeUUID: + // case LLSD::TypeURI: + // case LLSD::TypeBinary: + // case LLSD::TypeDate: + default: + break; + } + stop_glerror(); + } + //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + + psetting->applySpecial(shader); + + if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); + } + else + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); + } + +} + +void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) +{ + if (gPipeline.canUseWindLightShaders()) + { + updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater()); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); + } +} + +void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo, LLSettingsBase::Seconds transition) +{ + if (envinfo->mParcelId == INVALID_PARCEL_ID) + { + // the returned info applies to an entire region. + if (!envinfo->mDayCycle) + { + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, envinfo->mEnvVersion); + updateEnvironment(); + } + else if (envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_WATER) + || envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL)) + { + LL_WARNS("ENVIRONMENT") << "Invalid day cycle for region" << LL_ENDL; + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, envinfo->mEnvVersion); + updateEnvironment(); + } + else + { + setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset, envinfo->mEnvVersion); + mTrackAltitudes = envinfo->mAltitudes; + } + + LL_DEBUGS("ENVIRONMENT") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; + } + else + { + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); + LL_DEBUGS("ENVIRONMENT") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL; + if (parcel && (parcel->getLocalID() != parcel_id)) + { + LL_DEBUGS("ENVIRONMENT") << "Requested parcel #" << parcel_id << " agent is on " << parcel->getLocalID() << LL_ENDL; + return; + } + + if (!envinfo->mDayCycle) + { + LL_DEBUGS("ENVIRONMENT") << "Clearing environment on parcel #" << parcel_id << LL_ENDL; + clearEnvironment(ENV_PARCEL); + } + else if (envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_WATER) + || envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL)) + { + LL_WARNS("ENVIRONMENT") << "Invalid day cycle for parcel #" << parcel_id << LL_ENDL; + clearEnvironment(ENV_PARCEL); + } + else + { + setEnvironment(ENV_PARCEL, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset, envinfo->mEnvVersion); + } + } + + updateEnvironment(transition); +} + +void LLEnvironment::adjustRegionOffset(F32 adjust) +{ + if (isExtendedEnvironmentEnabled()) + { + LL_WARNS("ENVIRONMENT") << "Attempt to adjust region offset on EEP region. Legacy regions only." << LL_ENDL; + } + + if (mEnvironments[ENV_REGION]) + { + F32 day_length = mEnvironments[ENV_REGION]->getDayLength(); + F32 day_offset = mEnvironments[ENV_REGION]->getDayOffset(); + + F32 day_adjustment = adjust * day_length; + + day_offset += day_adjustment; + if (day_offset < 0.0f) + day_offset = day_length + day_offset; + mEnvironments[ENV_REGION]->setDayOffset(LLSettingsBase::Seconds(day_offset)); + } +} + +//========================================================================= +void LLEnvironment::requestRegion(environment_apply_fn cb) +{ + requestParcel(INVALID_PARCEL_ID, cb); +} + +void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, altitudes, cb); +} + +void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + if (!isExtendedEnvironmentEnabled()) + { + LL_WARNS("ENVIRONMENT") << "attempt to apply asset id to region not supporting it." << LL_ENDL; + LLNotificationsUtil::add("NoEnvironmentSettings"); + return; + } + + updateParcel(INVALID_PARCEL_ID, asset_id, display_name, track_num, day_length, day_offset, altitudes, cb); +} + +void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset, altitudes, cb); +} + +void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset, altitudes, cb); +} + + +void LLEnvironment::resetRegion(environment_apply_fn cb) +{ + resetParcel(INVALID_PARCEL_ID, cb); +} + +void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) +{ + if (!isExtendedEnvironmentEnabled()) + { /*TODO: When EEP is live on the entire grid, this can go away. */ + if (parcel_id == INVALID_PARCEL_ID) + { + if (!cb) + { + LLSettingsBase::Seconds transition = LLViewerParcelMgr::getInstance()->getTeleportInProgress() ? TRANSITION_FAST : TRANSITION_DEFAULT; + cb = [this, transition](S32 pid, EnvironmentInfo::ptr_t envinfo) + { + clearEnvironment(ENV_PARCEL); + recordEnvironment(pid, envinfo, transition); + }; + } + + LLEnvironmentRequest::initiate(cb); + } + else if (cb) + cb(parcel_id, EnvironmentInfo::ptr_t()); + return; + } + + if (!cb) + { + LLSettingsBase::Seconds transition = LLViewerParcelMgr::getInstance()->getTeleportInProgress() ? TRANSITION_FAST : TRANSITION_DEFAULT; + cb = [this, transition](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo, transition); }; + } + + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", + [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); +} + +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + UpdateInfo::ptr_t updates(std::make_shared<UpdateInfo>(asset_id, display_name, day_length, day_offset, altitudes)); + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + [this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); }); +} + +void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes) +{ + if (status) + { + LL_WARNS("ENVIRONMENT") << "Unable to get settings asset with id " << asset_id << "!" << LL_ENDL; + LLNotificationsUtil::add("FailedToLoadSettingsApply"); + return; + } + + LLSettingsDay::ptr_t pday; + + if (settings->getSettingsType() == "daycycle") + pday = std::static_pointer_cast<LLSettingsDay>(settings); + else + { + pday = createDayCycleFromEnvironment( (parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, settings); + } + + if (!pday) + { + LL_WARNS("ENVIRONMENT") << "Unable to construct day around " << asset_id << "!" << LL_ENDL; + LLNotificationsUtil::add("FailedToBuildSettingsDay"); + return; + } + + updateParcel(parcel_id, pday, day_length, day_offset, altitudes); +} + +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); + updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb); +} + +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); + updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb); +} + +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + UpdateInfo::ptr_t updates(std::make_shared<UpdateInfo>(pday, day_length, day_offset, altitudes)); + + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + [this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); }); +} + +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + updateParcel(parcel_id, pday, NO_TRACK, day_length, day_offset, altitudes, cb); +} + + + +void LLEnvironment::resetParcel(S32 parcel_id, environment_apply_fn cb) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", + [this, parcel_id, cb]() { coroResetEnvironment(parcel_id, NO_TRACK, cb); }); +} + +void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + LL_DEBUGS("ENVIRONMENT") << "Requesting for parcel_id=" << parcel_id << LL_ENDL; + + if (parcel_id != INVALID_PARCEL_ID) + { + std::stringstream query; + + query << "?parcelid=" << parcel_id; + url += query.str(); + } + + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("ENVIRONMENT") << "Couldn't retrieve environment settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; + } + else + { + LLSD environment = result[KEY_ENVIRONMENT]; + if (environment.isDefined() && apply) + { + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); + } + } + +} + +void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInfo::ptr_t updates, environment_apply_fn apply) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + LLSD body(LLSD::emptyMap()); + body[KEY_ENVIRONMENT] = LLSD::emptyMap(); + + if (track_no == NO_TRACK) + { // day length and offset are only applicable if we are addressing the entire day cycle. + if (updates->mDayLength > 0) + body[KEY_ENVIRONMENT][KEY_DAYLENGTH] = updates->mDayLength; + if (updates->mDayOffset > 0) + body[KEY_ENVIRONMENT][KEY_DAYOFFSET] = updates->mDayOffset; + + if ((parcel_id == INVALID_PARCEL_ID) && (updates->mAltitudes.size() == 3)) + { // only test for altitude changes if we are changing the region. + body[KEY_ENVIRONMENT][KEY_TRACKALTS] = LLSD::emptyArray(); + for (S32 i = 0; i < 3; ++i) + { + body[KEY_ENVIRONMENT][KEY_TRACKALTS][i] = updates->mAltitudes[i]; + } + } + } + + if (updates->mDayp) + body[KEY_ENVIRONMENT][KEY_DAYCYCLE] = updates->mDayp->getSettings(); + else if (!updates->mSettingsAsset.isNull()) + { + body[KEY_ENVIRONMENT][KEY_DAYASSET] = updates->mSettingsAsset; + if (!updates->mDayName.empty()) + body[KEY_ENVIRONMENT][KEY_DAYNAME] = updates->mDayName; + } + + //_WARNS("ENVIRONMENT") << "Body = " << body << LL_ENDL; + + if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) + { + std::stringstream query; + query << "?"; + + if (parcel_id != INVALID_PARCEL_ID) + { + query << "parcelid=" << parcel_id; + + if (track_no != NO_TRACK) + query << "&"; + } + if (track_no != NO_TRACK) + { + query << "trackno=" << track_no; + } + url += query.str(); + } + + LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if ((!status) || !result["success"].asBoolean()) + { + LL_WARNS("ENVIRONMENT") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; + + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = result["message"].asString(); + } + else + { + LLSD environment = result[KEY_ENVIRONMENT]; + if (environment.isDefined() && apply) + { + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } +} + +void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environment_apply_fn apply) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) + { + std::stringstream query; + query << "?"; + + if (parcel_id != INVALID_PARCEL_ID) + { + query << "parcelid=" << parcel_id; + + if (track_no != NO_TRACK) + query << "&"; + } + if (track_no != NO_TRACK) + { + query << "trackno=" << track_no; + } + url += query.str(); + } + + LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if ((!status) || !result["success"].asBoolean()) + { + LL_WARNS("ENVIRONMENT") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; + + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = result["message"].asString(); + } + else + { + LLSD environment = result[KEY_ENVIRONMENT]; + if (environment.isDefined() && apply) + { + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } + +} + + +//========================================================================= + +LLEnvironment::EnvironmentInfo::EnvironmentInfo(): + mParcelId(INVALID_PARCEL_ID), + mRegionId(), + mDayLength(0), + mDayOffset(0), + mDayHash(0), + mDayCycle(), + mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), + mIsDefault(false), + mIsLegacy(false), + mDayCycleName(), + mNameList(), + mEnvVersion(INVALID_PARCEL_ENVIRONMENT_VERSION) +{ +} + +LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LLSD environment) +{ + ptr_t pinfo = std::make_shared<EnvironmentInfo>(); + + pinfo->mIsDefault = environment.has(KEY_ISDEFAULT) ? environment[KEY_ISDEFAULT].asBoolean() : true; + pinfo->mParcelId = environment.has(KEY_PARCELID) ? environment[KEY_PARCELID].asInteger() : INVALID_PARCEL_ID; + pinfo->mRegionId = environment.has(KEY_REGIONID) ? environment[KEY_REGIONID].asUUID() : LLUUID::null; + pinfo->mIsLegacy = false; + + if (environment.has(KEY_TRACKALTS)) + { + for (int idx = 0; idx < 3; idx++) + { + pinfo->mAltitudes[idx+1] = environment[KEY_TRACKALTS][idx].asReal(); + } + pinfo->mAltitudes[0] = 0; + } + + if (environment.has(KEY_DAYCYCLE)) + { + pinfo->mDayCycle = LLSettingsVODay::buildFromEnvironmentMessage(environment[KEY_DAYCYCLE]); + pinfo->mDayLength = LLSettingsDay::Seconds(environment.has(KEY_DAYLENGTH) ? environment[KEY_DAYLENGTH].asInteger() : -1); + pinfo->mDayOffset = LLSettingsDay::Seconds(environment.has(KEY_DAYOFFSET) ? environment[KEY_DAYOFFSET].asInteger() : -1); + pinfo->mDayHash = environment.has(KEY_DAYHASH) ? environment[KEY_DAYHASH].asInteger() : 0; + } + else + { + pinfo->mDayLength = LLEnvironment::instance().getEnvironmentDayLength(ENV_REGION); + pinfo->mDayOffset = LLEnvironment::instance().getEnvironmentDayOffset(ENV_REGION); + } + + if (environment.has(KEY_DAYASSET)) + { + pinfo->mAssetId = environment[KEY_DAYASSET].asUUID(); + } + + if (environment.has(KEY_DAYNAMES)) + { + LLSD daynames = environment[KEY_DAYNAMES]; + if (daynames.isArray()) + { + pinfo->mDayCycleName.clear(); + for (S32 index = 0; index < pinfo->mNameList.size(); ++index) + { + pinfo->mNameList[index] = daynames[index].asString(); + } + } + else if (daynames.isString()) + { + for (std::string &name: pinfo->mNameList) + { + name.clear(); + } + + pinfo->mDayCycleName = daynames.asString(); + } + } + else if (pinfo->mDayCycle) + { + pinfo->mDayCycleName = pinfo->mDayCycle->getName(); + } + + + if (environment.has(KEY_ENVVERSION)) + { + LLSD version = environment[KEY_ENVVERSION]; + pinfo->mEnvVersion = version.asInteger(); + } + else + { + // can be used for region, but versions should be same + pinfo->mEnvVersion = pinfo->mIsDefault ? UNSET_PARCEL_ENVIRONMENT_VERSION : INVALID_PARCEL_ENVIRONMENT_VERSION; + } + + return pinfo; +} + + +LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extractLegacy(LLSD legacy) +{ + if (!legacy.isArray() || !legacy[0].has("regionID")) + { + LL_WARNS("ENVIRONMENT") << "Invalid legacy settings for environment: " << legacy << LL_ENDL; + return ptr_t(); + } + + ptr_t pinfo = std::make_shared<EnvironmentInfo>(); + + pinfo->mIsDefault = false; + pinfo->mParcelId = INVALID_PARCEL_ID; + pinfo->mRegionId = legacy[0]["regionID"].asUUID(); + pinfo->mIsLegacy = true; + + pinfo->mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; + pinfo->mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; + pinfo->mDayCycle = LLSettingsVODay::buildFromLegacyMessage(pinfo->mRegionId, legacy[1], legacy[2], legacy[3]); + if (pinfo->mDayCycle) + pinfo->mDayHash = pinfo->mDayCycle->getHash(); + + pinfo->mAltitudes[0] = 0; + pinfo->mAltitudes[2] = 10001; + pinfo->mAltitudes[3] = 10002; + pinfo->mAltitudes[4] = 10003; + + return pinfo; +} + +//========================================================================= +LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename, LLSD &messages) +{ + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string path(gDirUtilp->getDirName(filename)); + + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPresetFile(name, path, messages); + + if (!water) + { + messages["NAME"] = name; + messages["FILE"] = filename; + } + return water; +} + +LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename, LLSD &messages) +{ + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string path(gDirUtilp->getDirName(filename)); + + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPresetFile(name, path, messages); + if (!sky) + { + messages["NAME"] = name; + messages["FILE"] = filename; + } + return sky; +} + +LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename, LLSD &messages) +{ + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string path(gDirUtilp->getDirName(filename)); + + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPresetFile(name, path, messages); + if (!day) + { + messages["NAME"] = name; + messages["FILE"] = filename; + } + return day; +} + +LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromEnvironment(EnvSelection_t env, LLSettingsBase::ptr_t settings) +{ + std::string type(settings->getSettingsType()); + + if (type == "daycycle") + return std::static_pointer_cast<LLSettingsDay>(settings); + + if ((env != ENV_PARCEL) && (env != ENV_REGION)) + { + LL_WARNS("ENVIRONMENT") << "May only create from parcel or region environment." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t day = this->getEnvironmentDay(env); + if (!day && (env == ENV_PARCEL)) + { + day = this->getEnvironmentDay(ENV_REGION); + } + + if (!day) + { + LL_WARNS("ENVIRONMENT") << "Could not retrieve existing day settings." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + day = day->buildClone(); + + if (type == "sky") + { + for (S32 idx = 1; idx < LLSettingsDay::TRACK_MAX; ++idx) + day->clearCycleTrack(idx); + day->setSettingsAtKeyframe(settings, 0.0f, 1); + } + else if (type == "water") + { + day->clearCycleTrack(LLSettingsDay::TRACK_WATER); + day->setSettingsAtKeyframe(settings, 0.0f, LLSettingsDay::TRACK_WATER); + } + + return day; +} + +void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) +{ + S32 trackno = calculateSkyTrackForAltitude(localpos.mV[VZ]); + if (trackno == mCurrentTrack) + return; + + mCurrentTrack = trackno; + for (S32 env = ENV_LOCAL; env < ENV_DEFAULT; ++env) + { + if (mEnvironments[env]) + mEnvironments[env]->setSkyTrack(mCurrentTrack); + } +} + +S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) +{ + auto it = std::find_if_not(mTrackAltitudes.begin(), mTrackAltitudes.end(), [altitude](F32 test) { return altitude > test; }); + + if (it == mTrackAltitudes.begin()) + return 1; + else if (it == mTrackAltitudes.end()) + return 4; + + return std::min(static_cast<S32>(std::distance(mTrackAltitudes.begin(), it)), 4); +} + +//------------------------------------------------------------------------- +void LLEnvironment::handleEnvironmentPush(LLSD &message) +{ + // Log the experience message + LLExperienceLog::instance().handleExperienceMessage(message); + + std::string action = message[KEY_ACTION].asString(); + LLUUID experience_id = message[KEY_EXPERIENCEID].asUUID(); + LLSD action_data = message[KEY_ACTIONDATA]; + F32 transition_time = action_data[KEY_TRANSITIONTIME].asReal(); + + //TODO: Check here that the viewer thinks the experience is still valid. + + + if (action == ACTION_CLEARENVIRONMENT) + { + handleEnvironmentPushClear(experience_id, action_data, transition_time); + } + else if (action == ACTION_PUSHFULLENVIRONMENT) + { + handleEnvironmentPushFull(experience_id, action_data, transition_time); + } + else if (action == ACTION_PUSHPARTIALENVIRONMENT) + { + handleEnvironmentPushPartial(experience_id, action_data, transition_time); + } + else + { + LL_WARNS("ENVIRONMENT", "GENERICMESSAGES") << "Unknown environment push action '" << action << "'" << LL_ENDL; + } +} + +void LLEnvironment::handleEnvironmentPushClear(LLUUID experience_id, LLSD &message, F32 transition) +{ + clearExperienceEnvironment(experience_id, LLSettingsBase::Seconds(transition)); +} + +void LLEnvironment::handleEnvironmentPushFull(LLUUID experience_id, LLSD &message, F32 transition) +{ + LLUUID asset_id(message[KEY_ASSETID].asUUID()); + + setExperienceEnvironment(experience_id, asset_id, LLSettingsBase::Seconds(transition)); +} + +void LLEnvironment::handleEnvironmentPushPartial(LLUUID experience_id, LLSD &message, F32 transition) +{ + LLSD settings(message["settings"]); + + if (settings.isUndefined()) + return; + + setExperienceEnvironment(experience_id, settings, LLSettingsBase::Seconds(transition)); +} + +void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, LLSettingsBase::Seconds transition_time) +{ + DayInjection::ptr_t injection = std::dynamic_pointer_cast<DayInjection>(getEnvironmentInstance(ENV_PUSH)); + if (injection) + { + injection->clearInjections(experience_id, transition_time); + } + +} + +void LLEnvironment::setSharedEnvironment() +{ + clearEnvironment(LLEnvironment::ENV_LOCAL); + setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + updateEnvironment(); +} + +void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_id, F32 transition_time) +{ + LLSettingsVOBase::getSettingsAsset(asset_id, + [this, experience_id, transition_time](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) + { + onSetExperienceEnvAssetLoaded(experience_id, settings, transition_time, status); + }); + + +} + +void LLEnvironment::onSetExperienceEnvAssetLoaded(LLUUID experience_id, LLSettingsBase::ptr_t settings, F32 transition_time, S32 status) +{ + DayInjection::ptr_t environment = std::dynamic_pointer_cast<DayInjection>(getEnvironmentInstance(ENV_PUSH)); + bool updateenvironment(false); + + if (!settings || status) + { + LLSD args; + args["DESC"] = experience_id.asString(); + LLNotificationsUtil::add("FailedToFindSettings", args); + return; + } + + if (!environment) + { + environment = std::dynamic_pointer_cast<DayInjection>(getEnvironmentInstance(ENV_PUSH, true)); + updateenvironment = true; + } + + if (settings->getSettingsType() == "daycycle") + { + environment->setInjectedDay(std::static_pointer_cast<LLSettingsDay>(settings), experience_id, LLSettingsBase::Seconds(transition_time)); + } + else if (settings->getSettingsType() == "sky") + { + environment->setInjectedSky(std::static_pointer_cast<LLSettingsSky>(settings), experience_id, LLSettingsBase::Seconds(transition_time)); + } + else if (settings->getSettingsType() == "water") + { + environment->setInjectedWater(std::static_pointer_cast<LLSettingsWater>(settings), experience_id, LLSettingsBase::Seconds(transition_time)); + } + + if (updateenvironment) + updateEnvironment(TRANSITION_INSTANT, true); +} + + +void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F32 transition_time) +{ + LLSD sky(data["sky"]); + LLSD water(data["water"]); + + if (sky.isUndefined() && water.isUndefined()) + { + clearExperienceEnvironment(experience_id, LLSettingsBase::Seconds(transition_time)); + return; + } + + DayInjection::ptr_t environment = std::dynamic_pointer_cast<DayInjection>(getEnvironmentInstance(ENV_PUSH)); + bool updateenvironment(false); + + if (!environment) + { + environment = std::dynamic_pointer_cast<DayInjection>(getEnvironmentInstance(ENV_PUSH, true)); + updateenvironment = true; + } + + if (!sky.isUndefined()) + { + environment->injectSkySettings(sky, experience_id, LLSettingsBase::Seconds(transition_time)); + } + + if (!water.isUndefined()) + { + environment->injectWaterSettings(sky, experience_id, LLSettingsBase::Seconds(transition_time)); + } + + if (updateenvironment) + updateEnvironment(TRANSITION_INSTANT, true); + +} + +void LLEnvironment::listenExperiencePump(const LLSD &message) +{ + LLUUID experience_id = message["experience"]; + LLSD data = message[experience_id.asString()]; + std::string permission(data["permission"].asString()); + + if ((permission == "Forget") || (permission == "Block")) + { + clearExperienceEnvironment(experience_id, (permission == "Block") ? TRANSITION_INSTANT : TRANSITION_FAST); + } +} + +//========================================================================= +LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : + mDayCycle(), + mSky(), + mWater(), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mBlenderSky(), + mBlenderWater(), + mInitialized(false), + mType(TYPE_INVALID), + mSkyTrack(1), + mEnv(env) +{ } + + +LLEnvironment::DayInstance::ptr_t LLEnvironment::DayInstance::clone() const +{ + ptr_t environment = std::make_shared<DayInstance>(mEnv); + + environment->mDayCycle = mDayCycle; + environment->mSky = mSky; + environment->mWater = mWater; + environment->mDayLength = mDayLength; + environment->mDayOffset = mDayOffset; + environment->mBlenderSky = mBlenderSky; + environment->mBlenderWater = mBlenderWater; + environment->mInitialized = mInitialized; + environment->mType = mType; + environment->mSkyTrack = mSkyTrack; + + return environment; +} + +bool LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& delta) +{ + ptr_t keeper(shared_from_this()); // makes sure that this does not go away while it is being worked on. + + bool changed(false); + if (!mInitialized) + initialize(); + + if (mBlenderSky) + changed |= mBlenderSky->applyTimeDelta(delta); + if (mBlenderWater) + changed |= mBlenderWater->applyTimeDelta(delta); + return changed; +} + +void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) +{ + mType = TYPE_CYCLED; + mInitialized = false; + + mDayCycle = pday; + mDayLength = daylength; + mDayOffset = dayoffset; + + mBlenderSky.reset(); + mBlenderWater.reset(); + + mSky = LLSettingsVOSky::buildDefaultSky(); + mWater = LLSettingsVOWater::buildDefaultWater(); + + animate(); +} + + +void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) +{ + mType = TYPE_FIXED; + mInitialized = false; + + bool different_sky = mSky != psky; + + mSky = psky; + mSky->mReplaced |= different_sky; + mSky->update(); + mBlenderSky.reset(); + + if (gAtmosphere) + { + AtmosphericModelSettings settings; + LLEnvironment::getAtmosphericModelSettings(settings, psky); + gAtmosphere->configureAtmosphericModel(settings); + } +} + +void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) +{ + mType = TYPE_FIXED; + mInitialized = false; + + mWater = pwater; + mWater->update(); + mBlenderWater.reset(); +} + +void LLEnvironment::DayInstance::initialize() +{ + mInitialized = true; + + if (!mWater) + mWater = LLSettingsVOWater::buildDefaultWater(); + if (!mSky) + mSky = LLSettingsVOSky::buildDefaultSky(); +} + +void LLEnvironment::DayInstance::clear() +{ + mType = TYPE_INVALID; + mDayCycle.reset(); + mSky.reset(); + mWater.reset(); + mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; + mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; + mBlenderSky.reset(); + mBlenderWater.reset(); + mSkyTrack = 1; +} + +void LLEnvironment::DayInstance::setSkyTrack(S32 trackno) +{ + mSkyTrack = trackno; + if (mBlenderSky) + { + mBlenderSky->switchTrack(trackno, 0.0); + } +} + +void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend) +{ + mBlenderSky = skyblend; + mBlenderWater = waterblend; +} + +LLSettingsBase::TrackPosition LLEnvironment::DayInstance::getProgress() const +{ + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); + now += mDayOffset; + + if ((mDayLength <= 0) || !mDayCycle) + return -1.0f; // no actual day cycle. + + return convert_time_to_position(now, mDayLength); +} + +LLSettingsBase::TrackPosition LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) +{ + return convert_time_to_position(seconds, mDayLength); +} + +void LLEnvironment::DayInstance::animate() +{ + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); + + now += mDayOffset; + + if (!mDayCycle) + return; + + LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0); + + if (wtrack.empty()) + { + mWater.reset(); + mBlenderWater.reset(); + } + else + { + mWater = LLSettingsVOWater::buildDefaultWater(); + mBlenderWater = std::make_shared<LLTrackBlenderLoopingTime>(mWater, mDayCycle, 0, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + } + + // sky, initialize to track 1 + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); + + if (track.empty()) + { + mSky.reset(); + mBlenderSky.reset(); + } + else + { + mSky = LLSettingsVOSky::buildDefaultSky(); + mBlenderSky = std::make_shared<LLTrackBlenderLoopingTime>(mSky, mDayCycle, 1, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + mBlenderSky->switchTrack(mSkyTrack, 0.0); + } +} + +//------------------------------------------------------------------------- +LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart, + const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, LLSettingsDay::Seconds time) : + DayInstance(ENV_NONE), + mStartSky(skystart), + mStartWater(waterstart), + mNextInstance(end), + mTransitionTime(time) +{ + +} + +bool LLEnvironment::DayTransition::applyTimeDelta(const LLSettingsBase::Seconds& delta) +{ + bool changed(false); + + changed = mNextInstance->applyTimeDelta(delta); + changed |= DayInstance::applyTimeDelta(delta); + return changed; +} + +void LLEnvironment::DayTransition::animate() +{ + mNextInstance->animate(); + + mWater = mStartWater->buildClone(); + mBlenderWater = std::make_shared<LLSettingsBlenderTimeDelta>(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); + mBlenderWater->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { + mBlenderWater.reset(); + + if (!mBlenderSky && !mBlenderWater) + LLEnvironment::instance().mCurrentEnvironment = mNextInstance; + else + setWater(mNextInstance->getWater()); + }); + + mSky = mStartSky->buildClone(); + mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); + mBlenderSky->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { + mBlenderSky.reset(); + + if (!mBlenderSky && !mBlenderWater) + LLEnvironment::instance().mCurrentEnvironment = mNextInstance; + else + setSky(mNextInstance->getSky()); + }); +} + +//========================================================================= +LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno) : + LLSettingsBlender(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t()), + mDay(day), + mTrackNo(trackno), + mPosition(0.0) +{ + LLSettingsDay::TrackBound_t initial = getBoundingEntries(mPosition); + + if (initial.first != mEndMarker) + { // No frames in track + mInitial = (*initial.first).second; + mFinal = (*initial.second).second; + + LLSD initSettings = mInitial->getSettings(); + mTarget->replaceSettings(initSettings); + } +} + +LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSettingsBase::TrackPosition& position) +{ + mPosition = llclamp(position, 0.0f, 1.0f); + + LLSettingsDay::TrackBound_t bounds = getBoundingEntries(mPosition); + + if (bounds.first == mEndMarker) + { // No frames in track. + return 0.0; + } + + mInitial = (*bounds.first).second; + mFinal = (*bounds.second).second; + + F64 spanLength = getSpanLength(bounds); + + F64 spanPos = ((mPosition < (*bounds.first).first) ? (mPosition + 1.0) : mPosition) - (*bounds.first).first; + + if (spanPos > spanLength) + { + // we are clamping position to 0-1 and spanLength is 1 + // so don't account for case of spanPos == spanLength + spanPos = fmod(spanPos, spanLength); + } + + F64 blendf = spanPos / spanLength; + return LLSettingsBlender::setBlendFactor(blendf); +} + +void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) +{ + mTrackNo = trackno; + + LLSettingsBase::TrackPosition useposition = (position < 0.0) ? mPosition : position; + + setPosition(useposition); +} + +LLSettingsDay::TrackBound_t LLTrackBlenderLoopingManual::getBoundingEntries(F64 position) +{ + LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); + + mEndMarker = wtrack.end(); + + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); + return bounds; +} + +F64 LLTrackBlenderLoopingManual::getSpanLength(const LLSettingsDay::TrackBound_t &bounds) const +{ + return get_wrapping_distance((*bounds.first).first, (*bounds.second).first); +} + +//========================================================================= +namespace +{ + DayInjection::DayInjection(LLEnvironment::EnvSelection_t env): + LLEnvironment::DayInstance(env), + mBaseDayInstance(), + mInjectedSky(), + mInjectedWater(), + mActiveExperiences(), + mDayExperience(), + mSkyExperience(), + mWaterExperience(), + mEnvChangeConnection(), + mParcelChangeConnection() + { + mInjectedSky = std::make_shared<LLSettingsInjectedSky>(LLEnvironment::instance().getCurrentSky()); + mInjectedWater = std::make_shared<LLSettingsInjectedWater>(LLEnvironment::instance().getCurrentWater()); + mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); + mSky = mInjectedSky; + mWater = mInjectedWater; + + mEnvChangeConnection = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32) { onEnvironmentChanged(env); }); + mParcelChangeConnection = gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); + } + + DayInjection::~DayInjection() + { + if (mEnvChangeConnection.connected()) + mEnvChangeConnection.disconnect(); + if (mParcelChangeConnection.connected()) + mParcelChangeConnection.disconnect(); + } + + + bool DayInjection::applyTimeDelta(const LLSettingsBase::Seconds& delta) + { + bool changed(false); + + if (mBaseDayInstance) + changed |= mBaseDayInstance->applyTimeDelta(delta); + mInjectedSky->applyInjections(delta); + mInjectedWater->applyInjections(delta); + changed |= LLEnvironment::DayInstance::applyTimeDelta(delta); + if (changed) + { + mInjectedSky->setDirtyFlag(true); + mInjectedWater->setDirtyFlag(true); + } + mInjectedSky->update(); + mInjectedWater->update(); + + if (!hasInjections()) + { // There are no injections being managed. This should really go away. + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } + + return changed; + } + + void DayInjection::setBaseDayInstance(const LLEnvironment::DayInstance::ptr_t &baseday) + { + mBaseDayInstance = baseday; + + if (mSkyExperience.isNull()) + mInjectedSky->setSource(mBaseDayInstance->getSky()); + if (mWaterExperience.isNull()) + mInjectedWater->setSource(mBaseDayInstance->getWater()); + } + + + bool DayInjection::hasInjections() const + { + return (!mSkyExperience.isNull() || !mWaterExperience.isNull() || !mDayExperience.isNull() || + mBlenderSky || mBlenderWater || mInjectedSky->hasInjections() || mInjectedWater->hasInjections()); + } + + + void DayInjection::testExperiencesOnParcel(S32 parcel_id) + { + LLCoros::instance().launch("DayInjection::testExperiencesOnParcel", + [this, parcel_id]() { DayInjection::testExperiencesOnParcelCoro(std::static_pointer_cast<DayInjection>(this->shared_from_this()), parcel_id); }); + + } + + void DayInjection::setInjectedDay(const LLSettingsDay::ptr_t &pday, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mSkyExperience = experience_id; + mWaterExperience = experience_id; + mDayExperience = experience_id; + + mBaseDayInstance = mBaseDayInstance->clone(); + mBaseDayInstance->setEnvironmentSelection(LLEnvironment::ENV_NONE); + mBaseDayInstance->setDay(pday, mBaseDayInstance->getDayLength(), mBaseDayInstance->getDayOffset()); + animateSkyChange(mBaseDayInstance->getSky(), transition); + animateWaterChange(mBaseDayInstance->getWater(), transition); + + mActiveExperiences.insert(experience_id); + } + + void DayInjection::setInjectedSky(const LLSettingsSky::ptr_t &psky, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mSkyExperience = experience_id; + mActiveExperiences.insert(experience_id); + checkExperience(); + animateSkyChange(psky, transition); + } + + void DayInjection::setInjectedWater(const LLSettingsWater::ptr_t &pwater, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mWaterExperience = experience_id; + mActiveExperiences.insert(experience_id); + checkExperience(); + animateWaterChange(pwater, transition); + } + + void DayInjection::injectSkySettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mInjectedSky->injectExperienceValues(settings, experience_id, transition); + mActiveExperiences.insert(experience_id); + } + + void DayInjection::injectWaterSettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mInjectedWater->injectExperienceValues(settings, experience_id, transition); + mActiveExperiences.insert(experience_id); + } + + void DayInjection::clearInjections(LLUUID experience_id, LLSettingsBase::Seconds transition_time) + { + if ((experience_id.isNull() && !mDayExperience.isNull()) || (experience_id == mDayExperience)) + { + mDayExperience.setNull(); + if (mSkyExperience == experience_id) + mSkyExperience.setNull(); + if (mWaterExperience == experience_id) + mWaterExperience.setNull(); + + mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); + + if (mSkyExperience.isNull()) + animateSkyChange(mBaseDayInstance->getSky(), transition_time); + if (mWaterExperience.isNull()) + animateWaterChange(mBaseDayInstance->getWater(), transition_time); + } + + if ((experience_id.isNull() && !mSkyExperience.isNull()) || (experience_id == mSkyExperience)) + { + mSkyExperience.setNull(); + animateSkyChange(mBaseDayInstance->getSky(), transition_time); + } + if ((experience_id.isNull() && !mWaterExperience.isNull()) || (experience_id == mWaterExperience)) + { + mWaterExperience.setNull(); + animateWaterChange(mBaseDayInstance->getWater(), transition_time); + } + + mInjectedSky->removeInjections(experience_id, transition_time); + mInjectedWater->removeInjections(experience_id, transition_time); + + if (experience_id.isNull()) + mActiveExperiences.clear(); + else + mActiveExperiences.erase(experience_id); + + if ((transition_time == LLEnvironment::TRANSITION_INSTANT) && (countExperiencesActive() == 0)) + { // Only do this if instant and there are no other experiences injecting values. + // (otherwise will be handled after transition) + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } + } + + + void DayInjection::testExperiencesOnParcelCoro(wptr_t that, S32 parcel_id) + { + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("testExperiencesOnParcelCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + std::string url = gAgent.getRegionCapability("ExperienceQuery"); + + if (url.empty()) + { + LL_WARNS("ENVIRONMENT") << "No experience query cap." << LL_ENDL; + return; // no checking in this region. + } + + { + ptr_t thatlock(that); + std::stringstream fullurl; + + if (!thatlock) + return; + + fullurl << url << "?"; + fullurl << "parcelid=" << parcel_id; + + for (auto it = thatlock->mActiveExperiences.begin(); it != thatlock->mActiveExperiences.end(); ++it) + { + if (it != thatlock->mActiveExperiences.begin()) + fullurl << ","; + else + fullurl << "&experiences="; + fullurl << (*it).asString(); + } + url = fullurl.str(); + } + + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Unable to retrieve experience status for parcel." << LL_ENDL; + return; + } + + { + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + if (!parcel) + return; + + if (parcel_id != parcel->getLocalID()) + { + // Agent no longer on queried parcel. + return; + } + } + + + LLSD experiences = result["experiences"]; + { + ptr_t thatlock(that); + if (!thatlock) + return; + + for (LLSD::map_iterator itr = experiences.beginMap(); itr != experiences.endMap(); ++itr) + { + if (!((*itr).second.asBoolean())) + thatlock->clearInjections(LLUUID((*itr).first), LLEnvironment::TRANSITION_FAST); + + } + } + } + + void DayInjection::animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition) + { + if (mInjectedSky.get() == psky.get()) + { // An attempt to animate to itself... don't do it. + return; + } + if (transition == LLEnvironment::TRANSITION_INSTANT) + { + mBlenderSky.reset(); + mInjectedSky->setSource(psky); + } + else + { + LLSettingsSky::ptr_t start_sky(mInjectedSky->getSource()->buildClone()); + LLSettingsSky::ptr_t target_sky(start_sky->buildClone()); + mInjectedSky->setSource(target_sky); + + mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(target_sky, start_sky, psky, transition); + mBlenderSky->setOnFinished( + [this, psky](LLSettingsBlender::ptr_t blender) + { + mBlenderSky.reset(); + mInjectedSky->setSource(psky); + setSky(mInjectedSky); + if (!mBlenderWater && (countExperiencesActive() == 0)) + { + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } + }); + } + } + + void DayInjection::animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition) + { + if (mInjectedWater.get() == pwater.get()) + { // An attempt to animate to itself. Bad idea. + return; + } + if (transition == LLEnvironment::TRANSITION_INSTANT) + { + mBlenderWater.reset(); + mInjectedWater->setSource(pwater); + } + else + { + LLSettingsWater::ptr_t start_Water(mInjectedWater->getSource()->buildClone()); + LLSettingsWater::ptr_t scratch_Water(start_Water->buildClone()); + mInjectedWater->setSource(scratch_Water); + + mBlenderWater = std::make_shared<LLSettingsBlenderTimeDelta>(scratch_Water, start_Water, pwater, transition); + mBlenderWater->setOnFinished( + [this, pwater](LLSettingsBlender::ptr_t blender) + { + mBlenderWater.reset(); + mInjectedWater->setSource(pwater); + setWater(mInjectedWater); + if (!mBlenderSky && (countExperiencesActive() == 0)) + { + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } + }); + } + } + + void DayInjection::onEnvironmentChanged(LLEnvironment::EnvSelection_t env) + { + if (env >= LLEnvironment::ENV_PARCEL) + { + LLEnvironment::EnvSelection_t base_env(mBaseDayInstance->getEnvironmentSelection()); + LLEnvironment::DayInstance::ptr_t nextbase = LLEnvironment::instance().getSharedEnvironmentInstance(); + + if ((base_env == LLEnvironment::ENV_NONE) || (nextbase == mBaseDayInstance) || + (!mSkyExperience.isNull() && !mWaterExperience.isNull())) + { // base instance completely overridden, or not changed no transition will happen + return; + } + + LL_WARNS("PUSHENV") << "Underlying environment has changed (" << env << ")! Base env is type " << base_env << LL_ENDL; + + LLEnvironment::DayInstance::ptr_t trans = std::make_shared<InjectedTransition>(std::static_pointer_cast<DayInjection>(shared_from_this()), + mBaseDayInstance->getSky(), mBaseDayInstance->getWater(), nextbase, LLEnvironment::TRANSITION_DEFAULT); + + trans->animate(); + setBaseDayInstance(trans); + } + } + + void DayInjection::onParcelChange() + { + S32 parcel_id(INVALID_PARCEL_ID); + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (!parcel) + return; + + parcel_id = parcel->getLocalID(); + + testExperiencesOnParcel(parcel_id); + } + + void DayInjection::checkExperience() + { + if ((!mDayExperience.isNull()) && (mSkyExperience != mDayExperience) && (mWaterExperience != mDayExperience)) + { // There was a day experience but we've replaced it with a water and a sky experience. + mDayExperience.setNull(); + mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); + } + } + + void DayInjection::animate() + { + + } + + void InjectedTransition::animate() + { + mNextInstance->animate(); + + if (!mInjection->isOverriddenSky()) + { + mSky = mStartSky->buildClone(); + mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); + mBlenderSky->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { + mBlenderSky.reset(); + + if (!mBlenderSky && !mBlenderSky) + mInjection->setBaseDayInstance(mNextInstance); + else + mInjection->mInjectedSky->setSource(mNextInstance->getSky()); + }); + } + else + { + mSky = mInjection->getSky(); + mBlenderSky.reset(); + } + + if (!mInjection->isOverriddenWater()) + { + mWater = mStartWater->buildClone(); + mBlenderWater = std::make_shared<LLSettingsBlenderTimeDelta>(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); + mBlenderWater->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { + mBlenderWater.reset(); + + if (!mBlenderSky && !mBlenderWater) + mInjection->setBaseDayInstance(mNextInstance); + else + mInjection->mInjectedWater->setSource(mNextInstance->getWater()); + }); + } + else + { + mWater = mInjection->getWater(); + mBlenderWater.reset(); + } + + } + +} + diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h new file mode 100644 index 0000000000..64350c42e8 --- /dev/null +++ b/indra/newview/llenvironment.h @@ -0,0 +1,454 @@ +/** + * @file llenvmanager.h + * @brief Declaration of classes managing WindLight and water settings. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_ENVIRONMENT_H +#define LL_ENVIRONMENT_H + +#include "llsingleton.h" +#include "llmemory.h" +#include "llsd.h" + +#include "llsettingsbase.h" +#include "llsettingssky.h" +#include "llsettingswater.h" +#include "llsettingsdaycycle.h" + +#include "llatmosphere.h" + +#include <boost/signals2.hpp> + +//------------------------------------------------------------------------- +class LLViewerCamera; +class LLGLSLShader; +class LLParcel; + +//------------------------------------------------------------------------- +class LLEnvironment : public LLSingleton<LLEnvironment> +{ + LLSINGLETON_C11(LLEnvironment); + LOG_CLASS(LLEnvironment); + +public: + static const F32Seconds TRANSITION_INSTANT; + static const F32Seconds TRANSITION_FAST; + static const F32Seconds TRANSITION_DEFAULT; + static const F32Seconds TRANSITION_SLOW; + static const F32Seconds TRANSITION_ALTITUDE; + + static const LLUUID KNOWN_SKY_SUNRISE; + static const LLUUID KNOWN_SKY_MIDDAY; + static const LLUUID KNOWN_SKY_SUNSET; + static const LLUUID KNOWN_SKY_MIDNIGHT; + + static const S32 NO_TRACK; + static const S32 NO_VERSION; + static const S32 VERSION_CLEANUP; + + struct EnvironmentInfo + { + EnvironmentInfo(); + + typedef std::shared_ptr<EnvironmentInfo> ptr_t; + typedef std::array<std::string, 5> namelist_t; + + S32 mParcelId; + LLUUID mRegionId; + S64Seconds mDayLength; + S64Seconds mDayOffset; + size_t mDayHash; + LLSettingsDay::ptr_t mDayCycle; + std::array<F32, 4> mAltitudes; + bool mIsDefault; + LLUUID mAssetId; + bool mIsLegacy; + std::string mDayCycleName; + namelist_t mNameList; + S32 mEnvVersion; + + static ptr_t extract(LLSD); + static ptr_t extractLegacy(LLSD); + }; + + enum EnvSelection_t + { + ENV_EDIT = 0, + ENV_LOCAL, + ENV_PUSH, + ENV_PARCEL, + ENV_REGION, + ENV_DEFAULT, + ENV_END, + ENV_CURRENT = -1, + ENV_NONE = -2 + }; + + typedef boost::signals2::connection connection_t; + + typedef std::pair<LLSettingsSky::ptr_t, LLSettingsWater::ptr_t> fixedEnvironment_t; + typedef std::function<void(S32, EnvironmentInfo::ptr_t)> environment_apply_fn; + typedef boost::signals2::signal<void(EnvSelection_t, S32)> env_changed_signal_t; + typedef env_changed_signal_t::slot_type env_changed_fn; + typedef std::array<F32, 4> altitude_list_t; + typedef std::vector<F32> altitudes_vect_t; + + virtual ~LLEnvironment(); + + bool canEdit() const; + bool isExtendedEnvironmentEnabled() const; + bool isInventoryEnabled() const; + bool canAgentUpdateParcelEnvironment() const; + bool canAgentUpdateParcelEnvironment(LLParcel *parcel) const; + bool canAgentUpdateRegionEnvironment() const; + + LLSettingsDay::ptr_t getCurrentDay() const { return mCurrentEnvironment->getDayCycle(); } + LLSettingsSky::ptr_t getCurrentSky() const; + LLSettingsWater::ptr_t getCurrentWater() const; + + static void getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky); + + void update(const LLViewerCamera * cam); + + static void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); + void updateShaderUniforms(LLGLSLShader *shader); + + void setSelectedEnvironment(EnvSelection_t env, LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false); + EnvSelection_t getSelectedEnvironment() const { return mSelectedEnvironment; } + + bool hasEnvironment(EnvSelection_t env); + void setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 env_version = NO_VERSION); + void setEnvironment(EnvSelection_t env, fixedEnvironment_t fixed, S32 env_version = NO_VERSION); + void setEnvironment(EnvSelection_t env, const LLSettingsBase::ptr_t &fixed, S32 env_version = NO_VERSION); + void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed, S32 env_version = NO_VERSION) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t()), env_version); } + void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed, S32 env_version = NO_VERSION) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed), env_version); } + void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixeds, const LLSettingsWater::ptr_t & fixedw, S32 env_version = NO_VERSION) { setEnvironment(env, fixedEnvironment_t(fixeds, fixedw), env_version); } + void setEnvironment(EnvSelection_t env, const LLUUID &assetId, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 env_version = NO_VERSION); + void setEnvironment(EnvSelection_t env, const LLUUID &assetId, S32 env_version = NO_VERSION); + + void setSharedEnvironment(); + + void clearEnvironment(EnvSelection_t env); + LLSettingsDay::ptr_t getEnvironmentDay(EnvSelection_t env); + LLSettingsDay::Seconds getEnvironmentDayLength(EnvSelection_t env); + LLSettingsDay::Seconds getEnvironmentDayOffset(EnvSelection_t env); + fixedEnvironment_t getEnvironmentFixed(EnvSelection_t env, bool resolve = false); + LLSettingsSky::ptr_t getEnvironmentFixedSky(EnvSelection_t env, bool resolve = false) { return getEnvironmentFixed(env, resolve).first; }; + LLSettingsWater::ptr_t getEnvironmentFixedWater(EnvSelection_t env, bool resolve = false) { return getEnvironmentFixed(env, resolve).second; }; + + void updateEnvironment(LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false); + + inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } + void pauseCloudScroll() { mCloudScrollPaused = true; } + void resumeCloudScroll() { mCloudScrollPaused = false; } + bool isCloudScrollPaused() const { return mCloudScrollPaused; } + + F32 getCamHeight() const; + F32 getWaterHeight() const; + bool getIsSunUp() const; + bool getIsMoonUp() const; + + // Returns either sun or moon direction (depending on which is up and stronger) + // Light direction in +x right, +z up, +y at internal coord sys + LLVector3 getLightDirection() const; // returns sun or moon depending on which is up + LLVector3 getSunDirection() const; + LLVector3 getMoonDirection() const; + + // Returns light direction converted to CFR coord system + LLVector4 getLightDirectionCFR() const; // returns sun or moon depending on which is up + LLVector4 getSunDirectionCFR() const; + LLVector4 getMoonDirectionCFR() const; + + // Returns light direction converted to OGL coord system + // and clamped above -0.1f in Y to avoid render artifacts in sky shaders + LLVector4 getClampedLightNorm() const; // returns sun or moon depending on which is up + LLVector4 getClampedSunNorm() const; + LLVector4 getClampedMoonNorm() const; + + // Returns light direction converted to OGL coord system + // and rotated by last cam yaw needed by water rendering shaders + LLVector4 getRotatedLightNorm() const; + + static LLSettingsWater::ptr_t createWaterFromLegacyPreset(const std::string filename, LLSD &messages); + static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string filename, LLSD &messages); + static LLSettingsDay::ptr_t createDayCycleFromLegacyPreset(const std::string filename, LLSD &messages); + + // Construct a new day cycle based on the environment. Replacing either the water or the sky tracks. + LLSettingsDay::ptr_t createDayCycleFromEnvironment(EnvSelection_t env, LLSettingsBase::ptr_t settings); + + F32 getProgress() const { return (mCurrentEnvironment) ? mCurrentEnvironment->getProgress() : -1.0f; } + F32 getRegionProgress() const { return (mEnvironments[ENV_REGION]) ? mEnvironments[ENV_REGION]->getProgress() : -1.0f; } + void adjustRegionOffset(F32 adjust); // only used on legacy regions, to better sync the viewer with other agents + + //------------------------------------------- + connection_t setEnvironmentChanged(env_changed_fn cb) { return mSignalEnvChanged.connect(cb); } + + void requestRegion(environment_apply_fn cb = environment_apply_fn()); + void updateRegion(const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void resetRegion(environment_apply_fn cb = environment_apply_fn()); + void requestParcel(S32 parcel_id, environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 track_num, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn()); + void resetParcel(S32 parcel_id, environment_apply_fn cb = environment_apply_fn()); + + void selectAgentEnvironment(); + + S32 calculateSkyTrackForAltitude(F64 altitude); + + const altitude_list_t & getRegionAltitudes() const { return mTrackAltitudes; } + + void handleEnvironmentPush(LLSD &message); + + class DayInstance: public std::enable_shared_from_this<DayInstance> + { + public: + enum InstanceType_t + { + TYPE_INVALID, + TYPE_FIXED, + TYPE_CYCLED + }; + typedef std::shared_ptr<DayInstance> ptr_t; + + DayInstance(EnvSelection_t env); + virtual ~DayInstance() { }; + + virtual ptr_t clone() const; + + virtual bool applyTimeDelta(const LLSettingsBase::Seconds& delta); + + virtual void setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset); + virtual void setSky(const LLSettingsSky::ptr_t &psky); + virtual void setWater(const LLSettingsWater::ptr_t &pwater); + + void initialize(); + bool isInitialized(); + + void clear(); + + void setSkyTrack(S32 trackno); + + LLSettingsDay::ptr_t getDayCycle() const { return mDayCycle; } + LLSettingsSky::ptr_t getSky() const { return mSky; } + LLSettingsWater::ptr_t getWater() const { return mWater; } + LLSettingsDay::Seconds getDayLength() const { return mDayLength; } + LLSettingsDay::Seconds getDayOffset() const { return mDayOffset; } + S32 getSkyTrack() const { return mSkyTrack; } + + void setDayOffset(LLSettingsBase::Seconds offset) { mDayOffset = offset; animate(); } + + virtual void animate(); + + void setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend); + + EnvSelection_t getEnvironmentSelection() const { return mEnv; } + void setEnvironmentSelection(EnvSelection_t env) { mEnv = env; } + + LLSettingsBase::TrackPosition getProgress() const; + + protected: + LLSettingsDay::ptr_t mDayCycle; + LLSettingsSky::ptr_t mSky; + LLSettingsWater::ptr_t mWater; + S32 mSkyTrack; + + InstanceType_t mType; + bool mInitialized; + + LLSettingsDay::Seconds mDayLength; + LLSettingsDay::Seconds mDayOffset; + S32 mLastTrackAltitude; + + LLSettingsBlender::ptr_t mBlenderSky; + LLSettingsBlender::ptr_t mBlenderWater; + + EnvSelection_t mEnv; + + LLSettingsBase::TrackPosition secondsToKeyframe(LLSettingsDay::Seconds seconds); + }; + + class DayTransition : public DayInstance + { + public: + DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, LLSettingsDay::Seconds time); + virtual ~DayTransition() { }; + + virtual bool applyTimeDelta(const LLSettingsBase::Seconds& delta) override; + virtual void animate() override; + + protected: + LLSettingsSky::ptr_t mStartSky; + LLSettingsWater::ptr_t mStartWater; + DayInstance::ptr_t mNextInstance; + LLSettingsDay::Seconds mTransitionTime; + }; + + DayInstance::ptr_t getSelectedEnvironmentInstance(); + DayInstance::ptr_t getSharedEnvironmentInstance(); + +protected: + virtual void initSingleton() override; + virtual void cleanupSingleton() override; + + +private: + LLVector4 toCFR(const LLVector3 vec) const; + LLVector4 toLightNorm(const LLVector3 vec) const; + + typedef std::array<DayInstance::ptr_t, ENV_END> InstanceArray_t; + + struct ExpEnvironmentEntry + { + typedef std::shared_ptr<ExpEnvironmentEntry> ptr_t; + + S32Seconds mTime; + LLUUID mExperienceId; + LLSD mEnvironmentOverrides; + }; + typedef std::deque<ExpEnvironmentEntry::ptr_t> mPushOverrides; + + LLUUID mPushEnvironmentExpId; + + static const F32 SUN_DELTA_YAW; + F32 mLastCamYaw = 0.0f; + + LLVector2 mCloudScrollDelta; // cumulative cloud delta + bool mCloudScrollPaused; + + InstanceArray_t mEnvironments; + + EnvSelection_t mSelectedEnvironment; + DayInstance::ptr_t mCurrentEnvironment; + + LLSettingsSky::ptr_t mSelectedSky; + LLSettingsWater::ptr_t mSelectedWater; + LLSettingsDay::ptr_t mSelectedDay; + + LLSettingsBlender::ptr_t mBlenderSky; + LLSettingsBlender::ptr_t mBlenderWater; + + env_changed_signal_t mSignalEnvChanged; + + S32 mCurrentTrack; + altitude_list_t mTrackAltitudes; + + LLSD mSkyOverrides; + LLSD mWaterOverrides; + typedef std::map<std::string, LLUUID> experience_overrides_t; + experience_overrides_t mExperienceOverrides; + + DayInstance::ptr_t getEnvironmentInstance(EnvSelection_t env, bool create = false); + + void updateCloudScroll(); + + void onRegionChange(); + void onParcelChange(); + + struct UpdateInfo + { + typedef std::shared_ptr<UpdateInfo> ptr_t; + + UpdateInfo(LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, altitudes_vect_t altitudes): + mDayp(pday), + mSettingsAsset(), + mDayLength(day_length), + mDayOffset(day_offset), + mAltitudes(altitudes), + mDayName() + { + if (mDayp) + mDayName = mDayp->getName(); + } + + UpdateInfo(LLUUID settings_asset, std::string name, S32 day_length, S32 day_offset, altitudes_vect_t altitudes) : + mDayp(), + mSettingsAsset(settings_asset), + mDayLength(day_length), + mDayOffset(day_offset), + mAltitudes(altitudes), + mDayName(name) + {} + + LLSettingsDay::ptr_t mDayp; + LLUUID mSettingsAsset; + S32 mDayLength; + S32 mDayOffset; + altitudes_vect_t mAltitudes; + std::string mDayName; + }; + + void coroRequestEnvironment(S32 parcel_id, environment_apply_fn apply); + void coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInfo::ptr_t updates, environment_apply_fn apply); + void coroResetEnvironment(S32 parcel_id, S32 track_no, environment_apply_fn apply); + + void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment, LLSettingsBase::Seconds transition); + + void onAgentPositionHasChanged(const LLVector3 &localpos); + + void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, LLSettingsBase::Seconds transition, S32 status, S32 env_version); + void onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset, altitudes_vect_t altitudes); + + void handleEnvironmentPushClear(LLUUID experience_id, LLSD &message, F32 transition); + void handleEnvironmentPushFull(LLUUID experience_id, LLSD &message, F32 transition); + void handleEnvironmentPushPartial(LLUUID experience_id, LLSD &message, F32 transition); + + void clearExperienceEnvironment(LLUUID experience_id, LLSettingsBase::Seconds transition_time); + void setExperienceEnvironment(LLUUID experience_id, LLUUID asset_id, F32 transition_time); + void setExperienceEnvironment(LLUUID experience_id, LLSD environment, F32 transition_time); + void onSetExperienceEnvAssetLoaded(LLUUID experience_id, LLSettingsBase::ptr_t setting, F32 transition_time, S32 status); + + void listenExperiencePump(const LLSD &message); + +}; + +class LLTrackBlenderLoopingManual : public LLSettingsBlender +{ +public: + LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno); + + F64 setPosition(const LLSettingsBase::TrackPosition& position); + virtual void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) override; + S32 getTrack() const { return mTrackNo; } + + typedef std::shared_ptr<LLTrackBlenderLoopingManual> ptr_t; +protected: + LLSettingsDay::TrackBound_t getBoundingEntries(F64 position); + F64 getSpanLength(const LLSettingsDay::TrackBound_t &bounds) const; + +private: + LLSettingsDay::ptr_t mDay; + S32 mTrackNo; + F64 mPosition; + + LLSettingsDay::CycleTrack_t::iterator mEndMarker; +}; + +#endif // LL_ENVIRONMENT_H + diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp deleted file mode 100644 index fa1c3b983e..0000000000 --- a/indra/newview/llenvmanager.cpp +++ /dev/null @@ -1,721 +0,0 @@ -/** - * @file llenvmanager.cpp - * @brief Implementation of classes managing WindLight and water settings. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llenvmanager.h" - -#include "llagent.h" -#include "lldaycyclemanager.h" -#include "llviewercontrol.h" // for gSavedSettings -#include "llviewerregion.h" -#include "llwaterparammanager.h" -#include "llwlhandlers.h" -#include "llwlparammanager.h" -#include "lltrans.h" - -std::string LLWLParamKey::toString() const -{ - switch (scope) - { - case SCOPE_LOCAL: - return name + std::string(" (") + LLTrans::getString("Local") + std::string(")"); - break; - case SCOPE_REGION: - return name + std::string(" (") + LLTrans::getString("Region") + std::string(")"); - break; - default: - return name + " (?)"; - } -} - -std::string LLEnvPrefs::getWaterPresetName() const -{ - if (mWaterPresetName.empty()) - { - LL_WARNS() << "Water preset name is empty" << LL_ENDL; - } - - return mWaterPresetName; -} - -std::string LLEnvPrefs::getSkyPresetName() const -{ - if (mSkyPresetName.empty()) - { - LL_WARNS() << "Sky preset name is empty" << LL_ENDL; - } - - return mSkyPresetName; -} - -std::string LLEnvPrefs::getDayCycleName() const -{ - if (mDayCycleName.empty()) - { - LL_WARNS() << "Day cycle name is empty" << LL_ENDL; - } - - return mDayCycleName; -} - -void LLEnvPrefs::setUseRegionSettings(bool val) -{ - mUseRegionSettings = val; -} - -void LLEnvPrefs::setUseWaterPreset(const std::string& name) -{ - mUseRegionSettings = false; - mWaterPresetName = name; -} - -void LLEnvPrefs::setUseSkyPreset(const std::string& name) -{ - mUseRegionSettings = false; - mUseDayCycle = false; - mSkyPresetName = name; -} - -void LLEnvPrefs::setUseDayCycle(const std::string& name) -{ - mUseRegionSettings = false; - mUseDayCycle = true; - mDayCycleName = name; -} - -//============================================================================= -LLEnvManagerNew::LLEnvManagerNew(): - mInterpNextChangeMessage(true), - mCurRegionUUID(LLUUID::null), - mLastReceivedID(LLUUID::null) -{ - - // Set default environment settings. - mUserPrefs.mUseRegionSettings = true; - mUserPrefs.mUseDayCycle = true; - mUserPrefs.mWaterPresetName = "Default"; - mUserPrefs.mSkyPresetName = "Default"; - mUserPrefs.mDayCycleName = "Default"; - - LL_DEBUGS("Windlight")<<LL_ENDL; - gAgent.addRegionChangedCallback(boost::bind(&LLEnvManagerNew::onRegionChange, this)); -} - -bool LLEnvManagerNew::getUseRegionSettings() const -{ - return mUserPrefs.getUseRegionSettings(); -} - -bool LLEnvManagerNew::getUseDayCycle() const -{ - return mUserPrefs.getUseDayCycle(); -} - -bool LLEnvManagerNew::getUseFixedSky() const -{ - return mUserPrefs.getUseFixedSky(); -} - -std::string LLEnvManagerNew::getWaterPresetName() const -{ - return mUserPrefs.getWaterPresetName(); -} - -std::string LLEnvManagerNew::getSkyPresetName() const -{ - return mUserPrefs.getSkyPresetName(); -} - -std::string LLEnvManagerNew::getDayCycleName() const -{ - return mUserPrefs.getDayCycleName(); -} - -const LLEnvironmentSettings& LLEnvManagerNew::getRegionSettings() const -{ - return !mNewRegionPrefs.isEmpty() ? mNewRegionPrefs : mCachedRegionPrefs; -} - -void LLEnvManagerNew::setRegionSettings(const LLEnvironmentSettings& new_settings) -{ - // Set region settings override that will be used locally - // until user either uploads the changes or goes to another region. - mNewRegionPrefs = new_settings; -} - -bool LLEnvManagerNew::usePrefs() -{ - LL_DEBUGS("Windlight") << "Displaying preferred environment" << LL_ENDL; - updateManagersFromPrefs(false); - return true; -} - -bool LLEnvManagerNew::useDefaults() -{ - bool rslt; - - rslt = useDefaultWater(); - rslt &= useDefaultSky(); - - return rslt; -} - -bool LLEnvManagerNew::useRegionSettings() -{ - bool rslt; - - rslt = useRegionSky(); - rslt &= useRegionWater(); - - return rslt; -} - -bool LLEnvManagerNew::useWaterPreset(const std::string& name) -{ - LL_DEBUGS("Windlight") << "Displaying water preset " << name << LL_ENDL; - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - bool rslt = water_mgr.getParamSet(name, water_mgr.mCurParams); - llassert(rslt == true); - return rslt; -} - -bool LLEnvManagerNew::useWaterParams(const LLSD& params) -{ - LL_DEBUGS("Windlight") << "Displaying water params" << LL_ENDL; - LLWaterParamManager::instance().mCurParams.setAll(params); - return true; -} - -bool LLEnvManagerNew::useSkyPreset(const std::string& name) -{ - LLWLParamManager& sky_mgr = LLWLParamManager::instance(); - LLWLParamSet param_set; - - if (!sky_mgr.getParamSet(LLWLParamKey(name, LLEnvKey::SCOPE_LOCAL), param_set)) - { - LL_WARNS() << "No sky preset named " << name << LL_ENDL; - return false; - } - - LL_DEBUGS("Windlight") << "Displaying sky preset " << name << LL_ENDL; - sky_mgr.applySkyParams(param_set.getAll()); - return true; -} - -bool LLEnvManagerNew::useSkyParams(const LLSD& params) -{ - LL_DEBUGS("Windlight") << "Displaying sky params" << LL_ENDL; - LLWLParamManager::instance().applySkyParams(params); - return true; -} - -bool LLEnvManagerNew::useDayCycle(const std::string& name, LLEnvKey::EScope scope) -{ - LLSD params; - - if (scope == LLEnvKey::SCOPE_REGION) - { - LL_DEBUGS("Windlight") << "Displaying region day cycle " << name << LL_ENDL; - params = getRegionSettings().getWLDayCycle(); - } - else - { - LL_DEBUGS("Windlight") << "Displaying local day cycle " << name << LL_ENDL; - - if (!LLDayCycleManager::instance().getPreset(name, params)) - { - LL_WARNS() << "No day cycle named " << name << LL_ENDL; - return false; - } - } - - bool rslt = LLWLParamManager::instance().applyDayCycleParams(params, scope); - llassert(rslt == true); - return rslt; -} - -bool LLEnvManagerNew::useDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time /* = 0.5*/) -{ - LL_DEBUGS("Windlight") << "Displaying day cycle params" << LL_ENDL; - return LLWLParamManager::instance().applyDayCycleParams(params, scope); -} - -void LLEnvManagerNew::setUseRegionSettings(bool val) -{ - mUserPrefs.setUseRegionSettings(val); - saveUserPrefs(); - updateManagersFromPrefs(false); -} - -void LLEnvManagerNew::setUseWaterPreset(const std::string& name) -{ - // *TODO: make sure the preset exists. - if (name.empty()) - { - LL_WARNS() << "Empty water preset name passed" << LL_ENDL; - return; - } - - mUserPrefs.setUseWaterPreset(name); - saveUserPrefs(); - updateManagersFromPrefs(false); -} - -void LLEnvManagerNew::setUseSkyPreset(const std::string& name) -{ - // *TODO: make sure the preset exists. - if (name.empty()) - { - LL_WARNS() << "Empty sky preset name passed" << LL_ENDL; - return; - } - - mUserPrefs.setUseSkyPreset(name); - saveUserPrefs(); - updateManagersFromPrefs(false); -} - -void LLEnvManagerNew::setUseDayCycle(const std::string& name) -{ - if (!LLDayCycleManager::instance().presetExists(name)) - { - LL_WARNS() << "Invalid day cycle name passed" << LL_ENDL; - return; - } - - mUserPrefs.setUseDayCycle(name); - saveUserPrefs(); - updateManagersFromPrefs(false); -} - -void LLEnvManagerNew::loadUserPrefs() -{ - // operate on members directly to avoid side effects - mUserPrefs.mWaterPresetName = gSavedSettings.getString("WaterPresetName"); - mUserPrefs.mSkyPresetName = gSavedSettings.getString("SkyPresetName"); - mUserPrefs.mDayCycleName = gSavedSettings.getString("DayCycleName"); - - bool use_region_settings = gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin") ? gSavedSettings.getBOOL("UseEnvironmentFromRegion") : true; - mUserPrefs.mUseRegionSettings = use_region_settings; - mUserPrefs.mUseDayCycle = gSavedSettings.getBOOL("UseDayCycle"); - - if (mUserPrefs.mUseRegionSettings) - { - requestRegionSettings(); - } -} - -void LLEnvManagerNew::saveUserPrefs() -{ - gSavedSettings.setString("WaterPresetName", getWaterPresetName()); - gSavedSettings.setString("SkyPresetName", getSkyPresetName()); - gSavedSettings.setString("DayCycleName", getDayCycleName()); - - gSavedSettings.setBOOL("UseEnvironmentFromRegion", getUseRegionSettings()); - gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle()); - - mUsePrefsChangeSignal(); -} - -void LLEnvManagerNew::setUserPrefs( - const std::string& water_preset, - const std::string& sky_preset, - const std::string& day_cycle_preset, - bool use_fixed_sky, - bool use_region_settings) -{ - // operate on members directly to avoid side effects - mUserPrefs.mWaterPresetName = water_preset; - mUserPrefs.mSkyPresetName = sky_preset; - mUserPrefs.mDayCycleName = day_cycle_preset; - - mUserPrefs.mUseRegionSettings = use_region_settings; - mUserPrefs.mUseDayCycle = !use_fixed_sky; - - saveUserPrefs(); - updateManagersFromPrefs(false); -} - -void LLEnvManagerNew::dumpUserPrefs() -{ - LL_DEBUGS("Windlight") << "WaterPresetName: " << gSavedSettings.getString("WaterPresetName") << LL_ENDL; - LL_DEBUGS("Windlight") << "SkyPresetName: " << gSavedSettings.getString("SkyPresetName") << LL_ENDL; - LL_DEBUGS("Windlight") << "DayCycleName: " << gSavedSettings.getString("DayCycleName") << LL_ENDL; - - LL_DEBUGS("Windlight") << "UseEnvironmentFromRegion: " << gSavedSettings.getBOOL("UseEnvironmentFromRegion") << LL_ENDL; - LL_DEBUGS("Windlight") << "UseDayCycle: " << gSavedSettings.getBOOL("UseDayCycle") << LL_ENDL; -} - -void LLEnvManagerNew::dumpPresets() -{ - const LLEnvironmentSettings& region_settings = getRegionSettings(); - std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : "Unknown region"; - - // Dump water presets. - LL_DEBUGS("Windlight") << "Waters:" << LL_ENDL; - if (region_settings.getWaterParams().size() != 0) - { - LL_DEBUGS("Windlight") << " - " << region_name << LL_ENDL; - } - LLWaterParamManager::preset_name_list_t water_presets; - LLWaterParamManager::instance().getPresetNames(water_presets); - for (LLWaterParamManager::preset_name_list_t::const_iterator it = water_presets.begin(); it != water_presets.end(); ++it) - { - LL_DEBUGS("Windlight") << " - " << *it << LL_ENDL; - } - - // Dump sky presets. - LL_DEBUGS("Windlight") << "Skies:" << LL_ENDL; - LLWLParamManager::preset_key_list_t sky_preset_keys; - LLWLParamManager::instance().getPresetKeys(sky_preset_keys); - for (LLWLParamManager::preset_key_list_t::const_iterator it = sky_preset_keys.begin(); it != sky_preset_keys.end(); ++it) - { - std::string preset_name = it->name; - std::string item_title; - - if (it->scope == LLEnvKey::SCOPE_LOCAL) // local preset - { - item_title = preset_name; - } - else // region preset - { - item_title = preset_name + " (" + region_name + ")"; - } - LL_DEBUGS("Windlight") << " - " << item_title << LL_ENDL; - } - - // Dump day cycles. - LL_DEBUGS("Windlight") << "Days:" << LL_ENDL; - const LLSD& cur_region_dc = region_settings.getWLDayCycle(); - if (cur_region_dc.size() != 0) - { - LL_DEBUGS("Windlight") << " - " << region_name << LL_ENDL; - } - LLDayCycleManager::preset_name_list_t days; - LLDayCycleManager::instance().getPresetNames(days); - for (LLDayCycleManager::preset_name_list_t::const_iterator it = days.begin(); it != days.end(); ++it) - { - LL_DEBUGS("Windlight") << " - " << *it << LL_ENDL; - } -} - -void LLEnvManagerNew::requestRegionSettings() -{ - LL_DEBUGS("Windlight") << LL_ENDL; - LLEnvironmentRequest::initiate(); -} - -bool LLEnvManagerNew::sendRegionSettings(const LLEnvironmentSettings& new_settings) -{ - LLSD metadata; - - metadata["regionID"] = gAgent.getRegion()->getRegionID(); - // add last received update ID to outbound message so simulator can handle concurrent updates - metadata["messageID"] = mLastReceivedID; - - return LLEnvironmentApply::initiateRequest(new_settings.makePacket(metadata)); -} - -boost::signals2::connection LLEnvManagerNew::setPreferencesChangeCallback(const prefs_change_signal_t::slot_type& cb) -{ - return mUsePrefsChangeSignal.connect(cb); -} - -boost::signals2::connection LLEnvManagerNew::setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb) -{ - return mRegionSettingsChangeSignal.connect(cb); -} - -boost::signals2::connection LLEnvManagerNew::setRegionSettingsAppliedCallback(const region_settings_applied_signal_t::slot_type& cb) -{ - return mRegionSettingsAppliedSignal.connect(cb); -} - -// static -bool LLEnvManagerNew::canEditRegionSettings() -{ - LLViewerRegion* region = gAgent.getRegion(); - BOOL owner_or_god = gAgent.isGodlike() || (region && region->getOwner() == gAgent.getID()); - BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - - LL_DEBUGS("Windlight") << "Can edit region settings: " << (bool) owner_or_god_or_manager << LL_ENDL; - return owner_or_god_or_manager; -} - -// static -const std::string LLEnvManagerNew::getScopeString(LLEnvKey::EScope scope) -{ - switch(scope) - { - case LLEnvKey::SCOPE_LOCAL: - return LLTrans::getString("LocalSettings"); - case LLEnvKey::SCOPE_REGION: - return LLTrans::getString("RegionSettings"); - default: - return " (?)"; - } -} - -void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) -{ - // If the message was valid, grab the UUID from it and save it for next outbound update message. - mLastReceivedID = content[0]["messageID"].asUUID(); - - // Refresh cached region settings. - LL_DEBUGS("Windlight") << "Received region environment settings: " << content << LL_ENDL; - F32 sun_hour = 0; // *TODO - LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); - mCachedRegionPrefs = new_settings; - - // Load region sky presets. - LLWLParamManager::instance().refreshRegionPresets(getRegionSettings().getSkyMap()); - - // If using server settings, update managers. - if (getUseRegionSettings()) - { - updateManagersFromPrefs(mInterpNextChangeMessage); - } - - // Let interested parties know about the region settings update. - mRegionSettingsChangeSignal(); - - // reset - mInterpNextChangeMessage = false; -} - -void LLEnvManagerNew::onRegionSettingsApplyResponse(bool ok) -{ - LL_DEBUGS("Windlight") << "Applying region settings " << (ok ? "succeeded" : "failed") << LL_ENDL; - - // Clear locally modified region settings because they have just been uploaded. - mNewRegionPrefs.clear(); - - mRegionSettingsAppliedSignal(ok); -} - -//-- private methods ---------------------------------------------------------- - -// virtual -void LLEnvManagerNew::initSingleton() -{ - LL_DEBUGS("Windlight") << "Initializing LLEnvManagerNew" << LL_ENDL; - - loadUserPrefs(); - - // preferences loaded, can set params - std::string preferred_day = getDayCycleName(); - if (!useDayCycle(preferred_day, LLEnvKey::SCOPE_LOCAL)) - { - LL_WARNS() << "No day cycle named " << preferred_day << ", reverting LLWLParamManager to defaults" << LL_ENDL; - LLWLParamManager::instance().setDefaultDay(); - } - - std::string sky = getSkyPresetName(); - if (!useSkyPreset(sky)) - { - LL_WARNS() << "No sky preset named " << sky << ", falling back to defaults" << LL_ENDL; - LLWLParamManager::instance().setDefaultSky(); - - // *TODO: Fix user preferences accordingly. - } - - LLWLParamManager::instance().resetAnimator(0.5 /*noon*/, getUseDayCycle()); -} - -void LLEnvManagerNew::updateSkyFromPrefs() -{ - bool success = true; - - // Sync sky with user prefs. - if (getUseRegionSettings()) // apply region-wide settings - { - success = useRegionSky(); - } - else // apply user-specified settings - { - if (getUseDayCycle()) - { - success = useDayCycle(getDayCycleName(), LLEnvKey::SCOPE_LOCAL); - } - else - { - success = useSkyPreset(getSkyPresetName()); - } - } - - // If something went wrong, fall back to defaults. - if (!success) - { - // *TODO: fix user prefs - useDefaultSky(); - } -} - -void LLEnvManagerNew::updateWaterFromPrefs(bool interpolate) -{ - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - LLSD target_water_params; - - // Determine new water settings based on user prefs. - - { - // Fall back to default water. - LLWaterParamSet default_water; - water_mgr.getParamSet("Default", default_water); - target_water_params = default_water.getAll(); - } - - if (getUseRegionSettings()) - { - // *TODO: make sure whether region settings belong to the current region? - const LLSD& region_water_params = getRegionSettings().getWaterParams(); - if (region_water_params.size() != 0) // region has no water settings - { - LL_DEBUGS("Windlight") << "Applying region water" << LL_ENDL; - target_water_params = region_water_params; - } - else - { - LL_DEBUGS("Windlight") << "Applying default water" << LL_ENDL; - } - } - else - { - std::string water = getWaterPresetName(); - LL_DEBUGS("Windlight") << "Applying water preset [" << water << "]" << LL_ENDL; - LLWaterParamSet params; - if (!water_mgr.getParamSet(water, params)) - { - LL_WARNS() << "No water preset named " << water << ", falling back to defaults" << LL_ENDL; - water_mgr.getParamSet("Default", params); - - // *TODO: Fix user preferences accordingly. - } - target_water_params = params.getAll(); - } - - // Sync water with user prefs. - water_mgr.applyParams(target_water_params, interpolate); -} - -void LLEnvManagerNew::updateManagersFromPrefs(bool interpolate) -{ - LL_DEBUGS("Windlight")<<LL_ENDL; - // Apply water settings. - updateWaterFromPrefs(interpolate); - - // Apply sky settings. - updateSkyFromPrefs(); -} - -bool LLEnvManagerNew::useRegionSky() -{ - const LLEnvironmentSettings& region_settings = getRegionSettings(); - - // If region is set to defaults, - if (region_settings.getSkyMap().size() == 0) - { - // well... apply the default sky settings. - useDefaultSky(); - return true; - } - - // Otherwise apply region day cycle/skies. - LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; - - // *TODO: Support fixed sky from region. Just do sky reset for now. - if (region_settings.getSkyMap().size() == 1) - { - // Region is set to fixed sky. Reset. - useSkyParams(region_settings.getSkyMap().beginMap()->second); - } - return useDayCycleParams( - region_settings.getWLDayCycle(), - LLEnvKey::SCOPE_REGION, - region_settings.getDayTime()); -} - -bool LLEnvManagerNew::useRegionWater() -{ - const LLEnvironmentSettings& region_settings = getRegionSettings(); - const LLSD& region_water = region_settings.getWaterParams(); - - // If region is set to defaults, - if (region_water.size() == 0) - { - // well... apply the default water settings. - return useDefaultWater(); - } - - // Otherwise apply region water. - LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; - return useWaterParams(region_water); -} - -bool LLEnvManagerNew::useDefaultSky() -{ - return useDayCycle("Default", LLEnvKey::SCOPE_LOCAL); -} - -bool LLEnvManagerNew::useDefaultWater() -{ - return useWaterPreset("Default"); -} - - -void LLEnvManagerNew::onRegionChange() -{ - // Avoid duplicating region setting requests - // by checking whether the region is actually changing. - LLViewerRegion* regionp = gAgent.getRegion(); - LLUUID region_uuid = regionp ? regionp->getRegionID() : LLUUID::null; - if (region_uuid != mCurRegionUUID) - { - // Clear locally modified region settings. - mNewRegionPrefs.clear(); - - // *TODO: clear environment settings of the previous region? - - // Request environment settings of the new region. - mCurRegionUUID = region_uuid; - // for region crossings, interpolate the change; for teleports, don't - mInterpNextChangeMessage = (gAgent.getTeleportState() == LLAgent::TELEPORT_NONE); - LL_DEBUGS("Windlight") << (mInterpNextChangeMessage ? "Crossed" : "Teleported") - << " to new region: " << region_uuid - << LL_ENDL; - requestRegionSettings(); - } - else - { - LL_DEBUGS("Windlight") << "disregarding region change; interp: " - << (mInterpNextChangeMessage ? "true" : "false") - << " regionp: " << regionp - << " old: " << mCurRegionUUID - << " new: " << region_uuid - << LL_ENDL; - } -} diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h deleted file mode 100644 index 54bbf85e86..0000000000 --- a/indra/newview/llenvmanager.h +++ /dev/null @@ -1,349 +0,0 @@ -/** - * @file llenvmanager.h - * @brief Declaration of classes managing WindLight and water settings. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLENVMANAGER_H -#define LL_LLENVMANAGER_H - -#include "llmemory.h" -#include "llsd.h" - -class LLWLParamManager; -class LLWaterParamManager; -class LLWLAnimator; - -// generic key -struct LLEnvKey -{ -public: - // Note: enum ordering is important; for example, a region-level floater (1) will see local and region (all values that are <=) - typedef enum e_scope - { - SCOPE_LOCAL, // 0 - SCOPE_REGION//, // 1 - // SCOPE_ESTATE, // 2 - // etc. - } EScope; -}; - -struct LLWLParamKey : LLEnvKey -{ -public: - // scope and source of a param set (WL sky preset) - std::string name; - EScope scope; - - // for conversion from LLSD - static const int NAME_IDX = 0; - static const int SCOPE_IDX = 1; - - inline LLWLParamKey(const std::string& n, EScope s) - : name(n), scope(s) - { - } - - inline LLWLParamKey(LLSD llsd) - : name(llsd[NAME_IDX].asString()), scope(EScope(llsd[SCOPE_IDX].asInteger())) - { - } - - inline LLWLParamKey() // NOT really valid, just so std::maps can return a default of some sort - : name(""), scope(SCOPE_LOCAL) - { - } - - inline LLWLParamKey(std::string& stringVal) - { - size_t len = stringVal.length(); - if (len > 0) - { - name = stringVal.substr(0, len - 1); - scope = (EScope) atoi(stringVal.substr(len - 1, len).c_str()); - } - } - - inline std::string toStringVal() const - { - std::stringstream str; - str << name << scope; - return str.str(); - } - - inline LLSD toLLSD() const - { - LLSD llsd = LLSD::emptyArray(); - llsd.append(LLSD(name)); - llsd.append(LLSD(scope)); - return llsd; - } - - inline void fromLLSD(const LLSD& llsd) - { - name = llsd[NAME_IDX].asString(); - scope = EScope(llsd[SCOPE_IDX].asInteger()); - } - - inline bool operator <(const LLWLParamKey other) const - { - if (name < other.name) - { - return true; - } - else if (name > other.name) - { - return false; - } - else - { - return scope < other.scope; - } - } - - inline bool operator ==(const LLWLParamKey other) const - { - return (name == other.name) && (scope == other.scope); - } - - std::string toString() const; -}; - -class LLEnvironmentSettings -{ -public: - LLEnvironmentSettings() : - mWLDayCycle(LLSD::emptyMap()), - mSkyMap(LLSD::emptyMap()), - mWaterParams(LLSD::emptyMap()), - mDayTime(0.f) - {} - LLEnvironmentSettings(const LLSD& dayCycle, const LLSD& skyMap, const LLSD& waterParams, F64 dayTime) : - mWLDayCycle(dayCycle), - mSkyMap(skyMap), - mWaterParams(waterParams), - mDayTime(dayTime) - {} - ~LLEnvironmentSettings() {} - - void saveParams(const LLSD& dayCycle, const LLSD& skyMap, const LLSD& waterParams, F64 dayTime) - { - mWLDayCycle = dayCycle; - mSkyMap = skyMap; - mWaterParams = waterParams; - mDayTime = dayTime; - } - - const LLSD& getWLDayCycle() const - { - return mWLDayCycle; - } - - const LLSD& getWaterParams() const - { - return mWaterParams; - } - - const LLSD& getSkyMap() const - { - return mSkyMap; - } - - F64 getDayTime() const - { - return mDayTime; - } - - bool isEmpty() const - { - return mWLDayCycle.size() == 0; - } - - void clear() - { - *this = LLEnvironmentSettings(); - } - - LLSD makePacket(const LLSD& metadata) const - { - LLSD full_packet = LLSD::emptyArray(); - - // 0: metadata - full_packet.append(metadata); - - // 1: day cycle - full_packet.append(mWLDayCycle); - - // 2: map of sky setting names to sky settings (as LLSD) - full_packet.append(mSkyMap); - - // 3: water params - full_packet.append(mWaterParams); - - return full_packet; - } - -private: - LLSD mWLDayCycle, mWaterParams, mSkyMap; - F64 mDayTime; -}; - -/** - * User environment preferences. - */ -class LLEnvPrefs -{ -public: - LLEnvPrefs() : mUseRegionSettings(true), mUseDayCycle(true) {} - - bool getUseRegionSettings() const { return mUseRegionSettings; } - bool getUseDayCycle() const { return mUseDayCycle; } - bool getUseFixedSky() const { return !getUseDayCycle(); } - - std::string getWaterPresetName() const; - std::string getSkyPresetName() const; - std::string getDayCycleName() const; - - void setUseRegionSettings(bool val); - void setUseWaterPreset(const std::string& name); - void setUseSkyPreset(const std::string& name); - void setUseDayCycle(const std::string& name); - - bool mUseRegionSettings; - bool mUseDayCycle; - std::string mWaterPresetName; - std::string mSkyPresetName; - std::string mDayCycleName; -}; - -/** - * Setting: - * 1. Use region settings. - * 2. Use my setting: <water preset> + <fixed_sky>|<day_cycle> - */ -class LLEnvManagerNew : public LLSingleton<LLEnvManagerNew> -{ - LLSINGLETON(LLEnvManagerNew); - LOG_CLASS(LLEnvManagerNew); -public: - typedef boost::signals2::signal<void()> prefs_change_signal_t; - typedef boost::signals2::signal<void()> region_settings_change_signal_t; - typedef boost::signals2::signal<void(bool)> region_settings_applied_signal_t; - - // getters to access user env. preferences - bool getUseRegionSettings() const; - bool getUseDayCycle() const; - bool getUseFixedSky() const; - std::string getWaterPresetName() const; - std::string getSkyPresetName() const; - std::string getDayCycleName() const; - - /// @return cached env. settings of the current region. - const LLEnvironmentSettings& getRegionSettings() const; - - /** - * Set new region settings without uploading them to the region. - * - * The override will be reset when the changes are applied to the region (=uploaded) - * or user teleports to another region. - */ - void setRegionSettings(const LLEnvironmentSettings& new_settings); - - // Change environment w/o changing user preferences. - bool usePrefs(); - bool useDefaults(); - bool useRegionSettings(); - bool useWaterPreset(const std::string& name); - bool useWaterParams(const LLSD& params); - bool useSkyPreset(const std::string& name); - bool useSkyParams(const LLSD& params); - bool useDayCycle(const std::string& name, LLEnvKey::EScope scope); - bool useDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time = 0.5); - - // setters for user env. preferences - void setUseRegionSettings(bool val); - void setUseWaterPreset(const std::string& name); - void setUseSkyPreset(const std::string& name); - void setUseDayCycle(const std::string& name); - void setUserPrefs( - const std::string& water_preset, - const std::string& sky_preset, - const std::string& day_cycle_preset, - bool use_fixed_sky, - bool use_region_settings); - - // debugging methods - void dumpUserPrefs(); - void dumpPresets(); - - // Misc. - void requestRegionSettings(); - bool sendRegionSettings(const LLEnvironmentSettings& new_settings); - boost::signals2::connection setPreferencesChangeCallback(const prefs_change_signal_t::slot_type& cb); - boost::signals2::connection setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb); - boost::signals2::connection setRegionSettingsAppliedCallback(const region_settings_applied_signal_t::slot_type& cb); - - static bool canEditRegionSettings(); /// @return true if we have access to editing region environment - static const std::string getScopeString(LLEnvKey::EScope scope); - - // Public callbacks. - void onRegionSettingsResponse(const LLSD& content); - void onRegionSettingsApplyResponse(bool ok); - -private: - /*virtual*/ void initSingleton(); - - void loadUserPrefs(); - void saveUserPrefs(); - - void updateSkyFromPrefs(); - void updateWaterFromPrefs(bool interpolate); - void updateManagersFromPrefs(bool interpolate); - - bool useRegionSky(); - bool useRegionWater(); - - bool useDefaultSky(); - bool useDefaultWater(); - - void onRegionChange(); - - /// Emitted when user environment preferences change. - prefs_change_signal_t mUsePrefsChangeSignal; - - /// Emitted when region environment settings update comes. - region_settings_change_signal_t mRegionSettingsChangeSignal; - - /// Emitted when agent region changes. Move to LLAgent? - region_settings_applied_signal_t mRegionSettingsAppliedSignal; - - LLEnvPrefs mUserPrefs; /// User environment preferences. - LLEnvironmentSettings mCachedRegionPrefs; /// Cached region environment settings. - LLEnvironmentSettings mNewRegionPrefs; /// Not-yet-uploaded modified region env. settings. - bool mInterpNextChangeMessage; /// Interpolate env. settings on next region change. - LLUUID mCurRegionUUID; /// To avoid duplicated region env. settings requests. - LLUUID mLastReceivedID; /// Id of last received region env. settings. -}; - -#endif // LL_LLENVMANAGER_H - diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp index 95d40be913..e8da458168 100644 --- a/indra/newview/llestateinfomodel.cpp +++ b/indra/newview/llestateinfomodel.cpp @@ -34,15 +34,101 @@ // viewer #include "llagent.h" -#include "llfloaterregioninfo.h" // for invoice id #include "llviewerregion.h" - #include "llcorehttputil.h" -LLEstateInfoModel::LLEstateInfoModel() -: mID(0) -, mFlags(0) -, mSunHour(0) +//========================================================================= +namespace +{ + class LLDispatchEstateUpdateInfo : public LLDispatchHandler + { + public: + LLDispatchEstateUpdateInfo() {} + virtual ~LLDispatchEstateUpdateInfo() {} + virtual bool operator()(const LLDispatcher* dispatcher, const std::string& key, + const LLUUID& invoice, const sparam_t& strings) + { + // key = "estateupdateinfo" + // strings[0] = estate name + // strings[1] = str(owner_id) + // strings[2] = str(estate_id) + // strings[3] = str(estate_flags) + // strings[4] = str((S32)(sun_hour * 1024)) + // strings[5] = str(parent_estate_id) + // strings[6] = str(covenant_id) + // strings[7] = str(covenant_timestamp) + // strings[8] = str(send_to_agent_only) + // strings[9] = str(abuse_email_addr) + + LL_DEBUGS("ESTATEINFOM") << "Received estate update" << LL_ENDL; + + // Update estate info model. + // This will call LLPanelEstateInfo::refreshFromEstate(). + // *TODO: Move estate message handling stuff to llestateinfomodel.cpp. + LLEstateInfoModel::instance().updateEstateInfo(strings); + + return true; + } + }; + + class LLDispatchSetEstateAccess : public LLDispatchHandler + { + public: + LLDispatchSetEstateAccess() {} + virtual ~LLDispatchSetEstateAccess() {} + virtual bool operator()( + const LLDispatcher* dispatcher, const std::string& key, + const LLUUID& invoice, const sparam_t& strings) + { + // key = "setaccess" + // strings[0] = str(estate_id) + // strings[1] = str(packed_access_lists) + // strings[2] = str(num allowed agent ids) + // strings[3] = str(num allowed group ids) + // strings[4] = str(num banned agent ids) + // strings[5] = str(num estate manager agent ids) + // strings[6] = bin(uuid) + // strings[7] = bin(uuid) + // strings[8] = bin(uuid) + // ... + + LLEstateInfoModel::instance().updateAccessInfo(strings); + + return true; + } + + }; + + class LLDispatchSetEstateExperience : public LLDispatchHandler + { + public: + virtual bool operator()(const LLDispatcher* dispatcher, const std::string& key, + const LLUUID& invoice, const sparam_t& strings) + { + // key = "setexperience" + // strings[0] = str(estate_id) + // strings[1] = str(send_to_agent_only) + // strings[2] = str(num blocked) + // strings[3] = str(num trusted) + // strings[4] = str(num allowed) + // strings[8] = bin(uuid) ... + // ... + + LLEstateInfoModel::instance().updateExperienceInfo(strings); + + return true; + } + + }; + +} + +//========================================================================= +LLEstateInfoModel::LLEstateInfoModel(): + mID(0), + mFlags(0), + mSunHour(0), + mRegion(nullptr) { } @@ -51,38 +137,52 @@ boost::signals2::connection LLEstateInfoModel::setUpdateCallback(const update_si return mUpdateSignal.connect(cb); } +boost::signals2::connection LLEstateInfoModel::setUpdateAccessCallback(const update_flaged_signal_t::slot_type& cb) +{ + return mUpdateAccess.connect(cb); +} + +boost::signals2::connection LLEstateInfoModel::setUpdateExperienceCallback(const update_signal_t::slot_type& cb) +{ + return mUpdateExperience.connect(cb); +} + boost::signals2::connection LLEstateInfoModel::setCommitCallback(const update_signal_t::slot_type& cb) { return mCommitSignal.connect(cb); } +void LLEstateInfoModel::setRegion(LLViewerRegion* region) +{ + if (region != mRegion) + { + mRegion = region; + + if (mRegion) + { + nextInvoice(); + sendEstateOwnerMessage("getinfo", strings_t()); + } + } +} + + +void LLEstateInfoModel::clearRegion() +{ + mRegion = nullptr; +} + void LLEstateInfoModel::sendEstateInfo() { if (!commitEstateInfoCaps()) { // the caps method failed, try the old way - LLFloaterRegionInfo::nextInvoice(); + nextInvoice(); commitEstateInfoDataserver(); } } -bool LLEstateInfoModel::getUseFixedSun() const { return getFlag(REGION_FLAGS_SUN_FIXED); } -bool LLEstateInfoModel::getIsExternallyVisible() const { return getFlag(REGION_FLAGS_EXTERNALLY_VISIBLE); } -bool LLEstateInfoModel::getAllowDirectTeleport() const { return getFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT); } -bool LLEstateInfoModel::getDenyAnonymous() const { return getFlag(REGION_FLAGS_DENY_ANONYMOUS); } -bool LLEstateInfoModel::getDenyAgeUnverified() const { return getFlag(REGION_FLAGS_DENY_AGEUNVERIFIED); } -bool LLEstateInfoModel::getAllowVoiceChat() const { return getFlag(REGION_FLAGS_ALLOW_VOICE); } -bool LLEstateInfoModel::getAllowAccessOverride() const { return getFlag(REGION_FLAGS_ALLOW_ACCESS_OVERRIDE); } - -void LLEstateInfoModel::setUseFixedSun(bool val) { setFlag(REGION_FLAGS_SUN_FIXED, val); } -void LLEstateInfoModel::setIsExternallyVisible(bool val) { setFlag(REGION_FLAGS_EXTERNALLY_VISIBLE, val); } -void LLEstateInfoModel::setAllowDirectTeleport(bool val) { setFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT, val); } -void LLEstateInfoModel::setDenyAnonymous(bool val) { setFlag(REGION_FLAGS_DENY_ANONYMOUS, val); } -void LLEstateInfoModel::setDenyAgeUnverified(bool val) { setFlag(REGION_FLAGS_DENY_AGEUNVERIFIED, val); } -void LLEstateInfoModel::setAllowVoiceChat(bool val) { setFlag(REGION_FLAGS_ALLOW_VOICE, val); } -void LLEstateInfoModel::setAllowAccessOverride(bool val) { setFlag(REGION_FLAGS_ALLOW_ACCESS_OVERRIDE, val); } - -void LLEstateInfoModel::update(const strings_t& strings) +void LLEstateInfoModel::updateEstateInfo(const strings_t& strings) { // NOTE: LLDispatcher extracts strings with an extra \0 at the // end. If we pass the std::string direct to the UI/renderer @@ -93,10 +193,10 @@ void LLEstateInfoModel::update(const strings_t& strings) mFlags = strtoul(strings[3].c_str(), NULL, 10); mSunHour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f; - LL_DEBUGS("WindlightSync") << "Received estate info: " + LL_DEBUGS("ESTATEINFOM") << "Received estate info: " << "is_sun_fixed = " << getUseFixedSun() << ", sun_hour = " << getSunHour() << LL_ENDL; - LL_DEBUGS() << getInfoDump() << LL_ENDL; + LL_DEBUGS("ESTATEINFOM") << getInfoDump() << LL_ENDL; // Update region owner. LLViewerRegion* regionp = gAgent.getRegion(); @@ -106,20 +206,205 @@ void LLEstateInfoModel::update(const strings_t& strings) mUpdateSignal(); } +void LLEstateInfoModel::updateAccessInfo(const strings_t& strings) +{ + S32 index = 1; // skip estate_id + U32 access_flags = strtoul(strings[index++].c_str(), NULL, 10); + S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10); + S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10); + S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10); + S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10); + + // sanity ckecks + if (num_allowed_agents > 0 + && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)) + { + LL_WARNS("ESTATEINFOM") << "non-zero count for allowed agents, but no corresponding flag" << LL_ENDL; + } + if (num_allowed_groups > 0 + && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)) + { + LL_WARNS("ESTATEINFOM") << "non-zero count for allowed groups, but no corresponding flag" << LL_ENDL; + } + if (num_banned_agents > 0 + && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS)) + { + LL_WARNS("ESTATEINFOM") << "non-zero count for banned agents, but no corresponding flag" << LL_ENDL; + } + if (num_estate_managers > 0 + && !(access_flags & ESTATE_ACCESS_MANAGERS)) + { + LL_WARNS("ESTATEINFOM") << "non-zero count for managers, but no corresponding flag" << LL_ENDL; + } + + // grab the UUID's out of the string fields + if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS) + { + mAllowedAgents.clear(); + + for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++) + { + LLUUID id; + memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ + mAllowedAgents.insert(id); + } + } + + if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS) + { + mAllowedGroups.clear(); + + for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++) + { + LLUUID id; + memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ + mAllowedGroups.insert(id); + } + } + + if (access_flags & ESTATE_ACCESS_BANNED_AGENTS) + { + mBannedAgents.clear(); + + for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++) + { + LLUUID id; + memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ + mBannedAgents.insert(id); + } + } + + if (access_flags & ESTATE_ACCESS_MANAGERS) + { + mEstateManagers.clear(); + + // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't + // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, + // and they can still remove them. + for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++) + { + LLUUID id; + memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ + mEstateManagers.insert(id); + } + } + + // Update the buttons which may change based on the list contents but also needs to account for general access features. + mUpdateAccess(access_flags); +} + +void LLEstateInfoModel::updateExperienceInfo(const strings_t& strings) +{ + strings_t::const_iterator it = strings.begin(); + ++it; // U32 estate_id = strtol((*it).c_str(), NULL, 10); + ++it; // U32 send_to_agent_only = strtoul((*(++it)).c_str(), NULL, 10); + + LLUUID id; + S32 num_blocked = strtol((*(it++)).c_str(), NULL, 10); + S32 num_trusted = strtol((*(it++)).c_str(), NULL, 10); + S32 num_allowed = strtol((*(it++)).c_str(), NULL, 10); + + mExperienceAllowed.clear(); + mExperienceTrusted.clear(); + mExperienceBlocked.clear(); + + while (num_blocked-- > 0) + { + memcpy(id.mData, (*(it++)).data(), UUID_BYTES); + mExperienceBlocked.insert(id); + } + + while (num_trusted-- > 0) + { + memcpy(id.mData, (*(it++)).data(), UUID_BYTES); + mExperienceTrusted.insert(id); + } + + while (num_allowed-- > 0) + { + memcpy(id.mData, (*(it++)).data(), UUID_BYTES); + mExperienceAllowed.insert(id); + } + + mUpdateExperience(); +} + void LLEstateInfoModel::notifyCommit() { mCommitSignal(); } +void LLEstateInfoModel::initSingleton() +{ + gMessageSystem->setHandlerFunc("EstateOwnerMessage", &processEstateOwnerRequest); + + // name.assign("setowner"); + // static LLDispatchSetEstateOwner set_owner; + // dispatch.addHandler(name, &set_owner); + + static LLDispatchEstateUpdateInfo estate_update_info; + mDispatch.addHandler("estateupdateinfo", &estate_update_info); + + static LLDispatchSetEstateAccess set_access; + mDispatch.addHandler("setaccess", &set_access); + + static LLDispatchSetEstateExperience set_experience; + mDispatch.addHandler("setexperience", &set_experience); + +} + +void LLEstateInfoModel::sendEstateOwnerMessage(const std::string& request, const strings_t& strings) +{ + if (!mRegion) + { + LL_WARNS("ESTATEINFOM") << "No selected region." << LL_ENDL; + return; + } + LLMessageSystem* msg(gMessageSystem); + LLUUID invoice(LLEstateInfoModel::instance().getLastInvoice()); + + LL_INFOS() << "Sending estate request '" << request << "'" << LL_ENDL; + msg->newMessage("EstateOwnerMessage"); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used + msg->nextBlock("MethodData"); + msg->addString("Method", request); + msg->addUUID("Invoice", invoice); + if (strings.empty()) + { + msg->nextBlock("ParamList"); + msg->addString("Parameter", NULL); + } + else + { + strings_t::const_iterator it = strings.begin(); + strings_t::const_iterator end = strings.end(); + for (; it != end; ++it) + { + msg->nextBlock("ParamList"); + msg->addString("Parameter", *it); + } + } + msg->sendReliable(mRegion->getHost()); +} + //== PRIVATE STUFF ============================================================ // tries to send estate info using a cap; returns true if it succeeded bool LLEstateInfoModel::commitEstateInfoCaps() { - std::string url = gAgent.getRegionCapability("EstateChangeInfo"); + if (!mRegion) + { + LL_WARNS("ESTATEINFOM") << "Attempt to update estate caps with no anchor region! Don't do that!" << LL_ENDL; + return false; + } + std::string url = mRegion->getCapability("EstateChangeInfo"); if (url.empty()) { + LL_WARNS("ESTATEINFOM") << "No EstateChangeInfo cap from region." << LL_ENDL; // whoops, couldn't find the cap, so bail out return false; } @@ -148,13 +433,14 @@ void LLEstateInfoModel::commitEstateInfoCapsCoro(std::string url) body["deny_age_unverified"] = getDenyAgeUnverified(); body["allow_voice_chat"] = getAllowVoiceChat(); body["override_public_access"] = getAllowAccessOverride(); + body["override_environment"] = getAllowEnvironmentOverride(); - body["invoice"] = LLFloaterRegionInfo::getLastInvoice(); + body["invoice"] = getLastInvoice(); - LL_DEBUGS("WindlightSync") << "Sending estate caps: " + LL_DEBUGS("ESTATEINFOM") << "Sending estate caps: " << "is_sun_fixed = " << getUseFixedSun() << ", sun_hour = " << getSunHour() << LL_ENDL; - LL_DEBUGS() << body << LL_ENDL; + LL_DEBUGS("ESTATEINFOM") << body << LL_ENDL; LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body); @@ -163,12 +449,12 @@ void LLEstateInfoModel::commitEstateInfoCapsCoro(std::string url) if (status) { - LL_INFOS() << "Committed estate info" << LL_ENDL; + LL_INFOS("ESTATEINFOM") << "Committed estate info" << LL_ENDL; LLEstateInfoModel::instance().notifyCommit(); } else { - LL_WARNS() << "Failed to commit estate info " << LL_ENDL; + LL_WARNS("ESTATEINFOM") << "Failed to commit estate info " << LL_ENDL; } } @@ -181,10 +467,15 @@ void LLEstateInfoModel::commitEstateInfoCapsCoro(std::string url) // strings[3] = str((S32)(sun_hour * 1024.f)) void LLEstateInfoModel::commitEstateInfoDataserver() { - LL_DEBUGS("WindlightSync") << "Sending estate info: " + if (!mRegion) + { + LL_WARNS("ESTATEINFOM") << "No selected region." << LL_ENDL; + return; + } + LL_DEBUGS("ESTATEINFOM") << "Sending estate info: " << "is_sun_fixed = " << getUseFixedSun() << ", sun_hour = " << getSunHour() << LL_ENDL; - LL_DEBUGS() << getInfoDump() << LL_ENDL; + LL_DEBUGS("ESTATEINFOM") << getInfoDump() << LL_ENDL; LLMessageSystem* msg = gMessageSystem; msg->newMessage("EstateOwnerMessage"); @@ -195,7 +486,7 @@ void LLEstateInfoModel::commitEstateInfoDataserver() msg->nextBlock("MethodData"); msg->addString("Method", "estatechangeinfo"); - msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); + msg->addUUID("Invoice", getLastInvoice()); msg->nextBlock("ParamList"); msg->addString("Parameter", getName()); @@ -206,7 +497,7 @@ void LLEstateInfoModel::commitEstateInfoDataserver() msg->nextBlock("ParamList"); msg->addString("Parameter", llformat("%d", (S32) (getSunHour() * 1024.0f))); - gAgent.sendMessage(); + msg->sendReliable(mRegion->getHost()); } std::string LLEstateInfoModel::getInfoDump() @@ -222,8 +513,28 @@ std::string LLEstateInfoModel::getInfoDump() dump["deny_age_unverified" ] = getDenyAgeUnverified(); dump["allow_voice_chat" ] = getAllowVoiceChat(); dump["override_public_access"] = getAllowAccessOverride(); + dump["override_environment"] = getAllowEnvironmentOverride(); std::stringstream dump_str; dump_str << dump; return dump_str.str(); } + +// static +void LLEstateInfoModel::processEstateOwnerRequest(LLMessageSystem* msg, void**) +{ + // unpack the message + std::string request; + LLUUID invoice; + LLDispatcher::sparam_t strings; + LLDispatcher::unpackMessage(msg, request, invoice, strings); + if (invoice != LLEstateInfoModel::instance().getLastInvoice()) + { + LL_WARNS("ESTATEINFOM") << "Mismatched Estate message: " << request << LL_ENDL; + return; + } + + //dispatch the message + LLEstateInfoModel::instance().mDispatch.dispatch(request, invoice, strings); +} + diff --git a/indra/newview/llestateinfomodel.h b/indra/newview/llestateinfomodel.h index 0082b5b1f4..2c89a85500 100644 --- a/indra/newview/llestateinfomodel.h +++ b/indra/newview/llestateinfomodel.h @@ -32,76 +32,123 @@ class LLMessageSystem; #include "llsingleton.h" #include "llcoros.h" #include "lleventcoro.h" +#include "lldispatcher.h" +#include "llregionflags.h" +class LLViewerRegion; /** * Contains estate info, notifies interested parties of its changes. */ class LLEstateInfoModel : public LLSingleton<LLEstateInfoModel> { - LLSINGLETON(LLEstateInfoModel); + LLSINGLETON_C11(LLEstateInfoModel); LOG_CLASS(LLEstateInfoModel); public: - typedef boost::signals2::signal<void()> update_signal_t; - boost::signals2::connection setUpdateCallback(const update_signal_t::slot_type& cb); /// the model has been externally updated - boost::signals2::connection setCommitCallback(const update_signal_t::slot_type& cb); /// our changes have been applied + typedef std::vector<std::string> strings_t; + typedef boost::signals2::signal<void()> update_signal_t; + typedef boost::signals2::signal<void(U32)> update_flaged_signal_t; + typedef boost::signals2::connection connection_t; - void sendEstateInfo(); /// send estate info to the simulator + connection_t setUpdateCallback(const update_signal_t::slot_type& cb); /// the model has been externally updated + connection_t setUpdateAccessCallback(const update_flaged_signal_t::slot_type& cb); + connection_t setUpdateExperienceCallback(const update_signal_t::slot_type& cb); + connection_t setCommitCallback(const update_signal_t::slot_type& cb); /// our changes have been applied + + void setRegion(LLViewerRegion* region); + void clearRegion(); + void sendEstateInfo(); /// send estate info to the simulator // getters - bool getUseFixedSun() const; - bool getIsExternallyVisible() const; - bool getAllowDirectTeleport() const; - bool getDenyAnonymous() const; - bool getDenyAgeUnverified() const; - bool getAllowVoiceChat() const; - bool getAllowAccessOverride() const; - - const std::string& getName() const { return mName; } - const LLUUID& getOwnerID() const { return mOwnerID; } - U32 getID() const { return mID; } - F32 getSunHour() const { return getUseFixedSun() ? mSunHour : 0.f; } + bool getUseFixedSun() const { return getFlag(REGION_FLAGS_SUN_FIXED); } + bool getIsExternallyVisible() const { return getFlag(REGION_FLAGS_EXTERNALLY_VISIBLE); } + bool getAllowDirectTeleport() const { return getFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT); } + bool getDenyAnonymous() const { return getFlag(REGION_FLAGS_DENY_ANONYMOUS); } + bool getDenyAgeUnverified() const { return getFlag(REGION_FLAGS_DENY_AGEUNVERIFIED); } + bool getAllowVoiceChat() const { return getFlag(REGION_FLAGS_ALLOW_VOICE); } + bool getAllowAccessOverride() const { return getFlag(REGION_FLAGS_ALLOW_ACCESS_OVERRIDE); } + bool getAllowEnvironmentOverride() const { return getFlag(REGION_FLAGS_ALLOW_ENVIRONMENT_OVERRIDE); } + + const std::string& getName() const { return mName; } + const LLUUID& getOwnerID() const { return mOwnerID; } + U32 getID() const { return mID; } + F32 getSunHour() const { return getUseFixedSun() ? mSunHour : 0.f; } // setters - void setUseFixedSun(bool val); - void setIsExternallyVisible(bool val); - void setAllowDirectTeleport(bool val); - void setDenyAnonymous(bool val); - void setDenyAgeUnverified(bool val); - void setAllowVoiceChat(bool val); - void setAllowAccessOverride(bool val); + void setUseFixedSun(bool val) { setFlag(REGION_FLAGS_SUN_FIXED, val); } + void setIsExternallyVisible(bool val) { setFlag(REGION_FLAGS_EXTERNALLY_VISIBLE, val); } + void setAllowDirectTeleport(bool val) { setFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT, val); } + void setDenyAnonymous(bool val) { setFlag(REGION_FLAGS_DENY_ANONYMOUS, val); } + void setDenyAgeUnverified(bool val) { setFlag(REGION_FLAGS_DENY_AGEUNVERIFIED, val); } + void setAllowVoiceChat(bool val) { setFlag(REGION_FLAGS_ALLOW_VOICE, val); } + void setAllowAccessOverride(bool val) { setFlag(REGION_FLAGS_ALLOW_ACCESS_OVERRIDE, val); } + void setAllowEnvironmentOverride(bool val) { setFlag(REGION_FLAGS_ALLOW_ENVIRONMENT_OVERRIDE, val); } - void setSunHour(F32 sun_hour) { mSunHour = sun_hour; } + void setSunHour(F32 sun_hour) { mSunHour = sun_hour; } -protected: - typedef std::vector<std::string> strings_t; + const uuid_set_t & getAllowedAgents() const { return mAllowedAgents; } + const uuid_set_t & getAllowedGroups() const { return mAllowedGroups; } + const uuid_set_t & getBannedAgents() const { return mBannedAgents; } + const uuid_set_t & getEstateManagers() const { return mEstateManagers; } + + const uuid_set_t & getAllowedExperiences() const { return mExperienceAllowed; } + const uuid_set_t & getTrustedExperiences() const { return mExperienceTrusted; } + const uuid_set_t & getBlockedExperiences() const { return mExperienceBlocked; } + + void sendEstateOwnerMessage(const std::string& request, const strings_t& strings); + + //--------------------------------------------------------------------- + /// refresh model with data from the incoming server message + void updateEstateInfo(const strings_t& strings); + void updateAccessInfo(const strings_t& strings); + void updateExperienceInfo(const strings_t& strings); + + const LLUUID & getLastInvoice() { return mRequestInvoice; } + const LLUUID & nextInvoice() { mRequestInvoice.generate(); return mRequestInvoice; } - friend class LLDispatchEstateUpdateInfo; +protected: - /// refresh model with data from the incoming server message - void update(const strings_t& strings); + void notifyCommit(); - void notifyCommit(); + virtual void initSingleton() override; private: - bool commitEstateInfoCaps(); - void commitEstateInfoDataserver(); - inline bool getFlag(U64 flag) const; - inline void setFlag(U64 flag, bool val); - U64 getFlags() const { return mFlags; } - std::string getInfoDump(); + bool commitEstateInfoCaps(); + void commitEstateInfoDataserver(); + inline bool getFlag(U64 flag) const; + inline void setFlag(U64 flag, bool val); + U64 getFlags() const { return mFlags; } + std::string getInfoDump(); // estate info - std::string mName; /// estate name - LLUUID mOwnerID; /// estate owner id - U32 mID; /// estate id - U64 mFlags; /// estate flags - F32 mSunHour; /// estate sun hour + std::string mName; /// estate name + LLUUID mOwnerID; /// estate owner id + U32 mID; /// estate id + U64 mFlags; /// estate flags + F32 mSunHour; /// estate sun hour + + uuid_set_t mAllowedAgents; + uuid_set_t mAllowedGroups; + uuid_set_t mBannedAgents; + uuid_set_t mEstateManagers; + + uuid_set_t mExperienceAllowed; + uuid_set_t mExperienceTrusted; + uuid_set_t mExperienceBlocked; + + update_signal_t mUpdateSignal; /// emitted when we receive update from sim + update_flaged_signal_t mUpdateAccess; + update_signal_t mUpdateExperience; + update_signal_t mCommitSignal; /// emitted when our update gets applied to sim + + LLDispatcher mDispatch; + LLUUID mRequestInvoice; + LLViewerRegion* mRegion; + + void commitEstateInfoCapsCoro(std::string url); - update_signal_t mUpdateSignal; /// emitted when we receive update from sim - update_signal_t mCommitSignal; /// emitted when our update gets applied to sim + static void processEstateOwnerRequest(LLMessageSystem* msg, void**); - void commitEstateInfoCapsCoro(std::string url); }; inline bool LLEstateInfoModel::getFlag(U64 flag) const diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 5e0f3ab7f9..299fffd9ab 100644 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -106,6 +106,7 @@ namespace Details LLSD message; message["sender"] = mSenderIp; message["body"] = content["body"]; + LLMessageSystem::dispatch(msg_name, message); } @@ -241,7 +242,7 @@ namespace Details !result.get("events") || !result.get("id")) { - LL_WARNS("LLEventPollImpl") << " <" << counter << "> received event poll with no events or id key: " << LLSDXMLStreamer(result) << LL_ENDL; + LL_WARNS("LLEventPollImpl") << " <" << counter << "> received event poll with no events or id key: " << result << LL_ENDL; continue; } @@ -254,7 +255,7 @@ namespace Details } // was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG - LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> " << events.size() << "events (id " << LLSDXMLStreamer(acknowledge) << ")" << LL_ENDL; + LL_DEBUGS("LLEventPollImpl") << " <" << counter << "> " << events.size() << "events (id " << acknowledge << ")" << LL_ENDL; LLSD::array_const_iterator i = events.beginArray(); LLSD::array_const_iterator end = events.endArray(); diff --git a/indra/newview/llexperiencelog.h b/indra/newview/llexperiencelog.h index 09e0cd8821..5cc5bf685f 100644 --- a/indra/newview/llexperiencelog.h +++ b/indra/newview/llexperiencelog.h @@ -62,10 +62,9 @@ public: static std::string getPermissionString(const LLSD& message, const std::string& base); void setEventsToSave(LLSD new_events){mEventsToSave = new_events; } bool isNotExpired(std::string& date); -protected: void handleExperienceMessage(LLSD& message); - +protected: void loadEvents(); void saveEvents(); void eraseExpired(); diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 4f18cda92f..6d0e999845 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -306,6 +306,11 @@ void LLFace::setDiffuseMap(LLViewerTexture* tex) setTexture(LLRender::DIFFUSE_MAP, tex); } +void LLFace::setAlternateDiffuseMap(LLViewerTexture* tex) +{ + setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, tex); +} + void LLFace::setNormalMap(LLViewerTexture* tex) { setTexture(LLRender::NORMAL_MAP, tex); @@ -384,16 +389,20 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture) return; } - llassert(mTexture[ch].notNull()); - - new_texture->addTextureStats(mTexture[ch]->getMaxVirtualSize()) ; + if (mTexture[ch].notNull()) + { + new_texture->addTextureStats(mTexture[ch]->getMaxVirtualSize()) ; + } if (ch == LLRender::DIFFUSE_MAP) { - getViewerObject()->changeTEImage(mTEOffset, new_texture) ; + if (getViewerObject()) + { + getViewerObject()->changeTEImage(mTEOffset, new_texture); + } } - setTexture(ch, new_texture) ; + setTexture(ch, new_texture); dirtyTexture(); } @@ -1601,7 +1610,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, // that emboss mapping always shows up on the upward faces of cubes when // it's noon (since a lot of builders build with the sun forced to noon). LLVector3 sun_ray = gSky.mVOSkyp->mBumpSunDir; - LLVector3 moon_ray = gSky.getMoonDirection(); + LLVector3 moon_ray = gSky.mVOSkyp->getMoon().getDirection(); LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray; bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV); diff --git a/indra/newview/llface.h b/indra/newview/llface.h index ee545acb94..8531df8561 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -106,6 +106,7 @@ public: void setDiffuseMap(LLViewerTexture* tex); void setNormalMap(LLViewerTexture* tex); void setSpecularMap(LLViewerTexture* tex); + void setAlternateDiffuseMap(LLViewerTexture* tex); void switchTexture(U32 ch, LLViewerTexture* new_texture); void dirtyTexture(); LLXformMatrix* getXform() const { return mXform; } diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index c5561fe011..abf7b7f39d 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -361,59 +361,8 @@ void LLFloaterAvatarPicker::populateFriend() void LLFloaterAvatarPicker::drawFrustum() { - if(mFrustumOrigin.get()) - { - LLView * frustumOrigin = mFrustumOrigin.get(); - LLRect origin_rect; - frustumOrigin->localRectToOtherView(frustumOrigin->getLocalRect(), &origin_rect, this); - // draw context cone connecting color picker with color swatch in parent floater - LLRect local_rect = getLocalRect(); - if (hasFocus() && frustumOrigin->isInVisibleChain() && mContextConeOpacity > 0.001f) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLEnable(GL_CULL_FACE); - gGL.begin(LLRender::QUADS); - { - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mTop); - gGL.vertex2i(origin_rect.mRight, origin_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mBottom); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mRight, origin_rect.mTop); - gGL.vertex2i(origin_rect.mRight, origin_rect.mBottom); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mRight, origin_rect.mBottom); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mBottom); - } - gGL.end(); - } - - if (gFocusMgr.childHasMouseCapture(getDragHandle())) - { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLSmoothInterpolation::getInterpolant(mContextConeFadeTime)); - } - else - { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLSmoothInterpolation::getInterpolant(mContextConeFadeTime)); - } - } + static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, mFrustumOrigin.get(), mContextConeFadeTime, mContextConeInAlpha, mContextConeOutAlpha); } void LLFloaterAvatarPicker::draw() diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index f2040bc760..a1a06706bc 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -75,6 +75,7 @@ BOOL LLFloaterBulkPermission::postBuild() mBulkChangeIncludeScripts = gSavedSettings.getBOOL("BulkChangeIncludeScripts"); mBulkChangeIncludeSounds = gSavedSettings.getBOOL("BulkChangeIncludeSounds"); mBulkChangeIncludeTextures = gSavedSettings.getBOOL("BulkChangeIncludeTextures"); + mBulkChangeIncludeSettings = gSavedSettings.getBOOL("BulkChangeIncludeSettings"); mBulkChangeShareWithGroup = gSavedSettings.getBOOL("BulkChangeShareWithGroup"); mBulkChangeEveryoneCopy = gSavedSettings.getBOOL("BulkChangeEveryoneCopy"); mBulkChangeNextOwnerModify = gSavedSettings.getBOOL("BulkChangeNextOwnerModify"); @@ -186,6 +187,7 @@ void LLFloaterBulkPermission::onCloseBtn() gSavedSettings.setBOOL("BulkChangeIncludeScripts", mBulkChangeIncludeScripts); gSavedSettings.setBOOL("BulkChangeIncludeSounds", mBulkChangeIncludeSounds); gSavedSettings.setBOOL("BulkChangeIncludeTextures", mBulkChangeIncludeTextures); + gSavedSettings.setBOOL("BulkChangeIncludeSettings", mBulkChangeIncludeSettings); gSavedSettings.setBOOL("BulkChangeShareWithGroup", mBulkChangeShareWithGroup); gSavedSettings.setBOOL("BulkChangeEveryoneCopy", mBulkChangeEveryoneCopy); gSavedSettings.setBOOL("BulkChangeNextOwnerModify", mBulkChangeNextOwnerModify); @@ -281,6 +283,7 @@ void LLFloaterBulkPermission::doCheckUncheckAll(BOOL check) gSavedSettings.setBOOL("BulkChangeIncludeScripts" , check); gSavedSettings.setBOOL("BulkChangeIncludeSounds" , check); gSavedSettings.setBOOL("BulkChangeIncludeTextures" , check); + gSavedSettings.setBOOL("BulkChangeIncludeSettings" , check); } @@ -302,6 +305,7 @@ void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, LLInve ( asstype == LLAssetType::AT_OBJECT && gSavedSettings.getBOOL("BulkChangeIncludeObjects" )) || ( asstype == LLAssetType::AT_LSL_TEXT && gSavedSettings.getBOOL("BulkChangeIncludeScripts" )) || ( asstype == LLAssetType::AT_SOUND && gSavedSettings.getBOOL("BulkChangeIncludeSounds" )) || + ( asstype == LLAssetType::AT_SETTINGS && gSavedSettings.getBOOL("BulkChangeIncludeSettings" )) || ( asstype == LLAssetType::AT_TEXTURE && gSavedSettings.getBOOL("BulkChangeIncludeTextures" ))) { LLViewerObject* object = gObjectList.findObject(viewer_obj->getID()); @@ -333,7 +337,12 @@ void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, LLInve //|| something else // for next owner perms ) { - perm.setMaskNext(LLFloaterPerms::getNextOwnerPerms("BulkChange")); + U32 mask_next = LLFloaterPerms::getNextOwnerPerms("BulkChange"); + if (asstype == LLAssetType::AT_SETTINGS) + { + mask_next |= PERM_COPY; + } + perm.setMaskNext(mask_next); perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("BulkChange")); perm.setMaskGroup(LLFloaterPerms::getGroupPerms("BulkChange")); new_item->setPermissions(perm); // here's the beef diff --git a/indra/newview/llfloaterbulkpermission.h b/indra/newview/llfloaterbulkpermission.h index 0c042c3ee3..1afc876bba 100644 --- a/indra/newview/llfloaterbulkpermission.h +++ b/indra/newview/llfloaterbulkpermission.h @@ -102,6 +102,7 @@ private: bool mBulkChangeIncludeScripts; bool mBulkChangeIncludeSounds; bool mBulkChangeIncludeTextures; + bool mBulkChangeIncludeSettings; bool mBulkChangeShareWithGroup; bool mBulkChangeEveryoneCopy; bool mBulkChangeNextOwnerModify; diff --git a/indra/newview/llfloaterbuy.cpp b/indra/newview/llfloaterbuy.cpp index 5a9cdbba44..4d3ebcda1e 100644 --- a/indra/newview/llfloaterbuy.cpp +++ b/indra/newview/llfloaterbuy.cpp @@ -241,7 +241,7 @@ void LLFloaterBuy::inventoryChanged(LLViewerObject* obj, BOOL item_is_multi = FALSE; if (( inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_LANDMARK_VISITED || inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS) - && !(inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK)) + && !(inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_SUBTYPE_MASK)) { item_is_multi = TRUE; } diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp index 4607b4ac41..440ec06c4e 100644 --- a/indra/newview/llfloaterbuycontents.cpp +++ b/indra/newview/llfloaterbuycontents.cpp @@ -216,7 +216,7 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj, BOOL item_is_multi = FALSE; if ((inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_LANDMARK_VISITED || inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS) - && !(inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK)) + && !(inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_SUBTYPE_MASK)) { item_is_multi = TRUE; } diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index ec2c9740af..1a784223c2 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -485,56 +485,8 @@ BOOL LLFloaterColorPicker::isColorChanged() // void LLFloaterColorPicker::draw() { - LLRect swatch_rect; - mSwatch->localRectToOtherView(mSwatch->getLocalRect(), &swatch_rect, this); - // draw context cone connecting color picker with color swatch in parent floater - LLRect local_rect = getLocalRect(); - if (hasFocus() && mSwatch->isInVisibleChain() && mContextConeOpacity > 0.001f) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLEnable(GL_CULL_FACE); - gGL.begin(LLRender::QUADS); - { - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mTop); - gGL.vertex2i(swatch_rect.mRight, swatch_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mBottom); - gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(swatch_rect.mRight, swatch_rect.mTop); - gGL.vertex2i(swatch_rect.mRight, swatch_rect.mBottom); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(swatch_rect.mRight, swatch_rect.mBottom); - gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mBottom); - } - gGL.end(); - } - - if (gFocusMgr.childHasMouseCapture(getDragHandle())) - { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), - LLSmoothInterpolation::getInterpolant(mContextConeFadeTime)); - } - else - { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLSmoothInterpolation::getInterpolant(mContextConeFadeTime)); - } + static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, mSwatch, mContextConeFadeTime, mContextConeInAlpha, mContextConeOutAlpha); mPipetteBtn->setToggleState(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); mApplyImmediateCheck->setEnabled(mActive && mCanApplyImmediately); diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp deleted file mode 100644 index bb11c813b4..0000000000 --- a/indra/newview/llfloaterdeleteenvpreset.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/** - * @file llfloaterdeleteenvpreset.cpp - * @brief Floater to delete a water / sky / day cycle preset. - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llfloaterdeleteenvpreset.h" - -// libs -#include "llbutton.h" -#include "llcombobox.h" -#include "llnotificationsutil.h" - -// newview -#include "lldaycyclemanager.h" -#include "llwaterparammanager.h" - -static bool confirmation_callback(const LLSD& notification, const LLSD& response, boost::function<void()> cb) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option == 0) - { - cb(); - } - return false; - -} - -LLFloaterDeleteEnvPreset::LLFloaterDeleteEnvPreset(const LLSD &key) -: LLFloater(key) -, mPresetCombo(NULL) -{ -} - -// virtual -BOOL LLFloaterDeleteEnvPreset::postBuild() -{ - mPresetCombo = getChild<LLComboBox>("preset_combo"); - mPresetCombo->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::postPopulate, this)); - - getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnDelete, this)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnCancel, this)); - - // Listen to user preferences change, in which case we need to rebuild the presets list - // to disable the [new] current preset. - LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populatePresetsList, this)); - - // Listen to presets addition/removal. - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateDayCyclesList, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateSkyPresetsList, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateWaterPresetsList, this)); - - return TRUE; -} - -// virtual -void LLFloaterDeleteEnvPreset::onOpen(const LLSD& key) -{ - std::string param = key.asString(); - std::string floater_title = getString(std::string("title_") + param); - std::string combo_label = getString(std::string("label_" + param)); - - // Update floater title. - setTitle(floater_title); - - // Update the combobox label. - getChild<LLUICtrl>("label")->setValue(combo_label); - - // Populate the combobox. - populatePresetsList(); -} - -void LLFloaterDeleteEnvPreset::onBtnDelete() -{ - std::string param = mKey.asString(); - std::string preset_name = mPresetCombo->getValue().asString(); - boost::function<void()> confirm_cb; - - if (param == "water") - { - // Don't allow deleting system presets. - if (LLWaterParamManager::instance().isSystemPreset(preset_name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - confirm_cb = boost::bind(&LLFloaterDeleteEnvPreset::onDeleteWaterPresetConfirmation, this); - } - else if (param == "sky") - { - // Don't allow deleting presets referenced by local day cycles. - if (LLDayCycleManager::instance().isSkyPresetReferenced(preset_name)) - { - LLNotificationsUtil::add("GenericAlert", LLSD().with("MESSAGE", getString("msg_sky_is_referenced"))); - return; - } - - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - - // Don't allow deleting system presets. - if (wl_mgr.isSystemPreset(preset_name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - confirm_cb = boost::bind(&LLFloaterDeleteEnvPreset::onDeleteSkyPresetConfirmation, this); - } - else if (param == "day_cycle") - { - LLDayCycleManager& day_mgr = LLDayCycleManager::instance(); - - // Don't allow deleting system presets. - if (day_mgr.isSystemPreset(preset_name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - confirm_cb = boost::bind(&LLFloaterDeleteEnvPreset::onDeleteDayCycleConfirmation, this); - } - else - { - LL_WARNS() << "Unrecognized key" << LL_ENDL; - } - - LLSD args; - args["MESSAGE"] = getString("msg_confirm_deletion"); - LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), - boost::bind(&confirmation_callback, _1, _2, confirm_cb)); -} - -void LLFloaterDeleteEnvPreset::onBtnCancel() -{ - closeFloater(); -} - -void LLFloaterDeleteEnvPreset::populatePresetsList() -{ - std::string param = mKey.asString(); - - if (param == "water") - { - populateWaterPresetsList(); - } - else if (param == "sky") - { - populateSkyPresetsList(); - } - else if (param == "day_cycle") - { - populateDayCyclesList(); - } - else - { - LL_WARNS() << "Unrecognized key" << LL_ENDL; - } -} - -void LLFloaterDeleteEnvPreset::populateWaterPresetsList() -{ - if (mKey.asString() != "water") return; - - mPresetCombo->removeall(); - - std::string cur_preset; - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - if (!env_mgr.getUseRegionSettings()) - { - cur_preset = env_mgr.getWaterPresetName(); - } - - LLWaterParamManager::preset_name_list_t presets; - LLWaterParamManager::instance().getUserPresetNames(presets); // list only user presets - for (LLWaterParamManager::preset_name_list_t::const_iterator it = presets.begin(); it != presets.end(); ++it) - { - std::string name = *it; - - bool enabled = (name != cur_preset); // don't allow deleting current preset - mPresetCombo->add(name, ADD_BOTTOM, enabled); - } - - postPopulate(); -} - -void LLFloaterDeleteEnvPreset::populateSkyPresetsList() -{ - if (mKey.asString() != "sky") return; - - mPresetCombo->removeall(); - - std::string cur_preset; - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - if (!env_mgr.getUseRegionSettings() && env_mgr.getUseFixedSky()) - { - cur_preset = env_mgr.getSkyPresetName(); - } - - LLWLParamManager::preset_name_list_t user_presets; - LLWLParamManager::instance().getUserPresetNames(user_presets); - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - const std::string& name = *it; - mPresetCombo->add(name, ADD_BOTTOM, /*enabled = */ name != cur_preset); - } - - postPopulate(); -} - -void LLFloaterDeleteEnvPreset::populateDayCyclesList() -{ - if (mKey.asString() != "day_cycle") return; - - mPresetCombo->removeall(); - - std::string cur_day; - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - if (!env_mgr.getUseRegionSettings() && env_mgr.getUseDayCycle()) - { - cur_day = env_mgr.getDayCycleName(); - } - - LLDayCycleManager& day_mgr = LLDayCycleManager::instance(); - LLDayCycleManager::preset_name_list_t user_days; - day_mgr.getUserPresetNames(user_days); // list only user presets - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - const std::string& name = *it; - mPresetCombo->add(name, ADD_BOTTOM, name != cur_day); - } - - postPopulate(); -} - -void LLFloaterDeleteEnvPreset::postPopulate() -{ - // Handle empty list and empty selection. - bool has_selection = mPresetCombo->getItemCount() > 0 && mPresetCombo->getSelectedValue().isDefined(); - - if (!has_selection) - { - mPresetCombo->setLabel(getString("combo_label")); - } - - getChild<LLButton>("delete")->setEnabled(has_selection); -} - -void LLFloaterDeleteEnvPreset::onDeleteDayCycleConfirmation() -{ - LLDayCycleManager::instance().deletePreset(mPresetCombo->getValue().asString()); -} - -void LLFloaterDeleteEnvPreset::onDeleteSkyPresetConfirmation() -{ - LLWLParamKey key(mPresetCombo->getValue().asString(), LLEnvKey::SCOPE_LOCAL); - LLWLParamManager::instance().removeParamSet(key, true); -} - -void LLFloaterDeleteEnvPreset::onDeleteWaterPresetConfirmation() -{ - LLWaterParamManager::instance().removeParamSet(mPresetCombo->getValue().asString(), true); -} diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp deleted file mode 100644 index 5c0991b0b3..0000000000 --- a/indra/newview/llfloatereditdaycycle.cpp +++ /dev/null @@ -1,825 +0,0 @@ -/** - * @file llfloatereditdaycycle.cpp - * @brief Floater to create or edit a day cycle - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llfloatereditdaycycle.h" - -// libs -#include "llbutton.h" -#include "llcheckboxctrl.h" -#include "llcombobox.h" -#include "llloadingindicator.h" -#include "llmultisliderctrl.h" -#include "llnotifications.h" -#include "llnotificationsutil.h" -#include "llspinctrl.h" -#include "lltimectrl.h" - -// newview -#include "llagent.h" -#include "lldaycyclemanager.h" -#include "llenvmanager.h" -#include "llregioninfomodel.h" -#include "llviewerregion.h" -#include "llwlparammanager.h" - -const F32 LLFloaterEditDayCycle::sHoursPerDay = 24.0f; - -LLFloaterEditDayCycle::LLFloaterEditDayCycle(const LLSD &key) -: LLFloater(key) -, mDayCycleNameEditor(NULL) -, mDayCyclesCombo(NULL) -, mTimeSlider(NULL) -, mKeysSlider(NULL) -, mSkyPresetsCombo(NULL) -, mTimeCtrl(NULL) -, mMakeDefaultCheckBox(NULL) -, mSaveButton(NULL) -{ -} - -// virtual -BOOL LLFloaterEditDayCycle::postBuild() -{ - mDayCycleNameEditor = getChild<LLLineEditor>("day_cycle_name"); - mDayCyclesCombo = getChild<LLComboBox>("day_cycle_combo"); - - mTimeSlider = getChild<LLMultiSliderCtrl>("WLTimeSlider"); - mKeysSlider = getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); - mSkyPresetsCombo = getChild<LLComboBox>("WLSkyPresets"); - mTimeCtrl = getChild<LLTimeCtrl>("time"); - mSaveButton = getChild<LLButton>("save"); - mMakeDefaultCheckBox = getChild<LLCheckBoxCtrl>("make_default_cb"); - - initCallbacks(); - - // add the time slider - mTimeSlider->addSlider(); - - return TRUE; -} - -// virtual -void LLFloaterEditDayCycle::onOpen(const LLSD& key) -{ - bool new_day = isNewDay(); - std::string param = key.asString(); - std::string floater_title = getString(std::string("title_") + param); - std::string hint = getString(std::string("hint_" + param)); - - // Update floater title. - setTitle(floater_title); - - // Update the hint at the top. - getChild<LLUICtrl>("hint")->setValue(hint); - - // Hide the hint to the right of the combo if we're invoked to create a new preset. - getChildView("note")->setVisible(!new_day); - - // Switch between the day cycle presets combobox and day cycle name input field. - mDayCyclesCombo->setVisible(!new_day); - mDayCycleNameEditor->setVisible(new_day); - - // TODO: Make sure only one instance of the floater exists? - - reset(); -} - -// virtual -void LLFloaterEditDayCycle::onClose(bool app_quitting) -{ - if (!app_quitting) // there's no point to change environment if we're quitting - { - LLEnvManagerNew::instance().usePrefs(); // revert changes made to current day cycle - } -} - -// virtual -void LLFloaterEditDayCycle::draw() -{ - syncTimeSlider(); - LLFloater::draw(); -} - -void LLFloaterEditDayCycle::initCallbacks(void) -{ - mDayCycleNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleNameEdited, this), NULL); - mDayCyclesCombo->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleSelected, this)); - mDayCyclesCombo->setTextEntryCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleNameEdited, this)); - mTimeSlider->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onTimeSliderMoved, this)); - mKeysSlider->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onKeyTimeMoved, this)); - mTimeCtrl->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onKeyTimeChanged, this)); - mSkyPresetsCombo->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onKeyPresetChanged, this)); - - getChild<LLButton>("WLAddKey")->setClickedCallback(boost::bind(&LLFloaterEditDayCycle::onAddKey, this)); - getChild<LLButton>("WLDeleteKey")->setClickedCallback(boost::bind(&LLFloaterEditDayCycle::onDeleteKey, this)); - - mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onBtnSave, this)); - mSaveButton->setRightMouseDownCallback(boost::bind(&LLFloaterEditDayCycle::dumpTrack, this)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onBtnCancel, this)); - - // Connect to env manager events. - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - env_mgr.setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditDayCycle::onRegionSettingsChange, this)); - gAgent.addRegionChangedCallback(boost::bind(&LLFloaterEditDayCycle::onRegionChange, this)); - env_mgr.setRegionSettingsAppliedCallback(boost::bind(&LLFloaterEditDayCycle::onRegionSettingsApplied, this, _1)); - - // Connect to day cycle manager events. - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleListChange, this)); - - // Connect to sky preset list changes. - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditDayCycle::onSkyPresetListChange, this)); - - // Connect to region info updates. - LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditDayCycle::onRegionInfoUpdate, this)); -} - -void LLFloaterEditDayCycle::syncTimeSlider() -{ - // set time - mTimeSlider->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay); -} - -void LLFloaterEditDayCycle::loadTrack() -{ - // clear the slider - mKeysSlider->clear(); - mSliderToKey.clear(); - - // add sliders - - LL_DEBUGS() << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << LL_ENDL; - - LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; - for (std::map<F32, LLWLParamKey>::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it) - { - addSliderKey(it->first * sHoursPerDay, it->second); - } - - // set drop-down menu to match preset of currently-selected keyframe (one is automatically selected initially) - const std::string& cur_sldr = mKeysSlider->getCurSlider(); - if (strlen(cur_sldr.c_str()) > 0) // only do this if there is a curSldr, otherwise we put an invalid entry into the map - { - mSkyPresetsCombo->selectByValue(mSliderToKey[cur_sldr].keyframe.toStringVal()); - } - - syncTimeSlider(); -} - -void LLFloaterEditDayCycle::applyTrack() -{ - LL_DEBUGS() << "Applying track (" << mSliderToKey.size() << ")" << LL_ENDL; - - // if no keys, do nothing - if (mSliderToKey.size() == 0) - { - LL_DEBUGS() << "No keys, not syncing" << LL_ENDL; - return; - } - - llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size()); - - // create a new animation track - LLWLParamManager::getInstance()->mDay.clearKeyframes(); - - // add the keys one by one - for (std::map<std::string, SliderKey>::iterator it = mSliderToKey.begin(); - it != mSliderToKey.end(); ++it) - { - LLWLParamManager::getInstance()->mDay.addKeyframe(it->second.time / sHoursPerDay, - it->second.keyframe); - } - - // set the param manager's track to the new one - LLWLParamManager::getInstance()->resetAnimator( - mTimeSlider->getCurSliderValue() / sHoursPerDay, false); - - LLWLParamManager::getInstance()->mAnimator.update( - LLWLParamManager::getInstance()->mCurParams); -} - -void LLFloaterEditDayCycle::refreshSkyPresetsList() -{ - // Don't allow selecting region skies for a local day cycle, - // because thus we may end up with invalid day cycle. - bool include_region_skies = getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION; - - mSkyPresetsCombo->removeall(); - - LLWLParamManager::preset_name_list_t region_presets; - LLWLParamManager::preset_name_list_t user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - - if (include_region_skies) - { - // Add region presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) - { - std::string preset_name = *it; - std::string item_title = preset_name + " (" + getRegionName() + ")"; - mSkyPresetsCombo->add(preset_name, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toStringVal()); - } - - if (!region_presets.empty()) - { - mSkyPresetsCombo->addSeparator(); - } - } - - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetsCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - if (!user_presets.empty()) - { - mSkyPresetsCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetsCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - // set defaults on combo boxes - mSkyPresetsCombo->selectFirstItem(); -} - -void LLFloaterEditDayCycle::refreshDayCyclesList() -{ - llassert(isNewDay() == false); - - mDayCyclesCombo->removeall(); - -#if 0 // Disable editing existing day cycle until the workflow is clear enough. - const LLSD& region_day = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); - if (region_day.size() > 0) - { - LLWLParamKey key(getRegionName(), LLEnvKey::SCOPE_REGION); - mDayCyclesCombo->add(key.name, key.toLLSD()); - mDayCyclesCombo->addSeparator(); - } -#endif - - LLDayCycleManager::preset_name_list_t user_days, sys_days; - LLDayCycleManager::instance().getPresetNames(user_days, sys_days); - - // Add user days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - mDayCyclesCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - if (user_days.size() > 0) - { - mDayCyclesCombo->addSeparator(); - } - - // Add system days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) - { - mDayCyclesCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - mDayCyclesCombo->setLabel(getString("combo_label")); -} - -void LLFloaterEditDayCycle::onTimeSliderMoved() -{ - /// get the slider value - F32 val = mTimeSlider->getCurSliderValue() / sHoursPerDay; - - // set the value, turn off animation - LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val); - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - // then call update once - LLWLParamManager::getInstance()->mAnimator.update( - LLWLParamManager::getInstance()->mCurParams); -} - -void LLFloaterEditDayCycle::onKeyTimeMoved() -{ - if (mKeysSlider->getValue().size() == 0) - { - return; - } - - // make sure we have a slider - const std::string& cur_sldr = mKeysSlider->getCurSlider(); - if (cur_sldr == "") - { - return; - } - - F32 time24 = mKeysSlider->getCurSliderValue(); - - // check to see if a key exists - LLWLParamKey key = mSliderToKey[cur_sldr].keyframe; - LL_DEBUGS() << "Setting key time: " << time24 << LL_ENDL; - mSliderToKey[cur_sldr].time = time24; - - // if it exists, turn on check box - mSkyPresetsCombo->selectByValue(key.toStringVal()); - - mTimeCtrl->setTime24(time24); - - applyTrack(); -} - -void LLFloaterEditDayCycle::onKeyTimeChanged() -{ - // if no keys, skipped - if (mSliderToKey.size() == 0) - { - return; - } - - F32 time24 = mTimeCtrl->getTime24(); - - const std::string& cur_sldr = mKeysSlider->getCurSlider(); - mKeysSlider->setCurSliderValue(time24, TRUE); - F32 time = mKeysSlider->getCurSliderValue() / sHoursPerDay; - - // now set the key's time in the sliderToKey map - LL_DEBUGS() << "Setting key time: " << time << LL_ENDL; - mSliderToKey[cur_sldr].time = time; - - applyTrack(); -} - -void LLFloaterEditDayCycle::onKeyPresetChanged() -{ - // do nothing if no sliders - if (mKeysSlider->getValue().size() == 0) - { - return; - } - - // change the map - - std::string stringVal = mSkyPresetsCombo->getSelectedValue().asString(); - LLWLParamKey new_key(stringVal); - llassert(!new_key.name.empty()); - const std::string& cur_sldr = mKeysSlider->getCurSlider(); - - // if null, don't use - if (cur_sldr == "") - { - return; - } - - mSliderToKey[cur_sldr].keyframe = new_key; - - // Apply changes to current day cycle. - applyTrack(); -} - -void LLFloaterEditDayCycle::onAddKey() -{ - llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size()); - - S32 max_sliders; - LLEnvKey::EScope scope = LLEnvKey::SCOPE_LOCAL; // *TODO: editing region day cycle - switch (scope) - { - case LLEnvKey::SCOPE_LOCAL: - max_sliders = 20; // *HACK this should be LLWLPacketScrubber::MAX_LOCAL_KEY_FRAMES; - break; - case LLEnvKey::SCOPE_REGION: - max_sliders = 12; // *HACK this should be LLWLPacketScrubber::MAX_REGION_KEY_FRAMES; - break; - default: - max_sliders = (S32) mKeysSlider->getMaxValue(); - break; - } - - if ((S32)mSliderToKey.size() >= max_sliders) - { - LLSD args; - args["SCOPE"] = LLEnvManagerNew::getScopeString(scope); - args["MAX"] = max_sliders; - LLNotificationsUtil::add("DayCycleTooManyKeyframes", args, LLSD(), LLNotificationFunctorRegistry::instance().DONOTHING); - return; - } - - // add the slider key - std::string key_val = mSkyPresetsCombo->getSelectedValue().asString(); - LLWLParamKey sky_params(key_val); - llassert(!sky_params.name.empty()); - - F32 time = mTimeSlider->getCurSliderValue(); - addSliderKey(time, sky_params); - - // apply the change to current day cycles - applyTrack(); -} - -void LLFloaterEditDayCycle::addSliderKey(F32 time, LLWLParamKey keyframe) -{ - // make a slider - const std::string& sldr_name = mKeysSlider->addSlider(time); - if (sldr_name.empty()) - { - return; - } - - // set the key - SliderKey newKey(keyframe, mKeysSlider->getCurSliderValue()); - - llassert_always(sldr_name != LLStringUtil::null); - - // add to map - mSliderToKey.insert(std::pair<std::string, SliderKey>(sldr_name, newKey)); - - llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size()); -} - -LLWLParamKey LLFloaterEditDayCycle::getSelectedDayCycle() -{ - LLWLParamKey dc_key; - - if (mDayCycleNameEditor->getVisible()) - { - dc_key.name = mDayCycleNameEditor->getText(); - dc_key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - LLSD combo_val = mDayCyclesCombo->getValue(); - - if (!combo_val.isArray()) // manually typed text - { - dc_key.name = combo_val.asString(); - dc_key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - dc_key.fromLLSD(combo_val); - } - } - - return dc_key; -} - -bool LLFloaterEditDayCycle::isNewDay() const -{ - return mKey.asString() == "new"; -} - -void LLFloaterEditDayCycle::dumpTrack() -{ - LL_DEBUGS("Windlight") << "Dumping day cycle" << LL_ENDL; - - LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; - for (std::map<F32, LLWLParamKey>::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it) - { - F32 time = it->first * 24.0f; - S32 h = (S32) time; - S32 m = (S32) ((time - h) * 60.0f); - LL_DEBUGS("Windlight") << llformat("(%.3f) %02d:%02d", time, h, m) << " => " << it->second.name << LL_ENDL; - } -} - -void LLFloaterEditDayCycle::enableEditing(bool enable) -{ - mSkyPresetsCombo->setEnabled(enable); - mTimeCtrl->setEnabled(enable); - getChild<LLPanel>("day_cycle_slider_panel")->setCtrlsEnabled(enable); - mSaveButton->setEnabled(enable); - mMakeDefaultCheckBox->setEnabled(enable); -} - -void LLFloaterEditDayCycle::reset() -{ - // clear the slider - mKeysSlider->clear(); - mSliderToKey.clear(); - - refreshSkyPresetsList(); - - if (isNewDay()) - { - mDayCycleNameEditor->setValue(LLSD()); - F32 time = 0.5f * sHoursPerDay; - mSaveButton->setEnabled(FALSE); // will be enabled as soon as users enters a name - mTimeSlider->setCurSliderValue(time); - - addSliderKey(time, LLWLParamKey("Default", LLEnvKey::SCOPE_LOCAL)); - onKeyTimeMoved(); // update the time control and sky sky combo - - applyTrack(); - } - else - { - refreshDayCyclesList(); - - // Disable controls until a day cycle to edit is selected. - enableEditing(false); - } -} - -void LLFloaterEditDayCycle::saveRegionDayCycle() -{ - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; // the day cycle being edited - - // Get current day cycle and the sky preset it references. - LLSD day_cycle = cur_dayp.asLLSD(); - LLSD sky_map; - cur_dayp.getSkyMap(sky_map); - - // Apply it to the region. - LLEnvironmentSettings new_region_settings; - new_region_settings.saveParams(day_cycle, sky_map, env_mgr.getRegionSettings().getWaterParams(), 0.0f); - -#if 1 - LLEnvManagerNew::instance().setRegionSettings(new_region_settings); -#else // Temporary disabled ability to upload new region settings from the Day Cycle Editor. - if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings)) - { - LL_WARNS() << "Error applying region environment settings" << LL_ENDL; - return; - } - - setApplyProgress(true); -#endif -} - -void LLFloaterEditDayCycle::setApplyProgress(bool started) -{ - LLLoadingIndicator* indicator = getChild<LLLoadingIndicator>("progress_indicator"); - - indicator->setVisible(started); - - if (started) - { - indicator->start(); - } - else - { - indicator->stop(); - } -} - -bool LLFloaterEditDayCycle::getApplyProgress() const -{ - return getChild<LLLoadingIndicator>("progress_indicator")->getVisible(); -} - -void LLFloaterEditDayCycle::onDeleteKey() -{ - if (mSliderToKey.size() == 0) - { - return; - } - else if (mSliderToKey.size() == 1) - { - LLNotifications::instance().add("EnvCannotDeleteLastDayCycleKey", LLSD(), LLSD()); - return; - } - - // delete from map - const std::string& sldr_name = mKeysSlider->getCurSlider(); - std::map<std::string, SliderKey>::iterator mIt = mSliderToKey.find(sldr_name); - mSliderToKey.erase(mIt); - - mKeysSlider->deleteCurSlider(); - - if (mSliderToKey.size() == 0) - { - return; - } - - const std::string& name = mKeysSlider->getCurSlider(); - mSkyPresetsCombo->selectByValue(mSliderToKey[name].keyframe.toStringVal()); - F32 time24 = mSliderToKey[name].time; - - mTimeCtrl->setTime24(time24); - - applyTrack(); -} - -void LLFloaterEditDayCycle::onRegionSettingsChange() -{ - LL_DEBUGS("Windlight") << "Region settings changed" << LL_ENDL; - - if (getApplyProgress()) // our region settings have being applied - { - setApplyProgress(false); - - // Change preference if requested. - if (mMakeDefaultCheckBox->getValue()) - { - LL_DEBUGS("Windlight") << "Changed environment preference to region settings" << LL_ENDL; - LLEnvManagerNew::instance().setUseRegionSettings(true); - } - - closeFloater(); - } -} - -void LLFloaterEditDayCycle::onRegionChange() -{ - LL_DEBUGS("Windlight") << "Region changed" << LL_ENDL; - - // If we're editing the region day cycle - if (getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION) - { - reset(); // undoes all unsaved changes - } -} - -void LLFloaterEditDayCycle::onRegionSettingsApplied(bool success) -{ - LL_DEBUGS("Windlight") << "Region settings applied: " << success << LL_ENDL; - - if (!success) - { - // stop progress indicator - setApplyProgress(false); - } -} - -void LLFloaterEditDayCycle::onRegionInfoUpdate() -{ - LL_DEBUGS("Windlight") << "Region info updated" << LL_ENDL; - bool can_edit = true; - - // If we've selected the region day cycle for editing. - if (getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION) - { - // check whether we have the access - can_edit = LLEnvManagerNew::canEditRegionSettings(); - } - - enableEditing(can_edit); -} - -void LLFloaterEditDayCycle::onDayCycleNameEdited() -{ - // Disable saving a day cycle having empty name. - LLWLParamKey key = getSelectedDayCycle(); - mSaveButton->setEnabled(!key.name.empty()); -} - -void LLFloaterEditDayCycle::onDayCycleSelected() -{ - LLSD day_data; - LLWLParamKey dc_key = getSelectedDayCycle(); - bool can_edit = true; - - if (dc_key.scope == LLEnvKey::SCOPE_LOCAL) - { - if (!LLDayCycleManager::instance().getPreset(dc_key.name, day_data)) - { - LL_WARNS() << "No day cycle named " << dc_key.name << LL_ENDL; - return; - } - } - else - { - day_data = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); - if (day_data.size() == 0) - { - LL_WARNS() << "Empty region day cycle" << LL_ENDL; - llassert(day_data.size() > 0); - return; - } - - can_edit = LLEnvManagerNew::canEditRegionSettings(); - } - - // We may need to add or remove region skies from the list. - refreshSkyPresetsList(); - - F32 slider_time = mTimeSlider->getCurSliderValue() / sHoursPerDay; - LLWLParamManager::instance().applyDayCycleParams(day_data, dc_key.scope, slider_time); - loadTrack(); - - enableEditing(can_edit); -} - -void LLFloaterEditDayCycle::onBtnSave() -{ - LLDayCycleManager& day_mgr = LLDayCycleManager::instance(); - LLWLParamKey selected_day = getSelectedDayCycle(); - - if (selected_day.scope == LLEnvKey::SCOPE_REGION) - { - saveRegionDayCycle(); - closeFloater(); - return; - } - - std::string name = selected_day.name; - if (name.empty()) - { - // *TODO: show an alert - LL_WARNS() << "Empty day cycle name" << LL_ENDL; - return; - } - - // Don't allow overwriting system presets. - if (day_mgr.isSystemPreset(name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - // Save, ask for confirmation for overwriting an existing preset. - if (day_mgr.presetExists(name)) - { - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditDayCycle::onSaveAnswer, this, _1, _2)); - } - else - { - // new preset, hence no confirmation needed - onSaveConfirmed(); - } -} - -void LLFloaterEditDayCycle::onBtnCancel() -{ - closeFloater(); -} - -bool LLFloaterEditDayCycle::onSaveAnswer(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - - // If they choose save, do it. Otherwise, don't do anything - if (option == 0) - { - onSaveConfirmed(); - } - - return false; -} - -void LLFloaterEditDayCycle::onSaveConfirmed() -{ - std::string name = getSelectedDayCycle().name; - - // Save preset. - LLSD data = LLWLParamManager::instance().mDay.asLLSD(); - LL_DEBUGS("Windlight") << "Saving day cycle " << name << ": " << data << LL_ENDL; - LLDayCycleManager::instance().savePreset(name, data); - - // Change preference if requested. - if (mMakeDefaultCheckBox->getValue()) - { - LL_DEBUGS("Windlight") << name << " is now the new preferred day cycle" << LL_ENDL; - LLEnvManagerNew::instance().setUseDayCycle(name); - } - - closeFloater(); -} - -void LLFloaterEditDayCycle::onDayCycleListChange() -{ - if (!isNewDay()) - { - refreshDayCyclesList(); - } -} - -void LLFloaterEditDayCycle::onSkyPresetListChange() -{ - refreshSkyPresetsList(); - - // Refresh sliders from the currently visible day cycle. - loadTrack(); -} - -// static -std::string LLFloaterEditDayCycle::getRegionName() -{ - return gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); -} diff --git a/indra/newview/llfloatereditdaycycle.h b/indra/newview/llfloatereditdaycycle.h deleted file mode 100644 index e6e4fe39c1..0000000000 --- a/indra/newview/llfloatereditdaycycle.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @file llfloatereditdaycycle.h - * @brief Floater to create or edit a day cycle - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFLOATEREDITDAYCYCLE_H -#define LL_LLFLOATEREDITDAYCYCLE_H - -#include "llfloater.h" - -#include "llwlparammanager.h" // for LLWLParamKey - -class LLCheckBoxCtrl; -class LLComboBox; -class LLLineEditor; -class LLMultiSliderCtrl; -class LLTimeCtrl; - -/** - * Floater for creating or editing a day cycle. - */ -class LLFloaterEditDayCycle : public LLFloater -{ - LOG_CLASS(LLFloaterEditDayCycle); - -public: - LLFloaterEditDayCycle(const LLSD &key); - - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); - /*virtual*/ void draw(); - -private: - - /// sync the time slider with day cycle structure - void syncTimeSlider(); - - // makes sure key slider has what's in day cycle - void loadTrack(); - - /// makes sure day cycle data structure has what's in menu - void applyTrack(); - - /// refresh the sky presets combobox - void refreshSkyPresetsList(); - - /// refresh the day cycle combobox - void refreshDayCyclesList(); - - /// add a slider to the track - void addSliderKey(F32 time, LLWLParamKey keyframe); - - void initCallbacks(); - LLWLParamKey getSelectedDayCycle(); - bool isNewDay() const; - void dumpTrack(); - void enableEditing(bool enable); - void reset(); - void saveRegionDayCycle(); - - void setApplyProgress(bool started); - bool getApplyProgress() const; - - void onTimeSliderMoved(); /// time slider moved - void onKeyTimeMoved(); /// a key frame moved - void onKeyTimeChanged(); /// a key frame's time changed - void onKeyPresetChanged(); /// sky preset selected - void onAddKey(); /// new key added on slider - void onDeleteKey(); /// a key frame deleted - - void onRegionSettingsChange(); - void onRegionChange(); - void onRegionSettingsApplied(bool success); - void onRegionInfoUpdate(); - - void onDayCycleNameEdited(); - void onDayCycleSelected(); - void onBtnSave(); - void onBtnCancel(); - - bool onSaveAnswer(const LLSD& notification, const LLSD& response); - void onSaveConfirmed(); - - void onDayCycleListChange(); - void onSkyPresetListChange(); - - static std::string getRegionName(); - - /// convenience class for holding keyframes mapped to sliders - struct SliderKey - { - public: - SliderKey(LLWLParamKey kf, F32 t) : keyframe(kf), time(t) {} - SliderKey() : keyframe(), time(0.f) {} // Don't use this default constructor - - LLWLParamKey keyframe; - F32 time; - }; - - static const F32 sHoursPerDay; - - LLLineEditor* mDayCycleNameEditor; - LLComboBox* mDayCyclesCombo; - LLMultiSliderCtrl* mTimeSlider; - LLMultiSliderCtrl* mKeysSlider; - LLComboBox* mSkyPresetsCombo; - LLTimeCtrl* mTimeCtrl; - LLCheckBoxCtrl* mMakeDefaultCheckBox; - LLButton* mSaveButton; - - // map of sliders to parameters - std::map<std::string, SliderKey> mSliderToKey; -}; - -#endif // LL_LLFLOATEREDITDAYCYCLE_H diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp new file mode 100644 index 0000000000..4b88b4d7af --- /dev/null +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -0,0 +1,2084 @@ +/** + * @file llfloatereditextdaycycle.cpp + * @brief Floater to create or edit a day cycle + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatereditextdaycycle.h" + +// libs +#include "llbutton.h" +#include "llcallbacklist.h" +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "llloadingindicator.h" +#include "lllocalbitmaps.h" +#include "llmultisliderctrl.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" +#include "llspinctrl.h" +#include "lltimectrl.h" +#include "lltabcontainer.h" +#include "llfilepicker.h" + +#include "llsettingsvo.h" +#include "llinventorymodel.h" +#include "llviewerparcelmgr.h" + +#include "llsettingspicker.h" +#include "lltrackpicker.h" + +// newview +#include "llagent.h" +#include "llappviewer.h" //gDisconected +#include "llparcel.h" +#include "llflyoutcombobtn.h" //Todo: make a proper UI element/button/panel instead +#include "llregioninfomodel.h" +#include "llviewermenufile.h" // LLFilePickerReplyThread +#include "llviewerregion.h" +#include "llpaneleditwater.h" +#include "llpaneleditsky.h" + +#include "llui.h" + +#include "llenvironment.h" +#include "lltrans.h" + +extern LLControlGroup gSavedSettings; + +//========================================================================= +namespace { + const std::string track_tabs[] = { + "water_track", + "sky1_track", + "sky2_track", + "sky3_track", + "sky4_track", + }; + + const std::string ICN_LOCK_EDIT("icn_lock_edit"); + const std::string BTN_SAVE("save_btn"); + const std::string BTN_FLYOUT("btn_flyout"); + const std::string BTN_CANCEL("cancel_btn"); + const std::string BTN_ADDFRAME("add_frame"); + const std::string BTN_DELFRAME("delete_frame"); + const std::string BTN_IMPORT("btn_import"); + const std::string BTN_LOADFRAME("btn_load_frame"); + const std::string BTN_CLONETRACK("copy_track"); + const std::string BTN_LOADTRACK("load_track"); + const std::string BTN_CLEARTRACK("clear_track"); + const std::string SLDR_TIME("WLTimeSlider"); + const std::string SLDR_KEYFRAMES("WLDayCycleFrames"); + const std::string VIEW_SKY_SETTINGS("frame_settings_sky"); + const std::string VIEW_WATER_SETTINGS("frame_settings_water"); + const std::string LBL_CURRENT_TIME("current_time"); + const std::string TXT_DAY_NAME("day_cycle_name"); + const std::string TABS_SKYS("sky_tabs"); + const std::string TABS_WATER("water_tabs"); + + const std::string EVNT_DAYTRACK("DayCycle.Track"); + const std::string EVNT_PLAY("DayCycle.PlayActions"); + + const std::string ACTION_PLAY("play"); + const std::string ACTION_PAUSE("pause"); + const std::string ACTION_FORWARD("forward"); + const std::string ACTION_BACK("back"); + + // For flyout + const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml"); + // From menu_save_settings.xml, consider moving into flyout since it should be supported by flyout either way + const std::string ACTION_SAVE("save_settings"); + const std::string ACTION_SAVEAS("save_as_new_settings"); + const std::string ACTION_COMMIT("commit_changes"); + const std::string ACTION_APPLY_LOCAL("apply_local"); + const std::string ACTION_APPLY_PARCEL("apply_parcel"); + const std::string ACTION_APPLY_REGION("apply_region"); + + const F32 DAY_CYCLE_PLAY_TIME_SECONDS = 60; + + const std::string STR_COMMIT_PARCEL("commit_parcel"); + const std::string STR_COMMIT_REGION("commit_region"); + //--------------------------------------------------------------------- + +} + +//========================================================================= +const std::string LLFloaterEditExtDayCycle::KEY_INVENTORY_ID("inventory_id"); +const std::string LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT("edit_context"); +const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length"); +const std::string LLFloaterEditExtDayCycle::KEY_CANMOD("canmod"); + +const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_INVENTORY("inventory"); +const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL("parcel"); +const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_REGION("region"); + +//========================================================================= + +class LLDaySettingCopiedCallback : public LLInventoryCallback +{ +public: + LLDaySettingCopiedCallback(LLHandle<LLFloater> handle) : mHandle(handle) {} + + virtual void fire(const LLUUID& inv_item_id) + { + if (!mHandle.isDead()) + { + LLViewerInventoryItem* item = gInventory.getItem(inv_item_id); + if (item) + { + LLFloaterEditExtDayCycle* floater = (LLFloaterEditExtDayCycle*)mHandle.get(); + floater->onInventoryCreated(item->getAssetUUID(), inv_item_id); + } + } + } + +private: + LLHandle<LLFloater> mHandle; +}; + +//========================================================================= + +LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key) : + LLFloater(key), + mFlyoutControl(nullptr), + mDayLength(0), + mCurrentTrack(1), + mShiftCopyEnabled(false), + mTimeSlider(nullptr), + mFramesSlider(nullptr), + mCurrentTimeLabel(nullptr), + mImportButton(nullptr), + mInventoryId(), + mInventoryItem(nullptr), + mLoadFrame(nullptr), + mSkyBlender(), + mWaterBlender(), + mScratchSky(), + mScratchWater(), + mIsPlaying(false), + mIsDirty(false), + mCanCopy(false), + mCanMod(false), + mCanTrans(false), + mCloneTrack(nullptr), + mLoadTrack(nullptr), + mClearTrack(nullptr) +{ + + mCommitCallbackRegistrar.add(EVNT_DAYTRACK, [this](LLUICtrl *ctrl, const LLSD &data) { onTrackSelectionCallback(data); }); + mCommitCallbackRegistrar.add(EVNT_PLAY, [this](LLUICtrl *ctrl, const LLSD &data) { onPlayActionCallback(data); }); + + mScratchSky = LLSettingsVOSky::buildDefaultSky(); + mScratchWater = LLSettingsVOWater::buildDefaultWater(); + + mEditSky = mScratchSky; + mEditWater = mScratchWater; +} + +LLFloaterEditExtDayCycle::~LLFloaterEditExtDayCycle() +{ + // Todo: consider remaking mFlyoutControl into full view class that initializes intself with floater, + // complete with postbuild, e t c... + delete mFlyoutControl; +} + +// virtual +BOOL LLFloaterEditExtDayCycle::postBuild() +{ + getChild<LLLineEditor>(TXT_DAY_NAME)->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onCommitName, this, _1, _2), NULL); + + mAddFrameButton = getChild<LLButton>(BTN_ADDFRAME, true); + mDeleteFrameButton = getChild<LLButton>(BTN_DELFRAME, true); + mTimeSlider = getChild<LLMultiSliderCtrl>(SLDR_TIME); + mFramesSlider = getChild<LLMultiSliderCtrl>(SLDR_KEYFRAMES); + mSkyTabLayoutContainer = getChild<LLView>(VIEW_SKY_SETTINGS, true); + mWaterTabLayoutContainer = getChild<LLView>(VIEW_WATER_SETTINGS, true); + mCurrentTimeLabel = getChild<LLTextBox>(LBL_CURRENT_TIME, true); + mImportButton = getChild<LLButton>(BTN_IMPORT, true); + mLoadFrame = getChild<LLButton>(BTN_LOADFRAME, true); + mCloneTrack = getChild<LLButton>(BTN_CLONETRACK, true); + mLoadTrack = getChild<LLButton>(BTN_LOADTRACK, true); + mClearTrack = getChild<LLButton>(BTN_CLEARTRACK, true); + + mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BTN_SAVE, BTN_FLYOUT, XML_FLYOUTMENU_FILE, false); + mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); + + getChild<LLButton>(BTN_CANCEL, true)->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onClickCloseBtn(); }); + mTimeSlider->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onTimeSliderCallback(); }); + mAddFrameButton->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onAddFrame(); }); + mDeleteFrameButton->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onRemoveFrame(); }); + mImportButton->setCommitCallback([this](LLUICtrl *, const LLSD &){ onButtonImport(); }); + mLoadFrame->setCommitCallback([this](LLUICtrl *, const LLSD &){ onButtonLoadFrame(); }); + + mCloneTrack->setCommitCallback([this](LLUICtrl *, const LLSD&){ onCloneTrack(); }); + mLoadTrack->setCommitCallback([this](LLUICtrl *, const LLSD&){ onLoadTrack();}); + mClearTrack->setCommitCallback([this](LLUICtrl *, const LLSD&){ onClearTrack(); }); + + + mFramesSlider->setCommitCallback([this](LLUICtrl *, const LLSD &data) { onFrameSliderCallback(data); }); + mFramesSlider->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderDoubleClick(x, y, mask); }); + mFramesSlider->setMouseDownCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderMouseDown(x, y, mask); }); + mFramesSlider->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderMouseUp(x, y, mask); }); + + mTimeSlider->addSlider(0); + + LLTabContainer* tab_container = mSkyTabLayoutContainer->getChild<LLTabContainer>("sky_tabs"); + S32 tab_count = tab_container->getTabCount(); + + LLSettingsEditPanel *panel = nullptr; + + for (S32 idx = 0; idx < tab_count; ++idx) + { + panel = static_cast<LLSettingsEditPanel *>(tab_container->getPanelByIndex(idx)); + if (panel) + panel->setOnDirtyFlagChanged([this](LLPanel *, bool val) { onPanelDirtyFlagChanged(val); }); + } + + tab_container = mWaterTabLayoutContainer->getChild<LLTabContainer>("water_tabs"); + tab_count = tab_container->getTabCount(); + + for (S32 idx = 0; idx < tab_count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tab_container->getPanelByIndex(idx)); + if (panel) + panel->setOnDirtyFlagChanged([this](LLPanel *, bool val) { onPanelDirtyFlagChanged(val); }); + } + + return TRUE; +} + +void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) +{ + mEditDay.reset(); + mEditContext = CONTEXT_UNKNOWN; + if (key.has(KEY_EDIT_CONTEXT)) + { + std::string context = key[KEY_EDIT_CONTEXT].asString(); + + if (context == VALUE_CONTEXT_INVENTORY) + mEditContext = CONTEXT_INVENTORY; + else if (context == VALUE_CONTEXT_PARCEL) + mEditContext = CONTEXT_PARCEL; + else if (context == VALUE_CONTEXT_REGION) + mEditContext = CONTEXT_REGION; + } + + if (key.has(KEY_CANMOD)) + { + mCanMod = key[KEY_CANMOD].asBoolean(); + } + + if (mEditContext == CONTEXT_UNKNOWN) + { + LL_WARNS("ENVDAYEDIT") << "Unknown editing context!" << LL_ENDL; + } + + if (key.has(KEY_INVENTORY_ID)) + { + loadInventoryItem(key[KEY_INVENTORY_ID].asUUID()); + } + else + { + mCanCopy = true; + mCanMod = true; + mCanTrans = true; + setEditDefaultDayCycle(); + } + + mDayLength.value(0); + if (key.has(KEY_DAY_LENGTH)) + { + mDayLength.value(key[KEY_DAY_LENGTH].asReal()); + } + + // Time&Percentage labels + mCurrentTimeLabel->setTextArg("[PRCNT]", std::string("0")); + const S32 max_elm = 5; + if (mDayLength.value() != 0) + { + S32Hours hrs; + S32Minutes minutes; + LLSettingsDay::Seconds total; + LLUIString formatted_label = getString("time_label"); + for (int i = 0; i < max_elm; i++) + { + total = ((mDayLength / (max_elm - 1)) * i); + hrs = total; + minutes = total - hrs; + + formatted_label.setArg("[HH]", llformat("%d", hrs.value())); + formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); + getChild<LLTextBox>("p" + llformat("%d", i), true)->setTextArg("[DSC]", formatted_label.getString()); + } + hrs = mDayLength; + minutes = mDayLength - hrs; + formatted_label.setArg("[HH]", llformat("%d", hrs.value())); + formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); + mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString()); + } + else + { + for (int i = 0; i < max_elm; i++) + { + getChild<LLTextBox>("p" + llformat("%d", i), true)->setTextArg("[DSC]", std::string()); + } + mCurrentTimeLabel->setTextArg("[DSC]", std::string()); + } + + // Adjust Time&Percentage labels' location according to length + LLRect label_rect = getChild<LLTextBox>("p0", true)->getRect(); + F32 slider_width = mFramesSlider->getRect().getWidth(); + for (int i = 1; i < max_elm; i++) + { + LLTextBox *pcnt_label = getChild<LLTextBox>("p" + llformat("%d", i), true); + LLRect new_rect = pcnt_label->getRect(); + new_rect.mLeft = label_rect.mLeft + (S32)(slider_width * (F32)i / (F32)(max_elm - 1)) - (S32)(pcnt_label->getTextPixelWidth() / 2); + pcnt_label->setRect(new_rect); + } + + // Altitudes&Track labels + LLUIString formatted_label = getString("sky_track_label"); + const LLEnvironment::altitude_list_t &altitudes = LLEnvironment::instance().getRegionAltitudes(); + bool extended_env = LLEnvironment::instance().isExtendedEnvironmentEnabled(); + bool use_altitudes = extended_env + && altitudes.size() > 0 + && ((mEditContext == CONTEXT_PARCEL) || (mEditContext == CONTEXT_REGION)); + for (S32 idx = 1; idx < 4; ++idx) + { + std::ostringstream convert; + if (use_altitudes) + { + convert << altitudes[idx] << "m"; + } + else + { + convert << (idx + 1); + } + formatted_label.setArg("[ALT]", convert.str()); + getChild<LLButton>(track_tabs[idx + 1], true)->setLabel(formatted_label.getString()); + } + + for (U32 i = 2; i < LLSettingsDay::TRACK_MAX; i++) //skies #2 through #4 + { + getChild<LLButton>(track_tabs[i])->setEnabled(extended_env); + } + + if (mEditContext == CONTEXT_INVENTORY) + { + mFlyoutControl->setShownBtnEnabled(true); + mFlyoutControl->setSelectedItem(ACTION_SAVE); + } + else if ((mEditContext == CONTEXT_REGION) || (mEditContext == CONTEXT_PARCEL)) + { + std::string commit_str = (mEditContext == CONTEXT_PARCEL) ? STR_COMMIT_PARCEL : STR_COMMIT_REGION; + mFlyoutControl->setMenuItemLabel(ACTION_COMMIT, getString(commit_str)); + mFlyoutControl->setShownBtnEnabled(true); + mFlyoutControl->setSelectedItem(ACTION_COMMIT); + } + else + { + mFlyoutControl->setShownBtnEnabled(false); + } +} + +void LLFloaterEditExtDayCycle::onClose(bool app_quitting) +{ + doCloseInventoryFloater(app_quitting); + doCloseTrackFloater(app_quitting); + // there's no point to change environment if we're quitting + // or if we already restored environment + stopPlay(); + if (!app_quitting) + { + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_FAST); + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); + } +} + +void LLFloaterEditExtDayCycle::onFocusReceived() +{ + if (isInVisibleChain()) + { + updateEditEnvironment(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); + } +} + +void LLFloaterEditExtDayCycle::onFocusLost() +{ +} + + +void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility) +{ +} + +void LLFloaterEditExtDayCycle::refresh() +{ + if (mEditDay) + { + LLLineEditor* name_field = getChild<LLLineEditor>(TXT_DAY_NAME); + name_field->setText(mEditDay->getName()); + name_field->setEnabled(mCanMod); + } + + + bool is_inventory_avail = canUseInventory(); + + bool show_commit = ((mEditContext == CONTEXT_PARCEL) || (mEditContext == CONTEXT_REGION)); + bool show_apply = (mEditContext == CONTEXT_INVENTORY); + + if (show_commit) + { + std::string commit_text; + if (mEditContext == CONTEXT_PARCEL) + commit_text = getString(STR_COMMIT_PARCEL); + else + commit_text = getString(STR_COMMIT_REGION); + + mFlyoutControl->setMenuItemLabel(ACTION_COMMIT, commit_text); + } + + mFlyoutControl->setMenuItemVisible(ACTION_COMMIT, show_commit); + mFlyoutControl->setMenuItemVisible(ACTION_SAVE, is_inventory_avail); + mFlyoutControl->setMenuItemVisible(ACTION_SAVEAS, is_inventory_avail); + mFlyoutControl->setMenuItemVisible(ACTION_APPLY_LOCAL, true); + mFlyoutControl->setMenuItemVisible(ACTION_APPLY_PARCEL, show_apply); + mFlyoutControl->setMenuItemVisible(ACTION_APPLY_REGION, show_apply); + + mFlyoutControl->setMenuItemEnabled(ACTION_COMMIT, show_commit && !mCommitSignal.empty()); + mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, is_inventory_avail && mCanMod && !mInventoryId.isNull()); + mFlyoutControl->setMenuItemEnabled(ACTION_SAVEAS, is_inventory_avail && mCanCopy); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_LOCAL, true); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_PARCEL, canApplyParcel() && show_apply); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_REGION, canApplyRegion() && show_apply); + + mImportButton->setEnabled(mCanMod); + + LLFloater::refresh(); +} + + +void LLFloaterEditExtDayCycle::setEditDayCycle(const LLSettingsDay::ptr_t &pday) +{ + mExpectingAssetId.setNull(); + mEditDay = pday->buildDeepCloneAndUncompress(); + + if (mEditDay->isTrackEmpty(LLSettingsDay::TRACK_WATER)) + { + LL_WARNS("ENVDAYEDIT") << "No water frames found, generating replacement" << LL_ENDL; + mEditDay->setWaterAtKeyframe(LLSettingsVOWater::buildDefaultWater(), .5f); + } + + if (mEditDay->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL)) + { + LL_WARNS("ENVDAYEDIT") << "No sky frames found, generating replacement" << LL_ENDL; + mEditDay->setSkyAtKeyframe(LLSettingsVOSky::buildDefaultSky(), .5f, LLSettingsDay::TRACK_GROUND_LEVEL); + } + + updateEditEnvironment(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_INSTANT); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + synchronizeTabs(); + updateTabs(); + refresh(); +} + + +void LLFloaterEditExtDayCycle::setEditDefaultDayCycle() +{ + mInventoryItem = nullptr; + mInventoryId.setNull(); + mExpectingAssetId = LLSettingsDay::GetDefaultAssetId(); + LLSettingsVOBase::getSettingsAsset(LLSettingsDay::GetDefaultAssetId(), + [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); +} + +std::string LLFloaterEditExtDayCycle::getEditName() const +{ + if (mEditDay) + return mEditDay->getName(); + return "new"; +} + +void LLFloaterEditExtDayCycle::setEditName(const std::string &name) +{ + if (mEditDay) + mEditDay->setName(name); + getChild<LLLineEditor>(TXT_DAY_NAME)->setText(name); +} + +/* virtual */ +BOOL LLFloaterEditExtDayCycle::handleKeyUp(KEY key, MASK mask, BOOL called_from_parent) +{ + if (!mEditDay) + { + mShiftCopyEnabled = false; + } + else if (mask == MASK_SHIFT && mShiftCopyEnabled) + { + mShiftCopyEnabled = false; + std::string curslider = mFramesSlider->getCurSlider(); + if (!curslider.empty()) + { + F32 sliderpos = mFramesSlider->getCurSliderValue(); + + keymap_t::iterator it = mSliderKeyMap.find(curslider); + if (it != mSliderKeyMap.end()) + { + if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos)) + { + (*it).second.mFrame = sliderpos; + } + else + { + mFramesSlider->setCurSliderValue((*it).second.mFrame); + } + } + else + { + LL_WARNS("ENVDAYEDIT") << "Failed to find frame " << sliderpos << " for slider " << curslider << LL_ENDL; + } + } + } + return LLFloater::handleKeyUp(key, mask, called_from_parent); +} + +void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) +{ + std::string ctrl_action = ctrl->getName(); + + if (!mEditDay) + { + LL_WARNS("ENVDAYEDIT") << "mEditDay is null! This should never happen! Something is very very wrong" << LL_ENDL; + LLNotificationsUtil::add("EnvironmentApplyFailed"); + closeFloater(); + return; + } + + LLSettingsDay::ptr_t dayclone = mEditDay->buildClone(); // create a compressed copy + + if (!dayclone) + { + LL_WARNS("ENVDAYEDIT") << "Unable to clone daycylce from editor." << LL_ENDL; + return; + } + + // brute-force local texture scan + for (U32 i = 0; i <= LLSettingsDay::TRACK_MAX; i++) + { + LLSettingsDay::CycleTrack_t &day_track = dayclone->getCycleTrack(i); + + LLSettingsDay::CycleTrack_t::iterator iter = day_track.begin(); + LLSettingsDay::CycleTrack_t::iterator end = day_track.end(); + S32 frame_num = 0; + + while (iter != end) + { + frame_num++; + std::string desc; + bool is_local = false; // because getString can be empty + if (i == LLSettingsDay::TRACK_WATER) + { + LLSettingsWater::ptr_t water = std::static_pointer_cast<LLSettingsWater>(iter->second); + if (water) + { + // LLViewerFetchedTexture and check for FTT_LOCAL_FILE or check LLLocalBitmapMgr + if (LLLocalBitmapMgr::isLocal(water->getNormalMapID())) + { + desc = LLTrans::getString("EnvironmentNormalMap"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(water->getTransparentTextureID())) + { + desc = LLTrans::getString("EnvironmentTransparent"); + is_local = true; + } + } + } + else + { + LLSettingsSky::ptr_t sky = std::static_pointer_cast<LLSettingsSky>(iter->second); + if (sky) + { + if (LLLocalBitmapMgr::isLocal(sky->getSunTextureId())) + { + desc = LLTrans::getString("EnvironmentSun"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(sky->getMoonTextureId())) + { + desc = LLTrans::getString("EnvironmentMoon"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(sky->getCloudNoiseTextureId())) + { + desc = LLTrans::getString("EnvironmentCloudNoise"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(sky->getBloomTextureId())) + { + desc = LLTrans::getString("EnvironmentBloom"); + is_local = true; + } + } + } + + if (is_local) + { + LLSD args; + LLButton* button = getChild<LLButton>(track_tabs[i], true); + args["TRACK"] = button->getCurrentLabel(); + args["FRAME"] = iter->first * 100; // % + args["FIELD"] = desc; + args["FRAMENO"] = frame_num; + LLNotificationsUtil::add("WLLocalTextureDayBlock", args); + return; + } + iter++; + } + } + + if (ctrl_action == ACTION_SAVE) + { + doApplyUpdateInventory(dayclone); + } + else if (ctrl_action == ACTION_SAVEAS) + { + LLSD args; + args["DESC"] = dayclone->getName(); + LLNotificationsUtil::add("SaveSettingAs", args, LLSD(), boost::bind(&LLFloaterEditExtDayCycle::onSaveAsCommit, this, _1, _2, dayclone)); + } + else if ((ctrl_action == ACTION_APPLY_LOCAL) || + (ctrl_action == ACTION_APPLY_PARCEL) || + (ctrl_action == ACTION_APPLY_REGION)) + { + doApplyEnvironment(ctrl_action, dayclone); + } + else if (ctrl_action == ACTION_COMMIT) + { + doApplyCommit(dayclone); + } + else + { + LL_WARNS("ENVDAYEDIT") << "Unknown settings action '" << ctrl_action << "'" << LL_ENDL; + } +} + +void LLFloaterEditExtDayCycle::onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsDay::ptr_t &day) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option) + { + std::string settings_name = response["message"].asString(); + LLStringUtil::trim(settings_name); + if (mCanMod) + { + doApplyCreateNewInventory(day, settings_name); + } + else if (mInventoryItem) + { + const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); + LLUUID parent_id = mInventoryItem->getParentUUID(); + if (marketplacelistings_id == parent_id) + { + parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); + } + + LLPointer<LLInventoryCallback> cb = new LLDaySettingCopiedCallback(getHandle()); + copy_inventory_item( + gAgent.getID(), + mInventoryItem->getPermissions().getOwner(), + mInventoryItem->getUUID(), + parent_id, + settings_name, + cb); + } + else + { + LL_WARNS() << "Failed to copy day setting" << LL_ENDL; + } + } +} + +void LLFloaterEditExtDayCycle::onClickCloseBtn(bool app_quitting /*= false*/) +{ + if (!app_quitting) + checkAndConfirmSettingsLoss([this](){ closeFloater(); clearDirtyFlag(); }); + else + closeFloater(); +} + +void LLFloaterEditExtDayCycle::onButtonImport() +{ + checkAndConfirmSettingsLoss([this]() { doImportFromDisk(); }); +} + +void LLFloaterEditExtDayCycle::onButtonLoadFrame() +{ + doOpenInventoryFloater((mCurrentTrack == LLSettingsDay::TRACK_WATER) ? LLSettingsType::ST_WATER : LLSettingsType::ST_SKY, LLUUID::null); +} + +void LLFloaterEditExtDayCycle::onAddFrame() +{ + LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); + LLSettingsBase::ptr_t setting; + if (!mEditDay) + { + LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame while waiting for day(asset) to load." << LL_ENDL; + return; + } + if ((mEditDay->getSettingsNearKeyframe(frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second) + { + LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame too close to existing frame." << LL_ENDL; + return; + } + if (!mFramesSlider->canAddSliders()) + { + // Shouldn't happen, button should be disabled + LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame when slider is full." << LL_ENDL; + return; + } + + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + { + // scratch water should always have the current water settings. + LLSettingsWater::ptr_t water(mScratchWater->buildClone()); + setting = water; + mEditDay->setWaterAtKeyframe( std::static_pointer_cast<LLSettingsWater>(setting), frame); + } + else + { + // scratch sky should always have the current sky settings. + LLSettingsSky::ptr_t sky(mScratchSky->buildClone()); + setting = sky; + mEditDay->setSkyAtKeyframe(sky, frame, mCurrentTrack); + } + + addSliderFrame(frame, setting); + updateTabs(); +} + +void LLFloaterEditExtDayCycle::onRemoveFrame() +{ + std::string sldr_key = mFramesSlider->getCurSlider(); + if (sldr_key.empty()) + { + return; + } + removeCurrentSliderFrame(); + updateTabs(); +} + + +void LLFloaterEditExtDayCycle::onCloneTrack() +{ + if (!mEditDay) + { + LL_WARNS("ENVDAYEDIT") << "Attempt to copy track while waiting for day(asset) to load." << LL_ENDL; + return; + } + const LLEnvironment::altitude_list_t &altitudes = LLEnvironment::instance().getRegionAltitudes(); + bool use_altitudes = altitudes.size() > 0 && ((mEditContext == CONTEXT_PARCEL) || (mEditContext == CONTEXT_REGION)); + + LLSD args = LLSD::emptyArray(); + + S32 populated_counter = 0; + for (U32 i = 1; i < LLSettingsDay::TRACK_MAX; i++) + { + LLSD track; + track["id"] = LLSD::Integer(i); + bool populated = (!mEditDay->isTrackEmpty(i)) && (i != mCurrentTrack); + track["enabled"] = populated; + if (populated) + { + populated_counter++; + } + if (use_altitudes) + { + track["altitude"] = altitudes[i - 1]; + } + args.append(track); + } + + if (populated_counter > 0) + { + doOpenTrackFloater(args); + } + else + { + // Should not happen + LL_WARNS("ENVDAYEDIT") << "Tried to copy tracks, but there are no available sources" << LL_ENDL; + } +} + + +void LLFloaterEditExtDayCycle::onLoadTrack() +{ + LLUUID curitemId = mInventoryId; + + if (mCurrentEdit && curitemId.notNull()) + { + curitemId = LLFloaterSettingsPicker::findItemID(mCurrentEdit->getAssetId(), false, false); + } + + doOpenInventoryFloater(LLSettingsType::ST_DAYCYCLE, curitemId); +} + + +void LLFloaterEditExtDayCycle::onClearTrack() +{ + if (!mEditDay) + { + LL_WARNS("ENVDAYEDIT") << "Attempt to clear track while waiting for day(asset) to load." << LL_ENDL; + return; + } + + if (mCurrentTrack > 1) + mEditDay->getCycleTrack(mCurrentTrack).clear(); + else + { + LLSettingsDay::CycleTrack_t &track(mEditDay->getCycleTrack(mCurrentTrack)); + + auto first = track.begin(); + auto last = track.end(); + ++first; + track.erase(first, last); + } + + updateEditEnvironment(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_INSTANT); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + synchronizeTabs(); + updateTabs(); + refresh(); +} + +void LLFloaterEditExtDayCycle::onCommitName(class LLLineEditor* caller, void* user_data) +{ + if (!mEditDay) + { + LL_WARNS("ENVDAYEDIT") << "Attempt to rename day while waiting for day(asset) to load." << LL_ENDL; + return; + } + + mEditDay->setName(caller->getText()); +} + +void LLFloaterEditExtDayCycle::onTrackSelectionCallback(const LLSD& user_data) +{ + U32 track_index = user_data.asInteger(); // 1-5 + selectTrack(track_index); +} + +void LLFloaterEditExtDayCycle::onPlayActionCallback(const LLSD& user_data) +{ + std::string action = user_data.asString(); + + F32 frame = mTimeSlider->getCurSliderValue(); + + if (action == ACTION_PLAY) + { + startPlay(); + } + else if (action == ACTION_PAUSE) + { + stopPlay(); + } + else if (mSliderKeyMap.size() != 0) + { + F32 new_frame = 0; + if (action == ACTION_FORWARD) + { + new_frame = mEditDay->getUpperBoundFrame(mCurrentTrack, frame + (mTimeSlider->getIncrement() / 2)); + } + else if (action == ACTION_BACK) + { + new_frame = mEditDay->getLowerBoundFrame(mCurrentTrack, frame - (mTimeSlider->getIncrement() / 2)); + } + selectFrame(new_frame, 0.0f); + stopPlay(); + } +} + +void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data) +{ + std::string curslider = mFramesSlider->getCurSlider(); + + if (!curslider.empty() && mEditDay) + { + F32 sliderpos = mFramesSlider->getCurSliderValue(); + + keymap_t::iterator it = mSliderKeyMap.find(curslider); + if (it != mSliderKeyMap.end()) + { + if (gKeyboard->currentMask(TRUE) == MASK_SHIFT && mShiftCopyEnabled && mCanMod) + { + // don't move the point/frame as long as shift is pressed and user is attempting to copy + // handleKeyUp will do the move if user releases key too early. + if (!(mEditDay->getSettingsNearKeyframe(sliderpos, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second) + { + LL_DEBUGS("ENVDAYEDIT") << "Copying frame from " << it->second.mFrame << " to " << sliderpos << LL_ENDL; + LLSettingsBase::ptr_t new_settings; + + // mEditDay still remembers old position, add copy at new position + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + { + LLSettingsWaterPtr_t water_ptr = std::dynamic_pointer_cast<LLSettingsWater>(it->second.pSettings)->buildClone(); + mEditDay->setWaterAtKeyframe(water_ptr, sliderpos); + new_settings = water_ptr; + } + else + { + LLSettingsSkyPtr_t sky_ptr = std::dynamic_pointer_cast<LLSettingsSky>(it->second.pSettings)->buildClone(); + mEditDay->setSkyAtKeyframe(sky_ptr, sliderpos, mCurrentTrack); + new_settings = sky_ptr; + } + // mSliderKeyMap still remembers old position, for simplicity, just move it to be identical to slider + F32 old_frame = it->second.mFrame; + it->second.mFrame = sliderpos; + // slider already moved old frame, create new one in old place + addSliderFrame(old_frame, new_settings, false /*because we are going to reselect new one*/); + // reselect new frame + mFramesSlider->setCurSlider(it->first); + mShiftCopyEnabled = false; + } + } + else + { + if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos) && mCanMod) + { + (*it).second.mFrame = sliderpos; + } + else + { + mFramesSlider->setCurSliderValue((*it).second.mFrame); + } + + mShiftCopyEnabled = false; + } + } + } +} + +void LLFloaterEditExtDayCycle::onFrameSliderDoubleClick(S32 x, S32 y, MASK mask) +{ + stopPlay(); + onAddFrame(); +} + +void LLFloaterEditExtDayCycle::onFrameSliderMouseDown(S32 x, S32 y, MASK mask) +{ + stopPlay(); + F32 sliderpos = mFramesSlider->getSliderValueFromPos(x, y); + + std::string slidername = mFramesSlider->getCurSlider(); + + mShiftCopyEnabled = !slidername.empty() && gKeyboard->currentMask(TRUE) == MASK_SHIFT; + + if (!slidername.empty()) + { + F32 sliderval = mFramesSlider->getSliderValue(slidername); + + if (fabs(sliderval - sliderpos) > LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR) + { + mFramesSlider->resetCurSlider(); + } + } + + mTimeSlider->setCurSliderValue(sliderpos); + + updateTabs(); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); +} + +void LLFloaterEditExtDayCycle::onFrameSliderMouseUp(S32 x, S32 y, MASK mask) +{ + F32 sliderpos = mFramesSlider->getSliderValueFromPos(x, y); + + mTimeSlider->setCurSliderValue(sliderpos); + selectFrame(sliderpos, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR); +} + + +void LLFloaterEditExtDayCycle::onPanelDirtyFlagChanged(bool value) +{ + if (value) + setDirtyFlag(); +} + +void LLFloaterEditExtDayCycle::checkAndConfirmSettingsLoss(on_confirm_fn cb) +{ + if (isDirty()) + { + LLSD args(LLSDMap("TYPE", mEditDay->getSettingsType()) + ("NAME", mEditDay->getName())); + + // create and show confirmation textbox + LLNotificationsUtil::add("SettingsConfirmLoss", args, LLSD(), + [cb](const LLSD¬if, const LLSD&resp) + { + S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); + if (opt == 0) + cb(); + }); + } + else if (cb) + { + cb(); + } +} + +void LLFloaterEditExtDayCycle::onTimeSliderCallback() +{ + stopPlay(); + selectFrame(mTimeSlider->getCurSliderValue(), LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR); +} + +void LLFloaterEditExtDayCycle::cloneTrack(U32 source_index, U32 dest_index) +{ + cloneTrack(mEditDay, source_index, dest_index); +} + +void LLFloaterEditExtDayCycle::cloneTrack(const LLSettingsDay::ptr_t &source_day, U32 source_index, U32 dest_index) +{ + if ((source_index == LLSettingsDay::TRACK_WATER || dest_index == LLSettingsDay::TRACK_WATER) && (source_index != dest_index)) + { // one of the tracks is a water track, the other is not + LLSD args; + + LL_WARNS() << "Can not import water track into sky track or vice versa" << LL_ENDL; + + LLButton* button = getChild<LLButton>(track_tabs[source_index], true); + args["TRACK1"] = button->getCurrentLabel(); + button = getChild<LLButton>(track_tabs[dest_index], true); + args["TRACK2"] = button->getCurrentLabel(); + + LLNotificationsUtil::add("TrackLoadMismatch", args); + return; + } + + // don't use replaceCycleTrack because we will end up with references, but we need to clone + + // hold on to a backup of the + LLSettingsDay::CycleTrack_t backup_track = mEditDay->getCycleTrack(dest_index); + + mEditDay->clearCycleTrack(dest_index); // because source can be empty + LLSettingsDay::CycleTrack_t source_track = source_day->getCycleTrack(source_index); + S32 addcount(0); + for (auto &track_frame : source_track) + { + LLSettingsBase::ptr_t pframe = track_frame.second; + LLSettingsBase::ptr_t pframeclone = pframe->buildDerivedClone(); + if (pframeclone) + { + ++addcount; + mEditDay->setSettingsAtKeyframe(pframeclone, track_frame.first, dest_index); + } + } + + if (!addcount) + { // nothing was actually added. Restore the old track and issue a warning. + mEditDay->replaceCycleTrack(dest_index, backup_track); + + LLSD args; + LLButton* button = getChild<LLButton>(track_tabs[dest_index], true); + args["TRACK"] = button->getCurrentLabel(); + + LLNotificationsUtil::add("TrackLoadFailed", args); + } + setDirtyFlag(); + + updateSlider(); + updateTabs(); + updateButtons(); +} + +void LLFloaterEditExtDayCycle::selectTrack(U32 track_index, bool force ) +{ + if (track_index < LLSettingsDay::TRACK_MAX) + mCurrentTrack = track_index; + + LLButton* button = getChild<LLButton>(track_tabs[mCurrentTrack], true); + if (button->getToggleState() && !force) + { + return; + } + + for (U32 i = 0; i < LLSettingsDay::TRACK_MAX; i++) // use max value + { + getChild<LLButton>(track_tabs[i], true)->setToggleState(i == mCurrentTrack); + } + + bool show_water = (mCurrentTrack == LLSettingsDay::TRACK_WATER); + mSkyTabLayoutContainer->setVisible(!show_water); + mWaterTabLayoutContainer->setVisible(show_water); + + std::string iconname = (show_water) ? "Inv_SettingsWater" : "Inv_SettingsSky"; + + mFramesSlider->setSliderThumbImage(iconname); + updateSlider(); + updateLabels(); +} + +void LLFloaterEditExtDayCycle::selectFrame(F32 frame, F32 slop_factor) +{ + mFramesSlider->resetCurSlider(); + + keymap_t::iterator iter = mSliderKeyMap.begin(); + keymap_t::iterator end_iter = mSliderKeyMap.end(); + while (iter != end_iter) + { + F32 keyframe = iter->second.mFrame; + if (fabs(keyframe - frame) <= slop_factor) + { + mFramesSlider->setCurSlider(iter->first); + frame = iter->second.mFrame; + break; + } + iter++; + } + + mTimeSlider->setCurSliderValue(frame); + // block or update tabs according to new selection + updateTabs(); +// LLEnvironment::instance().updateEnvironment(); +} + +void LLFloaterEditExtDayCycle::clearTabs() +{ + // Note: If this doesn't look good, init panels with default settings. It might be better looking + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + { + const LLSettingsWaterPtr_t p_water = LLSettingsWaterPtr_t(NULL); + updateWaterTabs(p_water); + } + else + { + const LLSettingsSkyPtr_t p_sky = LLSettingsSkyPtr_t(NULL); + updateSkyTabs(p_sky); + } + updateButtons(); + updateTimeAndLabel(); +} + +void LLFloaterEditExtDayCycle::updateTabs() +{ + reblendSettings(); + synchronizeTabs(); + + updateButtons(); + updateTimeAndLabel(); +} + +void LLFloaterEditExtDayCycle::updateWaterTabs(const LLSettingsWaterPtr_t &p_water) +{ + LLView* tab_container = mWaterTabLayoutContainer->getChild<LLView>(TABS_WATER); //can't extract panels directly, since it is in 'tuple' + LLPanelSettingsWaterMainTab* panel = dynamic_cast<LLPanelSettingsWaterMainTab*>(tab_container->findChildView("water_panel")); + if (panel) + { + panel->setWater(p_water); + } +} + +void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) +{ + LLTabContainer* tab_container = mSkyTabLayoutContainer->getChild<LLTabContainer>(TABS_SKYS); //can't extract panels directly, since they are in 'tuple' + + LLPanelSettingsSky* panel; + panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->findChildView("atmosphere_panel")); + if (panel) + { + panel->setSky(p_sky); + } + panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->findChildView("clouds_panel")); + if (panel) + { + panel->setSky(p_sky); + } + panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->findChildView("moon_panel")); + if (panel) + { + panel->setSky(p_sky); + } +} + +void LLFloaterEditExtDayCycle::updateLabels() +{ + std::string label_arg = (mCurrentTrack == LLSettingsDay::TRACK_WATER) ? "water_label" : "sky_label"; + + mAddFrameButton->setLabelArg("[FRAME]", getString(label_arg)); + mDeleteFrameButton->setLabelArg("[FRAME]", getString(label_arg)); + mLoadFrame->setLabelArg("[FRAME]", getString(label_arg)); +} + +void LLFloaterEditExtDayCycle::updateButtons() +{ + // This logic appears to work in reverse, the add frame button + // is only enabled when you're on an existing frame and disabled + // in all the interim positions where you'd want to add a frame... + + bool can_manipulate = mEditDay && !mIsPlaying && mCanMod; + bool can_clone(false); + bool can_clear(false); + + if (can_manipulate) + { + if (mCurrentTrack == 0) + { + can_clone = false; + } + else + { + for (S32 track = 1; track < LLSettingsDay::TRACK_MAX; ++track) + { + if (track == mCurrentTrack) + continue; + can_clone |= !mEditDay->getCycleTrack(track).empty(); + } + } + + can_clear = (mCurrentTrack > 1) ? (!mEditDay->getCycleTrack(mCurrentTrack).empty()) : (mEditDay->getCycleTrack(mCurrentTrack).size() > 1); + } + + mCloneTrack->setEnabled(can_clone); + mLoadTrack->setEnabled(can_manipulate); + mClearTrack->setEnabled(can_clear); + mAddFrameButton->setEnabled(can_manipulate && isAddingFrameAllowed()); + mDeleteFrameButton->setEnabled(can_manipulate && isRemovingFrameAllowed()); + mLoadFrame->setEnabled(can_manipulate); + + // update track buttons + bool extended_env = LLEnvironment::instance().isExtendedEnvironmentEnabled(); + for (S32 track = 0; track < LLSettingsDay::TRACK_MAX; ++track) + { + LLButton* button = getChild<LLButton>(track_tabs[track], true); + button->setEnabled(extended_env); + button->setToggleState(track == mCurrentTrack); + } +} + +void LLFloaterEditExtDayCycle::updateSlider() +{ + F32 frame_position = mTimeSlider->getCurSliderValue(); + mFramesSlider->clear(); + mSliderKeyMap.clear(); + + if (!mEditDay) + { + // floater is waiting for asset + return; + } + + LLSettingsDay::CycleTrack_t track = mEditDay->getCycleTrack(mCurrentTrack); + for (auto &track_frame : track) + { + addSliderFrame(track_frame.first, track_frame.second, false); + } + + if (mSliderKeyMap.size() > 0) + { + // update positions + mLastFrameSlider = mFramesSlider->getCurSlider(); + updateTabs(); + } + else + { + // disable panels + clearTabs(); + mLastFrameSlider.clear(); + } + + selectFrame(frame_position, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR); +} + +void LLFloaterEditExtDayCycle::updateTimeAndLabel() +{ + F32 time = mTimeSlider->getCurSliderValue(); + mCurrentTimeLabel->setTextArg("[PRCNT]", llformat("%.0f", time * 100)); + if (mDayLength.value() != 0) + { + LLUIString formatted_label = getString("time_label"); + + LLSettingsDay::Seconds total = (mDayLength * time); + S32Hours hrs = total; + S32Minutes minutes = total - hrs; + + formatted_label.setArg("[HH]", llformat("%d", hrs.value())); + formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); + mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString()); + } + else + { + mCurrentTimeLabel->setTextArg("[DSC]", std::string()); + } + + // Update blender here: +} + +void LLFloaterEditExtDayCycle::addSliderFrame(F32 frame, const LLSettingsBase::ptr_t &setting, bool update_ui) +{ + // multi slider distinguishes elements by key/name in string format + // store names to map to be able to recall dependencies + std::string new_slider = mFramesSlider->addSlider(frame); + if (!new_slider.empty()) + { + mSliderKeyMap[new_slider] = FrameData(frame, setting); + + if (update_ui) + { + mLastFrameSlider = new_slider; + mTimeSlider->setCurSliderValue(frame); + updateTabs(); + } + } +} + +void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() +{ + std::string sldr = mFramesSlider->getCurSlider(); + if (sldr.empty()) + { + return; + } + mFramesSlider->deleteCurSlider(); + keymap_t::iterator iter = mSliderKeyMap.find(sldr); + if (iter != mSliderKeyMap.end()) + { + LL_DEBUGS("ENVDAYEDIT") << "Removing frame from " << iter->second.mFrame << LL_ENDL; + LLSettingsBase::Seconds seconds(iter->second.mFrame); + mEditDay->removeTrackKeyframe(mCurrentTrack, seconds); + mSliderKeyMap.erase(iter); + } + + mLastFrameSlider = mFramesSlider->getCurSlider(); + mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue()); + updateTabs(); +} + +void LLFloaterEditExtDayCycle::removeSliderFrame(F32 frame) +{ + keymap_t::iterator it = std::find_if(mSliderKeyMap.begin(), mSliderKeyMap.end(), + [frame](const keymap_t::value_type &value) { return fabs(value.second.mFrame - frame) < LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR; }); + + if (it != mSliderKeyMap.end()) + { + mFramesSlider->deleteSlider((*it).first); + mSliderKeyMap.erase(it); + } + +} + +//------------------------------------------------------------------------- + +LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSignal(LLFloaterEditExtDayCycle::edit_commit_signal_t::slot_type cb) +{ + return mCommitSignal.connect(cb); +} + +void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId) +{ + if (inventoryId.isNull()) + { + mInventoryItem = nullptr; + mInventoryId.setNull(); + mCanCopy = true; + mCanMod = true; + mCanTrans = true; + return; + } + + mInventoryId = inventoryId; + LL_INFOS("ENVDAYEDIT") << "Setting edit inventory item to " << mInventoryId << "." << LL_ENDL; + mInventoryItem = gInventory.getItem(mInventoryId); + + if (!mInventoryItem) + { + LL_WARNS("ENVDAYEDIT") << "Could not find inventory item with Id = " << mInventoryId << LL_ENDL; + + LLNotificationsUtil::add("CantFindInvItem"); + closeFloater(); + mInventoryId.setNull(); + mInventoryItem = nullptr; + return; + } + + if (mInventoryItem->getAssetUUID().isNull()) + { + LL_WARNS("ENVDAYEDIT") << "Asset ID in inventory item is NULL (" << mInventoryId << ")" << LL_ENDL; + + LLNotificationsUtil::add("UnableEditItem"); + closeFloater(); + + mInventoryId.setNull(); + mInventoryItem = nullptr; + return; + } + + mCanCopy = mInventoryItem->getPermissions().allowCopyBy(gAgent.getID()); + mCanMod = mInventoryItem->getPermissions().allowModifyBy(gAgent.getID()); + mCanTrans = mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); + + mExpectingAssetId = mInventoryItem->getAssetUUID(); + LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), + [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); +} + +void LLFloaterEditExtDayCycle::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +{ + if (asset_id != mExpectingAssetId) + { + LL_WARNS("ENVDAYEDIT") << "Expecting {" << mExpectingAssetId << "} got {" << asset_id << "} - throwing away." << LL_ENDL; + return; + } + mExpectingAssetId.setNull(); + clearDirtyFlag(); + + if (!settings || status) + { + LLSD args; + args["NAME"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown"; + LLNotificationsUtil::add("FailedToFindSettings", args); + closeFloater(); + return; + } + + if (mCanCopy) + settings->clearFlag(LLSettingsBase::FLAG_NOCOPY); + else + settings->setFlag(LLSettingsBase::FLAG_NOCOPY); + + if (mCanMod) + settings->clearFlag(LLSettingsBase::FLAG_NOMOD); + else + settings->setFlag(LLSettingsBase::FLAG_NOMOD); + + if (mCanTrans) + settings->clearFlag(LLSettingsBase::FLAG_NOTRANS); + else + settings->setFlag(LLSettingsBase::FLAG_NOTRANS); + + if (mInventoryItem) + settings->setName(mInventoryItem->getName()); + + setEditDayCycle(std::dynamic_pointer_cast<LLSettingsDay>(settings)); +} + +void LLFloaterEditExtDayCycle::updateEditEnvironment(void) +{ + if (!mEditDay) + return; + S32 skytrack = (mCurrentTrack) ? mCurrentTrack : 1; + mSkyBlender = std::make_shared<LLTrackBlenderLoopingManual>(mScratchSky, mEditDay, skytrack); + mWaterBlender = std::make_shared<LLTrackBlenderLoopingManual>(mScratchWater, mEditDay, LLSettingsDay::TRACK_WATER); + + if (LLEnvironment::instance().isExtendedEnvironmentEnabled()) + { + selectTrack(LLSettingsDay::TRACK_MAX, true); + } + else + { + selectTrack(1, true); + } + + reblendSettings(); + + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditSky, mEditWater); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); +} + +void LLFloaterEditExtDayCycle::synchronizeTabs() +{ + // This should probably get moved into "updateTabs" + LLSettingsBase::TrackPosition frame(mTimeSlider->getCurSliderValue()); + bool canedit(false); + + LLSettingsWater::ptr_t psettingW; + LLTabContainer * tabs = mWaterTabLayoutContainer->getChild<LLTabContainer>(TABS_WATER); + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + { + if (!mEditDay) + { + canedit = false; + } + else if (!mFramesSlider->getCurSlider().empty()) + { + canedit = !mIsPlaying; + // either search mEditDay or retrieve from mSliderKeyMap + LLSettingsDay::CycleTrack_t::value_type found = mEditDay->getSettingsNearKeyframe(frame, LLSettingsDay::TRACK_WATER, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR); + psettingW = std::static_pointer_cast<LLSettingsWater>(found.second); + } + mCurrentEdit = psettingW; + if (!psettingW) + { + canedit = false; + psettingW = mScratchWater; + } + + getChild<LLUICtrl>(ICN_LOCK_EDIT)->setVisible(!canedit); + } + else + { + psettingW = mScratchWater; + } + mEditWater = psettingW; + + setTabsData(tabs, psettingW, canedit); + + LLSettingsSky::ptr_t psettingS; + canedit = false; + tabs = mSkyTabLayoutContainer->getChild<LLTabContainer>(TABS_SKYS); + if (mCurrentTrack != LLSettingsDay::TRACK_WATER) + { + if (!mEditDay) + { + canedit = false; + } + else if (!mFramesSlider->getCurSlider().empty()) + { + canedit = !mIsPlaying; + // either search mEditDay or retrieve from mSliderKeyMap + LLSettingsDay::CycleTrack_t::value_type found = mEditDay->getSettingsNearKeyframe(frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR); + psettingS = std::static_pointer_cast<LLSettingsSky>(found.second); + } + mCurrentEdit = psettingS; + if (!psettingS) + { + canedit = false; + psettingS = mScratchSky; + } + + getChild<LLUICtrl>(ICN_LOCK_EDIT)->setVisible(!canedit); + } + else + { + psettingS = mScratchSky; + } + mEditSky = psettingS; + + doCloseInventoryFloater(); + doCloseTrackFloater(); + + setTabsData(tabs, psettingS, canedit); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditSky, mEditWater); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); +} + +void LLFloaterEditExtDayCycle::setTabsData(LLTabContainer * tabcontainer, const LLSettingsBase::ptr_t &settings, bool editable) +{ + S32 count = tabcontainer->getTabCount(); + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tabcontainer->getPanelByIndex(idx)); + if (panel) + { + panel->setSettings(settings); + panel->setCanChangeSettings(editable & mCanMod); + } + } +} + + +void LLFloaterEditExtDayCycle::reblendSettings() +{ + F64 position = mTimeSlider->getCurSliderValue(); + + if ((mSkyBlender->getTrack() != mCurrentTrack) && (mCurrentTrack != LLSettingsDay::TRACK_WATER)) + { + mSkyBlender->switchTrack(mCurrentTrack, position); + } + else + mSkyBlender->setPosition(position); + + mWaterBlender->setPosition(position); +} + +void LLFloaterEditExtDayCycle::doApplyCreateNewInventory(const LLSettingsDay::ptr_t &day, std::string settings_name) +{ + if (mInventoryItem) + { + LLUUID parent_id = mInventoryItem->getParentUUID(); + U32 next_owner_perm = mInventoryItem->getPermissions().getMaskNextOwner(); + LLSettingsVOBase::createInventoryItem(day, next_owner_perm, parent_id, settings_name, + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); + } + else + { + LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); + // This method knows what sort of settings object to create. + LLSettingsVOBase::createInventoryItem(day, parent_id, settings_name, + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); + } +} + +void LLFloaterEditExtDayCycle::doApplyUpdateInventory(const LLSettingsDay::ptr_t &day) +{ + if (mInventoryId.isNull()) + LLSettingsVOBase::createInventoryItem(day, gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS), std::string(), + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); + else + LLSettingsVOBase::updateInventoryItem(day, mInventoryId, + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryUpdated(asset_id, inventory_id, results); }); +} + +void LLFloaterEditExtDayCycle::doApplyEnvironment(const std::string &where, const LLSettingsDay::ptr_t &day) +{ + if (where == ACTION_APPLY_LOCAL) + { + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, day); + } + else if (where == ACTION_APPLY_PARCEL) + { + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + + if ((!parcel) || (parcel->getLocalID() == INVALID_PARCEL_ID)) + { + LL_WARNS("ENVDAYEDIT") << "Can not identify parcel. Not applying." << LL_ENDL; + LLNotificationsUtil::add("WLParcelApplyFail"); + return; + } + + if (mInventoryItem && !isDirty()) + { + LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1); + } + else + { + LLEnvironment::instance().updateParcel(parcel->getLocalID(), day, -1, -1); + } + } + else if (where == ACTION_APPLY_REGION) + { + if (mInventoryItem && !isDirty()) + { + LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1); + } + else + { + LLEnvironment::instance().updateRegion(day, -1, -1); + } + } + else + { + LL_WARNS("ENVDAYEDIT") << "Unknown apply '" << where << "'" << LL_ENDL; + return; + } + +} + +void LLFloaterEditExtDayCycle::doApplyCommit(LLSettingsDay::ptr_t day) +{ + if (!mCommitSignal.empty()) + { + mCommitSignal(day); + + closeFloater(); + } +} + +bool LLFloaterEditExtDayCycle::isRemovingFrameAllowed() +{ + if (mFramesSlider->getCurSlider().empty()) return false; + + if (mCurrentTrack <= LLSettingsDay::TRACK_GROUND_LEVEL) + { + return (mSliderKeyMap.size() > 1); + } + else + { + return (mSliderKeyMap.size() > 0); + } +} + +bool LLFloaterEditExtDayCycle::isAddingFrameAllowed() +{ + if (!mFramesSlider->getCurSlider().empty() || !mEditDay) return false; + + LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); + if ((mEditDay->getSettingsNearKeyframe(frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second) + { + return false; + } + return mFramesSlider->canAddSliders(); +} + +void LLFloaterEditExtDayCycle::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ + LL_INFOS("ENVDAYEDIT") << "Inventory item " << inventory_id << " has been created with asset " << asset_id << " results are:" << results << LL_ENDL; + + if (inventory_id.isNull() || !results["success"].asBoolean()) + { + LLNotificationsUtil::add("CantCreateInventory"); + return; + } + onInventoryCreated(asset_id, inventory_id); +} + +void LLFloaterEditExtDayCycle::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id) +{ + + if (mInventoryItem) + { + LLPermissions perms = mInventoryItem->getPermissions(); + + LLInventoryItem *created_item = gInventory.getItem(mInventoryId); + + if (created_item) + { + created_item->setPermissions(perms); + created_item->updateServer(false); + } + } + + clearDirtyFlag(); + setFocus(TRUE); // Call back the focus... + loadInventoryItem(inventory_id); +} + +void LLFloaterEditExtDayCycle::onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ + LL_WARNS("ENVDAYEDIT") << "Inventory item " << inventory_id << " has been updated with asset " << asset_id << " results are:" << results << LL_ENDL; + + clearDirtyFlag(); + if (inventory_id != mInventoryId) + { + loadInventoryItem(inventory_id); + } +} + +void LLFloaterEditExtDayCycle::doImportFromDisk() +{ // Load a a legacy Windlight XML from disk. + (new LLFilePickerReplyThread(boost::bind(&LLFloaterEditExtDayCycle::loadSettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false))->getFile(); +} + +void LLFloaterEditExtDayCycle::loadSettingFromFile(const std::vector<std::string>& filenames) +{ + LLSD messages; + if (filenames.size() < 1) return; + std::string filename = filenames[0]; + LL_DEBUGS("ENVDAYEDIT") << "Selected file: " << filename << LL_ENDL; + LLSettingsDay::ptr_t legacyday = LLEnvironment::createDayCycleFromLegacyPreset(filename, messages); + + if (!legacyday) + { + LLNotificationsUtil::add("WLImportFail", messages); + return; + } + + loadInventoryItem(LLUUID::null); + + mCurrentTrack = 1; + setDirtyFlag(); + setEditDayCycle(legacyday); +} + +bool LLFloaterEditExtDayCycle::canUseInventory() const +{ + return LLEnvironment::instance().isInventoryEnabled(); +} + +bool LLFloaterEditExtDayCycle::canApplyRegion() const +{ + return gAgent.canManageEstate(); +} + +bool LLFloaterEditExtDayCycle::canApplyParcel() const +{ + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); +} + +void LLFloaterEditExtDayCycle::startPlay() +{ + doCloseInventoryFloater(); + doCloseTrackFloater(); + + mIsPlaying = true; + mFramesSlider->resetCurSlider(); + mPlayTimer.reset(); + mPlayTimer.start(); + gIdleCallbacks.addFunction(onIdlePlay, this); + mPlayStartFrame = mTimeSlider->getCurSliderValue(); + + getChild<LLView>("play_layout", true)->setVisible(FALSE); + getChild<LLView>("pause_layout", true)->setVisible(TRUE); +} + +void LLFloaterEditExtDayCycle::stopPlay() +{ + if (!mIsPlaying) + return; + + mIsPlaying = false; + gIdleCallbacks.deleteFunction(onIdlePlay, this); + mPlayTimer.stop(); + F32 frame = mTimeSlider->getCurSliderValue(); + selectFrame(frame, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR); + + getChild<LLView>("play_layout", true)->setVisible(TRUE); + getChild<LLView>("pause_layout", true)->setVisible(FALSE); +} + +//static +void LLFloaterEditExtDayCycle::onIdlePlay(void* user_data) +{ + if (!gDisconnected) + { + LLFloaterEditExtDayCycle* self = (LLFloaterEditExtDayCycle*)user_data; + + F32 prcnt_played = self->mPlayTimer.getElapsedTimeF32() / DAY_CYCLE_PLAY_TIME_SECONDS; + F32 new_frame = fmod(self->mPlayStartFrame + prcnt_played, 1.f); + + self->mTimeSlider->setCurSliderValue(new_frame); // will do the rounding + self->mSkyBlender->setPosition(new_frame); + self->mWaterBlender->setPosition(new_frame); + self->synchronizeTabs(); + self->updateTimeAndLabel(); + self->updateButtons(); + } +} + + +void LLFloaterEditExtDayCycle::clearDirtyFlag() +{ + mIsDirty = false; + + LLTabContainer* tab_container = mSkyTabLayoutContainer->getChild<LLTabContainer>("sky_tabs"); + S32 tab_count = tab_container->getTabCount(); + + for (S32 idx = 0; idx < tab_count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tab_container->getPanelByIndex(idx)); + if (panel) + panel->clearIsDirty(); + } + + tab_container = mWaterTabLayoutContainer->getChild<LLTabContainer>("water_tabs"); + tab_count = tab_container->getTabCount(); + + for (S32 idx = 0; idx < tab_count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tab_container->getPanelByIndex(idx)); + if (panel) + panel->clearIsDirty(); + } + +} + +void LLFloaterEditExtDayCycle::doOpenTrackFloater(const LLSD &args) +{ + LLFloaterTrackPicker *picker = static_cast<LLFloaterTrackPicker *>(mTrackFloater.get()); + + // Show the dialog + if (!picker) + { + picker = new LLFloaterTrackPicker(this); + + mTrackFloater = picker->getHandle(); + + picker->setCommitCallback([this](LLUICtrl *, const LLSD &data){ onPickerCommitTrackId(data.asInteger()); }); + } + + picker->showPicker(args); +} + +void LLFloaterEditExtDayCycle::doCloseTrackFloater(bool quitting) +{ + LLFloater* floaterp = mTrackFloater.get(); + + if (floaterp) + { + floaterp->closeFloater(quitting); + } +} + +void LLFloaterEditExtDayCycle::onPickerCommitTrackId(U32 track_id) +{ + cloneTrack(track_id, mCurrentTrack); +} + +void LLFloaterEditExtDayCycle::doOpenInventoryFloater(LLSettingsType::type_e type, LLUUID curritem) +{ +// LLUI::sWindow->setCursor(UI_CURSOR_WAIT); + LLFloaterSettingsPicker *picker = static_cast<LLFloaterSettingsPicker *>(mInventoryFloater.get()); + + // Show the dialog + if (!picker) + { + picker = new LLFloaterSettingsPicker(this, + LLUUID::null); + + mInventoryFloater = picker->getHandle(); + + picker->setCommitCallback([this](LLUICtrl *, const LLSD &data){ onPickerCommitSetting(data["ItemId"].asUUID(), data["Track"].asInteger()); }); + } + + picker->setSettingsFilter(type); + picker->setSettingsItemId(curritem); + if (type == LLSettingsType::ST_DAYCYCLE) + { + picker->setTrackMode((mCurrentTrack == LLSettingsDay::TRACK_WATER) ? LLFloaterSettingsPicker::TRACK_WATER : LLFloaterSettingsPicker::TRACK_SKY); + } + else + { + picker->setTrackMode(LLFloaterSettingsPicker::TRACK_NONE); + } + picker->openFloater(); + picker->setFocus(TRUE); +} + +void LLFloaterEditExtDayCycle::doCloseInventoryFloater(bool quitting) +{ + LLFloater* floaterp = mInventoryFloater.get(); + + if (floaterp) + { + floaterp->closeFloater(quitting); + } +} + +void LLFloaterEditExtDayCycle::onPickerCommitSetting(LLUUID item_id, S32 track) +{ + LLSettingsBase::TrackPosition frame(mTimeSlider->getCurSliderValue()); + LLViewerInventoryItem *itemp = gInventory.getItem(item_id); + if (itemp) + { + LLSettingsVOBase::getSettingsAsset(itemp->getAssetUUID(), + [this, track, frame, item_id](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoadedForInsertion(item_id, asset_id, settings, status, track, mCurrentTrack, frame); }); + } +} + +void LLFloaterEditExtDayCycle::onAssetLoadedForInsertion(LLUUID item_id, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 source_track, S32 dest_track, LLSettingsBase::TrackPosition frame) +{ + std::function<void()> cb = [this, settings, frame, source_track, dest_track]() + { + if (settings->getSettingsType() == "daycycle") + { + // Load full track + LLSettingsDay::ptr_t pday = std::dynamic_pointer_cast<LLSettingsDay>(settings); + if (dest_track == LLSettingsDay::TRACK_WATER) + { + cloneTrack(pday, LLSettingsDay::TRACK_WATER, LLSettingsDay::TRACK_WATER); + } + else + { + cloneTrack(pday, source_track, dest_track); + } + } + else + { + if (!mFramesSlider->canAddSliders()) + { + LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame when slider is full." << LL_ENDL; + return; + } + + // load or replace single frame + LLSettingsDay::CycleTrack_t::value_type nearest = mEditDay->getSettingsNearKeyframe(frame, dest_track, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR); + if (nearest.first != LLSettingsDay::INVALID_TRACKPOS) + { // There is already a frame near the target location. Remove it so we can put the new one in its place. + mEditDay->removeTrackKeyframe(dest_track, nearest.first); + removeSliderFrame(nearest.first); + } + + // Don't forget to clone (we might reuse/load it couple times) + if (settings->getSettingsType() == "sky") + { + // Load sky to frame + if (dest_track != LLSettingsDay::TRACK_WATER) + { + mEditDay->setSettingsAtKeyframe(settings->buildDerivedClone(), frame, dest_track); + addSliderFrame(frame, settings, false); + } + else + { + LL_WARNS("ENVDAYEDIT") << "Trying to load day settings as sky" << LL_ENDL; + } + } + else if (settings->getSettingsType() == "water") + { + // Load water to frame + if (dest_track == LLSettingsDay::TRACK_WATER) + { + mEditDay->setSettingsAtKeyframe(settings->buildDerivedClone(), frame, dest_track); + addSliderFrame(frame, settings, false); + } + else + { + LL_WARNS("ENVDAYEDIT") << "Trying to load water settings as sky" << LL_ENDL; + } + } + } + reblendSettings(); + synchronizeTabs(); + }; + + if (!settings || status) + { + LL_WARNS("ENVDAYEDIT") << "Could not load asset " << asset_id << " into frame. status=" << status << LL_ENDL; + return; + } + + if (!mEditDay) + { + // day got reset while we were waiting for response + return; + } + + LLInventoryItem *inv_item = gInventory.getItem(item_id); + + if (inv_item && !inv_item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) + { + // Need to check if item is already no-transfer, otherwise make it no-transfer + bool no_transfer = false; + if (mInventoryItem) + { + no_transfer = !mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); + } + else + { + no_transfer = mEditDay->getFlag(LLSettingsBase::FLAG_NOTRANS); + } + + if (!no_transfer) + { + LLSD args; + + // create and show confirmation textbox + LLNotificationsUtil::add("SettingsMakeNoTrans", args, LLSD(), + [this, cb](const LLSD¬if, const LLSD&resp) + { + S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); + if (opt == 0) + { + mCanTrans = false; + mEditDay->setFlag(LLSettingsBase::FLAG_NOTRANS); + cb(); + } + }); + return; + } + } + + cb(); +} diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h new file mode 100644 index 0000000000..c271f15840 --- /dev/null +++ b/indra/newview/llfloatereditextdaycycle.h @@ -0,0 +1,261 @@ +/** + * @file llfloatereditextdaycycle.h + * @brief Floater to create or edit a day cycle + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATEREDITEXTDAYCYCLE_H +#define LL_LLFLOATEREDITEXTDAYCYCLE_H + +#include "llfloater.h" +#include "llsettingsdaycycle.h" +#include <boost/signals2.hpp> + +#include "llenvironment.h" + +class LLCheckBoxCtrl; +class LLComboBox; +class LLFlyoutComboBtnCtrl; +class LLLineEditor; +class LLMultiSliderCtrl; +class LLTextBox; +class LLTimeCtrl; +class LLTabContainer; + +class LLInventoryItem; +class LLDaySettingCopiedCallback; + +typedef std::shared_ptr<LLSettingsBase> LLSettingsBasePtr_t; + +/** + * Floater for creating or editing a day cycle. + */ +class LLFloaterEditExtDayCycle : public LLFloater +{ + LOG_CLASS(LLFloaterEditExtDayCycle); + + friend class LLDaySettingCopiedCallback; + +public: + static const std::string KEY_INVENTORY_ID; + static const std::string KEY_EDIT_CONTEXT; + static const std::string KEY_DAY_LENGTH; + static const std::string KEY_CANMOD; + + static const std::string VALUE_CONTEXT_INVENTORY; + static const std::string VALUE_CONTEXT_PARCEL; + static const std::string VALUE_CONTEXT_REGION; + + enum edit_context_t { + CONTEXT_UNKNOWN, + CONTEXT_INVENTORY, + CONTEXT_PARCEL, + CONTEXT_REGION + }; + + typedef boost::signals2::signal<void(LLSettingsDay::ptr_t)> edit_commit_signal_t; + typedef boost::signals2::connection connection_t; + + LLFloaterEditExtDayCycle(const LLSD &key); + virtual ~LLFloaterEditExtDayCycle(); + + virtual BOOL postBuild() override; + virtual void onOpen(const LLSD& key) override; + virtual void onClose(bool app_quitting) override; + virtual void onFocusReceived() override; + virtual void onFocusLost() override; + virtual void onVisibilityChange(BOOL new_visibility) override; + + connection_t setEditCommitSignal(edit_commit_signal_t::slot_type cb); + + virtual void refresh() override; + + void setEditDayCycle(const LLSettingsDay::ptr_t &pday); + void setEditDefaultDayCycle(); + std::string getEditName() const; + void setEditName(const std::string &name); + LLUUID getEditingAssetId() { return mEditDay ? mEditDay->getAssetId() : LLUUID::null; } + LLUUID getEditingInventoryId() { return mInventoryId; } + + + BOOL handleKeyUp(KEY key, MASK mask, BOOL called_from_parent) override; + + BOOL isDirty() const override { return getIsDirty(); } + +private: + typedef std::function<void()> on_confirm_fn; + F32 getCurrentFrame() const; + + // flyout response/click + void onButtonApply(LLUICtrl *ctrl, const LLSD &data); + virtual void onClickCloseBtn(bool app_quitting = false) override; + void onButtonImport(); + void onButtonLoadFrame(); + void onAddFrame(); + void onRemoveFrame(); + void onCloneTrack(); + void onLoadTrack(); + void onClearTrack(); + void onCommitName(class LLLineEditor* caller, void* user_data); + void onTrackSelectionCallback(const LLSD& user_data); + void onPlayActionCallback(const LLSD& user_data); + void onSaveAsCommit(const LLSD& notification, const LLSD& response, const LLSettingsDay::ptr_t &day); + // time slider clicked + void onTimeSliderCallback(); + // a frame moved or frame selection changed + void onFrameSliderCallback(const LLSD &); + void onFrameSliderDoubleClick(S32 x, S32 y, MASK mask); + void onFrameSliderMouseDown(S32 x, S32 y, MASK mask); + void onFrameSliderMouseUp(S32 x, S32 y, MASK mask); + + void onPanelDirtyFlagChanged(bool); + + void checkAndConfirmSettingsLoss(on_confirm_fn cb); + + void cloneTrack(U32 source_index, U32 dest_index); + void cloneTrack(const LLSettingsDay::ptr_t &source_day, U32 source_index, U32 dest_index); + void selectTrack(U32 track_index, bool force = false); + void selectFrame(F32 frame, F32 slop_factor); + void clearTabs(); + void updateTabs(); + void updateWaterTabs(const LLSettingsWaterPtr_t &p_water); + void updateSkyTabs(const LLSettingsSkyPtr_t &p_sky); + void updateButtons(); + void updateLabels(); + void updateSlider(); //generate sliders from current track + void updateTimeAndLabel(); + void addSliderFrame(F32 frame, const LLSettingsBase::ptr_t &setting, bool update_ui = true); + void removeCurrentSliderFrame(); + void removeSliderFrame(F32 frame); + + void loadInventoryItem(const LLUUID &inventoryId); + void onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); + + void doImportFromDisk(); + void loadSettingFromFile(const std::vector<std::string>& filenames); + void doApplyCreateNewInventory(const LLSettingsDay::ptr_t &day, std::string settings_name); + void doApplyUpdateInventory(const LLSettingsDay::ptr_t &day); + void doApplyEnvironment(const std::string &where, const LLSettingsDay::ptr_t &day); + void doApplyCommit(LLSettingsDay::ptr_t day); + void onInventoryCreated(LLUUID asset_id, LLUUID inventory_id); + void onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results); + void onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results); + + void doOpenTrackFloater(const LLSD &args); + void doCloseTrackFloater(bool quitting = false); + void onPickerCommitTrackId(U32 track_id); + + void doOpenInventoryFloater(LLSettingsType::type_e type, LLUUID curritem); + void doCloseInventoryFloater(bool quitting = false); + void onPickerCommitSetting(LLUUID item_id, S32 track); + void onAssetLoadedForInsertion(LLUUID item_id, + LLUUID asset_id, + LLSettingsBase::ptr_t settings, + S32 status, + S32 source_track, + S32 dest_track, + LLSettingsBase::TrackPosition dest_frame); + + bool canUseInventory() const; + bool canApplyRegion() const; + bool canApplyParcel() const; + + void updateEditEnvironment(); + void synchronizeTabs(); + void reblendSettings(); + + void setTabsData(LLTabContainer * tabcontainer, const LLSettingsBase::ptr_t &settings, bool editable); + + // play functions + void startPlay(); + void stopPlay(); + static void onIdlePlay(void *); + + bool getIsDirty() const { return mIsDirty; } + void setDirtyFlag() { mIsDirty = true; } + virtual void clearDirtyFlag(); + + bool isRemovingFrameAllowed(); + bool isAddingFrameAllowed(); + + LLSettingsDay::ptr_t mEditDay; // edited copy + LLSettingsDay::Seconds mDayLength; + U32 mCurrentTrack; + std::string mLastFrameSlider; + bool mShiftCopyEnabled; + + LLUUID mExpectingAssetId; + + LLButton* mAddFrameButton; + LLButton* mDeleteFrameButton; + LLButton* mImportButton; + LLButton* mLoadFrame; + LLButton * mCloneTrack; + LLButton * mLoadTrack; + LLButton * mClearTrack; + LLMultiSliderCtrl* mTimeSlider; + LLMultiSliderCtrl* mFramesSlider; + LLView* mSkyTabLayoutContainer; + LLView* mWaterTabLayoutContainer; + LLTextBox* mCurrentTimeLabel; + LLUUID mInventoryId; + LLInventoryItem * mInventoryItem; + LLFlyoutComboBtnCtrl * mFlyoutControl; + + LLHandle<LLFloater> mInventoryFloater; + LLHandle<LLFloater> mTrackFloater; + + LLTrackBlenderLoopingManual::ptr_t mSkyBlender; + LLTrackBlenderLoopingManual::ptr_t mWaterBlender; + LLSettingsSky::ptr_t mScratchSky; + LLSettingsWater::ptr_t mScratchWater; + LLSettingsBase::ptr_t mCurrentEdit; + LLSettingsSky::ptr_t mEditSky; + LLSettingsWater::ptr_t mEditWater; + + LLFrameTimer mPlayTimer; + F32 mPlayStartFrame; // an env frame + bool mIsPlaying; + bool mIsDirty; + bool mCanCopy; + bool mCanMod; + bool mCanTrans; + + edit_commit_signal_t mCommitSignal; + + edit_context_t mEditContext; + + // For map of sliders to parameters + class FrameData + { + public: + FrameData() : mFrame(0) {}; + FrameData(F32 frame, LLSettingsBase::ptr_t settings) : mFrame(frame), pSettings(settings) {}; + F32 mFrame; + LLSettingsBase::ptr_t pSettings; + }; + typedef std::map<std::string, FrameData> keymap_t; + keymap_t mSliderKeyMap; //slider's keys vs old_frames&settings, shadows mFramesSlider +}; + +#endif // LL_LLFloaterEditExtDayCycle_H diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index d809211ea7..6bdc5ee823 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -28,6 +28,8 @@ #include "llfloatereditsky.h" +#include <boost/make_shared.hpp> + // libs #include "llbutton.h" #include "llcheckboxctrl.h" @@ -38,6 +40,7 @@ #include "llsliderctrl.h" #include "lltabcontainer.h" #include "lltimectrl.h" +#include "lljoystickbutton.h" // newview #include "llagent.h" @@ -45,15 +48,18 @@ #include "llregioninfomodel.h" #include "llviewerregion.h" -static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; -static const F32 WL_BLUE_HORIZON_DENSITY_SCALE = 2.0f; -static const F32 WL_CLOUD_SLIDER_SCALE = 1.0f; +#include "v3colorutil.h" +#include "llenvironment.h" +#include "llenvadapters.h" -static F32 sun_pos_to_time24(F32 sun_pos) +namespace { - return fmodf(sun_pos * 24.0f + 6, 24.0f); + const F32 WL_SUN_AMBIENT_SLIDER_SCALE(3.0f); + const F32 WL_BLUE_HORIZON_DENSITY_SCALE(2.0f); + const F32 WL_CLOUD_SLIDER_SCALE(1.0f); } + static F32 time24_to_sun_pos(F32 time24) { F32 sun_pos = fmodf((time24 - 6) / 24.0f, 1.0f); @@ -61,12 +67,13 @@ static F32 time24_to_sun_pos(F32 time24) return sun_pos; } -LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) -: LLFloater(key) -, mSkyPresetNameEditor(NULL) -, mSkyPresetCombo(NULL) -, mMakeDefaultCheckBox(NULL) -, mSaveButton(NULL) +LLFloaterEditSky::LLFloaterEditSky(const LLSD &key): + LLFloater(key), + mSkyPresetNameEditor(NULL), + mSkyPresetCombo(NULL), + mMakeDefaultCheckBox(NULL), + mSaveButton(NULL), + mSkyAdapter() { } @@ -77,11 +84,14 @@ BOOL LLFloaterEditSky::postBuild() mSkyPresetCombo = getChild<LLComboBox>("sky_preset_combo"); mMakeDefaultCheckBox = getChild<LLCheckBoxCtrl>("make_default_cb"); mSaveButton = getChild<LLButton>("save"); + mSkyAdapter = boost::make_shared<LLSkySettingsAdapter>(); + + LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); initCallbacks(); - // Create the sun position scrubber on the slider. - getChild<LLMultiSliderCtrl>("WLSunPos")->addSlider(12.f); +// // Create the sun position scrubber on the slider. +// getChild<LLMultiSliderCtrl>("WLSunPos")->addSlider(12.f); return TRUE; } @@ -115,7 +125,8 @@ void LLFloaterEditSky::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } } @@ -137,71 +148,47 @@ void LLFloaterEditSky::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditSky::onRegionSettingsChange, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); - // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditSky::onRegionInfoUpdate, this)); - //------------------------------------------------------------------------- - - LLWLParamManager& param_mgr = LLWLParamManager::instance(); - - // blue horizon - getChild<LLUICtrl>("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueHorizon)); - - // haze density, horizon, mult, and altitude - getChild<LLUICtrl>("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mHazeDensity)); - getChild<LLUICtrl>("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mHazeHorizon)); - getChild<LLUICtrl>("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDensityMult)); - getChild<LLUICtrl>("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mMaxAlt)); - - // blue density - getChild<LLUICtrl>("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueDensity)); - - // Lighting - // sunlight - getChild<LLUICtrl>("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mSunlight)); + getChild<LLUICtrl>("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mSunlight)); // glow - getChild<LLUICtrl>("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, ¶m_mgr.mGlow)); - getChild<LLUICtrl>("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, ¶m_mgr.mGlow)); - - // ambient - getChild<LLUICtrl>("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mAmbient)); + getChild<LLUICtrl>("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, &mSkyAdapter->mGlow)); + getChild<LLUICtrl>("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, &mSkyAdapter->mGlow)); // time of day - getChild<LLUICtrl>("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // multi-slider - getChild<LLTimeCtrl>("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl - getChild<LLUICtrl>("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); +// getChild<LLUICtrl>("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider +// getChild<LLTimeCtrl>("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl +// getChild<LLUICtrl>("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); + getChild<LLJoystickQuaternion>("WLSunRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunRotationChanged, this)); + getChild<LLJoystickQuaternion>("WLMoonRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onMoonRotationChanged, this)); // Clouds // Cloud Color - getChild<LLUICtrl>("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mCloudColor)); + getChild<LLUICtrl>("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mCloudColor)); // Cloud - getChild<LLUICtrl>("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudMain)); - getChild<LLUICtrl>("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudMain)); - getChild<LLUICtrl>("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudMain)); + getChild<LLUICtrl>("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudMain)); + getChild<LLUICtrl>("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudMain)); + getChild<LLUICtrl>("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudMain)); // Cloud Detail - getChild<LLUICtrl>("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudDetail)); - getChild<LLUICtrl>("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudDetail)); - getChild<LLUICtrl>("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudDetail)); + getChild<LLUICtrl>("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudDetail)); + getChild<LLUICtrl>("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudDetail)); + getChild<LLUICtrl>("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudDetail)); // Cloud extras - getChild<LLUICtrl>("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudCoverage)); - getChild<LLUICtrl>("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudScale)); - getChild<LLUICtrl>("WLCloudLockX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXToggled, this, _1)); - getChild<LLUICtrl>("WLCloudLockY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYToggled, this, _1)); + getChild<LLUICtrl>("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudCoverage)); + getChild<LLUICtrl>("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudScale)); getChild<LLUICtrl>("WLCloudScrollX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXMoved, this, _1)); getChild<LLUICtrl>("WLCloudScrollY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYMoved, this, _1)); - getChild<LLUICtrl>("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDistanceMult)); + // Dome - getChild<LLUICtrl>("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mWLGamma)); + getChild<LLUICtrl>("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mWLGamma)); getChild<LLUICtrl>("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterEditSky::onStarAlphaMoved, this, _1)); } @@ -209,320 +196,229 @@ void LLFloaterEditSky::initCallbacks(void) void LLFloaterEditSky::syncControls() { - bool err; - - LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); - - LLWLParamSet& cur_params = param_mgr->mCurParams; + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + mEditSettings = psky; - // blue horizon - param_mgr->mBlueHorizon = cur_params.getVector(param_mgr->mBlueHorizon.mName, err); - setColorSwatch("WLBlueHorizon", param_mgr->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); + std::string name = psky->getName(); - // haze density, horizon, mult, and altitude - param_mgr->mHazeDensity = cur_params.getFloat(param_mgr->mHazeDensity.mName, err); - childSetValue("WLHazeDensity", (F32) param_mgr->mHazeDensity); - param_mgr->mHazeHorizon = cur_params.getFloat(param_mgr->mHazeHorizon.mName, err); - childSetValue("WLHazeHorizon", (F32) param_mgr->mHazeHorizon); - param_mgr->mDensityMult = cur_params.getFloat(param_mgr->mDensityMult.mName, err); - childSetValue("WLDensityMult", ((F32) param_mgr->mDensityMult) * param_mgr->mDensityMult.mult); - param_mgr->mMaxAlt = cur_params.getFloat(param_mgr->mMaxAlt.mName, err); - childSetValue("WLMaxAltitude", (F32) param_mgr->mMaxAlt); - - // blue density - param_mgr->mBlueDensity = cur_params.getVector(param_mgr->mBlueDensity.mName, err); - setColorSwatch("WLBlueDensity", param_mgr->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); + mSkyPresetNameEditor->setText(name); + mSkyPresetCombo->setValue(name); // Lighting // sunlight - param_mgr->mSunlight = cur_params.getVector(param_mgr->mSunlight.mName, err); - setColorSwatch("WLSunlight", param_mgr->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); + mSkyAdapter->mSunlight.setColor3( psky->getSunlightColor() ); + setColorSwatch("WLSunlight", mSkyAdapter->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); // glow - param_mgr->mGlow = cur_params.getVector(param_mgr->mGlow.mName, err); - childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f); - childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f); - - // ambient - param_mgr->mAmbient = cur_params.getVector(param_mgr->mAmbient.mName, err); - setColorSwatch("WLAmbient", param_mgr->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); - - F32 time24 = sun_pos_to_time24(param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); - getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE); - getChild<LLTimeCtrl>("WLDayTime")->setTime24(time24); - childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); + mSkyAdapter->mGlow.setColor3( psky->getGlow() ); + childSetValue("WLGlowR", 2 - mSkyAdapter->mGlow.getRed() / 20.0f); + childSetValue("WLGlowB", -mSkyAdapter->mGlow.getBlue() / 5.0f); + +// LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl(); +// +// F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI); +// getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE); +// getChild<LLTimeCtrl>("WLDayTime")->setTime24(time24); +// childSetValue("WLEastAngle", azal.first / F_TWO_PI); + getChild<LLJoystickQuaternion>("WLSunRotation")->setRotation(psky->getSunRotation()); + getChild<LLJoystickQuaternion>("WLMoonRotation")->setRotation(psky->getMoonRotation()); // Clouds // Cloud Color - param_mgr->mCloudColor = cur_params.getVector(param_mgr->mCloudColor.mName, err); - setColorSwatch("WLCloudColor", param_mgr->mCloudColor, WL_CLOUD_SLIDER_SCALE); + mSkyAdapter->mCloudColor.setColor3( psky->getCloudColor() ); + setColorSwatch("WLCloudColor", mSkyAdapter->mCloudColor, WL_CLOUD_SLIDER_SCALE); // Cloud - param_mgr->mCloudMain = cur_params.getVector(param_mgr->mCloudMain.mName, err); - childSetValue("WLCloudX", param_mgr->mCloudMain.r); - childSetValue("WLCloudY", param_mgr->mCloudMain.g); - childSetValue("WLCloudDensity", param_mgr->mCloudMain.b); + mSkyAdapter->mCloudMain.setColor3( psky->getCloudPosDensity1() ); + childSetValue("WLCloudX", mSkyAdapter->mCloudMain.getRed()); + childSetValue("WLCloudY", mSkyAdapter->mCloudMain.getGreen()); + childSetValue("WLCloudDensity", mSkyAdapter->mCloudMain.getBlue()); // Cloud Detail - param_mgr->mCloudDetail = cur_params.getVector(param_mgr->mCloudDetail.mName, err); - childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r); - childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g); - childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b); + mSkyAdapter->mCloudDetail.setColor3( psky->getCloudPosDensity2() ); + childSetValue("WLCloudDetailX", mSkyAdapter->mCloudDetail.getRed()); + childSetValue("WLCloudDetailY", mSkyAdapter->mCloudDetail.getGreen()); + childSetValue("WLCloudDetailDensity", mSkyAdapter->mCloudDetail.getBlue()); // Cloud extras - param_mgr->mCloudCoverage = cur_params.getFloat(param_mgr->mCloudCoverage.mName, err); - param_mgr->mCloudScale = cur_params.getFloat(param_mgr->mCloudScale.mName, err); - childSetValue("WLCloudCoverage", (F32) param_mgr->mCloudCoverage); - childSetValue("WLCloudScale", (F32) param_mgr->mCloudScale); + mSkyAdapter->mCloudCoverage = psky->getCloudShadow(); + mSkyAdapter->mCloudScale = psky->getCloudScale(); + childSetValue("WLCloudCoverage", (F32) mSkyAdapter->mCloudCoverage); + childSetValue("WLCloudScale", (F32) mSkyAdapter->mCloudScale); // cloud scrolling - bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX(); - bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY(); - childSetValue("WLCloudLockX", lockX); - childSetValue("WLCloudLockY", lockY); + LLVector2 scroll_rate = psky->getCloudScrollRate(); + + // LAPRAS: These should go away... + childDisable("WLCloudLockX"); + childDisable("WLCloudLockY"); // disable if locked, enable if not - if (lockX) - { - childDisable("WLCloudScrollX"); - } - else - { - childEnable("WLCloudScrollX"); - } - if (lockY) - { - childDisable("WLCloudScrollY"); - } - else - { - childEnable("WLCloudScrollY"); - } + childEnable("WLCloudScrollX"); + childEnable("WLCloudScrollY"); // *HACK cloud scrolling is off my an additive of 10 - childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f); - childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f); - - param_mgr->mDistanceMult = cur_params.getFloat(param_mgr->mDistanceMult.mName, err); - childSetValue("WLDistanceMult", (F32) param_mgr->mDistanceMult); + childSetValue("WLCloudScrollX", scroll_rate[0] - 10.0f); + childSetValue("WLCloudScrollY", scroll_rate[1] - 10.0f); // Tweak extras - param_mgr->mWLGamma = cur_params.getFloat(param_mgr->mWLGamma.mName, err); - childSetValue("WLGamma", (F32) param_mgr->mWLGamma); + mSkyAdapter->mWLGamma = psky->getGamma(); + childSetValue("WLGamma", (F32) mSkyAdapter->mWLGamma); - childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); + childSetValue("WLStarAlpha", psky->getStarBrightness()); } void LLFloaterEditSky::setColorSwatch(const std::string& name, const WLColorControl& from_ctrl, F32 k) { // Set the value, dividing it by <k> first. - LLVector4 color_vec = from_ctrl; - getChild<LLColorSwatchCtrl>(name)->set(LLColor4(color_vec / k)); + LLColor4 color = from_ctrl.getColor4(); + getChild<LLColorSwatchCtrl>(name)->set(color / k); } // color control callbacks void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl); - LLVector4 color_vec(swatch->get().mV); - - // Set intensity to maximum of the RGB values. - color_vec.mV[3] = llmax(color_vec.mV[0], llmax(color_vec.mV[1], color_vec.mV[2])); + LLColor4 color_vec(swatch->get().mV); // Multiply RGB values by the appropriate factor. F32 k = WL_CLOUD_SLIDER_SCALE; - if (color_ctrl->isSunOrAmbientColor) + if (color_ctrl->getIsSunOrAmbientColor()) { k = WL_SUN_AMBIENT_SLIDER_SCALE; } - if (color_ctrl->isBlueHorizonOrDensity) + else if (color_ctrl->getIsBlueHorizonOrDensity()) { k = WL_BLUE_HORIZON_DENSITY_SCALE; } color_vec *= k; // intensity isn't affected by the multiplication + // Set intensity to maximum of the RGB values. + color_vec.mV[3] = color_max(color_vec); + // Apply the new RGBI value. - *color_ctrl = color_vec; - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->setColor4(color_vec); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); - color_ctrl->r = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->r *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) + F32 red_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; + + if (color_ctrl->getIsSunOrAmbientColor()) { - color_ctrl->r *= WL_BLUE_HORIZON_DENSITY_SCALE; + k = WL_SUN_AMBIENT_SLIDER_SCALE; } - - // move i if it's the max - if (color_ctrl->r >= color_ctrl->g && color_ctrl->r >= color_ctrl->b && color_ctrl->hasSliderName) + if (color_ctrl->getIsBlueHorizonOrDensity()) { - color_ctrl->i = color_ctrl->r; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->r / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->r / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->r); - } + k = WL_BLUE_HORIZON_DENSITY_SCALE; } + color_ctrl->setRed(red_value * k); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - - LLWLParamManager::getInstance()->propagateParameters(); + adjustIntensity(color_ctrl, red_value, k); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlGMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); + F32 green_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; - color_ctrl->g = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->g *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) - { - color_ctrl->g *= WL_BLUE_HORIZON_DENSITY_SCALE; - } + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->getIsBlueHorizonOrDensity()) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + color_ctrl->setGreen(green_value * k); - // move i if it's the max - if (color_ctrl->g >= color_ctrl->r && color_ctrl->g >= color_ctrl->b && color_ctrl->hasSliderName) - { - color_ctrl->i = color_ctrl->g; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->g / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->g / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->g); - } - } - - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - - LLWLParamManager::getInstance()->propagateParameters(); + adjustIntensity(color_ctrl, green_value, k); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); + F32 blue_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; - color_ctrl->b = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->b *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) - { - color_ctrl->b *= WL_BLUE_HORIZON_DENSITY_SCALE; - } + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->getIsBlueHorizonOrDensity()) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + color_ctrl->setBlue(blue_value * k); - // move i if it's the max - if (color_ctrl->b >= color_ctrl->r && color_ctrl->b >= color_ctrl->g && color_ctrl->hasSliderName) - { - color_ctrl->i = color_ctrl->b; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->b / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->b / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->b); - } - } + adjustIntensity(color_ctrl, blue_value, k); + color_ctrl->update(mEditSettings); +} - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); +void LLFloaterEditSky::adjustIntensity(WLColorControl *ctrl, F32 val, F32 scale) +{ + if (ctrl->getHasSliderName()) + { + LLColor4 color = ctrl->getColor4(); + F32 i = color_max(color) / scale; + ctrl->setIntensity(i); + std::string name = ctrl->getSliderName(); + name.append("I"); - LLWLParamManager::getInstance()->propagateParameters(); + childSetValue(name, i); + } } + /// GLOW SPECIFIC CODE void LLFloaterEditSky::onGlowRMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); // scaled by 20 - color_ctrl->r = (2 - sldr_ctrl->getValueF32()) * 20; + color_ctrl->setRed((2 - sldr_ctrl->getValueF32()) * 20); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } /// \NOTE that we want NEGATIVE (-) B void LLFloaterEditSky::onGlowBMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); /// \NOTE that we want NEGATIVE (-) B and NOT by 20 as 20 is too big - color_ctrl->b = -sldr_ctrl->getValueF32() * 5; + color_ctrl->setBlue(-sldr_ctrl->getValueF32() * 5); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLFloatControl * floatControl = static_cast<WLFloatControl *>(userdata); - floatControl->x = sldr_ctrl->getValueF32() / floatControl->mult; + floatControl->setValue(sldr_ctrl->getValueF32() / floatControl->getMult()); - floatControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + floatControl->update(mEditSettings); } @@ -531,8 +427,6 @@ void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) // time of day void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLMultiSliderCtrl* sun_msldr = getChild<LLMultiSliderCtrl>("WLSunPos"); LLSliderCtrl* east_sldr = getChild<LLSliderCtrl>("WLEastAngle"); LLTimeCtrl* time_ctrl = getChild<LLTimeCtrl>("WLDayTime"); @@ -542,99 +436,60 @@ void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) time_ctrl->setTime24(time24); // sync the time ctrl with the new sun position // get the two angles - LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); - - param_mgr->mCurParams.setSunAngle(F_TWO_PI * time24_to_sun_pos(time24)); - param_mgr->mCurParams.setEastAngle(F_TWO_PI * east_sldr->getValueF32()); + F32 azimuth = F_TWO_PI * east_sldr->getValueF32(); + F32 altitude = F_TWO_PI * time24_to_sun_pos(time24); + mEditSettings->setSunRotation(azimuth, altitude); + mEditSettings->setMoonRotation(azimuth + F_PI, -altitude); - // set the sun vector - color_ctrl->r = -sin(param_mgr->mCurParams.getEastAngle()) * - cos(param_mgr->mCurParams.getSunAngle()); - color_ctrl->g = sin(param_mgr->mCurParams.getSunAngle()); - color_ctrl->b = cos(param_mgr->mCurParams.getEastAngle()) * - cos(param_mgr->mCurParams.getSunAngle()); - color_ctrl->i = 1.f; + LLVector4 sunnorm( mEditSettings->getSunDirection(), 1.f ); - color_ctrl->update(param_mgr->mCurParams); - param_mgr->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onTimeChanged() { F32 time24 = getChild<LLTimeCtrl>("WLDayTime")->getTime24(); getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE); - onSunMoved(getChild<LLUICtrl>("WLSunPos"), &LLWLParamManager::instance().mLightnorm); + onSunMoved(getChild<LLUICtrl>("WLSunPos"), &(mSkyAdapter->mLightnorm)); } -void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) +void LLFloaterEditSky::onSunRotationChanged() { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + LLJoystickQuaternion* sun_spinner = getChild<LLJoystickQuaternion>("WLSunRotation"); + LLQuaternion sunrot(sun_spinner->getRotation()); - LLWLParamManager::getInstance()->mCurParams.setStarBrightness(sldr_ctrl->getValueF32()); + mEditSettings->setSunRotation(sunrot); } -// Clouds -void LLFloaterEditSky::onCloudScrollXMoved(LLUICtrl* ctrl) +void LLFloaterEditSky::onMoonRotationChanged() { - LLWLParamManager::getInstance()->mAnimator.deactivate(); + LLJoystickQuaternion* moon_spinner = getChild<LLJoystickQuaternion>("WLMoonRotation"); + LLQuaternion moonrot(moon_spinner->getRotation()); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::getInstance()->mCurParams.setCloudScrollX(sldr_ctrl->getValueF32() + 10.0f); + mEditSettings->setMoonRotation(moonrot); } -void LLFloaterEditSky::onCloudScrollYMoved(LLUICtrl* ctrl) +void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::getInstance()->mCurParams.setCloudScrollY(sldr_ctrl->getValueF32() + 10.0f); + mEditSettings->setStarBrightness(sldr_ctrl->getValueF32()); } -void LLFloaterEditSky::onCloudScrollXToggled(LLUICtrl* ctrl) +// Clouds +void LLFloaterEditSky::onCloudScrollXMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLCheckBoxCtrl* cb_ctrl = static_cast<LLCheckBoxCtrl*>(ctrl); - - bool lock = cb_ctrl->get(); - LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollX(!lock); - - LLSliderCtrl* sldr = getChild<LLSliderCtrl>("WLCloudScrollX"); - - if (cb_ctrl->get()) - { - sldr->setEnabled(false); - } - else - { - sldr->setEnabled(true); - } - + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + // *HACK all cloud scrolling is off by an additive of 10. + mEditSettings->setCloudScrollRateX(sldr_ctrl->getValueF32() + 10.0f); } -void LLFloaterEditSky::onCloudScrollYToggled(LLUICtrl* ctrl) +void LLFloaterEditSky::onCloudScrollYMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLCheckBoxCtrl* cb_ctrl = static_cast<LLCheckBoxCtrl*>(ctrl); - bool lock = cb_ctrl->get(); - LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollY(!lock); - - LLSliderCtrl* sldr = getChild<LLSliderCtrl>("WLCloudScrollY"); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - if (cb_ctrl->get()) - { - sldr->setEnabled(false); - } - else - { - sldr->setEnabled(true); - } + // *HACK all cloud scrolling is off by an additive of 10. + mEditSettings->setCloudScrollRateY(sldr_ctrl->getValueF32() + 10.0f); } //================================================================================================= @@ -664,38 +519,12 @@ void LLFloaterEditSky::refreshSkyPresetsList() { mSkyPresetCombo->removeall(); - LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList(); -#if 0 // Disable editing region skies until the workflow is clear enough. - // Add region presets. - std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); - for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) - { - std::string item_title = *it + " (" + region_name + ")"; - mSkyPresetCombo->add(item_title, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toLLSD()); - } - if (region_presets.size() > 0) - { - mSkyPresetCombo->addSeparator(); - } -#endif - - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - if (user_presets.size() > 0) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } mSkyPresetCombo->setLabel(getString("combo_label")); } @@ -718,6 +547,7 @@ void LLFloaterEditSky::enableEditing(bool enable) void LLFloaterEditSky::saveRegionSky() { +#if 0 LLWLParamKey key(getSelectedSkyPreset()); llassert(key.scope == LLEnvKey::SCOPE_REGION); @@ -728,61 +558,55 @@ void LLFloaterEditSky::saveRegionSky() // *TODO: save to cached region settings. LL_WARNS("Windlight") << "Saving region sky is not fully implemented yet" << LL_ENDL; +#endif } -LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset() +std::string LLFloaterEditSky::getSelectedPresetName() const { - LLWLParamKey key; - - if (mSkyPresetNameEditor->getVisible()) - { - key.name = mSkyPresetNameEditor->getText(); - key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - LLSD combo_val = mSkyPresetCombo->getValue(); - - if (!combo_val.isArray()) // manually typed text - { - key.name = combo_val.asString(); - key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - key.fromLLSD(combo_val); - } - } + std::string name; + if (mSkyPresetNameEditor->getVisible()) + { + name = mSkyPresetNameEditor->getText(); + } + else + { + LLSD combo_val = mSkyPresetCombo->getValue(); + name = combo_val[0].asString(); + } - return key; + return name; } void LLFloaterEditSky::onSkyPresetNameEdited() { - // Disable saving a sky preset having empty name. - LLWLParamKey key = getSelectedSkyPreset(); - mSaveButton->setEnabled(!key.name.empty()); + std::string name = mSkyPresetNameEditor->getText(); + LLSettingsWater::ptr_t psky = LLEnvironment::instance().getCurrentWater(); + + psky->setName(name); } void LLFloaterEditSky::onSkyPresetSelected() { - LLWLParamKey key = getSelectedSkyPreset(); - LLWLParamSet sky_params; + std::string name; - if (!LLWLParamManager::instance().getParamSet(key, sky_params)) - { - // Manually entered string? - LL_WARNS("Windlight") << "No sky preset named " << key.toString() << LL_ENDL; - return; - } + name = getSelectedPresetName(); - LLEnvManagerNew::instance().useSkyParams(sky_params.getAll()); - //syncControls(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(name); - bool can_edit = (key.scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings()); - enableEditing(can_edit); + if (!psky) + { + LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL; + enableEditing(false); + return; + } + + psky = psky->buildClone(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, psky); + mEditSettings = psky; + + syncControls(); + enableEditing(true); - mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL); } bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) @@ -800,69 +624,29 @@ bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& respon void LLFloaterEditSky::onSaveConfirmed() { - // Save current params to the selected preset. - LLWLParamKey key(getSelectedSkyPreset()); + // Save currently displayed water params to the selected preset. + std::string name = mEditSettings->getName(); - LL_DEBUGS("Windlight") << "Saving sky preset " << key.name << LL_ENDL; - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - if (wl_mgr.hasParamSet(key)) - { - wl_mgr.setParamSet(key, wl_mgr.mCurParams); - } - else - { - wl_mgr.addParamSet(key, wl_mgr.mCurParams); - } + LL_DEBUGS("Windlight") << "Saving sky preset " << name << LL_ENDL; - wl_mgr.savePreset(key); + LLEnvironment::instance().addSky(mEditSettings); - // Change preference if requested. - if (mMakeDefaultCheckBox->getValue()) - { - LL_DEBUGS("Windlight") << key.name << " is now the new preferred sky preset" << LL_ENDL; - LLEnvManagerNew::instance().setUseSkyPreset(key.name); - } + // Change preference if requested. + if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue()) + { + LL_DEBUGS("Windlight") << name << " is now the new preferred sky preset" << LL_ENDL; + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings); + } - closeFloater(); + closeFloater(); } void LLFloaterEditSky::onBtnSave() { - LLWLParamKey selected_sky = getSelectedSkyPreset(); - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - - if (selected_sky.scope == LLEnvKey::SCOPE_REGION) - { - saveRegionSky(); - closeFloater(); - return; - } + LLEnvironment::instance().addSky(mEditSettings); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings); - std::string name = selected_sky.name; - if (name.empty()) - { - // *TODO: show an alert - LL_WARNS() << "Empty sky preset name" << LL_ENDL; - return; - } - - // Don't allow overwriting system presets. - if (wl_mgr.isSystemPreset(name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } - - // Save, ask for confirmation for overwriting an existing preset. - if (wl_mgr.hasParamSet(selected_sky)) - { - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditSky::onSaveAnswer, this, _1, _2)); - } - else - { - // new preset, hence no confirmation needed - onSaveConfirmed(); - } + closeFloater(); } void LLFloaterEditSky::onBtnCancel() @@ -872,22 +656,12 @@ void LLFloaterEditSky::onBtnCancel() void LLFloaterEditSky::onSkyPresetListChange() { - LLWLParamKey key = getSelectedSkyPreset(); // preset being edited - if (!LLWLParamManager::instance().hasParamSet(key)) - { - // Preset we've been editing doesn't exist anymore. Close the floater. - closeFloater(false); - } - else - { - // A new preset has been added. - // Refresh the presets list, though it may not make sense as the floater is about to be closed. - refreshSkyPresetsList(); - } + refreshSkyPresetsList(); } void LLFloaterEditSky::onRegionSettingsChange() { +#if 0 // If creating a new sky, don't bother. if (isNewPreset()) { @@ -905,10 +679,12 @@ void LLFloaterEditSky::onRegionSettingsChange() { refreshSkyPresetsList(); } +#endif } void LLFloaterEditSky::onRegionInfoUpdate() { +#if 0 bool can_edit = true; // If we've selected a region sky preset for editing. @@ -919,4 +695,5 @@ void LLFloaterEditSky::onRegionInfoUpdate() } enableEditing(can_edit); +#endif } diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h deleted file mode 100644 index a06c4fc5fa..0000000000 --- a/indra/newview/llfloatereditsky.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file llfloatereditsky.h - * @brief Floater to create or edit a sky preset - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFLOATEREDITSKY_H -#define LL_LLFLOATEREDITSKY_H - -#include "llfloater.h" -#include "llwlparammanager.h" - -class LLButton; -class LLCheckBoxCtrl; -class LLComboBox; -class LLLineEditor; - -/** - * Floater for creating or editing a sky preset. - */ -class LLFloaterEditSky : public LLFloater -{ - LOG_CLASS(LLFloaterEditSky); - -public: - LLFloaterEditSky(const LLSD &key); - - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); - /*virtual*/ void draw(); - -private: - void initCallbacks(void); - - //-- WL stuff begins ------------------------------------------------------ - - void syncControls(); /// sync up sliders with parameters - - void setColorSwatch(const std::string& name, const WLColorControl& from_ctrl, F32 k); - - // general purpose callbacks for dealing with color controllers - void onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl); - void onColorControlRMoved(LLUICtrl* ctrl, void* userdata); - void onColorControlGMoved(LLUICtrl* ctrl, void* userdata); - void onColorControlBMoved(LLUICtrl* ctrl, void* userdata); - void onFloatControlMoved(LLUICtrl* ctrl, void* userdata); - - // lighting callbacks for glow - void onGlowRMoved(LLUICtrl* ctrl, void* userdata); - void onGlowBMoved(LLUICtrl* ctrl, void* userdata); - - // lighting callbacks for sun - void onSunMoved(LLUICtrl* ctrl, void* userdata); - void onTimeChanged(); - - // for handling when the star slider is moved to adjust the alpha - void onStarAlphaMoved(LLUICtrl* ctrl); - - // handle cloud scrolling - void onCloudScrollXMoved(LLUICtrl* ctrl); - void onCloudScrollYMoved(LLUICtrl* ctrl); - void onCloudScrollXToggled(LLUICtrl* ctrl); - void onCloudScrollYToggled(LLUICtrl* ctrl); - - //-- WL stuff ends -------------------------------------------------------- - - void reset(); /// reset the floater to its initial state - bool isNewPreset() const; - void refreshSkyPresetsList(); - void enableEditing(bool enable); - void saveRegionSky(); - LLWLParamKey getSelectedSkyPreset(); - - void onSkyPresetNameEdited(); - void onSkyPresetSelected(); - bool onSaveAnswer(const LLSD& notification, const LLSD& response); - void onSaveConfirmed(); - - void onBtnSave(); - void onBtnCancel(); - - void onSkyPresetListChange(); - void onRegionSettingsChange(); - void onRegionInfoUpdate(); - - LLLineEditor* mSkyPresetNameEditor; - LLComboBox* mSkyPresetCombo; - LLCheckBoxCtrl* mMakeDefaultCheckBox; - LLButton* mSaveButton; -}; - -#endif // LL_LLFLOATEREDITSKY_H diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 43b44eae37..6e7b777e70 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -28,6 +28,8 @@ #include "llfloatereditwater.h" +#include <boost/make_shared.hpp> + // libs #include "llbutton.h" #include "llcheckboxctrl.h" @@ -42,16 +44,22 @@ #include "llagent.h" #include "llregioninfomodel.h" #include "llviewerregion.h" -#include "llwaterparammanager.h" + +#include "llenvironment.h" +#include "llsettingswater.h" +#include "llenvadapters.h" + +#include "v3colorutil.h" #undef max // Fixes a Windows compiler error -LLFloaterEditWater::LLFloaterEditWater(const LLSD &key) -: LLFloater(key) -, mWaterPresetNameEditor(NULL) -, mWaterPresetCombo(NULL) -, mMakeDefaultCheckBox(NULL) -, mSaveButton(NULL) +LLFloaterEditWater::LLFloaterEditWater(const LLSD &key): + LLFloater(key), + mWaterPresetNameEditor(NULL), + mWaterPresetCombo(NULL), + mMakeDefaultCheckBox(NULL), + mSaveButton(NULL), + mWaterAdapter() { } @@ -63,6 +71,10 @@ BOOL LLFloaterEditWater::postBuild() mMakeDefaultCheckBox = getChild<LLCheckBoxCtrl>("make_default_cb"); mSaveButton = getChild<LLButton>("save"); + mWaterAdapter = boost::make_shared<LLWatterSettingsAdapter>(); + + LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEditWater::onWaterPresetListChange, this)); + initCallbacks(); refreshWaterPresetsList(); syncControls(); @@ -99,7 +111,8 @@ void LLFloaterEditWater::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } } @@ -119,44 +132,38 @@ void LLFloaterEditWater::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditWater::onBtnSave, this)); getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditWater::onBtnCancel, this)); - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditWater::onRegionSettingsChange, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditWater::onWaterPresetListChange, this)); - // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditWater::onRegionInfoUpdate, this)); //------------------------------------------------------------------------- - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - - getChild<LLUICtrl>("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onWaterFogColorMoved, this, _1, &water_mgr.mFogColor)); - //getChild<LLUICtrl>("WaterGlow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlAMoved, this, _1, &water_mgr.mFogColor)); + getChild<LLUICtrl>("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlMoved, this, _1, &mWaterAdapter->mFogColor)); // fog density - getChild<LLUICtrl>("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &water_mgr.mFogDensity)); - getChild<LLUICtrl>("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mUnderWaterFogMod)); + getChild<LLUICtrl>("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &mWaterAdapter->mFogDensity)); + getChild<LLUICtrl>("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mUnderWaterFogMod)); // blue density - getChild<LLUICtrl>("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &water_mgr.mNormalScale)); - getChild<LLUICtrl>("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &water_mgr.mNormalScale)); - getChild<LLUICtrl>("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &water_mgr.mNormalScale)); + getChild<LLUICtrl>("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &mWaterAdapter->mNormalScale)); + getChild<LLUICtrl>("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &mWaterAdapter->mNormalScale)); + getChild<LLUICtrl>("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &mWaterAdapter->mNormalScale)); // fresnel - getChild<LLUICtrl>("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelScale)); - getChild<LLUICtrl>("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelOffset)); + getChild<LLUICtrl>("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelScale)); + getChild<LLUICtrl>("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelOffset)); // scale above/below - getChild<LLUICtrl>("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleAbove)); - getChild<LLUICtrl>("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleBelow)); + getChild<LLUICtrl>("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleAbove)); + getChild<LLUICtrl>("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleBelow)); // blur mult - getChild<LLUICtrl>("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mBlurMultiplier)); + getChild<LLUICtrl>("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mBlurMultiplier)); // wave direction - getChild<LLUICtrl>("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave1Dir)); - getChild<LLUICtrl>("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave1Dir)); - getChild<LLUICtrl>("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave2Dir)); - getChild<LLUICtrl>("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave2Dir)); + getChild<LLUICtrl>("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave1Dir)); + getChild<LLUICtrl>("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave1Dir)); + getChild<LLUICtrl>("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave2Dir)); + getChild<LLUICtrl>("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave2Dir)); LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("WaterNormalMap"); texture_ctrl->setDefaultImageAssetID(DEFAULT_WATER_NORMAL); @@ -169,304 +176,132 @@ void LLFloaterEditWater::syncControls() { // *TODO: Eliminate slow getChild() calls. - bool err; - - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - - LLWaterParamSet& current_params = water_mgr.mCurParams; + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mEditSettings = pwater; - // blue horizon - water_mgr.mFogColor = current_params.getVector4(water_mgr.mFogColor.mName, err); + std::string name = pwater->getName(); + mWaterPresetNameEditor->setText(name); + mWaterPresetCombo->setValue(name); - LLColor4 col = water_mgr.getFogColor(); //getChild<LLUICtrl>("WaterGlow")->setValue(col.mV[3]); - col.mV[3] = 1.0f; - getChild<LLColorSwatchCtrl>("WaterFogColor")->set(col); + getChild<LLColorSwatchCtrl>("WaterFogColor")->set(LLColor4(pwater->getWaterFogColor())); // fog and wavelets - water_mgr.mFogDensity.mExp = - log(current_params.getFloat(water_mgr.mFogDensity.mName, err)) / - log(water_mgr.mFogDensity.mBase); - water_mgr.setDensitySliderValue(water_mgr.mFogDensity.mExp); - getChild<LLUICtrl>("WaterFogDensity")->setValue(water_mgr.mFogDensity.mExp); + mWaterAdapter->mFogDensity = pwater->getWaterFogDensity(); + getChild<LLUICtrl>("WaterFogDensity")->setValue(mWaterAdapter->mFogDensity.getExp()); - water_mgr.mUnderWaterFogMod.mX = - current_params.getFloat(water_mgr.mUnderWaterFogMod.mName, err); - getChild<LLUICtrl>("WaterUnderWaterFogMod")->setValue(water_mgr.mUnderWaterFogMod.mX); + mWaterAdapter->mUnderWaterFogMod = pwater->getFogMod(); + getChild<LLUICtrl>("WaterUnderWaterFogMod")->setValue(static_cast<F32>(mWaterAdapter->mUnderWaterFogMod)); - water_mgr.mNormalScale = current_params.getVector3(water_mgr.mNormalScale.mName, err); - getChild<LLUICtrl>("WaterNormalScaleX")->setValue(water_mgr.mNormalScale.mX); - getChild<LLUICtrl>("WaterNormalScaleY")->setValue(water_mgr.mNormalScale.mY); - getChild<LLUICtrl>("WaterNormalScaleZ")->setValue(water_mgr.mNormalScale.mZ); + mWaterAdapter->mNormalScale = pwater->getNormalScale(); + getChild<LLUICtrl>("WaterNormalScaleX")->setValue(mWaterAdapter->mNormalScale.getX()); + getChild<LLUICtrl>("WaterNormalScaleY")->setValue(mWaterAdapter->mNormalScale.getY()); + getChild<LLUICtrl>("WaterNormalScaleZ")->setValue(mWaterAdapter->mNormalScale.getZ()); // Fresnel - water_mgr.mFresnelScale.mX = current_params.getFloat(water_mgr.mFresnelScale.mName, err); - getChild<LLUICtrl>("WaterFresnelScale")->setValue(water_mgr.mFresnelScale.mX); - water_mgr.mFresnelOffset.mX = current_params.getFloat(water_mgr.mFresnelOffset.mName, err); - getChild<LLUICtrl>("WaterFresnelOffset")->setValue(water_mgr.mFresnelOffset.mX); + mWaterAdapter->mFresnelScale = pwater->getFresnelScale(); + getChild<LLUICtrl>("WaterFresnelScale")->setValue(static_cast<F32>(mWaterAdapter->mFresnelScale)); + mWaterAdapter->mFresnelOffset = pwater->getFresnelOffset(); + getChild<LLUICtrl>("WaterFresnelOffset")->setValue(static_cast<F32>(mWaterAdapter->mFresnelOffset)); // Scale Above/Below - water_mgr.mScaleAbove.mX = current_params.getFloat(water_mgr.mScaleAbove.mName, err); - getChild<LLUICtrl>("WaterScaleAbove")->setValue(water_mgr.mScaleAbove.mX); - water_mgr.mScaleBelow.mX = current_params.getFloat(water_mgr.mScaleBelow.mName, err); - getChild<LLUICtrl>("WaterScaleBelow")->setValue(water_mgr.mScaleBelow.mX); + mWaterAdapter->mScaleAbove = pwater->getScaleAbove(); + getChild<LLUICtrl>("WaterScaleAbove")->setValue(static_cast<F32>(mWaterAdapter->mScaleAbove)); + mWaterAdapter->mScaleBelow = pwater->getScaleBelow(); + getChild<LLUICtrl>("WaterScaleBelow")->setValue(static_cast<F32>(mWaterAdapter->mScaleBelow)); // blur mult - water_mgr.mBlurMultiplier.mX = current_params.getFloat(water_mgr.mBlurMultiplier.mName, err); - getChild<LLUICtrl>("WaterBlurMult")->setValue(water_mgr.mBlurMultiplier.mX); + mWaterAdapter->mBlurMultiplier = pwater->getBlurMultiplier(); + getChild<LLUICtrl>("WaterBlurMult")->setValue(static_cast<F32>(mWaterAdapter->mBlurMultiplier)); // wave directions - water_mgr.mWave1Dir = current_params.getVector2(water_mgr.mWave1Dir.mName, err); - getChild<LLUICtrl>("WaterWave1DirX")->setValue(water_mgr.mWave1Dir.mX); - getChild<LLUICtrl>("WaterWave1DirY")->setValue(water_mgr.mWave1Dir.mY); + mWaterAdapter->mWave1Dir = pwater->getWave1Dir(); + getChild<LLUICtrl>("WaterWave1DirX")->setValue(mWaterAdapter->mWave1Dir.getU()); + getChild<LLUICtrl>("WaterWave1DirY")->setValue(mWaterAdapter->mWave1Dir.getV()); - water_mgr.mWave2Dir = current_params.getVector2(water_mgr.mWave2Dir.mName, err); - getChild<LLUICtrl>("WaterWave2DirX")->setValue(water_mgr.mWave2Dir.mX); - getChild<LLUICtrl>("WaterWave2DirY")->setValue(water_mgr.mWave2Dir.mY); + mWaterAdapter->mWave2Dir = pwater->getWave2Dir(); + getChild<LLUICtrl>("WaterWave2DirX")->setValue(mWaterAdapter->mWave2Dir.getU()); + getChild<LLUICtrl>("WaterWave2DirY")->setValue(mWaterAdapter->mWave2Dir.getV()); LLTextureCtrl* textCtrl = getChild<LLTextureCtrl>("WaterNormalMap"); - textCtrl->setImageAssetID(water_mgr.getNormalMapID()); -} - -// color control callbacks -void LLFloaterEditWater::onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - - color_ctrl->mR = sldr_ctrl->getValueF32(); - - // move i if it's the max - if (color_ctrl->mR >= color_ctrl->mG - && color_ctrl->mR >= color_ctrl->mB - && color_ctrl->mHasSliderName) - { - color_ctrl->mI = color_ctrl->mR; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - getChild<LLUICtrl>(name)->setValue(color_ctrl->mR); - } - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - - color_ctrl->mG = sldr_ctrl->getValueF32(); - - // move i if it's the max - if (color_ctrl->mG >= color_ctrl->mR - && color_ctrl->mG >= color_ctrl->mB - && color_ctrl->mHasSliderName) - { - color_ctrl->mI = color_ctrl->mG; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - getChild<LLUICtrl>(name)->setValue(color_ctrl->mG); - - } - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - - color_ctrl->mB = sldr_ctrl->getValueF32(); - - // move i if it's the max - if (color_ctrl->mB >= color_ctrl->mR - && color_ctrl->mB >= color_ctrl->mG - && color_ctrl->mHasSliderName) - { - color_ctrl->mI = color_ctrl->mB; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - getChild<LLUICtrl>(name)->setValue(color_ctrl->mB); - } - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - - color_ctrl->mA = sldr_ctrl->getValueF32(); - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + textCtrl->setImageAssetID(pwater->getNormalMapID()); } -void LLFloaterEditWater::onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - - color_ctrl->mI = sldr_ctrl->getValueF32(); - - // only for sliders where we pass a name - if (color_ctrl->mHasSliderName) - { - // set it to the top - F32 maxVal = std::max(std::max(color_ctrl->mR, color_ctrl->mG), color_ctrl->mB); - F32 iVal; - - iVal = color_ctrl->mI; - - // get the names of the other sliders - std::string rName = color_ctrl->mSliderName; - rName.append("R"); - std::string gName = color_ctrl->mSliderName; - gName.append("G"); - std::string bName = color_ctrl->mSliderName; - bName.append("B"); - - // handle if at 0 - if (iVal == 0) - { - color_ctrl->mR = 0; - color_ctrl->mG = 0; - color_ctrl->mB = 0; - - // if all at the start - // set them all to the intensity - } - else if (maxVal == 0) - { - color_ctrl->mR = iVal; - color_ctrl->mG = iVal; - color_ctrl->mB = iVal; - } - else - { - // add delta amounts to each - F32 delta = (iVal - maxVal) / maxVal; - color_ctrl->mR *= (1.0f + delta); - color_ctrl->mG *= (1.0f + delta); - color_ctrl->mB *= (1.0f + delta); - } - - // set the sliders to the new vals - getChild<LLUICtrl>(rName)->setValue(color_ctrl->mR); - getChild<LLUICtrl>(gName)->setValue(color_ctrl->mG); - getChild<LLUICtrl>(bName)->setValue(color_ctrl->mB); - } - - // now update the current parameters and send them to shaders - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); -} - // vector control callbacks -void LLFloaterEditWater::onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlXMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl) { LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - vector_ctrl->mX = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setX( sldr_ctrl->getValueF32() ); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlYMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl) { LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - vector_ctrl->mY = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setY(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlZMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl) { - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - - vector_ctrl->mZ = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setZ(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl) +void LLFloaterEditWater::onVector2ControlXMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl) { - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - - vector_ctrl->mX = sldr_ctrl->getValueF32(); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setU(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } // vector control callbacks -void LLFloaterEditWater::onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl) +void LLFloaterEditWater::onVector2ControlYMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl) { - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - vector_ctrl->mY = sldr_ctrl->getValueF32(); - - vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - - LLWaterParamManager::getInstance()->propagateParameters(); + vector_ctrl->setV(sldr_ctrl->getValueF32()); + vector_ctrl->update(mEditSettings); } -void LLFloaterEditWater::onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl) +void LLFloaterEditWater::onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* floatControl) { - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - floatControl->mX = sldr_ctrl->getValueF32() / floatControl->mMult; - - floatControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); + floatControl->setValue(sldr_ctrl->getValueF32()); + floatControl->update(mEditSettings); } -void LLFloaterEditWater::onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl) +void LLFloaterEditWater::onExpFloatControlMoved(LLUICtrl* ctrl, WLXFloatControl* expFloatControl) { LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - F32 val = sldr_ctrl->getValueF32(); - expFloatControl->mExp = val; - LLWaterParamManager::getInstance()->setDensitySliderValue(val); - - expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); + expFloatControl->setExp(sldr_ctrl->getValueF32()); + expFloatControl->update(mEditSettings); } -void LLFloaterEditWater::onWaterFogColorMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) +void LLFloaterEditWater::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) { LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl); - *color_ctrl = swatch->get(); - - color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - LLWaterParamManager::getInstance()->propagateParameters(); + color_ctrl->setColor4( swatch->get() ); + color_ctrl->update(mEditSettings); } void LLFloaterEditWater::onNormalMapPicked(LLUICtrl* ctrl) { LLTextureCtrl* textCtrl = static_cast<LLTextureCtrl*>(ctrl); LLUUID textID = textCtrl->getImageAssetID(); - LLWaterParamManager::getInstance()->setNormalMapID(textID); + mEditSettings->setNormalMapID(textID); } //============================================================================= @@ -496,38 +331,12 @@ void LLFloaterEditWater::refreshWaterPresetsList() { mWaterPresetCombo->removeall(); -#if 0 // *TODO: enable when we have a clear workflow to edit existing region environment - // If the region already has water params, add them to the list. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (region_settings.getWaterParams().size() != 0) - { - const std::string& region_name = gAgent.getRegion()->getName(); - mWaterPresetCombo->add(region_name, LLSD().with(0, region_name).with(1, LLEnvKey::SCOPE_REGION)); - mWaterPresetCombo->addSeparator(); - } -#endif - - std::list<std::string> user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList(); - // Add local user presets first. - for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - const std::string& name = *it; - mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [<name>, <scope>] - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add local system presets. - for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - const std::string& name = *it; - mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [<name>, <scope>] - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } mWaterPresetCombo->setLabel(getString("combo_label")); } @@ -544,6 +353,7 @@ void LLFloaterEditWater::enableEditing(bool enable) void LLFloaterEditWater::saveRegionWater() { +#if 0 llassert(getCurrentScope() == LLEnvKey::SCOPE_REGION); // make sure we're editing region water LL_DEBUGS("Windlight") << "Saving region water preset" << LL_ENDL; @@ -552,8 +362,10 @@ void LLFloaterEditWater::saveRegionWater() // *TODO: save to cached region settings. LL_WARNS("Windlight") << "Saving region water is not fully implemented yet" << LL_ENDL; +#endif } +#if 0 std::string LLFloaterEditWater::getCurrentPresetName() const { std::string name; @@ -561,7 +373,9 @@ std::string LLFloaterEditWater::getCurrentPresetName() const getSelectedPreset(name, scope); return name; } +#endif +#if 0 LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const { std::string name; @@ -569,71 +383,62 @@ LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const getSelectedPreset(name, scope); return scope; } +#endif -void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const +std::string LLFloaterEditWater::getSelectedPresetName() const { + std::string name; if (mWaterPresetNameEditor->getVisible()) { name = mWaterPresetNameEditor->getText(); - scope = LLEnvKey::SCOPE_LOCAL; } else { LLSD combo_val = mWaterPresetCombo->getValue(); - - if (!combo_val.isArray()) // manually typed text - { - name = combo_val.asString(); - scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - name = combo_val[0].asString(); - scope = (LLEnvKey::EScope) combo_val[1].asInteger(); - } + name = combo_val[0].asString(); } + + return name; } void LLFloaterEditWater::onWaterPresetNameEdited() { + std::string name = mWaterPresetNameEditor->getText(); + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + + pwater->setName(name); +#if 0 // Disable saving a water preset having empty name. mSaveButton->setEnabled(!getCurrentPresetName().empty()); +#endif } void LLFloaterEditWater::onWaterPresetSelected() { - LLWaterParamSet water_params; std::string name; - LLEnvKey::EScope scope; - getSelectedPreset(name, scope); + name = getSelectedPresetName(); - // Display selected preset. - if (scope == LLEnvKey::SCOPE_REGION) - { - water_params.setAll(LLEnvManagerNew::instance().getRegionSettings().getWaterParams()); - } - else // local preset selected - { - if (!LLWaterParamManager::instance().getParamSet(name, water_params)) - { - // Manually entered string? - LL_WARNS("Windlight") << "No water preset named " << name << LL_ENDL; - return; - } - } + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(name); - LLEnvManagerNew::instance().useWaterParams(water_params.getAll()); + if (!pwater) + { + LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL; + enableEditing(false); + return; + } - bool can_edit = (scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings()); - enableEditing(can_edit); + pwater = pwater->buildClone(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, pwater); + mEditSettings = pwater; - mMakeDefaultCheckBox->setEnabled(scope == LLEnvKey::SCOPE_LOCAL); + syncControls(); + enableEditing(true); } bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& response) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); // If they choose save, do it. Otherwise, don't do anything if (option == 0) @@ -641,32 +446,23 @@ bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& resp onSaveConfirmed(); } - return false; + return false; } void LLFloaterEditWater::onSaveConfirmed() { // Save currently displayed water params to the selected preset. - std::string name = getCurrentPresetName(); + std::string name = mEditSettings->getName(); LL_DEBUGS("Windlight") << "Saving sky preset " << name << LL_ENDL; - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - if (water_mgr.hasParamSet(name)) - { - water_mgr.setParamSet(name, water_mgr.mCurParams); - } - else - { - water_mgr.addParamSet(name, water_mgr.mCurParams); - } - water_mgr.savePreset(name); + LLEnvironment::instance().addWater(mEditSettings); // Change preference if requested. if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue()) { LL_DEBUGS("Windlight") << name << " is now the new preferred water preset" << LL_ENDL; - LLEnvManagerNew::instance().setUseWaterPreset(name); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings); } closeFloater(); @@ -674,42 +470,10 @@ void LLFloaterEditWater::onSaveConfirmed() void LLFloaterEditWater::onBtnSave() { - LLEnvKey::EScope scope; - std::string name; - getSelectedPreset(name, scope); - - if (scope == LLEnvKey::SCOPE_REGION) - { - saveRegionWater(); - closeFloater(); - return; - } - - if (name.empty()) - { - // *TODO: show an alert - LL_WARNS() << "Empty water preset name" << LL_ENDL; - return; - } - - // Don't allow overwriting system presets. - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - if (water_mgr.isSystemPreset(name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } + LLEnvironment::instance().addWater(mEditSettings); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings); - // Save, ask for confirmation for overwriting an existing preset. - if (water_mgr.hasParamSet(name)) - { - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditWater::onSaveAnswer, this, _1, _2)); - } - else - { - // new preset, hence no confirmation needed - onSaveConfirmed(); - } + closeFloater(); } void LLFloaterEditWater::onBtnCancel() @@ -719,25 +483,12 @@ void LLFloaterEditWater::onBtnCancel() void LLFloaterEditWater::onWaterPresetListChange() { - std::string name; - LLEnvKey::EScope scope; - getSelectedPreset(name, scope); // preset being edited - - if (scope == LLEnvKey::SCOPE_LOCAL && !LLWaterParamManager::instance().hasParamSet(name)) - { - // Preset we've been editing doesn't exist anymore. Close the floater. - closeFloater(false); - } - else - { - // A new preset has been added. - // Refresh the presets list, though it may not make sense as the floater is about to be closed. - refreshWaterPresetsList(); - } + refreshWaterPresetsList(); } void LLFloaterEditWater::onRegionSettingsChange() { +#if 0 // If creating a new preset, don't bother. if (isNewPreset()) { @@ -755,10 +506,12 @@ void LLFloaterEditWater::onRegionSettingsChange() { refreshWaterPresetsList(); } +#endif } void LLFloaterEditWater::onRegionInfoUpdate() { +#if 0 bool can_edit = true; // If we've selected the region water for editing. @@ -769,4 +522,5 @@ void LLFloaterEditWater::onRegionInfoUpdate() } enableEditing(can_edit); +#endif } diff --git a/indra/newview/llfloatereditwater.h b/indra/newview/llfloatereditwater.h deleted file mode 100644 index 2211bca59f..0000000000 --- a/indra/newview/llfloatereditwater.h +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @file llfloatereditwater.h - * @brief Floater to create or edit a water preset - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFLOATEREDITWATER_H -#define LL_LLFLOATEREDITWATER_H - -#include "llfloater.h" -#include "llenvmanager.h" // for LLEnvKey - -class LLButton; -class LLCheckBoxCtrl; -class LLComboBox; -class LLLineEditor; - -struct WaterVector2Control; -struct WaterVector3Control; -struct WaterColorControl; -struct WaterFloatControl; -struct WaterExpFloatControl; - -class LLFloaterEditWater : public LLFloater -{ - LOG_CLASS(LLFloaterEditWater); - -public: - LLFloaterEditWater(const LLSD &key); - - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); - /*virtual*/ void draw(); - -private: - void initCallbacks(void); - - //-- WL stuff begins ------------------------------------------------------ - - void syncControls(); /// sync up sliders with parameters - - // general purpose callbacks for dealing with color controllers - void onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - void onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - - void onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); - void onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); - void onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); - - void onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl); - void onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl); - - void onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl); - - void onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl); - - void onWaterFogColorMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); - - void onNormalMapPicked(LLUICtrl* ctrl); /// handle if they choose a new normal map - - //-- WL stuff ends -------------------------------------------------------- - - void reset(); - bool isNewPreset() const; - void refreshWaterPresetsList(); - void enableEditing(bool enable); - void saveRegionWater(); - - std::string getCurrentPresetName() const; - LLEnvKey::EScope getCurrentScope() const; - void getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const; - - void onWaterPresetNameEdited(); - void onWaterPresetSelected(); - bool onSaveAnswer(const LLSD& notification, const LLSD& response); - void onSaveConfirmed(); - - void onBtnSave(); - void onBtnCancel(); - - void onWaterPresetListChange(); - void onRegionSettingsChange(); - void onRegionInfoUpdate(); - - LLLineEditor* mWaterPresetNameEditor; - LLComboBox* mWaterPresetCombo; - LLCheckBoxCtrl* mMakeDefaultCheckBox; - LLButton* mSaveButton; -}; - -#endif // LL_LLFLOATEREDITWATER_H diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp deleted file mode 100644 index 4dbc8cdee0..0000000000 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @file llfloaterenvironmentsettings.cpp - * @brief LLFloaterEnvironmentSettings class definition - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llfloaterenvironmentsettings.h" - -#include "llcombobox.h" -#include "llradiogroup.h" - -#include "lldaycyclemanager.h" -#include "llenvmanager.h" -#include "llwaterparammanager.h" -#include "llwlparamset.h" -#include "llwlparammanager.h" - -LLFloaterEnvironmentSettings::LLFloaterEnvironmentSettings(const LLSD &key) -: LLFloater(key) - ,mRegionSettingsRadioGroup(NULL) - ,mDayCycleSettingsRadioGroup(NULL) - ,mWaterPresetCombo(NULL) - ,mSkyPresetCombo(NULL) - ,mDayCyclePresetCombo(NULL) -{ -} - -// virtual -BOOL LLFloaterEnvironmentSettings::postBuild() -{ - mRegionSettingsRadioGroup = getChild<LLRadioGroup>("region_settings_radio_group"); - mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSwitchRegionSettings, this)); - - mDayCycleSettingsRadioGroup = getChild<LLRadioGroup>("sky_dayc_settings_radio_group"); - mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSwitchDayCycle, this)); - - mWaterPresetCombo = getChild<LLComboBox>("water_settings_preset_combo"); - mWaterPresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectWaterPreset, this)); - - mSkyPresetCombo = getChild<LLComboBox>("sky_settings_preset_combo"); - mSkyPresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectSkyPreset, this)); - - mDayCyclePresetCombo = getChild<LLComboBox>("dayc_settings_preset_combo"); - mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectDayCyclePreset, this)); - - childSetCommitCallback("ok_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnOK, this), NULL); - getChild<LLUICtrl>("ok_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); - childSetCommitCallback("cancel_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnCancel, this), NULL); - getChild<LLUICtrl>("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); - - setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); - - LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); - - return TRUE; -} - -// virtual -void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) -{ - refresh(); -} - -void LLFloaterEnvironmentSettings::onSwitchRegionSettings() -{ - getChild<LLView>("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); - - apply(); -} - -void LLFloaterEnvironmentSettings::onSwitchDayCycle() -{ - bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - - mSkyPresetCombo->setEnabled(is_fixed_sky); - mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - - apply(); -} - -void LLFloaterEnvironmentSettings::onSelectWaterPreset() -{ - apply(); -} - -void LLFloaterEnvironmentSettings::onSelectSkyPreset() -{ - apply(); -} - -void LLFloaterEnvironmentSettings::onSelectDayCyclePreset() -{ - apply(); -} - -void LLFloaterEnvironmentSettings::onBtnOK() -{ - // Save and apply new user preferences. - bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - std::string water_preset = mWaterPresetCombo->getValue().asString(); - std::string sky_preset = mSkyPresetCombo->getValue().asString(); - std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); - - LLEnvManagerNew::instance().setUserPrefs( - water_preset, - sky_preset, - day_cycle, - use_fixed_sky, - use_region_settings); - - // *TODO: This triggers applying user preferences again, which is suboptimal. - closeFloater(); -} - -void LLFloaterEnvironmentSettings::onBtnCancel() -{ - closeFloater(); -} - -void LLFloaterEnvironmentSettings::refresh() -{ - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - - bool use_region_settings = env_mgr.getUseRegionSettings(); - bool use_fixed_sky = env_mgr.getUseFixedSky(); - - // Set up radio buttons according to user preferences. - mRegionSettingsRadioGroup->setSelectedIndex(use_region_settings ? 0 : 1); - mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); - - // Populate the combo boxes with appropriate lists of available presets. - populateWaterPresetsList(); - populateSkyPresetsList(); - populateDayCyclePresetsList(); - - // Enable/disable other controls based on user preferences. - getChild<LLView>("user_environment_settings")->setEnabled(!use_region_settings); - mSkyPresetCombo->setEnabled(use_fixed_sky); - mDayCyclePresetCombo->setEnabled(!use_fixed_sky); - - // Select the current presets in combo boxes. - mWaterPresetCombo->selectByValue(env_mgr.getWaterPresetName()); - mSkyPresetCombo->selectByValue(env_mgr.getSkyPresetName()); - mDayCyclePresetCombo->selectByValue(env_mgr.getDayCycleName()); -} - -void LLFloaterEnvironmentSettings::apply() -{ - // Update environment with the user choice. - bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - std::string water_preset = mWaterPresetCombo->getValue().asString(); - std::string sky_preset = mSkyPresetCombo->getValue().asString(); - std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); - - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - if (use_region_settings) - { - env_mgr.useRegionSettings(); - } - else - { - if (use_fixed_sky) - { - env_mgr.useSkyPreset(sky_preset); - } - else - { - env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); - } - - env_mgr.useWaterPreset(water_preset); - } -} - -void LLFloaterEnvironmentSettings::cancel() -{ - // Revert environment to user preferences. - LLEnvManagerNew::instance().usePrefs(); -} - -void LLFloaterEnvironmentSettings::populateWaterPresetsList() -{ - mWaterPresetCombo->removeall(); - - std::list<std::string> user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); - - // Add user presets first. - for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mWaterPresetCombo->add(*it); - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add system presets. - for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - mWaterPresetCombo->add(*it); - } -} - -void LLFloaterEnvironmentSettings::populateSkyPresetsList() -{ - mSkyPresetCombo->removeall(); - - LLWLParamManager::preset_name_list_t region_presets; // unused as we don't list region presets here - LLWLParamManager::preset_name_list_t user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it); - } - - if (!user_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it); - } -} - -void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() -{ - mDayCyclePresetCombo->removeall(); - - LLDayCycleManager::preset_name_list_t user_days, sys_days; - LLDayCycleManager::instance().getPresetNames(user_days, sys_days); - - // Add user days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it); - } - - if (user_days.size() > 0) - { - mDayCyclePresetCombo->addSeparator(); - } - - // Add system days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it); - } -} diff --git a/indra/newview/llfloaterenvironmentsettings.h b/indra/newview/llfloaterenvironmentsettings.h deleted file mode 100644 index 0ab458a0f6..0000000000 --- a/indra/newview/llfloaterenvironmentsettings.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @file llfloaterenvironmentsettings.h - * @brief LLFloaterEnvironmentSettings class definition - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFLOATERENVIRONMENTSETTINGS_H -#define LL_LLFLOATERENVIRONMENTSETTINGS_H - -#include "llfloater.h" - -class LLComboBox; -class LLRadioGroup; - -class LLFloaterEnvironmentSettings : public LLFloater -{ - LOG_CLASS(LLFloaterEnvironmentSettings); - -public: - LLFloaterEnvironmentSettings(const LLSD &key); - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - -private: - void onSwitchRegionSettings(); - void onSwitchDayCycle(); - - void onSelectWaterPreset(); - void onSelectSkyPreset(); - void onSelectDayCyclePreset(); - - void onBtnOK(); - void onBtnCancel(); - - void refresh(); /// update controls with user prefs - void apply(); - void cancel(); - - void populateWaterPresetsList(); - void populateSkyPresetsList(); - void populateDayCyclePresetsList(); - - LLRadioGroup* mRegionSettingsRadioGroup; - LLRadioGroup* mDayCycleSettingsRadioGroup; - - LLComboBox* mWaterPresetCombo; - LLComboBox* mSkyPresetCombo; - LLComboBox* mDayCyclePresetCombo; -}; - -#endif // LL_LLFLOATERENVIRONMENTSETTINGS_H diff --git a/indra/newview/llfloaterexperiencepicker.cpp b/indra/newview/llfloaterexperiencepicker.cpp index bb54c57baf..c642da7b83 100644 --- a/indra/newview/llfloaterexperiencepicker.cpp +++ b/indra/newview/llfloaterexperiencepicker.cpp @@ -74,59 +74,8 @@ LLFloaterExperiencePicker* LLFloaterExperiencePicker::show( select_callback_t ca void LLFloaterExperiencePicker::drawFrustum() { - if(mFrustumOrigin.get()) - { - LLView * frustumOrigin = mFrustumOrigin.get(); - LLRect origin_rect; - frustumOrigin->localRectToOtherView(frustumOrigin->getLocalRect(), &origin_rect, this); - // draw context cone connecting color picker with color swatch in parent floater - LLRect local_rect = getLocalRect(); - if (hasFocus() && frustumOrigin->isInVisibleChain() && mContextConeOpacity > 0.001f) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLEnable(GL_CULL_FACE); - gGL.begin(LLRender::QUADS); - { - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mTop); - gGL.vertex2i(origin_rect.mRight, origin_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mBottom); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mRight, origin_rect.mTop); - gGL.vertex2i(origin_rect.mRight, origin_rect.mBottom); - - gGL.color4f(0.f, 0.f, 0.f, mContextConeOutAlpha * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, mContextConeInAlpha * mContextConeOpacity); - gGL.vertex2i(origin_rect.mRight, origin_rect.mBottom); - gGL.vertex2i(origin_rect.mLeft, origin_rect.mBottom); - } - gGL.end(); - } - - if (gFocusMgr.childHasMouseCapture(getDragHandle())) - { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(mContextConeFadeTime)); - } - else - { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(mContextConeFadeTime)); - } - } + static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, mFrustumOrigin.get(), mContextConeFadeTime, mContextConeInAlpha, mContextConeOutAlpha); } void LLFloaterExperiencePicker::draw() diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp new file mode 100644 index 0000000000..f08c36a7e7 --- /dev/null +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -0,0 +1,856 @@ +/** + * @file llfloaterfixedenvironment.cpp + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterfixedenvironment.h" + +#include <boost/make_shared.hpp> + +// libs +#include "llbutton.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" +#include "llsliderctrl.h" +#include "lltabcontainer.h" +#include "llfilepicker.h" +#include "lllocalbitmaps.h" +#include "llsettingspicker.h" +#include "llviewermenufile.h" // LLFilePickerReplyThread +#include "llviewerparcelmgr.h" + +// newview +#include "llpaneleditwater.h" +#include "llpaneleditsky.h" + +#include "llsettingssky.h" +#include "llsettingswater.h" + +#include "llenvironment.h" +#include "llagent.h" +#include "llparcel.h" +#include "lltrans.h" + +#include "llsettingsvo.h" +#include "llinventorymodel.h" + +extern LLControlGroup gSavedSettings; + +namespace +{ + const std::string FIELD_SETTINGS_NAME("settings_name"); + + const std::string CONTROL_TAB_AREA("tab_settings"); + + const std::string BUTTON_NAME_IMPORT("btn_import"); + const std::string BUTTON_NAME_COMMIT("btn_commit"); + const std::string BUTTON_NAME_CANCEL("btn_cancel"); + const std::string BUTTON_NAME_FLYOUT("btn_flyout"); + const std::string BUTTON_NAME_LOAD("btn_load"); + + const std::string ACTION_SAVE("save_settings"); + const std::string ACTION_SAVEAS("save_as_new_settings"); + const std::string ACTION_COMMIT("commit_changes"); + const std::string ACTION_APPLY_LOCAL("apply_local"); + const std::string ACTION_APPLY_PARCEL("apply_parcel"); + const std::string ACTION_APPLY_REGION("apply_region"); + + const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml"); +} + +//========================================================================= +const std::string LLFloaterFixedEnvironment::KEY_INVENTORY_ID("inventory_id"); + + +//========================================================================= + +class LLFixedSettingCopiedCallback : public LLInventoryCallback +{ +public: + LLFixedSettingCopiedCallback(LLHandle<LLFloater> handle) : mHandle(handle) {} + + virtual void fire(const LLUUID& inv_item_id) + { + if (!mHandle.isDead()) + { + LLViewerInventoryItem* item = gInventory.getItem(inv_item_id); + if (item) + { + LLFloaterFixedEnvironment* floater = (LLFloaterFixedEnvironment*)mHandle.get(); + floater->onInventoryCreated(item->getAssetUUID(), inv_item_id); + } + } + } + +private: + LLHandle<LLFloater> mHandle; +}; + +//========================================================================= +LLFloaterFixedEnvironment::LLFloaterFixedEnvironment(const LLSD &key) : + LLFloater(key), + mFlyoutControl(nullptr), + mInventoryId(), + mInventoryItem(nullptr), + mIsDirty(false), + mCanCopy(false), + mCanMod(false), + mCanTrans(false) +{ +} + +LLFloaterFixedEnvironment::~LLFloaterFixedEnvironment() +{ + delete mFlyoutControl; +} + +BOOL LLFloaterFixedEnvironment::postBuild() +{ + mTab = getChild<LLTabContainer>(CONTROL_TAB_AREA); + mTxtName = getChild<LLLineEditor>(FIELD_SETTINGS_NAME); + + mTxtName->setCommitOnFocusLost(TRUE); + mTxtName->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNameChanged(mTxtName->getValue().asString()); }); + + getChild<LLButton>(BUTTON_NAME_IMPORT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonImport(); }); + getChild<LLButton>(BUTTON_NAME_CANCEL)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onClickCloseBtn(); }); + getChild<LLButton>(BUTTON_NAME_LOAD)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonLoad(); }); + + mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BUTTON_NAME_COMMIT, BUTTON_NAME_FLYOUT, XML_FLYOUTMENU_FILE, false); + mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); + mFlyoutControl->setMenuItemVisible(ACTION_COMMIT, false); + + return TRUE; +} + +void LLFloaterFixedEnvironment::onOpen(const LLSD& key) +{ + LLUUID invid; + + if (key.has(KEY_INVENTORY_ID)) + { + invid = key[KEY_INVENTORY_ID].asUUID(); + } + + loadInventoryItem(invid); + LL_INFOS("SETTINGS") << "Setting edit inventory item to " << mInventoryId << "." << LL_ENDL; + + updateEditEnvironment(); + syncronizeTabs(); + refresh(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); + +} + +void LLFloaterFixedEnvironment::onClose(bool app_quitting) +{ + doCloseInventoryFloater(app_quitting); + + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); + + mSettings.reset(); + syncronizeTabs(); +} + +void LLFloaterFixedEnvironment::onFocusReceived() +{ + if (isInVisibleChain()) + { + updateEditEnvironment(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); + } +} + +void LLFloaterFixedEnvironment::onFocusLost() +{ +} + +void LLFloaterFixedEnvironment::refresh() +{ + if (!mSettings) + { + // disable everything. + return; + } + + bool is_inventory_avail = canUseInventory(); + + mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, is_inventory_avail && mCanMod && !mInventoryId.isNull()); + mFlyoutControl->setMenuItemEnabled(ACTION_SAVEAS, is_inventory_avail && mCanCopy); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_PARCEL, canApplyParcel()); + mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_REGION, canApplyRegion()); + + mTxtName->setValue(mSettings->getName()); + mTxtName->setEnabled(mCanMod); + + S32 count = mTab->getTabCount(); + + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(mTab->getPanelByIndex(idx)); + if (panel) + { + panel->refresh(); + panel->setCanChangeSettings(mCanMod); + } + } +} + +void LLFloaterFixedEnvironment::syncronizeTabs() +{ + S32 count = mTab->getTabCount(); + + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(mTab->getPanelByIndex(idx)); + if (panel) + panel->setSettings(mSettings); + } +} + +LLFloaterSettingsPicker * LLFloaterFixedEnvironment::getSettingsPicker() +{ + LLFloaterSettingsPicker *picker = static_cast<LLFloaterSettingsPicker *>(mInventoryFloater.get()); + + // Show the dialog + if (!picker) + { + picker = new LLFloaterSettingsPicker(this, + LLUUID::null); + + mInventoryFloater = picker->getHandle(); + + picker->setCommitCallback([this](LLUICtrl *, const LLSD &data){ onPickerCommitSetting(data["ItemId"].asUUID() /*data["Track"]*/); }); + } + + return picker; +} + +void LLFloaterFixedEnvironment::loadInventoryItem(const LLUUID &inventoryId) +{ + if (inventoryId.isNull()) + { + mInventoryItem = nullptr; + mInventoryId.setNull(); + mCanMod = true; + mCanCopy = true; + mCanTrans = true; + return; + } + + mInventoryId = inventoryId; + LL_INFOS("SETTINGS") << "Setting edit inventory item to " << mInventoryId << "." << LL_ENDL; + mInventoryItem = gInventory.getItem(mInventoryId); + + if (!mInventoryItem) + { + LL_WARNS("SETTINGS") << "Could not find inventory item with Id = " << mInventoryId << LL_ENDL; + LLNotificationsUtil::add("CantFindInvItem"); + closeFloater(); + + mInventoryId.setNull(); + mInventoryItem = nullptr; + return; + } + + if (mInventoryItem->getAssetUUID().isNull()) + { + LL_WARNS("ENVIRONMENT") << "Asset ID in inventory item is NULL (" << mInventoryId << ")" << LL_ENDL; + LLNotificationsUtil::add("UnableEditItem"); + closeFloater(); + + mInventoryId.setNull(); + mInventoryItem = nullptr; + return; + } + + mCanCopy = mInventoryItem->getPermissions().allowCopyBy(gAgent.getID()); + mCanMod = mInventoryItem->getPermissions().allowModifyBy(gAgent.getID()); + mCanTrans = mInventoryItem->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); + + LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), + [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); +} + + +void LLFloaterFixedEnvironment::checkAndConfirmSettingsLoss(LLFloaterFixedEnvironment::on_confirm_fn cb) +{ + if (isDirty()) + { + LLSD args(LLSDMap("TYPE", mSettings->getSettingsType()) + ("NAME", mSettings->getName())); + + // create and show confirmation textbox + LLNotificationsUtil::add("SettingsConfirmLoss", args, LLSD(), + [cb](const LLSD¬if, const LLSD&resp) + { + S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); + if (opt == 0) + cb(); + }); + } + else if (cb) + { + cb(); + } +} + +void LLFloaterFixedEnvironment::onPickerCommitSetting(LLUUID item_id) +{ + mInventoryId = item_id; + mInventoryItem = gInventory.getItem(mInventoryId); + + LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), + [this](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onAssetLoaded(asset_id, settings, status); }); +} + +void LLFloaterFixedEnvironment::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +{ + if (mInventoryItem && mInventoryItem->getAssetUUID() != asset_id) + { + LL_WARNS("ENVIRONMENT") << "Discarding obsolete asset callback" << LL_ENDL; + return; + } + + clearDirtyFlag(); + + if (!settings || status) + { + LLSD args; + args["NAME"] = (mInventoryItem) ? mInventoryItem->getName() : "Unknown"; + LLNotificationsUtil::add("FailedToFindSettings", args); + closeFloater(); + return; + } + + mSettings = settings; + if (mInventoryItem) + mSettings->setName(mInventoryItem->getName()); + + if (mCanCopy) + settings->clearFlag(LLSettingsBase::FLAG_NOCOPY); + else + settings->setFlag(LLSettingsBase::FLAG_NOCOPY); + + if (mCanMod) + settings->clearFlag(LLSettingsBase::FLAG_NOMOD); + else + settings->setFlag(LLSettingsBase::FLAG_NOMOD); + + if (mCanTrans) + settings->clearFlag(LLSettingsBase::FLAG_NOTRANS); + else + settings->setFlag(LLSettingsBase::FLAG_NOTRANS); + + updateEditEnvironment(); + syncronizeTabs(); + refresh(); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST); +} + +void LLFloaterFixedEnvironment::onNameChanged(const std::string &name) +{ + mSettings->setName(name); + setDirtyFlag(); +} + +void LLFloaterFixedEnvironment::onButtonImport() +{ + checkAndConfirmSettingsLoss([this](){ doImportFromDisk(); }); +} + +void LLFloaterFixedEnvironment::onButtonApply(LLUICtrl *ctrl, const LLSD &data) +{ + std::string ctrl_action = ctrl->getName(); + + std::string local_desc; + bool is_local = false; // because getString can be empty + if (mSettings->getSettingsType() == "water") + { + LLSettingsWater::ptr_t water = std::static_pointer_cast<LLSettingsWater>(mSettings); + if (water) + { + // LLViewerFetchedTexture and check for FTT_LOCAL_FILE or check LLLocalBitmapMgr + if (LLLocalBitmapMgr::isLocal(water->getNormalMapID())) + { + local_desc = LLTrans::getString("EnvironmentNormalMap"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(water->getTransparentTextureID())) + { + local_desc = LLTrans::getString("EnvironmentTransparent"); + is_local = true; + } + } + } + else if (mSettings->getSettingsType() == "sky") + { + LLSettingsSky::ptr_t sky = std::static_pointer_cast<LLSettingsSky>(mSettings); + if (sky) + { + if (LLLocalBitmapMgr::isLocal(sky->getSunTextureId())) + { + local_desc = LLTrans::getString("EnvironmentSun"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(sky->getMoonTextureId())) + { + local_desc = LLTrans::getString("EnvironmentMoon"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(sky->getCloudNoiseTextureId())) + { + local_desc = LLTrans::getString("EnvironmentCloudNoise"); + is_local = true; + } + else if (LLLocalBitmapMgr::isLocal(sky->getBloomTextureId())) + { + local_desc = LLTrans::getString("EnvironmentBloom"); + is_local = true; + } + } + } + + if (is_local) + { + LLSD args; + args["FIELD"] = local_desc; + LLNotificationsUtil::add("WLLocalTextureFixedBlock", args); + return; + } + + if (ctrl_action == ACTION_SAVE) + { + doApplyUpdateInventory(); + } + else if (ctrl_action == ACTION_SAVEAS) + { + LLSD args; + args["DESC"] = mSettings->getName(); + LLNotificationsUtil::add("SaveSettingAs", args, LLSD(), boost::bind(&LLFloaterFixedEnvironment::onSaveAsCommit, this, _1, _2)); + } + else if ((ctrl_action == ACTION_APPLY_LOCAL) || + (ctrl_action == ACTION_APPLY_PARCEL) || + (ctrl_action == ACTION_APPLY_REGION)) + { + doApplyEnvironment(ctrl_action); + } + else + { + LL_WARNS("ENVIRONMENT") << "Unknown settings action '" << ctrl_action << "'" << LL_ENDL; + } +} + +void LLFloaterFixedEnvironment::onSaveAsCommit(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option) + { + std::string settings_name = response["message"].asString(); + LLStringUtil::trim(settings_name); + if (mCanMod) + { + doApplyCreateNewInventory(settings_name); + } + else if (mInventoryItem) + { + const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); + LLUUID parent_id = mInventoryItem->getParentUUID(); + if (marketplacelistings_id == parent_id) + { + parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); + } + + LLPointer<LLInventoryCallback> cb = new LLFixedSettingCopiedCallback(getHandle()); + copy_inventory_item( + gAgent.getID(), + mInventoryItem->getPermissions().getOwner(), + mInventoryItem->getUUID(), + parent_id, + settings_name, + cb); + } + else + { + LL_WARNS() << "Failed to copy fixed env setting" << LL_ENDL; + } + } +} + +void LLFloaterFixedEnvironment::onClickCloseBtn(bool app_quitting) +{ + if (!app_quitting) + checkAndConfirmSettingsLoss([this](){ closeFloater(); clearDirtyFlag(); }); + else + closeFloater(); +} + +void LLFloaterFixedEnvironment::onButtonLoad() +{ + checkAndConfirmSettingsLoss([this](){ doSelectFromInventory(); }); +} + +void LLFloaterFixedEnvironment::doApplyCreateNewInventory(std::string settings_name) +{ + if (mInventoryItem) + { + LLUUID parent_id = mInventoryItem->getParentUUID(); + U32 next_owner_perm = mInventoryItem->getPermissions().getMaskNextOwner(); + LLSettingsVOBase::createInventoryItem(mSettings, next_owner_perm, parent_id, settings_name, + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); + } + else + { + LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); + // This method knows what sort of settings object to create. + LLSettingsVOBase::createInventoryItem(mSettings, parent_id, settings_name, + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); + } +} + +void LLFloaterFixedEnvironment::doApplyUpdateInventory() +{ + LL_DEBUGS("ENVEDIT") << "Update inventory for " << mInventoryId << LL_ENDL; + if (mInventoryId.isNull()) + { + LLSettingsVOBase::createInventoryItem(mSettings, gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS), std::string(), + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryCreated(asset_id, inventory_id, results); }); + } + else + { + LLSettingsVOBase::updateInventoryItem(mSettings, mInventoryId, + [this](LLUUID asset_id, LLUUID inventory_id, LLUUID, LLSD results) { onInventoryUpdated(asset_id, inventory_id, results); }); + } +} + +void LLFloaterFixedEnvironment::doApplyEnvironment(const std::string &where) +{ + if (where == ACTION_APPLY_LOCAL) + { + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mSettings); + } + else if (where == ACTION_APPLY_PARCEL) + { + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + + if ((!parcel) || (parcel->getLocalID() == INVALID_PARCEL_ID)) + { + LL_WARNS("ENVIRONMENT") << "Can not identify parcel. Not applying." << LL_ENDL; + LLNotificationsUtil::add("WLParcelApplyFail"); + return; + } + + if (mInventoryItem && !isDirty()) + { + LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1); + } + else if (mSettings->getSettingsType() == "sky") + { + LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast<LLSettingsSky>(mSettings), -1, -1); + } + else if (mSettings->getSettingsType() == "water") + { + LLEnvironment::instance().updateParcel(parcel->getLocalID(), std::static_pointer_cast<LLSettingsWater>(mSettings), -1, -1); + } + } + else if (where == ACTION_APPLY_REGION) + { + if (mInventoryItem && !isDirty()) + { + LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1); + } + else if (mSettings->getSettingsType() == "sky") + { + LLEnvironment::instance().updateRegion(std::static_pointer_cast<LLSettingsSky>(mSettings), -1, -1); + } + else if (mSettings->getSettingsType() == "water") + { + LLEnvironment::instance().updateRegion(std::static_pointer_cast<LLSettingsWater>(mSettings), -1, -1); + } + } + else + { + LL_WARNS("ENVIRONMENT") << "Unknown apply '" << where << "'" << LL_ENDL; + return; + } + +} + +void LLFloaterFixedEnvironment::doCloseInventoryFloater(bool quitting) +{ + LLFloater* floaterp = mInventoryFloater.get(); + + if (floaterp) + { + floaterp->closeFloater(quitting); + } +} + +void LLFloaterFixedEnvironment::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ + LL_WARNS("ENVIRONMENT") << "Inventory item " << inventory_id << " has been created with asset " << asset_id << " results are:" << results << LL_ENDL; + + if (inventory_id.isNull() || !results["success"].asBoolean()) + { + LLNotificationsUtil::add("CantCreateInventory"); + return; + } + onInventoryCreated(asset_id, inventory_id); +} + +void LLFloaterFixedEnvironment::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id) +{ + if (mInventoryItem) + { + LLPermissions perms = mInventoryItem->getPermissions(); + + LLInventoryItem *created_item = gInventory.getItem(mInventoryId); + + if (created_item) + { + created_item->setPermissions(perms); + created_item->updateServer(false); + } + } + clearDirtyFlag(); + setFocus(TRUE); // Call back the focus... + loadInventoryItem(inventory_id); +} + +void LLFloaterFixedEnvironment::onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results) +{ + LL_WARNS("ENVIRONMENT") << "Inventory item " << inventory_id << " has been updated with asset " << asset_id << " results are:" << results << LL_ENDL; + + clearDirtyFlag(); + if (inventory_id != mInventoryId) + { + loadInventoryItem(inventory_id); + } +} + + +void LLFloaterFixedEnvironment::clearDirtyFlag() +{ + mIsDirty = false; + + S32 count = mTab->getTabCount(); + + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(mTab->getPanelByIndex(idx)); + if (panel) + panel->clearIsDirty(); + } + +} + +void LLFloaterFixedEnvironment::doSelectFromInventory() +{ + LLFloaterSettingsPicker *picker = getSettingsPicker(); + + picker->setSettingsFilter(mSettings->getSettingsTypeValue()); + picker->openFloater(); + picker->setFocus(TRUE); +} + +void LLFloaterFixedEnvironment::onPanelDirtyFlagChanged(bool value) +{ + if (value) + setDirtyFlag(); +} + +//------------------------------------------------------------------------- +bool LLFloaterFixedEnvironment::canUseInventory() const +{ + return LLEnvironment::instance().isInventoryEnabled(); +} + +bool LLFloaterFixedEnvironment::canApplyRegion() const +{ + return gAgent.canManageEstate(); +} + +bool LLFloaterFixedEnvironment::canApplyParcel() const +{ + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); +} + +//========================================================================= +LLFloaterFixedEnvironmentWater::LLFloaterFixedEnvironmentWater(const LLSD &key): + LLFloaterFixedEnvironment(key) +{} + +BOOL LLFloaterFixedEnvironmentWater::postBuild() +{ + if (!LLFloaterFixedEnvironment::postBuild()) + return FALSE; + + LLPanelSettingsWater * panel; + panel = new LLPanelSettingsWaterMainTab; + panel->buildFromFile("panel_settings_water.xml"); + panel->setWater(std::static_pointer_cast<LLSettingsWater>(mSettings)); + panel->setOnDirtyFlagChanged( [this] (LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(true)); + + return TRUE; +} + +void LLFloaterFixedEnvironmentWater::updateEditEnvironment(void) +{ + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, + std::static_pointer_cast<LLSettingsWater>(mSettings)); +} + +void LLFloaterFixedEnvironmentWater::onOpen(const LLSD& key) +{ + if (!mSettings) + { + // Initialize the settings, take a snapshot of the current water. + mSettings = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_CURRENT)->buildClone(); + mSettings->setName("Snapshot water (new)"); + + // TODO: Should we grab sky and keep it around for reference? + } + + LLFloaterFixedEnvironment::onOpen(key); +} + +void LLFloaterFixedEnvironmentWater::doImportFromDisk() +{ // Load a a legacy Windlight XML from disk. + (new LLFilePickerReplyThread(boost::bind(&LLFloaterFixedEnvironmentWater::loadWaterSettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false))->getFile(); +} + +void LLFloaterFixedEnvironmentWater::loadWaterSettingFromFile(const std::vector<std::string>& filenames) +{ + LLSD messages; + if (filenames.size() < 1) return; + std::string filename = filenames[0]; + LL_DEBUGS("ENVEDIT") << "Selected file: " << filename << LL_ENDL; + LLSettingsWater::ptr_t legacywater = LLEnvironment::createWaterFromLegacyPreset(filename, messages); + + if (!legacywater) + { + LLNotificationsUtil::add("WLImportFail", messages); + return; + } + + loadInventoryItem(LLUUID::null); + + setDirtyFlag(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, legacywater); + setEditSettings(legacywater); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST, true); +} + +//========================================================================= +LLFloaterFixedEnvironmentSky::LLFloaterFixedEnvironmentSky(const LLSD &key) : + LLFloaterFixedEnvironment(key) +{} + +BOOL LLFloaterFixedEnvironmentSky::postBuild() +{ + if (!LLFloaterFixedEnvironment::postBuild()) + return FALSE; + + LLPanelSettingsSky * panel; + panel = new LLPanelSettingsSkyAtmosTab; + panel->buildFromFile("panel_settings_sky_atmos.xml"); + panel->setSky(std::static_pointer_cast<LLSettingsSky>(mSettings)); + panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(true)); + + panel = new LLPanelSettingsSkyCloudTab; + panel->buildFromFile("panel_settings_sky_clouds.xml"); + panel->setSky(std::static_pointer_cast<LLSettingsSky>(mSettings)); + panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + + panel = new LLPanelSettingsSkySunMoonTab; + panel->buildFromFile("panel_settings_sky_sunmoon.xml"); + panel->setSky(std::static_pointer_cast<LLSettingsSky>(mSettings)); + panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + + return TRUE; +} + +void LLFloaterFixedEnvironmentSky::updateEditEnvironment(void) +{ + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, + std::static_pointer_cast<LLSettingsSky>(mSettings)); +} + +void LLFloaterFixedEnvironmentSky::onOpen(const LLSD& key) +{ + if (!mSettings) + { + // Initialize the settings, take a snapshot of the current water. + mSettings = LLEnvironment::instance().getEnvironmentFixedSky(LLEnvironment::ENV_CURRENT)->buildClone(); + mSettings->setName("Snapshot sky (new)"); + + // TODO: Should we grab water and keep it around for reference? + } + + LLFloaterFixedEnvironment::onOpen(key); +} + +void LLFloaterFixedEnvironmentSky::doImportFromDisk() +{ // Load a a legacy Windlight XML from disk. + (new LLFilePickerReplyThread(boost::bind(&LLFloaterFixedEnvironmentSky::loadSkySettingFromFile, this, _1), LLFilePicker::FFLOAD_XML, false))->getFile(); +} + +void LLFloaterFixedEnvironmentSky::loadSkySettingFromFile(const std::vector<std::string>& filenames) +{ + if (filenames.size() < 1) return; + std::string filename = filenames[0]; + LLSD messages; + + LL_DEBUGS("ENVEDIT") << "Selected file: " << filename << LL_ENDL; + LLSettingsSky::ptr_t legacysky = LLEnvironment::createSkyFromLegacyPreset(filename, messages); + + if (!legacysky) + { + LLNotificationsUtil::add("WLImportFail", messages); + + return; + } + + loadInventoryItem(LLUUID::null); + + setDirtyFlag(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, legacysky); + setEditSettings(legacysky); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST, true); +} + +//========================================================================= + +void LLSettingsEditPanel::setCanChangeSettings(bool enabled) +{ + setEnabled(enabled); + setAllChildrenEnabled(enabled); +} diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h new file mode 100644 index 0000000000..f694e59281 --- /dev/null +++ b/indra/newview/llfloaterfixedenvironment.h @@ -0,0 +1,204 @@ +/** + * @file llfloaterfixedenvironment.h + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_FLOATERFIXEDENVIRONMENT_H +#define LL_FLOATERFIXEDENVIRONMENT_H + +#include "llfloater.h" +#include "llsettingsbase.h" +#include "llflyoutcombobtn.h" +#include "llinventory.h" + +#include "boost/signals2.hpp" + +class LLTabContainer; +class LLButton; +class LLLineEditor; +class LLFloaterSettingsPicker; +class LLFixedSettingCopiedCallback; + +/** + * Floater container for creating and editing fixed environment settings. + */ +class LLFloaterFixedEnvironment : public LLFloater +{ + LOG_CLASS(LLFloaterFixedEnvironment); + + friend class LLFixedSettingCopiedCallback; + +public: + static const std::string KEY_INVENTORY_ID; + + LLFloaterFixedEnvironment(const LLSD &key); + ~LLFloaterFixedEnvironment(); + + virtual BOOL postBuild() override; + virtual void onOpen(const LLSD& key) override; + virtual void onClose(bool app_quitting) override; + + virtual void onFocusReceived() override; + virtual void onFocusLost() override; + + void setEditSettings(const LLSettingsBase::ptr_t &settings) { mSettings = settings; clearDirtyFlag(); syncronizeTabs(); refresh(); } + LLSettingsBase::ptr_t getEditSettings() const { return mSettings; } + + virtual BOOL isDirty() const override { return getIsDirty(); } + +protected: + typedef std::function<void()> on_confirm_fn; + + virtual void updateEditEnvironment() = 0; + virtual void refresh() override; + virtual void syncronizeTabs(); + + LLFloaterSettingsPicker *getSettingsPicker(); + + void loadInventoryItem(const LLUUID &inventoryId); + + void checkAndConfirmSettingsLoss(on_confirm_fn cb); + + LLTabContainer * mTab; + LLLineEditor * mTxtName; + + LLSettingsBase::ptr_t mSettings; + + virtual void doImportFromDisk() = 0; + virtual void doApplyCreateNewInventory(std::string settings_name); + virtual void doApplyUpdateInventory(); + virtual void doApplyEnvironment(const std::string &where); + void doCloseInventoryFloater(bool quitting = false); + + bool canUseInventory() const; + bool canApplyRegion() const; + bool canApplyParcel() const; + + LLFlyoutComboBtnCtrl * mFlyoutControl; + + LLUUID mInventoryId; + LLInventoryItem * mInventoryItem; + LLHandle<LLFloater> mInventoryFloater; + bool mCanCopy; + bool mCanMod; + bool mCanTrans; + + void onInventoryCreated(LLUUID asset_id, LLUUID inventory_id); + void onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results); + void onInventoryUpdated(LLUUID asset_id, LLUUID inventory_id, LLSD results); + + bool getIsDirty() const { return mIsDirty; } + void setDirtyFlag() { mIsDirty = true; } + virtual void clearDirtyFlag(); + + void doSelectFromInventory(); + void onPanelDirtyFlagChanged(bool); + + virtual void onClickCloseBtn(bool app_quitting = false) override; + void onSaveAsCommit(const LLSD& notification, const LLSD& response); + +private: + void onNameChanged(const std::string &name); + + void onButtonImport(); + void onButtonApply(LLUICtrl *ctrl, const LLSD &data); + void onButtonLoad(); + + void onPickerCommitSetting(LLUUID item_id); + void onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status); + + bool mIsDirty; +}; + +class LLFloaterFixedEnvironmentWater : public LLFloaterFixedEnvironment +{ + LOG_CLASS(LLFloaterFixedEnvironmentWater); + +public: + LLFloaterFixedEnvironmentWater(const LLSD &key); + + BOOL postBuild() override; + + virtual void onOpen(const LLSD& key) override; + +protected: + virtual void updateEditEnvironment() override; + + virtual void doImportFromDisk() override; + void loadWaterSettingFromFile(const std::vector<std::string>& filenames); + +private: +}; + +class LLFloaterFixedEnvironmentSky : public LLFloaterFixedEnvironment +{ + LOG_CLASS(LLFloaterFixedEnvironmentSky); + +public: + LLFloaterFixedEnvironmentSky(const LLSD &key); + + BOOL postBuild() override; + + virtual void onOpen(const LLSD& key) override; + +protected: + virtual void updateEditEnvironment() override; + + virtual void doImportFromDisk() override; + void loadSkySettingFromFile(const std::vector<std::string>& filenames); + +private: +}; + +class LLSettingsEditPanel : public LLPanel +{ +public: + virtual void setSettings(const LLSettingsBase::ptr_t &) = 0; + + typedef boost::signals2::signal<void(LLPanel *, bool)> on_dirty_charged_sg; + typedef boost::signals2::connection connection_t; + + inline bool getIsDirty() const { return mIsDirty; } + inline void setIsDirty() { mIsDirty = true; if (!mOnDirtyChanged.empty()) mOnDirtyChanged(this, mIsDirty); } + inline void clearIsDirty() { mIsDirty = false; if (!mOnDirtyChanged.empty()) mOnDirtyChanged(this, mIsDirty); } + + virtual void setCanChangeSettings(bool flag); + + inline connection_t setOnDirtyFlagChanged(on_dirty_charged_sg::slot_type cb) { return mOnDirtyChanged.connect(cb); } + + +protected: + LLSettingsEditPanel() : + LLPanel(), + mIsDirty(false), + mOnDirtyChanged() + {} + +private: + bool mIsDirty; + + on_dirty_charged_sg mOnDirtyChanged; +}; + +#endif // LL_FLOATERFIXEDENVIRONMENT_H diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index b840d37c4d..57c010502e 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -470,7 +470,7 @@ void LLFloaterGesture::onClickNew() "", LLAssetType::AT_GESTURE, LLInventoryType::IT_GESTURE, - NOT_WEARABLE, + NO_INV_SUBTYPE, PERM_MOVE | LLFloaterPerms::getNextOwnerPerms("Gestures"), cb); } diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 88b3fb7b96..eeb1c17f4b 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -78,9 +78,11 @@ #include "lltrans.h" #include "llpanelexperiencelisteditor.h" #include "llpanelexperiencepicker.h" +#include "llpanelenvironment.h" #include "llexperiencecache.h" #include "llgroupactions.h" +#include "llenvironment.h" const F64 COVENANT_REFRESH_TIME_SEC = 60.0f; @@ -138,6 +140,38 @@ protected: LLPanelExperienceListEditor* mBlocked; }; + +class LLPanelLandEnvironment + : public LLPanelEnvironmentInfo +{ +public: + LLPanelLandEnvironment(LLSafeHandle<LLParcelSelection>& parcelp); + + virtual bool isRegion() const override { return false; } + virtual bool isLargeEnough() override + { + LLParcel *parcelp = mParcel->getParcel(); + return ((parcelp) ? (parcelp->getArea() >= MINIMUM_PARCEL_SIZE) : false); + } + + virtual BOOL postBuild() override; + virtual void refresh() override; + + virtual LLParcel * getParcel() override; + + virtual bool canEdit() override; + virtual S32 getParcelId() override; + +protected: + virtual void refreshFromSource() override; + + bool isSameRegion(); + + LLSafeHandle<LLParcelSelection> & mParcel; + S32 mLastParcelId; +}; + + // inserts maturity info(icon and text) into target textbox // names_floater - pointer to floater which contains strings with maturity icons filenames // str_to_parse is string in format "txt1[MATURITY]txt2" where maturity icon and text will be inserted instead of [MATURITY] @@ -226,7 +260,7 @@ LLPanelLandCovenant* LLFloaterLand::getCurrentPanelLandCovenant() // static void LLFloaterLand::refreshAll() { - LLFloaterLand* land_instance = LLFloaterReg::getTypedInstance<LLFloaterLand>("about_land"); + LLFloaterLand* land_instance = LLFloaterReg::findTypedInstance<LLFloaterLand>("about_land"); if(land_instance) { land_instance->refresh(); @@ -277,6 +311,7 @@ LLFloaterLand::LLFloaterLand(const LLSD& seed) mFactoryMap["land_media_panel"] = LLCallbackMap(createPanelLandMedia, this); mFactoryMap["land_access_panel"] = LLCallbackMap(createPanelLandAccess, this); mFactoryMap["land_experiences_panel"] = LLCallbackMap(createPanelLandExperiences, this); + mFactoryMap["land_environment_panel"] = LLCallbackMap(createPanelLandEnvironment, this); sObserver = new LLParcelSelectionObserver(); LLViewerParcelMgr::getInstance()->addObserver( sObserver ); @@ -318,6 +353,7 @@ void LLFloaterLand::refresh() mPanelAccess->refresh(); mPanelCovenant->refresh(); mPanelExperiences->refresh(); + mPanelEnvironment->refresh(); } @@ -386,6 +422,14 @@ void* LLFloaterLand::createPanelLandExperiences(void* data) return self->mPanelExperiences; } +//static +void* LLFloaterLand::createPanelLandEnvironment(void* data) +{ + LLFloaterLand* self = (LLFloaterLand*)data; + self->mPanelEnvironment = new LLPanelLandEnvironment(self->mParcel); + return self->mPanelEnvironment; +} + //--------------------------------------------------------------------------- // LLPanelLandGeneral @@ -3211,3 +3255,141 @@ void LLPanelLandExperiences::refresh() refreshPanel(mAllowed, EXPERIENCE_KEY_TYPE_ALLOWED); refreshPanel(mBlocked, EXPERIENCE_KEY_TYPE_BLOCKED); } + +//========================================================================= + +LLPanelLandEnvironment::LLPanelLandEnvironment(LLParcelSelectionHandle& parcel) : + LLPanelEnvironmentInfo(), + mParcel(parcel), + mLastParcelId(INVALID_PARCEL_ID) +{ +} + +BOOL LLPanelLandEnvironment::postBuild() +{ + if (!LLPanelEnvironmentInfo::postBuild()) + return FALSE; + + getChild<LLUICtrl>(BTN_USEDEFAULT)->setLabelArg("[USEDEFAULT]", getString(STR_LABEL_USEREGION)); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setVisible(FALSE); + getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(TRUE); + + return TRUE; +} + +void LLPanelLandEnvironment::refresh() +{ + if (gDisconnected) + return; + + if (!isSameRegion()) + { + setCrossRegion(true); + mCurrentEnvironment.reset(); + mLastParcelId = INVALID_PARCEL_ID; + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + setControlsEnabled(false); + return; + } + + if (mLastParcelId != getParcelId()) + { + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + mCurrentEnvironment.reset(); + } + + if (!mCurrentEnvironment && mCurEnvVersion <= INVALID_PARCEL_ENVIRONMENT_VERSION) + { + refreshFromSource(); + return; + } + + LLPanelEnvironmentInfo::refresh(); +} + +void LLPanelLandEnvironment::refreshFromSource() +{ + LLParcel *parcel = getParcel(); + + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + { + setNoEnvironmentSupport(true); + setControlsEnabled(false); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + return; + } + setNoEnvironmentSupport(false); + + if (!parcel) + { + setNoSelection(true); + setControlsEnabled(false); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + return; + } + + setNoSelection(false); + if (isSameRegion()) + { + LL_DEBUGS("ENVIRONMENT") << "Requesting environment for parcel " << parcel->getLocalID() << ", known version " << mCurEnvVersion << LL_ENDL; + setCrossRegion(false); + + LLHandle<LLPanel> that_h = getHandle(); + + if (mCurEnvVersion < UNSET_PARCEL_ENVIRONMENT_VERSION) + { + // to mark as requesting + mCurEnvVersion = parcel->getParcelEnvironmentVersion(); + } + mLastParcelId = parcel->getLocalID(); + + LLEnvironment::instance().requestParcel(parcel->getLocalID(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) + { + LLPanelLandEnvironment *that = (LLPanelLandEnvironment*)that_h.get(); + if (!that) return; + that->mLastParcelId = parcel_id; + that->onEnvironmentReceived(parcel_id, envifo); + }); + } + else + { + setCrossRegion(true); + mCurrentEnvironment.reset(); + mLastParcelId = INVALID_PARCEL_ID; + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + } + setControlsEnabled(false); +} + + +bool LLPanelLandEnvironment::isSameRegion() +{ + LLViewerRegion* regionp = LLViewerParcelMgr::instance().getSelectionRegion(); + + return (!regionp || (regionp->getRegionID() == gAgent.getRegion()->getRegionID())); +} + +LLParcel *LLPanelLandEnvironment::getParcel() +{ + return mParcel->getParcel(); +} + + +bool LLPanelLandEnvironment::canEdit() +{ + LLParcel *parcel = getParcel(); + if (!parcel) + return false; + + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(parcel) && mAllowOverride; +} + +S32 LLPanelLandEnvironment::getParcelId() +{ + LLParcel *parcel = getParcel(); + if (!parcel) + return INVALID_PARCEL_ID; + + return parcel->getLocalID(); +} diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 0540ddb880..0eea46bc5a 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -67,6 +67,7 @@ class LLPanelLandRenters; class LLPanelLandCovenant; class LLParcel; class LLPanelLandExperiences; +class LLPanelLandEnvironment; class LLFloaterLand : public LLFloater @@ -103,7 +104,8 @@ protected: static void* createPanelLandMedia(void* data); static void* createPanelLandAccess(void* data); static void* createPanelLandExperiences(void* data); - static void* createPanelLandBan(void* data); + static void* createPanelLandEnvironment(void* data); + static void* createPanelLandBan(void* data); protected: @@ -119,6 +121,7 @@ protected: LLPanelLandAccess* mPanelAccess; LLPanelLandCovenant* mPanelCovenant; LLPanelLandExperiences* mPanelExperiences; + LLPanelLandEnvironment *mPanelEnvironment; LLSafeHandle<LLParcelSelection> mParcel; diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp new file mode 100644 index 0000000000..1edec248d9 --- /dev/null +++ b/indra/newview/llfloatermyenvironment.cpp @@ -0,0 +1,497 @@ +/** + * @file llfloatergesture.cpp + * @brief Read-only list of gestures from your inventory. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatermyenvironment.h" + +#include "llinventory.h" +#include "llinventorybridge.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "llclipboard.h" + +#include "llagent.h" +#include "llclipboard.h" +#include "llkeyboard.h" +#include "llmenugl.h" +#include "llmultigesture.h" +#include "llscrolllistctrl.h" +#include "llcheckboxctrl.h" +#include "lltrans.h" +#include "llviewergesture.h" +#include "llviewermenu.h" +#include "llviewerinventory.h" +#include "llviewercontrol.h" +#include "llfloaterperms.h" +#include "llenvironment.h" +#include "llparcel.h" +#include "llviewerparcelmgr.h" + +//========================================================================= +namespace +{ + const std::string CHECK_DAYS("chk_days"); + const std::string CHECK_SKIES("chk_skies"); + const std::string CHECK_WATER("chk_water"); + const std::string PANEL_SETTINGS("pnl_settings"); + const std::string CHECK_SHOWFOLDERS("chk_showfolders"); + const std::string BUTTON_NEWSETTINGS("btn_gear"); + const std::string BUTTON_GEAR("btn_newsettings"); + const std::string BUTTON_DELETE("btn_del"); + + + const std::string ACTION_DOCREATE("MyEnvironments.DoCreate"); + const std::string ACTION_DOEDIT("MyEnvironments.DoEdit"); + const std::string ACTION_DOAPPLY("MyEnvironments.DoApply"); + const std::string ACTION_COPYPASTE("MyEnvironments.CopyPaste"); + const std::string ENABLE_ACTION("MyEnvironments.EnableAction"); + const std::string ENABLE_CANAPPLY("MyEnvironments.CanApply"); + const std::string ENABLE_ENVIRONMENT("MyEnvironments.EnvironmentEnabled"); + + const std::string PARAMETER_REGION("region"); + const std::string PARAMETER_PARCEL("parcel"); + const std::string PARAMETER_LOCAL("local"); + + const std::string PARAMETER_EDIT("edit"); + const std::string PARAMETER_COPY("copy"); + const std::string PARAMETER_PASTE("paste"); + const std::string PARAMETER_COPYUUID("copy_uuid"); +} + +//========================================================================= +#if 0 +BOOL item_name_precedes( LLInventoryItem* a, LLInventoryItem* b ) +{ + return LLStringUtil::precedesDict( a->getName(), b->getName() ); +} + +class LLFloaterGestureObserver : public LLGestureManagerObserver +{ +public: + LLFloaterGestureObserver(LLFloaterGesture* floater) : mFloater(floater) {} + virtual ~LLFloaterGestureObserver() {} + virtual void changed() { mFloater->refreshAll(); } + +private: + LLFloaterGesture* mFloater; +}; +//----------------------------- +// GestureCallback +//----------------------------- + +class GestureShowCallback : public LLInventoryCallback +{ +public: + void fire(const LLUUID &inv_item) + { + LLPreviewGesture::show(inv_item, LLUUID::null); + + LLInventoryItem* item = gInventory.getItem(inv_item); + if (item) + { + LLPermissions perm = item->getPermissions(); + perm.setMaskNext(LLFloaterPerms::getNextOwnerPerms("Gestures")); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); + item->setPermissions(perm); + item->updateServer(FALSE); + } + } +}; + +class GestureCopiedCallback : public LLInventoryCallback +{ +private: + LLFloaterGesture* mFloater; + +public: + GestureCopiedCallback(LLFloaterGesture* floater): mFloater(floater) + {} + void fire(const LLUUID &inv_item) + { + if(mFloater) + { + mFloater->addGesture(inv_item,NULL,mFloater->getChild<LLScrollListCtrl>("gesture_list")); + + // EXP-1909 (Pasted gesture displayed twice) + // The problem is that addGesture is called here for the second time for the same item (which is copied) + // First time addGesture is called from LLFloaterGestureObserver::changed(), which is a callback for inventory + // change. So we need to refresh the gesture list to avoid duplicates. + mFloater->refreshAll(); + } + } +}; + +#endif + +//========================================================================= +LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : + LLFloater(key), + mInventoryList(nullptr), + mShowFolders(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS), + mTypeFilter((0x01 << static_cast<U64>(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast<U64>(LLSettingsType::ST_SKY)) | (0x01 << static_cast<U64>(LLSettingsType::ST_WATER))), + mSelectedAsset() +{ + mCommitCallbackRegistrar.add(ACTION_DOCREATE, [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); }); + mCommitCallbackRegistrar.add(ACTION_DOEDIT, [this](LLUICtrl *, const LLSD &userdata) { mInventoryList->openSelected(); }); + mCommitCallbackRegistrar.add(ACTION_DOAPPLY, [this](LLUICtrl *, const LLSD &userdata) { onDoApply(userdata.asString()); }); + mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [this](LLUICtrl *, const LLSD &userdata) { mInventoryList->doToSelected(userdata.asString()); }); + + mEnableCallbackRegistrar.add(ENABLE_ACTION, [this](LLUICtrl *, const LLSD &userdata) { return canAction(userdata.asString()); }); + mEnableCallbackRegistrar.add(ENABLE_CANAPPLY, [this](LLUICtrl *, const LLSD &userdata) { return canApply(userdata.asString()); }); + mEnableCallbackRegistrar.add(ENABLE_ENVIRONMENT, [](LLUICtrl *, const LLSD &) { return LLEnvironment::instance().isInventoryEnabled(); }); + +} + +LLFloaterMyEnvironment::~LLFloaterMyEnvironment() +{ + // LLGestureMgr::instance().removeObserver(mObserver); + // delete mObserver; + // mObserver = NULL; + // gInventory.removeObserver(this); +} + + +BOOL LLFloaterMyEnvironment::postBuild() +{ + mInventoryList = getChild<LLInventoryPanel>(PANEL_SETTINGS); + + if (mInventoryList) + { + U32 filter_types = 0x0; + filter_types |= 0x1 << LLInventoryType::IT_SETTINGS; + + mInventoryList->setFilterTypes(filter_types); + + mInventoryList->setSelectCallback([this](const std::deque<LLFolderViewItem*>&, BOOL) { onSelectionChange(); }); + mInventoryList->setShowFolderState(mShowFolders); + mInventoryList->setFilterSettingsTypes(mTypeFilter); + } + + childSetCommitCallback(CHECK_DAYS, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); + childSetCommitCallback(CHECK_SKIES, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); + childSetCommitCallback(CHECK_WATER, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); + childSetCommitCallback(CHECK_SHOWFOLDERS, [this](LLUICtrl*, void*) { onShowFoldersChange(); }, nullptr); + + childSetCommitCallback(BUTTON_DELETE, [this](LLUICtrl *, void*) { onDeleteSelected(); }, nullptr); + + return TRUE; +} + +void LLFloaterMyEnvironment::refresh() +{ + getChild<LLCheckBoxCtrl>(CHECK_SHOWFOLDERS)->setValue(LLSD::Boolean(mShowFolders == LLInventoryFilter::SHOW_ALL_FOLDERS)); + + getChild<LLCheckBoxCtrl>(CHECK_DAYS)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast<U64>(LLSettingsType::ST_DAYCYCLE)))); + getChild<LLCheckBoxCtrl>(CHECK_SKIES)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast<U64>(LLSettingsType::ST_SKY)))); + getChild<LLCheckBoxCtrl>(CHECK_WATER)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast<U64>(LLSettingsType::ST_WATER)))); + + refreshButtonStates(); + +} + +void LLFloaterMyEnvironment::onOpen(const LLSD& key) +{ + LLFloater::onOpen(key); + + if (key.has("asset_id") && mInventoryList) + { + mSelectedAsset = key["asset_id"].asUUID(); + + if (!mSelectedAsset.isNull()) + { + LLUUID obj_id = findItemByAssetId(mSelectedAsset, false, false); + if (!obj_id.isNull()) + mInventoryList->setSelection(obj_id, false); + } + } + else + { + mSelectedAsset.setNull(); + } + + refresh(); +} + +//------------------------------------------------------------------------- +void LLFloaterMyEnvironment::onShowFoldersChange() +{ + bool show_check (getChild<LLCheckBoxCtrl>(CHECK_SHOWFOLDERS)->getValue().asBoolean()); + + mShowFolders = (show_check) ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS; + + if (mInventoryList) + mInventoryList->setShowFolderState(mShowFolders); +} + +void LLFloaterMyEnvironment::onFilterCheckChange() +{ + mTypeFilter = 0x0; + + if (getChild<LLCheckBoxCtrl>(CHECK_DAYS)->getValue().asBoolean()) + mTypeFilter |= 0x01 << static_cast<U64>(LLSettingsType::ST_DAYCYCLE); + if (getChild<LLCheckBoxCtrl>(CHECK_SKIES)->getValue().asBoolean()) + mTypeFilter |= 0x01 << static_cast<U64>(LLSettingsType::ST_SKY); + if (getChild<LLCheckBoxCtrl>(CHECK_WATER)->getValue().asBoolean()) + mTypeFilter |= 0x01 << static_cast<U64>(LLSettingsType::ST_WATER); + + if (mInventoryList) + mInventoryList->setFilterSettingsTypes(mTypeFilter); +} + +void LLFloaterMyEnvironment::onSelectionChange() +{ + refreshButtonStates(); +} + +void LLFloaterMyEnvironment::onDeleteSelected() +{ + uuid_vec_t selected; + + getSelectedIds(selected); + if (selected.empty()) + return; + + const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); + for (const LLUUID& itemid: selected) + { + LLInventoryItem* inv_item = gInventory.getItem(itemid); + + if (inv_item && inv_item->getInventoryType() == LLInventoryType::IT_SETTINGS) + { + LLInventoryModel::update_list_t update; + LLInventoryModel::LLCategoryUpdate old_folder(inv_item->getParentUUID(), -1); + update.push_back(old_folder); + LLInventoryModel::LLCategoryUpdate new_folder(trash_id, 1); + update.push_back(new_folder); + gInventory.accountForUpdate(update); + + LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(inv_item); + new_item->setParent(trash_id); + new_item->updateParentOnServer(FALSE); + gInventory.updateItem(new_item); + } + } + gInventory.notifyObservers(); +} + + +void LLFloaterMyEnvironment::onDoCreate(const LLSD &data) +{ + menu_create_inventory_item(mInventoryList, NULL, data); +} + +void LLFloaterMyEnvironment::onDoApply(const std::string &context) +{ + uuid_vec_t selected; + getSelectedIds(selected); + + if (selected.size() != 1) // Exactly one item selected. + return; + + LLUUID item_id(selected.front()); + + LLInventoryItem* itemp = gInventory.getItem(item_id); + + if (itemp && itemp->getInventoryType() == LLInventoryType::IT_SETTINGS) + { + LLUUID asset_id = itemp->getAssetUUID(); + std::string name = itemp->getName(); + + if (context == PARAMETER_REGION) + { + LLEnvironment::instance().updateRegion(asset_id, name, LLEnvironment::NO_TRACK, -1, -1); + LLEnvironment::instance().setSharedEnvironment(); + } + else if (context == PARAMETER_PARCEL) + { + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + if (!parcel) + { + LL_WARNS("ENVIRONMENT") << "Unable to determine parcel." << LL_ENDL; + return; + } + LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, LLEnvironment::NO_TRACK, -1, -1); + LLEnvironment::instance().setSharedEnvironment(); + } + else if (context == PARAMETER_LOCAL) + { + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, asset_id); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + } + } +} + +bool LLFloaterMyEnvironment::canAction(const std::string &context) +{ + uuid_vec_t selected; + getSelectedIds(selected); + + if (selected.empty()) + return false; + + if (context == PARAMETER_EDIT) + { + return (selected.size() == 1) && isSettingSelected(selected.front()); + } + else if (context == PARAMETER_COPY) + { + for (std::vector<LLUUID>::iterator it = selected.begin(); it != selected.end(); it++) + { + if(!isSettingSelected(*it)) + { + return false; + } + } + return true; + } + else if (context == PARAMETER_PASTE) + { + if (!LLClipboard::instance().hasContents()) + return false; + + std::vector<LLUUID> ids; + LLClipboard::instance().pasteFromClipboard(ids); + for (std::vector<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++) + { + if (!isSettingSelected(*it)) + { + return false; + } + } + return (selected.size() == 1); + } + else if (context == PARAMETER_COPYUUID) + { + return (selected.size() == 1) && isSettingSelected(selected.front()); + } + + return false; +} + +bool LLFloaterMyEnvironment::canApply(const std::string &context) +{ + uuid_vec_t selected; + getSelectedIds(selected); + + if (selected.size() != 1) // Exactly one item selected. + return false; + + if (context == PARAMETER_REGION) + { + return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); + } + else if (context == PARAMETER_PARCEL) + { + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); + } + else + { + return (context == PARAMETER_LOCAL); + } +} + +//------------------------------------------------------------------------- +void LLFloaterMyEnvironment::refreshButtonStates() +{ + bool settings_ok = LLEnvironment::instance().isInventoryEnabled(); + + uuid_vec_t selected; + getSelectedIds(selected); + + getChild<LLUICtrl>(BUTTON_GEAR)->setEnabled(settings_ok); + getChild<LLUICtrl>(BUTTON_NEWSETTINGS)->setEnabled(true); + getChild<LLUICtrl>(BUTTON_DELETE)->setEnabled(settings_ok && !selected.empty()); +} + +//------------------------------------------------------------------------- +LLUUID LLFloaterMyEnvironment::findItemByAssetId(LLUUID asset_id, bool copyable_only, bool ignore_library) +{ + /*TODO: Rider: Move this to gInventory? */ + + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(asset_id); + + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::INCLUDE_TRASH, + asset_id_matches); + + if (!items.empty()) + { + // search for copyable version first + for (auto & item : items) + { + const LLPermissions& item_permissions = item->getPermissions(); + if (item_permissions.allowCopyBy(gAgent.getID(), gAgent.getGroupID())) + { + if(!ignore_library || !gInventory.isObjectDescendentOf(item->getUUID(),gInventory.getLibraryRootFolderID())) + { + return item->getUUID(); + } + } + } + // otherwise just return first instance, unless copyable requested + if (copyable_only) + { + return LLUUID::null; + } + else + { + if(!ignore_library || !gInventory.isObjectDescendentOf(items[0]->getUUID(),gInventory.getLibraryRootFolderID())) + { + return items[0]->getUUID(); + } + } + } + + return LLUUID::null; +} + +bool LLFloaterMyEnvironment::isSettingSelected(LLUUID item_id) +{ + LLInventoryItem* itemp = gInventory.getItem(item_id); + + if (itemp && itemp->getInventoryType() == LLInventoryType::IT_SETTINGS) + { + return true; + } + return false; +} + +void LLFloaterMyEnvironment::getSelectedIds(uuid_vec_t& ids) const +{ + LLInventoryPanel::selected_items_t items = mInventoryList->getSelectedItems(); + + for (auto itemview : items) + { + LLFolderViewModelItemInventory* itemp = static_cast<LLFolderViewModelItemInventory*>(itemview->getViewModelItem()); + ids.push_back(itemp->getUUID()); + } +} diff --git a/indra/newview/llfloatermyenvironment.h b/indra/newview/llfloatermyenvironment.h new file mode 100644 index 0000000000..10d64eaa93 --- /dev/null +++ b/indra/newview/llfloatermyenvironment.h @@ -0,0 +1,132 @@ +/** + * @file llfloatermyenvironment.h + * @brief Read-only list of gestures from your inventory. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/** + * (Also has legacy gesture editor for testing.) + */ + +#ifndef LL_LLFLOATERMYENVIRONMENT_H +#define LL_LLFLOATERMYENVIRONMENT_H +#include <vector> + +#include "llfloater.h" +#include "llinventoryobserver.h" +#include "llinventoryfilter.h" + +class LLView; +class LLButton; +class LLLineEditor; +class LLComboBox; +class LLViewerGesture; +class LLGestureOptions; +class LLMenuGL; +class LLInventoryPanel; + +class LLFloaterMyEnvironment +: public LLFloater, LLInventoryFetchDescendentsObserver +{ + LOG_CLASS(LLFloaterMyEnvironment); +public: + LLFloaterMyEnvironment(const LLSD& key); + virtual ~LLFloaterMyEnvironment(); + + virtual BOOL postBuild() override; + virtual void refresh() override; + + virtual void onOpen(const LLSD& key) override; + +private: + LLInventoryPanel * mInventoryList; + U64 mTypeFilter; + LLInventoryFilter::EFolderShow mShowFolders; + LLUUID mSelectedAsset; + + void onShowFoldersChange(); + void onFilterCheckChange(); + void onSelectionChange(); + void onDeleteSelected(); + void onDoCreate(const LLSD &data); + void onDoApply(const std::string &context); + bool canAction(const std::string &context); + bool canApply(const std::string &context); + + void getSelectedIds(uuid_vec_t& ids) const; + void refreshButtonStates(); + + bool isSettingSelected(LLUUID item_id); + + static LLUUID findItemByAssetId(LLUUID asset_id, bool copyable_only, bool ignore_library); + +#if 0 + virtual void done (); + void refreshAll(); + /** + * @brief Add new scrolllistitem into gesture_list. + * @param item_id inventory id of gesture + * @param gesture can be NULL , if item was not loaded yet + */ + void addGesture(const LLUUID& item_id, LLMultiGesture* gesture, LLCtrlListInterface * list); + +protected: + // Reads from the gesture manager's list of active gestures + // and puts them in this list. + void buildGestureList(); + void playGesture(LLUUID item_id); +private: + void addToCurrentOutFit(); + /** + * @brief This method is using to collect selected items. + * In some places gesture_list can be rebuilt by gestureObservers during iterating data from LLScrollListCtrl::getAllSelected(). + * Therefore we have to copy these items to avoid viewer crash. + * @see LLFloaterGesture::onActivateBtnClick + */ + void getSelectedIds(uuid_vec_t& ids); + bool isActionEnabled(const LLSD& command); + /** + * @brief Activation rules: + * According to Gesture Spec: + * 1. If all selected gestures are active: set to inactive + * 2. If all selected gestures are inactive: set to active + * 3. If selected gestures are in a mixed state: set all to active + */ + void onActivateBtnClick(); + void onClickEdit(); + void onClickPlay(); + void onClickNew(); + void onCommitList(); + void onCopyPasteAction(const LLSD& command); + void onDeleteSelected(); + + LLUUID mSelectedID; + LLUUID mGestureFolderID; + LLScrollListCtrl* mGestureList; + + LLFloaterGestureObserver* mObserver; +#endif +}; + + +#endif diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index c9a689281e..7cde061515 100644 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -161,7 +161,7 @@ void LLFloaterNameDesc::onBtnOK( ) { getChildView("ok_btn")->setEnabled(FALSE); // don't allow inadvertent extra uploads - LLAssetStorage::LLStoreAssetCallback callback = NULL; + LLAssetStorage::LLStoreAssetCallback callback; S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass). if (can_afford_transaction(expected_upload_cost)) @@ -169,7 +169,7 @@ void LLFloaterNameDesc::onBtnOK( ) void *nruserdata = NULL; std::string display_name = LLStringUtil::null; - LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLNewFileResourceUploadInfo>( mFilenameAndPath, getChild<LLUICtrl>("name_form")->getValue().asString(), getChild<LLUICtrl>("description_form")->getValue().asString(), 0, diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 2281ea1496..3968f43485 100644 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -121,7 +121,8 @@ const std::string LLFloaterPermsDefault::sCategoryNames[CAT_LAST] = "Scripts", "Notecards", "Gestures", - "Wearables" + "Wearables", + "Settings" }; BOOL LLFloaterPermsDefault::postBuild() diff --git a/indra/newview/llfloaterperms.h b/indra/newview/llfloaterperms.h index e866b6de7d..02359a256e 100644 --- a/indra/newview/llfloaterperms.h +++ b/indra/newview/llfloaterperms.h @@ -74,6 +74,7 @@ enum Categories CAT_NOTECARDS, CAT_GESTURES, CAT_WEARABLES, + CAT_SETTINGS, CAT_LAST }; diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index d63ee1b367..55796b1e7f 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -804,6 +804,17 @@ void LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable() refreshEnabledGraphics(); } +void LLFloaterPreferenceGraphicsAdvanced::onAdvancedAtmosphericsEnable() +{ + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->refresh(); + } + + refreshEnabledGraphics(); +} + void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledGraphics() { refreshEnabledState(); @@ -2740,7 +2751,7 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) : LLFloater(key) { - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); + mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this)); } diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 4e51137df5..e807038685 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -298,6 +298,7 @@ class LLFloaterPreferenceGraphicsAdvanced : public LLFloater void refresh(); // callback for when client turns on shaders void onVertexShaderEnable(); + void onAdvancedAtmosphericsEnable(); LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced); }; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index a0522c99c2..9f33feb901 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -52,8 +52,6 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" -#include "lldaycyclemanager.h" -#include "llenvmanager.h" #include "llestateinfomodel.h" #include "llfilepicker.h" #include "llfloatergodtools.h" // for send_sim_wide_deletes() @@ -87,7 +85,6 @@ #include "llviewertexteditor.h" #include "llviewerwindow.h" #include "llvlcomposition.h" -#include "llwaterparammanager.h" #include "lltrans.h" #include "llagentui.h" #include "llmeshrepository.h" @@ -98,6 +95,7 @@ #include "llexperiencecache.h" #include "llpanelexperiences.h" #include "llcorehttputil.h" +#include "llenvironment.h" const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -108,43 +106,6 @@ const S32 CORNER_COUNT = 4; /// Local class declaration ///---------------------------------------------------------------------------- -class LLDispatchEstateUpdateInfo : public LLDispatchHandler -{ -public: - LLDispatchEstateUpdateInfo() {} - virtual ~LLDispatchEstateUpdateInfo() {} - virtual bool operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings); -}; - -class LLDispatchSetEstateAccess : public LLDispatchHandler -{ -public: - LLDispatchSetEstateAccess() {} - virtual ~LLDispatchSetEstateAccess() {} - virtual bool operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings); -}; - -class LLDispatchSetEstateExperience : public LLDispatchHandler -{ -public: - virtual bool operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings); - - LLSD getIDs( sparam_t::const_iterator it, sparam_t::const_iterator end, S32 count ); -}; - - /* void unpack_request_params( LLMessageSystem* msg, @@ -178,6 +139,40 @@ void unpack_request_params( } */ +class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo +{ +public: + LLPanelRegionEnvironment(); + virtual ~LLPanelRegionEnvironment(); + + virtual void refresh() override; + + virtual bool isRegion() const override { return true; } + virtual LLParcel * getParcel() override { return nullptr; } + virtual bool canEdit() override { return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); } + virtual bool isLargeEnough() override { return true; } // regions are always large enough. + + bool refreshFromRegion(LLViewerRegion* region); + + virtual BOOL postBuild() override; + virtual void onOpen(const LLSD& key) override {}; + + virtual S32 getParcelId() override { return INVALID_PARCEL_ID; } + +protected: + static const U32 DIRTY_FLAG_OVERRIDE; + + virtual void refreshFromSource() override; + + bool confirmUpdateEstateEnvironment(const LLSD& notification, const LLSD& response); + + void onChkAllowOverride(bool value); + +private: + bool mAllowOverrideRestore; + connection_t mCommitConnect; +}; + bool estate_dispatch_initialized = false; @@ -187,12 +182,10 @@ bool estate_dispatch_initialized = false; /// LLFloaterRegionInfo ///---------------------------------------------------------------------------- -//S32 LLFloaterRegionInfo::sRequestSerial = 0; -LLUUID LLFloaterRegionInfo::sRequestInvoice; - - LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed) - : LLFloater(seed) + : LLFloater(seed), + mEnvironmentPanel(NULL), + mRegionChangedCallback() {} BOOL LLFloaterRegionInfo::postBuild() @@ -223,10 +216,10 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_terrain.xml"); mTab->addTabPanel(panel); - panel = new LLPanelEnvironmentInfo; - mInfoPanels.push_back(panel); - panel->buildFromFile("panel_region_environment.xml"); - mTab->addTabPanel(panel); + mEnvironmentPanel = new LLPanelRegionEnvironment; + mEnvironmentPanel->buildFromFile("panel_region_environment.xml"); +// mEnvironmentPanel->configureForRegion(); + mTab->addTabPanel(mEnvironmentPanel); panel = new LLPanelRegionDebugInfo; mInfoPanels.push_back(panel); @@ -245,19 +238,20 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_experiences.xml"); mTab->addTabPanel(panel); } - - gMessageSystem->setHandlerFunc( - "EstateOwnerMessage", - &processEstateOwnerRequest); // Request region info when agent region changes. - gAgent.addRegionChangedCallback(boost::bind(&LLFloaterRegionInfo::requestRegionInfo, this)); + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLFloaterRegionInfo::onRegionChanged, this)); return TRUE; } LLFloaterRegionInfo::~LLFloaterRegionInfo() -{} +{ + if (mRegionChangedCallback.connected()) + { + mRegionChangedCallback.disconnect(); + } +} void LLFloaterRegionInfo::onOpen(const LLSD& key) { @@ -266,20 +260,29 @@ void LLFloaterRegionInfo::onOpen(const LLSD& key) disableTabCtrls(); return; } - refreshFromRegion(gAgent.getRegion()); - requestRegionInfo(); + LLEstateInfoModel::instance().clearRegion(); + requestRegionInfo(); // will cause refreshFromRegion() requestMeshRezInfo(); } -// static -void LLFloaterRegionInfo::requestRegionInfo() +void LLFloaterRegionInfo::onRegionChanged() { - LLTabContainer* tab = getChild<LLTabContainer>("region_panels"); + if (getVisible()) //otherwise onOpen will do request + { + requestRegionInfo(); + } +} - tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE); - tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE); - tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE); - tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE); +void LLFloaterRegionInfo::requestRegionInfo() +{ + LLTabContainer* tab = findChild<LLTabContainer>("region_panels"); + if (tab) + { + tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE); + tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE); + tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE); + tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE); + } // Must allow anyone to request the RegionInfo data // so non-owners/non-gods can see the values. @@ -293,42 +296,6 @@ void LLFloaterRegionInfo::requestRegionInfo() } // static -void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) -{ - static LLDispatcher dispatch; - LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info"); - if(!floater) - { - return; - } - - if (!estate_dispatch_initialized) - { - LLPanelEstateInfo::initDispatch(dispatch); - } - - LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); - LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); - - // unpack the message - std::string request; - LLUUID invoice; - LLDispatcher::sparam_t strings; - LLDispatcher::unpackMessage(msg, request, invoice, strings); - if(invoice != getLastInvoice()) - { - LL_WARNS() << "Mismatched Estate message: " << request << LL_ENDL; - return; - } - - //dispatch the message - dispatch.dispatch(request, invoice, strings); - - panel->updateControls(gAgent.getRegion()); -} - - -// static void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { LLPanel* panel; @@ -337,13 +304,13 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { return; } - +#if 0 // We need to re-request environment setting here, // otherwise after we apply (send) updated region settings we won't get them back, // so our environment won't be updated. // This is also the way to know about externally changed region environment. LLEnvManagerNew::instance().requestRegionSettings(); - +#endif LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); LLViewerRegion* region = gAgent.getRegion(); @@ -450,7 +417,12 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) panel->setCtrlsEnabled(allow_modify); - floater->refreshFromRegion( gAgent.getRegion() ); + if (floater->getVisible()) + { + // Note: region info also causes LLRegionInfoModel::instance().update(msg); -> requestRegion(); -> changed message + // we need to know env version here and in update(msg) to know when to request and when not to, when to filter 'changed' + floater->refreshFromRegion(gAgent.getRegion()); + } // else will rerequest on onOpen either way } // static @@ -543,6 +515,7 @@ void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region) std::mem_fun(&LLPanelRegionInfo::refreshFromRegion), #endif region)); + mEnvironmentPanel->refreshFromRegion(region); } // public @@ -553,6 +526,7 @@ void LLFloaterRegionInfo::refresh() { (*iter)->refresh(); } + mEnvironmentPanel->refresh(); } void LLFloaterRegionInfo::enableTopButtons() @@ -635,43 +609,10 @@ void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr) // virtual bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region) { - if (region) mHost = region->getHost(); + LLEstateInfoModel::instance().setRegion(region); return true; } -void LLPanelRegionInfo::sendEstateOwnerMessage( - LLMessageSystem* msg, - const std::string& request, - const LLUUID& invoice, - const strings_t& strings) -{ - LL_INFOS() << "Sending estate request '" << request << "'" << LL_ENDL; - msg->newMessage("EstateOwnerMessage"); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used - msg->nextBlock("MethodData"); - msg->addString("Method", request); - msg->addUUID("Invoice", invoice); - if(strings.empty()) - { - msg->nextBlock("ParamList"); - msg->addString("Parameter", NULL); - } - else - { - strings_t::const_iterator it = strings.begin(); - strings_t::const_iterator end = strings.end(); - for(; it != end; ++it) - { - msg->nextBlock("ParamList"); - msg->addString("Parameter", *it); - } - } - msg->sendReliable(mHost); -} - void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable) { LLView* button = findChildView(btn_name); @@ -805,8 +746,7 @@ void LLPanelRegionGeneralInfo::onKickCommit(const uuid_vec_t& ids) ids[0].toString(buffer); strings.push_back(strings_t::value_type(buffer)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("teleporthomeuser", strings); } } @@ -831,9 +771,8 @@ bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const L gAgent.getID().toString(buffer); strings.push_back(buffer); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); // historical message name - sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("teleporthomeallusers", strings); } return false; } @@ -872,8 +811,7 @@ bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const L LLAgentUI::buildFullname(name); strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("simulatormessage", strings); return false; } @@ -959,8 +897,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() buffer = llformat("%s", (getChild<LLUICtrl>("allow_parcel_changes_check")->getValue().asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("setregioninfo", strings); } // if we changed access levels, tell user about it @@ -1032,8 +969,7 @@ BOOL LLPanelRegionDebugInfo::sendUpdate() buffer = llformat("%s", (getChild<LLUICtrl>("disable_physics_check")->getValue().asBoolean() ? "Y" : "N")); strings.push_back(buffer); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("setregiondebug", strings); return TRUE; } @@ -1103,9 +1039,7 @@ bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD strings.push_back(llformat("%d", flags)); strings.push_back(target_avatar.asString()); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - - sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("estateobjectreturn", strings); } else { @@ -1123,7 +1057,6 @@ void LLPanelRegionDebugInfo::onClickTopColliders(void* data) LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; strings_t strings; strings.push_back("1"); // one physics step - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects"); if(!instance) return; LLFloaterReg::showInstance("top_objects"); @@ -1133,7 +1066,7 @@ void LLPanelRegionDebugInfo::onClickTopColliders(void* data) self->getChildView("top_colliders_btn")->setEnabled(false); self->getChildView("top_scripts_btn")->setEnabled(false); - self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("colliders", strings); } // static @@ -1142,7 +1075,6 @@ void LLPanelRegionDebugInfo::onClickTopScripts(void* data) LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; strings_t strings; strings.push_back("6"); // top 5 scripts - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects"); if(!instance) return; LLFloaterReg::showInstance("top_objects"); @@ -1152,7 +1084,7 @@ void LLPanelRegionDebugInfo::onClickTopScripts(void* data) self->getChildView("top_colliders_btn")->setEnabled(false); self->getChildView("top_scripts_btn")->setEnabled(false); - self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("scripts", strings); } // static @@ -1169,19 +1101,16 @@ bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLS strings_t strings; strings.push_back("120"); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("restart", strings); return false; } // static void LLPanelRegionDebugInfo::onClickCancelRestart(void* data) { - LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; strings_t strings; strings.push_back("-1"); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("restart", strings); } // static @@ -1346,7 +1275,6 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() LL_INFOS() << "LLPanelRegionTerrainInfo::sendUpdate" << LL_ENDL; std::string buffer; strings_t strings; - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); // update the model LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); @@ -1355,7 +1283,7 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() region_info.mTerrainLowerLimit = (F32) getChild<LLUICtrl>("terrain_lower_spin")->getValue().asReal(); // and sync the region with it - region_info.sendRegionTerrain(invoice); + region_info.sendRegionTerrain(LLEstateInfoModel::instance().getLastInvoice()); // ======================================= // Assemble and send texturedetail message @@ -1383,7 +1311,6 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() LLTextureCtrl* texture_ctrl; std::string id_str; - LLMessageSystem* msg = gMessageSystem; for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { @@ -1397,7 +1324,7 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() strings.push_back(buffer); } } - sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("texturedetail", strings); strings.clear(); // ======================================== @@ -1410,13 +1337,13 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() std::string buffer3 = llformat("%d %f %f", i, (F32)getChild<LLUICtrl>(buffer)->getValue().asReal(), (F32)getChild<LLUICtrl>(buffer2)->getValue().asReal()); strings.push_back(buffer3); } - sendEstateOwnerMessage(msg, "textureheights", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("textureheights", strings); strings.clear(); // ======================================== // Send texturecommit message - sendEstateOwnerMessage(msg, "texturecommit", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("texturecommit", strings); return TRUE; } @@ -1456,12 +1383,10 @@ void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data) std::string filepath = picker.getFirstFile(); gXferManager->expectFileForRequest(filepath); - LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; strings_t strings; strings.push_back("download filename"); strings.push_back(filepath); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("terrain", strings); } // static @@ -1476,12 +1401,10 @@ void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data) std::string filepath = picker.getFirstFile(); gXferManager->expectFileForTransfer(filepath); - LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; strings_t strings; strings.push_back("upload filename"); strings.push_back(filepath); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("terrain", strings); LLNotificationsUtil::add("RawUploadStarted"); } @@ -1499,8 +1422,7 @@ bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, con strings_t strings; strings.push_back("bake"); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("terrain", strings); return false; } @@ -1514,33 +1436,11 @@ LLPanelEstateInfo::LLPanelEstateInfo() mEstateID(0) // invalid { LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + estate_info.setCommitCallback(boost::bind(&LLPanelEstateInfo::refreshFromEstate, this)); estate_info.setUpdateCallback(boost::bind(&LLPanelEstateInfo::refreshFromEstate, this)); -} - -// static -void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch) -{ - std::string name; - -// name.assign("setowner"); -// static LLDispatchSetEstateOwner set_owner; -// dispatch.addHandler(name, &set_owner); - name.assign("estateupdateinfo"); - static LLDispatchEstateUpdateInfo estate_update_info; - dispatch.addHandler(name, &estate_update_info); - - name.assign("setaccess"); - static LLDispatchSetEstateAccess set_access; - dispatch.addHandler(name, &set_access); - - - name.assign("setexperience"); - static LLDispatchSetEstateExperience set_experience; - dispatch.addHandler(name, &set_experience); - - estate_dispatch_initialized = true; + estate_info.setUpdateAccessCallback(boost::bind(&LLPanelEstateInfo::refreshAccessFromEstate, this, _1)); } //--------------------------------------------------------------------------- @@ -1703,7 +1603,7 @@ bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& re strings_t strings; strings.push_back(notification["payload"]["agent_id"].asString()); - sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("kickestate", strings); break; } default: @@ -2100,7 +2000,7 @@ void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_ msg->nextBlock("MethodData"); msg->addString("Method", "estateaccessdelta"); - msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); + msg->addUUID("Invoice", LLEstateInfoModel::instance().getLastInvoice()); std::string buf; gAgent.getID().toString(buf); @@ -2203,16 +2103,13 @@ bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region) strings_t strings; //integers_t integers; //LLFloaterRegionInfo::incrementSerial(); - LLFloaterRegionInfo::nextInvoice(); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate(); LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); panel->clearAccessLists(); - - sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings); + LLEstateInfoModel::instance().setRegion(region); refresh(); @@ -2331,6 +2228,147 @@ void LLPanelEstateInfo::refreshFromEstate() refresh(); } + +void LLPanelEstateInfo::refreshAccessFromEstate(U32 flags) +{ + const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + // grab the UUID's out of the string fields + if (flags & ESTATE_ACCESS_ALLOWED_AGENTS) + { + LLNameListCtrl *allowed_agent_name_list(getChild<LLNameListCtrl>("allowed_avatar_name_list")); + + const uuid_set_t& allowed_agents(estate_info.getAllowedAgents()); + int totalAllowedAgents = allowed_agents.size(); + + if (allowed_agent_name_list) + { + totalAllowedAgents += allowed_agent_name_list->getItemCount(); + } + + LLStringUtil::format_map_t args; + args["[ALLOWEDAGENTS]"] = llformat("%d", totalAllowedAgents); + args["[MAXACCESS]"] = llformat("%d", ESTATE_MAX_ACCESS_IDS); + std::string msg = LLTrans::getString("RegionInfoAllowedResidents", args); + getChild<LLUICtrl>("allow_resident_label")->setValue(LLSD(msg)); + + if (allowed_agent_name_list) + { + // Don't sort these as we add them, sort them when we are done. + allowed_agent_name_list->clearSortOrder(); + allowed_agent_name_list->deleteAllItems(); + + for (const LLUUID &id : allowed_agents) + { + allowed_agent_name_list->addNameItem(id); + } + allowed_agent_name_list->sortByName(TRUE); + } + } + + if (flags & ESTATE_ACCESS_ALLOWED_GROUPS) + { + LLNameListCtrl* allowed_group_name_list(getChild<LLNameListCtrl>("allowed_group_name_list")); + const uuid_set_t &allowed_groups(estate_info.getAllowedGroups()); + + LLStringUtil::format_map_t args; + args["[ALLOWEDGROUPS]"] = llformat("%d", allowed_groups.size()); + args["[MAXACCESS]"] = llformat("%d", ESTATE_MAX_GROUP_IDS); + std::string msg = LLTrans::getString("RegionInfoAllowedGroups", args); + getChild<LLUICtrl>("allow_group_label")->setValue(LLSD(msg)); + + if (allowed_group_name_list) + { + // Don't sort these as we add them, sort them when we are done. + allowed_group_name_list->clearSortOrder(); + allowed_group_name_list->deleteAllItems(); + + for (const LLUUID &id: allowed_groups) + { + allowed_group_name_list->addGroupNameItem(id); + } + allowed_group_name_list->sortByName(TRUE); + } + } + + if (flags & ESTATE_ACCESS_BANNED_AGENTS) + { + LLNameListCtrl* banned_agent_name_list(getChild<LLNameListCtrl>("banned_avatar_name_list")); + const uuid_set_t &banned_agents(estate_info.getBannedAgents()); + int totalBannedAgents = banned_agents.size(); + + if (banned_agent_name_list) + { + totalBannedAgents += banned_agent_name_list->getItemCount(); + } + + + LLStringUtil::format_map_t args; + args["[BANNEDAGENTS]"] = llformat("%d", totalBannedAgents); + args["[MAXBANNED]"] = llformat("%d", ESTATE_MAX_ACCESS_IDS); + std::string msg = LLTrans::getString("RegionInfoBannedResidents", args); + getChild<LLUICtrl>("ban_resident_label")->setValue(LLSD(msg)); + + if (banned_agent_name_list) + { + // Don't sort these as we add them, sort them when we are done. + banned_agent_name_list->clearSortOrder(); + + for (const LLUUID &id: banned_agents) + { + banned_agent_name_list->addNameItem(id); + } + banned_agent_name_list->sortByName(TRUE); + } + } + + if (flags & ESTATE_ACCESS_MANAGERS) + { + LLNameListCtrl* estate_manager_name_list(getChild<LLNameListCtrl>("estate_manager_name_list")); + const uuid_set_t &estate_mgrs(estate_info.getEstateManagers()); + + LLStringUtil::format_map_t args; + args["[ESTATEMANAGERS]"] = llformat("%d", estate_mgrs.size()); + args["[MAXMANAGERS]"] = llformat("%d", ESTATE_MAX_MANAGERS); + std::string msg = LLTrans::getString("RegionInfoEstateManagers", args); + getChild<LLUICtrl>("estate_manager_label")->setValue(LLSD(msg)); + + if (estate_manager_name_list) + { + // Don't sort these as we add them, sort them when we are done. + estate_manager_name_list->clearSortOrder(); + estate_manager_name_list->deleteAllItems(); // Clear existing entries + + // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't + // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, + // and they can still remove them. + for (const LLUUID &id : estate_mgrs) + { + estate_manager_name_list->addNameItem(id); + } + estate_manager_name_list->sortByName(TRUE); + } + } + + // Update the buttons which may change based on the list contents but also needs to account for general access features. + updateControls(gAgent.getRegion()); +} + + +namespace +{ + LLSD set_to_llsdarray(const uuid_set_t &values) + { + LLSD result(LLSD::emptyArray()); + + for (const LLUUID &id : values) + { + result.append(id); + } + return result; + } +} + BOOL LLPanelEstateInfo::sendUpdate() { LL_INFOS() << "LLPanelEsateInfo::sendUpdate()" << LL_ENDL; @@ -2368,8 +2406,6 @@ bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, con estate_info.setDenyAgeUnverified(getChild<LLUICtrl>("limit_age_verified")->getValue().asBoolean()); estate_info.setAllowVoiceChat(getChild<LLUICtrl>("voice_chat_check")->getValue().asBoolean()); estate_info.setAllowAccessOverride(getChild<LLUICtrl>("parcel_access_override")->getValue().asBoolean()); - // JIGGLYPUFF - //estate_info.setAllowAccessOverride(getChild<LLUICtrl>("")->getValue().asBoolean()); // send the update to sim estate_info.sendEstateInfo(); } @@ -2465,8 +2501,8 @@ bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& re LLAgentUI::buildFullname(name); strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings); + + LLEstateInfoModel::instance().sendEstateOwnerMessage("instantmessage", strings); return false; } @@ -2751,7 +2787,7 @@ void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id) msg->nextBlock("MethodData"); msg->addString("Method", "estatechangecovenantid"); - msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); + msg->addUUID("Invoice", LLEstateInfoModel::instance().getLastInvoice()); msg->nextBlock("ParamList"); msg->addString("Parameter", getCovenantID().asString()); @@ -2831,859 +2867,6 @@ void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text) mEditor->setText(text); } -// key = "estateupdateinfo" -// strings[0] = estate name -// strings[1] = str(owner_id) -// strings[2] = str(estate_id) -// strings[3] = str(estate_flags) -// strings[4] = str((S32)(sun_hour * 1024)) -// strings[5] = str(parent_estate_id) -// strings[6] = str(covenant_id) -// strings[7] = str(covenant_timestamp) -// strings[8] = str(send_to_agent_only) -// strings[9] = str(abuse_email_addr) -bool LLDispatchEstateUpdateInfo::operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings) -{ - LL_DEBUGS() << "Received estate update" << LL_ENDL; - - // Update estate info model. - // This will call LLPanelEstateInfo::refreshFromEstate(). - // *TODO: Move estate message handling stuff to llestateinfomodel.cpp. - LLEstateInfoModel::instance().update(strings); - - return true; -} - - -// key = "setaccess" -// strings[0] = str(estate_id) -// strings[1] = str(packed_access_lists) -// strings[2] = str(num allowed agent ids) -// strings[3] = str(num allowed group ids) -// strings[4] = str(num banned agent ids) -// strings[5] = str(num estate manager agent ids) -// strings[6] = bin(uuid) -// strings[7] = bin(uuid) -// strings[8] = bin(uuid) -// ... -bool LLDispatchSetEstateAccess::operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings) -{ - LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); - if (!panel) return true; - - S32 index = 1; // skip estate_id - U32 access_flags = strtoul(strings[index++].c_str(), NULL,10); - S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10); - S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10); - S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10); - S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10); - - // sanity ckecks - if (num_allowed_agents > 0 - && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)) - { - LL_WARNS() << "non-zero count for allowed agents, but no corresponding flag" << LL_ENDL; - } - if (num_allowed_groups > 0 - && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)) - { - LL_WARNS() << "non-zero count for allowed groups, but no corresponding flag" << LL_ENDL; - } - if (num_banned_agents > 0 - && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS)) - { - LL_WARNS() << "non-zero count for banned agents, but no corresponding flag" << LL_ENDL; - } - if (num_estate_managers > 0 - && !(access_flags & ESTATE_ACCESS_MANAGERS)) - { - LL_WARNS() << "non-zero count for managers, but no corresponding flag" << LL_ENDL; - } - - // grab the UUID's out of the string fields - if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS) - { - LLNameListCtrl* allowed_agent_name_list; - allowed_agent_name_list = panel->getChild<LLNameListCtrl>("allowed_avatar_name_list"); - - int totalAllowedAgents = num_allowed_agents; - - if (allowed_agent_name_list) - { - totalAllowedAgents += allowed_agent_name_list->getItemCount(); - } - - LLStringUtil::format_map_t args; - args["[ALLOWEDAGENTS]"] = llformat ("%d", totalAllowedAgents); - args["[MAXACCESS]"] = llformat ("%d", ESTATE_MAX_ACCESS_IDS); - std::string msg = LLTrans::getString("RegionInfoAllowedResidents", args); - panel->getChild<LLUICtrl>("allow_resident_label")->setValue(LLSD(msg)); - - if (allowed_agent_name_list) - { - // Don't sort these as we add them, sort them when we are done. - allowed_agent_name_list->clearSortOrder(); - for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - allowed_agent_name_list->addNameItem(id); - } - allowed_agent_name_list->sortByName(TRUE); - } - } - - if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS) - { - LLNameListCtrl* allowed_group_name_list; - allowed_group_name_list = panel->getChild<LLNameListCtrl>("allowed_group_name_list"); - - LLStringUtil::format_map_t args; - args["[ALLOWEDGROUPS]"] = llformat ("%d", num_allowed_groups); - args["[MAXACCESS]"] = llformat ("%d", ESTATE_MAX_GROUP_IDS); - std::string msg = LLTrans::getString("RegionInfoAllowedGroups", args); - panel->getChild<LLUICtrl>("allow_group_label")->setValue(LLSD(msg)); - - if (allowed_group_name_list) - { - // Don't sort these as we add them, sort them when we are done. - allowed_group_name_list->clearSortOrder(); - allowed_group_name_list->deleteAllItems(); - for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - allowed_group_name_list->addGroupNameItem(id); - } - allowed_group_name_list->sortByName(TRUE); - } - } - - if (access_flags & ESTATE_ACCESS_BANNED_AGENTS) - { - LLNameListCtrl* banned_agent_name_list; - banned_agent_name_list = panel->getChild<LLNameListCtrl>("banned_avatar_name_list"); - - int totalBannedAgents = num_banned_agents; - - if (banned_agent_name_list) - { - totalBannedAgents += banned_agent_name_list->getItemCount(); - } - - - LLStringUtil::format_map_t args; - args["[BANNEDAGENTS]"] = llformat("%d", totalBannedAgents); - args["[MAXBANNED]"] = llformat("%d", ESTATE_MAX_ACCESS_IDS); - std::string msg = LLTrans::getString("RegionInfoBannedResidents", args); - panel->getChild<LLUICtrl>("ban_resident_label")->setValue(LLSD(msg)); - - if (banned_agent_name_list) - { - // Don't sort these as we add them, sort them when we are done. - banned_agent_name_list->clearSortOrder(); - - for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - banned_agent_name_list->addNameItem(id); - } - banned_agent_name_list->sortByName(TRUE); - } - } - - if (access_flags & ESTATE_ACCESS_MANAGERS) - { - LLStringUtil::format_map_t args; - args["[ESTATEMANAGERS]"] = llformat("%d", num_estate_managers); - args["[MAXMANAGERS]"] = llformat("%d", ESTATE_MAX_MANAGERS); - std::string msg = LLTrans::getString("RegionInfoEstateManagers", args); - panel->getChild<LLUICtrl>("estate_manager_label")->setValue(LLSD(msg)); - - LLNameListCtrl* estate_manager_name_list = - panel->getChild<LLNameListCtrl>("estate_manager_name_list"); - if (estate_manager_name_list) - { - // Don't sort these as we add them, sort them when we are done. - estate_manager_name_list->clearSortOrder(); - - estate_manager_name_list->deleteAllItems(); // Clear existing entries - - // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't - // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, - // and they can still remove them. - for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - estate_manager_name_list->addNameItem(id); - } - estate_manager_name_list->sortByName(TRUE); - } - } - - // Update the buttons which may change based on the list contents but also needs to account for general access features. - panel->updateControls(gAgent.getRegion()); - - return true; -} - -LLSD LLDispatchSetEstateExperience::getIDs( sparam_t::const_iterator it, sparam_t::const_iterator end, S32 count ) -{ - LLSD idList = LLSD::emptyArray(); - LLUUID id; - while(count--> 0) - { - memcpy(id.mData, (*(it++)).data(), UUID_BYTES); - idList.append(id); - } - return idList; -} - -// key = "setexperience" -// strings[0] = str(estate_id) -// strings[1] = str(send_to_agent_only) -// strings[2] = str(num blocked) -// strings[3] = str(num trusted) -// strings[4] = str(num allowed) -// strings[8] = bin(uuid) ... -// ... -bool LLDispatchSetEstateExperience::operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings) -{ - LLPanelRegionExperiences* panel = LLFloaterRegionInfo::getPanelExperiences(); - if (!panel) return true; - - sparam_t::const_iterator it = strings.begin(); - ++it; // U32 estate_id = strtol((*it).c_str(), NULL, 10); - ++it; // U32 send_to_agent_only = strtoul((*(++it)).c_str(), NULL, 10); - - LLUUID id; - S32 num_blocked = strtol((*(it++)).c_str(), NULL, 10); - S32 num_trusted = strtol((*(it++)).c_str(), NULL, 10); - S32 num_allowed = strtol((*(it++)).c_str(), NULL, 10); - - LLSD ids = LLSD::emptyMap() - .with("blocked", getIDs(it, strings.end(), num_blocked)) - .with("trusted", getIDs(it + (num_blocked), strings.end(), num_trusted)) - .with("allowed", getIDs(it + (num_blocked+num_trusted), strings.end(), num_allowed)); - - panel->processResponse(ids); - - return true; -} - - - -LLPanelEnvironmentInfo::LLPanelEnvironmentInfo() -: mEnableEditing(false), - mRegionSettingsRadioGroup(NULL), - mDayCycleSettingsRadioGroup(NULL), - mWaterPresetCombo(NULL), - mSkyPresetCombo(NULL), - mDayCyclePresetCombo(NULL) -{ -} - -// virtual -BOOL LLPanelEnvironmentInfo::postBuild() -{ - mRegionSettingsRadioGroup = getChild<LLRadioGroup>("region_settings_radio_group"); - mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchRegionSettings, this)); - - mDayCycleSettingsRadioGroup = getChild<LLRadioGroup>("sky_dayc_settings_radio_group"); - mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this)); - - mWaterPresetCombo = getChild<LLComboBox>("water_settings_preset_combo"); - mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this)); - - mSkyPresetCombo = getChild<LLComboBox>("sky_settings_preset_combo"); - mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this)); - - mDayCyclePresetCombo = getChild<LLComboBox>("dayc_settings_preset_combo"); - mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); - - childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); - getChild<LLButton>("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); - childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); - getChild<LLButton>("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); - - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); - LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); - - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateWaterPresetsList, this)); - - return TRUE; -} - -// virtual -void LLPanelEnvironmentInfo::onOpen(const LLSD& key) -{ - LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL; - refresh(); -} - -// virtual -void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) -{ - // If hiding (user switched to another tab or closed the floater), - // display user's preferred environment. - if (!new_visibility) - { - LLEnvManagerNew::instance().usePrefs(); - } -} - -// virtual -bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) -{ - LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL; - BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); - BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - - // Don't refresh from region settings to avoid flicker after applying new region settings. - mEnableEditing = owner_or_god_or_manager; - setControlsEnabled(mEnableEditing); - - return LLPanelRegionInfo::refreshFromRegion(region); -} - -void LLPanelEnvironmentInfo::refresh() -{ - if(gDisconnected) - { - return; - } - - populateWaterPresetsList(); - populateSkyPresetsList(); - populateDayCyclesList(); - - // Init radio groups. - const LLEnvironmentSettings& settings = LLEnvManagerNew::instance().getRegionSettings(); - const LLSD& dc = settings.getWLDayCycle(); - LLSD::Real first_frame_time = dc.size() > 0 ? dc[0][0].asReal() : 0.0f; - const bool use_fixed_sky = dc.size() == 1 && first_frame_time < 0; - mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1); - mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); - - setControlsEnabled(mEnableEditing); - - setDirty(false); -} - -void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) -{ - mRegionSettingsRadioGroup->setEnabled(enabled); - mDayCycleSettingsRadioGroup->setEnabled(enabled); - - mWaterPresetCombo->setEnabled(enabled); - mSkyPresetCombo->setEnabled(enabled); - mDayCyclePresetCombo->setEnabled(enabled); - - getChildView("apply_btn")->setEnabled(enabled); - getChildView("cancel_btn")->setEnabled(enabled); - - if (enabled) - { - // Enable/disable some controls based on currently selected radio buttons. - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); - - bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - mSkyPresetCombo->setEnabled(is_fixed_sky); - mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - } -} - -void LLPanelEnvironmentInfo::setApplyProgress(bool started) -{ - LLLoadingIndicator* indicator = getChild<LLLoadingIndicator>("progress_indicator"); - - indicator->setVisible(started); - - if (started) - { - indicator->start(); - } - else - { - indicator->stop(); - } -} - -void LLPanelEnvironmentInfo::setDirty(bool dirty) -{ - getChildView("apply_btn")->setEnabled(dirty); - getChildView("cancel_btn")->setEnabled(dirty); -} - -void LLPanelEnvironmentInfo::sendRegionSunUpdate() -{ - LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); - - // If the region is being switched to fixed sky, - // change the region's sun hour according to the (fixed) sun position. - // This is needed for llGetSunDirection() LSL function to work properly (STORM-1330). - const LLSD& sky_map = mNewRegionSettings.getSkyMap(); - bool region_use_fixed_sky = sky_map.size() == 1; - if (region_use_fixed_sky) - { - LLWLParamSet param_set; - llassert(sky_map.isMap()); - param_set.setAll(sky_map.beginMap()->second); - F32 sun_angle = param_set.getSunAngle(); - - LL_DEBUGS("WindlightSync") << "Old sun hour: " << region_info.mSunHour << LL_ENDL; - // convert value range from 0..2pi to 6..30 - region_info.mSunHour = fmodf((sun_angle / F_TWO_PI) * 24.f, 24.f) + 6.f; - } - - region_info.setUseFixedSun(region_use_fixed_sky); - region_info.mUseEstateSun = !region_use_fixed_sky; - LL_DEBUGS("WindlightSync") << "Sun hour: " << region_info.mSunHour << LL_ENDL; - - region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); -} - -void LLPanelEnvironmentInfo::fixEstateSun() -{ - // We don't support fixed sun estates anymore and need to fix - // such estates for region day cycle to take effect. - // *NOTE: Assuming that current estate settings have arrived already. - LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); - if (estate_info.getUseFixedSun()) - { - LL_INFOS() << "Switching estate to global sun" << LL_ENDL; - estate_info.setUseFixedSun(false); - estate_info.sendEstateInfo(); - } -} - -void LLPanelEnvironmentInfo::populateWaterPresetsList() -{ - mWaterPresetCombo->removeall(); - - // If the region already has water params, add them to the list. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (region_settings.getWaterParams().size() != 0) - { - const std::string& region_name = gAgent.getRegion()->getName(); - mWaterPresetCombo->add(region_name, LLWLParamKey(region_name, LLEnvKey::SCOPE_REGION).toLLSD()); - mWaterPresetCombo->addSeparator(); - } - - std::list<std::string> user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); - - // Add local user presets first. - for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add local system presets. - for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - // There's no way to select current preset because its name is not stored on server. -} - -void LLPanelEnvironmentInfo::populateSkyPresetsList() -{ - mSkyPresetCombo->removeall(); - - LLWLParamManager::preset_name_list_t region_presets; - LLWLParamManager::preset_name_list_t user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - - // Add region presets. - std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); - for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) - { - std::string preset_name = *it; - std::string item_title = preset_name + " (" + region_name + ")"; - mSkyPresetCombo->add(item_title, LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); - } - - if (!region_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - if (!user_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - // Select current preset. - LLSD sky_map = LLEnvManagerNew::instance().getRegionSettings().getSkyMap(); - if (sky_map.size() == 1) // if the region is set to fixed sky - { - std::string preset_name = sky_map.beginMap()->first; - mSkyPresetCombo->selectByValue(LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); - } -} - -void LLPanelEnvironmentInfo::populateDayCyclesList() -{ - mDayCyclePresetCombo->removeall(); - - // If the region already has env. settings, add its day cycle to the list. - const LLSD& cur_region_dc = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); - if (cur_region_dc.size() != 0) - { - LLViewerRegion* region = gAgent.getRegion(); - llassert(region != NULL); - - LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION); - mDayCyclePresetCombo->add(region->getName(), key.toStringVal()); - mDayCyclePresetCombo->addSeparator(); - } - - // Add local user day cycles. - LLDayCycleManager::preset_name_list_t user_days, sys_days; - LLDayCycleManager::instance().getPresetNames(user_days, sys_days); - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - if (user_days.size() > 0) - { - mDayCyclePresetCombo->addSeparator(); - } - - // Add local system day cycles. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - // Current day cycle is already selected. -} - -bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) -{ - LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); - - if (water_key.scope == LLEnvKey::SCOPE_REGION) - { - water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); - } - else - { - LLWaterParamSet param_set; - if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) - { - LL_WARNS() << "Error getting water preset: " << water_key.name << LL_ENDL; - return false; - } - - water_params = param_set.getAll(); - } - - return true; -} - -bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name) -{ - std::string preset_key(mSkyPresetCombo->getValue().asString()); - LLWLParamKey preset(preset_key); - - // Get the preset sky params. - LLWLParamSet param_set; - if (!LLWLParamManager::instance().getParamSet(preset, param_set)) - { - LL_WARNS() << "Error getting sky params: " << preset.toLLSD() << LL_ENDL; - return false; - } - - sky_params = param_set.getAll(); - preset_name = preset.name; - return true; -} - -bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope) -{ - std::string preset_key(mDayCyclePresetCombo->getValue().asString()); - LLWLParamKey dc(preset_key); - LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; - - if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle - { - const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings(); - day_cycle = cur_region_settings.getWLDayCycle(); - sky_map = cur_region_settings.getSkyMap(); - } - else // a local day cycle - { - if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) - { - LL_WARNS() << "Error getting day cycle " << dc.name << LL_ENDL; - return false; - } - - // Create sky map from the day cycle. - { - LLWLDayCycle tmp_day; - tmp_day.loadDayCycle(day_cycle, dc.scope); - tmp_day.getSkyMap(sky_map); - } - } - - scope = dc.scope; - - return true; -} -void LLPanelEnvironmentInfo::onSwitchRegionSettings() -{ - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); - - if (use_defaults) - { - LLEnvManagerNew::instance().useDefaults(); - } - else - { - onSelectWaterPreset(); - onSwitchDayCycle(); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSwitchDayCycle() -{ - bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - - mSkyPresetCombo->setEnabled(is_fixed_sky); - mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - - if (is_fixed_sky) - { - onSelectSkyPreset(); - } - else - { - onSelectDayCycle(); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectWaterPreset() -{ - LLSD water_params; - - if (getSelectedWaterParams(water_params)) - { - LLEnvManagerNew::instance().useWaterParams(water_params); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectSkyPreset() -{ - LLSD params; - std::string dummy; - - if (getSelectedSkyParams(params, dummy)) - { - LLEnvManagerNew::instance().useSkyParams(params); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectDayCycle() -{ - LLSD day_cycle; - LLSD sky_map; // unused - short scope; - - if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) - { - LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onBtnApply() -{ - const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - - LLSD day_cycle; - LLSD sky_map; - LLSD water_params; - - if (use_defaults) - { - // settings will be empty - LL_DEBUGS("Windlight") << "Defaults" << LL_ENDL; - } - else // use custom region settings - { - if (use_fixed_sky) - { - LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; - - // Get selected sky params. - LLSD params; - std::string preset_name; - if (!getSelectedSkyParams(params, preset_name)) - { - return; - } - - // Create a day cycle consisting of a single sky preset. - LLSD key(LLSD::emptyArray()); - key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle - key.append(preset_name); - day_cycle.append(key); - - // Create a sky map consisting of only the sky preset. - std::map<LLWLParamKey, LLWLParamSet> refs; - LLWLParamSet param_set; - param_set.setAll(params); - refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here - sky_map = LLWLParamManager::createSkyMap(refs); - } - else // use day cycle - { - LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL; - - short scope; // unused - if (!getSelectedDayCycleParams(day_cycle, sky_map, scope)) - { - return; - } - - // If it's a special single-preset day cycle meaning using a fixed sky, - // reset the frame time to a non-negative value, - // so that the region setting is displayed in the floater as - // a day cycle, not a preset. (STORM-1289) - if (day_cycle.size() == 1 && day_cycle[0][0].asReal() < 0.0f) - { - LL_DEBUGS("Windlight") << "Fixing negative time" << LL_ENDL; - day_cycle[0][0] = 0.0f; - } - } - - // Get water params. - if (!getSelectedWaterParams(water_params)) - { - // *TODO: show a notification? - return; - } - } - - // Send settings apply request. - LLEnvironmentSettings new_region_settings; - new_region_settings.saveParams(day_cycle, sky_map, water_params, 0.0f); - if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings)) - { - LL_WARNS() << "Error applying region environment settings" << LL_ENDL; - return; - } - - // When the settings get applied, we'll also send the region sun position update. - // To determine the sun angle we're going to need the new settings. - mNewRegionSettings = new_region_settings; - - // Start spinning the progress indicator. - setApplyProgress(true); -} - -void LLPanelEnvironmentInfo::onBtnCancel() -{ - // Reload last saved region settings. - refresh(); - - // Apply them. - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings(); - const LLSD& region_day_cycle = cur_settings.getWLDayCycle(); - const LLSD& region_water = cur_settings.getWaterParams(); - env_mgr.useWaterParams(region_water); - env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION); -} - -void LLPanelEnvironmentInfo::onRegionSettingschange() -{ - LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; - refresh(); - - // Stop applying progress indicator (it may be running if it's us who initiated settings update). - setApplyProgress(false); -} - -void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) -{ - // If applying new settings has failed, stop the indicator right away. - // Otherwise it will be stopped when we receive the updated settings from server. - if (ok) - { - // Set the region sun phase/flags according to the chosen new preferences. - // - // If we do this earlier we may get jerky transition from fixed sky to a day cycle (STORM-1481). - // That is caused by the simulator re-sending the region info, which in turn makes us - // re-request and display old region environment settings while the new ones haven't been applied yet. - sendRegionSunUpdate(); - - // Switch estate to not using fixed sun for the region day cycle to work properly (STORM-1506). - fixEstateSun(); - } - else - { - setApplyProgress(false); - - // We need to re-request environment setting here, - // otherwise our subsequent attempts to change region settings will fail with the following error: - // "Unable to update environment settings because the last update your viewer saw was not the same - // as the last update sent from the simulator. Try sending your update again, and if this - // does not work, try leaving and returning to the region." - LLEnvManagerNew::instance().requestRegionSettings(); - } -} - BOOL LLPanelRegionExperiences::postBuild() { mAllowed = setupList("panel_allowed", ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE); @@ -3696,6 +2879,8 @@ BOOL LLPanelRegionExperiences::postBuild() getChild<LLTextBox>("allowed_text_help")->setText(getString("allowed_estate_text")); getChild<LLTextBox>("blocked_text_help")->setText(getString("blocked_estate_text")); + LLEstateInfoModel::instance().setUpdateExperienceCallback(boost::bind(&LLPanelRegionExperiences::refreshExperiencesFromEstate, this)); + return LLPanelRegionInfo::postBuild(); } @@ -3739,6 +2924,18 @@ void LLPanelRegionExperiences::processResponse( const LLSD& content ) } +void LLPanelRegionExperiences::refreshExperiencesFromEstate() +{ + const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + LLSD ids = LLSDMap("blocked", set_to_llsdarray(estate_info.getBlockedExperiences())) + ("trusted", set_to_llsdarray(estate_info.getTrustedExperiences())) + ("allowed", set_to_llsdarray(estate_info.getAllowedExperiences())); + + processResponse(ids); +} + + // Used for both access add and remove operations, depending on the flag // passed in (ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE, etc.) // static @@ -3801,11 +2998,7 @@ void LLPanelRegionExperiences::sendEstateExperienceDelta(U32 flags, const LLUUID str[1] = llformat("%u", flags); experience_id.toString(str[2]); - LLPanelRegionExperiences* panel = LLFloaterRegionInfo::getPanelExperiences(); - if (panel) - { - panel->sendEstateOwnerMessage(gMessageSystem, "estateexperiencedelta", LLFloaterRegionInfo::getLastInvoice(), str); - } + LLEstateInfoModel::instance().sendEstateOwnerMessage("estateexperiencedelta", str); } @@ -3942,3 +3135,142 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id ) onChangeAnything(); } + +//========================================================================= +const U32 LLPanelRegionEnvironment::DIRTY_FLAG_OVERRIDE(0x01 << 4); + +LLPanelRegionEnvironment::LLPanelRegionEnvironment(): + LLPanelEnvironmentInfo(), + mAllowOverrideRestore(false) +{ +} + +LLPanelRegionEnvironment::~LLPanelRegionEnvironment() +{ + if (mCommitConnect.connected()) + mCommitConnect.disconnect(); +} + +BOOL LLPanelRegionEnvironment::postBuild() +{ + LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + if (!LLPanelEnvironmentInfo::postBuild()) + return FALSE; + + getChild<LLUICtrl>(BTN_USEDEFAULT)->setLabelArg("[USEDEFAULT]", getString(STR_LABEL_USEDEFAULT)); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setVisible(TRUE); + getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(TRUE); + + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setCommitCallback([this](LLUICtrl *, const LLSD &value){ onChkAllowOverride(value.asBoolean()); }); + + mCommitConnect = estate_info.setCommitCallback(boost::bind(&LLPanelRegionEnvironment::refreshFromEstate, this)); + return TRUE; +} + + +void LLPanelRegionEnvironment::refresh() +{ + if (!mCurrentEnvironment) + { + if (mCurEnvVersion <= INVALID_PARCEL_ENVIRONMENT_VERSION) + { + refreshFromSource(); // will immediately set mCurEnvVersion + } // else - already requesting + return; + } + + LLPanelEnvironmentInfo::refresh(); + + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setValue(mAllowOverride); +} + +bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region) +{ + if (!region) + { + setNoSelection(true); + setControlsEnabled(false); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + } + setNoSelection(false); + + if (gAgent.getRegion()->getRegionID() != region->getRegionID()) + { + setCrossRegion(true); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + } + setCrossRegion(false); + + refreshFromSource(); + return true; +} + +void LLPanelRegionEnvironment::refreshFromSource() +{ + LL_DEBUGS("ENVIRONMENT") << "Requesting environment for region, known version " << mCurEnvVersion << LL_ENDL; + LLHandle<LLPanel> that_h = getHandle(); + + if (mCurEnvVersion < UNSET_PARCEL_ENVIRONMENT_VERSION) + { + // to mark as requesting + mCurEnvVersion = UNSET_PARCEL_ENVIRONMENT_VERSION; + } + + LLEnvironment::instance().requestRegion( + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + + setControlsEnabled(false); +} + +bool LLPanelRegionEnvironment::confirmUpdateEstateEnvironment(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + + switch (option) + { + case 0: + { + LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + // update model + estate_info.setAllowEnvironmentOverride(mAllowOverride); + // send the update to sim + estate_info.sendEstateInfo(); + clearDirtyFlag(DIRTY_FLAG_OVERRIDE); + } + break; + + case 1: + mAllowOverride = mAllowOverrideRestore; + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setValue(mAllowOverride); + break; + default: + break; + } + return false; +} + +void LLPanelRegionEnvironment::onChkAllowOverride(bool value) +{ + setDirtyFlag(DIRTY_FLAG_OVERRIDE); + mAllowOverrideRestore = mAllowOverride; + mAllowOverride = value; + + LLNotification::Params params("ChangeLindenEstate"); + params.functor.function([this](const LLSD& notification, const LLSD& response) { confirmUpdateEstateEnvironment(notification, response); }); + + std::string notification("EstateParcelEnvironmentOverride"); + if (LLPanelEstateInfo::isLindenEstate()) + notification = "ChangeLindenEstate"; + + if (!value || LLPanelEstateInfo::isLindenEstate()) + { // warn if turning off or a Linden Estate + LLNotifications::instance().add(params); + } + else + { + LLNotifications::instance().forceResponse(params, 0); + } + +} diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index c9d0e51640..e4687fff0c 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -34,8 +34,8 @@ #include "llhost.h" #include "llpanel.h" #include "llextendedstatus.h" +#include "llpanelenvironment.h" -#include "llenvmanager.h" // for LLEnvironmentSettings #include "lleventcoro.h" class LLAvatarName; @@ -64,13 +64,9 @@ class LLPanelEstateCovenant; class LLPanelExperienceListEditor; class LLPanelExperiences; class LLPanelRegionExperiences; +class LLPanelRegionEnvironment; class LLEventTimer; -class LLEnvironmentSettings; -class LLWLParamManager; -class LLWaterParamManager; -class LLWLParamSet; -class LLWaterParamSet; class LLFloaterRegionInfo : public LLFloater { @@ -81,13 +77,9 @@ public: /*virtual*/ void onOpen(const LLSD& key); /*virtual*/ BOOL postBuild(); - static void processEstateOwnerRequest(LLMessageSystem* msg, void**); - // get and process region info if necessary. static void processRegionInfo(LLMessageSystem* msg); - static const LLUUID& getLastInvoice() { return sRequestInvoice; } - static void nextInvoice() { sRequestInvoice.generate(); } //static S32 getSerial() { return sRequestSerial; } //static void incrementSerial() { sRequestSerial++; } @@ -100,6 +92,7 @@ public: // from LLPanel virtual void refresh(); + void onRegionChanged(); void requestRegionInfo(); void requestMeshRezInfo(); void enableTopButtons(); @@ -121,8 +114,10 @@ protected: LLTabContainer* mTab; typedef std::vector<LLPanelRegionInfo*> info_panels_t; info_panels_t mInfoPanels; - //static S32 sRequestSerial; // serial # of last EstateOwnerRequest - static LLUUID sRequestInvoice; + LLPanelRegionEnvironment *mEnvironmentPanel; + +private: + boost::signals2::connection mRegionChangedCallback; }; @@ -157,14 +152,6 @@ protected: typedef std::vector<std::string> strings_t; //typedef std::vector<U32> integers_t; - void sendEstateOwnerMessage( - LLMessageSystem* msg, - const std::string& request, - const LLUUID& invoice, - const strings_t& strings); - - // member data - LLHost mHost; }; ///////////////////////////////////////////////////////////////////////////// @@ -266,12 +253,9 @@ private: }; ///////////////////////////////////////////////////////////////////////////// - class LLPanelEstateInfo : public LLPanelRegionInfo { public: - static void initDispatch(LLDispatcher& dispatch); - void onChangeFixedSun(); void onChangeUseGlobalTime(); void onChangeAccessOverride(); @@ -331,6 +315,7 @@ public: virtual void refresh(); void refreshFromEstate(); + void refreshAccessFromEstate(U32 flags); static bool isLindenEstate(); @@ -415,69 +400,10 @@ protected: ///////////////////////////////////////////////////////////////////////////// -class LLPanelEnvironmentInfo : public LLPanelRegionInfo -{ - LOG_CLASS(LLPanelEnvironmentInfo); - -public: - LLPanelEnvironmentInfo(); - - // LLPanel - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); - - // LLView - /*virtual*/ void onVisibilityChange(BOOL new_visibility); - - // LLPanelRegionInfo - /*virtual*/ bool refreshFromRegion(LLViewerRegion* region); - -private: - void refresh(); - void setControlsEnabled(bool enabled); - void setApplyProgress(bool started); - void setDirty(bool dirty); - - void sendRegionSunUpdate(); - void fixEstateSun(); - - void populateWaterPresetsList(); - void populateSkyPresetsList(); - void populateDayCyclesList(); - - bool getSelectedWaterParams(LLSD& water_params); - bool getSelectedSkyParams(LLSD& sky_params, std::string& preset_name); - bool getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope); - - void onSwitchRegionSettings(); - void onSwitchDayCycle(); - - void onSelectWaterPreset(); - void onSelectSkyPreset(); - void onSelectDayCycle(); - - void onBtnApply(); - void onBtnCancel(); - - void onRegionSettingschange(); - void onRegionSettingsApplied(bool ok); - - /// New environment settings that are being applied to the region. - LLEnvironmentSettings mNewRegionSettings; - - bool mEnableEditing; - - LLRadioGroup* mRegionSettingsRadioGroup; - LLRadioGroup* mDayCycleSettingsRadioGroup; - - LLComboBox* mWaterPresetCombo; - LLComboBox* mSkyPresetCombo; - LLComboBox* mDayCyclePresetCombo; -}; class LLPanelRegionExperiences : public LLPanelRegionInfo { - LOG_CLASS(LLPanelEnvironmentInfo); + LOG_CLASS(LLPanelRegionExperiences); public: LLPanelRegionExperiences(){} @@ -492,7 +418,7 @@ public: void sendPurchaseRequest()const; void processResponse( const LLSD& content ); private: - void refreshRegionExperiences(); + void refreshExperiencesFromEstate(); static std::string regionCapabilityQuery(LLViewerRegion* region, const std::string &cap); diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp new file mode 100644 index 0000000000..48bfb85072 --- /dev/null +++ b/indra/newview/llflyoutcombobtn.cpp @@ -0,0 +1,162 @@ +/** + * @file llflyoutcombobtn.cpp + * @brief Represents outfit save/save as combo button. + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llflyoutcombobtn.h" +#include "llviewermenu.h" + +LLFlyoutComboBtnCtrl::LLFlyoutComboBtnCtrl(LLPanel* parent, + const std::string &action_button, + const std::string &flyout_button, + const std::string &menu_file, + bool apply_immediately) : + mParent(parent), + mActionButton(action_button), + mFlyoutButton(flyout_button), + mApplyImmediately(apply_immediately) +{ + // register action mapping before creating menu + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar save_registar; + save_registar.add("FlyoutCombo.Button.Action", [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutItemSelected(ctrl, data); }); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enabled_rgistar; + enabled_rgistar.add("FlyoutCombo.Button.Check", [this](LLUICtrl *ctrl, const LLSD &data) { return onFlyoutItemCheck(ctrl, data); }); + + mParent->childSetAction(flyout_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutButton(ctrl, data); }); + mParent->childSetAction(action_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutAction(ctrl, data); }); + + mFlyoutMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu> (menu_file, gMenuHolder, + LLViewerMenuHolderGL::child_registry_t::instance()); + + // select the first item in the list. + setSelectedItem(0); +} + +void LLFlyoutComboBtnCtrl::setAction(LLUICtrl::commit_callback_t cb) +{ + mActionSignal.connect(cb); +} + + +U32 LLFlyoutComboBtnCtrl::getItemCount() +{ + return mFlyoutMenu->getItemCount(); +} + +void LLFlyoutComboBtnCtrl::setSelectedItem(S32 itemno) +{ + LLMenuItemGL *pitem = mFlyoutMenu->getItem(itemno); + setSelectedItem(pitem); +} + +void LLFlyoutComboBtnCtrl::setSelectedItem(const std::string &item) +{ + LLMenuItemGL *pitem = mFlyoutMenu->getChild<LLMenuItemGL>(item, false); + setSelectedItem(pitem); +} + +void LLFlyoutComboBtnCtrl::setSelectedItem(LLMenuItemGL *pitem) +{ + if (!pitem) + { + LL_WARNS("INTERFACE") << "NULL item selected" << LL_ENDL; + return; + } + + mSelectedName = pitem->getName(); + + LLButton *action_button = mParent->getChild<LLButton>(mActionButton); + action_button->setEnabled(pitem->getEnabled()); + action_button->setLabel(pitem->getLabel()); +} + +void LLFlyoutComboBtnCtrl::setMenuItemEnabled(const std::string& item, bool enabled) +{ + mFlyoutMenu->setItemEnabled(item, enabled); + if (item == mSelectedName) + { + mParent->getChildView(mActionButton)->setEnabled(enabled); + } +} + +void LLFlyoutComboBtnCtrl::setShownBtnEnabled(bool enabled) +{ + mParent->getChildView(mActionButton)->setEnabled(enabled); +} + +void LLFlyoutComboBtnCtrl::setMenuItemVisible(const std::string &item, bool visible) +{ + mFlyoutMenu->setItemVisible(item, visible); +} + + +void LLFlyoutComboBtnCtrl::setMenuItemLabel(const std::string &item, const std::string &label) +{ + mFlyoutMenu->setItemLabel(item, label); +} + +void LLFlyoutComboBtnCtrl::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) +{ + S32 x, y; + LLUI::getMousePositionLocal(mParent, &x, &y); + + mFlyoutMenu->updateParent(LLMenuGL::sMenuContainer); + LLMenuGL::showPopup(mParent, mFlyoutMenu, x, y); +} + +void LLFlyoutComboBtnCtrl::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) +{ + LLMenuItemGL *pmenuitem = static_cast<LLMenuItemGL*>(ctrl); + setSelectedItem(pmenuitem); + + if (mApplyImmediately) + { + onFlyoutAction(pmenuitem, data); + } +} + +bool LLFlyoutComboBtnCtrl::onFlyoutItemCheck(LLUICtrl *ctrl, const LLSD &data) +{ + if (mApplyImmediately) + { + return false; + } + else + { + LLMenuItemGL *pmenuitem = static_cast<LLMenuItemGL*>(ctrl); + + return pmenuitem->getName() == mSelectedName; + } +} + +void LLFlyoutComboBtnCtrl::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) +{ + LLMenuItemGL *pmenuitem = mFlyoutMenu->getChild<LLMenuItemGL>(mSelectedName); + + if (!mActionSignal.empty()) + mActionSignal(pmenuitem, data); +} + diff --git a/indra/newview/llflyoutcombobtn.h b/indra/newview/llflyoutcombobtn.h new file mode 100644 index 0000000000..e41cd0cecb --- /dev/null +++ b/indra/newview/llflyoutcombobtn.h @@ -0,0 +1,76 @@ +/** + * @file llsaveoutfitcombobtn.h + * @brief Represents outfit save/save as combo button. + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLYOUTCOMBOBTN_H +#define LL_LLFLYOUTCOMBOBTN_H + +/*TODO: Make this button generic */ + +class LLButton; + +#include "lltoggleablemenu.h" + +class LLFlyoutComboBtnCtrl +{ + LOG_CLASS(LLFlyoutComboBtnCtrl); +public: + LLFlyoutComboBtnCtrl(LLPanel* parent, + const std::string &action_button, + const std::string &flyout_button, + const std::string &menu_file, + bool apply_immediately = true); + + void setMenuItemEnabled(const std::string &item, bool enabled); + void setShownBtnEnabled(bool enabled); + void setMenuItemVisible(const std::string &item, bool visible); + void setMenuItemLabel(const std::string &item, const std::string &label); + + U32 getItemCount(); + void setSelectedItem(S32 itemno); + void setSelectedItem(const std::string &item); + + void setAction(LLUICtrl::commit_callback_t cb); + +protected: + void onFlyoutButton(LLUICtrl *, const LLSD &); + void onFlyoutItemSelected(LLUICtrl *, const LLSD &); + bool onFlyoutItemCheck(LLUICtrl *, const LLSD &); + void onFlyoutAction(LLUICtrl *, const LLSD &); + + void setSelectedItem(LLMenuItemGL *pitem); + +private: + LLPanel * mParent; + LLToggleableMenu * mFlyoutMenu; + std::string mActionButton; + std::string mFlyoutButton; + + std::string mSelectedName; + bool mApplyImmediately; + + LLUICtrl::commit_signal_t mActionSignal; +}; +#endif // LL_LLFLYOUTCOMBOBTN_H diff --git a/indra/newview/llfolderviewmodelinventory.h b/indra/newview/llfolderviewmodelinventory.h index dea54cbe57..06a908cccc 100644 --- a/indra/newview/llfolderviewmodelinventory.h +++ b/indra/newview/llfolderviewmodelinventory.h @@ -49,8 +49,9 @@ public: virtual bool hasChildren() const = 0; virtual LLInventoryType::EType getInventoryType() const = 0; virtual void performAction(LLInventoryModel* model, std::string action) = 0; - virtual LLWearableType::EType getWearableType() const = 0; - virtual EInventorySortGroup getSortGroup() const = 0; + virtual LLWearableType::EType getWearableType() const = 0; + virtual LLSettingsType::type_e getSettingsType() const = 0; + virtual EInventorySortGroup getSortGroup() const = 0; virtual LLInventoryObject* getInventoryObject() const = 0; virtual void requestSort(); virtual void setPassedFilter(bool filtered, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0); diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp index 62cbea6401..0be748ace9 100644 --- a/indra/newview/llfriendcard.cpp +++ b/indra/newview/llfriendcard.cpp @@ -504,7 +504,7 @@ void LLFriendCardsManager::syncFriendsFolder() gAgentID.asString(), LLAssetType::AT_CALLINGCARD, LLInventoryType::IT_CALLINGCARD, - NOT_WEARABLE, + NO_INV_SUBTYPE, PERM_MOVE | PERM_TRANSFER, NULL); } diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index a9b15fc8b6..eb417106b6 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -44,6 +44,7 @@ #include "llviewercamera.h" #include "llvoavatarself.h" +#include "llsky.h" #include "llagent.h" #include "lltoolmgr.h" #include "llselectmgr.h" @@ -771,6 +772,16 @@ void draw_line_cube(F32 width, const LLVector3& center) gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width); } +void draw_cross_lines(const LLVector3& center, F32 dx, F32 dy, F32 dz) +{ + gGL.vertex3f(center.mV[VX] - dx, center.mV[VY], center.mV[VZ]); + gGL.vertex3f(center.mV[VX] + dx, center.mV[VY], center.mV[VZ]); + gGL.vertex3f(center.mV[VX], center.mV[VY] - dy, center.mV[VZ]); + gGL.vertex3f(center.mV[VX], center.mV[VY] + dy, center.mV[VZ]); + gGL.vertex3f(center.mV[VX], center.mV[VY], center.mV[VZ] - dz); + gGL.vertex3f(center.mV[VX], center.mV[VY], center.mV[VZ] + dz); +} + void LLViewerObjectList::renderObjectBeacons() { if (mDebugBeacons.empty()) @@ -808,13 +819,7 @@ void LLViewerObjectList::renderObjectBeacons() gGL.begin(LLRender::LINES); gGL.color4fv(color.mV); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 50.f); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 50.f); - gGL.vertex3f(thisline.mV[VX] - 2.f,thisline.mV[VY],thisline.mV[VZ]); - gGL.vertex3f(thisline.mV[VX] + 2.f,thisline.mV[VY],thisline.mV[VZ]); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] - 2.f,thisline.mV[VZ]); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] + 2.f,thisline.mV[VZ]); - + draw_cross_lines(thisline, 2.0f, 2.0f, 50.f); draw_line_cube(0.10f, thisline); gGL.end(); @@ -843,13 +848,7 @@ void LLViewerObjectList::renderObjectBeacons() const LLVector3 &thisline = debug_beacon.mPositionAgent; gGL.begin(LLRender::LINES); gGL.color4fv(debug_beacon.mColor.mV); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 0.5f); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 0.5f); - gGL.vertex3f(thisline.mV[VX] - 0.5f,thisline.mV[VY],thisline.mV[VZ]); - gGL.vertex3f(thisline.mV[VX] + 0.5f,thisline.mV[VY],thisline.mV[VZ]); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] - 0.5f,thisline.mV[VZ]); - gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] + 0.5f,thisline.mV[VZ]); - + draw_cross_lines(thisline, 0.5f, 0.5f, 0.5f); draw_line_cube(0.10f, thisline); gGL.end(); @@ -880,6 +879,34 @@ void LLViewerObjectList::renderObjectBeacons() } } +void LLSky::renderSunMoonBeacons(const LLVector3& pos_agent, const LLVector3& direction, LLColor4 color) +{ + LLGLSUIDefault gls_ui; + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + LLVector3 pos_end; + for (S32 i = 0; i < 3; ++i) + { + pos_end.mV[i] = pos_agent.mV[i] + (50 * direction.mV[i]); + } + glLineWidth(LLPipeline::DebugBeaconLineWidth); + gGL.begin(LLRender::LINES); + color.mV[3] *= 0.5f; + gGL.color4fv(color.mV); + draw_cross_lines(pos_agent, 0.5f, 0.5f, 0.5f); + draw_cross_lines(pos_end, 2.f, 2.f, 2.f); + gGL.vertex3fv(pos_agent.mV); + gGL.vertex3fv(pos_end.mV); + gGL.end(); + + gGL.flush(); + glLineWidth(1.f); + +} //----------------------------------------------------------------------------- // gpu_benchmark() helper classes diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index 6b1e196182..486e077b9b 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -588,8 +588,6 @@ void LLHUDText::renderAllHUD() LLVertexBuffer::unbind(); - LLVertexBuffer::unbind(); - LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 1987e15850..61696d89e3 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -81,6 +81,10 @@ #include "llwearableitemslist.h" #include "lllandmarkactions.h" #include "llpanellandmarks.h" +#include "llviewerparcelmgr.h" +#include "llparcel.h" + +#include "llenvironment.h" #include <boost/shared_ptr.hpp> @@ -1414,6 +1418,14 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type, //LL_WARNS() << LLAssetType::lookup(asset_type) << " asset type is unhandled for uuid " << uuid << LL_ENDL; break; + case LLAssetType::AT_SETTINGS: + if (inv_type != LLInventoryType::IT_SETTINGS) + { + LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL; + } + new_listener = new LLSettingsBridge(inventory, root, uuid, LLSettingsType::fromInventoryFlags(flags)); + break; + default: LL_INFOS() << "Unhandled asset type (llassetstorage.h): " << (S32)asset_type << " (" << LLAssetType::lookup(asset_type) << ")" << LL_ENDL; @@ -3945,6 +3957,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items disabled_items.push_back(std::string("New Folder")); disabled_items.push_back(std::string("New Script")); disabled_items.push_back(std::string("New Note")); + disabled_items.push_back(std::string("New Settings")); disabled_items.push_back(std::string("New Gesture")); disabled_items.push_back(std::string("New Clothes")); disabled_items.push_back(std::string("New Body Parts")); @@ -4038,10 +4051,18 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items items.push_back(std::string("New Gesture")); items.push_back(std::string("New Clothes")); items.push_back(std::string("New Body Parts")); + items.push_back(std::string("New Settings")); items.push_back(std::string("upload_def")); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + disabled_items.push_back("New Settings"); + } + } } getClipboardEntries(false, items, disabled_items, flags); + } else { @@ -4304,6 +4325,7 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_ANIMATION: case DAD_GESTURE: case DAD_MESH: + case DAD_SETTINGS: accept = dragItemIntoFolder(inv_item, drop, tooltip_msg); break; case DAD_LINK: @@ -5093,6 +5115,11 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, tooltip_msg = LLTrans::getString("TooltipOutboxNotInInventory"); accept = FALSE; } + else if ((inv_item->getActualType() == LLAssetType::AT_SETTINGS) && !LLEnvironment::instance().isInventoryEnabled()) + { + tooltip_msg = LLTrans::getString("NoEnvironmentSettings"); + accept = FALSE; + } else { // Don't allow placing an original item from a notecard to Current Outfit or an outfit folder @@ -5809,6 +5836,7 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_ANIMATION: case DAD_GESTURE: case DAD_MESH: + case DAD_SETTINGS: { LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data; const LLPermissions& perm = inv_item->getPermissions(); @@ -6882,6 +6910,146 @@ void LLMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags) hide_context_entries(menu, items, disabled_items); } +// +=================================================+ +// | LLSettingsBridge | +// +=================================================+ + +LLSettingsBridge::LLSettingsBridge(LLInventoryPanel* inventory, + LLFolderView* root, + const LLUUID& uuid, + LLSettingsType::type_e settings_type): + LLItemBridge(inventory, root, uuid), + mSettingsType(settings_type) +{ +} + +LLUIImagePtr LLSettingsBridge::getIcon() const +{ + return LLInventoryIcon::getIcon(LLAssetType::AT_SETTINGS, LLInventoryType::IT_SETTINGS, mSettingsType, FALSE); +} + +void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action) +{ + if ("apply_settings_local" == action) + { + // Single item only + LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem()); + if (!item) + return; + LLUUID asset_id = item->getAssetUUID(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, asset_id); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + } + else if ("apply_settings_parcel" == action) + { + // Single item only + LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem()); + if (!item) + return; + LLUUID asset_id = item->getAssetUUID(); + std::string name = item->getName(); + + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentOrSelectedParcel(); + if (!parcel) + { + LL_WARNS("INVENTORY") << "could not identify parcel." << LL_ENDL; + return; + } + S32 parcel_id = parcel->getLocalID(); + + LL_DEBUGS("ENVIRONMENT") << "Applying asset ID " << asset_id << " to parcel " << parcel_id << LL_ENDL; + LLEnvironment::instance().updateParcel(parcel_id, asset_id, name, LLEnvironment::NO_TRACK, -1, -1); + LLEnvironment::instance().setSharedEnvironment(); + } + else + LLItemBridge::performAction(model, action); +} + +void LLSettingsBridge::openItem() +{ + LLViewerInventoryItem* item = getItem(); + if (item) + { + if (item->getPermissions().getOwner() != gAgent.getID()) + LLNotificationsUtil::add("NoEditFromLibrary"); + else + LLInvFVBridgeAction::doAction(item->getType(), mUUID, getInventoryModel()); + } +} + +void LLSettingsBridge::buildContextMenu(LLMenuGL& menu, U32 flags) +{ + LL_DEBUGS() << "LLSettingsBridge::buildContextMenu()" << LL_ENDL; + menuentry_vec_t items; + menuentry_vec_t disabled_items; + + if (isMarketplaceListingsFolder()) + { + menuentry_vec_t items; + menuentry_vec_t disabled_items; + addMarketplaceContextMenuOptions(flags, items, disabled_items); + items.push_back(std::string("Properties")); + getClipboardEntries(false, items, disabled_items, flags); + hide_context_entries(menu, items, disabled_items); + } + else if (isItemInTrash()) + { + addTrashContextMenuOptions(items, disabled_items); + } + else + { + items.push_back(std::string("Share")); + if (!canShare()) + { + disabled_items.push_back(std::string("Share")); + } + + addOpenRightClickMenuOption(items); + items.push_back(std::string("Properties")); + + getClipboardEntries(true, items, disabled_items, flags); + + items.push_back("Settings Separator"); + items.push_back("Settings Apply Local"); + + items.push_back("Settings Apply Parcel"); + if (!canUpdateParcel()) + disabled_items.push_back("Settings Apply Parcel"); + + items.push_back("Settings Apply Region"); + if (!canUpdateRegion()) + disabled_items.push_back("Settings Apply Region"); + } + addLinkReplaceMenuOption(items, disabled_items); + hide_context_entries(menu, items, disabled_items); +} + +BOOL LLSettingsBridge::renameItem(const std::string& new_name) +{ + /*TODO: change internal settings name? */ + return LLItemBridge::renameItem(new_name); +} + +BOOL LLSettingsBridge::isItemRenameable() const +{ + LLViewerInventoryItem* item = getItem(); + if (item) + { + return (item->getPermissions().allowModifyBy(gAgent.getID())); + } + return FALSE; +} + +bool LLSettingsBridge::canUpdateParcel() const +{ + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); +} + +bool LLSettingsBridge::canUpdateRegion() const +{ + return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); +} + // +=================================================+ // | LLLinkBridge | @@ -7241,6 +7409,40 @@ void LLWearableBridgeAction::wearOnAvatar() } } +class LLSettingsBridgeAction + : public LLInvFVBridgeAction +{ + friend class LLInvFVBridgeAction; +public: + virtual void doIt() + { + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLSettingsType::type_e type = item->getSettingsType(); + switch (type) + { + case LLSettingsType::ST_SKY: + LLFloaterReg::showInstance("env_fixed_environmentent_sky", LLSDMap("inventory_id", item->getUUID()), TAKE_FOCUS_YES); + break; + case LLSettingsType::ST_WATER: + LLFloaterReg::showInstance("env_fixed_environmentent_water", LLSDMap("inventory_id", item->getUUID()), TAKE_FOCUS_YES); + break; + case LLSettingsType::ST_DAYCYCLE: + LLFloaterReg::showInstance("env_edit_extdaycycle", LLSDMap("inventory_id", item->getUUID())("edit_context", "inventory"), TAKE_FOCUS_YES); + break; + default: + break; + } + } + LLInvFVBridgeAction::doIt(); + } + virtual ~LLSettingsBridgeAction(){} +protected: + LLSettingsBridgeAction(const LLUUID& id, LLInventoryModel* model) : LLInvFVBridgeAction(id, model) {} +}; + + LLInvFVBridgeAction* LLInvFVBridgeAction::createAction(LLAssetType::EType asset_type, const LLUUID& uuid, LLInventoryModel* model) @@ -7279,6 +7481,9 @@ LLInvFVBridgeAction* LLInvFVBridgeAction::createAction(LLAssetType::EType asset_ case LLAssetType::AT_BODYPART: action = new LLWearableBridgeAction(uuid,model); break; + case LLAssetType::AT_SETTINGS: + action = new LLSettingsBridgeAction(uuid, model); + break; default: break; } diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index ce06e8fffc..73f20d2146 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -38,6 +38,7 @@ #include "lltooldraganddrop.h" #include "lllandmarklist.h" #include "llfolderviewitem.h" +#include "llsettingsbase.h" class LLInventoryFilter; class LLInventoryPanel; @@ -108,6 +109,7 @@ public: virtual void closeItem() {} virtual void showProperties(); virtual BOOL isItemRenameable() const { return TRUE; } + virtual BOOL isMultiPreviewAllowed() { return TRUE; } //virtual BOOL renameItem(const std::string& new_name) {} virtual BOOL isItemRemovable() const; virtual BOOL isItemMovable() const; @@ -136,6 +138,7 @@ public: std::string& tooltip_msg) { return FALSE; } virtual LLInventoryType::EType getInventoryType() const { return mInvType; } virtual LLWearableType::EType getWearableType() const { return LLWearableType::WT_NONE; } + virtual LLSettingsType::type_e getSettingsType() const { return LLSettingsType::ST_NONE; } EInventorySortGroup getSortGroup() const { return SG_ITEM; } virtual LLInventoryObject* getInventoryObject() const; @@ -620,6 +623,30 @@ protected: }; +class LLSettingsBridge : public LLItemBridge +{ +public: + LLSettingsBridge(LLInventoryPanel* inventory, + LLFolderView* root, + const LLUUID& uuid, + LLSettingsType::type_e settings_type); + virtual LLUIImagePtr getIcon() const; + virtual void performAction(LLInventoryModel* model, std::string action); + virtual void openItem(); + virtual BOOL isMultiPreviewAllowed() { return FALSE; } + virtual void buildContextMenu(LLMenuGL& menu, U32 flags); + virtual BOOL renameItem(const std::string& new_name); + virtual BOOL isItemRenameable() const; + virtual LLSettingsType::type_e getSettingsType() const { return mSettingsType; } + +protected: + bool canUpdateRegion() const; + bool canUpdateParcel() const; + + LLSettingsType::type_e mSettingsType; + +}; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInvFVBridgeAction // diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 9193613e9f..a9640a2264 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -53,6 +53,7 @@ LLInventoryFilter::FilterOps::FilterOps(const Params& p) : mFilterObjectTypes(p.object_types), mFilterCategoryTypes(p.category_types), mFilterWearableTypes(p.wearable_types), + mFilterSettingsTypes(p.settings_types), mMinDate(p.date_range.min_date), mMaxDate(p.date_range.max_date), mHoursAgo(p.hours_ago), @@ -325,12 +326,26 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent if (filterTypes & FILTERTYPE_WEARABLE) { LLWearableType::EType type = listener->getWearableType(); - if ((0x1LL << type & mFilterOps.mFilterWearableTypes) == 0) + if ((object_type == LLInventoryType::IT_WEARABLE) && + (((0x1LL << type) & mFilterOps.mFilterWearableTypes) == 0)) { return FALSE; } } + //////////////////////////////////////////////////////////////////////////////// + // FILTERTYPE_SETTINGS + // Pass if this item is a setting of the appropriate type + if (filterTypes & FILTERTYPE_SETTINGS) + { + LLSettingsType::type_e type = listener->getSettingsType(); + if ((object_type == LLInventoryType::IT_SETTINGS) && + (((0x1LL << type) & mFilterOps.mFilterSettingsTypes) == 0)) + { + return FALSE; + } + } + //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_EMPTYFOLDERS // Pass if this item is a folder and is not a system folder that should be hidden @@ -626,6 +641,12 @@ void LLInventoryFilter::setFilterWearableTypes(U64 types) mFilterOps.mFilterTypes |= FILTERTYPE_WEARABLE; } +void LLInventoryFilter::setFilterSettingsTypes(U64 types) +{ + updateFilterTypes(types, mFilterOps.mFilterSettingsTypes); + mFilterOps.mFilterTypes |= FILTERTYPE_SETTINGS; +} + void LLInventoryFilter::setFilterEmptySystemFolders() { mFilterOps.mFilterTypes |= FILTERTYPE_EMPTYFOLDERS; @@ -1241,6 +1262,11 @@ U64 LLInventoryFilter::getFilterWearableTypes() const return mFilterOps.mFilterWearableTypes; } +U64 LLInventoryFilter::getFilterSettingsTypes() const +{ + return mFilterOps.mFilterSettingsTypes; +} + bool LLInventoryFilter::hasFilterString() const { return mFilterSubString.size() > 0; diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 01754ed023..9fb986f21d 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -47,18 +47,19 @@ public: enum EFilterType { FILTERTYPE_NONE = 0, - FILTERTYPE_OBJECT = 0x1 << 0, // normal default search-by-object-type - FILTERTYPE_CATEGORY = 0x1 << 1, // search by folder type - FILTERTYPE_UUID = 0x1 << 2, // find the object with UUID and any links to it - FILTERTYPE_DATE = 0x1 << 3, // search by date range - FILTERTYPE_WEARABLE = 0x1 << 4, // search by wearable type + FILTERTYPE_OBJECT = 0x1 << 0, // normal default search-by-object-type + FILTERTYPE_CATEGORY = 0x1 << 1, // search by folder type + FILTERTYPE_UUID = 0x1 << 2, // find the object with UUID and any links to it + FILTERTYPE_DATE = 0x1 << 3, // search by date range + FILTERTYPE_WEARABLE = 0x1 << 4, // search by wearable type FILTERTYPE_EMPTYFOLDERS = 0x1 << 5, // pass if folder is not a system folder to be hidden if empty FILTERTYPE_MARKETPLACE_ACTIVE = 0x1 << 6, // pass if folder is a marketplace active folder FILTERTYPE_MARKETPLACE_INACTIVE = 0x1 << 7, // pass if folder is a marketplace inactive folder FILTERTYPE_MARKETPLACE_UNASSOCIATED = 0x1 << 8, // pass if folder is a marketplace non associated (no market ID) folder FILTERTYPE_MARKETPLACE_LISTING_FOLDER = 0x1 << 9, // pass iff folder is a listing folder FILTERTYPE_NO_MARKETPLACE_ITEMS = 0x1 << 10, // pass iff folder is not under the marketplace - FILTERTYPE_WORN = 0x1 << 11, // pass if item is worn + FILTERTYPE_WORN = 0x1 << 11, // pass if item is worn + FILTERTYPE_SETTINGS = 0x1 << 12, // pass if the item is a settings object }; enum EFilterDateDirection @@ -80,7 +81,7 @@ public: SO_DATE = 0x1, // Sort inventory by date SO_FOLDERS_BY_NAME = 0x1 << 1, // Force folder sort by name SO_SYSTEM_FOLDERS_TO_TOP = 0x1 << 2,// Force system folders to be on top - SO_FOLDERS_BY_WEIGHT = 0x1 << 3, // Force folder sort by weight, usually, amount of some elements in their descendents + SO_FOLDERS_BY_WEIGHT = 0x1 << 3, // Force folder sort by weight, usually, amount of some elements in their descendants }; enum ESearchType @@ -118,6 +119,7 @@ public: Optional<U32> types; Optional<U64> object_types, wearable_types, + settings_types, category_types; Optional<EFilterLink> links; Optional<LLUUID> uuid; @@ -131,7 +133,8 @@ public: : types("filter_types", FILTERTYPE_OBJECT), object_types("object_types", 0xffffFFFFffffFFFFULL), wearable_types("wearable_types", 0xffffFFFFffffFFFFULL), - category_types("category_types", 0xffffFFFFffffFFFFULL), + settings_types("settings_types", 0xffffFFFFffffFFFFULL), + category_types("category_types", 0xffffFFFFffffFFFFULL), links("links", FILTERLINK_INCLUDE_LINKS), uuid("uuid"), date_range("date_range"), @@ -145,10 +148,11 @@ public: FilterOps(const Params& = Params()); U32 mFilterTypes; - U64 mFilterObjectTypes, // For _OBJECT - mFilterWearableTypes, - mFilterLinks, - mFilterCategoryTypes; // For _CATEGORY + U64 mFilterObjectTypes, // For _OBJECT + mFilterWearableTypes, + mFilterSettingsTypes, // for _SETTINGS + mFilterLinks, + mFilterCategoryTypes; // For _CATEGORY LLUUID mFilterUUID; // for UUID time_t mMinDate, @@ -186,11 +190,14 @@ public: U64 getFilterObjectTypes() const; U64 getFilterCategoryTypes() const; U64 getFilterWearableTypes() const; + U64 getFilterSettingsTypes() const; + bool isFilterObjectTypesWith(LLInventoryType::EType t) const; void setFilterObjectTypes(U64 types); void setFilterCategoryTypes(U64 types); void setFilterUUID(const LLUUID &object_id); void setFilterWearableTypes(U64 types); + void setFilterSettingsTypes(U64 types); void setFilterEmptySystemFolders(); void setFilterWorn(); void setFilterMarketplaceActiveFolders(); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 030c967019..b0004c5e58 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2395,10 +2395,29 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root if (("task_open" == action || "open" == action) && selected_items.size() > 1) { - multi_previewp = new LLMultiPreview(); - gFloaterView->addChild(multi_previewp); + bool open_multi_preview = true; - LLFloater::setFloaterHost(multi_previewp); + for (std::set<LLFolderViewItem*>::iterator set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter) + { + LLFolderViewItem* folder_item = *set_iter; + if (folder_item) + { + LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getViewModelItem(); + if (!bridge || !bridge->isMultiPreviewAllowed()) + { + open_multi_preview = false; + break; + } + } + } + + if (open_multi_preview) + { + multi_previewp = new LLMultiPreview(); + gFloaterView->addChild(multi_previewp); + + LLFloater::setFloaterHost(multi_previewp); + } } else if (("task_properties" == action || "properties" == action) && selected_items.size() > 1) diff --git a/indra/newview/llinventoryicon.cpp b/indra/newview/llinventoryicon.cpp index d0df1c94d5..323d19b68a 100644 --- a/indra/newview/llinventoryicon.cpp +++ b/indra/newview/llinventoryicon.cpp @@ -34,6 +34,7 @@ #include "llui.h" #include "lluiimage.h" #include "llwearabletype.h" +#include "llinventorysettings.h" struct IconEntry : public LLDictionaryEntry { @@ -92,6 +93,11 @@ LLIconDictionary::LLIconDictionary() addEntry(LLInventoryType::ICONNAME_LINKFOLDER, new IconEntry("Inv_LinkFolder")); addEntry(LLInventoryType::ICONNAME_MESH, new IconEntry("Inv_Mesh")); + addEntry(LLInventoryType::ICONNAME_SETTINGS_SKY, new IconEntry("Inv_SettingsSky")); + addEntry(LLInventoryType::ICONNAME_SETTINGS_WATER, new IconEntry("Inv_SettingsWater")); + addEntry(LLInventoryType::ICONNAME_SETTINGS_DAY, new IconEntry("Inv_SettingsDay")); + addEntry(LLInventoryType::ICONNAME_SETTINGS, new IconEntry("Inv_Settings")); + addEntry(LLInventoryType::ICONNAME_INVALID, new IconEntry("Inv_Invalid")); addEntry(LLInventoryType::ICONNAME_UNKNOWN, new IconEntry("Inv_Unknown")); @@ -167,8 +173,14 @@ const std::string& LLInventoryIcon::getIconName(LLAssetType::EType asset_type, break; case LLAssetType::AT_MESH: idx = LLInventoryType::ICONNAME_MESH; + break; + case LLAssetType::AT_SETTINGS: + // TODO: distinguish between Sky and Water settings. + idx = assignSettingsIcon(misc_flag); + break; case LLAssetType::AT_UNKNOWN: idx = LLInventoryType::ICONNAME_UNKNOWN; + break; default: break; } @@ -188,3 +200,9 @@ LLInventoryType::EIconName LLInventoryIcon::assignWearableIcon(U32 misc_flag) const LLWearableType::EType wearable_type = LLWearableType::inventoryFlagsToWearableType(misc_flag); return LLWearableType::getIconName(wearable_type); } + +LLInventoryType::EIconName LLInventoryIcon::assignSettingsIcon(U32 misc_flag) +{ + LLSettingsType::type_e settings_type = LLSettingsType::fromInventoryFlags(misc_flag); + return LLSettingsType::getIconName(settings_type); +} diff --git a/indra/newview/llinventoryicon.h b/indra/newview/llinventoryicon.h index bc09e32087..b8637c4e33 100644 --- a/indra/newview/llinventoryicon.h +++ b/indra/newview/llinventoryicon.h @@ -48,6 +48,7 @@ public: protected: static LLInventoryType::EIconName assignWearableIcon(U32 misc_flag); + static LLInventoryType::EIconName assignSettingsIcon(U32 misc_flag); }; #endif // LL_LLINVENTORYICON_H diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index a520e0171e..6046fbf2ab 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -1818,7 +1818,7 @@ void LLInventoryModel::addItem(LLViewerInventoryItem* item) return; } - if (LLAssetType::lookup(item->getType()) == LLAssetType::badLookup()) + if (LLAssetType::lookup(item->getType()) == LLAssetType::BADLOOKUP) { LL_WARNS(LOG_INV) << "Got unknown asset type for item [ name: " << item->getName() << " type: " << item->getType() @@ -2597,6 +2597,7 @@ void LLInventoryModel::createCommonSystemCategories() gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE,true); gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD,true); gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS,true); + gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS, true); } struct LLUUIDAndName diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 3992b506e9..c96760dd66 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -46,12 +46,19 @@ #include "llnotificationsutil.h" #include "llpreview.h" #include "llsidepanelinventory.h" +#include "llstartup.h" #include "lltrans.h" +#include "llviewerassettype.h" #include "llviewerattachmenu.h" #include "llviewerfoldertype.h" #include "llvoavatarself.h" +class LLInventoryRecentItemsPanel; +class LLAssetFilteredInventoryPanel; + static LLDefaultChildRegistry::Register<LLInventoryPanel> r("inventory_panel"); +static LLDefaultChildRegistry::Register<LLInventoryRecentItemsPanel> t_recent_inventory_panel("recent_inventory_panel"); +static LLDefaultChildRegistry::Register<LLAssetFilteredInventoryPanel> t_asset_filtered_inv_panel("asset_filtered_inv_panel"); const std::string LLInventoryPanel::DEFAULT_SORT_ORDER = std::string("InventorySortOrder"); const std::string LLInventoryPanel::RECENTITEMS_SORT_ORDER = std::string("RecentItemsSortOrder"); @@ -142,8 +149,11 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : mInventory(p.inventory), mAcceptsDragAndDrop(p.accepts_drag_and_drop), mAllowMultiSelect(p.allow_multi_select), + mAllowDrag(p.allow_drag), mShowItemLinkOverlays(p.show_item_link_overlays), mShowEmptyMessage(p.show_empty_message), + mSuppressFolderMenu(p.suppress_folder_menu), + mSuppressOpenItemAction(false), mViewsInitialized(false), mInvFVBridgeBuilder(NULL), mInventoryViewModel(p.name), @@ -190,7 +200,9 @@ LLFolderView * LLInventoryPanel::createFolderRoot(LLUUID root_id ) p.grouped_item_model = mGroupedItemBridge; p.use_label_suffix = mParams.use_label_suffix; p.allow_multiselect = mAllowMultiSelect; + p.allow_drag = mAllowDrag; p.show_empty_message = mShowEmptyMessage; + p.suppress_folder_menu = mSuppressFolderMenu; p.show_item_link_overlays = mShowItemLinkOverlays; p.root = NULL; p.allow_drop = mParams.allow_drop_on_root; @@ -269,9 +281,9 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) mCompletionObserver = new LLInvPanelComplObserver(boost::bind(&LLInventoryPanel::onItemsCompletion, this)); mInventory->addObserver(mCompletionObserver); - // Build view of inventory if we need default full hierarchy and inventory ready, - // otherwise wait for idle callback. - if (mInventory->isInventoryUsable() && !mViewsInitialized) + // Build view of inventory if we need default full hierarchy and inventory ready, otherwise do in onIdle. + // Initializing views takes a while so always do it onIdle if viewer already loaded. + if (mInventory->isInventoryUsable() && !mViewsInitialized && LLStartUp::getStartupState() <= STATE_WEARABLES_WAIT) { initializeViews(); } @@ -377,6 +389,11 @@ void LLInventoryPanel::setFilterWearableTypes(U64 types) getFilter().setFilterWearableTypes(types); } +void LLInventoryPanel::setFilterSettingsTypes(U64 filter) +{ + getFilter().setFilterSettingsTypes(filter); +} + void LLInventoryPanel::setFilterSubString(const std::string& string) { getFilter().setFilterSubString(string); @@ -387,7 +404,6 @@ const std::string LLInventoryPanel::getFilterSubString() return getFilter().getFilterSubString(); } - void LLInventoryPanel::setSortOrder(U32 order) { LLInventorySort sorter(order); @@ -445,195 +461,201 @@ LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState() return getFilter().getShowFolderState(); } -// Called when something changed in the global model (new item, item coming through the wire, rename, move, etc...) (CHUI-849) -static LLTrace::BlockTimerStatHandle FTM_REFRESH("Inventory Refresh"); -void LLInventoryPanel::modelChanged(U32 mask) +void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInventoryObject* model_item) { - LL_RECORD_BLOCK_TIME(FTM_REFRESH); + LLFolderViewItem* view_item = getItemByID(item_id); + LLFolderViewModelItemInventory* viewmodel_item = + static_cast<LLFolderViewModelItemInventory*>(view_item ? view_item->getViewModelItem() : NULL); - if (!mViewsInitialized) return; - - const LLInventoryModel* model = getModel(); - if (!model) return; + // LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item + // to folder is the fast way to get a folder without searching through folders tree. + LLFolderViewFolder* view_folder = NULL; - const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs(); - if (changed_items.empty()) return; + // Check requires as this item might have already been deleted + // as a child of its deleted parent. + if (model_item && view_item) + { + view_folder = dynamic_cast<LLFolderViewFolder*>(view_item); + } - for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); - items_iter != changed_items.end(); - ++items_iter) + ////////////////////////////// + // LABEL Operation + // Empty out the display name for relabel. + if (mask & LLInventoryObserver::LABEL) { - const LLUUID& item_id = (*items_iter); - const LLInventoryObject* model_item = model->getObject(item_id); - LLFolderViewItem* view_item = getItemByID(item_id); - LLFolderViewModelItemInventory* viewmodel_item = - static_cast<LLFolderViewModelItemInventory*>(view_item ? view_item->getViewModelItem() : NULL); + if (view_item) + { + // Request refresh on this item (also flags for filtering) + LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getViewModelItem(); + if(bridge) + { + // Clear the display name first, so it gets properly re-built during refresh() + bridge->clearDisplayName(); - // LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item - // to folder is the fast way to get a folder without searching through folders tree. - LLFolderViewFolder* view_folder = NULL; + view_item->refresh(); + } + LLFolderViewFolder* parent = view_item->getParentFolder(); + if(parent) + { + parent->getViewModelItem()->dirtyDescendantsFilter(); + } + } + } - // Check requires as this item might have already been deleted - // as a child of its deleted parent. - if (model_item && view_item) + ////////////////////////////// + // REBUILD Operation + // Destroy and regenerate the UI. + if (mask & LLInventoryObserver::REBUILD) + { + if (model_item && view_item && viewmodel_item) { - view_folder = dynamic_cast<LLFolderViewFolder*>(view_item); + const LLUUID& idp = viewmodel_item->getUUID(); + view_item->destroyView(); + removeItemID(idp); } + view_item = buildNewViews(item_id); + viewmodel_item = + static_cast<LLFolderViewModelItemInventory*>(view_item ? view_item->getViewModelItem() : NULL); + view_folder = dynamic_cast<LLFolderViewFolder *>(view_item); + } - ////////////////////////////// - // LABEL Operation - // Empty out the display name for relabel. - if (mask & LLInventoryObserver::LABEL) + ////////////////////////////// + // INTERNAL Operation + // This could be anything. For now, just refresh the item. + if (mask & LLInventoryObserver::INTERNAL) + { + if (view_item) { - if (view_item) - { - // Request refresh on this item (also flags for filtering) - LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getViewModelItem(); - if(bridge) - { // Clear the display name first, so it gets properly re-built during refresh() - bridge->clearDisplayName(); - - view_item->refresh(); - } - LLFolderViewFolder* parent = view_item->getParentFolder(); - if(parent) - { - parent->getViewModelItem()->dirtyDescendantsFilter(); - } - } + view_item->refresh(); } + } - ////////////////////////////// - // REBUILD Operation - // Destroy and regenerate the UI. - if (mask & LLInventoryObserver::REBUILD) + ////////////////////////////// + // SORT Operation + // Sort the folder. + if (mask & LLInventoryObserver::SORT) + { + if (view_folder) { - if (model_item && view_item && viewmodel_item) - { - const LLUUID& idp = viewmodel_item->getUUID(); - view_item->destroyView(); - removeItemID(idp); - } - view_item = buildNewViews(item_id); - viewmodel_item = - static_cast<LLFolderViewModelItemInventory*>(view_item ? view_item->getViewModelItem() : NULL); - view_folder = dynamic_cast<LLFolderViewFolder *>(view_item); + view_folder->getViewModelItem()->requestSort(); } + } + // We don't typically care which of these masks the item is actually flagged with, since the masks + // may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into + // Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks + // panel). What's relevant is that the item and UI are probably out of sync and thus need to be + // resynchronized. + if (mask & (LLInventoryObserver::STRUCTURE | + LLInventoryObserver::ADD | + LLInventoryObserver::REMOVE)) + { ////////////////////////////// - // INTERNAL Operation - // This could be anything. For now, just refresh the item. - if (mask & LLInventoryObserver::INTERNAL) + // ADD Operation + // Item exists in memory but a UI element hasn't been created for it. + if (model_item && !view_item) { - if (view_item) + // Add the UI element for this item. + buildNewViews(item_id); + // Select any newly created object that has the auto rename at top of folder root set. + if(mFolderRoot.get()->getRoot()->needsAutoRename()) { - view_item->refresh(); + setSelection(item_id, FALSE); } + updateFolderLabel(model_item->getParentUUID()); } ////////////////////////////// - // SORT Operation - // Sort the folder. - if (mask & LLInventoryObserver::SORT) + // STRUCTURE Operation + // This item already exists in both memory and UI. It was probably reparented. + else if (model_item && view_item) { - if (view_folder) + LLFolderViewFolder* old_parent = view_item->getParentFolder(); + // Don't process the item if it is the root + if (old_parent) { - view_folder->getViewModelItem()->requestSort(); - } - } - - // We don't typically care which of these masks the item is actually flagged with, since the masks - // may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into - // Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks - // panel). What's relevant is that the item and UI are probably out of sync and thus need to be - // resynchronized. - if (mask & (LLInventoryObserver::STRUCTURE | - LLInventoryObserver::ADD | - LLInventoryObserver::REMOVE)) - { - ////////////////////////////// - // ADD Operation - // Item exists in memory but a UI element hasn't been created for it. - if (model_item && !view_item) - { - // Add the UI element for this item. - buildNewViews(item_id); - // Select any newly created object that has the auto rename at top of folder root set. - if(mFolderRoot.get()->getRoot()->needsAutoRename()) + LLFolderViewModelItemInventory* viewmodel_folder = static_cast<LLFolderViewModelItemInventory*>(old_parent->getViewModelItem()); + LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID()); + // Item has been moved. + if (old_parent != new_parent) { - setSelection(item_id, FALSE); - } - updateFolderLabel(model_item->getParentUUID()); - } - - ////////////////////////////// - // STRUCTURE Operation - // This item already exists in both memory and UI. It was probably reparented. - else if (model_item && view_item) - { - LLFolderViewFolder* old_parent = view_item->getParentFolder(); - // Don't process the item if it is the root - if (old_parent) - { - LLFolderViewModelItemInventory* viewmodel_folder = static_cast<LLFolderViewModelItemInventory*>(old_parent->getViewModelItem()); - LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID()); - // Item has been moved. - if (old_parent != new_parent) + if (new_parent != NULL) { - if (new_parent != NULL) + // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. + view_item->addToFolder(new_parent); + addItemID(viewmodel_item->getUUID(), view_item); + if (mInventory) { - // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. - view_item->addToFolder(new_parent); - addItemID(viewmodel_item->getUUID(), view_item); - if (mInventory) + const LLUUID trash_id = mInventory->findCategoryUUIDForType(LLFolderType::FT_TRASH); + if (trash_id != model_item->getParentUUID() && (mask & LLInventoryObserver::INTERNAL) && new_parent->isOpen()) { - const LLUUID trash_id = mInventory->findCategoryUUIDForType(LLFolderType::FT_TRASH); - if (trash_id != model_item->getParentUUID() && (mask & LLInventoryObserver::INTERNAL) && new_parent->isOpen()) - { - setSelection(item_id, FALSE); - } + setSelection(item_id, FALSE); } - updateFolderLabel(model_item->getParentUUID()); } - else - { - // Remove the item ID before destroying the view because the view-model-item gets - // destroyed when the view is destroyed - removeItemID(viewmodel_item->getUUID()); + updateFolderLabel(model_item->getParentUUID()); + } + else + { + // Remove the item ID before destroying the view because the view-model-item gets + // destroyed when the view is destroyed + removeItemID(viewmodel_item->getUUID()); - // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that - // doesn't include trash). Just remove the item's UI. - view_item->destroyView(); - } - if(viewmodel_folder) - { - updateFolderLabel(viewmodel_folder->getUUID()); - } - old_parent->getViewModelItem()->dirtyDescendantsFilter(); + // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that + // doesn't include trash). Just remove the item's UI. + view_item->destroyView(); } - } - } - - ////////////////////////////// - // REMOVE Operation - // This item has been removed from memory, but its associated UI element still exists. - else if (!model_item && view_item && viewmodel_item) - { - // Remove the item's UI. - LLFolderViewFolder* parent = view_item->getParentFolder(); - removeItemID(viewmodel_item->getUUID()); - view_item->destroyView(); - if(parent) - { - parent->getViewModelItem()->dirtyDescendantsFilter(); - LLFolderViewModelItemInventory* viewmodel_folder = static_cast<LLFolderViewModelItemInventory*>(parent->getViewModelItem()); if(viewmodel_folder) { updateFolderLabel(viewmodel_folder->getUUID()); } + old_parent->getViewModelItem()->dirtyDescendantsFilter(); } } } + + ////////////////////////////// + // REMOVE Operation + // This item has been removed from memory, but its associated UI element still exists. + else if (!model_item && view_item && viewmodel_item) + { + // Remove the item's UI. + LLFolderViewFolder* parent = view_item->getParentFolder(); + removeItemID(viewmodel_item->getUUID()); + view_item->destroyView(); + if(parent) + { + parent->getViewModelItem()->dirtyDescendantsFilter(); + LLFolderViewModelItemInventory* viewmodel_folder = static_cast<LLFolderViewModelItemInventory*>(parent->getViewModelItem()); + if(viewmodel_folder) + { + updateFolderLabel(viewmodel_folder->getUUID()); + } + } + } + } +} + +// Called when something changed in the global model (new item, item coming through the wire, rename, move, etc...) (CHUI-849) +static LLTrace::BlockTimerStatHandle FTM_REFRESH("Inventory Refresh"); +void LLInventoryPanel::modelChanged(U32 mask) +{ + LL_RECORD_BLOCK_TIME(FTM_REFRESH); + + if (!mViewsInitialized) return; + + const LLInventoryModel* model = getModel(); + if (!model) return; + + const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs(); + if (changed_items.empty()) return; + + for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); + items_iter != changed_items.end(); + ++items_iter) + { + const LLUUID& item_id = (*items_iter); + const LLInventoryObject* model_item = model->getObject(item_id); + itemChanged(item_id, mask, model_item); } } @@ -831,14 +853,17 @@ LLFolderViewItem * LLInventoryPanel::createFolderViewItem(LLInvFVBridge * bridge LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) { - LLInventoryObject const* objectp = gInventory.getObject(id); - - if (!objectp) + LLInventoryObject const* objectp = gInventory.getObject(id); + return buildNewViews(id, objectp); +} + +LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id, LLInventoryObject const* objectp) +{ + if (!objectp) { return NULL; } - - LLFolderViewItem* folder_view_item = getItemByID(id); + LLFolderViewItem* folder_view_item = getItemByID(id); const LLUUID &parent_id = objectp->getParentUUID(); LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)getItemByID(parent_id); @@ -1122,6 +1147,11 @@ void LLInventoryPanel::clearSelection() mSelectThisID.setNull(); } +LLInventoryPanel::selected_items_t LLInventoryPanel::getSelectedItems() const +{ + return mFolderRoot.get()->getSelectionList(); +} + void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& items, BOOL user_action) { // Schedule updating the folder view context menu when all selected items become complete (STORM-373). @@ -1631,21 +1661,18 @@ BOOL LLInventoryPanel::handleKeyHere( KEY key, MASK mask ) // Open selected items if enter key hit on the inventory panel if (mask == MASK_NONE) { - -// @TODO$: Rider: This code is dead with Outbox, however should something similar be -// done for VMM? -// -// //Don't allow attaching or opening items from Merchant Outbox -// LLFolderViewItem* folder_item = mFolderRoot.get()->getCurSelectedItem(); -// if(folder_item) -// { -// LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getViewModelItem(); -// if(bridge && bridge->is() && (bridge->getInventoryType() != LLInventoryType::IT_CATEGORY)) -// { -// return handled; -// } -// } - + if (mSuppressOpenItemAction) + { + LLFolderViewItem* folder_item = mFolderRoot.get()->getCurSelectedItem(); + if(folder_item) + { + LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getViewModelItem(); + if(bridge && (bridge->getInventoryType() != LLInventoryType::IT_CATEGORY)) + { + return handled; + } + } + } LLInventoryAction::doToSelected(mInventory, mFolderRoot.get(), "open"); handled = TRUE; } @@ -1698,8 +1725,6 @@ bool LLInventoryPanel::isSelectionRemovable() /************************************************************************/ /* Recent Inventory Panel related class */ /************************************************************************/ -class LLInventoryRecentItemsPanel; -static LLDefaultChildRegistry::Register<LLInventoryRecentItemsPanel> t_recent_inventory_panel("recent_inventory_panel"); static const LLRecentInventoryBridgeBuilder RECENT_ITEMS_BUILDER; class LLInventoryRecentItemsPanel : public LLInventoryPanel @@ -1729,6 +1754,111 @@ LLInventoryRecentItemsPanel::LLInventoryRecentItemsPanel( const Params& params) mInvFVBridgeBuilder = &RECENT_ITEMS_BUILDER; } +/************************************************************************/ +/* Asset Pre-Filtered Inventory Panel related class */ +/* Exchanges filter's flexibility for speed of generation and */ +/* improved performance */ +/************************************************************************/ +class LLAssetFilteredInventoryPanel : public LLInventoryPanel +{ +public: + struct Params + : public LLInitParam::Block<Params, LLInventoryPanel::Params> + { + Mandatory<std::string> filter_asset_type; + + Params() : filter_asset_type("filter_asset_type") {} + }; + + void initFromParams(const Params& p); +protected: + LLAssetFilteredInventoryPanel(const Params& p) : LLInventoryPanel(p) {} + friend class LLUICtrlFactory; +public: + ~LLAssetFilteredInventoryPanel() {} + + /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) override; + +protected: + /*virtual*/ LLFolderViewItem* buildNewViews(const LLUUID& id) override; + /*virtual*/ void itemChanged(const LLUUID& item_id, U32 mask, const LLInventoryObject* model_item) override; + +private: + LLAssetType::EType mAssetType; +}; + + +void LLAssetFilteredInventoryPanel::initFromParams(const Params& p) +{ + mAssetType = LLAssetType::lookup(p.filter_asset_type.getValue()); + LLInventoryPanel::initFromParams(p); + U64 filter_cats = getFilter().getFilterCategoryTypes(); + filter_cats &= ~(1ULL << LLFolderType::FT_MARKETPLACE_LISTINGS); + getFilter().setFilterCategoryTypes(filter_cats); + getFilter().setFilterNoMarketplaceFolder(); +} + +BOOL LLAssetFilteredInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + BOOL result = FALSE; + + if (mAcceptsDragAndDrop) + { + EDragAndDropType allow_type = LLViewerAssetType::lookupDragAndDropType(mAssetType); + // Don't allow DAD_CATEGORY here since it can contain other items besides required assets + // We should see everything we drop! + if (allow_type == cargo_type) + { + result = LLInventoryPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); + } + } + + return result; +} + +LLFolderViewItem* LLAssetFilteredInventoryPanel::buildNewViews(const LLUUID& id) +{ + LLInventoryObject const* objectp = gInventory.getObject(id); + + if (!objectp) + { + return NULL; + } + + if (objectp->getType() != mAssetType && objectp->getType() != LLAssetType::AT_CATEGORY) + { + return NULL; + } + + return LLInventoryPanel::buildNewViews(id, objectp); +} + +void LLAssetFilteredInventoryPanel::itemChanged(const LLUUID& id, U32 mask, const LLInventoryObject* model_item) +{ + if (!model_item && !getItemByID(id)) + { + // remove operation, but item is not in panel already + return; + } + + if (model_item + && model_item->getType() != mAssetType + && model_item->getType() != LLAssetType::AT_CATEGORY) + { + return; + } + + LLInventoryPanel::itemChanged(id, mask, model_item); +} + namespace LLInitParam { void TypeValues<LLFolderType::EType>::declareValues() @@ -1758,6 +1888,7 @@ namespace LLInitParam declare(LLFolderType::lookup(LLFolderType::FT_INBOX) , LLFolderType::FT_INBOX); declare(LLFolderType::lookup(LLFolderType::FT_OUTBOX) , LLFolderType::FT_OUTBOX); declare(LLFolderType::lookup(LLFolderType::FT_BASIC_ROOT) , LLFolderType::FT_BASIC_ROOT); + declare(LLFolderType::lookup(LLFolderType::FT_SETTINGS) , LLFolderType::FT_SETTINGS); declare(LLFolderType::lookup(LLFolderType::FT_MARKETPLACE_LISTINGS) , LLFolderType::FT_MARKETPLACE_LISTINGS); declare(LLFolderType::lookup(LLFolderType::FT_MARKETPLACE_STOCK), LLFolderType::FT_MARKETPLACE_STOCK); declare(LLFolderType::lookup(LLFolderType::FT_MARKETPLACE_VERSION), LLFolderType::FT_MARKETPLACE_VERSION); diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 12001f5a2b..b55eb2b828 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -92,11 +92,13 @@ public: Optional<std::string> sort_order_setting; Optional<LLInventoryModel*> inventory; Optional<bool> allow_multi_select; + Optional<bool> allow_drag; Optional<bool> show_item_link_overlays; Optional<Filter> filter; Optional<StartFolder> start_folder; Optional<bool> use_label_suffix; Optional<bool> show_empty_message; + Optional<bool> suppress_folder_menu; Optional<bool> show_root_folder; Optional<bool> allow_drop_on_root; Optional<bool> use_marketplace_folders; @@ -110,7 +112,9 @@ public: : sort_order_setting("sort_order_setting"), inventory("", &gInventory), allow_multi_select("allow_multi_select", true), + allow_drag("allow_drag", true), show_item_link_overlays("show_item_link_overlays", false), + suppress_folder_menu("suppress_folder_menu", false), filter("filter"), start_folder("start_folder"), use_label_suffix("use_label_suffix", true), @@ -144,6 +148,8 @@ public: virtual ~LLInventoryPanel(); public: + typedef std::set<LLFolderViewItem*> selected_items_t; + LLInventoryModel* getModel() { return mInventory; } LLFolderViewModelInventory& getRootViewModel() { return mInventoryViewModel; } @@ -151,7 +157,7 @@ public: void draw(); /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask ); BOOL handleHover(S32 x, S32 y, MASK mask); - BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, @@ -168,6 +174,8 @@ public: void setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus); void setSelectCallback(const boost::function<void (const std::deque<LLFolderViewItem*>& items, BOOL user_action)>& cb); void clearSelection(); + selected_items_t getSelectedItems() const; + bool isSelectionRemovable(); LLInventoryFilter& getFilter(); const LLInventoryFilter& getFilter() const; @@ -176,8 +184,9 @@ public: U32 getFilterObjectTypes() const; void setFilterPermMask(PermissionMask filter_perm_mask); U32 getFilterPermMask() const; - void setFilterWearableTypes(U64 filter); - void setFilterSubString(const std::string& string); + void setFilterWearableTypes(U64 filter); + void setFilterSettingsTypes(U64 filter); + void setFilterSubString(const std::string& string); const std::string getFilterSubString(); void setSinceLogoff(BOOL sl); void setHoursAgo(U32 hours); @@ -236,6 +245,8 @@ public: void setSelectionByID(const LLUUID& obj_id, BOOL take_keyboard_focus); void updateSelection(); + void setSuppressOpenItemAction(bool supress_open_item) { mSuppressOpenItemAction = supress_open_item; } + LLFolderViewModelInventory* getFolderViewModel() { return &mInventoryViewModel; } const LLFolderViewModelInventory* getFolderViewModel() const { return &mInventoryViewModel; } @@ -254,8 +265,11 @@ protected: LLInvPanelComplObserver* mCompletionObserver; bool mAcceptsDragAndDrop; bool mAllowMultiSelect; + bool mAllowDrag; bool mShowItemLinkOverlays; // Shows link graphic over inventory item icons bool mShowEmptyMessage; + bool mSuppressFolderMenu; + bool mSuppressOpenItemAction; LLHandle<LLFolderView> mFolderRoot; LLScrollContainer* mScroller; @@ -311,7 +325,9 @@ protected: static LLUIColor sLibraryColor; static LLUIColor sLinkColor; - LLFolderViewItem* buildNewViews(const LLUUID& id); + virtual LLFolderViewItem* buildNewViews(const LLUUID& id); + LLFolderViewItem* buildNewViews(const LLUUID& id, LLInventoryObject const* objectp); + virtual void itemChanged(const LLUUID& item_id, U32 mask, const LLInventoryObject* model_item); BOOL getIsHiddenFolderType(LLFolderType::EType folder_type) const; virtual LLFolderView * createFolderRoot(LLUUID root_id ); diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 59e14e6cc0..7fcd6f4361 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -48,7 +48,7 @@ static LLDefaultChildRegistry::Register<LLJoystickAgentSlide> r1("joystick_slide static LLDefaultChildRegistry::Register<LLJoystickAgentTurn> r2("joystick_turn"); static LLDefaultChildRegistry::Register<LLJoystickCameraRotate> r3("joystick_rotate"); static LLDefaultChildRegistry::Register<LLJoystickCameraTrack> r5("joystick_track"); - +static LLDefaultChildRegistry::Register<LLJoystickQuaternion> r6("joystick_quat"); const F32 NUDGE_TIME = 0.25f; // in seconds @@ -646,3 +646,238 @@ void LLJoystickCameraTrack::onHeldDown() gAgentCamera.setPanDownKey(getOrbitRate()); } } + +//------------------------------------------------------------------------------- +// LLJoystickQuaternion +//------------------------------------------------------------------------------- + +LLJoystickQuaternion::Params::Params() +{ +} + +LLJoystickQuaternion::LLJoystickQuaternion(const LLJoystickQuaternion::Params &p): + LLJoystick(p), + mInLeft(false), + mInTop(false), + mInRight(false), + mInBottom(false), + mVectorZero(0.0f, 0.0f, 1.0f), + mRotation(), + mUpDnAxis(1.0f, 0.0f, 0.0f), + mLfRtAxis(0.0f, 0.0f, 1.0f), + mXAxisIndex(2), // left & right across the control + mYAxisIndex(0), // up & down across the control + mZAxisIndex(1) // tested for above and below +{ + for (int i = 0; i < 3; ++i) + { + mLfRtAxis.mV[i] = (mXAxisIndex == i) ? 1.0 : 0.0; + mUpDnAxis.mV[i] = (mYAxisIndex == i) ? 1.0 : 0.0; + } +} + +void LLJoystickQuaternion::setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom) +{ + mInLeft = left; + mInTop = top; + mInRight = right; + mInBottom = bottom; +} + +BOOL LLJoystickQuaternion::handleMouseDown(S32 x, S32 y, MASK mask) +{ + updateSlop(); + + // Set initial offset based on initial click location + S32 horiz_center = getRect().getWidth() / 2; + S32 vert_center = getRect().getHeight() / 2; + + S32 dx = x - horiz_center; + S32 dy = y - vert_center; + + if (dy > dx && dy > -dx) + { + // top + mInitialOffset.mX = 0; + mInitialOffset.mY = (mVertSlopNear + mVertSlopFar) / 2; + mInitialQuadrant = JQ_UP; + } + else if (dy > dx && dy <= -dx) + { + // left + mInitialOffset.mX = -(mHorizSlopNear + mHorizSlopFar) / 2; + mInitialOffset.mY = 0; + mInitialQuadrant = JQ_LEFT; + } + else if (dy <= dx && dy <= -dx) + { + // bottom + mInitialOffset.mX = 0; + mInitialOffset.mY = -(mVertSlopNear + mVertSlopFar) / 2; + mInitialQuadrant = JQ_DOWN; + } + else + { + // right + mInitialOffset.mX = (mHorizSlopNear + mHorizSlopFar) / 2; + mInitialOffset.mY = 0; + mInitialQuadrant = JQ_RIGHT; + } + + return LLJoystick::handleMouseDown(x, y, mask); +} + +BOOL LLJoystickQuaternion::handleMouseUp(S32 x, S32 y, MASK mask) +{ + return LLJoystick::handleMouseUp(x, y, mask); +} + +void LLJoystickQuaternion::onHeldDown() +{ + LLVector3 axis; + updateSlop(); + + S32 dx = mLastMouse.mX - mFirstMouse.mX + mInitialOffset.mX; + S32 dy = mLastMouse.mY - mFirstMouse.mY + mInitialOffset.mY; + + // left-right rotation + if (dx > mHorizSlopNear) + { + axis += mUpDnAxis; + } + else if (dx < -mHorizSlopNear) + { + axis -= mUpDnAxis; + } + + // over/under rotation + if (dy > mVertSlopNear) + { + axis += mLfRtAxis; + } + else if (dy < -mVertSlopNear) + { + axis -= mLfRtAxis; + } + + if (axis.isNull()) + return; + + axis.normalize(); + + LLQuaternion delta; + delta.setAngleAxis(0.0523599f, axis); // about 3deg + + mRotation *= delta; + setValue(mRotation.getValue()); + onCommit(); +} + +void LLJoystickQuaternion::draw() +{ + LLGLSUIDefault gls_ui; + + getImageUnselected()->draw(0, 0); + LLPointer<LLUIImage> image = getImageSelected(); + + if (mInTop) + { + drawRotatedImage(getImageSelected(), 0); + } + + if (mInRight) + { + drawRotatedImage(getImageSelected(), 1); + } + + if (mInBottom) + { + drawRotatedImage(getImageSelected(), 2); + } + + if (mInLeft) + { + drawRotatedImage(getImageSelected(), 3); + } + + LLVector3 draw_point = mVectorZero * mRotation; + S32 halfwidth = getRect().getWidth() / 2; + S32 halfheight = getRect().getHeight() / 2; + draw_point.mV[mXAxisIndex] = (draw_point.mV[mXAxisIndex] + 1.0) * halfwidth; + draw_point.mV[mYAxisIndex] = (draw_point.mV[mYAxisIndex] + 1.0) * halfheight; + + gl_circle_2d(draw_point.mV[mXAxisIndex], draw_point.mV[mYAxisIndex], 4, 8, + draw_point.mV[mZAxisIndex] >= 0.f); + +} + +F32 LLJoystickQuaternion::getOrbitRate() +{ + return 1; +} + +void LLJoystickQuaternion::updateSlop() +{ + // small fixed slop region + mVertSlopNear = 16; + mVertSlopFar = 32; + + mHorizSlopNear = 16; + mHorizSlopFar = 32; +} + +void LLJoystickQuaternion::drawRotatedImage(LLPointer<LLUIImage> image, S32 rotations) +{ + S32 width = image->getWidth(); + S32 height = image->getHeight(); + LLTexture* texture = image->getImage(); + + /* + * Scale texture coordinate system + * to handle the different between image size and size of texture. + */ + F32 uv[][2] = + { + { (F32)width / texture->getWidth(), (F32)height / texture->getHeight() }, + { 0.f, (F32)height / texture->getHeight() }, + { 0.f, 0.f }, + { (F32)width / texture->getWidth(), 0.f } + }; + + gGL.getTexUnit(0)->bind(texture); + + gGL.color4fv(UI_VERTEX_COLOR.mV); + + gGL.begin(LLRender::QUADS); + { + gGL.texCoord2fv(uv[(rotations + 0) % 4]); + gGL.vertex2i(width, height); + + gGL.texCoord2fv(uv[(rotations + 1) % 4]); + gGL.vertex2i(0, height); + + gGL.texCoord2fv(uv[(rotations + 2) % 4]); + gGL.vertex2i(0, 0); + + gGL.texCoord2fv(uv[(rotations + 3) % 4]); + gGL.vertex2i(width, 0); + } + gGL.end(); +} + +void LLJoystickQuaternion::setRotation(const LLQuaternion &value) +{ + if (value != mRotation) + { + mRotation = value; + mRotation.normalize(); + LLJoystick::setValue(mRotation.getValue()); + } +} + +LLQuaternion LLJoystickQuaternion::getRotation() const +{ + return mRotation; +} + + diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index 4e6c774cad..ee66088b56 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -30,6 +30,7 @@ #include "llbutton.h" #include "llcoord.h" #include "llviewertexture.h" +#include "llquaternion.h" typedef enum e_joystick_quadrant { @@ -178,4 +179,47 @@ public: virtual void onHeldDown(); }; +// +class LLJoystickQuaternion : + public LLJoystick +{ +public: + struct Params : + public LLInitParam::Block<Params, LLJoystick::Params> + { + Params(); + }; + + LLJoystickQuaternion(const LLJoystickQuaternion::Params &); + + virtual void setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom); + + virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); + virtual void onHeldDown(); + virtual void draw(); + + void setRotation(const LLQuaternion &value); + LLQuaternion getRotation() const; + +protected: + F32 getOrbitRate(); + virtual void updateSlop(); + void drawRotatedImage(LLPointer<LLUIImage> image, S32 rotations); + + BOOL mInLeft; + BOOL mInTop; + BOOL mInRight; + BOOL mInBottom; + + S32 mXAxisIndex; + S32 mYAxisIndex; + S32 mZAxisIndex; + + LLVector3 mVectorZero; + LLQuaternion mRotation; + LLVector3 mUpDnAxis; + LLVector3 mLfRtAxis; +}; + #endif // LL_LLJOYSTICKBUTTON_H diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp index 9c00243f44..c243f8b4f0 100644 --- a/indra/newview/lllandmarkactions.cpp +++ b/indra/newview/lllandmarkactions.cpp @@ -272,7 +272,7 @@ void LLLandmarkActions::createLandmarkHere( name, desc, LLAssetType::AT_LANDMARK, LLInventoryType::IT_LANDMARK, - NOT_WEARABLE, PERM_ALL, + NO_INV_SUBTYPE, PERM_ALL, NULL); } diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp new file mode 100644 index 0000000000..017c21df39 --- /dev/null +++ b/indra/newview/lllegacyatmospherics.cpp @@ -0,0 +1,676 @@ +/** + * @file lllegacyatmospherics.cpp + * @brief LLAtmospherics class implementation + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lllegacyatmospherics.h" + +#include "llfeaturemanager.h" +#include "llviewercontrol.h" +#include "llframetimer.h" + +#include "llagent.h" +#include "llagentcamera.h" +#include "lldrawable.h" +#include "llface.h" +#include "llglheaders.h" +#include "llsky.h" +#include "llviewercamera.h" +#include "llviewertexturelist.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" +#include "llworld.h" +#include "pipeline.h" +#include "v3colorutil.h" + +#include "llsettingssky.h" +#include "llenvironment.h" +#include "lldrawpoolwater.h" + +class LLFastLn +{ +public: + LLFastLn() + { + mTable[0] = 0; + for( S32 i = 1; i < 257; i++ ) + { + mTable[i] = log((F32)i); + } + } + + F32 ln( F32 x ) + { + const F32 OO_255 = 0.003921568627450980392156862745098f; + const F32 LN_255 = 5.5412635451584261462455391880218f; + + if( x < OO_255 ) + { + return log(x); + } + else + if( x < 1 ) + { + x *= 255.f; + S32 index = llfloor(x); + F32 t = x - index; + F32 low = mTable[index]; + F32 high = mTable[index + 1]; + return low + t * (high - low) - LN_255; + } + else + if( x <= 255 ) + { + S32 index = llfloor(x); + F32 t = x - index; + F32 low = mTable[index]; + F32 high = mTable[index + 1]; + return low + t * (high - low); + } + else + { + return log( x ); + } + } + + F32 pow( F32 x, F32 y ) + { + return (F32)LL_FAST_EXP(y * ln(x)); + } + + +private: + F32 mTable[257]; // index 0 is unused +}; + +static LLFastLn gFastLn; + + +// Functions used a lot. + +inline F32 LLHaze::calcPhase(const F32 cos_theta) const +{ + const F32 g2 = mG * mG; + const F32 den = 1 + g2 - 2 * mG * cos_theta; + return (1 - g2) * gFastLn.pow(den, -1.5); +} + +inline void color_pow(LLColor3 &col, const F32 e) +{ + col.mV[0] = gFastLn.pow(col.mV[0], e); + col.mV[1] = gFastLn.pow(col.mV[1], e); + col.mV[2] = gFastLn.pow(col.mV[2], e); +} + +inline LLColor3 color_norm(const LLColor3 &col) +{ + const F32 m = color_max(col); + if (m > 1.f) + { + return 1.f/m * col; + } + else return col; +} + +inline void color_gamma_correct(LLColor3 &col) +{ + const F32 gamma_inv = 1.f/1.2f; + if (col.mV[0] != 0.f) + { + col.mV[0] = gFastLn.pow(col.mV[0], gamma_inv); + } + if (col.mV[1] != 0.f) + { + col.mV[1] = gFastLn.pow(col.mV[1], gamma_inv); + } + if (col.mV[2] != 0.f) + { + col.mV[2] = gFastLn.pow(col.mV[2], gamma_inv); + } +} + +static LLColor3 calc_air_sca_sea_level() +{ + static LLColor3 WAVE_LEN(675, 520, 445); + static LLColor3 refr_ind = refr_ind_calc(WAVE_LEN); + static LLColor3 n21 = refr_ind * refr_ind - LLColor3(1, 1, 1); + static LLColor3 n4 = n21 * n21; + static LLColor3 wl2 = WAVE_LEN * WAVE_LEN * 1e-6f; + static LLColor3 wl4 = wl2 * wl2; + static LLColor3 mult_const = fsigma * 2.0f/ 3.0f * 1e24f * (F_PI * F_PI) * n4; + static F32 dens_div_N = F32( ATM_SEA_LEVEL_NDENS / Ndens2); + return dens_div_N * mult_const.divide(wl4); +} + +// static constants. +LLColor3 const LLHaze::sAirScaSeaLevel = calc_air_sca_sea_level(); +F32 const LLHaze::sAirScaIntense = color_intens(LLHaze::sAirScaSeaLevel); +F32 const LLHaze::sAirScaAvg = LLHaze::sAirScaIntense / 3.f; + +/*************************************** + Atmospherics +***************************************/ + +LLAtmospherics::LLAtmospherics() +: mCloudDensity(0.2f), + mWind(0.f), + mWorldScale(1.f) +{ + /// WL PARAMS + mInitialized = FALSE; + mUpdateTimer.reset(); + mAmbientScale = gSavedSettings.getF32("SkyAmbientScale"); + mNightColorShift = gSavedSettings.getColor3("SkyNightColorShift"); + mFogColor.mV[VRED] = mFogColor.mV[VGREEN] = mFogColor.mV[VBLUE] = 0.5f; + mFogColor.mV[VALPHA] = 0.0f; + mFogRatio = 1.2f; + mHazeConcentration = 0.f; + mInterpVal = 0.f; +} + + +LLAtmospherics::~LLAtmospherics() +{ +} + +void LLAtmospherics::init() +{ + const F32 haze_int = color_intens(mHaze.calcSigSca(0)); + mHazeConcentration = haze_int / (color_intens(mHaze.calcAirSca(0)) + haze_int); + mInitialized = true; +} + +LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) +{ + F32 saturation = 0.3f; + if (dir.mV[VZ] < -0.02f) + { + LLColor4 col = LLColor4(llmax(mFogColor[0],0.2f), llmax(mFogColor[1],0.2f), llmax(mFogColor[2],0.22f),0.f); + if (isShiny) + { + LLColor3 desat_fog = LLColor3(mFogColor); + F32 brightness = desat_fog.brightness(); + // So that shiny somewhat shows up at night. + if (brightness < 0.15f) + { + brightness = 0.15f; + desat_fog = smear(0.15f); + } + LLColor3 greyscale = smear(brightness); + desat_fog = desat_fog * saturation + greyscale * (1.0f - saturation); + if (!gPipeline.canUseWindLightShaders()) + { + col = LLColor4(desat_fog, 0.f); + } + else + { + col = LLColor4(desat_fog * 0.5f, 0.f); + } + } + float x = 1.0f-fabsf(-0.1f-dir.mV[VZ]); + x *= x; + col.mV[0] *= x*x; + col.mV[1] *= powf(x, 2.5f); + col.mV[2] *= x*x*x; + return col; + } + + // undo OGL_TO_CFR_ROTATION and negate vertical direction. + LLVector3 Pn = LLVector3(-dir[1] , -dir[2], -dir[0]); + + calcSkyColorWLVert(Pn, vars); + + LLColor3 sky_color = calcSkyColorWLFrag(Pn, vars); + if (isShiny) + { + F32 brightness = sky_color.brightness(); + LLColor3 greyscale = smear(brightness); + sky_color = sky_color * saturation + greyscale * (1.0f - saturation); + sky_color *= (0.5f + 0.5f * brightness); + } + return LLColor4(sky_color, 0.0f); +} + +void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) +{ +// LEGACY_ATMOSPHERICS + //LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor3 blue_density = vars.blue_density; + LLColor3 blue_horizon = vars.blue_horizon; + F32 haze_horizon = vars.haze_horizon; + F32 haze_density = vars.haze_density; + F32 density_multiplier = vars.density_multiplier; + //F32 distance_multiplier = vars.distance_multiplier; + F32 max_y = vars.max_y; + LLVector4 sun_norm = vars.sun_norm; + + // project the direction ray onto the sky dome. + F32 phi = acos(Pn[1]); + F32 sinA = sin(F_PI - phi); + if (fabsf(sinA) < 0.01f) + { //avoid division by zero + sinA = 0.01f; + } + + F32 Plen = vars.dome_radius * sin(F_PI + phi + asin(vars.dome_offset * sinA)) / sinA; + + Pn *= Plen; + + vars.horizontalProjection[0] = LLVector2(Pn[0], Pn[2]); + vars.horizontalProjection[0] /= - 2.f * Plen; + + // Set altitude + if (Pn[1] > 0.f) + { + Pn *= (max_y / Pn[1]); + } + else + { + Pn *= (-32000.f / Pn[1]); + } + + Plen = Pn.length(); + Pn /= Plen; + + // Initialize temp variables + LLColor3 sunlight = vars.sunlight; + LLColor3 ambient = vars.ambient; + + LLColor3 glow = vars.glow; + F32 cloud_shadow = vars.cloud_shadow; + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + LLColor3 light_atten = vars.light_atten; + + // Calculate relative weights + LLColor3 temp2(0.f, 0.f, 0.f); + LLColor3 temp1 = vars.light_transmittance; + + LLColor3 blue_weight = componentDiv(blue_density, temp1); + LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + sun_norm[1] ); + + temp2.mV[1] = 1.f / temp2.mV[1]; + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + + // Distance + temp2.mV[2] = Plen * density_multiplier; + + // Transparency (-> temp1) + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);// * distance_multiplier); + + + // Compute haze glow + temp2.mV[0] = Pn * LLVector3(sun_norm); + + temp2.mV[0] = 1.f - temp2.mV[0]; + // temp2.x is 0 at the sun and increases away from sun + temp2.mV[0] = llmax(temp2.mV[0], .001f); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + + if (glow.mV[0] > 0) // don't pow(zero,negative value), glow from 0 to 2 + { + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.mV[0] *= glow.mV[0]; + } + else + { + temp2.mV[0] = F32_MIN; + } + + temp2.mV[0] = pow(temp2.mV[0], glow.mV[2]); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // Add "minimum anti-solar illumination" + temp2.mV[0] += .25f; + + + // Haze color above cloud + vars.hazeColor = (blue_horizon * blue_weight * (sunlight + ambient) + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + ambient)); + + // Increase ambient when there are more clouds + LLColor3 tmpAmbient = ambient + (LLColor3::white - ambient) * cloud_shadow * 0.5f; + + // Dim sunlight by cloud shadow percentage + sunlight *= (1.f - cloud_shadow); + + // Haze color below cloud + vars.hazeColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + tmpAmbient)); + + // Final atmosphere additive + componentMultBy(vars.hazeColor, LLColor3::white - temp1); + + sunlight = vars.sunlight; + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, sun_norm[1] * 2.f); + temp2.mV[1] = 1.f / temp2.mV[1]; + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + + // Attenuate cloud color by atmosphere + temp1 = componentSqrt(temp1); //less atmos opacity (more transparency) below clouds + + // At horizon, blend high altitude sky color towards the darker color below the clouds + vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1)); + + if (Pn[1] < 0.f) + { + // Eric's original: + // LLColor3 dark_brown(0.143f, 0.129f, 0.114f); + LLColor3 dark_brown(0.082f, 0.076f, 0.066f); + LLColor3 brown(0.430f, 0.386f, 0.322f); + LLColor3 sky_lighting = sunlight + ambient; + F32 haze_brightness = vars.hazeColor.brightness(); + + if (Pn[1] < -0.05f) + { + vars.hazeColor = colorMix(dark_brown, brown, -Pn[1] * 0.9f) * sky_lighting * haze_brightness; + } + + if (Pn[1] > -0.1f) + { + vars.hazeColor = colorMix(LLColor3::white * haze_brightness, vars.hazeColor, fabs((Pn[1] + 0.05f) * -20.f)); + } + } +} + +LLColor3 LLAtmospherics::calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& vars) +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + + LLColor3 res; + LLColor3 color0 = vars.hazeColor; + + if (!gPipeline.canUseWindLightShaders()) + { + res = psky->gammaCorrect(color0 * 2.0f); + } + else + { + res = color0; + } + +#ifndef LL_RELEASE_FOR_DOWNLOAD + F32 gamma = psky->getGamma(); + LLColor3 color2 = 2.f * color0; + LLColor3 color3 = LLColor3(1.f, 1.f, 1.f) - componentSaturate(color2); + componentPow(color3, gamma); + color3 = LLColor3(1.f, 1.f, 1.f) - color3; + + static enum { + OUT_DEFAULT = 0, + OUT_SKY_BLUE = 1, + OUT_RED = 2, + OUT_PN = 3, + OUT_HAZE = 4, + } debugOut = OUT_DEFAULT; + + switch(debugOut) + { + case OUT_DEFAULT: + break; + case OUT_SKY_BLUE: + res = LLColor3(0.4f, 0.4f, 0.9f); + break; + case OUT_RED: + res = LLColor3(1.f, 0.f, 0.f); + break; + case OUT_PN: + res = LLColor3(Pn[0], Pn[1], Pn[2]); + break; + case OUT_HAZE: + res = vars.hazeColor; + break; + } +#endif // LL_RELEASE_FOR_DOWNLOAD + return res; +} + +void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) +{ + LLVector3 tosun = tosun_in; + + if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG)) + { + if (!LLGLSLShader::sNoFixedFunction) + { + glFogf(GL_FOG_DENSITY, 0); + glFogfv(GL_FOG_COLOR, (F32 *) &LLColor4::white.mV); + glFogf(GL_FOG_END, 1000000.f); + } + return; + } + + const BOOL hide_clip_plane = TRUE; + LLColor4 target_fog(0.f, 0.2f, 0.5f, 0.f); + + const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f; + // LLWorld::getInstance()->getWaterHeight(); + F32 camera_height = gAgentCamera.getCameraPositionAgent().mV[2]; + + F32 near_clip_height = LLViewerCamera::getInstance()->getAtAxis().mV[VZ] * LLViewerCamera::getInstance()->getNear(); + camera_height += near_clip_height; + + F32 fog_distance = 0.f; + LLColor3 res_color[3]; + + LLColor3 sky_fog_color = LLColor3::white; + LLColor3 render_fog_color = LLColor3::white; + + const F32 tosun_z = tosun.mV[VZ]; + tosun.mV[VZ] = 0.f; + tosun.normalize(); + LLVector3 perp_tosun; + perp_tosun.mV[VX] = -tosun.mV[VY]; + perp_tosun.mV[VY] = tosun.mV[VX]; + LLVector3 tosun_45 = tosun + perp_tosun; + tosun_45.normalize(); + + F32 delta = 0.06f; + tosun.mV[VZ] = delta; + perp_tosun.mV[VZ] = delta; + tosun_45.mV[VZ] = delta; + tosun.normalize(); + perp_tosun.normalize(); + tosun_45.normalize(); + + // Sky colors, just slightly above the horizon in the direction of the sun, perpendicular to the sun, and at a 45 degree angle to the sun. + AtmosphericsVars vars; + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + // invariants across whole sky tex process... + vars.blue_density = psky->getBlueDensity(); + vars.blue_horizon = psky->getBlueHorizon(); + vars.haze_density = psky->getHazeDensity(); + vars.haze_horizon = psky->getHazeHorizon(); + vars.density_multiplier = psky->getDensityMultiplier(); + vars.distance_multiplier = psky->getDistanceMultiplier(); + vars.max_y = psky->getMaxY(); + vars.sun_norm = LLEnvironment::instance().getClampedSunNorm(); + vars.sunlight = psky->getSunlightColor(); + vars.ambient = psky->getAmbientColor(); + vars.glow = psky->getGlow(); + vars.cloud_shadow = psky->getCloudShadow(); + vars.dome_radius = psky->getDomeRadius(); + vars.dome_offset = psky->getDomeOffset(); + vars.light_atten = psky->getLightAttenuation(vars.max_y); + vars.light_transmittance = psky->getLightTransmittance(); + + res_color[0] = calcSkyColorInDir(vars, tosun); + res_color[1] = calcSkyColorInDir(vars, perp_tosun); + res_color[2] = calcSkyColorInDir(vars, tosun_45); + + sky_fog_color = color_norm(res_color[0] + res_color[1] + res_color[2]); + + F32 full_off = -0.25f; + F32 full_on = 0.00f; + F32 on = (tosun_z - full_off) / (full_on - full_off); + on = llclamp(on, 0.01f, 1.f); + sky_fog_color *= 0.5f * on; + + + // We need to clamp these to non-zero, in order for the gamma correction to work. 0^y = ??? + S32 i; + for (i = 0; i < 3; i++) + { + sky_fog_color.mV[i] = llmax(0.0001f, sky_fog_color.mV[i]); + } + + color_gamma_correct(sky_fog_color); + + render_fog_color = sky_fog_color; + + F32 fog_density = 0.f; + fog_distance = mFogRatio * distance; + + if (camera_height > water_height) + { + LLColor4 fog(render_fog_color); + if (!LLGLSLShader::sNoFixedFunction) + { + glFogfv(GL_FOG_COLOR, fog.mV); + } + mGLFogCol = fog; + + if (hide_clip_plane) + { + // For now, set the density to extend to the cull distance. + const F32 f_log = 2.14596602628934723963618357029f; // sqrt(fabs(log(0.01f))) + fog_density = f_log/fog_distance; + if (!LLGLSLShader::sNoFixedFunction) + { + glFogi(GL_FOG_MODE, GL_EXP2); + } + } + else + { + const F32 f_log = 4.6051701859880913680359829093687f; // fabs(log(0.01f)) + fog_density = (f_log)/fog_distance; + if (!LLGLSLShader::sNoFixedFunction) + { + glFogi(GL_FOG_MODE, GL_EXP); + } + } + } + else + { + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + F32 depth = water_height - camera_height; + + // get the water param manager variables + float water_fog_density = pwater->getModifiedWaterFogDensity(depth <= 0.0f); + + LLColor4 water_fog_color(pwater->getWaterFogColor()); + + // adjust the color based on depth. We're doing linear approximations + float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale"); + float depth_modifier = 1.0f - llmin(llmax(depth / depth_scale, 0.01f), + gSavedSettings.getF32("WaterGLFogDepthFloor")); + + LLColor4 fogCol = water_fog_color * depth_modifier; + fogCol.setAlpha(1); + + // set the gl fog color + mGLFogCol = fogCol; + + // set the density based on what the shaders use + fog_density = water_fog_density * gSavedSettings.getF32("WaterGLFogDensityScale"); + + if (!LLGLSLShader::sNoFixedFunction) + { + glFogfv(GL_FOG_COLOR, (F32 *) &fogCol.mV); + glFogi(GL_FOG_MODE, GL_EXP2); + } + } + + mFogColor = sky_fog_color; + mFogColor.setAlpha(1); + + LLDrawPoolWater::sWaterFogEnd = fog_distance*2.2f; + + if (!LLGLSLShader::sNoFixedFunction) + { + LLGLSFog gls_fog; + glFogf(GL_FOG_END, fog_distance*2.2f); + glFogf(GL_FOG_DENSITY, fog_density); + glHint(GL_FOG_HINT, GL_NICEST); + } + stop_glerror(); +} + +// Functions used a lot. +F32 color_norm_pow(LLColor3& col, F32 e, BOOL postmultiply) +{ + F32 mv = color_max(col); + if (0 == mv) + { + return 0; + } + + col *= 1.f / mv; + color_pow(col, e); + if (postmultiply) + { + col *= mv; + } + return mv; +} + +// Returns angle (RADIANs) between the horizontal projection of "v" and the x_axis. +// Range of output is 0.0f to 2pi //359.99999...f +// Returns 0.0f when "v" = +/- z_axis. +F32 azimuth(const LLVector3 &v) +{ + F32 azimuth = 0.0f; + if (v.mV[VX] == 0.0f) + { + if (v.mV[VY] > 0.0f) + { + azimuth = F_PI * 0.5f; + } + else if (v.mV[VY] < 0.0f) + { + azimuth = F_PI * 1.5f;// 270.f; + } + } + else + { + azimuth = (F32) atan(v.mV[VY] / v.mV[VX]); + if (v.mV[VX] < 0.0f) + { + azimuth += F_PI; + } + else if (v.mV[VY] < 0.0f) + { + azimuth += F_PI * 2; + } + } + return azimuth; +} diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h new file mode 100644 index 0000000000..f2900b4323 --- /dev/null +++ b/indra/newview/lllegacyatmospherics.h @@ -0,0 +1,283 @@ +/** + * @file lllegacyatmospherics.h + * @brief LLVOSky class header file + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLLEGACYATMOSPHERICS_H +#define LL_LLLEGACYATMOSPHERICS_H + +#include "stdtypes.h" +#include "v3color.h" +#include "v4coloru.h" +#include "llviewertexture.h" +#include "llviewerobject.h" +#include "llframetimer.h" +#include "v3colorutil.h" +#include "llsettingssky.h" + +////////////////////////////////// +// +// Lots of constants +// +// Will clean these up at some point... +// + +const F32 HORIZON_DIST = 1024.0f; +const F32 ATM_EXP_FALLOFF = 0.000126f; +const F32 ATM_SEA_LEVEL_NDENS = 2.55e25f; +const F32 ATM_HEIGHT = 100000.f; + +// constants used in calculation of scattering coeff of clear air +const F32 sigma = 0.035f; +const F32 fsigma = (6.f + 3.f * sigma) / (6.f-7.f*sigma); +const F64 Ndens = 2.55e25; +const F64 Ndens2 = Ndens*Ndens; + +class LLFace; +class LLHaze; + +LL_FORCE_INLINE LLColor3 refr_ind_calc(const LLColor3 &wave_length) +{ + LLColor3 refr_ind; + for (S32 i = 0; i < 3; ++i) + { + const F32 wl2 = wave_length.mV[i] * wave_length.mV[i] * 1e-6f; + refr_ind.mV[i] = 6.43e3f + ( 2.95e6f / ( 146.0f - 1.f/wl2 ) ) + ( 2.55e4f / ( 41.0f - 1.f/wl2 ) ); + refr_ind.mV[i] *= 1.0e-8f; + refr_ind.mV[i] += 1.f; + } + return refr_ind; +} + + +class LLHaze +{ +public: + LLHaze() : mG(0), mFalloff(1), mAbsCoef(0.f) {mSigSca.setToBlack();} + LLHaze(const F32 g, const LLColor3& sca, const F32 fo = 2.f) : + mG(g), mSigSca(0.25f/F_PI * sca), mFalloff(fo), mAbsCoef(0.f) + { + mAbsCoef = color_intens(mSigSca) / sAirScaIntense; + } + + LLHaze(const F32 g, const F32 sca, const F32 fo = 2.f) : mG(g), + mSigSca(0.25f/F_PI * LLColor3(sca, sca, sca)), mFalloff(fo) + { + mAbsCoef = 0.01f * sca / sAirScaAvg; + } + +/* Proportion of light that is scattered into 'path' from 'in' over distance dt. */ +/* assumes that vectors 'path' and 'in' are normalized. Scattering coef / 2pi */ + + LL_FORCE_INLINE LLColor3 calcAirSca(const F32 h) + { + return calcFalloff(h) * sAirScaSeaLevel; + } + + LL_FORCE_INLINE void calcAirSca(const F32 h, LLColor3 &result) + { + result = sAirScaSeaLevel; + result *= calcFalloff(h); + } + + F32 getG() const { return mG; } + + void setG(const F32 g) + { + mG = g; + } + + const LLColor3& getSigSca() const // sea level + { + return mSigSca; + } + + void setSigSca(const LLColor3& s) + { + mSigSca = s; + mAbsCoef = 0.01f * color_intens(mSigSca) / sAirScaIntense; + } + + void setSigSca(const F32 s0, const F32 s1, const F32 s2) + { + mSigSca = sAirScaAvg * LLColor3 (s0, s1, s2); + mAbsCoef = 0.01f * (s0 + s1 + s2) / 3; + } + + F32 getFalloff() const + { + return mFalloff; + } + + void setFalloff(const F32 fo) + { + mFalloff = fo; + } + + F32 getAbsCoef() const + { + return mAbsCoef; + } + + inline static F32 calcFalloff(const F32 h) + { + return (h <= 0) ? 1.0f : (F32)LL_FAST_EXP(-ATM_EXP_FALLOFF * h); + } + + inline LLColor3 calcSigSca(const F32 h) const + { + return calcFalloff(h * mFalloff) * mSigSca; + } + + inline void calcSigSca(const F32 h, LLColor3 &result) const + { + result = mSigSca; + result *= calcFalloff(h * mFalloff); + } + + LLColor3 calcSigExt(const F32 h) const + { + return calcFalloff(h * mFalloff) * (1 + mAbsCoef) * mSigSca; + } + + F32 calcPhase(const F32 cos_theta) const; + +private: + static LLColor3 const sAirScaSeaLevel; + static F32 const sAirScaIntense; + static F32 const sAirScaAvg; + +protected: + F32 mG; + LLColor3 mSigSca; + F32 mFalloff; // 1 - slow, >1 - faster + F32 mAbsCoef; +}; + + +class LLCubeMap; + +class AtmosphericsVars +{ +public: + AtmosphericsVars() + : hazeColor(0,0,0) + , hazeColorBelowCloud(0,0,0) + , cloudColorSun(0,0,0) + , cloudColorAmbient(0,0,0) + , cloudDensity(0.0f) + , blue_density() + , blue_horizon() + , haze_density(0.0f) + , haze_horizon(0.0f) + , density_multiplier(0.0f) + , max_y(0.0f) + , gamma(1.0f) + , sun_norm(0.0f, 1.0f, 0.0f, 1.0f) + , sunlight() + , ambient() + , glow() + , cloud_shadow(1.0f) + , dome_radius(1.0f) + , dome_offset(1.0f) + , light_atten() + , light_transmittance() + { + horizontalProjection[0] = LLVector2(0,0); + horizontalProjection[1] = LLVector2(0,0); + } + + LLColor3 hazeColor; + LLColor3 hazeColorBelowCloud; + LLColor3 cloudColorSun; + LLColor3 cloudColorAmbient; + F32 cloudDensity; + LLVector2 horizontalProjection[2]; + LLColor3 blue_density; + LLColor3 blue_horizon; + F32 haze_density; + F32 haze_horizon; + F32 density_multiplier; + F32 distance_multiplier; + F32 max_y; + F32 gamma; + LLVector4 sun_norm; + LLColor3 sunlight; + LLColor3 ambient; + LLColor3 glow; + F32 cloud_shadow; + F32 dome_radius; + F32 dome_offset; + LLColor3 light_atten; + LLColor3 light_transmittance; +}; + +class LLAtmospherics +{ +public: + LLAtmospherics(); + ~LLAtmospherics(); + + void init(); + void updateFog(const F32 distance, const LLVector3& tosun); + + const LLHaze& getHaze() const { return mHaze; } + LLHaze& getHaze() { return mHaze; } + F32 getHazeConcentration() const { return mHazeConcentration; } + void setHaze(const LLHaze& h) { mHaze = h; } + void setFogRatio(const F32 fog_ratio) { mFogRatio = fog_ratio; } + + F32 getFogRatio() const { return mFogRatio; } + LLColor4 getFogColor() const { return mFogColor; } + LLColor4 getGLFogColor() const { return mGLFogCol; } + + void setCloudDensity(F32 cloud_density) { mCloudDensity = cloud_density; } + void setWind ( const LLVector3& wind ) { mWind = wind.length(); } + + LLColor4 calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false); + +protected: + + void calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars); + LLColor3 calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& vars); + LLColor3 getHazeColor(LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, F32 costheta, F32 cloud_shadow); + + LLHaze mHaze; + F32 mHazeConcentration; + F32 mCloudDensity; + F32 mWind; + BOOL mInitialized; + LLVector3 mLastLightingDirection; + LLColor3 mLastTotalAmbient; + F32 mAmbientScale; + LLColor3 mNightColorShift; + F32 mInterpVal; + LLColor4 mFogColor; + LLColor4 mGLFogCol; + F32 mFogRatio; + F32 mWorldScale; + LLFrameTimer mUpdateTimer; +}; + +#endif diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp index 760325b652..47b6da708c 100644 --- a/indra/newview/lllocalbitmaps.cpp +++ b/indra/newview/lllocalbitmaps.cpp @@ -976,6 +976,19 @@ LLUUID LLLocalBitmapMgr::getWorldID(LLUUID tracking_id) return world_id; } +bool LLLocalBitmapMgr::isLocal(const LLUUID world_id) +{ + for (local_list_iter iter = sBitmapList.begin(); iter != sBitmapList.end(); iter++) + { + LLLocalBitmap* unit = *iter; + if (unit->getWorldID() == world_id) + { + return true; + } + } + return false; +} + std::string LLLocalBitmapMgr::getFilename(LLUUID tracking_id) { std::string filename = ""; diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h index ee4161fb45..3b33091fdb 100644 --- a/indra/newview/lllocalbitmaps.h +++ b/indra/newview/lllocalbitmaps.h @@ -123,6 +123,7 @@ class LLLocalBitmapMgr static bool checkTextureDimensions(std::string filename); static LLUUID getWorldID(LLUUID tracking_id); + static bool isLocal(const LLUUID world_id); static std::string getFilename(LLUUID tracking_id); static void feedScrollList(LLScrollListCtrl* ctrl); diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 11bc1425f9..c01a2fbf8a 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -44,7 +44,6 @@ // newview includes #include "llagent.h" -#include "llenvmanager.h" #include "llfloatersidepanelcontainer.h" #include "llinventoryobserver.h" #include "lllandmarkactions.h" diff --git a/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp b/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp index 63d97f6ac2..0663dd41ee 100644 --- a/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp +++ b/indra/newview/llmenuoptionpathfindingrebakenavmesh.cpp @@ -34,7 +34,6 @@ #include <boost/signals2.hpp> #include "llagent.h" -#include "llenvmanager.h" #include "llnotificationsutil.h" #include "llpathfindingmanager.h" #include "llpathfindingnavmesh.h" diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index b2b6de94b3..278d83bab7 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -1215,7 +1215,6 @@ void LLOutfitGallery::uploadOutfitImage(const std::vector<std::string>& filename checkRemovePhoto(outfit_id); std::string upload_pending_name = outfit_id.asString(); std::string upload_pending_desc = ""; - LLAssetStorage::LLStoreAssetCallback callback = NULL; LLUUID photo_id = upload_new_resource(filename, // file upload_pending_name, upload_pending_desc, @@ -1223,7 +1222,7 @@ void LLOutfitGallery::uploadOutfitImage(const std::vector<std::string>& filename LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - upload_pending_name, callback, expected_upload_cost, nruserdata, false); + upload_pending_name, LLAssetStorage::LLStoreAssetCallback(), expected_upload_cost, nruserdata, false); mOutfitLinkPending = outfit_id; } delete unit; diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp new file mode 100644 index 0000000000..fdd365cc92 --- /dev/null +++ b/indra/newview/llpaneleditsky.cpp @@ -0,0 +1,834 @@ +/** +* @file llpaneleditsky.cpp +* @brief Floaters to create and edit fixed settings for sky and water. +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "llpaneleditsky.h" + +#include "llslider.h" +#include "llsliderctrl.h" +#include "lltexturectrl.h" +#include "llcolorswatch.h" +#include "llvirtualtrackball.h" +#include "llsettingssky.h" +#include "llenvironment.h" +#include "llatmosphere.h" + +namespace +{ + // Atmosphere Tab + const std::string FIELD_SKY_AMBIENT_LIGHT("ambient_light"); + const std::string FIELD_SKY_BLUE_HORIZON("blue_horizon"); + const std::string FIELD_SKY_BLUE_DENSITY("blue_density"); + const std::string FIELD_SKY_HAZE_HORIZON("haze_horizon"); + const std::string FIELD_SKY_HAZE_DENSITY("haze_density"); + const std::string FIELD_SKY_SCENE_GAMMA("scene_gamma"); + const std::string FIELD_SKY_DENSITY_MULTIP("density_multip"); + const std::string FIELD_SKY_DISTANCE_MULTIP("distance_multip"); + const std::string FIELD_SKY_MAX_ALT("max_alt"); + + const std::string FIELD_SKY_CLOUD_COLOR("cloud_color"); + const std::string FIELD_SKY_CLOUD_COVERAGE("cloud_coverage"); + const std::string FIELD_SKY_CLOUD_SCALE("cloud_scale"); + const std::string FIELD_SKY_CLOUD_VARIANCE("cloud_variance"); + + const std::string FIELD_SKY_CLOUD_SCROLL_XY("cloud_scroll_xy"); + const std::string FIELD_SKY_CLOUD_MAP("cloud_map"); + const std::string FIELD_SKY_CLOUD_DENSITY_X("cloud_density_x"); + const std::string FIELD_SKY_CLOUD_DENSITY_Y("cloud_density_y"); + const std::string FIELD_SKY_CLOUD_DENSITY_D("cloud_density_d"); + const std::string FIELD_SKY_CLOUD_DETAIL_X("cloud_detail_x"); + const std::string FIELD_SKY_CLOUD_DETAIL_Y("cloud_detail_y"); + const std::string FIELD_SKY_CLOUD_DETAIL_D("cloud_detail_d"); + + const std::string FIELD_SKY_SUN_MOON_COLOR("sun_moon_color"); + const std::string FIELD_SKY_GLOW_FOCUS("glow_focus"); + const std::string FIELD_SKY_GLOW_SIZE("glow_size"); + const std::string FIELD_SKY_STAR_BRIGHTNESS("star_brightness"); + const std::string FIELD_SKY_SUN_ROTATION("sun_rotation"); + const std::string FIELD_SKY_SUN_IMAGE("sun_image"); + const std::string FIELD_SKY_SUN_SCALE("sun_scale"); + const std::string FIELD_SKY_MOON_ROTATION("moon_rotation"); + const std::string FIELD_SKY_MOON_IMAGE("moon_image"); + const std::string FIELD_SKY_MOON_SCALE("moon_scale"); + const std::string FIELD_SKY_MOON_BRIGHTNESS("moon_brightness"); + + const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL("rayleigh_exponential"); + const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE("rayleigh_exponential_scale"); + const std::string FIELD_SKY_DENSITY_RAYLEIGH_LINEAR("rayleigh_linear"); + const std::string FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT("rayleigh_constant"); + const std::string FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE("rayleigh_max_altitude"); + + const std::string FIELD_SKY_DENSITY_MIE_EXPONENTIAL("mie_exponential"); + const std::string FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE("mie_exponential_scale"); + const std::string FIELD_SKY_DENSITY_MIE_LINEAR("mie_linear"); + const std::string FIELD_SKY_DENSITY_MIE_CONSTANT("mie_constant"); + const std::string FIELD_SKY_DENSITY_MIE_ANISO("mie_aniso_factor"); + const std::string FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE("mie_max_altitude"); + + const std::string FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL("absorption_exponential"); + const std::string FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE("absorption_exponential_scale"); + const std::string FIELD_SKY_DENSITY_ABSORPTION_LINEAR("absorption_linear"); + const std::string FIELD_SKY_DENSITY_ABSORPTION_CONSTANT("absorption_constant"); + const std::string FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE("absorption_max_altitude"); + + const std::string FIELD_SKY_DENSITY_MOISTURE_LEVEL("moisture_level"); + const std::string FIELD_SKY_DENSITY_DROPLET_RADIUS("droplet_radius"); + const std::string FIELD_SKY_DENSITY_ICE_LEVEL("ice_level"); + + const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f); + const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); + const F32 SLIDER_SCALE_GLOW_R(20.0f); + const F32 SLIDER_SCALE_GLOW_B(-5.0f); + const F32 SLIDER_SCALE_DENSITY_MULTIPLIER(0.001f); +} + +static LLPanelInjector<LLPanelSettingsSkyAtmosTab> t_settings_atmos("panel_settings_atmos"); +static LLPanelInjector<LLPanelSettingsSkyCloudTab> t_settings_cloud("panel_settings_cloud"); +static LLPanelInjector<LLPanelSettingsSkySunMoonTab> t_settings_sunmoon("panel_settings_sunmoon"); +static LLPanelInjector<LLPanelSettingsSkyDensityTab> t_settings_density("panel_settings_density"); + +//========================================================================== +LLPanelSettingsSky::LLPanelSettingsSky() : + LLSettingsEditPanel(), + mSkySettings() +{ + +} + + +//========================================================================== +LLPanelSettingsSkyAtmosTab::LLPanelSettingsSkyAtmosTab() : + LLPanelSettingsSky() +{ +} + + +BOOL LLPanelSettingsSkyAtmosTab::postBuild() +{ + getChild<LLUICtrl>(FIELD_SKY_AMBIENT_LIGHT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAmbientLightChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_BLUE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueHorizonChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_BLUE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueDensityChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeHorizonChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeDensityChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSceneGammaChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDensityMultipChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DISTANCE_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDistanceMultipChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_MAX_ALT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMaxAltChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoistureLevelChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDropletRadiusChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ICE_LEVEL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onIceLevelChanged(); }); + refresh(); + + return TRUE; +} + +//virtual +void LLPanelSettingsSkyAtmosTab::setEnabled(BOOL enabled) +{ + LLPanelSettingsSky::setEnabled(enabled); + + // Make sure we have initialized children (initialized) + if (getFirstChild()) + { + getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MULTIP)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DISTANCE_MULTIP)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_MAX_ALT)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ICE_LEVEL)->setEnabled(enabled); + } +} + +void LLPanelSettingsSkyAtmosTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + getChild<LLColorSwatchCtrl>(FIELD_SKY_AMBIENT_LIGHT)->set(mSkySettings->getAmbientColor() / SLIDER_SCALE_SUN_AMBIENT); + getChild<LLColorSwatchCtrl>(FIELD_SKY_BLUE_HORIZON)->set(mSkySettings->getBlueHorizon() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); + getChild<LLColorSwatchCtrl>(FIELD_SKY_BLUE_DENSITY)->set(mSkySettings->getBlueDensity() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); + + getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->setValue(mSkySettings->getHazeHorizon()); + getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->setValue(mSkySettings->getHazeDensity()); + getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->setValue(mSkySettings->getGamma()); + F32 density_mult = mSkySettings->getDensityMultiplier(); + density_mult /= SLIDER_SCALE_DENSITY_MULTIPLIER; + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MULTIP)->setValue(density_mult); + getChild<LLUICtrl>(FIELD_SKY_DISTANCE_MULTIP)->setValue(mSkySettings->getDistanceMultiplier()); + getChild<LLUICtrl>(FIELD_SKY_MAX_ALT)->setValue(mSkySettings->getMaxY()); + + F32 moisture_level = mSkySettings->getSkyMoistureLevel(); + F32 droplet_radius = mSkySettings->getSkyDropletRadius(); + F32 ice_level = mSkySettings->getSkyIceLevel(); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setValue(moisture_level); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setValue(droplet_radius); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ICE_LEVEL)->setValue(ice_level); +} + +//------------------------------------------------------------------------- +void LLPanelSettingsSkyAtmosTab::onAmbientLightChanged() +{ + mSkySettings->setAmbientColor(LLColor3(getChild<LLColorSwatchCtrl>(FIELD_SKY_AMBIENT_LIGHT)->get() * SLIDER_SCALE_SUN_AMBIENT)); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onBlueHorizonChanged() +{ + mSkySettings->setBlueHorizon(LLColor3(getChild<LLColorSwatchCtrl>(FIELD_SKY_BLUE_HORIZON)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onBlueDensityChanged() +{ + mSkySettings->setBlueDensity(LLColor3(getChild<LLColorSwatchCtrl>(FIELD_SKY_BLUE_DENSITY)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onHazeHorizonChanged() +{ + mSkySettings->setHazeHorizon(getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onHazeDensityChanged() +{ + mSkySettings->setHazeDensity(getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onSceneGammaChanged() +{ + mSkySettings->setGamma(getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onDensityMultipChanged() +{ + F32 density_mult = getChild<LLUICtrl>(FIELD_SKY_DENSITY_MULTIP)->getValue().asReal(); + density_mult *= SLIDER_SCALE_DENSITY_MULTIPLIER; + mSkySettings->setDensityMultiplier(density_mult); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onDistanceMultipChanged() +{ + mSkySettings->setDistanceMultiplier(getChild<LLUICtrl>(FIELD_SKY_DISTANCE_MULTIP)->getValue().asReal()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onMaxAltChanged() +{ + mSkySettings->setMaxY(getChild<LLUICtrl>(FIELD_SKY_MAX_ALT)->getValue().asReal()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onMoistureLevelChanged() +{ + F32 moisture_level = getChild<LLUICtrl>(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->getValue().asReal(); + mSkySettings->setSkyMoistureLevel(moisture_level); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onDropletRadiusChanged() +{ + F32 droplet_radius = getChild<LLUICtrl>(FIELD_SKY_DENSITY_DROPLET_RADIUS)->getValue().asReal(); + mSkySettings->setSkyDropletRadius(droplet_radius); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyAtmosTab::onIceLevelChanged() +{ + F32 ice_level = getChild<LLUICtrl>(FIELD_SKY_DENSITY_ICE_LEVEL)->getValue().asReal(); + mSkySettings->setSkyIceLevel(ice_level); + mSkySettings->update(); + setIsDirty(); +} + +//========================================================================== +LLPanelSettingsSkyCloudTab::LLPanelSettingsSkyCloudTab() : + LLPanelSettingsSky() +{ +} + +BOOL LLPanelSettingsSkyCloudTab::postBuild() +{ + getChild<LLUICtrl>(FIELD_SKY_CLOUD_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudColorChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudCoverageChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScaleChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudVarianceChanged(); }); + + getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCROLL_XY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScrollChanged(); }); + getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudMapChanged(); }); + getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->setDefaultImageAssetID(LLSettingsSky::GetDefaultCloudNoiseTextureId()); + getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->setAllowNoTexture(TRUE); + + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_D)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_D)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); + + refresh(); + + return TRUE; +} + +//virtual +void LLPanelSettingsSkyCloudTab::setEnabled(BOOL enabled) +{ + LLPanelSettingsSky::setEnabled(enabled); + + // Make sure we have children (initialized) + if (getFirstChild()) + { + getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_X)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_Y)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_D)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_X)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_Y)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_D)->setEnabled(enabled); + } +} + +void LLPanelSettingsSkyCloudTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + getChild<LLColorSwatchCtrl>(FIELD_SKY_CLOUD_COLOR)->set(mSkySettings->getCloudColor()); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->setValue(mSkySettings->getCloudShadow()); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->setValue(mSkySettings->getCloudScale()); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->setValue(mSkySettings->getCloudVariance()); + + LLVector2 cloudScroll(mSkySettings->getCloudScrollRate()); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCROLL_XY)->setValue(cloudScroll.getValue()); + + getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->setValue(mSkySettings->getCloudNoiseTextureId()); + + LLVector3 cloudDensity(mSkySettings->getCloudPosDensity1().getValue()); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_X)->setValue(cloudDensity[0]); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_Y)->setValue(cloudDensity[1]); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_D)->setValue(cloudDensity[2]); + + LLVector3 cloudDetail(mSkySettings->getCloudPosDensity2().getValue()); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_X)->setValue(cloudDetail[0]); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_Y)->setValue(cloudDetail[1]); + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_D)->setValue(cloudDetail[2]); +} + +//------------------------------------------------------------------------- +void LLPanelSettingsSkyCloudTab::onCloudColorChanged() +{ + mSkySettings->setCloudColor(LLColor3(getChild<LLColorSwatchCtrl>(FIELD_SKY_CLOUD_COLOR)->get())); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyCloudTab::onCloudCoverageChanged() +{ + mSkySettings->setCloudShadow(getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkyCloudTab::onCloudScaleChanged() +{ + mSkySettings->setCloudScale(getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsSkyCloudTab::onCloudVarianceChanged() +{ + mSkySettings->setCloudVariance(getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsSkyCloudTab::onCloudScrollChanged() +{ + LLVector2 scroll(getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCROLL_XY)->getValue()); + mSkySettings->setCloudScrollRate(scroll); + setIsDirty(); +} + +void LLPanelSettingsSkyCloudTab::onCloudMapChanged() +{ + LLTextureCtrl* ctrl = getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP); + mSkySettings->setCloudNoiseTextureId(ctrl->getValue().asUUID()); + setIsDirty(); +} + +void LLPanelSettingsSkyCloudTab::onCloudDensityChanged() +{ + LLColor3 density(getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_X)->getValue().asReal(), + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_Y)->getValue().asReal(), + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_D)->getValue().asReal()); + + mSkySettings->setCloudPosDensity1(density); + setIsDirty(); +} + +void LLPanelSettingsSkyCloudTab::onCloudDetailChanged() +{ + LLColor3 detail(getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_X)->getValue().asReal(), + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_Y)->getValue().asReal(), + getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_D)->getValue().asReal()); + + mSkySettings->setCloudPosDensity2(detail); + setIsDirty(); +} + +//========================================================================== +LLPanelSettingsSkySunMoonTab::LLPanelSettingsSkySunMoonTab() : + LLPanelSettingsSky() +{ +} + + +BOOL LLPanelSettingsSkySunMoonTab::postBuild() +{ + getChild<LLUICtrl>(FIELD_SKY_SUN_MOON_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunMoonColorChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onStarBrightnessChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_SUN_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunRotationChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_SUN_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunImageChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunScaleChanged(); }); + getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetBlankSunTextureId()); + getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetBlankSunTextureId()); + getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setAllowNoTexture(TRUE); + getChild<LLUICtrl>(FIELD_SKY_MOON_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonRotationChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_MOON_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonImageChanged(); }); + getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetDefaultMoonTextureId()); + getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetDefaultMoonTextureId()); + getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setAllowNoTexture(TRUE); + getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonScaleChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonBrightnessChanged(); }); + + refresh(); + + return TRUE; +} + +//virtual +void LLPanelSettingsSkySunMoonTab::setEnabled(BOOL enabled) +{ + LLPanelSettingsSky::setEnabled(enabled); + + // Make sure we have children + if (getFirstChild()) + { + getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setEnabled(enabled); + } +} + +void LLPanelSettingsSkySunMoonTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + getChild<LLColorSwatchCtrl>(FIELD_SKY_SUN_MOON_COLOR)->set(mSkySettings->getSunlightColor() / SLIDER_SCALE_SUN_AMBIENT); + + LLColor3 glow(mSkySettings->getGlow()); + + // takes 40 - 0.2 range -> 0 - 1.99 UI range + getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setValue(2.0 - (glow.mV[0] / SLIDER_SCALE_GLOW_R)); + getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setValue(glow.mV[2] / SLIDER_SCALE_GLOW_B); + + getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mSkySettings->getStarBrightness()); + getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(mSkySettings->getSunRotation()); + getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setValue(mSkySettings->getSunTextureId()); + getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setValue(mSkySettings->getSunScale()); + getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation()); + getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId()); + getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setValue(mSkySettings->getMoonScale()); + getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setValue(mSkySettings->getMoonBrightness()); +} + +//------------------------------------------------------------------------- +void LLPanelSettingsSkySunMoonTab::onSunMoonColorChanged() +{ + LLColor3 color(getChild<LLColorSwatchCtrl>(FIELD_SKY_SUN_MOON_COLOR)->get()); + + color *= SLIDER_SCALE_SUN_AMBIENT; + + mSkySettings->setSunlightColor(color); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onGlowChanged() +{ + LLColor3 glow(getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->getValue().asReal(), 0.0f, getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->getValue().asReal()); + + // takes 0 - 1.99 UI range -> 40 -> 0.2 range + glow.mV[0] = (2.0f - glow.mV[0]) * SLIDER_SCALE_GLOW_R; + glow.mV[2] *= SLIDER_SCALE_GLOW_B; + + mSkySettings->setGlow(glow); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onStarBrightnessChanged() +{ + mSkySettings->setStarBrightness(getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onSunRotationChanged() +{ + mSkySettings->setSunRotation(getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->getRotation()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onSunScaleChanged() +{ + mSkySettings->setSunScale((getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->getValue().asReal())); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onSunImageChanged() +{ + mSkySettings->setSunTextureId(getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->getValue().asUUID()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onMoonRotationChanged() +{ + mSkySettings->setMoonRotation(getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->getRotation()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onMoonImageChanged() +{ + mSkySettings->setMoonTextureId(getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->getValue().asUUID()); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged() +{ + mSkySettings->setMoonScale((getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->getValue().asReal())); + mSkySettings->update(); + setIsDirty(); +} + +void LLPanelSettingsSkySunMoonTab::onMoonBrightnessChanged() +{ + mSkySettings->setMoonBrightness((getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->getValue().asReal())); + mSkySettings->update(); + setIsDirty(); +} + +LLPanelSettingsSkyDensityTab::LLPanelSettingsSkyDensityTab() +{ +} + +BOOL LLPanelSettingsSkyDensityTab::postBuild() +{ + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighExponentialChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighExponentialScaleChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighLinearChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighConstantChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighMaxAltitudeChanged(); }); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieExponentialChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieExponentialScaleChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieLinearChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieConstantChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_ANISO)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieAnisoFactorChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieMaxAltitudeChanged(); }); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionExponentialChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionExponentialScaleChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionLinearChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionConstantChanged(); }); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionMaxAltitudeChanged(); }); + + refresh(); + return TRUE; +} + +void LLPanelSettingsSkyDensityTab::setEnabled(BOOL enabled) +{ + LLPanelSettingsSky::setEnabled(enabled); + + // Make sure we have children + if (getFirstChild()) + { + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->setEnabled(enabled); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_LINEAR)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_CONSTANT)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_ANISO)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->setEnabled(enabled); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->setEnabled(enabled); + } +} + +void LLPanelSettingsSkyDensityTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + // Get first (only) profile layer of each type for editing + LLSD rayleigh_config = mSkySettings->getRayleighConfig(); + LLSD mie_config = mSkySettings->getMieConfig(); + LLSD absorption_config = mSkySettings->getAbsorptionConfig(); + + F32 rayleigh_exponential_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 rayleigh_exponential_scale = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 rayleigh_linear_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 rayleigh_constant_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + F32 rayleigh_max_alt = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + + F32 mie_exponential_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 mie_exponential_scale = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 mie_linear_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 mie_constant_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + F32 mie_aniso_factor = mie_config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR].asReal(); + F32 mie_max_alt = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + + F32 absorption_exponential_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 absorption_exponential_scale = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 absorption_linear_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 absorption_constant_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 absorption_max_alt = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setValue(rayleigh_exponential_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setValue(rayleigh_exponential_scale); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setValue(rayleigh_linear_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setValue(rayleigh_constant_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->setValue(rayleigh_max_alt); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setValue(mie_exponential_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setValue(mie_exponential_scale); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_LINEAR)->setValue(mie_linear_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_CONSTANT)->setValue(mie_constant_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_ANISO)->setValue(mie_aniso_factor); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->setValue(mie_max_alt); + + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setValue(absorption_exponential_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setValue(absorption_exponential_scale); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setValue(absorption_linear_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setValue(absorption_constant_term); + getChild<LLUICtrl>(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->setValue(absorption_max_alt); +} + +void LLPanelSettingsSkyDensityTab::updateProfile() +{ + F32 rayleigh_exponential_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->getValueF32(); + F32 rayleigh_exponential_scale = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->getValueF32(); + F32 rayleigh_linear_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->getValueF32(); + F32 rayleigh_constant_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->getValueF32(); + F32 rayleigh_max_alt = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->getValueF32(); + + F32 mie_exponential_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->getValueF32(); + F32 mie_exponential_scale = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->getValueF32(); + F32 mie_linear_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MIE_LINEAR)->getValueF32(); + F32 mie_constant_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MIE_CONSTANT)->getValueF32(); + F32 mie_aniso_factor = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MIE_ANISO)->getValueF32(); + F32 mie_max_alt = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->getValueF32(); + + F32 absorption_exponential_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->getValueF32(); + F32 absorption_exponential_scale = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->getValueF32(); + F32 absorption_linear_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->getValueF32(); + F32 absorption_constant_term = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->getValueF32(); + F32 absorption_max_alt = getChild<LLSliderCtrl>(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->getValueF32(); + + LLSD rayleigh_config = LLSettingsSky::createSingleLayerDensityProfile(rayleigh_max_alt, rayleigh_exponential_term, rayleigh_exponential_scale, rayleigh_linear_term, rayleigh_constant_term); + LLSD mie_config = LLSettingsSky::createSingleLayerDensityProfile(mie_max_alt, mie_exponential_term, mie_exponential_scale, mie_linear_term, mie_constant_term, mie_aniso_factor); + LLSD absorption_layer = LLSettingsSky::createSingleLayerDensityProfile(absorption_max_alt, absorption_exponential_term, absorption_exponential_scale, absorption_linear_term, absorption_constant_term); + + static LLSD absorption_layer_ozone = LLSettingsSky::createDensityProfileLayer(0.0f, 0.0f, 0.0f, -1.0f / 15000.0f, 8.0f / 3.0f); + + LLSD absorption_config; + absorption_config.append(absorption_layer); + absorption_config.append(absorption_layer_ozone); + + mSkySettings->setRayleighConfigs(rayleigh_config); + mSkySettings->setMieConfigs(mie_config); + mSkySettings->setAbsorptionConfigs(absorption_config); + mSkySettings->update(); + setIsDirty(); + + if (gAtmosphere) + { + AtmosphericModelSettings atmospheric_settings; + LLEnvironment::getAtmosphericModelSettings(atmospheric_settings, mSkySettings); + gAtmosphere->configureAtmosphericModel(atmospheric_settings); + } +} + +void LLPanelSettingsSkyDensityTab::onRayleighExponentialChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onRayleighExponentialScaleChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onRayleighLinearChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onRayleighConstantChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onRayleighMaxAltitudeChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onMieExponentialChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onMieExponentialScaleChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onMieLinearChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onMieConstantChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onMieAnisoFactorChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onMieMaxAltitudeChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onAbsorptionExponentialChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onAbsorptionExponentialScaleChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onAbsorptionLinearChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onAbsorptionConstantChanged() +{ + updateProfile(); +} + +void LLPanelSettingsSkyDensityTab::onAbsorptionMaxAltitudeChanged() +{ + updateProfile(); +} diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h new file mode 100644 index 0000000000..c02c9c95a0 --- /dev/null +++ b/indra/newview/llpaneleditsky.h @@ -0,0 +1,171 @@ +/** +* @file llpaneleditsky.h +* @brief Panels for sky settings +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LLPANEL_EDIT_SKY_H +#define LLPANEL_EDIT_SKY_H + +#include "llpanel.h" +#include "llsettingssky.h" +#include "llfloaterfixedenvironment.h" + +//========================================================================= +class LLSlider; +class LLColorSwatchCtrl; +class LLTextureCtrl; + +//========================================================================= +class LLPanelSettingsSky : public LLSettingsEditPanel +{ + LOG_CLASS(LLPanelSettingsSky); + +public: + LLPanelSettingsSky(); + + virtual void setSettings(const LLSettingsBase::ptr_t &settings) override { setSky(std::static_pointer_cast<LLSettingsSky>(settings)); } + + LLSettingsSky::ptr_t getSky() const { return mSkySettings; } + void setSky(const LLSettingsSky::ptr_t &sky) { mSkySettings = sky; clearIsDirty(); refresh(); } + +protected: + LLSettingsSky::ptr_t mSkySettings; +}; + +class LLPanelSettingsSkyAtmosTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsSkyAtmosTab); + +public: + LLPanelSettingsSkyAtmosTab(); + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + +protected: + virtual void refresh() override; + +private: + void onAmbientLightChanged(); + void onBlueHorizonChanged(); + void onBlueDensityChanged(); + void onHazeHorizonChanged(); + void onHazeDensityChanged(); + void onSceneGammaChanged(); + void onDensityMultipChanged(); + void onDistanceMultipChanged(); + void onMaxAltChanged(); + void onMoistureLevelChanged(); + void onDropletRadiusChanged(); + void onIceLevelChanged(); + +}; + +class LLPanelSettingsSkyCloudTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsSkyCloudTab); + +public: + LLPanelSettingsSkyCloudTab(); + + virtual BOOL postBuild() override; + void setEnabled(BOOL enabled) override; + +protected: + virtual void refresh() override; + +private: + void onCloudColorChanged(); + void onCloudCoverageChanged(); + void onCloudScaleChanged(); + void onCloudVarianceChanged(); + void onCloudScrollChanged(); + void onCloudMapChanged(); + void onCloudDensityChanged(); + void onCloudDetailChanged(); +}; + +class LLPanelSettingsSkySunMoonTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsSkySunMoonTab); + +public: + LLPanelSettingsSkySunMoonTab(); + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + +protected: + virtual void refresh() override; + +private: + void onSunMoonColorChanged(); + void onGlowChanged(); + void onStarBrightnessChanged(); + void onSunRotationChanged(); + void onSunScaleChanged(); + void onSunImageChanged(); + void onMoonRotationChanged(); + void onMoonScaleChanged(); + void onMoonBrightnessChanged(); + void onMoonImageChanged(); +}; + +// single subtab of the density settings tab +class LLPanelSettingsSkyDensityTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsSkyDensityTab); + +public: + LLPanelSettingsSkyDensityTab(); + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + +protected: + virtual void refresh() override; + + void onRayleighExponentialChanged(); + void onRayleighExponentialScaleChanged(); + void onRayleighLinearChanged(); + void onRayleighConstantChanged(); + void onRayleighMaxAltitudeChanged(); + + void onMieExponentialChanged(); + void onMieExponentialScaleChanged(); + void onMieLinearChanged(); + void onMieConstantChanged(); + void onMieAnisoFactorChanged(); + void onMieMaxAltitudeChanged(); + + void onAbsorptionExponentialChanged(); + void onAbsorptionExponentialScaleChanged(); + void onAbsorptionLinearChanged(); + void onAbsorptionConstantChanged(); + void onAbsorptionMaxAltitudeChanged(); + + // update the settings for our profile type + void updateProfile(); +}; +#endif // LLPANEL_EDIT_SKY_H diff --git a/indra/newview/llpaneleditwater.cpp b/indra/newview/llpaneleditwater.cpp new file mode 100644 index 0000000000..1f9c79c9eb --- /dev/null +++ b/indra/newview/llpaneleditwater.cpp @@ -0,0 +1,240 @@ +/** +* @file llpaneleditwater.cpp +* @brief Floaters to create and edit fixed settings for sky and water. +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "llpaneleditwater.h" + +#include "llslider.h" +#include "lltexturectrl.h" +#include "llcolorswatch.h" +#include "llxyvector.h" +#include "llviewercontrol.h" + +namespace +{ + const std::string FIELD_WATER_FOG_COLOR("water_fog_color"); + const std::string FIELD_WATER_FOG_DENSITY("water_fog_density"); + const std::string FIELD_WATER_UNDERWATER_MOD("water_underwater_mod"); + const std::string FIELD_WATER_NORMAL_MAP("water_normal_map"); + + const std::string FIELD_WATER_WAVE1_XY("water_wave1_xy"); + const std::string FIELD_WATER_WAVE2_XY("water_wave2_xy"); + + const std::string FIELD_WATER_NORMAL_SCALE_X("water_normal_scale_x"); + const std::string FIELD_WATER_NORMAL_SCALE_Y("water_normal_scale_y"); + const std::string FIELD_WATER_NORMAL_SCALE_Z("water_normal_scale_z"); + + const std::string FIELD_WATER_FRESNEL_SCALE("water_fresnel_scale"); + const std::string FIELD_WATER_FRESNEL_OFFSET("water_fresnel_offset"); + + const std::string FIELD_WATER_SCALE_ABOVE("water_scale_above"); + const std::string FIELD_WATER_SCALE_BELOW("water_scale_below"); + const std::string FIELD_WATER_BLUR_MULTIP("water_blur_multip"); +} + +static LLPanelInjector<LLPanelSettingsWaterMainTab> t_settings_water("panel_settings_water"); + +//========================================================================== +LLPanelSettingsWater::LLPanelSettingsWater() : + LLSettingsEditPanel(), + mWaterSettings() +{ + +} + + +//========================================================================== +LLPanelSettingsWaterMainTab::LLPanelSettingsWaterMainTab(): + LLPanelSettingsWater(), + mClrFogColor(nullptr), + mTxtNormalMap(nullptr) +{ +} + + +BOOL LLPanelSettingsWaterMainTab::postBuild() +{ + mClrFogColor = getChild<LLColorSwatchCtrl>(FIELD_WATER_FOG_COLOR); + mTxtNormalMap = getChild<LLTextureCtrl>(FIELD_WATER_NORMAL_MAP); + + getChild<LLXYVector>(FIELD_WATER_WAVE1_XY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLargeWaveChanged(); }); + + mClrFogColor->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogColorChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(); }); +// getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); }); + getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogUnderWaterChanged(); }); + + mTxtNormalMap->setDefaultImageAssetID(LLSettingsWater::GetDefaultWaterNormalAssetId()); + mTxtNormalMap->setBlankImageAssetID(LLUUID( gSavedSettings.getString( "DefaultBlankNormalTexture" ))); + mTxtNormalMap->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalMapChanged(); }); + + getChild<LLUICtrl>(FIELD_WATER_WAVE2_XY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSmallWaveChanged(); }); + + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalScaleChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalScaleChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalScaleChanged(); }); + + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFresnelScaleChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFresnelOffsetChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onScaleAboveChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onScaleBelowChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlurMultipChanged(); }); + + refresh(); + + return TRUE; +} + +//virtual +void LLPanelSettingsWaterMainTab::setEnabled(BOOL enabled) +{ + LLPanelSettingsWater::setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->setEnabled(enabled); + + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->setEnabled(enabled); + + getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->setEnabled(enabled); +} + +//========================================================================== +void LLPanelSettingsWaterMainTab::refresh() +{ + if (!mWaterSettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + mClrFogColor->set(mWaterSettings->getWaterFogColor()); + getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setValue(mWaterSettings->getWaterFogDensity()); + getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->setValue(mWaterSettings->getFogMod()); + mTxtNormalMap->setValue(mWaterSettings->getNormalMapID()); + LLVector2 vect2 = mWaterSettings->getWave1Dir() * -1.0; // Flip so that north and east are + + getChild<LLUICtrl>(FIELD_WATER_WAVE1_XY)->setValue(vect2.getValue()); + vect2 = mWaterSettings->getWave2Dir() * -1.0; // Flip so that north and east are + + getChild<LLUICtrl>(FIELD_WATER_WAVE2_XY)->setValue(vect2.getValue()); + LLVector3 vect3 = mWaterSettings->getNormalScale(); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->setValue(vect3[0]); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->setValue(vect3[1]); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->setValue(vect3[2]); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->setValue(mWaterSettings->getFresnelScale()); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->setValue(mWaterSettings->getFresnelOffset()); + getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->setValue(mWaterSettings->getScaleAbove()); + getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->setValue(mWaterSettings->getScaleBelow()); + getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->setValue(mWaterSettings->getBlurMultiplier()); +} + +//========================================================================== + +void LLPanelSettingsWaterMainTab::onFogColorChanged() +{ + mWaterSettings->setWaterFogColor(LLColor3(mClrFogColor->get())); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onFogDensityChanged() +{ + mWaterSettings->setWaterFogDensity(getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onFogUnderWaterChanged() +{ + mWaterSettings->setFogMod(getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onNormalMapChanged() +{ + mWaterSettings->setNormalMapID(mTxtNormalMap->getImageAssetID()); + setIsDirty(); +} + + +void LLPanelSettingsWaterMainTab::onLargeWaveChanged() +{ + LLVector2 vect(getChild<LLUICtrl>(FIELD_WATER_WAVE1_XY)->getValue()); + vect *= -1.0; // Flip so that north and east are - + mWaterSettings->setWave1Dir(vect); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onSmallWaveChanged() +{ + LLVector2 vect(getChild<LLUICtrl>(FIELD_WATER_WAVE2_XY)->getValue()); + vect *= -1.0; // Flip so that north and east are - + mWaterSettings->setWave2Dir(vect); + setIsDirty(); +} + + +void LLPanelSettingsWaterMainTab::onNormalScaleChanged() +{ + LLVector3 vect(getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->getValue().asReal()); + mWaterSettings->setNormalScale(vect); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onFresnelScaleChanged() +{ + mWaterSettings->setFresnelScale(getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onFresnelOffsetChanged() +{ + mWaterSettings->setFresnelOffset(getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onScaleAboveChanged() +{ + mWaterSettings->setScaleAbove(getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onScaleBelowChanged() +{ + mWaterSettings->setScaleBelow(getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->getValue().asReal()); + setIsDirty(); +} + +void LLPanelSettingsWaterMainTab::onBlurMultipChanged() +{ + mWaterSettings->setBlurMultiplier(getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->getValue().asReal()); + setIsDirty(); +} diff --git a/indra/newview/llpaneleditwater.h b/indra/newview/llpaneleditwater.h new file mode 100644 index 0000000000..ab2dc47bcc --- /dev/null +++ b/indra/newview/llpaneleditwater.h @@ -0,0 +1,98 @@ +/** +* @file llpaneleditwater.h +* @brief Panels for water settings +* +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2011, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LLPANEL_EDIT_WATER_H +#define LLPANEL_EDIT_WATER_H + +#include "llpanel.h" +#include "llsettingswater.h" + +#include "llfloaterfixedenvironment.h" + +//========================================================================= +class LLSlider; +class LLColorSwatchCtrl; +class LLTextureCtrl; +class LLXYVector; + +//========================================================================= +class LLPanelSettingsWater : public LLSettingsEditPanel +{ + LOG_CLASS(LLPanelSettingsWater); + +public: + LLPanelSettingsWater(); + + virtual void setSettings(const LLSettingsBase::ptr_t &settings) override { setWater(std::static_pointer_cast<LLSettingsWater>(settings)); } + + LLSettingsWater::ptr_t getWater() const { return mWaterSettings; } + void setWater(const LLSettingsWater::ptr_t &water) { mWaterSettings = water; clearIsDirty(); refresh(); } + +protected: + LLSettingsWater::ptr_t mWaterSettings; +}; + +// *RIDER* In this case this split is unecessary since there is only a single +// tab page for water settings at this point. However more may be added in the +// future and I want to reinforce the pattern used for sky/atmosphere tabs. +class LLPanelSettingsWaterMainTab : public LLPanelSettingsWater +{ + LOG_CLASS(LLPanelSettingsWaterMainTab); + +public: + LLPanelSettingsWaterMainTab(); + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + +protected: + virtual void refresh() override; + +private: + + LLColorSwatchCtrl * mClrFogColor; +// LLSlider * mSldFogDensity; +// LLSlider * mSldUnderWaterMod; + LLTextureCtrl * mTxtNormalMap; + + void onFogColorChanged(); + void onFogDensityChanged(); + void onFogUnderWaterChanged(); + void onNormalMapChanged(); + + void onLargeWaveChanged(); + void onSmallWaveChanged(); + + void onNormalScaleChanged(); + void onFresnelScaleChanged(); + void onFresnelOffsetChanged(); + void onScaleAboveChanged(); + void onScaleBelowChanged(); + void onBlurMultipChanged(); +}; + + +#endif // LLPANEL_EDIT_WATER_H diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp new file mode 100644 index 0000000000..44806e7d23 --- /dev/null +++ b/indra/newview/llpanelenvironment.cpp @@ -0,0 +1,1111 @@ +/** + * @file llpanelenvironment.cpp + * @brief LLPanelExperiences class implementation + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + + +#include "llpanelprofile.h" +#include "lluictrlfactory.h" +#include "llexperiencecache.h" +#include "llagent.h" +#include "llparcel.h" + +#include "llviewerregion.h" +#include "llpanelenvironment.h" +#include "llslurl.h" +#include "lllayoutstack.h" + +#include "llfloater.h" +#include "llfloaterreg.h" +#include "llfloatereditextdaycycle.h" +#include "llmultisliderctrl.h" +#include "llnotificationsutil.h" +#include "llsettingsvo.h" + +#include "llappviewer.h" +#include "llcallbacklist.h" +#include "llviewerparcelmgr.h" + +#include "llinventorymodel.h" + +//========================================================================= +namespace +{ + const std::string FLOATER_DAY_CYCLE_EDIT("env_edit_extdaycycle"); + const std::string STRING_REGION_ENV("str_region_env"); + const std::string STRING_EMPTY_NAME("str_empty"); + + inline bool ends_with(std::string const & value, std::string const & ending) + { + if (ending.size() > value.size()) + return false; + return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); + } + +} + +//========================================================================= +const std::string LLPanelEnvironmentInfo::BTN_SELECTINV("btn_select_inventory"); +const std::string LLPanelEnvironmentInfo::BTN_EDIT("btn_edit"); +const std::string LLPanelEnvironmentInfo::BTN_USEDEFAULT("btn_usedefault"); +const std::string LLPanelEnvironmentInfo::BTN_RST_ALTITUDES("btn_rst_altitudes"); +const std::string LLPanelEnvironmentInfo::SLD_DAYLENGTH("sld_day_length"); +const std::string LLPanelEnvironmentInfo::SLD_DAYOFFSET("sld_day_offset"); +const std::string LLPanelEnvironmentInfo::SLD_ALTITUDES("sld_altitudes"); +const std::string LLPanelEnvironmentInfo::ICN_GROUND("icon_ground"); +const std::string LLPanelEnvironmentInfo::ICN_WATER("icon_water"); +const std::string LLPanelEnvironmentInfo::CHK_ALLOWOVERRIDE("chk_allow_override"); +const std::string LLPanelEnvironmentInfo::LBL_TIMEOFDAY("lbl_apparent_time"); +const std::string LLPanelEnvironmentInfo::PNL_SETTINGS("pnl_environment_config"); +const std::string LLPanelEnvironmentInfo::PNL_ENVIRONMENT_ALTITUDES("pnl_environment_altitudes"); +const std::string LLPanelEnvironmentInfo::PNL_BUTTONS("pnl_environment_buttons"); +const std::string LLPanelEnvironmentInfo::PNL_DISABLED("pnl_environment_disabled"); +const std::string LLPanelEnvironmentInfo::TXT_DISABLED("txt_environment_disabled"); +const std::string LLPanelEnvironmentInfo::SDT_DROP_TARGET("sdt_drop_target"); + +const std::string LLPanelEnvironmentInfo::STR_LABEL_USEDEFAULT("str_label_use_default"); +const std::string LLPanelEnvironmentInfo::STR_LABEL_USEREGION("str_label_use_region"); +const std::string LLPanelEnvironmentInfo::STR_ALTITUDE_DESCRIPTION("str_altitude_desription"); +const std::string LLPanelEnvironmentInfo::STR_NO_PARCEL("str_no_parcel"); +const std::string LLPanelEnvironmentInfo::STR_CROSS_REGION("str_cross_region"); +const std::string LLPanelEnvironmentInfo::STR_LEGACY("str_legacy"); +const std::string LLPanelEnvironmentInfo::STR_DISALLOWED("str_disallowed"); +const std::string LLPanelEnvironmentInfo::STR_TOO_SMALL("str_too_small"); + +const S32 LLPanelEnvironmentInfo::MINIMUM_PARCEL_SIZE(128); + +const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYCYCLE(0x01 << 0); +const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYLENGTH(0x01 << 1); +const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYOFFSET(0x01 << 2); +const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_ALTITUDES(0x01 << 3); + +const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_MASK( + LLPanelEnvironmentInfo::DIRTY_FLAG_DAYCYCLE | + LLPanelEnvironmentInfo::DIRTY_FLAG_DAYLENGTH | + LLPanelEnvironmentInfo::DIRTY_FLAG_DAYOFFSET | + LLPanelEnvironmentInfo::DIRTY_FLAG_ALTITUDES); + +const U32 ALTITUDE_SLIDER_COUNT = 3; +const F32 ALTITUDE_DEFAULT_HEIGHT_STEP = 1000; +const U32 ALTITUDE_MARKERS_COUNT = 3; +const U32 ALTITUDE_PREFIXERS_COUNT = 5; + +const std::string slider_marker_base = "mark"; + +const std::string alt_sliders[] = { + "sld1", + "sld2", + "sld3", +}; + +const std::string alt_prefixes[] = { + "alt1", + "alt2", + "alt3", + "ground", + "water", +}; + +const std::string alt_panels[] = { + "pnl_alt1", + "pnl_alt2", + "pnl_alt3", + "pnl_ground", + "pnl_water", +}; + +static LLDefaultChildRegistry::Register<LLSettingsDropTarget> r("settings_drop_target"); + +//========================================================================= +LLPanelEnvironmentInfo::LLPanelEnvironmentInfo(): + mCurrentEnvironment(), + mDirtyFlag(0), + mEditorLastParcelId(INVALID_PARCEL_ID), + mCrossRegion(false), + mNoSelection(false), + mNoEnvironment(false), + mCurEnvVersion(INVALID_PARCEL_ENVIRONMENT_VERSION), + mSettingsFloater(), + mEditFloater(), + mAllowOverride(true) +{ +} + +LLPanelEnvironmentInfo::~LLPanelEnvironmentInfo() +{ + if (mChangeMonitor.connected()) + mChangeMonitor.disconnect(); + if (mCommitConnection.connected()) + mCommitConnection.disconnect(); + if (mUpdateConnection.connected()) + mUpdateConnection.disconnect(); +} + +BOOL LLPanelEnvironmentInfo::postBuild() +{ + + getChild<LLUICtrl>(BTN_USEDEFAULT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnDefault(); }); + getChild<LLUICtrl>(BTN_SELECTINV)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnSelect(); }); + getChild<LLUICtrl>(BTN_EDIT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnEdit(); }); + getChild<LLUICtrl>(BTN_RST_ALTITUDES)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnRstAltitudes(); }); + + getChild<LLUICtrl>(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged(value.asReal()); }); + getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); + getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); + getChild<LLUICtrl>(SLD_DAYOFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged(value.asReal()); }); + getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); + getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); + + getChild<LLMultiSliderCtrl>(SLD_ALTITUDES)->setCommitCallback([this](LLUICtrl *cntrl, const LLSD &value) { onAltSliderCallback(cntrl, value); }); + getChild<LLMultiSliderCtrl>(SLD_ALTITUDES)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onAltSliderMouseUp(); }); + + mChangeMonitor = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32 version) { onEnvironmentChanged(env, version); }); + + for (U32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; idx++) + { + LLSettingsDropTarget* drop_target = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]); + if (drop_target) + { + drop_target->setPanel(this, alt_sliders[idx]); + } + } + getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[3])->setPanel(this, alt_prefixes[3]); + getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[4])->setPanel(this, alt_prefixes[4]); + + return TRUE; +} + +// virtual +void LLPanelEnvironmentInfo::onOpen(const LLSD& key) +{ + refreshFromSource(); +} + +// virtual +void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) +{ + if (new_visibility) + { + gIdleCallbacks.addFunction(onIdlePlay, this); + } + else + { + LLFloaterSettingsPicker *picker = getSettingsPicker(false); + if (picker) + { + picker->closeFloater(); + } + + gIdleCallbacks.deleteFunction(onIdlePlay, this); + LLFloaterEditExtDayCycle *dayeditor = getEditFloater(false); + if (mCommitConnection.connected()) + mCommitConnection.disconnect(); + + if (dayeditor) + { + if (dayeditor->isDirty()) + dayeditor->refresh(); + else + { + dayeditor->closeFloater(); + mEditFloater.markDead(); + } + } + } + +} + +void LLPanelEnvironmentInfo::refresh() +{ + if (gDisconnected) + return; + + if (!setControlsEnabled(canEdit())) + return; + + if (!mCurrentEnvironment) + { + return; + } + + F32Hours daylength(mCurrentEnvironment->mDayLength); + F32Hours dayoffset(mCurrentEnvironment->mDayOffset); + + if (dayoffset.value() > 12.0f) + dayoffset -= F32Hours(24.0); + + getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setValue(daylength.value()); + getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setValue(dayoffset.value()); + + udpateApparentTimeOfDay(); + + updateEditFloater(mCurrentEnvironment, canEdit()); + + LLEnvironment::altitude_list_t altitudes = mCurrentEnvironment->mAltitudes; + + if (altitudes.size() > 0) + { + LLMultiSliderCtrl *sld = getChild<LLMultiSliderCtrl>(SLD_ALTITUDES); + sld->clear(); + + for (S32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; ++idx) + { + // make sure values are in range, server is supposed to validate them, + // but issues happen, try to fix values in such case + F32 altitude = llclamp(altitudes[idx + 1], sld->getMinValue(), sld->getMaxValue()); + bool res = sld->addSlider(altitude, alt_sliders[idx]); + if (!res) + { + LL_WARNS_ONCE("ENVPANEL") << "Failed to validate altitude from server for parcel id" << getParcelId() << LL_ENDL; + // Find a spot to insert altitude. + // Assuming everything alright with slider, we should find new place in 11 steps top (step 25m, no overlap 100m) + F32 alt_step = (altitude > (sld->getMaxValue() / 2)) ? -sld->getIncrement() : sld->getIncrement(); + for (U32 i = 0; i < 30; i++) + { + altitude += alt_step; + if (altitude > sld->getMaxValue()) + { + altitude = sld->getMinValue(); + } + else if (altitude < sld->getMinValue()) + { + altitude = sld->getMaxValue(); + } + res = sld->addSlider(altitude, alt_sliders[idx]); + if (res) break; + } + } + if (res) + { + // slider has some auto correction that might have kicked in + altitude = sld->getSliderValue(alt_sliders[idx]); + } + else + { + // Something is very very wrong + LL_WARNS_ONCE("ENVPANEL") << "Failed to set up altitudes for parcel id " << getParcelId() << LL_ENDL; + } + updateAltLabel(alt_prefixes[idx], idx + 2, altitude); + mAltitudes[alt_sliders[idx]] = AltitudeData(idx + 2, idx, altitude); + } + if (sld->getCurNumSliders() != ALTITUDE_SLIDER_COUNT) + { + LL_WARNS("ENVPANEL") << "Failed to add altitude sliders!" << LL_ENDL; + } + readjustAltLabels(); + } + + updateAltLabel(alt_prefixes[3], 1, 0); // ground + updateAltLabel(alt_prefixes[4], 0, 0); // water + +} + +void LLPanelEnvironmentInfo::refreshFromEstate() +{ + LLViewerRegion *pRegion = gAgent.getRegion(); + + bool oldAO = mAllowOverride; + mAllowOverride = (isRegion() && LLEstateInfoModel::instance().getAllowEnvironmentOverride()) || pRegion->getAllowEnvironmentOverride(); + if (oldAO != mAllowOverride) + refresh(); +} + +std::string LLPanelEnvironmentInfo::getNameForTrackIndex(S32 index) +{ + std::string invname; + if (mCurrentEnvironment || index < LLSettingsDay::TRACK_WATER || index >= LLSettingsDay::TRACK_MAX) + { + invname = getString(STRING_EMPTY_NAME); + } + else if (mCurrentEnvironment->mDayCycleName.empty()) + { + invname = mCurrentEnvironment->mNameList[index]; + + if (invname.empty()) + { + if (index <= LLSettingsDay::TRACK_GROUND_LEVEL) + invname = getString(isRegion() ? STRING_EMPTY_NAME : STRING_REGION_ENV); + } + } + else if (!mCurrentEnvironment->mDayCycle->isTrackEmpty(index)) + { + invname = mCurrentEnvironment->mDayCycleName; + } + + + if (invname.empty()) + { + invname = getNameForTrackIndex(index - 1); + if (invname[0] != '(') + invname = "(" + invname + ")"; + } + + return invname; +} + +LLFloaterSettingsPicker * LLPanelEnvironmentInfo::getSettingsPicker(bool create) +{ + LLFloaterSettingsPicker *picker = static_cast<LLFloaterSettingsPicker *>(mSettingsFloater.get()); + + // Show the dialog + if (!picker && create) + { + picker = new LLFloaterSettingsPicker(this, + LLUUID::null); + + mSettingsFloater = picker->getHandle(); + + picker->setCommitCallback([this](LLUICtrl *, const LLSD &data){ onPickerCommitted(data["ItemId"].asUUID()); }); + } + + return picker; +} + +LLFloaterEditExtDayCycle * LLPanelEnvironmentInfo::getEditFloater(bool create) +{ + static const S32 FOURHOURS(4 * 60 * 60); + LLFloaterEditExtDayCycle *editor = static_cast<LLFloaterEditExtDayCycle *>(mEditFloater.get()); + + // Show the dialog + if (!editor && create) + { + LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, isRegion() ? LLFloaterEditExtDayCycle::CONTEXT_REGION : LLFloaterEditExtDayCycle::CONTEXT_PARCEL) + (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS)); + + editor = (LLFloaterEditExtDayCycle *)LLFloaterReg::getInstance(FLOATER_DAY_CYCLE_EDIT, params); + + if (!editor) + return nullptr; + mEditFloater = editor->getHandle(); + } + + if (editor && !mCommitConnection.connected()) + mCommitConnection = editor->setEditCommitSignal([this](LLSettingsDay::ptr_t pday) { onEditCommitted(pday); }); + + return editor; +} + + +void LLPanelEnvironmentInfo::updateEditFloater(const LLEnvironment::EnvironmentInfo::ptr_t &nextenv, bool enable) +{ + LLFloaterEditExtDayCycle *dayeditor(getEditFloater(false)); + + if (!dayeditor || !dayeditor->isInVisibleChain()) + return; + + if (!nextenv || !nextenv->mDayCycle || !enable) + { + if (mCommitConnection.connected()) + mCommitConnection.disconnect(); + + if (dayeditor->isDirty()) + dayeditor->refresh(); + else + dayeditor->closeFloater(); + } + else if (dayeditor->getEditingAssetId() != nextenv->mDayCycle->getAssetId() + || mEditorLastParcelId != nextenv->mParcelId + || mEditorLastRegionId != nextenv->mRegionId) + { + // Ignore dirty + // If parcel selection changed whatever we do except saving to inventory with + // old settings will be invalid. + mEditorLastParcelId = nextenv->mParcelId; + mEditorLastRegionId = nextenv->mRegionId; + dayeditor->setEditDayCycle(nextenv->mDayCycle); + } +} + +bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) +{ + bool is_unavailable(false); + bool is_legacy = (mCurrentEnvironment) ? mCurrentEnvironment->mIsLegacy : true; + bool is_bigenough = isLargeEnough(); + + if (mNoEnvironment || (!LLEnvironment::instance().isExtendedEnvironmentEnabled() && !isRegion())) + { + is_unavailable = true; + getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_LEGACY)); + } + else if (mNoSelection) + { + is_unavailable = true; + getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_NO_PARCEL)); + } + else if (mCrossRegion) + { + is_unavailable = true; + getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_CROSS_REGION)); + } + else if (!isRegion() && !mAllowOverride) + { + is_unavailable = true; + getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_DISALLOWED)); + } + else if (!is_bigenough) + { + is_unavailable = true; + getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_TOO_SMALL)); + } + + if (is_unavailable) + { + getChild<LLUICtrl>(PNL_SETTINGS)->setVisible(false); + getChild<LLUICtrl>(PNL_BUTTONS)->setVisible(false); + getChild<LLUICtrl>(PNL_DISABLED)->setVisible(true); + getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(false); + + updateEditFloater(mCurrentEnvironment, false); + + return false; + } + getChild<LLUICtrl>(PNL_SETTINGS)->setVisible(true); + getChild<LLUICtrl>(PNL_BUTTONS)->setVisible(true); + getChild<LLUICtrl>(PNL_DISABLED)->setVisible(false); + + getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(LLEnvironment::instance().isExtendedEnvironmentEnabled()); + getChild<LLUICtrl>(BTN_RST_ALTITUDES)->setVisible(isRegion()); + + bool can_enable = enabled && !is_legacy && mCurrentEnvironment && (mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION); + getChild<LLUICtrl>(BTN_SELECTINV)->setEnabled(can_enable); + getChild<LLUICtrl>(BTN_USEDEFAULT)->setEnabled(can_enable); + getChild<LLUICtrl>(BTN_EDIT)->setEnabled(can_enable); + getChild<LLUICtrl>(SLD_DAYLENGTH)->setEnabled(can_enable); + getChild<LLUICtrl>(SLD_DAYOFFSET)->setEnabled(can_enable); + getChild<LLUICtrl>(SLD_ALTITUDES)->setEnabled(can_enable && isRegion()); + getChild<LLUICtrl>(ICN_GROUND)->setColor((can_enable && isRegion()) ? LLColor4::white : LLColor4::grey % 0.8f); + getChild<LLUICtrl>(ICN_WATER)->setColor((can_enable && isRegion()) ? LLColor4::white : LLColor4::grey % 0.8f); + getChild<LLUICtrl>(BTN_RST_ALTITUDES)->setEnabled(can_enable && isRegion()); + getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setEnabled(can_enable); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setEnabled(can_enable && isRegion()); + + for (U32 idx = 0; idx < ALTITUDE_MARKERS_COUNT; idx++) + { + LLUICtrl* marker = findChild<LLUICtrl>(slider_marker_base + llformat("%u", idx)); + if (marker) + { + static LLColor4 marker_color(0.75f, 0.75f, 0.75f, 1.f); + marker->setColor((can_enable && isRegion()) ? marker_color : marker_color % 0.3f); + } + } + + for (U32 idx = 0; idx < ALTITUDE_PREFIXERS_COUNT; idx++) + { + LLSettingsDropTarget* drop_target = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]); + if (drop_target) + { + drop_target->setDndEnabled(can_enable); + } + } + + return true; +} + +void LLPanelEnvironmentInfo::setDirtyFlag(U32 flag) +{ + mDirtyFlag |= flag; +} + +void LLPanelEnvironmentInfo::clearDirtyFlag(U32 flag) +{ + mDirtyFlag &= ~flag; +} + +void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_prefix, U32 sky_index, F32 alt_value) +{ + LLMultiSliderCtrl *sld = findChild<LLMultiSliderCtrl>(SLD_ALTITUDES); + if (!sld) + { + LL_WARNS() << "Failed to find slider " << SLD_ALTITUDES << LL_ENDL; + return; + } + LLRect sld_rect = sld->getRect(); + S32 sld_range = sld_rect.getHeight(); + S32 sld_bottom = sld_rect.mBottom; + S32 sld_offset = sld_rect.getWidth(); // Roughly identical to thumb's width in slider. + S32 pos = (sld_range - sld_offset) * ((alt_value - 100) / (4000 - 100)); + + // get related views + LLTextBox* text = findChild<LLTextBox>("txt_" + alt_prefix); + LLLineEditor *field = findChild<LLLineEditor>("edt_invname_" + alt_prefix); + LLView *alt_panel = findChild<LLView>("pnl_" + alt_prefix); + + if (text && (sky_index > 1)) + { + // update text + std::ostringstream convert; + convert << alt_value; + text->setTextArg("[ALTITUDE]", convert.str()); + convert.str(""); + convert.clear(); + convert << sky_index; + text->setTextArg("[INDEX]", convert.str()); + } + + if (field) + { + field->setText(getNameForTrackIndex(sky_index)); + } + + if (alt_panel && (sky_index > 1)) + { + // move containing panel + LLRect rect = alt_panel->getRect(); + S32 height = rect.getHeight(); + rect.mBottom = sld_bottom + (sld_offset / 2 + 1) + pos - (height / 2); + rect.mTop = rect.mBottom + height; + alt_panel->setRect(rect); + } + +} + +void LLPanelEnvironmentInfo::readjustAltLabels() +{ + // Re-adjust all labels + // Very simple "adjust after the fact" method + // Note: labels can be in any order + + LLMultiSliderCtrl *sld = findChild<LLMultiSliderCtrl>(SLD_ALTITUDES); + if (!sld) return; + + LLView* view_midle = NULL; + U32 midle_ind = 0; + S32 shift_up = 0; + S32 shift_down = 0; + LLRect sld_rect = sld->getRect(); + + // Find the middle one + for (U32 i = 0; i < ALTITUDE_SLIDER_COUNT; i++) + { + LLView* cmp_view = findChild<LLView>(alt_panels[i], true); + if (!cmp_view) return; + LLRect cmp_rect = cmp_view->getRect(); + S32 pos = 0; + shift_up = 0; + shift_down = 0; + + for (U32 j = 0; j < ALTITUDE_SLIDER_COUNT; j++) + { + if (i != j) + { + LLView* intr_view = findChild<LLView>(alt_panels[j], true); + if (!intr_view) return; + LLRect intr_rect = intr_view->getRect(); + if (cmp_rect.mBottom >= intr_rect.mBottom) + { + pos++; + } + if (intr_rect.mBottom <= cmp_rect.mTop && intr_rect.mBottom >= cmp_rect.mBottom) + { + shift_up = cmp_rect.mTop - intr_rect.mBottom; + } + else if (intr_rect.mTop >= cmp_rect.mBottom && intr_rect.mBottom <= cmp_rect.mBottom) + { + shift_down = cmp_rect.mBottom - intr_rect.mTop; + } + } + } + if (pos == 1) // middle + { + view_midle = cmp_view; + midle_ind = i; + break; + } + } + + // Account for edges + LLRect midle_rect = view_midle->getRect(); + F32 factor = 0.5f; + S32 edge_zone_height = midle_rect.getHeight() * 1.5f; + + if (midle_rect.mBottom - sld_rect.mBottom < edge_zone_height) + { + factor = 1 - ((midle_rect.mBottom - sld_rect.mBottom) / (edge_zone_height * 2)); + } + else if (sld_rect.mTop - midle_rect.mTop < edge_zone_height ) + { + factor = ((sld_rect.mTop - midle_rect.mTop) / (edge_zone_height * 2)); + } + + S32 shift_middle = (S32)(((F32)shift_down * factor) + ((F32)shift_up * (1.f - factor))); + shift_down = shift_down - shift_middle; + shift_up = shift_up - shift_middle; + + // fix crossings + for (U32 i = 0; i < ALTITUDE_SLIDER_COUNT; i++) + { + if (i != midle_ind) + { + LLView* trn_view = findChild<LLView>(alt_panels[i], true); + LLRect trn_rect = trn_view->getRect(); + + if (trn_rect.mBottom <= midle_rect.mTop && trn_rect.mBottom >= midle_rect.mBottom) + { + // Approximate shift + trn_rect.translate(0, shift_up); + trn_view->setRect(trn_rect); + } + else if (trn_rect.mTop >= midle_rect.mBottom && trn_rect.mBottom <= midle_rect.mBottom) + { + // Approximate shift + trn_rect.translate(0, shift_down); + trn_view->setRect(trn_rect); + } + } + } + + if (shift_middle != 0) + { + midle_rect.translate(0, -shift_middle); //reversed relative to others + view_midle->setRect(midle_rect); + } +} + +void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value) +{ + F32Hours daylength(value); + + mCurrentEnvironment->mDayLength = daylength; + setDirtyFlag(DIRTY_FLAG_DAYLENGTH); + + udpateApparentTimeOfDay(); +} + +void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) +{ + F32Hours dayoffset(value); + + if (dayoffset.value() <= 0.0f) + dayoffset += F32Hours(24.0); + + mCurrentEnvironment->mDayOffset = dayoffset; + setDirtyFlag(DIRTY_FLAG_DAYOFFSET); + + udpateApparentTimeOfDay(); +} + +void LLPanelEnvironmentInfo::onDayLenOffsetMouseUp() +{ + if (getDirtyFlag() & (DIRTY_FLAG_DAYLENGTH | DIRTY_FLAG_DAYOFFSET)) + { + clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); + clearDirtyFlag(DIRTY_FLAG_DAYLENGTH); + + LLHandle<LLPanel> that_h = getHandle(); + + LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), + mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + + } +} + +void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &data) +{ + LLMultiSliderCtrl *sld = (LLMultiSliderCtrl *)cntrl; + std::string sld_name = sld->getCurSlider(); + F32 sld_value = sld->getCurSliderValue(); + + mAltitudes[sld_name].mAltitude = sld_value; + + // update all labels since we could have jumped multiple and we will need to readjust + // (or sort by altitude, too little elements, so I didn't bother with efficiency) + altitudes_data_t::iterator end = mAltitudes.end(); + altitudes_data_t::iterator iter = mAltitudes.begin(); + altitudes_data_t::iterator iter2; + U32 new_index; + while (iter != end) + { + iter2 = mAltitudes.begin(); + new_index = 2; + while (iter2 != end) + { + if (iter->second.mAltitude > iter2->second.mAltitude) + { + new_index++; + } + iter2++; + } + iter->second.mTrackIndex = new_index; + + updateAltLabel(alt_prefixes[iter->second.mLabelIndex], iter->second.mTrackIndex, iter->second.mAltitude); + iter++; + } + + readjustAltLabels(); + setDirtyFlag(DIRTY_FLAG_ALTITUDES); +} + +void LLPanelEnvironmentInfo::onAltSliderMouseUp() +{ + if (isRegion() && (getDirtyFlag() & DIRTY_FLAG_ALTITUDES)) + { + clearDirtyFlag(DIRTY_FLAG_ALTITUDES); + + LLHandle<LLPanel> that_h = getHandle(); + LLEnvironment::altitudes_vect_t alts; + + for (auto alt : mAltitudes) + { + alts.push_back(alt.second.mAltitude); + } + + LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), + -1, -1, alts, + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + + } +} + +void LLPanelEnvironmentInfo::onBtnDefault() +{ + LLHandle<LLPanel> that_h = getHandle(); + S32 parcel_id = getParcelId(); + LLNotificationsUtil::add("SettingsConfirmReset", LLSD(), LLSD(), + [that_h, parcel_id](const LLSD¬if, const LLSD&resp) + { + S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); + if (opt == 0) + { + LLEnvironment::instance().resetParcel(parcel_id, + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + } + }); +} + +void LLPanelEnvironmentInfo::onBtnEdit() +{ + static const S32 FOURHOURS(4 * 60 * 60); + + LLFloaterEditExtDayCycle *dayeditor = getEditFloater(); + + LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, isRegion() ? LLFloaterEditExtDayCycle::VALUE_CONTEXT_REGION : LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL) + (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS) + (LLFloaterEditExtDayCycle::KEY_CANMOD, LLSD::Boolean(true))); + + dayeditor->openFloater(params); + if (mCurrentEnvironment && mCurrentEnvironment->mDayCycle) + { + dayeditor->setEditDayCycle(mCurrentEnvironment->mDayCycle); + if (!ends_with(mCurrentEnvironment->mDayCycle->getName(), "(customized)")) + { + dayeditor->setEditName(mCurrentEnvironment->mDayCycle->getName() + "(customized)"); + } + } + else + dayeditor->setEditDefaultDayCycle(); +} + +void LLPanelEnvironmentInfo::onBtnSelect() +{ + LLFloaterSettingsPicker *picker = getSettingsPicker(); + if (picker) + { + LLUUID item_id; + if (mCurrentEnvironment && mCurrentEnvironment->mDayCycle) + { + item_id = LLFloaterSettingsPicker::findItemID(mCurrentEnvironment->mDayCycle->getAssetId(), false, false); + } + picker->setSettingsFilter(LLSettingsType::ST_NONE); + picker->setSettingsItemId(item_id); + picker->openFloater(); + picker->setFocus(TRUE); + } +} + +void LLPanelEnvironmentInfo::onBtnRstAltitudes() +{ + if (isRegion()) + { + LLHandle<LLPanel> that_h = getHandle(); + LLEnvironment::altitudes_vect_t alts; + + for (S32 idx = 1; idx <= ALTITUDE_SLIDER_COUNT; ++idx) + { + F32 new_height = idx * ALTITUDE_DEFAULT_HEIGHT_STEP; + alts.push_back(new_height); + } + + LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), + -1, -1, alts, + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + } +} + +void LLPanelEnvironmentInfo::udpateApparentTimeOfDay() +{ + static const F32 SECONDSINDAY(24.0 * 60.0 * 60.0); + + if ((!mCurrentEnvironment) || (mCurrentEnvironment->mDayLength.value() < 1.0) || (mCurrentEnvironment->mDayOffset.value() < 1.0)) + { + getChild<LLUICtrl>(LBL_TIMEOFDAY)->setVisible(false); + return; + } + getChild<LLUICtrl>(LBL_TIMEOFDAY)->setVisible(true); + + S32Seconds now(LLDate::now().secondsSinceEpoch()); + + now += mCurrentEnvironment->mDayOffset; + + F32 perc = (F32)(now.value() % mCurrentEnvironment->mDayLength.value()) / (F32)(mCurrentEnvironment->mDayLength.value()); + + S32Seconds secondofday((S32)(perc * SECONDSINDAY)); + S32Hours hourofday(secondofday); + S32Seconds secondofhour(secondofday - hourofday); + S32Minutes minutesofhour(secondofhour); + bool am_pm(hourofday.value() >= 12); + + if (hourofday.value() < 1) + hourofday = S32Hours(12); + if (hourofday.value() > 12) + hourofday -= S32Hours(12); + + std::string lblminute(((minutesofhour.value() < 10) ? "0" : "") + LLSD(minutesofhour.value()).asString()); + + + getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[HH]", LLSD(hourofday.value()).asString()); + getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[MM]", lblminute); + getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[AP]", std::string(am_pm ? "PM" : "AM")); + getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[PRC]", LLSD((S32)(100 * perc)).asString()); + +} + +void LLPanelEnvironmentInfo::onIdlePlay(void *data) +{ + ((LLPanelEnvironmentInfo *)data)->udpateApparentTimeOfDay(); +} + + +void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, std::string source) +{ + if (source == alt_prefixes[4]) + { + onPickerCommitted(item_id, 0); + } + else if (source == alt_prefixes[3]) + { + onPickerCommitted(item_id, 1); + } + else + { + onPickerCommitted(item_id, mAltitudes[source].mTrackIndex); + } +} + +void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, S32 track_num) +{ + LLInventoryItem *itemp = gInventory.getItem(item_id); + if (itemp) + { + LLHandle<LLPanel> that_h = getHandle(); + + LLEnvironment::instance().updateParcel(getParcelId(), itemp->getAssetUUID(), + itemp->getName(), + track_num, + -1, -1, LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + } +} + +void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) +{ + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().updateEnvironment(); + if (!newday) + { + LL_WARNS("ENVPANEL") << "Editor committed an empty day. Do nothing." << LL_ENDL; + return; + } + if (!mCurrentEnvironment) + { + // Attempting to save mid update? + LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " env version: " << mCurEnvVersion << LL_ENDL; + return; + } + size_t newhash(newday->getHash()); + size_t oldhash((mCurrentEnvironment->mDayCycle) ? mCurrentEnvironment->mDayCycle->getHash() : 0); + + if (newhash != oldhash) + { + LLHandle<LLPanel> that_h = getHandle(); + + LLEnvironment::instance().updateParcel(getParcelId(), newday, + -1, -1, LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + } +} + +void LLPanelEnvironmentInfo::onEnvironmentChanged(LLEnvironment::EnvSelection_t env, S32 new_version) +{ + if (new_version < INVALID_PARCEL_ENVIRONMENT_VERSION) + { + // cleanups and local changes, we are only interested in changes sent by server + return; + } + + LL_DEBUGS("ENVPANEL") << "Received environment update " << mCurEnvVersion << " " << new_version << LL_ENDL; + + // Environment comes from different sources, from environment update callbacks, + // from hovers (causes callbacks on version change) and from personal requests + // filter out duplicates and out of order packets by checking parcel environment version. + + if (isRegion()) + { + // Note: region uses same init versions as parcel + if (env == LLEnvironment::ENV_REGION + // version should be always growing, UNSET_PARCEL_ENVIRONMENT_VERSION is backup case + && (mCurEnvVersion < new_version || mCurEnvVersion <= UNSET_PARCEL_ENVIRONMENT_VERSION)) + { + if (new_version >= UNSET_PARCEL_ENVIRONMENT_VERSION) + { + // 'pending state' to prevent re-request on following onEnvironmentChanged if there will be any + mCurEnvVersion = new_version; + } + mCurrentEnvironment.reset(); + refreshFromSource(); + } + } + else if ((env == LLEnvironment::ENV_PARCEL) + && (getParcelId() == LLViewerParcelMgr::instance().getAgentParcelId())) + { + LLParcel *parcel = getParcel(); + if (parcel) + { + // first for parcel own settings, second is for case when parcel uses region settings + if (mCurEnvVersion < new_version + || (mCurEnvVersion != new_version && new_version == UNSET_PARCEL_ENVIRONMENT_VERSION)) + { + // 'pending state' to prevent re-request on following onEnvironmentChanged if there will be any + mCurEnvVersion = new_version; + mCurrentEnvironment.reset(); + + refreshFromSource(); + } + else if (mCurrentEnvironment) + { + // update controls + refresh(); + } + } + } +} + + +void LLPanelEnvironmentInfo::onPickerAssetDownloaded(LLSettingsBase::ptr_t settings) +{ + LLSettingsVODay::buildFromOtherSetting(settings, [this](LLSettingsDay::ptr_t pday) + { + if (pday) + { + mCurrentEnvironment->mDayCycle = pday; + setDirtyFlag(DIRTY_FLAG_DAYCYCLE); + } + refresh(); + }); +} + +void LLPanelEnvironmentInfo::onEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) +{ + if (parcel_id != getParcelId()) + { + LL_WARNS("ENVPANEL") << "Have environment for parcel " << parcel_id << " expecting " << getParcelId() << ". Discarding." << LL_ENDL; + return; + } + mCurrentEnvironment = envifo; + clearDirtyFlag(DIRTY_FLAG_MASK); + if (mCurrentEnvironment->mEnvVersion > INVALID_PARCEL_ENVIRONMENT_VERSION) + { + // Server provided version, use it + mCurEnvVersion = mCurrentEnvironment->mEnvVersion; + LL_DEBUGS("ENVPANEL") << " Setting environment version: " << mCurEnvVersion << " for parcel id: " << parcel_id << LL_ENDL; + } + // Backup: Version was not provided for some reason + else + { + LL_WARNS("ENVPANEL") << " Environment version was not provided for " << parcel_id << ", old env version: " << mCurEnvVersion << LL_ENDL; + } + + refreshFromEstate(); + refresh(); + + // todo: we have envifo and parcel env version, should we just setEnvironment() and parcel's property to prevent dupplicate requests? +} + +void LLPanelEnvironmentInfo::_onEnvironmentReceived(LLHandle<LLPanel> that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) +{ + LLPanelEnvironmentInfo *that = (LLPanelEnvironmentInfo *)that_h.get(); + if (!that) + return; + that->onEnvironmentReceived(parcel_id, envifo); +} + +LLSettingsDropTarget::LLSettingsDropTarget(const LLSettingsDropTarget::Params& p) + : LLView(p), mEnvironmentInfoPanel(NULL), mDndEnabled(false) +{} + +BOOL LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + BOOL handled = FALSE; + + if (getParent() && mDndEnabled) + { + handled = TRUE; + + switch (cargo_type) + { + case DAD_SETTINGS: + { + LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; + if (inv_item && mEnvironmentInfoPanel) + { + LLUUID item_id = inv_item->getUUID(); + if (gInventory.getItem(item_id)) + { + *accept = ACCEPT_YES_COPY_SINGLE; + if (drop) + { + // might be better to use name of the element + mEnvironmentInfoPanel->onPickerCommitted(item_id, mTrack); + } + } + } + else + { + *accept = ACCEPT_NO; + } + break; + } + default: + *accept = ACCEPT_NO; + break; + } + } + return handled; +} diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h new file mode 100644 index 0000000000..9eb4040758 --- /dev/null +++ b/indra/newview/llpanelenvironment.h @@ -0,0 +1,220 @@ +/** + * @file llpanelenvironment.h + * @brief LLPanelExperiences class definition + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLPANELENVIRONMENT_H +#define LL_LLPANELENVIRONMENT_H + +#include "llaccordionctrltab.h" +#include "llradiogroup.h" +#include "llcheckboxctrl.h" +#include "llsliderctrl.h" +#include "llsettingsdaycycle.h" +#include "llenvironment.h" +#include "llparcel.h" +#include "llsettingspicker.h" +#include "llfloatereditextdaycycle.h" +#include "llestateinfomodel.h" + +class LLViewerRegion; + +class LLPanelEnvironmentInfo : public LLPanel +{ + friend class LLSettingsDropTarget; +public: + LLPanelEnvironmentInfo(); + virtual ~LLPanelEnvironmentInfo(); + + virtual BOOL postBuild() override; + virtual void onOpen(const LLSD& key) override; + + virtual BOOL isDirty() const override { return getIsDirty(); } + virtual void onVisibilityChange(BOOL new_visibility) override; + + virtual void refresh() override; + + virtual bool isRegion() const = 0; + virtual LLParcel * getParcel() = 0; + virtual bool canEdit() = 0; + virtual S32 getParcelId() = 0; + +protected: + LOG_CLASS(LLPanelEnvironmentInfo); + + static const std::string BTN_SELECTINV; + static const std::string BTN_EDIT; + static const std::string BTN_USEDEFAULT; + static const std::string BTN_RST_ALTITUDES; + static const std::string SLD_DAYLENGTH; + static const std::string SLD_DAYOFFSET; + static const std::string SLD_ALTITUDES; + static const std::string ICN_GROUND; + static const std::string ICN_WATER; + static const std::string CHK_ALLOWOVERRIDE; + static const std::string BTN_APPLY; + static const std::string BTN_CANCEL; + static const std::string LBL_TIMEOFDAY; + static const std::string PNL_SETTINGS; + static const std::string PNL_ENVIRONMENT_ALTITUDES; + static const std::string PNL_BUTTONS; + static const std::string PNL_DISABLED; + static const std::string TXT_DISABLED; + static const std::string SDT_DROP_TARGET; + + static const std::string STR_LABEL_USEDEFAULT; + static const std::string STR_LABEL_USEREGION; + static const std::string STR_ALTITUDE_DESCRIPTION; + static const std::string STR_NO_PARCEL; + static const std::string STR_CROSS_REGION; + static const std::string STR_LEGACY; + static const std::string STR_DISALLOWED; + static const std::string STR_TOO_SMALL; + + static const S32 MINIMUM_PARCEL_SIZE; + + static const U32 DIRTY_FLAG_DAYCYCLE; + static const U32 DIRTY_FLAG_DAYLENGTH; + static const U32 DIRTY_FLAG_DAYOFFSET; + static const U32 DIRTY_FLAG_ALTITUDES; + + static const U32 DIRTY_FLAG_MASK; + + bool setControlsEnabled(bool enabled); + void setDirtyFlag(U32 flag); + void clearDirtyFlag(U32 flag); + bool getIsDirty() const { return (mDirtyFlag != 0); } + bool getIsDirtyFlag(U32 flag) const { return ((mDirtyFlag & flag) != 0); } + U32 getDirtyFlag() const { return mDirtyFlag; } + void updateAltLabel(const std::string &alt_prefix, U32 sky_index, F32 alt_value); + void readjustAltLabels(); + + void onSldDayLengthChanged(F32 value); + void onSldDayOffsetChanged(F32 value); + void onAltSliderCallback(LLUICtrl *cntrl, const LLSD &data); + void onAltSliderMouseUp(); + + void onBtnEdit(); + void onBtnSelect(); + void onBtnDefault(); + void onBtnRstAltitudes(); + + void udpateApparentTimeOfDay(); + + void onPickerCommitted(LLUUID item_id, std::string source); + void onPickerCommitted(LLUUID item_id, S32 track_num = LLEnvironment::NO_TRACK); + void onEditCommitted(LLSettingsDay::ptr_t newday); + void onDayLenOffsetMouseUp(); + + void onPickerAssetDownloaded(LLSettingsBase::ptr_t settings); + void onEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); + static void _onEnvironmentReceived(LLHandle<LLPanel> that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); + + virtual bool isLargeEnough() = 0; + virtual void refreshFromSource() = 0; + + std::string getNameForTrackIndex(S32 index); + + LLFloaterSettingsPicker * getSettingsPicker(bool create = true); + LLFloaterEditExtDayCycle * getEditFloater(bool create = true); + void updateEditFloater(const LLEnvironment::EnvironmentInfo::ptr_t &nextenv, bool enable); + + void setCrossRegion(bool val) { mCrossRegion = val; } + void setNoSelection(bool val) { mNoSelection = val; } + void setNoEnvironmentSupport(bool val) { mNoEnvironment = val; } + + LLEnvironment::EnvironmentInfo::ptr_t mCurrentEnvironment; + + void onEnvironmentChanged(LLEnvironment::EnvSelection_t env, S32 version); + + class AltitudeData + { + public: + AltitudeData() : + mTrackIndex(0), mLabelIndex(0), mAltitude(0) + {} + AltitudeData(U32 track_index, U32 label_index, F32 altitude) : + mTrackIndex(track_index), mLabelIndex(label_index), mAltitude(altitude) + {} + + U32 mTrackIndex; + U32 mLabelIndex; + F32 mAltitude; + }; + typedef std::map<std::string, AltitudeData> altitudes_data_t; + altitudes_data_t mAltitudes; + S32 mCurEnvVersion; // used to filter duplicate callbacks/refreshes + +protected: + typedef boost::signals2::connection connection_t; + + void refreshFromEstate(); + bool mAllowOverride; + +private: + static void onIdlePlay(void *); + + connection_t mCommitConnection; + connection_t mChangeMonitor; + connection_t mUpdateConnection; + + LLHandle<LLFloater> mSettingsFloater; + LLHandle<LLFloater> mEditFloater; + S32 mDirtyFlag; + S32 mEditorLastParcelId; + LLUUID mEditorLastRegionId; + bool mCrossRegion; + bool mNoSelection; + bool mNoEnvironment; + +}; + +class LLSettingsDropTarget : public LLView +{ +public: + struct Params : public LLInitParam::Block<Params, LLView::Params> + { + Params() + { + changeDefault(mouse_opaque, false); + changeDefault(follows.flags, FOLLOWS_ALL); + } + }; + LLSettingsDropTarget(const Params&); + ~LLSettingsDropTarget() {}; + + virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg); + void setPanel(LLPanelEnvironmentInfo* panel, std::string track) { mEnvironmentInfoPanel = panel; mTrack = track; }; + void setDndEnabled(bool dnd_enabled) { mDndEnabled = dnd_enabled; }; + +protected: + LLPanelEnvironmentInfo* mEnvironmentInfoPanel; + std::string mTrack; + bool mDndEnabled; +}; +#endif // LL_LLPANELENVIRONMENT_H diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index ce6834b4b3..7373c7412c 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -155,6 +155,7 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, case DAD_GESTURE: case DAD_CALLINGCARD: case DAD_MESH: + case DAD_SETTINGS: { LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; if(gInventory.getItem(inv_item->getUUID()) diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index db9d61c637..b5e24b6efb 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -58,6 +58,7 @@ #include "llsidepanelinventory.h" #include "llfolderview.h" #include "llradiogroup.h" +#include "llenvironment.h" const std::string FILTERS_FILENAME("filters.xml"); @@ -128,6 +129,9 @@ LLPanelMainInventory::LLPanelMainInventory(const LLPanel::Params& p) mCommitCallbackRegistrar.add("Inventory.SetSortBy", boost::bind(&LLPanelMainInventory::setSortBy, this, _2)); mCommitCallbackRegistrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars, this)); + mEnableCallbackRegistrar.add("Inventory.EnvironmentEnabled", [](LLUICtrl *, const LLSD &) { return LLPanelMainInventory::hasSettingsInventory(); }); + + mSavedFolderState = new LLSaveFolderState(); mSavedFolderState->setApply(FALSE); } @@ -905,6 +909,7 @@ void LLFloaterInventoryFinder::updateElementsFromFilter() getChild<LLUICtrl>("check_sound")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND)); getChild<LLUICtrl>("check_texture")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE)); getChild<LLUICtrl>("check_snapshot")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT)); + getChild<LLUICtrl>("check_settings")->setValue((S32)(filter_types & 0x1 << LLInventoryType::IT_SETTINGS)); getChild<LLUICtrl>("check_show_empty")->setValue(show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS); getChild<LLUICtrl>("check_created_by_me")->setValue(show_created_by_me); @@ -997,6 +1002,12 @@ void LLFloaterInventoryFinder::draw() filtered_by_all_types = FALSE; } + if (!getChild<LLUICtrl>("check_settings")->getValue()) + { + filter &= ~(0x1 << LLInventoryType::IT_SETTINGS); + filtered_by_all_types = FALSE; + } + if (!filtered_by_all_types || (mPanelMainInventory->getPanel()->getFilter().getFilterTypes() & LLInventoryFilter::FILTERTYPE_DATE)) { // don't include folders in filter, unless I've selected everything or filtering by date @@ -1114,7 +1125,8 @@ void LLFloaterInventoryFinder::selectAllTypes(void* user_data) self->getChild<LLUICtrl>("check_script")->setValue(TRUE); self->getChild<LLUICtrl>("check_sound")->setValue(TRUE); self->getChild<LLUICtrl>("check_texture")->setValue(TRUE); - self->getChild<LLUICtrl>("check_snapshot")->setValue(TRUE); + self->getChild<LLUICtrl>("check_snapshot")->setValue(TRUE); + self->getChild<LLUICtrl>("check_settings")->setValue(TRUE); } //static @@ -1135,6 +1147,7 @@ void LLFloaterInventoryFinder::selectNoTypes(void* user_data) self->getChild<LLUICtrl>("check_sound")->setValue(FALSE); self->getChild<LLUICtrl>("check_texture")->setValue(FALSE); self->getChild<LLUICtrl>("check_snapshot")->setValue(FALSE); + self->getChild<LLUICtrl>("check_settings")->setValue(FALSE); } ////////////////////////////////////////////////////////////////////////////////// @@ -1546,5 +1559,10 @@ void LLPanelMainInventory::setUploadCostIfNeeded() } } +bool LLPanelMainInventory::hasSettingsInventory() +{ + return LLEnvironment::instance().isInventoryEnabled(); +} + // List Commands // //////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index 732a3b04e3..a6bdee233d 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -161,6 +161,7 @@ protected: BOOL isActionChecked(const LLSD& userdata); void onCustomAction(const LLSD& command_name); bool handleDragAndDropToTrash(BOOL drop, EDragAndDropType cargo_type, EAcceptance* accept); + static bool hasSettingsInventory(); /** * Set upload cost in "Upload" sub menu. */ diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index cd1875e995..35c5407e6c 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -143,6 +143,7 @@ public: virtual bool hasChildren() const { return FALSE; } virtual LLInventoryType::EType getInventoryType() const { return LLInventoryType::IT_NONE; } virtual LLWearableType::EType getWearableType() const { return LLWearableType::WT_NONE; } + virtual LLSettingsType::type_e getSettingsType() const { return LLSettingsType::ST_NONE; } virtual EInventorySortGroup getSortGroup() const { return SG_ITEM; } virtual LLInventoryObject* getInventoryObject() const { return findInvObject(); } @@ -702,6 +703,7 @@ BOOL LLTaskCategoryBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_GESTURE: case DAD_CALLINGCARD: case DAD_MESH: + case DAD_SETTINGS: accept = LLToolDragAndDrop::isInventoryDropAcceptable(object, (LLViewerInventoryItem*)cargo_data); if(accept && drop) { @@ -1208,6 +1210,34 @@ void LLTaskMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } ///---------------------------------------------------------------------------- +/// Class LLTaskSettingsBridge +///---------------------------------------------------------------------------- + +class LLTaskSettingsBridge : public LLTaskInvFVBridge +{ +public: + LLTaskSettingsBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name, + U32 flags) : + LLTaskInvFVBridge(panel, uuid, name, flags) {} + + virtual LLUIImagePtr getIcon() const; + virtual LLSettingsType::type_e getSettingsType() const; +}; + +LLUIImagePtr LLTaskSettingsBridge::getIcon() const +{ + return LLInventoryIcon::getIcon(mAssetType, mInventoryType, mFlags, FALSE); +} + +LLSettingsType::type_e LLTaskSettingsBridge::getSettingsType() const +{ + return LLSettingsType::ST_NONE; +} + + +///---------------------------------------------------------------------------- /// LLTaskInvFVBridge impl //---------------------------------------------------------------------------- @@ -1293,6 +1323,12 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory* object_id, object_name); break; + case LLAssetType::AT_SETTINGS: + new_bridge = new LLTaskSettingsBridge(panel, + object_id, + object_name, + itemflags); + break; default: LL_INFOS() << "Unhandled inventory type (llassetstorage.h): " << (S32)type << LL_ENDL; diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 5f413fc3c0..3d3dccee0b 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -64,8 +64,8 @@ #include "llvector4a.h" // Functions pulled from pipeline.cpp -glh::matrix4f glh_get_current_modelview(); -glh::matrix4f glh_get_current_projection(); +glh::matrix4f get_current_modelview(); +glh::matrix4f get_current_projection(); // Functions pulled from llviewerdisplay.cpp bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model); @@ -642,7 +642,7 @@ void LLPanelPrimMediaControls::updateShape() glh::matrix4f mat; if (!is_hud) { - mat = glh_get_current_projection() * glh_get_current_modelview(); + mat = get_current_projection() * get_current_modelview(); } else { glh::matrix4f proj, modelview; diff --git a/indra/newview/llpanelsnapshotpostcard.cpp b/indra/newview/llpanelsnapshotpostcard.cpp index f3a4cf36ee..b8aa976657 100644 --- a/indra/newview/llpanelsnapshotpostcard.cpp +++ b/indra/newview/llpanelsnapshotpostcard.cpp @@ -170,14 +170,16 @@ void LLPanelSnapshotPostcard::sendPostcard() std::string url = gAgent.getRegion()->getCapability("SendPostcard"); if (!url.empty()) { - LLResourceUploadInfo::ptr_t uploadInfo(new LLPostcardUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLPostcardUploadInfo>( getChild<LLUICtrl>("name_form")->getValue().asString(), getChild<LLUICtrl>("to_form")->getValue().asString(), getChild<LLUICtrl>("subject_form")->getValue().asString(), getChild<LLUICtrl>("msg_form")->getValue().asString(), mSnapshotFloater->getPosTakenGlobal(), mSnapshotFloater->getImageData(), - boost::bind(&LLPanelSnapshotPostcard::sendPostcardFinished, _4))); + [](LLUUID, LLUUID, LLUUID, LLSD response) { + LLPanelSnapshotPostcard::sendPostcardFinished(response); + })); LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 96dd309fa4..4993441508 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -560,7 +560,7 @@ void LLPanelVolume::refresh() mRootObject = NULL; } - BOOL visible = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 0 ? TRUE : FALSE; + BOOL visible = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 0 ? TRUE : FALSE; getChildView("Light FOV")->setVisible( visible); getChildView("Light Focus")->setVisible( visible); diff --git a/indra/newview/llplacesinventorypanel.cpp b/indra/newview/llplacesinventorypanel.cpp index 5eadd65884..a23830e8e1 100644 --- a/indra/newview/llplacesinventorypanel.cpp +++ b/indra/newview/llplacesinventorypanel.cpp @@ -78,6 +78,7 @@ LLFolderView * LLPlacesInventoryPanel::createFolderRoot(LLUUID root_id ) p.view_model = &mInventoryViewModel; p.use_label_suffix = mParams.use_label_suffix; p.allow_multiselect = mAllowMultiSelect; + p.allow_drag = mAllowDrag; p.show_empty_message = mShowEmptyMessage; p.show_item_link_overlays = mShowItemLinkOverlays; p.root = NULL; diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 787bd68e58..70ce275734 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -1091,7 +1091,7 @@ void LLPreviewGesture::saveIfNeeded() const LLViewerRegion* region = gAgent.getRegion(); if (!region) { - LL_WARNS() << "Not connected to a region, cannot save notecard." << LL_ENDL; + LL_WARNS() << "Not connected to a region, cannot save gesture." << LL_ENDL; return; } std::string agent_url = region->getCapability("UpdateGestureAgentInventory"); @@ -1111,13 +1111,15 @@ void LLPreviewGesture::saveIfNeeded() refresh(); item->setComplete(true); - uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_GESTURE, buffer, - boost::bind(&LLPreviewGesture::finishInventoryUpload, _1, _2))); + uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mItemUUID, LLAssetType::AT_GESTURE, buffer, + [](LLUUID itemId, LLUUID newAssetId, LLUUID, LLSD) { + LLPreviewGesture::finishInventoryUpload(itemId, newAssetId); + }); url = agent_url; } else if (!mObjectUUID.isNull() && !task_url.empty()) { - uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, NULL)); + uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, nullptr); url = task_url; } diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index d4a8bbdf45..9a0a80147a 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -110,13 +110,15 @@ bool LLPreviewNotecard::saveItem() void LLPreviewNotecard::setEnabled( BOOL enabled ) { - - LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor"); - - getChildView("Notecard Editor")->setEnabled(enabled); - getChildView("lock")->setVisible( !enabled); - getChildView("desc")->setEnabled(enabled); - getChildView("Save")->setEnabled(enabled && editor && (!editor->isPristine())); + LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); + // editor is part of xml, if it doesn't exists, nothing else does + if (editor) + { + editor->setEnabled(enabled); + getChildView("lock")->setVisible( !enabled); + getChildView("desc")->setEnabled(enabled); + getChildView("Save")->setEnabled(enabled && (!editor->isPristine())); + } } @@ -508,14 +510,19 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) if (mObjectUUID.isNull() && !agent_url.empty()) { - uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mItemUUID, LLAssetType::AT_NOTECARD, buffer, - boost::bind(&LLPreviewNotecard::finishInventoryUpload, _1, _2, _3))); + uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mItemUUID, LLAssetType::AT_NOTECARD, buffer, + [](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD) { + LLPreviewNotecard::finishInventoryUpload(itemId, newAssetId, newItemId); + }); url = agent_url; } else if (!mObjectUUID.isNull() && !task_url.empty()) { - uploadInfo = LLResourceUploadInfo::ptr_t(new LLBufferedAssetUploadInfo(mObjectUUID, mItemUUID, LLAssetType::AT_NOTECARD, buffer, - boost::bind(&LLPreviewNotecard::finishTaskUpload, _1, _3, mObjectUUID))); + LLUUID object_uuid(mObjectUUID); + uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mObjectUUID, mItemUUID, LLAssetType::AT_NOTECARD, buffer, + [object_uuid](LLUUID itemId, LLUUID, LLUUID newAssetId, LLSD) { + LLPreviewNotecard::finishTaskUpload(itemId, newAssetId, object_uuid); + }); url = task_url; } diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 9431914ba3..2773e02598 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -33,7 +33,6 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldir.h" -#include "llenvmanager.h" #include "llexternaleditor.h" #include "llfilepicker.h" #include "llfloaterreg.h" @@ -1710,9 +1709,11 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/) if (!url.empty()) { std::string buffer(mScriptEd->mEditor->getText()); - LLBufferedAssetUploadInfo::invnUploadFinish_f proc = boost::bind(&LLPreviewLSL::finishedLSLUpload, _1, _4); - LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload(mItemUUID, buffer, proc)); + LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mItemUUID, buffer, + [](LLUUID itemId, LLUUID, LLUUID, LLSD response) { + LLPreviewLSL::finishedLSLUpload(itemId, response); + })); LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } @@ -2260,11 +2261,13 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/) if (!url.empty()) { std::string buffer(mScriptEd->mEditor->getText()); - LLBufferedAssetUploadInfo::taskUploadFinish_f proc = boost::bind(&LLLiveLSLEditor::finishLSLUpload, _1, _2, _3, _4, isRunning); - LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload(mObjectUUID, mItemUUID, + LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mObjectUUID, mItemUUID, monoChecked() ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2, - isRunning, mScriptEd->getAssociatedExperience(), buffer, proc)); + isRunning, mScriptEd->getAssociatedExperience(), buffer, + [isRunning](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) { + LLLiveLSLEditor::finishLSLUpload(itemId, taskId, newAssetId, response, isRunning); + })); LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); } diff --git a/indra/newview/llscriptruntimeperms.h b/indra/newview/llscriptruntimeperms.h index 51f57afdc9..f692c0ad01 100644 --- a/indra/newview/llscriptruntimeperms.h +++ b/indra/newview/llscriptruntimeperms.h @@ -37,7 +37,7 @@ typedef struct _script_perm { question(q), permbit(b), caution(c) {} } script_perm_t; -const U32 NUM_SCRIPT_PERMISSIONS = 16; +const U32 NUM_SCRIPT_PERMISSIONS = 18; const S32 SCRIPT_PERMISSION_DEBIT = 0; const S32 SCRIPT_PERMISSION_TRIGGER_ANIMATION = 3; const S32 SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS = 14; @@ -58,7 +58,9 @@ static const boost::array<script_perm_t, NUM_SCRIPT_PERMISSIONS> SCRIPT_PERMISSI _script_perm("JoinAnExperience", (0x1 << 13), false), _script_perm("SilentlyManageEstateAccess", (0x1 << 14), false), _script_perm("OverrideYourAnimations", (0x1 << 15), false), - _script_perm("ScriptReturnObjects", (0x1 << 16), false) -}}; + _script_perm("ScriptReturnObjects", (0x1 << 16), false), + _script_perm("ForceSitAvatar", (0x1 << 17), false), + _script_perm("ChangeEnvSettings", (0x1 << 18), false) + } }; #endif // LL_LLSCRIPTRUNTIME_PERMS_H diff --git a/indra/newview/llsettingspicker.cpp b/indra/newview/llsettingspicker.cpp new file mode 100644 index 0000000000..b47821ddf2 --- /dev/null +++ b/indra/newview/llsettingspicker.cpp @@ -0,0 +1,509 @@ +/** +* @author Rider Linden +* @brief LLSettingsPicker class header file including related functions +* +* $LicenseInfo:firstyear=2018&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2018, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "llsettingspicker.h" + +#include "llcombobox.h" +#include "llfiltereditor.h" +#include "llfolderviewmodel.h" +#include "llinventory.h" +#include "llinventorybridge.h" +#include "llinventoryfunctions.h" +#include "llinventorymodelbackgroundfetch.h" +#include "llinventoryobserver.h" +#include "llinventorypanel.h" +#include "llsettingsvo.h" + +#include "lldraghandle.h" +#include "llviewercontrol.h" +#include "llagent.h" + +//========================================================================= +namespace +{ + const std::string FLOATER_DEFINITION_XML("floater_settings_picker.xml"); + + const std::string FLT_INVENTORY_SEARCH("flt_inventory_search"); + const std::string CMB_TRACK_SELECTION("track_selection"); + const std::string PNL_INVENTORY("pnl_inventory"); + const std::string PNL_COMBO("pnl_combo"); + const std::string BTN_SELECT("btn_select"); + const std::string BTN_CANCEL("btn_cancel"); + + // strings in xml + + const std::string STR_TITLE_PREFIX = "pick title"; + const std::string STR_TITLE_TRACK = "pick_track"; + const std::string STR_TITLE_SETTINGS = "pick_settings"; + const std::string STR_TRACK_WATER = "track_water"; + const std::string STR_TRACK_GROUND = "track_ground"; + const std::string STR_TRACK_SKY = "track_sky"; +} +//========================================================================= + +LLFloaterSettingsPicker::LLFloaterSettingsPicker(LLView * owner, LLUUID initial_item_id, const LLSD ¶ms): + LLFloater(params), + mOwnerHandle(), + mActive(true), + mContextConeOpacity(0.0f), + mSettingItemID(initial_item_id), + mTrackMode(TRACK_NONE), + mImmediateFilterPermMask(PERM_NONE) +{ + mOwnerHandle = owner->getHandle(); + + buildFromFile(FLOATER_DEFINITION_XML); + setCanMinimize(FALSE); +} + + +LLFloaterSettingsPicker::~LLFloaterSettingsPicker() +{ + +} + +//------------------------------------------------------------------------- +BOOL LLFloaterSettingsPicker::postBuild() +{ + if (!LLFloater::postBuild()) + return FALSE; + + std::string prefix = getString(STR_TITLE_PREFIX); + std::string label = getString(STR_TITLE_SETTINGS); + setTitle(prefix + " " + label); + + mFilterEdit = getChild<LLFilterEditor>(FLT_INVENTORY_SEARCH); + mFilterEdit->setCommitCallback([this](LLUICtrl*, const LLSD& param){ onFilterEdit(param.asString()); }); + + mInventoryPanel = getChild<LLInventoryPanel>(PNL_INVENTORY); + if (mInventoryPanel) + { + U32 filter_types = 0x0; + filter_types |= 0x1 << LLInventoryType::IT_SETTINGS; + + mInventoryPanel->setFilterTypes(filter_types); + mInventoryPanel->setFilterPermMask(mImmediateFilterPermMask); + + mInventoryPanel->setSelectCallback([this](const LLFloaterSettingsPicker::itemlist_t &items, bool useraction){ onSelectionChange(items, useraction); }); + mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); + mInventoryPanel->setSuppressOpenItemAction(true); + + // Disable auto selecting first filtered item because it takes away + // selection from the item set by LLTextureCtrl owning this floater. + mInventoryPanel->getRootFolder()->setAutoSelectOverride(TRUE); + + // don't put keyboard focus on selected item, because the selection callback + // will assume that this was user input + if (!mSettingItemID.isNull()) + { + //todo: this is bad idea + mInventoryPanel->setSelection(mSettingItemID, TAKE_FOCUS_NO); + } + getChild<LLView>(BTN_SELECT)->setEnabled(mSettingItemID.notNull()); + } + + mNoCopySettingsSelected = FALSE; + + childSetAction(BTN_CANCEL, [this](LLUICtrl*, const LLSD& param){ onButtonCancel(); }); + childSetAction(BTN_SELECT, [this](LLUICtrl*, const LLSD& param){ onButtonSelect(); }); + + getChild<LLPanel>(PNL_COMBO)->setVisible(mTrackMode != TRACK_NONE); + + // update permission filter once UI is fully initialized + mSavedFolderState.setApply(FALSE); + + return TRUE; +} + +void LLFloaterSettingsPicker::onClose(bool app_quitting) +{ + if (app_quitting) + return; + + mCloseSignal(); + LLView *owner = mOwnerHandle.get(); + if (owner) + { + owner->setFocus(TRUE); + } + mSettingItemID.setNull(); + mInventoryPanel->getRootFolder()->clearSelection(); +} + +void LLFloaterSettingsPicker::setValue(const LLSD& value) +{ + mSettingItemID = value.asUUID(); +} + +LLSD LLFloaterSettingsPicker::getValue() const +{ + return LLSD(mSettingItemID); +} + +void LLFloaterSettingsPicker::setSettingsFilter(LLSettingsType::type_e type) +{ + U64 filter = 0xFFFFFFFFFFFFFFFF; + if (type != LLSettingsType::ST_NONE) + { + filter = static_cast<S64>(0x1) << static_cast<S64>(type); + } + + mInventoryPanel->setFilterSettingsTypes(filter); +} + +void LLFloaterSettingsPicker::setTrackMode(ETrackMode mode) +{ + mTrackMode = mode; + getChild<LLPanel>(PNL_COMBO)->setVisible(mode != TRACK_NONE); + + std::string prefix = getString(STR_TITLE_PREFIX); + std::string label; + if (mode != TRACK_NONE) + { + label = getString(STR_TITLE_TRACK); + } + else + { + label = getString(STR_TITLE_SETTINGS); + } + setTitle(prefix + " " + label); +} + +void LLFloaterSettingsPicker::draw() +{ + LLView *owner = mOwnerHandle.get(); + static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, owner); + + LLFloater::draw(); +} + + +//========================================================================= +void LLFloaterSettingsPicker::onFilterEdit(const std::string& search_string) +{ + std::string upper_case_search_string = search_string; + LLStringUtil::toUpper(upper_case_search_string); + + if (upper_case_search_string.empty()) + { + if (mInventoryPanel->getFilterSubString().empty()) + { + // current filter and new filter empty, do nothing + return; + } + + mSavedFolderState.setApply(TRUE); + mInventoryPanel->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + // add folder with current item to list of previously opened folders + LLOpenFoldersWithSelection opener; + mInventoryPanel->getRootFolder()->applyFunctorRecursively(opener); + mInventoryPanel->getRootFolder()->scrollToShowSelection(); + + } + else if (mInventoryPanel->getFilterSubString().empty()) + { + // first letter in search term, save existing folder open state + if (!mInventoryPanel->getFilter().isNotDefault()) + { + mSavedFolderState.setApply(FALSE); + mInventoryPanel->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + } + } + + mInventoryPanel->setFilterSubString(search_string); +} + +void LLFloaterSettingsPicker::onSelectionChange(const LLFloaterSettingsPicker::itemlist_t &items, bool user_action) +{ + bool is_item = false; + LLUUID asset_id; + if (items.size()) + { + LLFolderViewItem* first_item = items.front(); + + mNoCopySettingsSelected = false; + if (first_item) + { + LLItemBridge *bridge_model = dynamic_cast<LLItemBridge *>(first_item->getViewModelItem()); + if (bridge_model && bridge_model->getItem()) + { + if (!bridge_model->isItemCopyable()) + { + mNoCopySettingsSelected = true; + } + setSettingsItemId(bridge_model->getItem()->getUUID(), false); + asset_id = bridge_model->getItem()->getAssetUUID(); + mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? + is_item = true; + + if (user_action) + { + mChangeIDSignal(mSettingItemID); + } + } + } + } + bool track_picker_enabled = mTrackMode != TRACK_NONE; + + getChild<LLView>(CMB_TRACK_SELECTION)->setEnabled(track_picker_enabled && mSettingAssetID == asset_id); + getChild<LLView>(BTN_SELECT)->setEnabled(is_item && (!track_picker_enabled || mSettingAssetID == asset_id)); + if (track_picker_enabled && asset_id.notNull() && mSettingAssetID != asset_id) + { + LLUUID item_id = mSettingItemID; + LLHandle<LLFloater> handle = getHandle(); + LLSettingsVOBase::getSettingsAsset(asset_id, + [item_id, handle](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { LLFloaterSettingsPicker::onAssetLoadedCb(handle, item_id, asset_id, settings, status); }); + } +} + +void LLFloaterSettingsPicker::onAssetLoadedCb(LLHandle<LLFloater> handle, LLUUID item_id, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +{ + if (handle.isDead() || status) + { + return; + } + + LLFloaterSettingsPicker *picker = static_cast<LLFloaterSettingsPicker *>(handle.get()); + + if (picker->mSettingItemID != item_id) + { + return; + } + + picker->onAssetLoaded(asset_id, settings); +} + +void LLFloaterSettingsPicker::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings) +{ + LLComboBox* track_selection = getChild<LLComboBox>(CMB_TRACK_SELECTION); + track_selection->clear(); + track_selection->removeall(); + if (!settings) + { + LL_WARNS() << "Failed to load asset " << asset_id << LL_ENDL; + return; + } + LLSettingsDay::ptr_t pday = std::dynamic_pointer_cast<LLSettingsDay>(settings); + + if (!pday) + { + LL_WARNS() << "Wrong asset type received by id " << asset_id << LL_ENDL; + return; + } + + if (mTrackMode == TRACK_WATER) + { + track_selection->add(getString(STR_TRACK_WATER), LLSD::Integer(LLSettingsDay::TRACK_WATER), ADD_TOP, true); + } + else if (mTrackMode == TRACK_SKY) + { + // track 1 always present + track_selection->add(getString(STR_TRACK_GROUND), LLSD::Integer(LLSettingsDay::TRACK_GROUND_LEVEL), ADD_TOP, true); + LLUIString formatted_label = getString(STR_TRACK_SKY); + for (int i = 2; i < LLSettingsDay::TRACK_MAX; i++) + { + if (!pday->isTrackEmpty(i)) + { + formatted_label.setArg("[NUM]", llformat("%d", i)); + track_selection->add(formatted_label.getString(), LLSD::Integer(i), ADD_TOP, true); + } + } + } + + mSettingAssetID = asset_id; + track_selection->setEnabled(true); + track_selection->selectFirstItem(); + getChild<LLView>(BTN_SELECT)->setEnabled(true); +} + +void LLFloaterSettingsPicker::onButtonCancel() +{ + closeFloater(); +} + +void LLFloaterSettingsPicker::onButtonSelect() +{ + if (mCommitSignal) + { + LLSD res; + res["ItemId"] = mSettingItemID; + res["Track"] = getChild<LLComboBox>(CMB_TRACK_SELECTION)->getValue(); + (*mCommitSignal)(this, res); + } + closeFloater(); +} + +BOOL LLFloaterSettingsPicker::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + BOOL result = FALSE; + if (mSettingItemID.notNull() + && mInventoryPanel) + { + S32 inventory_x = x - mInventoryPanel->getRect().mLeft; + S32 inventory_y = y - mInventoryPanel->getRect().mBottom; + if (mInventoryPanel->parentPointInView(inventory_x, inventory_y)) + { + // make sure item is selected and visible + LLFolderViewItem* item_viewp = mInventoryPanel->getItemByID(mSettingItemID); + if (item_viewp && item_viewp->getIsCurSelection() && item_viewp->getVisible()) + { + LLRect target_rect; + item_viewp->localRectToOtherView(item_viewp->getLocalRect(), &target_rect, this); + if (target_rect.pointInRect(x, y)) + { + // Quick-apply + if (mCommitSignal) + { + LLSD res; + res["ItemId"] = mSettingItemID; + res["Track"] = getChild<LLComboBox>(CMB_TRACK_SELECTION)->getValue(); + (*mCommitSignal)(this, res); + } + closeFloater(); + // hit inside panel on selected item, double click should do nothing + result = TRUE; + } + } + } + } + + if (!result) + { + result = LLFloater::handleDoubleClick(x, y, mask); + } + return result; +} + +BOOL LLFloaterSettingsPicker::handleKeyHere(KEY key, MASK mask) +{ + if ((key == KEY_RETURN) && (mask == MASK_NONE)) + { + LLFolderViewItem* item_viewp = mInventoryPanel->getItemByID(mSettingItemID); + if (item_viewp && item_viewp->getIsCurSelection() && item_viewp->getVisible()) + { + // Quick-apply + if (mCommitSignal) + { + LLSD res; + res["ItemId"] = mSettingItemID; + res["Track"] = getChild<LLComboBox>(CMB_TRACK_SELECTION)->getValue(); + (*mCommitSignal)(this, res); + } + closeFloater(); + return TRUE; + } + } + + return LLFloater::handleKeyHere(key, mask); +} + +void LLFloaterSettingsPicker::onFocusLost() +{ + if (isInVisibleChain()) + { + closeFloater(); + } +} + +//========================================================================= +void LLFloaterSettingsPicker::setActive(bool active) +{ + mActive = active; +} + +void LLFloaterSettingsPicker::setSettingsItemId(const LLUUID &settings_id, bool set_selection) +{ + if (mSettingItemID != settings_id && mActive) + { + mNoCopySettingsSelected = false; + mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? + mSettingItemID = settings_id; + if (mSettingItemID.isNull()) + { + mInventoryPanel->getRootFolder()->clearSelection(); + } + else + { + LLInventoryItem* itemp = gInventory.getItem(settings_id); + if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) + { + mNoCopySettingsSelected = true; + } + } + + if (set_selection) + { + mInventoryPanel->setSelection(settings_id, TAKE_FOCUS_NO); + } + } +} + +LLInventoryItem* LLFloaterSettingsPicker::findItem(const LLUUID& asset_id, bool copyable_only, bool ignore_library) +{ + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(asset_id); + + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::INCLUDE_TRASH, + asset_id_matches); + + if (items.size()) + { + // search for copyable version first + for (S32 i = 0; i < items.size(); i++) + { + LLInventoryItem* itemp = items[i]; + LLPermissions item_permissions = itemp->getPermissions(); + if (item_permissions.allowCopyBy(gAgent.getID(), gAgent.getGroupID())) + { + if(!ignore_library || !gInventory.isObjectDescendentOf(itemp->getUUID(),gInventory.getLibraryRootFolderID())) + { + return itemp; + } + } + } + // otherwise just return first instance, unless copyable requested + if (copyable_only) + { + return nullptr; + } + else + { + if(!ignore_library || !gInventory.isObjectDescendentOf(items[0]->getUUID(),gInventory.getLibraryRootFolderID())) + { + return items[0]; + } + } + } + + return nullptr; +} diff --git a/indra/newview/llsettingspicker.h b/indra/newview/llsettingspicker.h new file mode 100644 index 0000000000..859f92fbe8 --- /dev/null +++ b/indra/newview/llsettingspicker.h @@ -0,0 +1,137 @@ +/** + * @file llsettingspicker.h + * @author Rider Linden + * @brief LLSettingsPicker class header file including related functions + * + * $LicenseInfo:firstyear=2018&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2018, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_SETTINGSPICKER_H +#define LL_SETTINGSPICKER_H + +#include "llinventorysettings.h" +#include "llfloater.h" +#include "llpermissionsflags.h" +#include "llfolderview.h" +#include "llinventory.h" +#include "llsettingsdaycycle.h" + +#include <boost/signals2.hpp> + +//========================================================================= +class LLFilterEditor; +class LLInventoryPanel; + +//========================================================================= +class LLFloaterSettingsPicker : public LLFloater +{ +public: + enum ETrackMode + { + TRACK_NONE, + TRACK_WATER, + TRACK_SKY + }; + typedef std::function<void()> close_callback_t; + typedef std::function<void(const LLUUID& item_id)> id_changed_callback_t; + + LLFloaterSettingsPicker(LLView * owner, LLUUID setting_item_id, const LLSD ¶ms = LLSD()); + + virtual ~LLFloaterSettingsPicker() override; + + void setActive(bool active); + + virtual BOOL postBuild() override; + virtual void onClose(bool app_quitting) override; + virtual void draw() override; + + void setSettingsItemId(const LLUUID &settings_id, bool set_selection = true); + LLUUID getSettingsItemId() const { return mSettingItemID; } + + void setSettingsFilter(LLSettingsType::type_e type); + LLSettingsType::type_e getSettingsFilter() const { return mSettingsType; } + + // Only for day cycle + void setTrackMode(ETrackMode mode); + void setTrackWater() { mTrackMode = TRACK_WATER; } + void setTrackSky() { mTrackMode = TRACK_SKY; } + + // Takes a UUID, wraps get/setImageAssetID + virtual void setValue(const LLSD& value) override; + virtual LLSD getValue() const override; + + static LLUUID findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false) + { + LLInventoryItem *pitem = findItem(asset_id, copyable_only, ignore_library); + if (pitem) + return pitem->getUUID(); + return LLUUID::null; + } + + static std::string findItemName(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false) + { + LLInventoryItem *pitem = findItem(asset_id, copyable_only, ignore_library); + if (pitem) + return pitem->getName(); + return std::string(); + } + + static LLInventoryItem * findItem(const LLUUID& asset_id, bool copyable_only, bool ignore_library); + + +private: + typedef std::deque<LLFolderViewItem *> itemlist_t; + + void onFilterEdit(const std::string& search_string); + void onSelectionChange(const itemlist_t &items, bool user_action); + static void onAssetLoadedCb(LLHandle<LLFloater> handle, LLUUID item_id, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); + void onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings); + void onButtonCancel(); + void onButtonSelect(); + virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask) override; + BOOL handleKeyHere(KEY key, MASK mask) override; + void onFocusLost() override; + + + LLHandle<LLView> mOwnerHandle; + LLUUID mSettingItemID; + LLUUID mSettingAssetID; + ETrackMode mTrackMode; + + LLFilterEditor * mFilterEdit; + LLInventoryPanel * mInventoryPanel; + LLSettingsType::type_e mSettingsType; + + F32 mContextConeOpacity; + PermissionMask mImmediateFilterPermMask; + + bool mActive; + bool mNoCopySettingsSelected; + + LLSaveFolderState mSavedFolderState; + +// boost::signals2::signal<void(LLUUID id)> mCommitSignal; + boost::signals2::signal<void()> mCloseSignal; + boost::signals2::signal<void(const LLUUID& item_id)> mChangeIDSignal; +}; + +#endif // LL_LLTEXTURECTRL_H diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp new file mode 100644 index 0000000000..10a0527fe2 --- /dev/null +++ b/indra/newview/llsettingsvo.cpp @@ -0,0 +1,1427 @@ +/** +* @file llsettingsvo.cpp +* @author Rider Linden +* @brief Subclasses for viewer specific settings behaviors. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "llviewercontrol.h" +#include "llsettingsvo.h" + +#include "pipeline.h" + +#include <algorithm> +#include <cstdio> +#include <boost/make_shared.hpp> +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +#include "llglslshader.h" +#include "llviewershadermgr.h" + +#include "llagent.h" +#include "llassettype.h" +#include "llfloaterperms.h" +#include "llnotificationsutil.h" + +#include "llviewerregion.h" +#include "llviewerassetupload.h" +#include "llviewerinventory.h" + +#include "llenvironment.h" +#include "llsky.h" + +#include "llpermissions.h" + +#include "llinventorymodel.h" +#include "llassetstorage.h" +#include "llvfile.h" +#include "lldrawpoolwater.h" + +#include <boost/algorithm/string/replace.hpp> +#include "llinventoryobserver.h" +#include "llinventorydefines.h" + +#include "lltrans.h" + +#undef VERIFY_LEGACY_CONVERSION + +//========================================================================= +namespace +{ + LLSD ensure_array_4(LLSD in, F32 fill); + LLSD read_legacy_preset_data(const std::string &name, const std::string& path, LLSD &messages); + + //------------------------------------------------------------------------- + class LLSettingsInventoryCB : public LLInventoryCallback + { + public: + typedef std::function<void(const LLUUID &)> callback_t; + + LLSettingsInventoryCB(callback_t cbfn) : + mCbfn(cbfn) + { } + + void fire(const LLUUID& inv_item) override { if (mCbfn) mCbfn(inv_item); } + + private: + callback_t mCbfn; + }; + + //------------------------------------------------------------------------- +} + + +//========================================================================= +void LLSettingsVOBase::createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback) +{ + LLTransactionID tid; + U32 nextOwnerPerm = LLFloaterPerms::getNextOwnerPerms("Settings"); + nextOwnerPerm |= PERM_COPY; + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + tid.generate(); + + LLPointer<LLInventoryCallback> cb = new LLSettingsInventoryCB([callback](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, LLSettingsBase::ptr_t(), callback); + }); + + create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, + LLSettingsType::getDefaultName(stype), "", + stype, nextOwnerPerm, cb); +} + + +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback) +{ + U32 nextOwnerPerm = LLPermissions::DEFAULT.getMaskNextOwner(); + createInventoryItem(settings, nextOwnerPerm, parent_id, settings_name, callback); +} + +void LLSettingsVOBase::createInventoryItem(const LLSettingsBase::ptr_t &settings, U32 next_owner_perm, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback) +{ + LLTransactionID tid; + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + tid.generate(); + + LLPointer<LLInventoryCallback> cb = new LLSettingsInventoryCB([settings, callback](const LLUUID &inventoryId) { + LLSettingsVOBase::onInventoryItemCreated(inventoryId, settings, callback); + }); + + if (settings_name.empty()) + { + settings_name = settings->getName(); + } + create_inventory_settings(gAgent.getID(), gAgent.getSessionID(), + parent_id, tid, + settings_name, "", + settings->getSettingsTypeValue(), next_owner_perm, cb); +} + +void LLSettingsVOBase::onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback) +{ + LLViewerInventoryItem *pitem = gInventory.getItem(inventoryId); + if (pitem) + { + LLPermissions perm = pitem->getPermissions(); + if (perm.getMaskEveryone() != PERM_COPY) + { + perm.setMaskEveryone(PERM_COPY); + pitem->setPermissions(perm); + pitem->updateServer(FALSE); + } + } + if (!settings) + { // The item was created as new with no settings passed in. Simulator should have given it the default for the type... check ID, + // no need to upload asset. + LLUUID asset_id; + if (pitem) + { + asset_id = pitem->getAssetUUID(); + } + if (callback) + callback(asset_id, inventoryId, LLUUID::null, LLSD()); + return; + } + // We need to update some inventory stuff here.... maybe. + updateInventoryItem(settings, inventoryId, callback, false); +} + +void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback, bool update_name) +{ + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; + return; + } + + std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + LLViewerInventoryItem *inv_item = gInventory.getItem(inv_item_id); + if (inv_item) + { + bool need_update(false); + LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(inv_item); + + if (settings->getFlag(LLSettingsBase::FLAG_NOTRANS) && new_item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) + { + LLPermissions perm(inv_item->getPermissions()); + perm.setBaseBits(LLUUID::null, FALSE, PERM_TRANSFER); + perm.setOwnerBits(LLUUID::null, FALSE, PERM_TRANSFER); + new_item->setPermissions(perm); + need_update |= true; + } + if (update_name && (settings->getName() != new_item->getName())) + { + new_item->rename(settings->getName()); + settings->setName(new_item->getName()); // account for corrections + need_update |= true; + } + if (need_update) + { + new_item->updateServer(FALSE); + gInventory.updateItem(new_item); + gInventory.notifyObservers(); + } + } + + std::stringstream buffer; + LLSD settingdata(settings->getSettings()); + LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); + + LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), + [settings, callback](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) { + LLSettingsVOBase::onAgentAssetUploadComplete(itemId, newAssetId, newItemId, response, settings, callback); + }); + + LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); +} + +void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID object_id, LLUUID inv_item_id, inventory_result_fn callback) +{ + const LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS("SETTINGS") << "Not connected to a region, cannot save setting." << LL_ENDL; + return; + } + + std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + LL_WARNS("SETTINGS") << "Region does not support settings inventory objects." << LL_ENDL; + LLNotificationsUtil::add("SettingsUnsuported"); + return; + } + + std::stringstream buffer; + LLSD settingdata(settings->getSettings()); + + LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION); + + LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(), + [settings, callback](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) { + LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings, callback); + }); + + LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); +} + +void LLSettingsVOBase::onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) +{ + LL_INFOS("SETTINGS") << "itemId:" << itemId << " newAssetId:" << newAssetId << " newItemId:" << newItemId << " response:" << response << LL_ENDL; + psettings->setAssetId(newAssetId); + if (callback) + callback( newAssetId, itemId, LLUUID::null, response ); +} + +void LLSettingsVOBase::onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback) +{ + LL_INFOS("SETTINGS") << "Upload to task complete!" << LL_ENDL; + psettings->setAssetId(newAssetId); + if (callback) + callback(newAssetId, itemId, taskId, response); +} + + +void LLSettingsVOBase::getSettingsAsset(const LLUUID &assetId, LLSettingsVOBase::asset_download_fn callback) +{ + gAssetStorage->getAssetData(assetId, LLAssetType::AT_SETTINGS, + [callback](LLVFS *vfs, const LLUUID &asset_id, LLAssetType::EType, void *, S32 status, LLExtStat ext_status) + { onAssetDownloadComplete(vfs, asset_id, status, ext_status, callback); }, + nullptr, true); + +} + +void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_id, S32 status, LLExtStat ext_status, LLSettingsVOBase::asset_download_fn callback) +{ + LLSettingsBase::ptr_t settings; + if (!status) + { + LLVFile file(vfs, asset_id, LLAssetType::AT_SETTINGS, LLVFile::READ); + S32 size = file.getSize(); + + std::string buffer(size + 1, '\0'); + file.read((U8 *)buffer.data(), size); + + std::stringstream llsdstream(buffer); + LLSD llsdsettings; + + if (LLSDSerialize::deserialize(llsdsettings, llsdstream, -1)) + { + settings = createFromLLSD(llsdsettings); + } + + if (!settings) + { + status = 1; + LL_WARNS("SETTINGS") << "Unable to create settings object." << LL_ENDL; + } + else + { + settings->setAssetId(asset_id); + } + } + else + { + LL_WARNS("SETTINGS") << "Error retrieving asset " << asset_id << ". Status code=" << status << "(" << LLAssetStorage::getErrorString(status) << ") ext_status=" << ext_status << LL_ENDL; + } + if (callback) + callback(asset_id, settings, status, ext_status); +} + +void LLSettingsVOBase::getSettingsInventory(const LLUUID &inventoryId, inventory_download_fn callback) +{ + +} + +bool LLSettingsVOBase::exportFile(const LLSettingsBase::ptr_t &settings, const std::string &filename, LLSDSerialize::ELLSD_Serialize format) +{ + try + { + std::ofstream file(filename, std::ios::out | std::ios::trunc); + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + + if (!file) + { + LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for writing." << LL_ENDL; + return false; + } + + LLSDSerialize::serialize(settings->getSettings(), file, format); + } + catch (const std::ios_base::failure &e) + { + LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; + return false; + } + + return true; +} + +LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) +{ + LLSD settings; + + try + { + std::ifstream file(filename, std::ios::in); + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + + if (!file) + { + LL_WARNS("SETTINGS") << "Unable to open '" << filename << "' for reading." << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + if (!LLSDSerialize::deserialize(settings, file, -1)) + { + LL_WARNS("SETTINGS") << "Unable to deserialize settings from '" << filename << "'" << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + } + catch (const std::ios_base::failure &e) + { + LL_WARNS("SETTINGS") << "Unable to save settings to file '" << filename << "': " << e.what() << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + return createFromLLSD(settings); +} + +LLSettingsBase::ptr_t LLSettingsVOBase::createFromLLSD(const LLSD &settings) +{ + if (!settings.has(SETTING_TYPE)) + { + LL_WARNS("SETTINGS") << "No settings type in LLSD" << LL_ENDL; + return LLSettingsBase::ptr_t(); + } + + std::string settingtype = settings[SETTING_TYPE].asString(); + + LLSettingsBase::ptr_t psetting; + + if (settingtype == "water") + { + return LLSettingsVOWater::buildWater(settings); + } + else if (settingtype == "sky") + { + return LLSettingsVOSky::buildSky(settings); + } + else if (settingtype == "daycycle") + { + return LLSettingsVODay::buildDay(settings); + } + + LL_WARNS("SETTINGS") << "Unable to determine settings type for '" << settingtype << "'." << LL_ENDL; + return LLSettingsBase::ptr_t(); + +} + +//========================================================================= +LLSettingsVOSky::LLSettingsVOSky(const LLSD &data, bool isAdvanced) +: LLSettingsSky(data) +, m_isAdvanced(isAdvanced) +{ +} + +LLSettingsVOSky::LLSettingsVOSky() +: LLSettingsSky() +, m_isAdvanced(false) +{ +} + +//------------------------------------------------------------------------- +LLSettingsSky::ptr_t LLSettingsVOSky::buildSky(LLSD settings) +{ + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + + LLSD results = LLSettingsBase::settingValidation(settings, validations); + + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + + return std::make_shared<LLSettingsVOSky>(settings, true); +} + + +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages) +{ + + LLSD newsettings = LLSettingsSky::translateLegacySettings(oldsettings); + if (newsettings.isUndefined()) + { + messages["REASONS"] = LLTrans::getString("SettingTranslateError", LLSDMap("NAME", name)); + return LLSettingsSky::ptr_t(); + } + + newsettings[SETTING_NAME] = name; + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + messages["REASONS"] = LLTrans::getString("SettingValidationError", LLSDMap("NAME", name)); + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + + LLSettingsSky::ptr_t skyp = std::make_shared<LLSettingsVOSky>(newsettings); + +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOSky::convertToLegacy(skyp, isAdvanced()); + + if (!llsd_equals(oldsettings, oldsettings)) + { + LL_WARNS("SKY") << "Conversion to/from legacy does not match!\n" + << "Old: " << oldsettings + << "new: " << oldsettings << LL_ENDL; + } + +#endif + + return skyp; +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages) +{ + LLSD legacy_data = read_legacy_preset_data(name, path, messages); + + if (!legacy_data) + { // messages filled in by read_legacy_preset_data + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data, messages); +} + + +LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() +{ + static LLSD default_settings; + + if (!default_settings.size()) + { + default_settings = LLSettingsSky::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + } + + LLSettingsSky::ptr_t skyp = std::make_shared<LLSettingsVOSky>(default_settings); + return skyp; +} + +LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const +{ + LLSD settings = cloneSettings(); + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } + + LLSettingsSky::ptr_t skyp = std::make_shared<LLSettingsVOSky>(settings); + return skyp; +} + +void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) +{ + // These may need to be inferred from new settings' density profiles + // if the legacy settings values are not available. + if (settings.has(SETTING_LEGACY_HAZE)) + { + LLSD legacyhaze = settings[SETTING_LEGACY_HAZE]; + + // work-around for setter formerly putting ambient values in wrong loc... + if (legacyhaze.has(SETTING_AMBIENT)) + { + legacy[SETTING_AMBIENT] = ensure_array_4(legacyhaze[SETTING_AMBIENT], 1.0f); + } + else if (settings.has(SETTING_AMBIENT)) + { + legacy[SETTING_AMBIENT] = ensure_array_4(settings[SETTING_AMBIENT], 1.0f); + } + + legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0); + legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0); + + F32 density_multiplier = legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal(); + density_multiplier = (density_multiplier < 0.0001f) ? 0.0001f : density_multiplier; + legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(density_multiplier)(0.0f)(0.0f)(1.0f); + + F32 distance_multiplier = legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal(); + legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(distance_multiplier)(0.0f)(0.0f)(1.0f); + + legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); + legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f); + } +} + +LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isAdvanced) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = psky->getSettings(); + + convertAtmosphericsToLegacy(legacy, settings); + + legacy[SETTING_CLOUD_COLOR] = ensure_array_4(settings[SETTING_CLOUD_COLOR], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY1] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY1], 1.0); + legacy[SETTING_CLOUD_POS_DENSITY2] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); + legacy[SETTING_CLOUD_SCALE] = LLSDArray(settings[SETTING_CLOUD_SCALE])(LLSD::Real(0.0))(LLSD::Real(0.0))(LLSD::Real(1.0)); + legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; + legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = LLSDArray(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal()))) + (LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); + legacy[SETTING_CLOUD_SHADOW] = LLSDArray(settings[SETTING_CLOUD_SHADOW].asReal())(0.0f)(0.0f)(1.0f); + legacy[SETTING_GAMMA] = LLSDArray(settings[SETTING_GAMMA])(0.0f)(0.0f)(1.0f); + legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); + legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f); + legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); + legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; + legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); + + LLVector3 dir = psky->getLightDirection(); + + F32 phi = asin(dir.mV[2]); + F32 cos_phi = cosf(phi); + F32 theta = (cos_phi != 0) ? asin(dir.mV[1] / cos_phi) : 0.0f; + + theta = -theta; + + // get angles back into valid ranges for legacy viewer... + // + while (theta < 0) + { + theta += F_PI * 2; + } + + if (theta > 4 * F_PI) + { + theta = fmod(theta, 2 * F_PI); + } + + while (phi < -F_PI) + { + phi += 2 * F_PI; + } + + if (phi > 3 * F_PI) + { + phi = F_PI + fmod(phi - F_PI, 2 * F_PI); + } + + legacy[SETTING_LEGACY_EAST_ANGLE] = theta; + legacy[SETTING_LEGACY_SUN_ANGLE] = phi; + + return legacy; +} + +//------------------------------------------------------------------------- +void LLSettingsVOSky::updateSettings() +{ + LLSettingsSky::updateSettings(); + LLVector3 sun_direction = getSunDirection(); + LLVector3 moon_direction = getMoonDirection(); + + F32 dp = getLightDirection() * LLVector3(0.0f, 0.0f, 1.0f); + if (dp < 0) + { + dp = 0; + } + dp = llmax(dp, 0.1f); + + // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio + // between sunlight and point lights in windlight to normalize point lights. + F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); + mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); + + gSky.setSunAndMoonDirectionsCFR(sun_direction, moon_direction); + gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); + gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); + gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId()); + gSky.setBloomTextures(getBloomTextureId(), getNextBloomTextureId()); + + gSky.setSunScale(getSunScale()); + gSky.setMoonScale(getMoonScale()); +} + +void LLSettingsVOSky::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + + if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) + { + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + } + else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) + { + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); + + LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); + vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); + shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + } + + F32 g = getGamma(); + + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); + shader->uniform4f(LLShaderMgr::GAMMA, g, 0.0, 0.0, 1.0); + shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, g); +} + +LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { +// LEGACY_ATMOSPHERICS + + // Todo: default 'legacy' values duplicate the ones from functions like getBlueDensity() find a better home for them + // There is LLSettingsSky::defaults(), but it doesn't contain everything since it is geared towards creating new settings. + param_map[SETTING_AMBIENT] = DefaultParam(LLShaderMgr::AMBIENT, LLColor3(0.25f, 0.25f, 0.25f).getValue()); + param_map[SETTING_BLUE_DENSITY] = DefaultParam(LLShaderMgr::BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f).getValue()); + param_map[SETTING_BLUE_HORIZON] = DefaultParam(LLShaderMgr::BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f).getValue()); + param_map[SETTING_HAZE_DENSITY] = DefaultParam(LLShaderMgr::HAZE_DENSITY, LLSD(0.7f)); + param_map[SETTING_HAZE_HORIZON] = DefaultParam(LLShaderMgr::HAZE_HORIZON, LLSD(0.19f)); + param_map[SETTING_DENSITY_MULTIPLIER] = DefaultParam(LLShaderMgr::DENSITY_MULTIPLIER, LLSD(0.0001f)); + param_map[SETTING_DISTANCE_MULTIPLIER] = DefaultParam(LLShaderMgr::DISTANCE_MULTIPLIER, LLSD(0.8f)); + + // Following values are always present, so we can just zero these ones, but used values from defaults() + LLSD sky_defaults = LLSettingsSky::defaults(); + param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); + param_map[SETTING_CLOUD_POS_DENSITY2] = DefaultParam(LLShaderMgr::CLOUD_POS_DENSITY2, sky_defaults[SETTING_CLOUD_POS_DENSITY2]); + param_map[SETTING_CLOUD_SCALE] = DefaultParam(LLShaderMgr::CLOUD_SCALE, sky_defaults[SETTING_CLOUD_SCALE]); + param_map[SETTING_CLOUD_SHADOW] = DefaultParam(LLShaderMgr::CLOUD_SHADOW, sky_defaults[SETTING_CLOUD_SHADOW]); + param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); + param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); + param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); + param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); + param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); + param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); + param_map[SETTING_SKY_ICE_LEVEL] = DefaultParam(LLShaderMgr::ICE_LEVEL, sky_defaults[SETTING_SKY_ICE_LEVEL]); + +// AdvancedAtmospherics TODO +// Provide mappings for new shader params here + } + + return param_map; +} + +//========================================================================= +const F32 LLSettingsVOWater::WATER_FOG_LIGHT_CLAMP(0.3f); + +//------------------------------------------------------------------------- +LLSettingsVOWater::LLSettingsVOWater(const LLSD &data) : + LLSettingsWater(data) +{ + +} + +LLSettingsVOWater::LLSettingsVOWater() : + LLSettingsWater() +{ + +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildWater(LLSD settings) +{ + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL; + LLSettingsWater::ptr_t(); + } + + return std::make_shared<LLSettingsVOWater>(settings); +} + +//------------------------------------------------------------------------- +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages) +{ + LLSD newsettings(LLSettingsWater::translateLegacySettings(oldsettings)); + if (newsettings.isUndefined()) + { + messages["REASONS"] = LLTrans::getString("SettingTranslateError", LLSDMap("NAME", name)); + return LLSettingsWater::ptr_t(); + } + + newsettings[SETTING_NAME] = name; + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + messages["REASONS"] = LLTrans::getString("SettingValidationError", name); + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + + LLSettingsWater::ptr_t waterp = std::make_shared<LLSettingsVOWater>(newsettings); + +#ifdef VERIFY_LEGACY_CONVERSION + LLSD oldsettings = LLSettingsVOWater::convertToLegacy(waterp); + + if (!llsd_equals(oldsettings, oldsettings)) + { + LL_WARNS("WATER") << "Conversion to/from legacy does not match!\n" + << "Old: " << oldsettings + << "new: " << oldsettings << LL_ENDL; + } + +#endif + return waterp; +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages) +{ + LLSD legacy_data = read_legacy_preset_data(name, path, messages); + + if (!legacy_data) + { // messages filled in by read_legacy_preset_data + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, legacy_data, messages); +} + + +LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() +{ + static LLSD default_settings; + + if (!default_settings.size()) + { + default_settings = LLSettingsWater::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + } + + LLSettingsWater::ptr_t waterp = std::make_shared<LLSettingsVOWater>(default_settings); + + return waterp; +} + +LLSettingsWater::ptr_t LLSettingsVOWater::buildClone() const +{ + LLSD settings = cloneSettings(); + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + + LLSettingsWater::ptr_t waterp = std::make_shared<LLSettingsVOWater>(settings); + + return waterp; +} + +LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) +{ + LLSD legacy(LLSD::emptyMap()); + LLSD settings = pwater->getSettings(); + + legacy[SETTING_LEGACY_BLUR_MULTIPLIER] = settings[SETTING_BLUR_MULTIPLIER]; + legacy[SETTING_LEGACY_FOG_COLOR] = ensure_array_4(settings[SETTING_FOG_COLOR], 1.0f); + legacy[SETTING_LEGACY_FOG_DENSITY] = settings[SETTING_FOG_DENSITY]; + legacy[SETTING_LEGACY_FOG_MOD] = settings[SETTING_FOG_MOD]; + legacy[SETTING_LEGACY_FRESNEL_OFFSET] = settings[SETTING_FRESNEL_OFFSET]; + legacy[SETTING_LEGACY_FRESNEL_SCALE] = settings[SETTING_FRESNEL_SCALE]; + legacy[SETTING_LEGACY_NORMAL_MAP] = settings[SETTING_NORMAL_MAP]; + legacy[SETTING_LEGACY_NORMAL_SCALE] = settings[SETTING_NORMAL_SCALE]; + legacy[SETTING_LEGACY_SCALE_ABOVE] = settings[SETTING_SCALE_ABOVE]; + legacy[SETTING_LEGACY_SCALE_BELOW] = settings[SETTING_SCALE_BELOW]; + legacy[SETTING_LEGACY_WAVE1_DIR] = settings[SETTING_WAVE1_DIR]; + legacy[SETTING_LEGACY_WAVE2_DIR] = settings[SETTING_WAVE2_DIR]; + + return legacy; +} +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- +void LLSettingsVOWater::applySpecial(void *ptarget) +{ + LLGLSLShader *shader = (LLGLSLShader *)ptarget; + + LLEnvironment& env = LLEnvironment::instance(); + + if (shader->mShaderGroup == LLGLSLShader::SG_WATER) + { + F32 water_height = env.getWaterHeight(); + + //transform water plane to eye space + glh::vec3f norm(0.f, 0.f, 1.f); + glh::vec3f p(0.f, 0.f, water_height + 0.1f); + + F32 modelView[16]; + for (U32 i = 0; i < 16; i++) + { + modelView[i] = (F32)gGLModelView[i]; + } + + glh::matrix4f mat(modelView); + glh::matrix4f invtrans = mat.inverse().transpose(); + glh::vec3f enorm; + glh::vec3f ep; + invtrans.mult_matrix_vec(norm, enorm); + enorm.normalize(); + mat.mult_matrix_vec(p, ep); + + LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + + shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, waterPlane.mV); + + LLVector4 light_direction = env.getClampedLightNorm(); + + F32 waterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); + + shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS); + + F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - water_height; + + F32 waterFogDensity = env.getCurrentWater()->getModifiedWaterFogDensity(LLPipeline::sUnderWaterRender || (eyedepth <= 0.0f)); + shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, waterFogDensity); + + F32 blend_factor = env.getCurrentWater()->getBlendFactor(); + shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + + LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + } +} + +void LLSettingsVOWater::updateSettings() +{ + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + LLDrawPoolWater* pwaterpool = (LLDrawPoolWater*)gPipeline.getPool(LLDrawPool::POOL_WATER); + if (pwaterpool) + { + pwaterpool->setTransparentTextures(getTransparentTextureID(), getNextTransparentTextureID()); + pwaterpool->setOpaqueTexture(GetDefaultOpaqueTextureAssetId()); + pwaterpool->setNormalMaps(getNormalMapID(), getNextNormalMapID()); + } +} + +LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const +{ + static parammapping_t param_map; + + if (param_map.empty()) + { + LLSD water_defaults = LLSettingsWater::defaults(); + param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]); + + // let this get set by LLSettingsVOWater::applySpecial so that it can properly reflect the underwater modifier + //param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]); + } + return param_map; +} + +//========================================================================= +LLSettingsVODay::LLSettingsVODay(const LLSD &data): + LLSettingsDay(data) +{} + +LLSettingsVODay::LLSettingsVODay(): + LLSettingsDay() +{} + +LLSettingsDay::ptr_t LLSettingsVODay::buildDay(LLSD settings) +{ + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t pday = std::make_shared<LLSettingsVODay>(settings); + if (pday) + pday->initialize(); + + return pday; +} + +//------------------------------------------------------------------------- +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings, LLSD &messages) +{ + LLSD newsettings(defaults()); + std::set<std::string> framenames; + std::set<std::string> notfound; + + std::string base_path(gDirUtilp->getDirName(path)); + std::string water_path(base_path); + std::string sky_path(base_path); + + gDirUtilp->append(water_path, "water"); + gDirUtilp->append(sky_path, "skies"); + + newsettings[SETTING_NAME] = name; + + LLSD watertrack = LLSDArray( + LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) + (SETTING_KEYNAME, "water:Default")); + + LLSD skytrack = LLSD::emptyArray(); + + for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) + { + std::string framename = (*it)[1].asString(); + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) + (SETTING_KEYNAME, "sky:" + framename); + framenames.insert(framename); + skytrack.append(entry); + } + + newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); + + LLSD frames(LLSD::emptyMap()); + + { + LLSettingsWater::ptr_t pwater = LLSettingsVOWater::buildFromLegacyPresetFile("Default", water_path, messages); + if (!pwater) + { // messages filled in by buildFromLegacyPresetFile + return LLSettingsDay::ptr_t(); + } + frames["water:Default"] = pwater->getSettings(); + } + + for (std::set<std::string>::iterator itn = framenames.begin(); itn != framenames.end(); ++itn) + { + LLSettingsSky::ptr_t psky = LLSettingsVOSky::buildFromLegacyPresetFile((*itn), sky_path, messages); + if (!psky) + { // messages filled in by buildFromLegacyPresetFile + return LLSettingsDay::ptr_t(); + } + frames["sky:" + (*itn)] = psky->getSettings(); + } + + newsettings[SETTING_FRAMES] = frames; + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + messages["REASONS"] = LLTrans::getString("SettingValidationError", LLSDMap("NAME", name)); + LL_WARNS("SETTINGS") << "Day setting validation failed!: " << results << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared<LLSettingsVODay>(newsettings); + +#ifdef VERIFY_LEGACY_CONVERSION + LLSD testsettings = LLSettingsVODay::convertToLegacy(dayp); + + if (!llsd_equals(oldsettings, testsettings)) + { + LL_WARNS("DAYCYCLE") << "Conversion to/from legacy does not match!\n" + << "Old: " << oldsettings + << "new: " << testsettings << LL_ENDL; + } + +#endif + + dayp->initialize(); + + return dayp; +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages) +{ + LLSD legacy_data = read_legacy_preset_data(name, path, messages); + + if (!legacy_data) + { // messages filled in by read_legacy_preset_data + LL_WARNS("SETTINGS") << "Could not load legacy Windlight \"" << name << "\" from " << path << LL_ENDL; + return ptr_t(); + } + + return buildFromLegacyPreset(name, path, legacy_data, messages); +} + + + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) +{ + LLSD frames(LLSD::emptyMap()); + + for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) + { + std::string newname = "sky:" + (*itm).first; + LLSD newsettings = LLSettingsSky::translateLegacySettings((*itm).second); + + newsettings[SETTING_NAME] = newname; + frames[newname] = newsettings; + + LL_WARNS("SETTINGS") << "created region sky '" << newname << "'" << LL_ENDL; + } + + LLSD watersettings = LLSettingsWater::translateLegacySettings(waterdef); + std::string watername = "water:"+ watersettings[SETTING_NAME].asString(); + watersettings[SETTING_NAME] = watername; + frames[watername] = watersettings; + + LLSD watertrack = LLSDArray( + LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f)) + (SETTING_KEYNAME, watername)); + + LLSD skytrack(LLSD::emptyArray()); + for (LLSD::array_const_iterator it = daycycle.beginArray(); it != daycycle.endArray(); ++it) + { + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) + (SETTING_KEYNAME, "sky:" + (*it)[1].asString()); + skytrack.append(entry); + } + + LLSD newsettings = LLSDMap + ( SETTING_NAME, "Region (legacy)" ) + ( SETTING_TRACKS, LLSDArray(watertrack)(skytrack)) + ( SETTING_FRAMES, frames ) + ( SETTING_TYPE, "daycycle" ); + + LLSettingsSky::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(newsettings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!:" << results << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared<LLSettingsVODay>(newsettings); + + if (dayp) + { + // true for validation - either validate here, or when cloning for floater. + dayp->initialize(true); + } + return dayp; +} + + + +LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() +{ + static LLSD default_settings; + + if (!default_settings.size()) + { + default_settings = LLSettingsDay::defaults(); + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + } + + LLSettingsDay::ptr_t dayp = std::make_shared<LLSettingsVODay>(default_settings); + + dayp->initialize(); + return dayp; +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) +{ + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared<LLSettingsVODay>(settings); + + dayp->initialize(); + return dayp; +} + + +void LLSettingsVODay::buildFromOtherSetting(LLSettingsBase::ptr_t settings, LLSettingsVODay::asset_built_fn cb) +{ + if (settings->getSettingsType() == "daycycle") + { + if (cb) + cb(std::static_pointer_cast<LLSettingsDay>(settings)); + } + else + { + LLSettingsVOBase::getSettingsAsset(LLSettingsDay::GetDefaultAssetId(), + [settings, cb](LLUUID, LLSettingsBase::ptr_t pday, S32, LLExtStat){ combineIntoDayCycle(std::static_pointer_cast<LLSettingsDay>(pday), settings, cb); }); + } +} + +void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsBase::ptr_t settings, asset_built_fn cb) +{ + if (settings->getSettingsType() == "sky") + { + pday->setName("sky: " + settings->getName()); + pday->clearCycleTrack(1); + pday->setSettingsAtKeyframe(settings, 0.0, 1); + } + else if (settings->getSettingsType() == "water") + { + pday->setName("water: " + settings->getName()); + pday->clearCycleTrack(0); + pday->setSettingsAtKeyframe(settings, 0.0, 0); + } + else + { + pday.reset(); + } + + if (cb) + cb(pday); +} + + +LLSettingsDay::ptr_t LLSettingsVODay::buildClone() const +{ + LLSD settings = cloneSettings(); + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t dayp = std::make_shared<LLSettingsVODay>(settings); + + U32 flags = getFlags(); + if (flags) + dayp->setFlags(flags); + + dayp->initialize(); + return dayp; +} + +LLSettingsDay::ptr_t LLSettingsVODay::buildDeepCloneAndUncompress() const +{ + // no need for SETTING_TRACKS or SETTING_FRAMES, so take base LLSD + LLSD settings = llsd_clone(mSettings); + + LLSettingsDay::ptr_t day_clone = std::make_shared<LLSettingsVODay>(settings); + + for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i) + { + const LLSettingsDay::CycleTrack_t& track = getCycleTrackConst(i); + LLSettingsDay::CycleTrack_t::const_iterator iter = track.begin(); + while (iter != track.end()) + { + // 'Unpack', usually for editing + // - frames 'share' settings multiple times + // - settings can reuse LLSDs they were initialized from + // We do not want for edited frame to change multiple frames in same track, so do a clone + day_clone->setSettingsAtKeyframe(iter->second->buildDerivedClone(), iter->first, i); + iter++; + } + } + return day_clone; +} + +LLSD LLSettingsVODay::convertToLegacy(const LLSettingsVODay::ptr_t &pday) +{ + CycleTrack_t &trackwater = pday->getCycleTrack(TRACK_WATER); + + LLSettingsWater::ptr_t pwater; + if (!trackwater.empty()) + { + pwater = std::static_pointer_cast<LLSettingsWater>((*trackwater.begin()).second); + } + + if (!pwater) + pwater = LLSettingsVOWater::buildDefaultWater(); + + LLSD llsdwater = LLSettingsVOWater::convertToLegacy(pwater); + + CycleTrack_t &tracksky = pday->getCycleTrack(1); // first sky track + std::map<std::string, LLSettingsSky::ptr_t> skys; + + LLSD llsdcycle(LLSD::emptyArray()); + + for(CycleTrack_t::iterator it = tracksky.begin(); it != tracksky.end(); ++it) + { + size_t hash = (*it).second->getHash(); + std::stringstream name; + + name << hash; + + skys[name.str()] = std::static_pointer_cast<LLSettingsSky>((*it).second); + + F32 frame = ((tracksky.size() == 1) && (it == tracksky.begin())) ? -1.0f : (*it).first; + llsdcycle.append( LLSDArray(LLSD::Real(frame))(name.str()) ); + } + + LLSD llsdskylist(LLSD::emptyMap()); + + for (std::map<std::string, LLSettingsSky::ptr_t>::iterator its = skys.begin(); its != skys.end(); ++its) + { + LLSD llsdsky = LLSettingsVOSky::convertToLegacy((*its).second, false); + llsdsky[SETTING_NAME] = (*its).first; + + llsdskylist[(*its).first] = llsdsky; + } + + return LLSDArray(LLSD::emptyMap())(llsdcycle)(llsdskylist)(llsdwater); +} + +LLSettingsSkyPtr_t LLSettingsVODay::getDefaultSky() const +{ + return LLSettingsVOSky::buildDefaultSky(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::getDefaultWater() const +{ + return LLSettingsVOWater::buildDefaultWater(); +} + +LLSettingsSkyPtr_t LLSettingsVODay::buildSky(LLSD settings) const +{ + LLSettingsSky::ptr_t skyp = std::make_shared<LLSettingsVOSky>(settings); + + if (skyp->validate()) + return skyp; + + return LLSettingsSky::ptr_t(); +} + +LLSettingsWaterPtr_t LLSettingsVODay::buildWater(LLSD settings) const +{ + LLSettingsWater::ptr_t waterp = std::make_shared<LLSettingsVOWater>(settings); + + if (waterp->validate()) + return waterp; + + return LLSettingsWater::ptr_t(); +} + +//========================================================================= +namespace +{ + LLSD ensure_array_4(LLSD in, F32 fill) + { + if (in.size() >= 4) + return in; + + LLSD out(LLSD::emptyArray()); + + for (S32 idx = 0; idx < in.size(); ++idx) + { + out.append(in[idx]); + } + + while (out.size() < 4) + { + out.append(LLSD::Real(fill)); + } + return out; + } + + // This is a disturbing hack + std::string legacy_name_to_filename(const std::string &name, bool convertdash = false) + { + std::string fixedname(LLURI::escape(name)); + + if (convertdash) + boost::algorithm::replace_all(fixedname, "-", "%2D"); + + return fixedname; + } + + //--------------------------------------------------------------------- + LLSD read_legacy_preset_data(const std::string &name, const std::string& path, LLSD &messages) + { + llifstream xml_file; + + std::string full_path(path); + std::string full_name(name); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + + xml_file.open(full_path.c_str()); + if (!xml_file) + { + std::string bad_path(full_path); + full_path = path; + full_name = legacy_name_to_filename(name); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + + LL_INFOS("LEGACYSETTING") << "Could not open \"" << bad_path << "\" trying escaped \"" << full_path << "\"" << LL_ENDL; + + xml_file.open(full_path.c_str()); + if (!xml_file) + { + LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; + + full_path = path; + full_name = legacy_name_to_filename(name, true); + full_name += ".xml"; + gDirUtilp->append(full_path, full_name); + xml_file.open(full_path.c_str()); + if (!xml_file) + { + messages["REASONS"] = LLTrans::getString("SettingImportFileError", LLSDMap("FILE", bad_path)); + LL_WARNS("LEGACYSETTING") << "Unable to open legacy windlight \"" << name << "\" from " << path << LL_ENDL; + return LLSD(); + } + } + } + + LLSD params_data; + LLPointer<LLSDParser> parser = new LLSDXMLParser(); + if (parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE) + { + xml_file.close(); + messages["REASONS"] = LLTrans::getString("SettingParseFileError", LLSDMap("FILE", full_path)); + return LLSD(); + } + xml_file.close(); + + return params_data; + } +} diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h new file mode 100644 index 0000000000..0f4b715e44 --- /dev/null +++ b/indra/newview/llsettingsvo.h @@ -0,0 +1,183 @@ +/** +* @file llsettingsvo.h +* @author Rider Linden +* @brief Subclasses for viewer specific settings behaviors. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LL_SETTINGS_VO_H +#define LL_SETTINGS_VO_H + +#include "llsettingsbase.h" +#include "llsettingssky.h" +#include "llsettingswater.h" +#include "llsettingsdaycycle.h" + +#include "llsdserialize.h" + +#include "llextendedstatus.h" +#include <boost/signals2.hpp> + +class LLVFS; +class LLInventoryItem; + +//========================================================================= +class LLSettingsVOBase : public LLSettingsBase +{ +public: + typedef std::function<void(LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status, LLExtStat extstat)> asset_download_fn; + typedef std::function<void(LLInventoryItem *inv_item, LLSettingsBase::ptr_t settings, S32 status, LLExtStat extstat)> inventory_download_fn; + typedef std::function<void(LLUUID asset_id, LLUUID inventory_id, LLUUID object_id, LLSD results)> inventory_result_fn; + + static void createNewInventoryItem(LLSettingsType::type_e stype, const LLUUID &parent_id, inventory_result_fn callback = inventory_result_fn()); + static void createInventoryItem(const LLSettingsBase::ptr_t &settings, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback = inventory_result_fn()); + static void createInventoryItem(const LLSettingsBase::ptr_t &settings, U32 next_owner_perm, const LLUUID &parent_id, std::string settings_name, inventory_result_fn callback = inventory_result_fn()); + + static void updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID inv_item_id, inventory_result_fn callback = inventory_result_fn(), bool update_name = true); + static void updateInventoryItem(const LLSettingsBase::ptr_t &settings, LLUUID object_id, LLUUID inv_item_id, inventory_result_fn callback = inventory_result_fn()); + + static void getSettingsAsset(const LLUUID &assetId, asset_download_fn callback); + static void getSettingsInventory(const LLUUID &inventoryId, inventory_download_fn callback = inventory_download_fn()); + + static bool exportFile(const LLSettingsBase::ptr_t &settings, const std::string &filename, LLSDSerialize::ELLSD_Serialize format = LLSDSerialize::LLSD_NOTATION); + static LLSettingsBase::ptr_t importFile(const std::string &filename); + static LLSettingsBase::ptr_t createFromLLSD(const LLSD &settings); + +private: + struct SettingsSaveData + { + typedef std::shared_ptr<SettingsSaveData> ptr_t; + std::string mType; + std::string mTempFile; + LLSettingsBase::ptr_t mSettings; + LLTransactionID mTransId; + }; + + LLSettingsVOBase() {} + + static void onInventoryItemCreated(const LLUUID &inventoryId, LLSettingsBase::ptr_t settings, inventory_result_fn callback); + + static void onAgentAssetUploadComplete(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback); + static void onTaskAssetUploadComplete(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, LLSettingsBase::ptr_t psettings, inventory_result_fn callback); + + static void onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_id, S32 status, LLExtStat ext_status, asset_download_fn callback); +}; + +//========================================================================= +class LLSettingsVOSky : public LLSettingsSky +{ +public: + LLSettingsVOSky(const LLSD &data, bool advanced = false); + + static ptr_t buildSky(LLSD settings); + + static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages); + static ptr_t buildDefaultSky(); + virtual ptr_t buildClone() const SETTINGS_OVERRIDE; + + static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages); + + static LLSD convertToLegacy(const ptr_t &, bool isAdvanced); + + bool isAdvanced() const { return m_isAdvanced; } + +protected: + LLSettingsVOSky(); + + // Interpret new settings in terms of old atmospherics params + static void convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings); + + virtual void updateSettings() override; + + virtual void applySpecial(void *) override; + + virtual parammapping_t getParameterMap() const override; + + bool m_isAdvanced = false; + F32 mSceneLightStrength = 3.0f; +}; + +//========================================================================= +class LLSettingsVOWater : public LLSettingsWater +{ +public: + LLSettingsVOWater(const LLSD &data); + + static ptr_t buildWater(LLSD settings); + + static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings, LLSD &messages); + static ptr_t buildDefaultWater(); + virtual ptr_t buildClone() const SETTINGS_OVERRIDE; + + static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages); + + static LLSD convertToLegacy(const ptr_t &); +protected: + LLSettingsVOWater(); + + virtual void updateSettings() override; + virtual void applySpecial(void *) override; + + virtual parammapping_t getParameterMap() const override; + + +private: + static const F32 WATER_FOG_LIGHT_CLAMP; + +}; + +//========================================================================= +class LLSettingsVODay : public LLSettingsDay +{ +public: + typedef std::function<void(LLSettingsDay::ptr_t day)> asset_built_fn; + + LLSettingsVODay(const LLSD &data); + + static ptr_t buildDay(LLSD settings); + + static ptr_t buildFromLegacyPreset(const std::string &name, const std::string &path, const LLSD &oldsettings, LLSD &messages); + static ptr_t buildFromLegacyPresetFile(const std::string &name, const std::string &path, LLSD &messages); + static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); + static ptr_t buildDefaultDayCycle(); + static ptr_t buildFromEnvironmentMessage(LLSD settings); + static void buildFromOtherSetting(LLSettingsBase::ptr_t settings, asset_built_fn cb); + virtual ptr_t buildClone() const SETTINGS_OVERRIDE; + virtual ptr_t buildDeepCloneAndUncompress() const SETTINGS_OVERRIDE; + + static LLSD convertToLegacy(const ptr_t &); + + virtual LLSettingsSkyPtr_t getDefaultSky() const override; + virtual LLSettingsWaterPtr_t getDefaultWater() const override; + virtual LLSettingsSkyPtr_t buildSky(LLSD) const override; + virtual LLSettingsWaterPtr_t buildWater(LLSD) const override; + +protected: + LLSettingsVODay(); + +private: + static void combineIntoDayCycle(LLSettingsDay::ptr_t, LLSettingsBase::ptr_t, asset_built_fn); +}; + + +#endif diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index 2503e2a5e2..d7c2ecb758 100644 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -301,6 +301,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) BOOL is_complete = item->isFinished(); const BOOL cannot_restrict_permissions = LLInventoryType::cannotRestrictPermissions(item->getInventoryType()); const BOOL is_calling_card = (item->getInventoryType() == LLInventoryType::IT_CALLINGCARD); + const BOOL is_settings = (item->getInventoryType() == LLInventoryType::IT_SETTINGS); const LLPermissions& perm = item->getPermissions(); const BOOL can_agent_manipulate = gAgent.allowOperation(PERM_OWNER, perm, GP_OBJECT_MANIPULATE); @@ -630,14 +631,14 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) LLUICtrl* edit_cost = getChild<LLUICtrl>("Edit Cost"); // Check for ability to change values. - if (is_obj_modify && can_agent_sell + if (is_obj_modify && can_agent_sell && gAgent.allowOperation(PERM_TRANSFER, perm, GP_OBJECT_MANIPULATE)) { getChildView("CheckPurchase")->setEnabled(is_complete); getChildView("NextOwnerLabel")->setEnabled(TRUE); getChildView("CheckNextOwnerModify")->setEnabled((base_mask & PERM_MODIFY) && !cannot_restrict_permissions); - getChildView("CheckNextOwnerCopy")->setEnabled((base_mask & PERM_COPY) && !cannot_restrict_permissions); + getChildView("CheckNextOwnerCopy")->setEnabled((base_mask & PERM_COPY) && !cannot_restrict_permissions && !is_settings); getChildView("CheckNextOwnerTransfer")->setEnabled((next_owner_mask & PERM_COPY) && !cannot_restrict_permissions); combo_sale_type->setEnabled(is_complete && is_for_sale); @@ -656,6 +657,25 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) edit_cost->setEnabled(FALSE); } + // Hide any properties that are not relevant to settings + if (is_settings) + { + getChild<LLUICtrl>("GroupLabel")->setEnabled(false); + getChild<LLUICtrl>("GroupLabel")->setVisible(false); + getChild<LLUICtrl>("CheckShareWithGroup")->setEnabled(false); + getChild<LLUICtrl>("CheckShareWithGroup")->setVisible(false); + getChild<LLUICtrl>("AnyoneLabel")->setEnabled(false); + getChild<LLUICtrl>("AnyoneLabel")->setVisible(false); + getChild<LLUICtrl>("CheckEveryoneCopy")->setEnabled(false); + getChild<LLUICtrl>("CheckEveryoneCopy")->setVisible(false); + getChild<LLUICtrl>("CheckPurchase")->setEnabled(false); + getChild<LLUICtrl>("CheckPurchase")->setVisible(false); + getChild<LLUICtrl>("ComboBoxSaleType")->setEnabled(false); + getChild<LLUICtrl>("ComboBoxSaleType")->setVisible(false); + getChild<LLUICtrl>("Edit Cost")->setEnabled(false); + getChild<LLUICtrl>("Edit Cost")->setVisible(false); + } + // Set values. getChild<LLUICtrl>("CheckPurchase")->setValue(is_for_sale); getChild<LLUICtrl>("CheckNextOwnerModify")->setValue(LLSD(BOOL(next_owner_mask & PERM_MODIFY))); diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp index 3ef89ba920..71de99b4ec 100644 --- a/indra/newview/llsky.cpp +++ b/indra/newview/llsky.cpp @@ -51,19 +51,16 @@ #include "llvosky.h" #include "llcubemap.h" #include "llviewercontrol.h" -#include "llenvmanager.h" - +#include "llenvironment.h" +#include "llvoavatarself.h" #include "llvowlsky.h" F32 azimuth_from_vector(const LLVector3 &v); F32 elevation_from_vector(const LLVector3 &v); -LLSky gSky; -// ---------------- LLSky ---------------- - -const F32 LLSky::NIGHTTIME_ELEVATION = -8.0f; // degrees -const F32 LLSky::NIGHTTIME_ELEVATION_COS = (F32)sin(NIGHTTIME_ELEVATION*DEG_TO_RAD); +LLSky gSky; +// ---------------- LLSky ---------------- ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -77,8 +74,6 @@ LLSky::LLSky() mLightingGeneration = 0; mUpdatedThisFrame = TRUE; - mOverrideSimSunPosition = FALSE; - mSunPhase = 0.f; } @@ -134,211 +129,89 @@ void LLSky::resetVertexBuffers() } } -void LLSky::setOverrideSun(BOOL override) +void LLSky::setSunScale(F32 sun_scale) { - if (!mOverrideSimSunPosition && override) - { - mLastSunDirection = getSunDirection(); - } - else if (mOverrideSimSunPosition && !override) - { - setSunDirection(mLastSunDirection, LLVector3::zero); + if(mVOSkyp.notNull()) + { + mVOSkyp->setSunScale(sun_scale); } - mOverrideSimSunPosition = override; } -void LLSky::setSunDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity) +void LLSky::setMoonScale(F32 moon_scale) { - if(mVOSkyp.notNull()) { - mVOSkyp->setSunDirection(sun_direction, sun_ang_velocity); + if(mVOSkyp.notNull()) + { + mVOSkyp->setMoonScale(moon_scale); } } - -void LLSky::setSunTargetDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity) -{ - mSunTargDir = sun_direction; -} - - -LLVector3 LLSky::getSunDirection() const +void LLSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next) { - if (mVOSkyp) - { - return mVOSkyp->getToSun(); - } - else - { - return LLVector3::z_axis; + if(mVOSkyp.notNull()) { + mVOSkyp->setSunTextures(sun_texture, sun_texture_next); } } - -LLVector3 LLSky::getMoonDirection() const +void LLSky::setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_texture_next) { - if (mVOSkyp) - { - return mVOSkyp->getToMoon(); - } - else - { - return LLVector3::z_axis; + if(mVOSkyp.notNull()) { + mVOSkyp->setMoonTextures(moon_texture, moon_texture_next); } } - -LLColor4 LLSky::getSunDiffuseColor() const +void LLSky::setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUID& cloud_noise_texture_next) { - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getSunDiffuseColor()); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); + if(mVOSkyp.notNull()) { + mVOSkyp->setCloudNoiseTextures(cloud_noise_texture, cloud_noise_texture_next); } } -LLColor4 LLSky::getSunAmbientColor() const -{ - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getSunAmbientColor()); - } - else - { - return LLColor4(0.f, 0.f, 0.f, 1.f); - } -} - - -LLColor4 LLSky::getMoonDiffuseColor() const +void LLSky::setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next) { - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getMoonDiffuseColor()); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); - } -} - -LLColor4 LLSky::getMoonAmbientColor() const -{ - if (mVOSkyp) - { - return LLColor4(mVOSkyp->getMoonAmbientColor()); - } - else - { - return LLColor4(0.f, 0.f, 0.f, 0.f); + if(mVOSkyp.notNull()) { + mVOSkyp->setBloomTextures(bloom_texture, bloom_texture_next); } } - -LLColor4 LLSky::getTotalAmbientColor() const +void LLSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_direction, const LLVector3 &moon_direction) { - if (mVOSkyp) - { - return mVOSkyp->getTotalAmbientColor(); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); + if(mVOSkyp.notNull()) { + mVOSkyp->setSunAndMoonDirectionsCFR(sun_direction, moon_direction); } } - -BOOL LLSky::sunUp() const +void LLSky::setSunDirectionCFR(const LLVector3 &sun_direction) { - if (mVOSkyp) - { - return mVOSkyp->isSunUp(); - } - else - { - return TRUE; + if(mVOSkyp.notNull()) { + mVOSkyp->setSunDirectionCFR(sun_direction); } } - -LLColor4U LLSky::getFadeColor() const +void LLSky::setMoonDirectionCFR(const LLVector3 &moon_direction) { - if (mVOSkyp) - { - return mVOSkyp->getFadeColor(); - } - else - { - return LLColor4(1.f, 1.f, 1.f, 1.f); + if(mVOSkyp.notNull()) { + mVOSkyp->setMoonDirectionCFR(moon_direction); } } - ////////////////////////////////////////////////////////////////////// // Public Methods ////////////////////////////////////////////////////////////////////// -void LLSky::init(const LLVector3 &sun_direction) +void LLSky::init() { - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - mVOWLSkyp = static_cast<LLVOWLSky*>(gObjectList.createObjectViewer(LLViewerObject::LL_VO_WL_SKY, NULL)); - mVOWLSkyp->initSunDirection(sun_direction, LLVector3::zero); + mVOWLSkyp->init(); gPipeline.createObject(mVOWLSkyp.get()); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - mVOSkyp = (LLVOSky *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_SKY, NULL); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - - mVOSkyp->initSunDirection(sun_direction, LLVector3()); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - - gPipeline.createObject((LLViewerObject *)mVOSkyp); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); + mVOSkyp->init(); + gPipeline.createObject(mVOSkyp.get()); mVOGroundp = (LLVOGround*)gObjectList.createObjectViewer(LLViewerObject::LL_VO_GROUND, NULL); - LLVOGround *groundp = mVOGroundp; - gPipeline.createObject((LLViewerObject *)groundp); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - - gSky.setFogRatio(gSavedSettings.getF32("RenderFogRatio")); - - //////////////////////////// - // - // Legacy code, ignore - // - // - - // Get the parameters. - mSunDefaultPosition = gSavedSettings.getVector3("SkySunDefaultPosition"); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - - if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition") || mOverrideSimSunPosition) - { - setSunDirection(mSunDefaultPosition, LLVector3(0.f, 0.f, 0.f)); - } - else - { - setSunDirection(sun_direction, LLVector3(0.f, 0.f, 0.f)); - } + gPipeline.createObject(mVOGroundp.get()); - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); + gSky.setFogRatio(gSavedSettings.getF32("RenderFogRatio")); mUpdatedThisFrame = TRUE; } @@ -361,37 +234,21 @@ void LLSky::setWind(const LLVector3& average_wind) } } +void LLSky::addSunMoonBeacons() +{ + if (!gAgentAvatarp || !mVOSkyp) return; -void LLSky::propagateHeavenlyBodies(F32 dt) -{ - if (!mOverrideSimSunPosition) + static LLUICachedControl<bool> show_sun_beacon("sunbeacon", false); + static LLUICachedControl<bool> show_moon_beacon("moonbeacon", false); + + if (show_sun_beacon) { - LLVector3 curr_dir = getSunDirection(); - LLVector3 diff = mSunTargDir - curr_dir; - const F32 dist = diff.normVec(); - if (dist > 0) - { - const F32 step = llmin (dist, 0.00005f); - //const F32 step = min (dist, 0.0001); - diff *= step; - curr_dir += diff; - curr_dir.normVec(); - if (mVOSkyp) - { - mVOSkyp->setSunDirection(curr_dir, LLVector3()); - } - } + renderSunMoonBeacons(gAgentAvatarp->getPositionAgent(), mVOSkyp->getSun().getDirection(), LLColor4(1.f, 0.5f, 0.f, 0.5f)); + } + if (show_moon_beacon) + { + renderSunMoonBeacons(gAgentAvatarp->getPositionAgent(), mVOSkyp->getMoon().getDirection(), LLColor4(1.f, 0.f, 0.8f, 0.5f)); } -} - -F32 LLSky::getSunPhase() const -{ - return mSunPhase; -} - -void LLSky::setSunPhase(const F32 phase) -{ - mSunPhase = phase; } ////////////////////////////////////////////////////////////////////// @@ -399,11 +256,11 @@ void LLSky::setSunPhase(const F32 phase) ////////////////////////////////////////////////////////////////////// -LLColor4 LLSky::getFogColor() const +LLColor4 LLSky::getSkyFogColor() const { if (mVOSkyp) { - return mVOSkyp->getFogColor(); + return mVOSkyp->getSkyFogColor(); } return LLColor4(1.f, 1.f, 1.f, 1.f); diff --git a/indra/newview/llsky.h b/indra/newview/llsky.h index 7b98c97840..8c0d70c16c 100644 --- a/indra/newview/llsky.h +++ b/indra/newview/llsky.h @@ -48,16 +48,23 @@ public: LLSky(); ~LLSky(); - void init(const LLVector3 &sun_direction); - + void init(); void cleanup(); - void setOverrideSun(BOOL override); - BOOL getOverrideSun() { return mOverrideSimSunPosition; } - void setSunDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity); - void setSunTargetDirection(const LLVector3 &sun_direction, const LLVector3 &sun_ang_velocity); + // These directions should be in CFR coord sys (+x at, +z up, +y right) + void setSunAndMoonDirectionsCFR(const LLVector3 &sun_direction, const LLVector3 &moon_direction); + void setSunDirectionCFR(const LLVector3 &sun_direction); + void setMoonDirectionCFR(const LLVector3 &moon_direction); + + void setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next); + void setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_texture_next); + void setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUID& cloud_noise_texture_next); + void setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next); - LLColor4 getFogColor() const; + void setSunScale(F32 sun_scale); + void setMoonScale(F32 moon_scale); + + LLColor4 getSkyFogColor() const; void setCloudDensityAtAgent(F32 cloud_density); void setWind(const LLVector3& wind); @@ -66,8 +73,6 @@ public: void updateCull(); void updateSky(); - void propagateHeavenlyBodies(F32 dt); // dt = seconds - S32 mLightingGeneration; BOOL mUpdatedThisFrame; @@ -75,44 +80,21 @@ public: F32 getFogRatio() const; LLColor4U getFadeColor() const; - LLVector3 getSunDirection() const; - LLVector3 getMoonDirection() const; - LLColor4 getSunDiffuseColor() const; - LLColor4 getMoonDiffuseColor() const; - LLColor4 getSunAmbientColor() const; - LLColor4 getMoonAmbientColor() const; - LLColor4 getTotalAmbientColor() const; - BOOL sunUp() const; - - F32 getSunPhase() const; - void setSunPhase(const F32 phase); - void destroyGL(); void restoreGL(); void resetVertexBuffers(); + void addSunMoonBeacons(); + void renderSunMoonBeacons(const LLVector3& pos_agent, const LLVector3& direction, LLColor4 color); + public: LLPointer<LLVOSky> mVOSkyp; // Pointer to the LLVOSky object (only one, ever!) LLPointer<LLVOGround> mVOGroundp; - LLPointer<LLVOWLSky> mVOWLSkyp; - LLVector3 mSunTargDir; - - // Legacy stuff - LLVector3 mSunDefaultPosition; - - static const F32 NIGHTTIME_ELEVATION; // degrees - static const F32 NIGHTTIME_ELEVATION_COS; - protected: - BOOL mOverrideSimSunPosition; - - F32 mSunPhase; - LLColor4 mFogColor; // Color to use for fog and haze - - LLVector3 mLastSunDirection; + LLColor4 mFogColor; }; -extern LLSky gSky; +extern LLSky gSky; #endif diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 1dc1e65fe5..b24f37fc72 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -55,8 +55,6 @@ #include "llviewershadermgr.h" #include "llcontrolavatar.h" -//#pragma optimize("", off) - static LLTrace::BlockTimerStatHandle FTM_FRUSTUM_CULL("Frustum Culling"); static LLTrace::BlockTimerStatHandle FTM_CULL_REBOUND("Cull Rebound Partition"); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 243ba00457..c5da7dc1b0 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -180,8 +180,6 @@ #include "llnamebox.h" #include "llnameeditor.h" #include "llpostprocess.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" #include "llagentlanguage.h" #include "llwearable.h" #include "llinventorybridge.h" @@ -197,6 +195,8 @@ #include "llexperiencelog.h" #include "llcleanup.h" +#include "llenvironment.h" + #include "llstacktrace.h" #if LL_WINDOWS @@ -333,7 +333,6 @@ bool idle_startup() static std::string auth_desc; static std::string auth_message; - static LLVector3 initial_sun_direction(1.f, 0.f, 0.f); static LLVector3 agent_start_position_region(10.f, 10.f, 10.f); // default for when no space server // last location by default @@ -941,21 +940,6 @@ bool idle_startup() LLFile::mkdir(gDirUtilp->getChatLogsDir()); LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir()); - - //good a place as any to create user windlight directories - std::string user_windlight_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", "")); - LLFile::mkdir(user_windlight_path_name.c_str()); - - std::string user_windlight_skies_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", "")); - LLFile::mkdir(user_windlight_skies_path_name.c_str()); - - std::string user_windlight_water_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); - LLFile::mkdir(user_windlight_water_path_name.c_str()); - - std::string user_windlight_days_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", "")); - LLFile::mkdir(user_windlight_days_path_name.c_str()); - - if (show_connect_box) { LLSLURL slurl; @@ -1465,8 +1449,7 @@ bool idle_startup() LLGLState::checkStates(); LLGLState::checkTextureChannels(); - LLEnvManagerNew::getInstance()->usePrefs(); // Load all presets and settings - gSky.init(initial_sun_direction); + gSky.init(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); @@ -2533,7 +2516,8 @@ void register_viewer_callbacks(LLMessageSystem* msg) msg->setHandlerFunc("InitiateDownload", process_initiate_download); msg->setHandlerFunc("LandStatReply", LLFloaterTopObjects::handle_land_reply); - msg->setHandlerFunc("GenericMessage", process_generic_message); + msg->setHandlerFunc("GenericMessage", process_generic_message); + msg->setHandlerFunc("LargeGenericMessage", process_large_generic_message); msg->setHandlerFuncFast(_PREHASH_FeatureDisabled, process_feature_disabled_message); } @@ -3507,26 +3491,6 @@ bool process_login_success_response() } } - LLSD global_textures = response["global-textures"][0]; - if(global_textures.size()) - { - // Extract sun and moon texture IDs. These are used - // in the LLVOSky constructor, but I can't figure out - // how to pass them in. JC - LLUUID id = global_textures["sun_texture_id"]; - if(id.notNull()) - { - gSunTextureID = id; - } - - id = global_textures["moon_texture_id"]; - if(id.notNull()) - { - gMoonTextureID = id; - } - - } - // set the location of the Agent Appearance service, from which we can request // avatar baked textures if they are supported by the current region std::string agent_appearance_url = response["agent_appearance_service"]; diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index a5a2eec246..5ca77ad3c3 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -70,9 +70,6 @@ #include "lllocalbitmaps.h" #include "llerror.h" -static const F32 CONTEXT_CONE_IN_ALPHA = 0.0f; -static const F32 CONTEXT_CONE_OUT_ALPHA = 1.f; -static const F32 CONTEXT_FADE_TIME = 0.08f; static const S32 LOCAL_TRACKING_ID_COLUMN = 1; @@ -410,59 +407,8 @@ BOOL LLFloaterTexturePicker::postBuild() // virtual void LLFloaterTexturePicker::draw() { - if (mOwner) - { - // draw cone of context pointing back to texture swatch - LLRect owner_rect; - mOwner->localRectToOtherView(mOwner->getLocalRect(), &owner_rect, this); - LLRect local_rect = getLocalRect(); - if (gFocusMgr.childHasKeyboardFocus(this) && mOwner->isInVisibleChain() && mContextConeOpacity > 0.001f) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLEnable(GL_CULL_FACE); - gGL.begin(LLRender::QUADS); - { - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); - gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); - gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); - - - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); - } - gGL.end(); - } - } - - if (gFocusMgr.childHasMouseCapture(getDragHandle())) - { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME)); - } - else - { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME)); - } + static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, mOwner); updateImageStats(); diff --git a/indra/newview/lltoastalertpanel.cpp b/indra/newview/lltoastalertpanel.cpp index 495c9c1f44..f31e3cfb14 100644 --- a/indra/newview/lltoastalertpanel.cpp +++ b/indra/newview/lltoastalertpanel.cpp @@ -268,14 +268,15 @@ LLToastAlertPanel::LLToastAlertPanel( LLNotificationPtr notification, bool modal mLineEditor->setMaxTextChars(edit_text_max_chars); mLineEditor->setText(edit_text_contents); - if("SaveOutfitAs" == mNotification->getName()) + std::string notif_name = mNotification->getName(); + if (("SaveOutfitAs" == notif_name) || ("SaveSettingAs" == notif_name)) { mLineEditor->setPrevalidate(&LLTextValidate::validateASCII); } // decrease limit of line editor of teleport offer dialog to avoid truncation of // location URL in invitation message, see EXT-6891 - if ("OfferTeleport" == mNotification->getName()) + if ("OfferTeleport" == notif_name) { mLineEditor->setMaxTextLength(gSavedSettings.getS32( "teleport_offer_invitation_max_length")); diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index f66211ef34..e43015a793 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -270,7 +270,8 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary() addEntry(DAD_GESTURE, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dActivateGesture, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_LINK, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_MESH, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dMeshObject, &LLToolDragAndDrop::dad3dNULL)); - // TODO: animation on self could play it? edit it? + addEntry(DAD_SETTINGS, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); + // TODO: animation on self could play it? edit it? // TODO: gesture on self could play it? edit it? }; @@ -1626,6 +1627,7 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_ case DAD_CALLINGCARD: case DAD_MESH: case DAD_CATEGORY: + case DAD_SETTINGS: { LLInventoryObject* inv_obj = (LLInventoryObject*)cargo_data; if(gInventory.getCategory(inv_obj->getUUID()) || (gInventory.getItem(inv_obj->getUUID()) diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp index 6c9155be85..9539081f30 100644 --- a/indra/newview/lltoolgun.cpp +++ b/indra/newview/lltoolgun.cpp @@ -107,11 +107,18 @@ BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask) if (gSavedSettings.getBOOL("MouseSun")) { - gSky.setSunDirection(LLViewerCamera::getInstance()->getAtAxis(), LLVector3(0.f, 0.f, 0.f)); - gSky.setOverrideSun(TRUE); + LLVector3 sunpos = LLViewerCamera::getInstance()->getAtAxis(); + gSky.setSunDirectionCFR(sunpos); gSavedSettings.setVector3("SkySunDefaultPosition", LLViewerCamera::getInstance()->getAtAxis()); } + if (gSavedSettings.getBOOL("MouseMoon")) + { + LLVector3 moonpos = LLViewerCamera::getInstance()->getAtAxis(); + gSky.setMoonDirectionCFR(moonpos); + gSavedSettings.setVector3("SkyMoonDefaultPosition", LLViewerCamera::getInstance()->getAtAxis()); + } + gViewerWindow->moveCursorToCenter(); gViewerWindow->hideCursor(); } diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp index 2ec5c41b88..728d0c9417 100644 --- a/indra/newview/lltracker.cpp +++ b/indra/newview/lltracker.cpp @@ -570,8 +570,8 @@ void LLTracker::renderBeacon(LLVector3d pos_global, color_frac = 1.f - 0.6f*(dist/LLViewerCamera::getInstance()->getFar()); } - LLColor4 fogged_color = color_frac * color + (1 - color_frac)*gSky.getFogColor(); - LLColor4 fogged_color_under = color_frac * color_under + (1 - color_frac) * gSky.getFogColor(); + LLColor4 fogged_color = color_frac * color + (1 - color_frac)*gSky.getSkyFogColor(); + LLColor4 fogged_color_under = color_frac * color_under + (1 - color_frac) * gSky.getSkyFogColor(); F32 FADE_DIST = 3.f; fogged_color.mV[3] = llmax(0.2f, llmin(0.5f,(dist-FADE_DIST)/FADE_DIST)); diff --git a/indra/newview/lltrackpicker.cpp b/indra/newview/lltrackpicker.cpp new file mode 100644 index 0000000000..fe6256a8a9 --- /dev/null +++ b/indra/newview/lltrackpicker.cpp @@ -0,0 +1,134 @@ +/** +* @author AndreyK Productengine +* @brief LLTrackPicker class header file including related functions +* +* $LicenseInfo:firstyear=2018&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2018, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "lltrackpicker.h" + +#include "llradiogroup.h" +#include "llviewercontrol.h" + + +//========================================================================= +namespace +{ + const std::string FLOATER_DEFINITION_XML("floater_pick_track.xml"); + + const std::string BTN_SELECT("btn_select"); + const std::string BTN_CANCEL("btn_cancel"); + const std::string RDO_TRACK_SELECTION("track_selection"); + const std::string RDO_TRACK_PREFIX("radio_sky"); +} +//========================================================================= + +LLFloaterTrackPicker::LLFloaterTrackPicker(LLView * owner, const LLSD ¶ms) : + LLFloater(params), + mContextConeOpacity(0.0f), + mOwnerHandle() +{ + mOwnerHandle = owner->getHandle(); + buildFromFile(FLOATER_DEFINITION_XML); +} + +LLFloaterTrackPicker::~LLFloaterTrackPicker() +{ +} + +BOOL LLFloaterTrackPicker::postBuild() +{ + childSetAction(BTN_CANCEL, [this](LLUICtrl*, const LLSD& param){ onButtonCancel(); }); + childSetAction(BTN_SELECT, [this](LLUICtrl*, const LLSD& param){ onButtonSelect(); }); + return TRUE; +} + +void LLFloaterTrackPicker::onClose(bool app_quitting) +{ + if (app_quitting) + return; + + LLView *owner = mOwnerHandle.get(); + if (owner) + { + owner->setFocus(TRUE); + } +} + +void LLFloaterTrackPicker::showPicker(const LLSD &args) +{ + LLSD::array_const_iterator iter; + LLSD::array_const_iterator end = args.endArray(); + + bool select_item = true; + for (iter = args.beginArray(); iter != end; ++iter) + { + S32 track_id = (*iter)["id"].asInteger(); + bool can_enable = (*iter)["enabled"].asBoolean(); + LLCheckBoxCtrl *view = getChild<LLCheckBoxCtrl>(RDO_TRACK_PREFIX + llformat("%d", track_id), true); + view->setEnabled(can_enable); + view->setLabelArg("[ALT]", (*iter).has("altitude") ? ((*iter)["altitude"].asString() + "m") : " "); + + // Mark first avaliable item as selected + if (can_enable && select_item) + { + select_item = false; + getChild<LLRadioGroup>(RDO_TRACK_SELECTION, true)->setSelectedByValue(LLSD(track_id), TRUE); + } + } + + openFloater(getKey()); + setFocus(TRUE); +} + +void LLFloaterTrackPicker::draw() +{ + LLView *owner = mOwnerHandle.get(); + static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, owner); + + LLFloater::draw(); +} + +void LLFloaterTrackPicker::onButtonCancel() +{ + closeFloater(); +} + +void LLFloaterTrackPicker::onButtonSelect() +{ + if (mCommitSignal) + { + (*mCommitSignal)(this, getChild<LLRadioGroup>(RDO_TRACK_SELECTION, true)->getSelectedValue()); + } + closeFloater(); +} + +void LLFloaterTrackPicker::onFocusLost() +{ + if (isInVisibleChain()) + { + closeFloater(); + } +} diff --git a/indra/newview/lltrackpicker.h b/indra/newview/lltrackpicker.h new file mode 100644 index 0000000000..dab3b72915 --- /dev/null +++ b/indra/newview/lltrackpicker.h @@ -0,0 +1,58 @@ +/** + * @file lltrackpicker.h + * @author AndreyK Productengine + * @brief LLTrackPicker class header file including related functions + * + * $LicenseInfo:firstyear=2018&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2018, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_TRACKPICKER_H +#define LL_TRACKPICKER_H + +#include "llfloater.h" + + +//========================================================================= + +class LLFloaterTrackPicker : public LLFloater +{ +public: + LLFloaterTrackPicker(LLView * owner, const LLSD ¶ms = LLSD()); + virtual ~LLFloaterTrackPicker() override; + + virtual BOOL postBuild() override; + virtual void onClose(bool app_quitting) override; + void showPicker(const LLSD &args); + + virtual void draw() override; + + void onButtonCancel(); + void onButtonSelect(); + +private: + void onFocusLost() override; + + F32 mContextConeOpacity; + LLHandle<LLView> mOwnerHandle; +}; + +#endif // LL_TRACKPICKER_H diff --git a/indra/newview/llviewerassetstorage.h b/indra/newview/llviewerassetstorage.h index 50131682e7..cefe215431 100644 --- a/indra/newview/llviewerassetstorage.h +++ b/indra/newview/llviewerassetstorage.h @@ -69,14 +69,14 @@ protected: // virtual void _queueDataRequest(const LLUUID& uuid, LLAssetType::EType type, - void (*callback) (LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat), + LLGetAssetCallback callback, void *user_data, BOOL duplicate, BOOL is_priority); void queueRequestHttp(const LLUUID& uuid, LLAssetType::EType type, - void (*callback) (LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat), + LLGetAssetCallback callback, void *user_data, BOOL duplicate, BOOL is_priority); @@ -86,7 +86,7 @@ protected: void assetRequestCoro(LLViewerAssetRequest *req, const LLUUID uuid, LLAssetType::EType atype, - void (*callback) (LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat), + LLGetAssetCallback callback, void *user_data); std::string getAssetURL(const std::string& cap_url, const LLUUID& uuid, LLAssetType::EType atype); diff --git a/indra/newview/llviewerassettype.cpp b/indra/newview/llviewerassettype.cpp index f07c14d01f..4804ef6ddc 100644 --- a/indra/newview/llviewerassettype.cpp +++ b/indra/newview/llviewerassettype.cpp @@ -87,6 +87,7 @@ LLViewerAssetDictionary::LLViewerAssetDictionary() addEntry(LLViewerAssetType::AT_UNKNOWN, new ViewerAssetEntry(DAD_NONE)); addEntry(LLViewerAssetType::AT_NONE, new ViewerAssetEntry(DAD_NONE)); + addEntry(LLViewerAssetType::AT_SETTINGS, new ViewerAssetEntry(DAD_SETTINGS)); }; EDragAndDropType LLViewerAssetType::lookupDragAndDropType(EType asset_type) diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 97fbb8c601..2544f75926 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -487,7 +487,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType: mTaskId(LLUUID::null), mContents(buffer), mInvnFinishFn(finish), - mTaskFinishFn(NULL), + mTaskFinishFn(nullptr), mStoredToVFS(false) { setItemId(itemId); @@ -501,7 +501,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer<LL mTaskId(LLUUID::null), mContents(), mInvnFinishFn(finish), - mTaskFinishFn(NULL), + mTaskFinishFn(nullptr), mStoredToVFS(false) { setItemId(itemId); @@ -534,7 +534,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemI mTaskUpload(true), mTaskId(taskId), mContents(buffer), - mInvnFinishFn(NULL), + mInvnFinishFn(nullptr), mTaskFinishFn(finish), mStoredToVFS(false) { @@ -739,6 +739,10 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti LLUploadDialog::modalUploadFinished(); return; } + if (!result.has("success")) + { + result["success"] = LLSD::Boolean((ulstate == "complete") && status); + } S32 uploadPrice = result["upload_price"].asInteger();//uploadInfo->getEconomyUploadCost(); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index ee1806b782..4241c22c3e 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -40,7 +40,7 @@ class LLResourceUploadInfo { public: - typedef boost::shared_ptr<LLResourceUploadInfo> ptr_t; + typedef std::shared_ptr<LLResourceUploadInfo> ptr_t; LLResourceUploadInfo( LLTransactionID transactId, @@ -169,8 +169,8 @@ private: class LLBufferedAssetUploadInfo : public LLResourceUploadInfo { public: - typedef boost::function<void(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response)> invnUploadFinish_f; - typedef boost::function<void(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response)> taskUploadFinish_f; + typedef std::function<void(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response)> invnUploadFinish_f; + typedef std::function<void(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response)> taskUploadFinish_f; LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish); LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer<LLImageFormatted> image, invnUploadFinish_f finish); diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 778e275727..27a87ee1a0 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -81,31 +81,6 @@ glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height return glh::matrix4f(m); } -glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) -{ - GLfloat f = 1.f/tanf(DEG_TO_RAD*fovy/2.f); - - return glh::matrix4f(f/aspect, 0, 0, 0, - 0, f, 0, 0, - 0, 0, (zFar+zNear)/(zNear-zFar), (2.f*zFar*zNear)/(zNear-zFar), - 0, 0, -1.f, 0); -} - -glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up) -{ - LLVector3 f = center-eye; - f.normVec(); - up.normVec(); - LLVector3 s = f % up; - LLVector3 u = s % f; - - return glh::matrix4f(s[0], s[1], s[2], 0, - u[0], u[1], u[2], 0, - -f[0], -f[1], -f[2], 0, - 0, 0, 0, 1); - -} - // Build time optimization, generate this once in .cpp file template class LLViewerCamera* LLSingleton<class LLViewerCamera>::getInstance(); diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index 5901de289f..fb07a3fb2d 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -35,14 +35,6 @@ #include "lltrace.h" class LLViewerObject; - -// This rotation matrix moves the default OpenGL reference frame -// (-Z at, Y up) to Cory's favorite reference frame (X at, Z up) -const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X - -1.f, 0.f, 0.f, 0.f, // -X becomes Y - 0.f, 1.f, 0.f, 0.f, // Y becomes Z - 0.f, 0.f, 0.f, 1.f }; - const BOOL FOR_SELECTION = TRUE; const BOOL NOT_FOR_SELECTION = FALSE; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 86a9e7e2ad..2e5807cab9 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -74,11 +74,11 @@ #include "llviewerregion.h" #include "lldrawpoolwater.h" #include "lldrawpoolbump.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" #include "llpostprocess.h" #include "llscenemonitor.h" +#include "llenvironment.h" + extern LLPointer<LLViewerTexture> gStartTexture; extern bool gShiftFrame; @@ -200,8 +200,7 @@ void display_update_camera() gViewerWindow->setup3DRender(); // update all the sky/atmospheric/water settings - LLWLParamManager::getInstance()->update(LLViewerCamera::getInstance()); - LLWaterParamManager::getInstance()->update(LLViewerCamera::getInstance()); + LLEnvironment::instance().update(LLViewerCamera::getInstance()); // Update land visibility too LLWorld::getInstance()->setLandFarClip(final_far); @@ -654,7 +653,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) stop_glerror(); S32 water_clip = 0; - if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && + if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER) || gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER))) { @@ -718,11 +717,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (!for_snapshot) { - if (gFrameCount > 1) - { //for some reason, ATI 4800 series will error out if you - //try to generate a shadow before the first frame is through - gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); - } + gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); LLVertexBuffer::unbind(); @@ -730,8 +725,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); - glh::matrix4f proj = glh_get_current_projection(); - glh::matrix4f mod = glh_get_current_modelview(); + glh::matrix4f proj = get_current_projection(); + glh::matrix4f mod = get_current_modelview(); glViewport(0,0,512,512); LLVOAvatar::updateFreezeCounter() ; @@ -740,8 +735,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLVOAvatar::updateImpostors(); } - glh_set_current_projection(proj); - glh_set_current_modelview(mod); + set_current_projection(proj); + set_current_modelview(mod); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadMatrix(proj.m); gGL.matrixMode(LLRender::MM_MODELVIEW); @@ -921,7 +916,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.mScreen.bindTarget(); if (LLPipeline::sUnderWaterRender && !gPipeline.canUseWindLightShaders()) { - const LLColor4 &col = LLDrawPoolWater::sWaterFogColor; + const LLColor4 &col = LLEnvironment::instance().getCurrentWater()->getWaterFogColor(); glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); } gPipeline.mScreen.clear(); @@ -1024,7 +1019,12 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (LLPipeline::sRenderDeferred) { - gPipeline.renderDeferredLighting(); + gPipeline.renderDeferredLighting(&gPipeline.mScreen); + } + + if (to_texture) + { + gPipeline.renderBloom(gSnapshot, zoom_factor, subfield); } LLPipeline::sUnderWaterRender = FALSE; @@ -1037,7 +1037,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI"); if (!for_snapshot) { - LL_RECORD_BLOCK_TIME(FTM_RENDER_UI); render_ui(); swap(); } @@ -1079,8 +1078,8 @@ void render_hud_attachments() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - glh::matrix4f current_proj = glh_get_current_projection(); - glh::matrix4f current_mod = glh_get_current_modelview(); + glh::matrix4f current_proj = get_current_projection(); + glh::matrix4f current_mod = get_current_modelview(); // clamp target zoom level to reasonable values gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); @@ -1172,8 +1171,8 @@ void render_hud_attachments() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - glh_set_current_projection(current_proj); - glh_set_current_modelview(current_mod); + set_current_projection(current_proj); + set_current_modelview(current_mod); } LLRect get_whole_screen_region() @@ -1255,29 +1254,32 @@ bool setup_hud_matrices(const LLRect& screen_region) // set up transform to keep HUD objects in front of camera gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadMatrix(proj.m); - glh_set_current_projection(proj); + set_current_projection(proj); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(model.m); - glh_set_current_modelview(model); + set_current_modelview(model); return TRUE; } void render_ui(F32 zoom_factor, int subfield) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI); + LLGLState::checkStates(); - glh::matrix4f saved_view = glh_get_current_modelview(); + glh::matrix4f saved_view = get_current_modelview(); if (!gSnapshot) { gGL.pushMatrix(); gGL.loadMatrix(gGLLastModelView); - glh_set_current_modelview(glh_copy_matrix(gGLLastModelView)); + set_current_modelview(copy_matrix(gGLLastModelView)); } if(LLSceneMonitor::getInstance()->needsUpdate()) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_SCENE_MON); gGL.pushMatrix(); gViewerWindow->setup2DRender(); LLSceneMonitor::getInstance()->compare(); @@ -1286,14 +1288,7 @@ void render_ui(F32 zoom_factor, int subfield) } { - BOOL to_texture = gPipeline.canUseVertexShaders() && - LLPipeline::sRenderGlow; - - if (to_texture) - { - gPipeline.renderBloom(gSnapshot, zoom_factor, subfield); - } - + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_HUD); render_hud_elements(); render_hud_attachments(); } @@ -1308,10 +1303,9 @@ void render_ui(F32 zoom_factor, int subfield) gGL.color4f(1,1,1,1); if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { - LL_RECORD_BLOCK_TIME(FTM_RENDER_UI); - if (!gDisconnected) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_3D); render_ui_3d(); LLGLState::checkStates(); } @@ -1320,12 +1314,14 @@ void render_ui(F32 zoom_factor, int subfield) render_disconnected_background(); } + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_2D); render_ui_2d(); LLGLState::checkStates(); } gGL.flush(); { + LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_DEBUG_TEXT); gViewerWindow->setup2DRender(); gViewerWindow->updateDebugText(); gViewerWindow->drawDebugText(); @@ -1336,7 +1332,7 @@ void render_ui(F32 zoom_factor, int subfield) if (!gSnapshot) { - glh_set_current_modelview(saved_view); + set_current_modelview(saved_view); gGL.popMatrix(); } } diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 0ebacddd9b..6ad4ea76af 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -55,18 +55,15 @@ #include "llfloaterchatvoicevolume.h" #include "llfloaterconversationlog.h" #include "llfloaterconversationpreview.h" -#include "llfloaterdeleteenvpreset.h" #include "llfloaterdeleteprefpreset.h" #include "llfloaterdestinations.h" -#include "llfloatereditdaycycle.h" -#include "llfloatereditsky.h" -#include "llfloatereditwater.h" -#include "llfloaterenvironmentsettings.h" +#include "llfloatereditextdaycycle.h" #include "llfloaterexperienceprofile.h" #include "llfloaterexperiences.h" #include "llfloaterexperiencepicker.h" #include "llfloaterevent.h" #include "llfloaterfacebook.h" +#include "llfloaterfixedenvironment.h" #include "llfloaterflickr.h" #include "llfloaterfonttest.h" #include "llfloatergesture.h" @@ -90,6 +87,7 @@ #include "llfloatermediasettings.h" #include "llfloatermemleak.h" #include "llfloatermodelpreview.h" +#include "llfloatermyenvironment.h" #include "llfloaternamedesc.h" #include "llfloaternotificationsconsole.h" #include "llfloaternotificationstabbed.h" @@ -221,11 +219,13 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>); LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>); - LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>); - LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>); - LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>); - LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>); - LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>); + + LLFloaterReg::add("env_fixed_environmentent_water", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFixedEnvironmentWater>); + LLFloaterReg::add("env_fixed_environmentent_sky", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFixedEnvironmentSky>); + //LLFloaterReg::add("env_fixed_environmentent", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFixedEnvironment>); + + LLFloaterReg::add("env_edit_extdaycycle", "floater_edit_ext_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditExtDayCycle>); + LLFloaterReg::add("my_environments", "floater_my_environments.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMyEnvironment>); LLFloaterReg::add("event", "floater_event.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEvent>); LLFloaterReg::add("experiences", "floater_experiences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiences>); @@ -250,6 +250,9 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>); LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>); + +// LLFloaterReg::add("floater_settings_picker", "floater_settings_picker.xml" , (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>); + LLInspectAvatarUtil::registerFloater(); LLInspectGroupUtil::registerFloater(); LLInspectObjectUtil::registerFloater(); diff --git a/indra/newview/llviewerfoldertype.cpp b/indra/newview/llviewerfoldertype.cpp index 9cb2e0336a..afa84a5afc 100644 --- a/indra/newview/llviewerfoldertype.cpp +++ b/indra/newview/llviewerfoldertype.cpp @@ -133,7 +133,8 @@ LLViewerFolderDictionary::LLViewerFolderDictionary() addEntry(LLFolderType::FT_OUTFIT, new ViewerFolderEntry("New Outfit", "Inv_LookFolderOpen", "Inv_LookFolderClosed", TRUE, true)); addEntry(LLFolderType::FT_MY_OUTFITS, new ViewerFolderEntry("My Outfits", "Inv_SysOpen", "Inv_SysClosed", TRUE, true)); addEntry(LLFolderType::FT_MESH, new ViewerFolderEntry("Meshes", "Inv_SysOpen", "Inv_SysClosed", FALSE, true)); - + addEntry(LLFolderType::FT_SETTINGS, new ViewerFolderEntry("Settings", "Inv_SysOpen", "Inv_SysClosed", FALSE, true)); + bool boxes_invisible = !gSavedSettings.getBOOL("InventoryOutboxMakeVisible"); addEntry(LLFolderType::FT_INBOX, new ViewerFolderEntry("Received Items", "Inv_SysOpen", "Inv_SysClosed", FALSE, boxes_invisible)); addEntry(LLFolderType::FT_OUTBOX, new ViewerFolderEntry("Merchant Outbox", "Inv_SysOpen", "Inv_SysClosed", FALSE, true)); diff --git a/indra/newview/llviewergenericmessage.cpp b/indra/newview/llviewergenericmessage.cpp index 3df53a4a30..d3de9d72bf 100644 --- a/indra/newview/llviewergenericmessage.cpp +++ b/indra/newview/llviewergenericmessage.cpp @@ -70,8 +70,6 @@ void send_generic_message(const std::string& method, gAgent.sendReliableMessage(); } - - void process_generic_message(LLMessageSystem* msg, void**) { LLUUID agent_id; @@ -93,3 +91,25 @@ void process_generic_message(LLMessageSystem* msg, void**) << LL_ENDL; } } + +void process_large_generic_message(LLMessageSystem* msg, void**) +{ + LLUUID agent_id; + msg->getUUID("AgentData", "AgentID", agent_id); + if (agent_id != gAgent.getID()) + { + LL_WARNS() << "GenericMessage for wrong agent" << LL_ENDL; + return; + } + + std::string request; + LLUUID invoice; + LLDispatcher::sparam_t strings; + LLDispatcher::unpackLargeMessage(msg, request, invoice, strings); + + if (!gGenericDispatcher.dispatch(request, invoice, strings)) + { + LL_WARNS() << "GenericMessage " << request << " failed to dispatch" + << LL_ENDL; + } +} diff --git a/indra/newview/llviewergenericmessage.h b/indra/newview/llviewergenericmessage.h index 9d451ec0bc..170f38a485 100644 --- a/indra/newview/llviewergenericmessage.h +++ b/indra/newview/llviewergenericmessage.h @@ -38,6 +38,7 @@ void send_generic_message(const std::string& method, const LLUUID& invoice = LLUUID::null); void process_generic_message(LLMessageSystem* msg, void**); +void process_large_generic_message(LLMessageSystem* msg, void**); extern LLDispatcher gGenericDispatcher; diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 1ab7ec0156..e4d3d73a3e 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -70,6 +70,7 @@ #include "llfloaterperms.h" #include "llclipboard.h" #include "llhttpretrypolicy.h" +#include "llsettingsvo.h" // do-nothing ops for use in callbacks. void no_op_inventory_func(const LLUUID&) {} @@ -1097,7 +1098,7 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, const LLUUID& parent, const LLTransactionID& transaction_id, const std::string& name, const std::string& desc, LLAssetType::EType asset_type, - LLInventoryType::EType inv_type, LLWearableType::EType wtype, + LLInventoryType::EType inv_type, U8 subtype, U32 next_owner_perm, LLPointer<LLInventoryCallback> cb) { @@ -1132,7 +1133,7 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, msg->addU32Fast(_PREHASH_NextOwnerMask, next_owner_perm); msg->addS8Fast(_PREHASH_Type, (S8)asset_type); msg->addS8Fast(_PREHASH_InvType, (S8)inv_type); - msg->addU8Fast(_PREHASH_WearableType, (U8)wtype); + msg->addU8Fast(_PREHASH_WearableType, (U8)subtype); msg->addStringFast(_PREHASH_Name, server_name); msg->addStringFast(_PREHASH_Description, desc); @@ -1146,9 +1147,36 @@ void create_inventory_callingcard(const LLUUID& avatar_id, const LLUUID& parent LLAvatarNameCache::get(avatar_id, &av_name); create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, LLTransactionID::tnull, av_name.getUserName(), item_desc, LLAssetType::AT_CALLINGCARD, - LLInventoryType::IT_CALLINGCARD, NOT_WEARABLE, PERM_MOVE | PERM_TRANSFER, cb); + LLInventoryType::IT_CALLINGCARD, NO_INV_SUBTYPE, PERM_MOVE | PERM_TRANSFER, cb); } +void create_inventory_wearable(const LLUUID& agent_id, const LLUUID& session_id, + const LLUUID& parent, const LLTransactionID& transaction_id, + const std::string& name, + const std::string& desc, LLAssetType::EType asset_type, + LLWearableType::EType wtype, + U32 next_owner_perm, + LLPointer<LLInventoryCallback> cb) +{ + create_inventory_item(agent_id, session_id, parent, transaction_id, + name, desc, asset_type, LLInventoryType::IT_WEARABLE, static_cast<U8>(wtype), + next_owner_perm, cb); +} + +void create_inventory_settings(const LLUUID& agent_id, const LLUUID& session_id, + const LLUUID& parent, const LLTransactionID& transaction_id, + const std::string& name, + const std::string& desc, + LLSettingsType::type_e settype, + U32 next_owner_perm, + LLPointer<LLInventoryCallback> cb) +{ + create_inventory_item(agent_id, session_id, parent, transaction_id, + name, desc, LLAssetType::AT_SETTINGS, LLInventoryType::IT_SETTINGS, + static_cast<U8>(settype), next_owner_perm, cb); +} + + void copy_inventory_item( const LLUUID& agent_id, const LLUUID& current_owner, @@ -1700,7 +1728,7 @@ void create_new_item(const std::string& name, desc, asset_type, inv_type, - NOT_WEARABLE, + NO_INV_SUBTYPE, next_owner_perm, cb); } @@ -1793,6 +1821,32 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, LLInventoryType::IT_GESTURE, PERM_ALL); // overridden in create_new_item } + else if (("sky" == type_name) || ("water" == type_name) || ("daycycle" == type_name)) + { + LLSettingsType::type_e stype(LLSettingsType::ST_NONE); + + if ("sky" == type_name) + { + stype = LLSettingsType::ST_SKY; + } + else if ("water" == type_name) + { + stype = LLSettingsType::ST_WATER; + } + else if ("daycycle" == type_name) + { + stype = LLSettingsType::ST_DAYCYCLE; + } + else + { + LL_ERRS(LOG_INV) << "Unknown settings type: '" << type_name << "'" << LL_ENDL; + return; + } + + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS); + + LLSettingsVOBase::createNewInventoryItem(stype, parent_id); + } else { // Use for all clothing and body parts. Adding new wearable types requires updating LLWearableDictionary. @@ -1973,6 +2027,19 @@ LLWearableType::EType LLViewerInventoryItem::getWearableType() const return LLWearableType::inventoryFlagsToWearableType(getFlags()); } +bool LLViewerInventoryItem::isSettingsType() const +{ + return (getInventoryType() == LLInventoryType::IT_SETTINGS); +} + +LLSettingsType::type_e LLViewerInventoryItem::getSettingsType() const +{ + if (!isSettingsType()) + { + return LLSettingsType::ST_NONE; + } + return LLSettingsType::fromInventoryFlags(getFlags()); +} time_t LLViewerInventoryItem::getCreationDate() const { diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index b3053e365b..d537b28682 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -31,6 +31,7 @@ #include "llframetimer.h" #include "llwearable.h" #include "llinitdestroyclass.h" //for LLDestroyClass +#include "llinventorysettings.h" #include <boost/signals2.hpp> // boost::signals2::trackable @@ -74,6 +75,9 @@ public: virtual LLInventoryType::EType getInventoryType() const; virtual bool isWearableType() const; virtual LLWearableType::EType getWearableType() const; + virtual bool isSettingsType() const; + virtual LLSettingsType::type_e getSettingsType() const; + virtual U32 getFlags() const; virtual time_t getCreationDate() const; virtual U32 getCRC32() const; // really more of a checksum. @@ -295,7 +299,7 @@ public: // virtual void fire(const LLUUID& item_id) -{ + { mFireFunc(item_id); } @@ -336,17 +340,32 @@ public: extern LLInventoryCallbackManager gInventoryCallbacks; -#define NOT_WEARABLE (LLWearableType::EType)0 +const U8 NO_INV_SUBTYPE{ 0 }; // *TODO: Find a home for these void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, const LLUUID& parent, const LLTransactionID& transaction_id, const std::string& name, const std::string& desc, LLAssetType::EType asset_type, - LLInventoryType::EType inv_type, LLWearableType::EType wtype, + LLInventoryType::EType inv_type, U8 subtype, U32 next_owner_perm, LLPointer<LLInventoryCallback> cb); +void create_inventory_wearable(const LLUUID& agent_id, const LLUUID& session_id, + const LLUUID& parent, const LLTransactionID& transaction_id, + const std::string& name, + const std::string& desc, LLAssetType::EType asset_type, + LLWearableType::EType wtype, + U32 next_owner_perm, + LLPointer<LLInventoryCallback> cb); + +void create_inventory_settings(const LLUUID& agent_id, const LLUUID& session_id, + const LLUUID& parent, const LLTransactionID& transaction_id, + const std::string& name, const std::string& desc, + LLSettingsType::type_e settype, + U32 next_owner_perm, LLPointer<LLInventoryCallback> cb); + + void create_inventory_callingcard(const LLUUID& avatar_id, const LLUUID& parent = LLUUID::null, LLPointer<LLInventoryCallback> cb=NULL); /** diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 43a81ada49..6990f56a08 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -112,7 +112,7 @@ void LLViewerJointMesh::uploadJointMatrices() S32 joint_num; LLPolyMesh *reference_mesh = mMesh->getReferenceMesh(); LLDrawPool *poolp = mFace ? mFace->getPool() : NULL; - BOOL hardware_skinning = (poolp && poolp->getVertexShaderLevel() > 0) ? TRUE : FALSE; + BOOL hardware_skinning = (poolp && poolp->getShaderLevel() > 0) ? TRUE : FALSE; //calculate joint matrices for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); joint_num++) @@ -246,7 +246,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) stop_glerror(); - LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), (mFace->getPool()->getVertexShaderLevel() > 0 || LLGLSLShader::sNoFixedFunction) ? 0.f : mShiny); + LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), (mFace->getPool()->getShaderLevel() > 0 || LLGLSLShader::sNoFixedFunction) ? 0.f : mShiny); //---------------------------------------------------------------- // setup current texture @@ -307,14 +307,14 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) if (mMesh->hasWeights()) { - if ((mFace->getPool()->getVertexShaderLevel() > 0)) + if ((mFace->getPool()->getShaderLevel() > 0)) { if (first_pass) { uploadJointMatrices(); } mask = mask | LLVertexBuffer::MAP_WEIGHT; - if (mFace->getPool()->getVertexShaderLevel() > 1) + if (mFace->getPool()->getShaderLevel() > 1) { mask = mask | LLVertexBuffer::MAP_CLOTHWEIGHT; } @@ -390,7 +390,7 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w } LLDrawPool *poolp = mFace->getPool(); - BOOL hardware_skinning = (poolp && poolp->getVertexShaderLevel() > 0) ? TRUE : FALSE; + BOOL hardware_skinning = (poolp && poolp->getShaderLevel() > 0) ? TRUE : FALSE; if (!hardware_skinning && terse_update) { //no need to do terse updates if we're doing software vertex skinning @@ -538,7 +538,7 @@ void LLViewerJointMesh::updateJointGeometry() && mFace && mMesh->hasWeights() && mFace->getVertexBuffer() - && LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) == 0)) + && LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) == 0)) { return; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 6c52f118ad..68a91968ea 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -51,9 +51,8 @@ #include "llagentpilot.h" #include "llcompilequeue.h" #include "llconsole.h" -#include "lldaycyclemanager.h" #include "lldebugview.h" -#include "llenvmanager.h" +#include "llenvironment.h" #include "llfacebookconnect.h" #include "llfilepicker.h" #include "llfirstuse.h" @@ -121,9 +120,6 @@ #include "llworldmap.h" #include "pipeline.h" #include "llviewerjoystick.h" -#include "llwaterparammanager.h" -#include "llwlanimator.h" -#include "llwlparammanager.h" #include "llfloatercamera.h" #include "lluilistener.h" #include "llappearancemgr.h" @@ -136,6 +132,7 @@ #include "boost/unordered_map.hpp" #include <boost/regex.hpp> #include "llcleanup.h" +#include "llviewershadermgr.h" using namespace LLAvatarAppearanceDefines; @@ -2277,8 +2274,8 @@ class LLAdvancedEnableRenderDeferred: public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = gGLManager.mHasFramebufferObject && LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1 && - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0; + bool new_value = gGLManager.mHasFramebufferObject && LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1 && + LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0; return new_value; } }; @@ -2290,8 +2287,8 @@ class LLAdvancedEnableRenderDeferredOptions: public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = gGLManager.mHasFramebufferObject && LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1 && - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0 && gSavedSettings.getBOOL("RenderDeferred"); + bool new_value = gGLManager.mHasFramebufferObject && LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1 && + LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0 && gSavedSettings.getBOOL("RenderDeferred"); return new_value; } }; @@ -8261,6 +8258,14 @@ class LLViewToggleBeacon : public view_listener_t gSavedSettings.setBOOL( "scriptsbeacon", LLPipeline::getRenderScriptedBeacons() ); } } + else if (beacon == "sunbeacon") + { + gSavedSettings.setBOOL("sunbeacon", !gSavedSettings.getBOOL("sunbeacon")); + } + else if (beacon == "moonbeacon") + { + gSavedSettings.setBOOL("moonbeacon", !gSavedSettings.getBOOL("moonbeacon")); + } else if (beacon == "renderbeacons") { LLPipeline::toggleRenderBeacons(); @@ -8477,44 +8482,71 @@ class LLToolsSelectTool : public view_listener_t /// WINDLIGHT callbacks class LLWorldEnvSettings : public view_listener_t { + void defocusEnvFloaters() + { + //currently there is only one instance of each floater + std::vector<std::string> env_floaters_names = { "env_edit_extdaycycle", "env_fixed_environmentent_water", "env_fixed_environmentent_sky" }; + for (std::vector<std::string>::const_iterator it = env_floaters_names.begin(); it != env_floaters_names.end(); ++it) + { + LLFloater* env_floater = LLFloaterReg::findTypedInstance<LLFloater>(*it); + if (env_floater) + { + env_floater->setFocus(FALSE); + } + } + } + bool handleEvent(const LLSD& userdata) { - std::string tod = userdata.asString(); + std::string event_name = userdata.asString(); - if (tod == "editor") + if (event_name == "sunrise") { - LLFloaterReg::toggleInstance("env_settings"); - return true; - } - - if (tod == "sunrise") - { - LLEnvManagerNew::instance().setUseSkyPreset("Sunrise"); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNRISE); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().updateEnvironment(); + defocusEnvFloaters(); } - else if (tod == "noon") + else if (event_name == "noon") { - LLEnvManagerNew::instance().setUseSkyPreset("Midday"); - } - else if (tod == "sunset") + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDDAY); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().updateEnvironment(); + defocusEnvFloaters(); + } + else if (event_name == "sunset") { - LLEnvManagerNew::instance().setUseSkyPreset("Sunset"); - } - else if (tod == "midnight") + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNSET); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().updateEnvironment(); + defocusEnvFloaters(); + } + else if (event_name == "midnight") { - LLEnvManagerNew::instance().setUseSkyPreset("Midnight"); - } - else + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDNIGHT); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().updateEnvironment(); + defocusEnvFloaters(); + } + else if (event_name == "region") { - LLEnvManagerNew &envmgr = LLEnvManagerNew::instance(); - // reset all environmental settings to track the region defaults, make this reset 'sticky' like the other sun settings. - bool use_fixed_sky = false; - bool use_region_settings = true; - envmgr.setUserPrefs(envmgr.getWaterPresetName(), - envmgr.getSkyPresetName(), - envmgr.getDayCycleName(), - use_fixed_sky, use_region_settings); - } - + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + LLEnvironment::instance().updateEnvironment(); + defocusEnvFloaters(); + } + else if (event_name == "pause_clouds") + { + if (LLEnvironment::instance().isCloudScrollPaused()) + LLEnvironment::instance().resumeCloudScroll(); + else + LLEnvironment::instance().pauseCloudScroll(); + } + else if (event_name == "my_environs") + { + LLFloaterReg::showInstance("my_environments"); + } + return true; } }; @@ -8524,39 +8556,46 @@ class LLWorldEnableEnvSettings : public view_listener_t bool handleEvent(const LLSD& userdata) { bool result = false; - std::string tod = userdata.asString(); + std::string event_name = userdata.asString(); - if (LLEnvManagerNew::instance().getUseRegionSettings()) + if (event_name == "pause_clouds") + { + return LLEnvironment::instance().isCloudScrollPaused(); + } + + LLSettingsSky::ptr_t sky = LLEnvironment::instance().getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL); + + if (!sky) { - return (tod == "region"); + return (event_name == "region"); } - if (LLEnvManagerNew::instance().getUseFixedSky()) + std::string skyname = (sky) ? sky->getName() : ""; + LLUUID skyid = (sky) ? sky->getAssetId() : LLUUID::null; + + if (event_name == "sunrise") { - if (tod == "sunrise") - { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Sunrise"); - } - else if (tod == "noon") - { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Midday"); - } - else if (tod == "sunset") - { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Sunset"); - } - else if (tod == "midnight") - { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Midnight"); - } - else if (tod == "region") - { - return false; - } - else - { - LL_WARNS() << "Unknown time-of-day item: " << tod << LL_ENDL; - } + result = (skyid == LLEnvironment::KNOWN_SKY_SUNRISE); + } + else if (event_name == "noon") + { + result = (skyid == LLEnvironment::KNOWN_SKY_MIDDAY); + } + else if (event_name == "sunset") + { + result = (skyid == LLEnvironment::KNOWN_SKY_SUNSET); + } + else if (event_name == "midnight") + { + result = (skyid == LLEnvironment::KNOWN_SKY_MIDNIGHT); + } + else if (event_name == "region") + { + return false; + } + else + { + LL_WARNS() << "Unknown time-of-day item: " << event_name << LL_ENDL; } return result; } @@ -8570,39 +8609,27 @@ class LLWorldEnvPreset : public view_listener_t if (item == "new_water") { - LLFloaterReg::showInstance("env_edit_water", "new"); + LLFloaterReg::showInstance("env_fixed_environmentent_water", "new"); } else if (item == "edit_water") { - LLFloaterReg::showInstance("env_edit_water", "edit"); - } - else if (item == "delete_water") - { - LLFloaterReg::showInstance("env_delete_preset", "water"); - } + LLFloaterReg::showInstance("env_fixed_environmentent_water", "edit"); + } else if (item == "new_sky") { - LLFloaterReg::showInstance("env_edit_sky", "new"); - } + LLFloaterReg::showInstance("env_fixed_environmentent_sky", "new"); + } else if (item == "edit_sky") { - LLFloaterReg::showInstance("env_edit_sky", "edit"); - } - else if (item == "delete_sky") - { - LLFloaterReg::showInstance("env_delete_preset", "sky"); - } + LLFloaterReg::showInstance("env_fixed_environmentent_sky", "edit"); + } else if (item == "new_day_cycle") { - LLFloaterReg::showInstance("env_edit_day_cycle", "new"); + LLFloaterReg::showInstance("env_edit_extdaycycle", LLSDMap("edit_context", "inventory")); } else if (item == "edit_day_cycle") { - LLFloaterReg::showInstance("env_edit_day_cycle", "edit"); - } - else if (item == "delete_day_cycle") - { - LLFloaterReg::showInstance("env_delete_preset", "day_cycle"); + LLFloaterReg::showInstance("env_edit_extdaycycle", LLSDMap("edit_context", "inventory")); } else { @@ -8617,30 +8644,6 @@ class LLWorldEnableEnvPreset : public view_listener_t { bool handleEvent(const LLSD& userdata) { - std::string item = userdata.asString(); - - if (item == "delete_water") - { - LLWaterParamManager::preset_name_list_t user_waters; - LLWaterParamManager::instance().getUserPresetNames(user_waters); - return !user_waters.empty(); - } - else if (item == "delete_sky") - { - LLWLParamManager::preset_name_list_t user_skies; - LLWLParamManager::instance().getUserPresetNames(user_skies); - return !user_skies.empty(); - } - else if (item == "delete_day_cycle") - { - LLDayCycleManager::preset_name_list_t user_days; - LLDayCycleManager::instance().getUserPresetNames(user_days); - return !user_days.empty(); - } - else - { - LL_WARNS() << "Unknown item" << LL_ENDL; - } return false; } diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index d2a5578568..bb557fbdaa 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -440,7 +440,7 @@ const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker:: LLFloaterPerms::getEveryonePerms("Uploads"), expected_upload_cost)); - upload_new_resource(uploadInfo, NULL, NULL); + upload_new_resource(uploadInfo); } } @@ -693,7 +693,7 @@ LLUUID upload_new_resource( bool show_inventory) { - LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( + LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLNewFileResourceUploadInfo>( src_filename, name, desc, compression_info, destination_folder_type, inv_type, @@ -776,7 +776,7 @@ void upload_done_callback( create_inventory_item(gAgent.getID(), gAgent.getSessionID(), folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(), data->mAssetInfo.getDescription(), data->mAssetInfo.mType, - data->mInventoryType, NOT_WEARABLE, next_owner_perms, + data->mInventoryType, NO_INV_SUBTYPE, next_owner_perms, LLPointer<LLInventoryCallback>(NULL)); } else @@ -812,7 +812,7 @@ void upload_done_callback( LLStringUtil::trim(asset_name); std::string display_name = LLStringUtil::null; - LLAssetStorage::LLStoreAssetCallback callback = NULL; + LLAssetStorage::LLStoreAssetCallback callback; void *userdata = NULL; upload_new_resource( next_file, diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 4e8348b5e5..4e6250d9b4 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -60,7 +60,7 @@ LLUUID upload_new_resource( void upload_new_resource( LLResourceUploadInfo::ptr_t &uploadInfo, - LLAssetStorage::LLStoreAssetCallback callback = NULL, + LLAssetStorage::LLStoreAssetCallback callback = LLAssetStorage::LLStoreAssetCallback(), void *userdata = NULL); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 981d226824..e610387b37 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3760,6 +3760,7 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data) void process_time_synch(LLMessageSystem *mesgsys, void **user_data) { LLVector3 sun_direction; + LLVector3 moon_direction; LLVector3 sun_ang_velocity; F32 phase; U64 space_time_usec; @@ -3779,14 +3780,26 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data) LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec); - LL_DEBUGS("WindlightSync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL; + LL_DEBUGS("ENVIRONMENT") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL; - gSky.setSunPhase(phase); - gSky.setSunTargetDirection(sun_direction, sun_ang_velocity); - if ( !(gSavedSettings.getBOOL("SkyOverrideSimSunPosition") || gSky.getOverrideSun()) ) - { - gSky.setSunDirection(sun_direction, sun_ang_velocity); - } + F32 region_phase = LLEnvironment::instance().getRegionProgress(); + if (region_phase >= 0.0) + { + F32 adjusted_phase = fmodf(phase / F_TWO_PI + 0.25, 1.f); + F32 delta_phase = adjusted_phase - region_phase; + + LL_DEBUGS("ENVIRONMENT") << "adjusted phase = " << adjusted_phase << " local phase = " << region_phase << " delta = " << delta_phase << LL_ENDL; + + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled() && (fabs(delta_phase) > 0.125)) + { + LL_INFOS("ENVIRONMENT") << "Adjusting environment to match region. adjustment=" << delta_phase << LL_ENDL; + LLEnvironment::instance().adjustRegionOffset(delta_phase); + } + } + + /* We decode these parts of the message but ignore them + as the real values are provided elsewhere. */ + (void)sun_direction, (void)moon_direction, (void)phase; } void process_sound_trigger(LLMessageSystem *msg, void **) @@ -5763,18 +5776,16 @@ void process_script_question(LLMessageSystem *msg, void **user_data) // check whether permission question should cause special caution dialog caution |= (script_perm.caution); - if (("ScriptTakeMoney" == script_perm.question) && has_not_only_debit) + if ((("ScriptTakeMoney" == script_perm.question) && has_not_only_debit) || + (script_perm.question == "JoinAnExperience")) continue; - if (script_perm.question == "JoinAnExperience") - { // Some experience only permissions do not have an explicit permission bit. Add them here. - script_question += " " + LLTrans::getString("ForceSitAvatar") + "\n"; - } - script_question += " " + LLTrans::getString(script_perm.question) + "\n"; } } + script_question += "\n"; + args["QUESTIONS"] = script_question; if (known_questions != questions) diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index 46b3c8f315..374322ac10 100644 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -34,7 +34,6 @@ #include "lltrans.h" #include "llweb.h" - /// key used to store the grid, and the name attribute in the grid data const std::string GRID_VALUE = "keyname"; /// the value displayed in the grid selector menu, and other human-oriented text @@ -88,6 +87,13 @@ LLGridManager::LLGridManager() // an attacker. Don't want someone snagging a password. std::string grid_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grids.xml"); + + // fall back to app_settings/grids.xml if it's provided + if (!LLFile::isfile(grid_file)) + { + grid_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, + "grids.xml"); + } LL_DEBUGS("GridManager")<<LL_ENDL; initialize(grid_file); @@ -133,6 +139,13 @@ void LLGridManager::initialize(const std::string& grid_file) "https://my.aditi.lindenlab.com/", "Aditi"); + // dump example grid file... + //llofstream out_llsd_xml; + //std::string default_grid_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"); + //out_llsd_xml.open(default_grid_file.c_str()); + //LLSDSerialize::toPrettyXML(mGridList, out_llsd_xml); + //out_llsd_xml.close(); + LLSD other_grids; llifstream llsd_xml; if (!grid_file.empty()) @@ -484,12 +497,19 @@ void LLGridManager::getLoginURIs(const std::string& grid, std::vector<std::strin std::string grid_name = getGrid(grid); if (!grid_name.empty()) { - for (LLSD::array_iterator llsd_uri = mGridList[grid_name][GRID_LOGIN_URI_VALUE].beginArray(); - llsd_uri != mGridList[grid_name][GRID_LOGIN_URI_VALUE].endArray(); - llsd_uri++) - { - uris.push_back(llsd_uri->asString()); - } + if (mGridList[grid_name][GRID_LOGIN_URI_VALUE].isArray()) + { + for (LLSD::array_iterator llsd_uri = mGridList[grid_name][GRID_LOGIN_URI_VALUE].beginArray(); + llsd_uri != mGridList[grid_name][GRID_LOGIN_URI_VALUE].endArray(); + llsd_uri++) + { + uris.push_back(llsd_uri->asString()); + } + } + else + { + uris.push_back(mGridList[grid_name][GRID_LOGIN_URI_VALUE].asString()); + } } else { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 1e46a1cf9e..a7151c4d1b 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -3072,6 +3072,7 @@ void LLViewerObject::unlinkControlAvatar() if (mControlAvatar) { mControlAvatar->markForDeath(); + mControlAvatar->mRootVolp = NULL; mControlAvatar = NULL; } } diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 00a652384c..459ee1f35c 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1110,16 +1110,13 @@ void LLOcclusionCullingGroup::checkOcclusion() static LLCachedControl<bool> wait_for_query(gSavedSettings, "RenderSynchronousOcclusion", true); - if (wait_for_query && mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount) + U32 target_read_frame = (gFrameCount > 2) ? (gFrameCount - 2) : 0; + if (wait_for_query && (mOcclusionIssued[LLViewerCamera::sCurCameraID] < target_read_frame)) { //query was issued last frame, wait until it's available - S32 max_loop = 1024; + S32 max_loop = 64; LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_WAIT); while (!available && max_loop-- > 0) { - //do some usefu work while we wait - F32 max_time = llmin(gFrameIntervalSeconds.value()*10.f, 1.f); - LLAppViewer::instance()->updateTextureThreads(max_time); - glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available); } } @@ -1272,7 +1269,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh { LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_DRAW_WATER); - LLGLSquashToFarClip squash(glh_get_current_projection(), 1); + LLGLSquashToFarClip squash; if (camera->getOrigin().isExactlyZero()) { //origin is invalid, draw entire box gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0); diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index f4d14a39fe..e2a7c563a7 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -69,6 +69,8 @@ #include "llvieweraudio.h" #include "llcorehttputil.h" +#include "llenvironment.h" + const F32 PARCEL_COLLISION_DRAW_SECS = 1.f; @@ -645,6 +647,31 @@ LLParcel *LLViewerParcelMgr::getAgentParcel() const return mAgentParcel; } + +LLParcel * LLViewerParcelMgr::getAgentOrSelectedParcel() const +{ + LLParcel *parcel(nullptr); + + LLParcelSelectionHandle sel_handle(getFloatingParcelSelection()); + if (sel_handle) + { + LLParcelSelection *selection(sel_handle.get()); + if (selection) + { + parcel = selection->getParcel(); + if (parcel && (parcel->getLocalID() == INVALID_PARCEL_ID)) + { + parcel = NULL; + } + } + } + + if (!parcel) + parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + return parcel; +} + // Return whether the agent can build on the land they are on bool LLViewerParcelMgr::allowAgentBuild() const { @@ -1285,6 +1312,13 @@ const std::string& LLViewerParcelMgr::getAgentParcelName() const } +const S32 LLViewerParcelMgr::getAgentParcelId() const +{ + if (mAgentParcel) + return mAgentParcel->getLocalID(); + return INVALID_PARCEL_ID; +} + void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region) { if(!parcel) @@ -1460,6 +1494,8 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use BOOL region_deny_transacted_override = false; // Deprecated BOOL region_deny_age_unverified_override = false; BOOL region_allow_access_override = true; + BOOL region_allow_environment_override = true; + S32 parcel_environment_version = 0; BOOL agent_parcel_update = false; // updating previous(existing) agent parcel S32 other_clean_time = 0; @@ -1550,6 +1586,12 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use msg->getBOOLFast(_PREHASH_RegionAllowAccessBlock, _PREHASH_RegionAllowAccessOverride, region_allow_access_override); } + if (msg->getNumberOfBlocks(_PREHASH_ParcelEnvironmentBlock)) + { + msg->getS32Fast(_PREHASH_ParcelEnvironmentBlock, _PREHASH_ParcelEnvironmentVersion, parcel_environment_version); + msg->getBOOLFast(_PREHASH_ParcelEnvironmentBlock, _PREHASH_RegionAllowEnvironmentOverride, region_allow_environment_override); + } + msg->getS32("ParcelData", "OtherCleanTime", other_clean_time ); // Actually extract the data. @@ -1567,6 +1609,9 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use } } + S32 cur_parcel_environment_version = parcel->getParcelEnvironmentVersion(); + bool environment_changed = (cur_parcel_environment_version != parcel_environment_version); + parcel->init(owner_id, FALSE, FALSE, FALSE, claim_date, claim_price_per_meter, rent_price_per_meter, @@ -1592,6 +1637,9 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use parcel->setRegionDenyAnonymousOverride(region_deny_anonymous_override); parcel->setRegionDenyAgeUnverifiedOverride(region_deny_age_unverified_override); parcel->setRegionAllowAccessOverride(region_allow_access_override); + parcel->setParcelEnvironmentVersion(cur_parcel_environment_version); + parcel->setRegionAllowEnvironmentOverride(region_allow_environment_override); + parcel->unpackMessage(msg); if (parcel == parcel_mgr.mAgentParcel) @@ -1609,12 +1657,8 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use // Let interesting parties know about agent parcel change. LLViewerParcelMgr* instance = LLViewerParcelMgr::getInstance(); - // Notify anything that wants to know when the agent changes parcels - gAgent.changeParcels(); - if (instance->mTeleportInProgress) { - instance->mTeleportInProgress = FALSE; if(instance->mTeleportInProgressPosition.isNull()) { //initial update @@ -1625,12 +1669,23 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use instance->mTeleportFinishedSignal(instance->mTeleportInProgressPosition, false); } } - } - else if (agent_parcel_update) - { - // updated agent parcel - parcel_mgr.mAgentParcel->unpackMessage(msg); - } + parcel->setParcelEnvironmentVersion(parcel_environment_version); + LL_DEBUGS("ENVIRONMENT") << "Parcel environment version is " << parcel->getParcelEnvironmentVersion() << LL_ENDL; + // Notify anything that wants to know when the agent changes parcels + gAgent.changeParcels(); + instance->mTeleportInProgress = FALSE; + } + else if (agent_parcel_update) + { + parcel->setParcelEnvironmentVersion(parcel_environment_version); + // updated agent parcel + parcel_mgr.mAgentParcel->unpackMessage(msg); + if ((LLEnvironment::instance().isExtendedEnvironmentEnabled() && environment_changed)) + { + LL_DEBUGS("ENVIRONMENT") << "Parcel environment version is " << parcel->getParcelEnvironmentVersion() << LL_ENDL; + LLEnvironment::instance().requestParcel(local_id); + } + } } // Handle updating selections, if necessary. @@ -1811,6 +1866,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use } }//if gAudiop }; + } void LLViewerParcelMgr::optionally_start_music(const std::string& music_url) @@ -2520,3 +2576,9 @@ void LLViewerParcelMgr::onTeleportFailed() { mTeleportFailedSignal(); } + +bool LLViewerParcelMgr::getTeleportInProgress() +{ + return mTeleportInProgress // case where parcel data arrives after teleport + || gAgent.getTeleportState() > LLAgent::TELEPORT_NONE; // For LOCAL, no mTeleportInProgress +} diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index 29219843c9..ec8dde7d40 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -154,6 +154,7 @@ public: //LLParcel *getParcelSelection() const; LLParcel *getAgentParcel() const; + LLParcel *getAgentOrSelectedParcel() const; BOOL inAgentParcel(const LLVector3d &pos_global) const; @@ -262,6 +263,7 @@ public: // accessors for mAgentParcel const std::string& getAgentParcelName() const; + const S32 getAgentParcelId() const; // Create a landmark at the "appropriate" location for the // currently selected parcel. @@ -285,6 +287,7 @@ public: boost::signals2::connection setTeleportFailedCallback(teleport_failed_callback_t cb); void onTeleportFinished(bool local, const LLVector3d& new_pos); void onTeleportFailed(); + bool getTeleportInProgress(); static BOOL isParcelOwnedByAgent(const LLParcel* parcelp, U64 group_proxy_power); static BOOL isParcelModifiableByAgent(const LLParcel* parcelp, U64 group_proxy_power); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 0d7e295b9a..1c4f7c7b4d 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -80,6 +80,7 @@ #include "lleventcoro.h" #include "llcorehttputil.h" #include "llcallstack.h" +#include "llsettingsdaycycle.h" #ifdef LL_WINDOWS #pragma warning(disable:4355) @@ -2894,6 +2895,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("EnvironmentSettings"); capabilityNames.append("EstateChangeInfo"); capabilityNames.append("EventQueueGet"); + capabilityNames.append("ExtEnvironment"); capabilityNames.append("FacebookConnect"); capabilityNames.append("FlickrConnect"); capabilityNames.append("TwitterConnect"); @@ -2918,6 +2920,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("IsExperienceAdmin"); capabilityNames.append("IsExperienceContributor"); capabilityNames.append("RegionExperiences"); + capabilityNames.append("ExperienceQuery"); capabilityNames.append("GetMetadata"); capabilityNames.append("GetObjectCost"); capabilityNames.append("GetObjectPhysicsData"); @@ -2968,7 +2971,9 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("UpdateNotecardTaskInventory"); capabilityNames.append("UpdateScriptAgent"); capabilityNames.append("UpdateScriptTask"); - capabilityNames.append("UploadBakedTexture"); + capabilityNames.append("UpdateSettingsAgentInventory"); + capabilityNames.append("UpdateSettingsTaskInventory"); + capabilityNames.append("UploadBakedTexture"); capabilityNames.append("UserInfo"); capabilityNames.append("ViewerAsset"); capabilityNames.append("ViewerMetrics"); diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index d5266ec873..0e39e9b284 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -131,6 +131,7 @@ public: inline BOOL isPrelude() const; inline BOOL getAllowTerraform() const; inline BOOL getRestrictPushObject() const; + inline BOOL getAllowEnvironmentOverride() const; inline BOOL getReleaseNotesRequested() const; bool isAlive(); // can become false if circuit disconnects @@ -635,6 +636,11 @@ inline BOOL LLViewerRegion::getRestrictPushObject() const return ((mRegionFlags & REGION_FLAGS_RESTRICT_PUSHOBJECT) != 0); } +inline BOOL LLViewerRegion::getAllowEnvironmentOverride() const +{ + return ((mRegionFlags & REGION_FLAGS_ALLOW_ENVIRONMENT_OVERRIDE) != 0); +} + inline BOOL LLViewerRegion::getReleaseNotesRequested() const { return mReleaseNotesRequested; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ff7647a7e4..5f35f71742 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -31,27 +31,24 @@ #include "llfeaturemanager.h" #include "llviewershadermgr.h" - -#include "llfile.h" -#include "llviewerwindow.h" -#include "llwindow.h" #include "llviewercontrol.h" -#include "pipeline.h" + +#include "llrender.h" +#include "llenvironment.h" +#include "llatmosphere.h" #include "llworld.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" #include "llsky.h" #include "llvosky.h" -#include "llrender.h" + +#include "pipeline.h" + +#include "llfile.h" +#include "llviewerwindow.h" +#include "llwindow.h" + #include "lljoint.h" #include "llskinningutil.h" -#ifdef LL_RELEASE_FOR_DOWNLOAD -#define UNIFORM_ERRS LL_WARNS_ONCE("Shader") -#else -#define UNIFORM_ERRS LL_ERRS("Shader") -#endif - static LLStaticHashedString sTexture0("texture0"); static LLStaticHashedString sTexture1("texture1"); static LLStaticHashedString sTex0("tex0"); @@ -154,6 +151,7 @@ LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; LLGLSLShader gTerrainProgram; LLGLSLShader gTerrainWaterProgram; LLGLSLShader gWaterProgram; +LLGLSLShader gWaterEdgeProgram; LLGLSLShader gUnderWaterProgram; //interface shaders @@ -174,7 +172,8 @@ LLGLSLShader gImpostorProgram; // WindLight shader handles LLGLSLShader gWLSkyProgram; LLGLSLShader gWLCloudProgram; - +LLGLSLShader gWLSunProgram; +LLGLSLShader gWLMoonProgram; // Effects Shaders LLGLSLShader gGlowProgram; @@ -196,6 +195,7 @@ LLGLSLShader gDeferredSkinnedBumpProgram; LLGLSLShader gDeferredSkinnedAlphaProgram; LLGLSLShader gDeferredBumpProgram; LLGLSLShader gDeferredTerrainProgram; +LLGLSLShader gDeferredTerrainWaterProgram; LLGLSLShader gDeferredTreeProgram; LLGLSLShader gDeferredTreeShadowProgram; LLGLSLShader gDeferredAvatarProgram; @@ -230,6 +230,8 @@ LLGLSLShader gFXAAProgram; LLGLSLShader gDeferredPostNoDoFProgram; LLGLSLShader gDeferredWLSkyProgram; LLGLSLShader gDeferredWLCloudProgram; +LLGLSLShader gDeferredWLSunProgram; +LLGLSLShader gDeferredWLMoonProgram; LLGLSLShader gDeferredStarProgram; LLGLSLShader gDeferredFullbrightShinyProgram; LLGLSLShader gDeferredSkinnedFullbrightShinyProgram; @@ -241,17 +243,20 @@ LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; LLViewerShaderMgr::LLViewerShaderMgr() : - mVertexShaderLevel(SHADER_COUNT, 0), + mShaderLevel(SHADER_COUNT, 0), mMaxAvatarShaderLevel(0) -{ - /// Make sure WL Sky is the first program - //ONLY shaders that need WL Param management should be added here +{ + /// Make sure WL Sky is the first program + //ONLY shaders that need WL Param management should be added here mShaderList.push_back(&gWLSkyProgram); mShaderList.push_back(&gWLCloudProgram); + mShaderList.push_back(&gWLSunProgram); + mShaderList.push_back(&gWLMoonProgram); mShaderList.push_back(&gAvatarProgram); mShaderList.push_back(&gObjectShinyProgram); mShaderList.push_back(&gObjectShinyNonIndexedProgram); mShaderList.push_back(&gWaterProgram); + mShaderList.push_back(&gWaterEdgeProgram); mShaderList.push_back(&gAvatarEyeballProgram); mShaderList.push_back(&gObjectSimpleProgram); mShaderList.push_back(&gObjectSimpleImpostorProgram); @@ -306,22 +311,6 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredSunProgram); mShaderList.push_back(&gDeferredSoftenProgram); mShaderList.push_back(&gDeferredSoftenWaterProgram); - mShaderList.push_back(&gDeferredMaterialProgram[1]); - mShaderList.push_back(&gDeferredMaterialProgram[5]); - mShaderList.push_back(&gDeferredMaterialProgram[9]); - mShaderList.push_back(&gDeferredMaterialProgram[13]); - mShaderList.push_back(&gDeferredMaterialProgram[1+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialProgram[5+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialProgram[9+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialProgram[13+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[1]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[5]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[9]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[13]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[1+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[5+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[9+LLMaterial::SHADER_COUNT]); - mShaderList.push_back(&gDeferredMaterialWaterProgram[13+LLMaterial::SHADER_COUNT]); mShaderList.push_back(&gDeferredAlphaProgram); mShaderList.push_back(&gDeferredAlphaImpostorProgram); mShaderList.push_back(&gDeferredAlphaWaterProgram); @@ -337,14 +326,17 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredAvatarEyesProgram); mShaderList.push_back(&gDeferredWaterProgram); mShaderList.push_back(&gDeferredUnderWaterProgram); + mShaderList.push_back(&gDeferredTerrainWaterProgram); mShaderList.push_back(&gDeferredAvatarAlphaProgram); mShaderList.push_back(&gDeferredWLSkyProgram); mShaderList.push_back(&gDeferredWLCloudProgram); + mShaderList.push_back(&gDeferredWLMoonProgram); + mShaderList.push_back(&gDeferredWLSunProgram); } LLViewerShaderMgr::~LLViewerShaderMgr() { - mVertexShaderLevel.clear(); + mShaderLevel.clear(); mShaderList.clear(); } @@ -381,9 +373,9 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) //============================================================================ // Set Levels -S32 LLViewerShaderMgr::getVertexShaderLevel(S32 type) +S32 LLViewerShaderMgr::getShaderLevel(S32 type) { - return LLPipeline::sDisableShaders ? 0 : mVertexShaderLevel[type]; + return LLPipeline::sDisableShaders ? 0 : mShaderLevel[type]; } //============================================================================ @@ -458,7 +450,7 @@ void LLViewerShaderMgr::setShaders() for (S32 i = 0; i < SHADER_COUNT; i++) { - mVertexShaderLevel[i] = 0; + mShaderLevel[i] = 0; } mMaxAvatarShaderLevel = 0; @@ -467,7 +459,13 @@ void LLViewerShaderMgr::setShaders() if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") && (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 10) && gSavedSettings.getBOOL("VertexShaderEnable")) - { + { + bool canRenderDeferred = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"); + bool hasWindLightShaders = LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"); + S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail"); + bool useRenderDeferred = canRenderDeferred && gSavedSettings.getBOOL("RenderDeferred") && gSavedSettings.getBOOL("RenderAvatarVP"); + bool doingWindLight = hasWindLightShaders && gSavedSettings.getBOOL("WindLightUseAtmosShaders"); + //using shaders, disable fixed function LLGLSLShader::sNoFixedFunction = true; @@ -485,57 +483,61 @@ void LLViewerShaderMgr::setShaders() { transform_class = 0; } - - if (LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && - gSavedSettings.getBOOL("RenderDeferred") && - gSavedSettings.getBOOL("RenderAvatarVP") && - gSavedSettings.getBOOL("WindLightUseAtmosShaders")) - { - if (gSavedSettings.getS32("RenderShadowDetail") > 0) - { //shadows - deferred_class = 2; - } - else - { //no shadows - deferred_class = 1; - } - - //make sure hardware skinning is enabled - //gSavedSettings.setBOOL("RenderAvatarVP", TRUE); - - //make sure atmospheric shaders are enabled - //gSavedSettings.setBOOL("WindLightUseAtmosShaders", TRUE); - } - - if (!(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders") - && gSavedSettings.getBOOL("WindLightUseAtmosShaders"))) - { - // user has disabled WindLight in their settings, downgrade - // windlight shaders to stub versions. - wl_class = 1; - } + if (useRenderDeferred) + { + //shadows + switch (shadow_detail) + { + case 1: + deferred_class = 2; // PCF shadows + break; + + case 2: + deferred_class = 2; // PCF shadows + break; + + case 0: + default: + deferred_class = 1; // no shadows + break; + } + } + + if (doingWindLight) + { + // user has disabled WindLight in their settings, downgrade + // windlight shaders to stub versions. + wl_class = 2; + } - // Trigger a full rebuild of the fallback skybox / cubemap if we've toggled windlight shaders - if (mVertexShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull()) + if (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull()) { gSky.mVOSkyp->forceSkyUpdate(); } - // Load lighting shaders - mVertexShaderLevel[SHADER_LIGHTING] = light_class; - mVertexShaderLevel[SHADER_INTERFACE] = light_class; - mVertexShaderLevel[SHADER_ENVIRONMENT] = env_class; - mVertexShaderLevel[SHADER_WATER] = water_class; - mVertexShaderLevel[SHADER_OBJECT] = obj_class; - mVertexShaderLevel[SHADER_EFFECT] = effect_class; - mVertexShaderLevel[SHADER_WINDLIGHT] = wl_class; - mVertexShaderLevel[SHADER_DEFERRED] = deferred_class; - mVertexShaderLevel[SHADER_TRANSFORM] = transform_class; - - BOOL loaded = loadBasicShaders(); + mShaderLevel[SHADER_LIGHTING] = light_class; + mShaderLevel[SHADER_INTERFACE] = light_class; + mShaderLevel[SHADER_ENVIRONMENT] = env_class; + mShaderLevel[SHADER_WATER] = water_class; + mShaderLevel[SHADER_OBJECT] = obj_class; + mShaderLevel[SHADER_EFFECT] = effect_class; + mShaderLevel[SHADER_WINDLIGHT] = wl_class; + mShaderLevel[SHADER_DEFERRED] = deferred_class; + mShaderLevel[SHADER_TRANSFORM] = transform_class; + + BOOL loaded = loadBasicShaders(); + if (loaded) + { + LL_INFOS() << "Loaded basic shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load basic shaders." << LL_ENDL; + llassert(loaded); + } if (loaded) { @@ -547,147 +549,207 @@ void LLViewerShaderMgr::setShaders() if (loaded) { - loaded = loadShadersWater(); + LL_INFOS() << "Loaded environment shaders." << LL_ENDL; } - - if (loaded) + else { - loaded = loadShadersWindLight(); + LL_WARNS() << "Failed to load environment shaders." << LL_ENDL; + llassert(loaded); } if (loaded) { - loaded = loadShadersEffects(); + loaded = loadShadersWater(); + if (loaded) + { + LL_INFOS() << "Loaded water shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load water shaders." << LL_ENDL; + llassert(loaded); + } } if (loaded) { - loaded = loadShadersInterface(); + loaded = loadShadersWindLight(); + if (loaded) + { + LL_INFOS() << "Loaded windlight shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load windlight shaders." << LL_ENDL; + llassert(loaded); + } } if (loaded) - - { - loaded = loadTransformShaders(); + { + loaded = loadShadersEffects(); + if (loaded) + { + LL_INFOS() << "Loaded effects shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load effects shaders." << LL_ENDL; + llassert(loaded); + } } if (loaded) { - // Load max avatar shaders to set the max level - mVertexShaderLevel[SHADER_AVATAR] = 3; - mMaxAvatarShaderLevel = 3; - - if (gSavedSettings.getBOOL("RenderAvatarVP") && loadShadersObject()) - { //hardware skinning is enabled and rigged attachment shaders loaded correctly - BOOL avatar_cloth = gSavedSettings.getBOOL("RenderAvatarCloth"); - S32 avatar_class = 1; - - // cloth is a class3 shader - if(avatar_cloth) - { - avatar_class = 3; - } - - // Set the actual level - mVertexShaderLevel[SHADER_AVATAR] = avatar_class; - loadShadersAvatar(); - if (mVertexShaderLevel[SHADER_AVATAR] != avatar_class) - { - if (mVertexShaderLevel[SHADER_AVATAR] == 0) - { - gSavedSettings.setBOOL("RenderAvatarVP", FALSE); - } - if(llmax(mVertexShaderLevel[SHADER_AVATAR]-1,0) >= 3) - { - avatar_cloth = true; - } - else - { - avatar_cloth = false; - } - gSavedSettings.setBOOL("RenderAvatarCloth", avatar_cloth); - } + loaded = loadShadersInterface(); + if (loaded) + { + LL_INFOS() << "Loaded interface shaders." << LL_ENDL; } else - { //hardware skinning not possible, neither is deferred rendering - mVertexShaderLevel[SHADER_AVATAR] = 0; - mVertexShaderLevel[SHADER_DEFERRED] = 0; - - if (gSavedSettings.getBOOL("RenderAvatarVP")) - { - gSavedSettings.setBOOL("RenderDeferred", FALSE); - gSavedSettings.setBOOL("RenderAvatarCloth", FALSE); - gSavedSettings.setBOOL("RenderAvatarVP", FALSE); - } - - loadShadersAvatar(); // unloads - - loaded = loadShadersObject(); + { + LL_WARNS() << "Failed to load interface shaders." << LL_ENDL; + llassert(loaded); } } - if (!loaded) - { //some shader absolutely could not load, try to fall back to a simpler setting - if (gSavedSettings.getBOOL("WindLightUseAtmosShaders")) - { //disable windlight and try again - gSavedSettings.setBOOL("WindLightUseAtmosShaders", FALSE); - reentrance = false; - setShaders(); - return; - } + if (loaded) - if (gSavedSettings.getBOOL("VertexShaderEnable")) - { //disable shaders outright and try again - gSavedSettings.setBOOL("VertexShaderEnable", FALSE); - reentrance = false; - setShaders(); - return; - } - } - - if (loaded && !loadShadersDeferred()) - { //everything else succeeded but deferred failed, disable deferred and try again - gSavedSettings.setBOOL("RenderDeferred", FALSE); - reentrance = false; - setShaders(); - return; - } - } - else - { - LLGLSLShader::sNoFixedFunction = false; - gPipeline.mVertexShadersEnabled = FALSE; - gPipeline.mVertexShadersLoaded = 0; - mVertexShaderLevel[SHADER_LIGHTING] = 0; - mVertexShaderLevel[SHADER_INTERFACE] = 0; - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mVertexShaderLevel[SHADER_WATER] = 0; - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_EFFECT] = 0; - mVertexShaderLevel[SHADER_WINDLIGHT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = 0; - } - } - else - { - LLGLSLShader::sNoFixedFunction = false; - gPipeline.mVertexShadersEnabled = FALSE; - gPipeline.mVertexShadersLoaded = 0; - mVertexShaderLevel[SHADER_LIGHTING] = 0; - mVertexShaderLevel[SHADER_INTERFACE] = 0; - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mVertexShaderLevel[SHADER_WATER] = 0; - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_EFFECT] = 0; - mVertexShaderLevel[SHADER_WINDLIGHT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = 0; - } - - if (gViewerWindow) - { - gViewerWindow->setCursor(UI_CURSOR_ARROW); - } - gPipeline.createGLBuffers(); + { + loaded = loadTransformShaders(); + if (loaded) + { + LL_INFOS() << "Loaded transform shaders." << LL_ENDL; + } + else + { + LL_WARNS() << "Failed to load transform shaders." << LL_ENDL; + llassert(loaded); + } + } + + if (loaded) + { + // Load max avatar shaders to set the max level + mShaderLevel[SHADER_AVATAR] = 3; + mMaxAvatarShaderLevel = 3; + + if (gSavedSettings.getBOOL("RenderAvatarVP") && loadShadersObject()) + { //hardware skinning is enabled and rigged attachment shaders loaded correctly + BOOL avatar_cloth = gSavedSettings.getBOOL("RenderAvatarCloth"); + + // cloth is a class3 shader + S32 avatar_class = avatar_cloth ? 3 : 1; + + // Set the actual level + mShaderLevel[SHADER_AVATAR] = avatar_class; + + loaded = loadShadersAvatar(); + llassert(loaded); + + if (mShaderLevel[SHADER_AVATAR] != avatar_class) + { + if (mShaderLevel[SHADER_AVATAR] == 0) + { + gSavedSettings.setBOOL("RenderAvatarVP", FALSE); + } + if(llmax(mShaderLevel[SHADER_AVATAR]-1,0) >= 3) + { + avatar_cloth = true; + } + else + { + avatar_cloth = false; + } + gSavedSettings.setBOOL("RenderAvatarCloth", avatar_cloth); + } + } + else + { //hardware skinning not possible, neither is deferred rendering + mShaderLevel[SHADER_AVATAR] = 0; + mShaderLevel[SHADER_DEFERRED] = 0; + + if (gSavedSettings.getBOOL("RenderAvatarVP")) + { + gSavedSettings.setBOOL("RenderDeferred", FALSE); + gSavedSettings.setBOOL("RenderAvatarCloth", FALSE); + gSavedSettings.setBOOL("RenderAvatarVP", FALSE); + } + + loadShadersAvatar(); // unloads + + loaded = loadShadersObject(); + llassert(loaded); + } + } + + if (!loaded) + { //some shader absolutely could not load, try to fall back to a simpler setting + if (gSavedSettings.getBOOL("WindLightUseAtmosShaders")) + { //disable windlight and try again + gSavedSettings.setBOOL("WindLightUseAtmosShaders", FALSE); + LL_WARNS() << "Falling back to no windlight shaders." << LL_ENDL; + reentrance = false; + setShaders(); + return; + } + + if (gSavedSettings.getBOOL("VertexShaderEnable")) + { //disable shaders outright and try again + gSavedSettings.setBOOL("VertexShaderEnable", FALSE); + LL_WARNS() << "Falling back to no vertex shaders." << LL_ENDL; + reentrance = false; + setShaders(); + return; + } + } + + llassert(loaded); + + if (loaded && !loadShadersDeferred()) + { //everything else succeeded but deferred failed, disable deferred and try again + gSavedSettings.setBOOL("RenderDeferred", FALSE); + LL_WARNS() << "Falling back to no deferred shaders." << LL_ENDL; + reentrance = false; + setShaders(); + return; + } + } + else + { + LLGLSLShader::sNoFixedFunction = false; + gPipeline.mVertexShadersEnabled = FALSE; + gPipeline.mVertexShadersLoaded = 0; + mShaderLevel[SHADER_LIGHTING] = 0; + mShaderLevel[SHADER_INTERFACE] = 0; + mShaderLevel[SHADER_ENVIRONMENT] = 0; + mShaderLevel[SHADER_WATER] = 0; + mShaderLevel[SHADER_OBJECT] = 0; + mShaderLevel[SHADER_EFFECT] = 0; + mShaderLevel[SHADER_WINDLIGHT] = 0; + mShaderLevel[SHADER_AVATAR] = 0; + } + } + else + { + LLGLSLShader::sNoFixedFunction = false; + gPipeline.mVertexShadersEnabled = FALSE; + gPipeline.mVertexShadersLoaded = 0; + mShaderLevel[SHADER_LIGHTING] = 0; + mShaderLevel[SHADER_INTERFACE] = 0; + mShaderLevel[SHADER_ENVIRONMENT] = 0; + mShaderLevel[SHADER_WATER] = 0; + mShaderLevel[SHADER_OBJECT] = 0; + mShaderLevel[SHADER_EFFECT] = 0; + mShaderLevel[SHADER_WINDLIGHT] = 0; + mShaderLevel[SHADER_AVATAR] = 0; + } + + if (gViewerWindow) + { + gViewerWindow->setCursor(UI_CURSOR_ARROW); + } + gPipeline.createGLBuffers(); reentrance = false; } @@ -771,6 +833,7 @@ void LLViewerShaderMgr::unloadShaders() gWaterProgram.unload(); + gWaterEdgeProgram.unload(); gUnderWaterProgram.unload(); gTerrainProgram.unload(); gTerrainWaterProgram.unload(); @@ -786,6 +849,8 @@ void LLViewerShaderMgr::unloadShaders() gWLSkyProgram.unload(); gWLCloudProgram.unload(); + gWLSunProgram.unload(); + gWLMoonProgram.unload(); gPostColorFilterProgram.unload(); gPostNightVisionProgram.unload(); @@ -805,15 +870,15 @@ void LLViewerShaderMgr::unloadShaders() gTransformColorProgram.unload(); gTransformTangentProgram.unload(); - mVertexShaderLevel[SHADER_LIGHTING] = 0; - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = 0; - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mVertexShaderLevel[SHADER_WATER] = 0; - mVertexShaderLevel[SHADER_INTERFACE] = 0; - mVertexShaderLevel[SHADER_EFFECT] = 0; - mVertexShaderLevel[SHADER_WINDLIGHT] = 0; - mVertexShaderLevel[SHADER_TRANSFORM] = 0; + mShaderLevel[SHADER_LIGHTING] = 0; + mShaderLevel[SHADER_OBJECT] = 0; + mShaderLevel[SHADER_AVATAR] = 0; + mShaderLevel[SHADER_ENVIRONMENT] = 0; + mShaderLevel[SHADER_WATER] = 0; + mShaderLevel[SHADER_INTERFACE] = 0; + mShaderLevel[SHADER_EFFECT] = 0; + mShaderLevel[SHADER_WINDLIGHT] = 0; + mShaderLevel[SHADER_TRANSFORM] = 0; gPipeline.mVertexShadersLoaded = 0; } @@ -856,23 +921,23 @@ BOOL LLViewerShaderMgr::loadBasicShaders() // (in order of shader function call depth for reference purposes, deepest level first) vector< pair<string, S32> > shaders; - shaders.push_back( make_pair( "windlight/atmosphericsVarsV.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterV.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "windlight/atmosphericsHelpersV.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "lighting/lightFuncV.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/sumLightsV.glsl", sum_lights_class ) ); - shaders.push_back( make_pair( "lighting/lightV.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/lightFuncSpecularV.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "lighting/sumLightsSpecularV.glsl", sum_lights_class ) ); - shaders.push_back( make_pair( "lighting/lightSpecularV.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - shaders.push_back( make_pair( "windlight/atmosphericsV.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "avatar/avatarSkinV.glsl", 1 ) ); - shaders.push_back( make_pair( "avatar/objectSkinV.glsl", 1 ) ); + shaders.push_back( make_pair( "windlight/atmosphericsVarsV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + shaders.push_back( make_pair( "windlight/atmosphericsHelpersV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + shaders.push_back( make_pair( "lighting/lightFuncV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + shaders.push_back( make_pair( "lighting/sumLightsV.glsl", sum_lights_class ) ); + shaders.push_back( make_pair( "lighting/lightV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + shaders.push_back( make_pair( "lighting/lightFuncSpecularV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + shaders.push_back( make_pair( "lighting/sumLightsSpecularV.glsl", sum_lights_class ) ); + shaders.push_back( make_pair( "lighting/lightSpecularV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + shaders.push_back( make_pair( "windlight/atmosphericsV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + shaders.push_back( make_pair( "avatar/avatarSkinV.glsl", 1 ) ); + shaders.push_back( make_pair( "avatar/objectSkinV.glsl", 1 ) ); if (gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30) { - shaders.push_back( make_pair( "objects/indexedTextureV.glsl", 1 ) ); + shaders.push_back( make_pair( "objects/indexedTextureV.glsl", 1 ) ); } - shaders.push_back( make_pair( "objects/nonindexedTextureV.glsl", 1 ) ); + shaders.push_back( make_pair( "objects/nonindexedTextureV.glsl", 1 ) ); boost::unordered_map<std::string, std::string> attribs; attribs["MAX_JOINTS_PER_MESH_OBJECT"] = @@ -884,6 +949,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() // Note usage of GL_VERTEX_SHADER_ARB if (loadShaderFile(shaders[i].first, shaders[i].second, GL_VERTEX_SHADER_ARB, &attribs) == 0) { + LL_SHADER_LOADING_WARNS() << "Failed to load vertex shader " << shaders[i].first << LL_ENDL; return FALSE; } } @@ -899,43 +965,50 @@ BOOL LLViewerShaderMgr::loadBasicShaders() ch = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); } - std::vector<S32> index_channels; - index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/gammaF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT]) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/transportF.glsl", mVertexShaderLevel[SHADER_WINDLIGHT] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "environment/waterFogF.glsl", mVertexShaderLevel[SHADER_WATER] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightShinyNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightShinyNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightShinyWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterNonIndexedF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mVertexShaderLevel[SHADER_LIGHTING] ) ); - + std::vector<S32> index_channels; + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsHelpersF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/gammaF.glsl", mShaderLevel[SHADER_WINDLIGHT]) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/transportF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "environment/waterFogF.glsl", mShaderLevel[SHADER_WATER] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "environment/encodeNormF.glsl", mShaderLevel[SHADER_ENVIRONMENT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "environment/srgbF.glsl", mShaderLevel[SHADER_ENVIRONMENT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/deferredUtil.glsl", 1) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/shadowUtil.glsl", 1) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/aoUtil.glsl", 1) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightShinyNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightShinyNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightShinyWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + for (U32 i = 0; i < shaders.size(); i++) { // Note usage of GL_FRAGMENT_SHADER_ARB if (loadShaderFile(shaders[i].first, shaders[i].second, GL_FRAGMENT_SHADER_ARB, &attribs, index_channels[i]) == 0) { + LL_SHADER_LOADING_WARNS() << "Failed to load fragment shader " << shaders[i].first << LL_ENDL; return FALSE; } } @@ -947,7 +1020,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() { BOOL success = TRUE; - if (mVertexShaderLevel[SHADER_ENVIRONMENT] == 0) + if (mShaderLevel[SHADER_ENVIRONMENT] == 0) { gTerrainProgram.unload(); return TRUE; @@ -959,19 +1032,23 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gTerrainProgram.mFeatures.calculatesLighting = true; gTerrainProgram.mFeatures.calculatesAtmospherics = true; gTerrainProgram.mFeatures.hasAtmospherics = true; + gTerrainProgram.mFeatures.hasTransport = true; + gTerrainProgram.mFeatures.hasGamma = true; + gTerrainProgram.mFeatures.hasSrgb = true; gTerrainProgram.mFeatures.mIndexedTextureChannels = 0; gTerrainProgram.mFeatures.disableTextureIndex = true; gTerrainProgram.mFeatures.hasGamma = true; - gTerrainProgram.mShaderFiles.clear(); - gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainV.glsl", GL_VERTEX_SHADER_ARB)); - gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainF.glsl", GL_FRAGMENT_SHADER_ARB)); - gTerrainProgram.mShaderLevel = mVertexShaderLevel[SHADER_ENVIRONMENT]; - success = gTerrainProgram.createShader(NULL, NULL); + gTerrainProgram.mShaderFiles.clear(); + gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainV.glsl", GL_VERTEX_SHADER_ARB)); + gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainF.glsl", GL_FRAGMENT_SHADER_ARB)); + gTerrainProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gTerrainProgram.createShader(NULL, NULL); + llassert(success); } if (!success) { - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; + mShaderLevel[SHADER_ENVIRONMENT] = 0; return FALSE; } @@ -985,9 +1062,10 @@ BOOL LLViewerShaderMgr::loadShadersWater() BOOL success = TRUE; BOOL terrainWaterSuccess = TRUE; - if (mVertexShaderLevel[SHADER_WATER] == 0) + if (mShaderLevel[SHADER_WATER] == 0) { gWaterProgram.unload(); + gWaterEdgeProgram.unload(); gUnderWaterProgram.unload(); gTerrainWaterProgram.unload(); return TRUE; @@ -1003,8 +1081,27 @@ BOOL LLViewerShaderMgr::loadShadersWater() gWaterProgram.mShaderFiles.clear(); gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB)); gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER]; + gWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gWaterProgram.mShaderLevel = mShaderLevel[SHADER_WATER]; success = gWaterProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + // load water shader + gWaterEdgeProgram.mName = "Water Edge Shader"; + gWaterEdgeProgram.mFeatures.calculatesAtmospherics = true; + gWaterEdgeProgram.mFeatures.hasGamma = true; + gWaterEdgeProgram.mFeatures.hasTransport = true; + gWaterEdgeProgram.mShaderFiles.clear(); + gWaterEdgeProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB)); + gWaterEdgeProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gWaterEdgeProgram.addPermutation("WATER_EDGE", "1"); + gWaterEdgeProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gWaterEdgeProgram.mShaderLevel = mShaderLevel[SHADER_WATER]; + success = gWaterEdgeProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1012,13 +1109,14 @@ BOOL LLViewerShaderMgr::loadShadersWater() //load under water vertex shader gUnderWaterProgram.mName = "Underwater Shader"; gUnderWaterProgram.mFeatures.calculatesAtmospherics = true; + gUnderWaterProgram.mFeatures.hasWaterFog = true; gUnderWaterProgram.mShaderFiles.clear(); gUnderWaterProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB)); gUnderWaterProgram.mShaderFiles.push_back(make_pair("environment/underWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER]; - gUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; - + gUnderWaterProgram.mShaderLevel = mShaderLevel[SHADER_WATER]; + gUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gUnderWaterProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1034,29 +1132,30 @@ BOOL LLViewerShaderMgr::loadShadersWater() gTerrainWaterProgram.mShaderFiles.clear(); gTerrainWaterProgram.mShaderFiles.push_back(make_pair("environment/terrainV.glsl", GL_VERTEX_SHADER_ARB)); gTerrainWaterProgram.mShaderFiles.push_back(make_pair("environment/terrainWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gTerrainWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_ENVIRONMENT]; + gTerrainWaterProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; gTerrainWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; terrainWaterSuccess = gTerrainWaterProgram.createShader(NULL, NULL); + llassert(terrainWaterSuccess); } /// Keep track of water shader levels - if (gWaterProgram.mShaderLevel != mVertexShaderLevel[SHADER_WATER] - || gUnderWaterProgram.mShaderLevel != mVertexShaderLevel[SHADER_WATER]) + if (gWaterProgram.mShaderLevel != mShaderLevel[SHADER_WATER] + || gUnderWaterProgram.mShaderLevel != mShaderLevel[SHADER_WATER]) { - mVertexShaderLevel[SHADER_WATER] = llmin(gWaterProgram.mShaderLevel, gUnderWaterProgram.mShaderLevel); + mShaderLevel[SHADER_WATER] = llmin(gWaterProgram.mShaderLevel, gUnderWaterProgram.mShaderLevel); } if (!success) { - mVertexShaderLevel[SHADER_WATER] = 0; + mShaderLevel[SHADER_WATER] = 0; return FALSE; } // if we failed to load the terrain water shaders and we need them (using class2 water), // then drop down to class1 water. - if (mVertexShaderLevel[SHADER_WATER] > 1 && !terrainWaterSuccess) + if (mShaderLevel[SHADER_WATER] > 1 && !terrainWaterSuccess) { - mVertexShaderLevel[SHADER_WATER]--; + mShaderLevel[SHADER_WATER]--; return loadShadersWater(); } @@ -1069,7 +1168,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() { BOOL success = TRUE; - if (mVertexShaderLevel[SHADER_EFFECT] == 0) + if (mShaderLevel[SHADER_EFFECT] == 0) { gGlowProgram.unload(); gGlowExtractProgram.unload(); @@ -1084,7 +1183,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() gGlowProgram.mShaderFiles.clear(); gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowV.glsl", GL_VERTEX_SHADER_ARB)); gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowF.glsl", GL_FRAGMENT_SHADER_ARB)); - gGlowProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; + gGlowProgram.mShaderLevel = mShaderLevel[SHADER_EFFECT]; success = gGlowProgram.createShader(NULL, NULL); if (!success) { @@ -1098,7 +1197,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() gGlowExtractProgram.mShaderFiles.clear(); gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractV.glsl", GL_VERTEX_SHADER_ARB)); gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractF.glsl", GL_FRAGMENT_SHADER_ARB)); - gGlowExtractProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; + gGlowExtractProgram.mShaderLevel = mShaderLevel[SHADER_EFFECT]; success = gGlowExtractProgram.createShader(NULL, NULL); if (!success) { @@ -1112,7 +1211,9 @@ BOOL LLViewerShaderMgr::loadShadersEffects() BOOL LLViewerShaderMgr::loadShadersDeferred() { - if (mVertexShaderLevel[SHADER_DEFERRED] == 0) + bool use_sun_shadow = mShaderLevel[SHADER_DEFERRED] > 1; + + if (mShaderLevel[SHADER_DEFERRED] == 0) { gDeferredTreeProgram.unload(); gDeferredTreeShadowProgram.unload(); @@ -1127,6 +1228,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredBumpProgram.unload(); gDeferredImpostorProgram.unload(); gDeferredTerrainProgram.unload(); + gDeferredTerrainWaterProgram.unload(); gDeferredLightProgram.unload(); for (U32 i = 0; i < LL_DEFERRED_MULTI_LIGHT_COUNT; ++i) { @@ -1162,6 +1264,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredUnderWaterProgram.unload(); gDeferredWLSkyProgram.unload(); gDeferredWLCloudProgram.unload(); + gDeferredWLSunProgram.unload(); + gDeferredWLMoonProgram.unload(); gDeferredStarProgram.unload(); gDeferredFullbrightShinyProgram.unload(); gDeferredSkinnedFullbrightShinyProgram.unload(); @@ -1181,76 +1285,87 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredDiffuseProgram.mName = "Deferred Diffuse Shader"; + gDeferredDiffuseProgram.mFeatures.encodesNormal = true; gDeferredDiffuseProgram.mShaderFiles.clear(); gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredDiffuseProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - gDeferredDiffuseProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredDiffuseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredDiffuseProgram.createShader(NULL, NULL); } if (success) { gDeferredDiffuseAlphaMaskProgram.mName = "Deferred Diffuse Alpha Mask Shader"; + gDeferredDiffuseAlphaMaskProgram.mFeatures.encodesNormal = true; gDeferredDiffuseAlphaMaskProgram.mShaderFiles.clear(); gDeferredDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredDiffuseAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - gDeferredDiffuseAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredDiffuseAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredDiffuseAlphaMaskProgram.createShader(NULL, NULL); } if (success) { gDeferredNonIndexedDiffuseAlphaMaskProgram.mName = "Deferred Diffuse Non-Indexed Alpha Mask Shader"; + gDeferredNonIndexedDiffuseAlphaMaskProgram.mFeatures.encodesNormal = true; gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.clear(); gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredNonIndexedDiffuseAlphaMaskProgram.createShader(NULL, NULL); + llassert(success); } - + if (success) { gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mName = "Deferred Diffuse Non-Indexed Alpha Mask Shader"; + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mFeatures.encodesNormal = true; gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.clear(); gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("deferred/diffuseNoColorV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskNoColorF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredNonIndexedDiffuseProgram.mName = "Non Indexed Deferred Diffuse Shader"; gDeferredNonIndexedDiffuseProgram.mShaderFiles.clear(); + gDeferredNonIndexedDiffuseProgram.mFeatures.encodesNormal = true; gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredNonIndexedDiffuseProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredNonIndexedDiffuseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredNonIndexedDiffuseProgram.createShader(NULL, NULL); + llassert(success); } - if (success) { gDeferredSkinnedDiffuseProgram.mName = "Deferred Skinned Diffuse Shader"; gDeferredSkinnedDiffuseProgram.mFeatures.hasObjectSkinning = true; + gDeferredSkinnedDiffuseProgram.mFeatures.encodesNormal = true; gDeferredSkinnedDiffuseProgram.mShaderFiles.clear(); gDeferredSkinnedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSkinnedDiffuseProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSkinnedDiffuseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredSkinnedDiffuseProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredSkinnedBumpProgram.mName = "Deferred Skinned Bump Shader"; gDeferredSkinnedBumpProgram.mFeatures.hasObjectSkinning = true; + gDeferredSkinnedBumpProgram.mFeatures.encodesNormal = true; gDeferredSkinnedBumpProgram.mShaderFiles.clear(); gDeferredSkinnedBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSkinnedBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSkinnedBumpProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredSkinnedBumpProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1261,16 +1376,30 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = false; gDeferredSkinnedAlphaProgram.mFeatures.isAlphaLighting = true; gDeferredSkinnedAlphaProgram.mFeatures.disableTextureIndex = true; + gDeferredSkinnedAlphaProgram.mFeatures.hasSrgb = true; + gDeferredSkinnedAlphaProgram.mFeatures.encodesNormal = true; + gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true; + gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true; + gDeferredSkinnedAlphaProgram.mFeatures.hasTransport = true; + gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true; + gDeferredSkinnedAlphaProgram.mFeatures.hasShadows = true; + gDeferredSkinnedAlphaProgram.mShaderFiles.clear(); gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSkinnedAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSkinnedAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + gDeferredSkinnedAlphaProgram.clearPermutations(); gDeferredSkinnedAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1"); gDeferredSkinnedAlphaProgram.addPermutation("HAS_SKIN", "1"); gDeferredSkinnedAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); - gDeferredSkinnedAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); + if (use_sun_shadow) + { + gDeferredSkinnedAlphaProgram.addPermutation("HAS_SHADOW", "1"); + } success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL); - + llassert(success); + // Hack to include uniforms for lighting without linking in lighting file gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = true; gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = true; @@ -1279,11 +1408,13 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredBumpProgram.mName = "Deferred Bump Shader"; + gDeferredBumpProgram.mFeatures.encodesNormal = true; gDeferredBumpProgram.mShaderFiles.clear(); gDeferredBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredBumpProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredBumpProgram.createShader(NULL, NULL); + llassert(success); } gDeferredMaterialProgram[1].mFeatures.hasLighting = false; @@ -1308,6 +1439,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { if (success) { + mShaderList.push_back(&gDeferredMaterialProgram[i]); + gDeferredMaterialProgram[i].mName = llformat("Deferred Material Shader %d", i); U32 alpha_mode = i & 0x3; @@ -1315,48 +1448,108 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialProgram[i].mShaderFiles.clear(); gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMaterialProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredMaterialProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - gDeferredMaterialProgram[i].addPermutation("HAS_NORMAL_MAP", i & 0x8? "1" : "0"); - gDeferredMaterialProgram[i].addPermutation("HAS_SPECULAR_MAP", i & 0x4 ? "1" : "0"); - gDeferredMaterialProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); - gDeferredMaterialProgram[i].addPermutation("HAS_SUN_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); - bool has_skin = i & 0x10; - gDeferredMaterialProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0"); - - if (has_skin) - { - gDeferredMaterialProgram[i].mFeatures.hasObjectSkinning = true; - } + gDeferredMaterialProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - success = gDeferredMaterialProgram[i].createShader(NULL, NULL); - } + gDeferredMaterialProgram[i].clearPermutations(); - if (success) - { - gDeferredMaterialWaterProgram[i].mName = llformat("Deferred Underwater Material Shader %d", i); + bool has_normal_map = (i & 0x8) > 0; + bool has_specular_map = (i & 0x4) > 0; - U32 alpha_mode = i & 0x3; + if (has_normal_map) + { + gDeferredMaterialProgram[i].addPermutation("HAS_NORMAL_MAP", "1"); + } - gDeferredMaterialWaterProgram[i].mShaderFiles.clear(); - gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredMaterialWaterProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - gDeferredMaterialWaterProgram[i].mShaderGroup = LLGLSLShader::SG_WATER; - - gDeferredMaterialWaterProgram[i].addPermutation("HAS_NORMAL_MAP", i & 0x8? "1" : "0"); - gDeferredMaterialWaterProgram[i].addPermutation("HAS_SPECULAR_MAP", i & 0x4 ? "1" : "0"); - gDeferredMaterialWaterProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); - gDeferredMaterialWaterProgram[i].addPermutation("HAS_SUN_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); - bool has_skin = i & 0x10; - gDeferredMaterialWaterProgram[i].addPermutation("HAS_SKIN",has_skin ? "1" : "0"); - gDeferredMaterialWaterProgram[i].addPermutation("WATER_FOG","1"); - - if (has_skin) + if (has_specular_map) { - gDeferredMaterialWaterProgram[i].mFeatures.hasObjectSkinning = true; + gDeferredMaterialProgram[i].addPermutation("HAS_SPECULAR_MAP", "1"); } - success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL);//&mWLUniforms); + gDeferredMaterialProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); + + if (use_sun_shadow) + { + gDeferredMaterialProgram[i].addPermutation("HAS_SUN_SHADOW", "1"); + } + + bool has_skin = i & 0x10; + gDeferredMaterialProgram[i].mFeatures.hasSrgb = true; + gDeferredMaterialProgram[i].mFeatures.hasTransport = true; + gDeferredMaterialProgram[i].mFeatures.encodesNormal = true; + gDeferredMaterialProgram[i].mFeatures.calculatesAtmospherics = true; + gDeferredMaterialProgram[i].mFeatures.hasAtmospherics = true; + gDeferredMaterialProgram[i].mFeatures.hasGamma = true; + gDeferredMaterialProgram[i].mFeatures.hasShadows = use_sun_shadow; + + if (has_skin) + { + gDeferredMaterialProgram[i].addPermutation("HAS_SKIN", "1"); + gDeferredMaterialProgram[i].mFeatures.hasObjectSkinning = true; + } + + success = gDeferredMaterialProgram[i].createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + mShaderList.push_back(&gDeferredMaterialWaterProgram[i]); + + gDeferredMaterialWaterProgram[i].mName = llformat("Deferred Underwater Material Shader %d", i); + + U32 alpha_mode = i & 0x3; + + gDeferredMaterialWaterProgram[i].mShaderFiles.clear(); + gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredMaterialWaterProgram[i].mShaderFiles.push_back(make_pair("deferred/materialF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredMaterialWaterProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gDeferredMaterialWaterProgram[i].mShaderGroup = LLGLSLShader::SG_WATER; + + gDeferredMaterialWaterProgram[i].clearPermutations(); + + bool has_normal_map = (i & 0x8) > 0; + bool has_specular_map = (i & 0x4) > 0; + + if (has_normal_map) + { + gDeferredMaterialWaterProgram[i].addPermutation("HAS_NORMAL_MAP", "1"); + } + + if (has_specular_map) + { + gDeferredMaterialWaterProgram[i].addPermutation("HAS_SPECULAR_MAP", "1"); + } + + gDeferredMaterialWaterProgram[i].addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); + if (use_sun_shadow) + { + gDeferredMaterialWaterProgram[i].addPermutation("HAS_SUN_SHADOW", "1"); + } + + bool has_skin = i & 0x10; + if (has_skin) + { + gDeferredMaterialWaterProgram[i].addPermutation("HAS_SKIN", "1"); + } + gDeferredMaterialWaterProgram[i].addPermutation("WATER_FOG","1"); + + gDeferredMaterialWaterProgram[i].mFeatures.hasWaterFog = true; + gDeferredMaterialWaterProgram[i].mFeatures.hasSrgb = true; + gDeferredMaterialWaterProgram[i].mFeatures.encodesNormal = true; + gDeferredMaterialWaterProgram[i].mFeatures.calculatesAtmospherics = true; + gDeferredMaterialWaterProgram[i].mFeatures.hasAtmospherics = true; + gDeferredMaterialWaterProgram[i].mFeatures.hasGamma = true; + + gDeferredMaterialWaterProgram[i].mFeatures.hasTransport = true; + gDeferredMaterialWaterProgram[i].mFeatures.hasShadows = use_sun_shadow; + + if (has_skin) + { + gDeferredMaterialWaterProgram[i].mFeatures.hasObjectSkinning = true; + } + + success = gDeferredMaterialWaterProgram[i].createShader(NULL, NULL);//&mWLUniforms); + llassert(success); } } @@ -1383,9 +1576,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredTreeProgram.mName = "Deferred Tree Shader"; gDeferredTreeProgram.mShaderFiles.clear(); + gDeferredTreeProgram.mFeatures.encodesNormal = true; gDeferredTreeProgram.mShaderFiles.push_back(make_pair("deferred/treeV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredTreeProgram.mShaderFiles.push_back(make_pair("deferred/treeF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredTreeProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredTreeProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredTreeProgram.createShader(NULL, NULL); } @@ -1393,44 +1587,59 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredTreeShadowProgram.mName = "Deferred Tree Shadow Shader"; gDeferredTreeShadowProgram.mShaderFiles.clear(); + gDeferredTreeShadowProgram.mFeatures.isDeferred = true; + gDeferredTreeShadowProgram.mFeatures.hasShadows = true; gDeferredTreeShadowProgram.mShaderFiles.push_back(make_pair("deferred/treeShadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredTreeShadowProgram.mShaderFiles.push_back(make_pair("deferred/treeShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredTreeShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredTreeShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredTreeShadowProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredImpostorProgram.mName = "Deferred Impostor Shader"; + gDeferredImpostorProgram.mFeatures.hasSrgb = true; + gDeferredImpostorProgram.mFeatures.encodesNormal = true; + //gDeferredImpostorProgram.mFeatures.isDeferred = true; gDeferredImpostorProgram.mShaderFiles.clear(); gDeferredImpostorProgram.mShaderFiles.push_back(make_pair("deferred/impostorV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredImpostorProgram.mShaderFiles.push_back(make_pair("deferred/impostorF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredImpostorProgram.createShader(NULL, NULL); + gDeferredImpostorProgram.mShaderFiles.push_back(make_pair("deferred/impostorF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredImpostorProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredImpostorProgram.createShader(NULL, NULL); + llassert(success); } if (success) - { + { gDeferredLightProgram.mName = "Deferred Light Shader"; + gDeferredLightProgram.mFeatures.isDeferred = true; + gDeferredLightProgram.mFeatures.hasShadows = true; + gDeferredLightProgram.mShaderFiles.clear(); gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredLightProgram.createShader(NULL, NULL); + llassert(success); } for (U32 i = 0; i < LL_DEFERRED_MULTI_LIGHT_COUNT; i++) { - if (success) - { + if (success) + { gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i); + gDeferredMultiLightProgram[i].mFeatures.isDeferred = true; + gDeferredMultiLightProgram[i].mFeatures.hasShadows = true; + gDeferredMultiLightProgram[i].mShaderFiles.clear(); gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMultiLightProgram[i].mShaderFiles.push_back(make_pair("deferred/multiPointLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredMultiLightProgram[i].mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredMultiLightProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredMultiLightProgram[i].addPermutation("LIGHT_COUNT", llformat("%d", i+1)); success = gDeferredMultiLightProgram[i].createShader(NULL, NULL); + llassert(success); } } @@ -1438,22 +1647,32 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredSpotLightProgram.mName = "Deferred SpotLight Shader"; gDeferredSpotLightProgram.mShaderFiles.clear(); + gDeferredSpotLightProgram.mFeatures.hasSrgb = true; + gDeferredSpotLightProgram.mFeatures.isDeferred = true; + gDeferredSpotLightProgram.mFeatures.hasShadows = true; + gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSpotLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredSpotLightProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredMultiSpotLightProgram.mName = "Deferred MultiSpotLight Shader"; + gDeferredMultiSpotLightProgram.mFeatures.hasSrgb = true; + gDeferredMultiSpotLightProgram.mFeatures.isDeferred = true; + gDeferredMultiSpotLightProgram.mFeatures.hasShadows = true; + gDeferredMultiSpotLightProgram.mShaderFiles.clear(); gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiPointLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/multiSpotLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredMultiSpotLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredMultiSpotLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredMultiSpotLightProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1461,37 +1680,48 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() std::string fragment; std::string vertex = "deferred/sunLightV.glsl"; - if (gSavedSettings.getBOOL("RenderDeferredSSAO")) - { - fragment = "deferred/sunLightSSAOF.glsl"; - } - else - { - fragment = "deferred/sunLightF.glsl"; - if (mVertexShaderLevel[SHADER_DEFERRED] == 1) - { //no shadows, no SSAO, no frag coord - vertex = "deferred/sunLightNoFragCoordV.glsl"; - } - } - - gDeferredSunProgram.mName = "Deferred Sun Shader"; + bool use_ao = gSavedSettings.getBOOL("RenderDeferredSSAO"); + + if (use_ao) + { + fragment = "deferred/sunLightSSAOF.glsl"; + } + else + { + fragment = "deferred/sunLightF.glsl"; + if (mShaderLevel[SHADER_DEFERRED] == 1) + { //no shadows, no SSAO, no frag coord + vertex = "deferred/sunLightNoFragCoordV.glsl"; + } + } + + gDeferredSunProgram.mName = "Deferred Sun Shader"; + gDeferredSunProgram.mFeatures.isDeferred = true; + gDeferredSunProgram.mFeatures.hasShadows = true; + gDeferredSunProgram.mFeatures.hasAmbientOcclusion = use_ao; + + gDeferredSunProgram.mName = "Deferred Sun Shader"; gDeferredSunProgram.mShaderFiles.clear(); gDeferredSunProgram.mShaderFiles.push_back(make_pair(vertex, GL_VERTEX_SHADER_ARB)); gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB)); - gDeferredSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSunProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - success = gDeferredSunProgram.createShader(NULL, NULL); + success = gDeferredSunProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredBlurLightProgram.mName = "Deferred Blur Light Shader"; + gDeferredBlurLightProgram.mFeatures.isDeferred = true; + gDeferredBlurLightProgram.mShaderFiles.clear(); gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredBlurLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredBlurLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredBlurLightProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1502,63 +1732,88 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaProgram.mFeatures.hasLighting = false; gDeferredAlphaProgram.mFeatures.isAlphaLighting = true; gDeferredAlphaProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels - if (mVertexShaderLevel[SHADER_DEFERRED] < 1) - { - gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } - - gDeferredAlphaProgram.mShaderFiles.clear(); - gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); - gDeferredAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); - gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); - gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - - success = gDeferredAlphaProgram.createShader(NULL, NULL); - - // Hack - gDeferredAlphaProgram.mFeatures.calculatesLighting = true; - gDeferredAlphaProgram.mFeatures.hasLighting = true; - } - - if (success) - { - gDeferredAlphaImpostorProgram.mName = "Deferred Alpha Shader"; + gDeferredAlphaProgram.mFeatures.hasSrgb = true; + gDeferredAlphaProgram.mFeatures.encodesNormal = true; + gDeferredAlphaProgram.mFeatures.calculatesAtmospherics = true; + gDeferredAlphaProgram.mFeatures.hasAtmospherics = true; + gDeferredAlphaProgram.mFeatures.hasGamma = true; + gDeferredAlphaProgram.mFeatures.hasTransport = true; + gDeferredAlphaProgram.mFeatures.hasShadows = use_sun_shadow; + + if (mShaderLevel[SHADER_DEFERRED] < 1) + { + gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + } + else + { //shave off some texture units for shadow maps + gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); + } + + gDeferredAlphaProgram.mShaderFiles.clear(); + gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + + gDeferredAlphaProgram.clearPermutations(); + + gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1"); + if (use_sun_shadow) + { + gDeferredAlphaProgram.addPermutation("HAS_SHADOW", "1"); + } + gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1"); + gDeferredAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + success = gDeferredAlphaProgram.createShader(NULL, NULL); + llassert(success); + + // Hack + gDeferredAlphaProgram.mFeatures.calculatesLighting = true; + gDeferredAlphaProgram.mFeatures.hasLighting = true; + } + + if (success) + { + gDeferredAlphaImpostorProgram.mName = "Deferred Alpha Impostor Shader"; gDeferredAlphaImpostorProgram.mFeatures.calculatesLighting = false; gDeferredAlphaImpostorProgram.mFeatures.hasLighting = false; gDeferredAlphaImpostorProgram.mFeatures.isAlphaLighting = true; - gDeferredAlphaImpostorProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels - if (mVertexShaderLevel[SHADER_DEFERRED] < 1) - { - gDeferredAlphaImpostorProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - gDeferredAlphaImpostorProgram.mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } + gDeferredAlphaImpostorProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of gDeferredAlphaImpostorProgram.mFeatures.hasSrgb = true; + gDeferredAlphaImpostorProgram.mFeatures.encodesNormal = true; + gDeferredAlphaImpostorProgram.mFeatures.hasShadows = use_sun_shadow; - gDeferredAlphaImpostorProgram.mShaderFiles.clear(); - gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAlphaImpostorProgram.addPermutation("USE_INDEXED_TEX", "1"); - gDeferredAlphaImpostorProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); - gDeferredAlphaImpostorProgram.addPermutation("USE_VERTEX_COLOR", "1"); - gDeferredAlphaImpostorProgram.addPermutation("FOR_IMPOSTOR", "1"); + if (mShaderLevel[SHADER_DEFERRED] < 1) + { + gDeferredAlphaImpostorProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + } + else + { //shave off some texture units for shadow maps + gDeferredAlphaImpostorProgram.mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); + } - gDeferredAlphaImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredAlphaImpostorProgram.mShaderFiles.clear(); + gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAlphaImpostorProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); - success = gDeferredAlphaImpostorProgram.createShader(NULL, NULL); + gDeferredAlphaImpostorProgram.clearPermutations(); + gDeferredAlphaImpostorProgram.addPermutation("USE_INDEXED_TEX", "1"); + gDeferredAlphaImpostorProgram.addPermutation("USE_VERTEX_COLOR", "1"); + gDeferredAlphaImpostorProgram.addPermutation("FOR_IMPOSTOR", "1"); - // Hack - gDeferredAlphaImpostorProgram.mFeatures.calculatesLighting = true; - gDeferredAlphaImpostorProgram.mFeatures.hasLighting = true; - } + if (use_sun_shadow) + { + gDeferredAlphaImpostorProgram.addPermutation("HAS_SHADOW", "1"); + } + + gDeferredAlphaImpostorProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + success = gDeferredAlphaImpostorProgram.createShader(NULL, NULL); + llassert(success); + + // Hack + gDeferredAlphaImpostorProgram.mFeatures.calculatesLighting = true; + gDeferredAlphaImpostorProgram.mFeatures.hasLighting = true; + } if (success) { @@ -1567,7 +1822,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaWaterProgram.mFeatures.hasLighting = false; gDeferredAlphaWaterProgram.mFeatures.isAlphaLighting = true; gDeferredAlphaWaterProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels - if (mVertexShaderLevel[SHADER_DEFERRED] < 1) + gDeferredAlphaWaterProgram.mFeatures.hasWaterFog = true; + gDeferredAlphaWaterProgram.mFeatures.hasSrgb = true; + gDeferredAlphaWaterProgram.mFeatures.encodesNormal = true; + gDeferredAlphaWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredAlphaWaterProgram.mFeatures.hasAtmospherics = true; + gDeferredAlphaWaterProgram.mFeatures.hasGamma = true; + gDeferredAlphaWaterProgram.mFeatures.hasTransport = true; + gDeferredAlphaWaterProgram.mFeatures.hasShadows = use_sun_shadow; + + if (mShaderLevel[SHADER_DEFERRED] < 1) { gDeferredAlphaWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; } @@ -1579,13 +1843,19 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAlphaWaterProgram.mShaderFiles.clear(); gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAlphaWaterProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + + gDeferredAlphaWaterProgram.clearPermutations(); gDeferredAlphaWaterProgram.addPermutation("USE_INDEXED_TEX", "1"); gDeferredAlphaWaterProgram.addPermutation("WATER_FOG", "1"); gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1"); - gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); - gDeferredAlphaWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + if (use_sun_shadow) + { + gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", "1"); + } + gDeferredAlphaWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAlphaWaterProgram.createShader(NULL, NULL); + llassert(success); // Hack gDeferredAlphaWaterProgram.mFeatures.calculatesLighting = true; @@ -1599,11 +1869,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarEyesProgram.mFeatures.hasGamma = true; gDeferredAvatarEyesProgram.mFeatures.hasTransport = true; gDeferredAvatarEyesProgram.mFeatures.disableTextureIndex = true; + gDeferredAvatarEyesProgram.mFeatures.hasSrgb = true; + gDeferredAvatarEyesProgram.mFeatures.encodesNormal = true; + gDeferredAvatarEyesProgram.mFeatures.hasShadows = true; + gDeferredAvatarEyesProgram.mShaderFiles.clear(); gDeferredAvatarEyesProgram.mShaderFiles.push_back(make_pair("deferred/avatarEyesV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarEyesProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAvatarEyesProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredAvatarEyesProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarEyesProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1612,12 +1887,14 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightProgram.mFeatures.hasGamma = true; gDeferredFullbrightProgram.mFeatures.hasTransport = true; + gDeferredFullbrightProgram.mFeatures.hasSrgb = true; gDeferredFullbrightProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightProgram.mShaderFiles.clear(); gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredFullbrightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredFullbrightProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1626,13 +1903,15 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; + gDeferredFullbrightAlphaMaskProgram.mFeatures.hasSrgb = true; gDeferredFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightAlphaMaskProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredFullbrightAlphaMaskProgram.addPermutation("HAS_ALPHA_MASK","1"); - gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredFullbrightAlphaMaskProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1641,14 +1920,17 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightWaterProgram.mFeatures.hasGamma = true; gDeferredFullbrightWaterProgram.mFeatures.hasTransport = true; + gDeferredFullbrightWaterProgram.mFeatures.hasWaterFog = true; + gDeferredFullbrightWaterProgram.mFeatures.hasSrgb = true; gDeferredFullbrightWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightWaterProgram.mShaderFiles.clear(); gDeferredFullbrightWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredFullbrightWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredFullbrightWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gDeferredFullbrightWaterProgram.addPermutation("WATER_FOG","1"); success = gDeferredFullbrightWaterProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1657,15 +1939,18 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasGamma = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasTransport = true; + gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasWaterFog = true; + gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.hasSrgb = true; gDeferredFullbrightAlphaMaskWaterProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.clear(); gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightAlphaMaskWaterProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredFullbrightAlphaMaskWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightAlphaMaskWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredFullbrightAlphaMaskWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("HAS_ALPHA_MASK","1"); gDeferredFullbrightAlphaMaskWaterProgram.addPermutation("WATER_FOG","1"); success = gDeferredFullbrightAlphaMaskWaterProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1678,8 +1963,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightShinyProgram.mShaderFiles.clear(); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredFullbrightShinyProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredFullbrightShinyProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1690,11 +1976,13 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedFullbrightProgram.mFeatures.hasTransport = true; gDeferredSkinnedFullbrightProgram.mFeatures.hasObjectSkinning = true; gDeferredSkinnedFullbrightProgram.mFeatures.disableTextureIndex = true; + gDeferredSkinnedFullbrightProgram.mFeatures.hasSrgb = true; gDeferredSkinnedFullbrightProgram.mShaderFiles.clear(); gDeferredSkinnedFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSkinnedFullbrightProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gDeferredSkinnedFullbrightProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gDeferredSkinnedFullbrightProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1708,8 +1996,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.clear(); gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSkinnedFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gDeferredSkinnedFullbrightShinyProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gDeferredSkinnedFullbrightShinyProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1722,8 +2011,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredEmissiveProgram.mShaderFiles.clear(); gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredEmissiveProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredEmissiveProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredEmissiveProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1733,11 +2023,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWaterProgram.mFeatures.calculatesAtmospherics = true; gDeferredWaterProgram.mFeatures.hasGamma = true; gDeferredWaterProgram.mFeatures.hasTransport = true; + gDeferredWaterProgram.mFeatures.encodesNormal = true; + //gDeferredWaterProgram.mFeatures.hasShadows = true; + gDeferredWaterProgram.mShaderFiles.clear(); gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gDeferredWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gDeferredWaterProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1745,23 +2040,37 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() // load water shader gDeferredUnderWaterProgram.mName = "Deferred Under Water Shader"; gDeferredUnderWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredUnderWaterProgram.mFeatures.hasWaterFog = true; gDeferredUnderWaterProgram.mFeatures.hasGamma = true; gDeferredUnderWaterProgram.mFeatures.hasTransport = true; + gDeferredUnderWaterProgram.mFeatures.hasSrgb = true; + gDeferredUnderWaterProgram.mFeatures.encodesNormal = true; + //gDeferredUnderWaterProgram.mFeatures.hasShadows = true; + gDeferredUnderWaterProgram.mShaderFiles.clear(); gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredUnderWaterProgram.mShaderFiles.push_back(make_pair("deferred/underWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredUnderWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredUnderWaterProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredSoftenProgram.mName = "Deferred Soften Shader"; gDeferredSoftenProgram.mShaderFiles.clear(); + gDeferredSoftenProgram.mFeatures.hasSrgb = true; + gDeferredSoftenProgram.mFeatures.calculatesAtmospherics = true; + gDeferredSoftenProgram.mFeatures.hasAtmospherics = true; + gDeferredSoftenProgram.mFeatures.hasTransport = true; + gDeferredSoftenProgram.mFeatures.hasGamma = true; + gDeferredSoftenProgram.mFeatures.isDeferred = true; + gDeferredSoftenProgram.mFeatures.hasShadows = true; + gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSoftenProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; if (gSavedSettings.getBOOL("RenderDeferredSSAO")) { //if using SSAO, take screen space light map into account as if shadows are enabled @@ -1769,6 +2078,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() } success = gDeferredSoftenProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1778,9 +2088,17 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenWaterProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredSoftenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredSoftenWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredSoftenWaterProgram.addPermutation("WATER_FOG", "1"); gDeferredSoftenWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gDeferredSoftenWaterProgram.mFeatures.hasWaterFog = true; + gDeferredSoftenWaterProgram.mFeatures.hasSrgb = true; + gDeferredSoftenWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredSoftenWaterProgram.mFeatures.hasAtmospherics = true; + gDeferredSoftenWaterProgram.mFeatures.hasTransport = true; + gDeferredSoftenWaterProgram.mFeatures.hasGamma = true; + gDeferredSoftenWaterProgram.mFeatures.isDeferred = true; + gDeferredSoftenWaterProgram.mFeatures.hasShadows = true; if (gSavedSettings.getBOOL("RenderDeferredSSAO")) { //if using SSAO, take screen space light map into account as if shadows are enabled @@ -1788,85 +2106,152 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() } success = gDeferredSoftenWaterProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredShadowProgram.mName = "Deferred Shadow Shader"; + gDeferredShadowProgram.mFeatures.isDeferred = true; + gDeferredShadowProgram.mFeatures.hasShadows = true; gDeferredShadowProgram.mShaderFiles.clear(); gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - gDeferredShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); + gDeferredShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + if (gGLManager.mHasDepthClamp) + { + gDeferredShadowProgram.addPermutation("DEPTH_CLAMP", "1"); + } success = gDeferredShadowProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredShadowCubeProgram.mName = "Deferred Shadow Cube Shader"; + gDeferredShadowCubeProgram.mFeatures.isDeferred = true; + gDeferredShadowCubeProgram.mFeatures.hasShadows = true; gDeferredShadowCubeProgram.mShaderFiles.clear(); gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowCubeV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredShadowCubeProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredShadowCubeProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); - gDeferredShadowCubeProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + if (gGLManager.mHasDepthClamp) + { + gDeferredShadowCubeProgram.addPermutation("DEPTH_CLAMP", "1"); + } + gDeferredShadowCubeProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredShadowCubeProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredShadowAlphaMaskProgram.mName = "Deferred Shadow Alpha Mask Shader"; gDeferredShadowAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; + gDeferredShadowAlphaMaskProgram.mShaderFiles.clear(); gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredShadowAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/shadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredShadowAlphaMaskProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); - gDeferredShadowAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + if (gGLManager.mHasDepthClamp) + { + gDeferredShadowAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1"); + } + gDeferredShadowAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredShadowAlphaMaskProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredAvatarShadowProgram.mName = "Deferred Avatar Shadow Shader"; gDeferredAvatarShadowProgram.mFeatures.hasSkinning = true; + gDeferredAvatarShadowProgram.mShaderFiles.clear(); gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAvatarShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); - gDeferredAvatarShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + if (gGLManager.mHasDepthClamp) + { + gDeferredAvatarShadowProgram.addPermutation("DEPTH_CLAMP", "1"); + } + gDeferredAvatarShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarShadowProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredAttachmentShadowProgram.mName = "Deferred Attachment Shadow Shader"; gDeferredAttachmentShadowProgram.mFeatures.hasObjectSkinning = true; + gDeferredAttachmentShadowProgram.mShaderFiles.clear(); gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAttachmentShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAttachmentShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); - gDeferredAttachmentShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + if (gGLManager.mHasDepthClamp) + { + gDeferredAttachmentShadowProgram.addPermutation("DEPTH_CLAMP", "1"); + } + gDeferredAttachmentShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAttachmentShadowProgram.createShader(NULL, NULL); + llassert(success); } if (success) { - gTerrainProgram.mName = "Deferred Terrain Shader"; + gDeferredTerrainProgram.mName = "Deferred Terrain Shader"; + gDeferredTerrainProgram.mFeatures.encodesNormal = true; + gDeferredTerrainProgram.mFeatures.hasSrgb = true; + gDeferredTerrainProgram.mFeatures.calculatesLighting = false; + gDeferredTerrainProgram.mFeatures.hasLighting = false; + gDeferredTerrainProgram.mFeatures.isAlphaLighting = true; + gDeferredTerrainProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels + gDeferredTerrainProgram.mFeatures.hasWaterFog = true; + gDeferredTerrainProgram.mFeatures.calculatesAtmospherics = true; + gDeferredTerrainProgram.mFeatures.hasAtmospherics = true; + gDeferredTerrainProgram.mFeatures.hasGamma = true; + gDeferredTerrainProgram.mFeatures.hasTransport = true; + gDeferredTerrainProgram.mShaderFiles.clear(); gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredTerrainProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; - success = gDeferredTerrainProgram.createShader(NULL, NULL); + gDeferredTerrainProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredTerrainProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gDeferredTerrainWaterProgram.mName = "Deferred Terrain Underwater Shader"; + gDeferredTerrainWaterProgram.mFeatures.encodesNormal = true; + gDeferredTerrainWaterProgram.mFeatures.hasSrgb = true; + gDeferredTerrainWaterProgram.mFeatures.calculatesLighting = false; + gDeferredTerrainWaterProgram.mFeatures.hasLighting = false; + gDeferredTerrainWaterProgram.mFeatures.isAlphaLighting = true; + gDeferredTerrainWaterProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels + gDeferredTerrainWaterProgram.mFeatures.hasWaterFog = true; + gDeferredTerrainWaterProgram.mFeatures.calculatesAtmospherics = true; + gDeferredTerrainWaterProgram.mFeatures.hasAtmospherics = true; + gDeferredTerrainWaterProgram.mFeatures.hasGamma = true; + gDeferredTerrainWaterProgram.mFeatures.hasTransport = true; + + gDeferredTerrainWaterProgram.mShaderFiles.clear(); + gDeferredTerrainWaterProgram.mShaderFiles.push_back(make_pair("deferred/terrainV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredTerrainWaterProgram.mShaderFiles.push_back(make_pair("deferred/terrainF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredTerrainWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gDeferredTerrainWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gDeferredTerrainWaterProgram.addPermutation("WATER_FOG", "1"); + success = gDeferredTerrainWaterProgram.createShader(NULL, NULL); } if (success) { gDeferredAvatarProgram.mName = "Avatar Shader"; gDeferredAvatarProgram.mFeatures.hasSkinning = true; + gDeferredAvatarProgram.mFeatures.encodesNormal = true; gDeferredAvatarProgram.mShaderFiles.clear(); gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredAvatarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredAvatarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1877,15 +2262,30 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mFeatures.hasLighting = false; gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true; gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true; + gDeferredAvatarAlphaProgram.mFeatures.hasSrgb = true; + gDeferredAvatarAlphaProgram.mFeatures.encodesNormal = true; + gDeferredAvatarAlphaProgram.mFeatures.calculatesAtmospherics = true; + gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true; + gDeferredAvatarAlphaProgram.mFeatures.hasTransport = true; + gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true; + gDeferredAvatarAlphaProgram.mFeatures.isDeferred = true; + gDeferredAvatarAlphaProgram.mFeatures.hasShadows = true; + gDeferredAvatarAlphaProgram.mShaderFiles.clear(); - gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); - gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + + gDeferredAvatarAlphaProgram.clearPermutations(); gDeferredAvatarAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1"); gDeferredAvatarAlphaProgram.addPermutation("IS_AVATAR_SKIN", "1"); - gDeferredAvatarAlphaProgram.addPermutation("HAS_SHADOW", mVertexShaderLevel[SHADER_DEFERRED] > 1 ? "1" : "0"); - gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + if (use_sun_shadow) + { + gDeferredAvatarAlphaProgram.addPermutation("HAS_SHADOW", "1"); + } + gDeferredAvatarAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredAvatarAlphaProgram.createShader(NULL, NULL); + llassert(success); gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = true; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true; @@ -1894,95 +2294,158 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() if (success) { gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process"; + gDeferredPostGammaCorrectProgram.mFeatures.hasSrgb = true; + gDeferredPostGammaCorrectProgram.mFeatures.isDeferred = true; gDeferredPostGammaCorrectProgram.mShaderFiles.clear(); gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredPostGammaCorrectProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredPostGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredPostGammaCorrectProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gFXAAProgram.mName = "FXAA Shader"; + gFXAAProgram.mFeatures.isDeferred = true; gFXAAProgram.mShaderFiles.clear(); gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB)); gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER_ARB)); - gFXAAProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gFXAAProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gFXAAProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredPostProgram.mName = "Deferred Post Shader"; + gFXAAProgram.mFeatures.isDeferred = true; gDeferredPostProgram.mShaderFiles.clear(); gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredPostProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredPostProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredPostProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredCoFProgram.mName = "Deferred CoF Shader"; gDeferredCoFProgram.mShaderFiles.clear(); + gDeferredCoFProgram.mFeatures.isDeferred = true; gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/cofF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredCoFProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredCoFProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredCoFProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredDoFCombineProgram.mName = "Deferred DoFCombine Shader"; + gDeferredDoFCombineProgram.mFeatures.isDeferred = true; gDeferredDoFCombineProgram.mShaderFiles.clear(); gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/dofCombineF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredDoFCombineProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredDoFCombineProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredDoFCombineProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredPostNoDoFProgram.mName = "Deferred Post Shader"; + gDeferredPostNoDoFProgram.mFeatures.isDeferred = true; gDeferredPostNoDoFProgram.mShaderFiles.clear(); gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoDoFF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredPostNoDoFProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredPostNoDoFProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = gDeferredPostNoDoFProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredWLSkyProgram.mName = "Deferred Windlight Sky Shader"; - //gWLSkyProgram.mFeatures.hasGamma = true; gDeferredWLSkyProgram.mShaderFiles.clear(); + gDeferredWLSkyProgram.mFeatures.calculatesAtmospherics = true; + gDeferredWLSkyProgram.mFeatures.hasTransport = true; + gDeferredWLSkyProgram.mFeatures.hasGamma = true; + gDeferredWLSkyProgram.mFeatures.hasSrgb = true; + gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gDeferredWLSkyProgram.createShader(NULL, NULL); + llassert(success); } if (success) { gDeferredWLCloudProgram.mName = "Deferred Windlight Cloud Program"; gDeferredWLCloudProgram.mShaderFiles.clear(); + gDeferredWLCloudProgram.mFeatures.calculatesAtmospherics = true; + gDeferredWLCloudProgram.mFeatures.hasTransport = true; + gDeferredWLCloudProgram.mFeatures.hasGamma = true; + gDeferredWLCloudProgram.mFeatures.hasSrgb = true; + gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; success = gDeferredWLCloudProgram.createShader(NULL, NULL); - } - - if (success) + llassert(success); + } + + if (success) + { + gDeferredWLSunProgram.mName = "Deferred Windlight Sun Program"; + gDeferredWLSunProgram.mFeatures.calculatesAtmospherics = true; + gDeferredWLSunProgram.mFeatures.hasTransport = true; + gDeferredWLSunProgram.mFeatures.hasGamma = true; + gDeferredWLSunProgram.mFeatures.hasAtmospherics = true; + gDeferredWLSunProgram.mFeatures.isFullbright = true; + gDeferredWLSunProgram.mFeatures.disableTextureIndex = true; + gDeferredWLSunProgram.mShaderFiles.clear(); + gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredWLSunProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gDeferredWLSunProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gDeferredWLSunProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gDeferredWLMoonProgram.mName = "Deferred Windlight Moon Program"; + gDeferredWLMoonProgram.mFeatures.calculatesAtmospherics = true; + gDeferredWLMoonProgram.mFeatures.hasTransport = true; + gDeferredWLMoonProgram.mFeatures.hasGamma = true; + gDeferredWLMoonProgram.mFeatures.hasAtmospherics = true; + gDeferredWLMoonProgram.mFeatures.isFullbright = true; + gDeferredWLMoonProgram.mFeatures.disableTextureIndex = true; + + gDeferredWLMoonProgram.mShaderFiles.clear(); + gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gDeferredWLMoonProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) { gDeferredStarProgram.mName = "Deferred Star Program"; gDeferredStarProgram.mShaderFiles.clear(); gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredStarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredStarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY; success = gDeferredStarProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -1991,7 +2454,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gNormalMapGenProgram.mShaderFiles.clear(); gNormalMapGenProgram.mShaderFiles.push_back(make_pair("deferred/normgenV.glsl", GL_VERTEX_SHADER_ARB)); gNormalMapGenProgram.mShaderFiles.push_back(make_pair("deferred/normgenF.glsl", GL_FRAGMENT_SHADER_ARB)); - gNormalMapGenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gNormalMapGenProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gNormalMapGenProgram.mShaderGroup = LLGLSLShader::SG_SKY; success = gNormalMapGenProgram.createShader(NULL, NULL); } @@ -2003,7 +2466,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() { BOOL success = TRUE; - if (mVertexShaderLevel[SHADER_OBJECT] == 0) + if (mShaderLevel[SHADER_OBJECT] == 0) { gObjectShinyProgram.unload(); gObjectFullbrightShinyProgram.unload(); @@ -2068,7 +2531,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleNonIndexedProgram.mShaderFiles.clear(); gObjectSimpleNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleNonIndexedProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectSimpleNonIndexedProgram.createShader(NULL, NULL); } @@ -2084,7 +2547,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleNonIndexedTexGenProgram.mShaderFiles.clear(); gObjectSimpleNonIndexedTexGenProgram.mShaderFiles.push_back(make_pair("objects/simpleTexGenV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleNonIndexedTexGenProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleNonIndexedTexGenProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleNonIndexedTexGenProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectSimpleNonIndexedTexGenProgram.createShader(NULL, NULL); } @@ -2101,7 +2564,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleNonIndexedWaterProgram.mShaderFiles.clear(); gObjectSimpleNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleNonIndexedWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectSimpleNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectSimpleNonIndexedWaterProgram.createShader(NULL, NULL); } @@ -2118,7 +2581,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleNonIndexedTexGenWaterProgram.mShaderFiles.clear(); gObjectSimpleNonIndexedTexGenWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleTexGenV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleNonIndexedTexGenWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleNonIndexedTexGenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleNonIndexedTexGenWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectSimpleNonIndexedTexGenWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectSimpleNonIndexedTexGenWaterProgram.createShader(NULL, NULL); } @@ -2136,7 +2599,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectAlphaMaskNonIndexedProgram.mShaderFiles.clear(); gObjectAlphaMaskNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleNonIndexedV.glsl", GL_VERTEX_SHADER_ARB)); gObjectAlphaMaskNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectAlphaMaskNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectAlphaMaskNonIndexedProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectAlphaMaskNonIndexedProgram.createShader(NULL, NULL); } @@ -2153,7 +2616,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectAlphaMaskNonIndexedWaterProgram.mShaderFiles.clear(); gObjectAlphaMaskNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleNonIndexedV.glsl", GL_VERTEX_SHADER_ARB)); gObjectAlphaMaskNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectAlphaMaskNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectAlphaMaskNonIndexedWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectAlphaMaskNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectAlphaMaskNonIndexedWaterProgram.createShader(NULL, NULL); } @@ -2171,7 +2634,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectAlphaMaskNoColorProgram.mShaderFiles.clear(); gObjectAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("objects/simpleNoColorV.glsl", GL_VERTEX_SHADER_ARB)); gObjectAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectAlphaMaskNoColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectAlphaMaskNoColorProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectAlphaMaskNoColorProgram.createShader(NULL, NULL); } @@ -2188,7 +2651,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectAlphaMaskNoColorWaterProgram.mShaderFiles.clear(); gObjectAlphaMaskNoColorWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleNoColorV.glsl", GL_VERTEX_SHADER_ARB)); gObjectAlphaMaskNoColorWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectAlphaMaskNoColorWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectAlphaMaskNoColorWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectAlphaMaskNoColorWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectAlphaMaskNoColorWaterProgram.createShader(NULL, NULL); } @@ -2206,7 +2669,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gTreeProgram.mShaderFiles.clear(); gTreeProgram.mShaderFiles.push_back(make_pair("objects/treeV.glsl", GL_VERTEX_SHADER_ARB)); gTreeProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gTreeProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gTreeProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gTreeProgram.createShader(NULL, NULL); } @@ -2223,7 +2686,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gTreeWaterProgram.mShaderFiles.clear(); gTreeWaterProgram.mShaderFiles.push_back(make_pair("objects/treeV.glsl", GL_VERTEX_SHADER_ARB)); gTreeWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gTreeWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gTreeWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gTreeWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gTreeWaterProgram.createShader(NULL, NULL); } @@ -2239,7 +2702,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightNonIndexedProgram.mShaderFiles.clear(); gObjectFullbrightNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightNonIndexedProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectFullbrightNonIndexedProgram.createShader(NULL, NULL); } @@ -2251,10 +2714,11 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightNonIndexedWaterProgram.mFeatures.hasWaterFog = true; gObjectFullbrightNonIndexedWaterProgram.mFeatures.hasTransport = true; gObjectFullbrightNonIndexedWaterProgram.mFeatures.disableTextureIndex = true; + gObjectFullbrightNonIndexedWaterProgram.mFeatures.hasSrgb = true; gObjectFullbrightNonIndexedWaterProgram.mShaderFiles.clear(); gObjectFullbrightNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightNonIndexedWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectFullbrightNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectFullbrightNonIndexedWaterProgram.createShader(NULL, NULL); } @@ -2267,10 +2731,11 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectEmissiveNonIndexedProgram.mFeatures.hasTransport = true; gObjectEmissiveNonIndexedProgram.mFeatures.isFullbright = true; gObjectEmissiveNonIndexedProgram.mFeatures.disableTextureIndex = true; + gObjectEmissiveNonIndexedProgram.mFeatures.hasSrgb = true; gObjectEmissiveNonIndexedProgram.mShaderFiles.clear(); gObjectEmissiveNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); gObjectEmissiveNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectEmissiveNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectEmissiveNonIndexedProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectEmissiveNonIndexedProgram.createShader(NULL, NULL); } @@ -2285,7 +2750,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectEmissiveNonIndexedWaterProgram.mShaderFiles.clear(); gObjectEmissiveNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); gObjectEmissiveNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectEmissiveNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectEmissiveNonIndexedWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectEmissiveNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectEmissiveNonIndexedWaterProgram.createShader(NULL, NULL); } @@ -2297,11 +2762,12 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightNoColorProgram.mFeatures.hasGamma = true; gObjectFullbrightNoColorProgram.mFeatures.hasTransport = true; gObjectFullbrightNoColorProgram.mFeatures.isFullbright = true; + gObjectFullbrightNoColorProgram.mFeatures.hasSrgb = true; gObjectFullbrightNoColorProgram.mFeatures.disableTextureIndex = true; gObjectFullbrightNoColorProgram.mShaderFiles.clear(); gObjectFullbrightNoColorProgram.mShaderFiles.push_back(make_pair("objects/fullbrightNoColorV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightNoColorProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightNoColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightNoColorProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectFullbrightNoColorProgram.createShader(NULL, NULL); } @@ -2316,7 +2782,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightNoColorWaterProgram.mShaderFiles.clear(); gObjectFullbrightNoColorWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightNoColorV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightNoColorWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightNoColorWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightNoColorWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectFullbrightNoColorWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectFullbrightNoColorWaterProgram.createShader(NULL, NULL); } @@ -2333,7 +2799,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyNonIndexedProgram.mShaderFiles.clear(); gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectShinyNonIndexedProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectShinyNonIndexedProgram.createShader(NULL, NULL); } @@ -2349,12 +2815,12 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyNonIndexedWaterProgram.mShaderFiles.clear(); gObjectShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); - gObjectShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectShinyNonIndexedWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectShinyNonIndexedWaterProgram.createShader(NULL, NULL); } - if (success) + if (success) { gObjectFullbrightShinyNonIndexedProgram.mName = "Non Indexed Fullbright Shiny Shader"; gObjectFullbrightShinyNonIndexedProgram.mFeatures.calculatesAtmospherics = true; @@ -2366,7 +2832,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.clear(); gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightShinyNonIndexedProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectFullbrightShinyNonIndexedProgram.createShader(NULL, NULL); } @@ -2383,7 +2849,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.clear(); gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightShinyNonIndexedWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectFullbrightShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectFullbrightShinyNonIndexedWaterProgram.createShader(NULL, NULL); } @@ -2392,10 +2858,11 @@ BOOL LLViewerShaderMgr::loadShadersObject() { gImpostorProgram.mName = "Impostor Shader"; gImpostorProgram.mFeatures.disableTextureIndex = true; + gImpostorProgram.mFeatures.hasSrgb = true; gImpostorProgram.mShaderFiles.clear(); gImpostorProgram.mShaderFiles.push_back(make_pair("objects/impostorV.glsl", GL_VERTEX_SHADER_ARB)); gImpostorProgram.mShaderFiles.push_back(make_pair("objects/impostorF.glsl", GL_FRAGMENT_SHADER_ARB)); - gImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gImpostorProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gImpostorProgram.createShader(NULL, NULL); } @@ -2412,7 +2879,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectPreviewProgram.mShaderFiles.clear(); gObjectPreviewProgram.mShaderFiles.push_back(make_pair("objects/previewV.glsl", GL_VERTEX_SHADER_ARB)); gObjectPreviewProgram.mShaderFiles.push_back(make_pair("objects/previewF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectPreviewProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectPreviewProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectPreviewProgram.createShader(NULL, NULL); gObjectPreviewProgram.mFeatures.hasLighting = true; } @@ -2429,7 +2896,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleProgram.mShaderFiles.clear(); gObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectSimpleProgram.createShader(NULL, NULL); } @@ -2449,7 +2916,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleImpostorProgram.mShaderFiles.clear(); gObjectSimpleImpostorProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleImpostorProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleImpostorProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleImpostorProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectSimpleImpostorProgram.createShader(NULL, NULL); } @@ -2466,7 +2933,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleWaterProgram.mShaderFiles.clear(); gObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectSimpleWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectSimpleWaterProgram.createShader(NULL, NULL); } @@ -2480,10 +2947,11 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectBumpProgram.mFeatures.hasAtmospherics = true; gObjectBumpProgram.mFeatures.hasLighting = true; gObjectBumpProgram.mFeatures.mIndexedTextureChannels = 0;*/ + gObjectBumpProgram.mFeatures.encodesNormal = true; gObjectBumpProgram.mShaderFiles.clear(); gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpV.glsl", GL_VERTEX_SHADER_ARB)); gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectBumpProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectBumpProgram.createShader(NULL, NULL); if (success) { //lldrawpoolbump assumes "texture0" has channel 0 and "texture1" has channel 1 @@ -2508,7 +2976,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleAlphaMaskProgram.mShaderFiles.clear(); gObjectSimpleAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectSimpleAlphaMaskProgram.createShader(NULL, NULL); } @@ -2525,7 +2993,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleWaterAlphaMaskProgram.mShaderFiles.clear(); gObjectSimpleWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); gObjectSimpleWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectSimpleWaterAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleWaterAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectSimpleWaterAlphaMaskProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectSimpleWaterAlphaMaskProgram.createShader(NULL, NULL); } @@ -2537,11 +3005,12 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightProgram.mFeatures.hasGamma = true; gObjectFullbrightProgram.mFeatures.hasTransport = true; gObjectFullbrightProgram.mFeatures.isFullbright = true; + gObjectFullbrightProgram.mFeatures.hasSrgb = true; gObjectFullbrightProgram.mFeatures.mIndexedTextureChannels = 0; gObjectFullbrightProgram.mShaderFiles.clear(); gObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectFullbrightProgram.createShader(NULL, NULL); } @@ -2556,7 +3025,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightWaterProgram.mShaderFiles.clear(); gObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectFullbrightWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectFullbrightWaterProgram.createShader(NULL, NULL); } @@ -2568,11 +3037,12 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectEmissiveProgram.mFeatures.hasGamma = true; gObjectEmissiveProgram.mFeatures.hasTransport = true; gObjectEmissiveProgram.mFeatures.isFullbright = true; + gObjectEmissiveProgram.mFeatures.hasSrgb = true; gObjectEmissiveProgram.mFeatures.mIndexedTextureChannels = 0; gObjectEmissiveProgram.mShaderFiles.clear(); gObjectEmissiveProgram.mShaderFiles.push_back(make_pair("objects/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); gObjectEmissiveProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectEmissiveProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectEmissiveProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectEmissiveProgram.createShader(NULL, NULL); } @@ -2587,7 +3057,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectEmissiveWaterProgram.mShaderFiles.clear(); gObjectEmissiveWaterProgram.mShaderFiles.push_back(make_pair("objects/emissiveV.glsl", GL_VERTEX_SHADER_ARB)); gObjectEmissiveWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectEmissiveWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectEmissiveWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectEmissiveWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectEmissiveWaterProgram.createShader(NULL, NULL); } @@ -2600,11 +3070,12 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; gObjectFullbrightAlphaMaskProgram.mFeatures.isFullbright = true; gObjectFullbrightAlphaMaskProgram.mFeatures.hasAlphaMask = true; + gObjectFullbrightAlphaMaskProgram.mFeatures.hasSrgb = true; gObjectFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = 0; gObjectFullbrightAlphaMaskProgram.mShaderFiles.clear(); gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectFullbrightAlphaMaskProgram.createShader(NULL, NULL); } @@ -2620,7 +3091,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightWaterAlphaMaskProgram.mShaderFiles.clear(); gObjectFullbrightWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightWaterAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightWaterAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightWaterAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectFullbrightWaterAlphaMaskProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectFullbrightWaterAlphaMaskProgram.createShader(NULL, NULL); } @@ -2637,7 +3108,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyProgram.mShaderFiles.clear(); gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectShinyProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectShinyProgram.createShader(NULL, NULL); } @@ -2653,7 +3124,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectShinyWaterProgram.mShaderFiles.clear(); gObjectShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); gObjectShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB)); - gObjectShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectShinyWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectShinyWaterProgram.createShader(NULL, NULL); } @@ -2670,7 +3141,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyProgram.mShaderFiles.clear(); gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightShinyProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gObjectFullbrightShinyProgram.createShader(NULL, NULL); } @@ -2687,12 +3158,12 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyWaterProgram.mShaderFiles.clear(); gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB)); gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectFullbrightShinyWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; gObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gObjectFullbrightShinyWaterProgram.createShader(NULL, NULL); } - if (mVertexShaderLevel[SHADER_AVATAR] > 0) + if (mShaderLevel[SHADER_AVATAR] > 0) { //load hardware skinned attachment shaders if (success) { @@ -2708,7 +3179,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectSimpleProgram.mShaderFiles.clear(); gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectSimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectSimpleProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectSimpleProgram.createShader(NULL, NULL); } @@ -2722,10 +3193,11 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightProgram.mFeatures.hasObjectSkinning = true; gSkinnedObjectFullbrightProgram.mFeatures.hasAlphaMask = true; gSkinnedObjectFullbrightProgram.mFeatures.disableTextureIndex = true; + gSkinnedObjectFullbrightProgram.mFeatures.hasSrgb = true; gSkinnedObjectFullbrightProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectFullbrightProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectFullbrightProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectFullbrightProgram.createShader(NULL, NULL); } @@ -2738,10 +3210,11 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectEmissiveProgram.mFeatures.isFullbright = true; gSkinnedObjectEmissiveProgram.mFeatures.hasObjectSkinning = true; gSkinnedObjectEmissiveProgram.mFeatures.disableTextureIndex = true; + gSkinnedObjectEmissiveProgram.mFeatures.hasSrgb = true; gSkinnedObjectEmissiveProgram.mShaderFiles.clear(); gSkinnedObjectEmissiveProgram.mShaderFiles.push_back(make_pair("objects/emissiveSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectEmissiveProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectEmissiveProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectEmissiveProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectEmissiveProgram.createShader(NULL, NULL); } @@ -2758,7 +3231,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectEmissiveWaterProgram.mShaderFiles.clear(); gSkinnedObjectEmissiveWaterProgram.mShaderFiles.push_back(make_pair("objects/emissiveSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectEmissiveWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectEmissiveWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectEmissiveWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectEmissiveWaterProgram.createShader(NULL, NULL); } @@ -2776,7 +3249,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectFullbrightShinyProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectFullbrightShinyProgram.createShader(NULL, NULL); } @@ -2794,7 +3267,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleProgram.mShaderFiles.clear(); gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectShinySimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectShinySimpleProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectShinySimpleProgram.createShader(NULL, NULL); } @@ -2815,7 +3288,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectSimpleWaterProgram.mShaderFiles.clear(); gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectSimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectSimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectSimpleWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectSimpleWaterProgram.createShader(NULL, NULL); } @@ -2834,7 +3307,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightWaterProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectFullbrightWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectFullbrightWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectFullbrightWaterProgram.createShader(NULL, NULL); } @@ -2854,7 +3327,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.clear(); gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectFullbrightShinyWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectFullbrightShinyWaterProgram.createShader(NULL, NULL); } @@ -2874,14 +3347,14 @@ BOOL LLViewerShaderMgr::loadShadersObject() gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.clear(); gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSkinnedObjectShinySimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gSkinnedObjectShinySimpleWaterProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; success = gSkinnedObjectShinySimpleWaterProgram.createShader(NULL, NULL); } } if( !success ) { - mVertexShaderLevel[SHADER_OBJECT] = 0; + mShaderLevel[SHADER_OBJECT] = 0; return FALSE; } @@ -2892,7 +3365,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() { BOOL success = TRUE; - if (mVertexShaderLevel[SHADER_AVATAR] == 0) + if (mShaderLevel[SHADER_AVATAR] == 0) { gAvatarProgram.unload(); gAvatarWaterProgram.unload(); @@ -2915,7 +3388,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarProgram.mShaderFiles.clear(); gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarF.glsl", GL_FRAGMENT_SHADER_ARB)); - gAvatarProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR]; + gAvatarProgram.mShaderLevel = mShaderLevel[SHADER_AVATAR]; success = gAvatarProgram.createShader(NULL, NULL); if (success) @@ -2933,15 +3406,15 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarWaterProgram.mShaderFiles.push_back(make_pair("avatar/avatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); // Note: no cloth under water: - gAvatarWaterProgram.mShaderLevel = llmin(mVertexShaderLevel[SHADER_AVATAR], 1); + gAvatarWaterProgram.mShaderLevel = llmin(mShaderLevel[SHADER_AVATAR], 1); gAvatarWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gAvatarWaterProgram.createShader(NULL, NULL); } /// Keep track of avatar levels - if (gAvatarProgram.mShaderLevel != mVertexShaderLevel[SHADER_AVATAR]) + if (gAvatarProgram.mShaderLevel != mShaderLevel[SHADER_AVATAR]) { - mMaxAvatarShaderLevel = mVertexShaderLevel[SHADER_AVATAR] = gAvatarProgram.mShaderLevel; + mMaxAvatarShaderLevel = mShaderLevel[SHADER_AVATAR] = gAvatarProgram.mShaderLevel; } } @@ -2953,7 +3426,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarPickProgram.mShaderFiles.clear(); gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarF.glsl", GL_FRAGMENT_SHADER_ARB)); - gAvatarPickProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR]; + gAvatarPickProgram.mShaderLevel = mShaderLevel[SHADER_AVATAR]; success = gAvatarPickProgram.createShader(NULL, NULL); } @@ -2971,13 +3444,13 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() gAvatarEyeballProgram.mShaderFiles.clear(); gAvatarEyeballProgram.mShaderFiles.push_back(make_pair("avatar/eyeballV.glsl", GL_VERTEX_SHADER_ARB)); gAvatarEyeballProgram.mShaderFiles.push_back(make_pair("avatar/eyeballF.glsl", GL_FRAGMENT_SHADER_ARB)); - gAvatarEyeballProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR]; + gAvatarEyeballProgram.mShaderLevel = mShaderLevel[SHADER_AVATAR]; success = gAvatarEyeballProgram.createShader(NULL, NULL); } if( !success ) { - mVertexShaderLevel[SHADER_AVATAR] = 0; + mShaderLevel[SHADER_AVATAR] = 0; mMaxAvatarShaderLevel = 0; return FALSE; } @@ -2989,7 +3462,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() { BOOL success = TRUE; - if (mVertexShaderLevel[SHADER_INTERFACE] == 0) + if (mShaderLevel[SHADER_INTERFACE] == 0) { gHighlightProgram.unload(); return TRUE; @@ -3001,7 +3474,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gHighlightProgram.mShaderFiles.clear(); gHighlightProgram.mShaderFiles.push_back(make_pair("interface/highlightV.glsl", GL_VERTEX_SHADER_ARB)); gHighlightProgram.mShaderFiles.push_back(make_pair("interface/highlightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gHighlightProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gHighlightProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gHighlightProgram.createShader(NULL, NULL); } @@ -3011,7 +3484,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gHighlightNormalProgram.mShaderFiles.clear(); gHighlightNormalProgram.mShaderFiles.push_back(make_pair("interface/highlightNormV.glsl", GL_VERTEX_SHADER_ARB)); gHighlightNormalProgram.mShaderFiles.push_back(make_pair("interface/highlightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gHighlightNormalProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gHighlightNormalProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gHighlightNormalProgram.createShader(NULL, NULL); } @@ -3021,7 +3494,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gHighlightSpecularProgram.mShaderFiles.clear(); gHighlightSpecularProgram.mShaderFiles.push_back(make_pair("interface/highlightSpecV.glsl", GL_VERTEX_SHADER_ARB)); gHighlightSpecularProgram.mShaderFiles.push_back(make_pair("interface/highlightF.glsl", GL_FRAGMENT_SHADER_ARB)); - gHighlightSpecularProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gHighlightSpecularProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gHighlightSpecularProgram.createShader(NULL, NULL); } @@ -3031,7 +3504,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gUIProgram.mShaderFiles.clear(); gUIProgram.mShaderFiles.push_back(make_pair("interface/uiV.glsl", GL_VERTEX_SHADER_ARB)); gUIProgram.mShaderFiles.push_back(make_pair("interface/uiF.glsl", GL_FRAGMENT_SHADER_ARB)); - gUIProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gUIProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gUIProgram.createShader(NULL, NULL); } @@ -3041,7 +3514,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gPathfindingProgram.mShaderFiles.clear(); gPathfindingProgram.mShaderFiles.push_back(make_pair("interface/pathfindingV.glsl", GL_VERTEX_SHADER_ARB)); gPathfindingProgram.mShaderFiles.push_back(make_pair("interface/pathfindingF.glsl", GL_FRAGMENT_SHADER_ARB)); - gPathfindingProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gPathfindingProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gPathfindingProgram.createShader(NULL, NULL); } @@ -3051,7 +3524,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gPathfindingNoNormalsProgram.mShaderFiles.clear(); gPathfindingNoNormalsProgram.mShaderFiles.push_back(make_pair("interface/pathfindingNoNormalV.glsl", GL_VERTEX_SHADER_ARB)); gPathfindingNoNormalsProgram.mShaderFiles.push_back(make_pair("interface/pathfindingF.glsl", GL_FRAGMENT_SHADER_ARB)); - gPathfindingNoNormalsProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gPathfindingNoNormalsProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gPathfindingNoNormalsProgram.createShader(NULL, NULL); } @@ -3061,7 +3534,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gCustomAlphaProgram.mShaderFiles.clear(); gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaV.glsl", GL_VERTEX_SHADER_ARB)); gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaF.glsl", GL_FRAGMENT_SHADER_ARB)); - gCustomAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gCustomAlphaProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gCustomAlphaProgram.createShader(NULL, NULL); } @@ -3071,7 +3544,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gSplatTextureRectProgram.mShaderFiles.clear(); gSplatTextureRectProgram.mShaderFiles.push_back(make_pair("interface/splattexturerectV.glsl", GL_VERTEX_SHADER_ARB)); gSplatTextureRectProgram.mShaderFiles.push_back(make_pair("interface/splattexturerectF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSplatTextureRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gSplatTextureRectProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gSplatTextureRectProgram.createShader(NULL, NULL); if (success) { @@ -3087,7 +3560,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gGlowCombineProgram.mShaderFiles.clear(); gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineV.glsl", GL_VERTEX_SHADER_ARB)); gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineF.glsl", GL_FRAGMENT_SHADER_ARB)); - gGlowCombineProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gGlowCombineProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gGlowCombineProgram.createShader(NULL, NULL); if (success) { @@ -3104,7 +3577,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gGlowCombineFXAAProgram.mShaderFiles.clear(); gGlowCombineFXAAProgram.mShaderFiles.push_back(make_pair("interface/glowcombineFXAAV.glsl", GL_VERTEX_SHADER_ARB)); gGlowCombineFXAAProgram.mShaderFiles.push_back(make_pair("interface/glowcombineFXAAF.glsl", GL_FRAGMENT_SHADER_ARB)); - gGlowCombineFXAAProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gGlowCombineFXAAProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gGlowCombineFXAAProgram.createShader(NULL, NULL); if (success) { @@ -3122,7 +3595,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gTwoTextureAddProgram.mShaderFiles.clear(); gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddV.glsl", GL_VERTEX_SHADER_ARB)); gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddF.glsl", GL_FRAGMENT_SHADER_ARB)); - gTwoTextureAddProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gTwoTextureAddProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gTwoTextureAddProgram.createShader(NULL, NULL); if (success) { @@ -3139,7 +3612,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gTwoTextureCompareProgram.mShaderFiles.clear(); gTwoTextureCompareProgram.mShaderFiles.push_back(make_pair("interface/twotexturecompareV.glsl", GL_VERTEX_SHADER_ARB)); gTwoTextureCompareProgram.mShaderFiles.push_back(make_pair("interface/twotexturecompareF.glsl", GL_FRAGMENT_SHADER_ARB)); - gTwoTextureCompareProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gTwoTextureCompareProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gTwoTextureCompareProgram.createShader(NULL, NULL); if (success) { @@ -3156,7 +3629,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gOneTextureFilterProgram.mShaderFiles.clear(); gOneTextureFilterProgram.mShaderFiles.push_back(make_pair("interface/onetexturefilterV.glsl", GL_VERTEX_SHADER_ARB)); gOneTextureFilterProgram.mShaderFiles.push_back(make_pair("interface/onetexturefilterF.glsl", GL_FRAGMENT_SHADER_ARB)); - gOneTextureFilterProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gOneTextureFilterProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gOneTextureFilterProgram.createShader(NULL, NULL); if (success) { @@ -3172,7 +3645,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gOneTextureNoColorProgram.mShaderFiles.clear(); gOneTextureNoColorProgram.mShaderFiles.push_back(make_pair("interface/onetexturenocolorV.glsl", GL_VERTEX_SHADER_ARB)); gOneTextureNoColorProgram.mShaderFiles.push_back(make_pair("interface/onetexturenocolorF.glsl", GL_FRAGMENT_SHADER_ARB)); - gOneTextureNoColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gOneTextureNoColorProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gOneTextureNoColorProgram.createShader(NULL, NULL); if (success) { @@ -3187,7 +3660,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gSolidColorProgram.mShaderFiles.clear(); gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorV.glsl", GL_VERTEX_SHADER_ARB)); gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorF.glsl", GL_FRAGMENT_SHADER_ARB)); - gSolidColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gSolidColorProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gSolidColorProgram.createShader(NULL, NULL); if (success) { @@ -3203,7 +3676,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gOcclusionProgram.mShaderFiles.clear(); gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionV.glsl", GL_VERTEX_SHADER_ARB)); gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionF.glsl", GL_FRAGMENT_SHADER_ARB)); - gOcclusionProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gOcclusionProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gOcclusionProgram.createShader(NULL, NULL); } @@ -3213,7 +3686,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gOcclusionCubeProgram.mShaderFiles.clear(); gOcclusionCubeProgram.mShaderFiles.push_back(make_pair("interface/occlusionCubeV.glsl", GL_VERTEX_SHADER_ARB)); gOcclusionCubeProgram.mShaderFiles.push_back(make_pair("interface/occlusionF.glsl", GL_FRAGMENT_SHADER_ARB)); - gOcclusionCubeProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gOcclusionCubeProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gOcclusionCubeProgram.createShader(NULL, NULL); } @@ -3223,7 +3696,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gDebugProgram.mShaderFiles.clear(); gDebugProgram.mShaderFiles.push_back(make_pair("interface/debugV.glsl", GL_VERTEX_SHADER_ARB)); gDebugProgram.mShaderFiles.push_back(make_pair("interface/debugF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDebugProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gDebugProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gDebugProgram.createShader(NULL, NULL); } @@ -3233,7 +3706,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gClipProgram.mShaderFiles.clear(); gClipProgram.mShaderFiles.push_back(make_pair("interface/clipV.glsl", GL_VERTEX_SHADER_ARB)); gClipProgram.mShaderFiles.push_back(make_pair("interface/clipF.glsl", GL_FRAGMENT_SHADER_ARB)); - gClipProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gClipProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gClipProgram.createShader(NULL, NULL); } @@ -3243,7 +3716,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gDownsampleDepthProgram.mShaderFiles.clear(); gDownsampleDepthProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER_ARB)); gDownsampleDepthProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDownsampleDepthProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gDownsampleDepthProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gDownsampleDepthProgram.createShader(NULL, NULL); } @@ -3253,7 +3726,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gBenchmarkProgram.mShaderFiles.clear(); gBenchmarkProgram.mShaderFiles.push_back(make_pair("interface/benchmarkV.glsl", GL_VERTEX_SHADER_ARB)); gBenchmarkProgram.mShaderFiles.push_back(make_pair("interface/benchmarkF.glsl", GL_FRAGMENT_SHADER_ARB)); - gBenchmarkProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gBenchmarkProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gBenchmarkProgram.createShader(NULL, NULL); } @@ -3263,17 +3736,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gDownsampleDepthRectProgram.mShaderFiles.clear(); gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER_ARB)); gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDownsampleDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; - success = gDownsampleDepthRectProgram.createShader(NULL, NULL); - } - - if (success) - { - gDownsampleDepthRectProgram.mName = "DownsampleDepthRect Shader"; - gDownsampleDepthRectProgram.mShaderFiles.clear(); - gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER_ARB)); - gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDownsampleDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gDownsampleDepthRectProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gDownsampleDepthRectProgram.createShader(NULL, NULL); } @@ -3283,13 +3746,13 @@ BOOL LLViewerShaderMgr::loadShadersInterface() gAlphaMaskProgram.mShaderFiles.clear(); gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskV.glsl", GL_VERTEX_SHADER_ARB)); gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskF.glsl", GL_FRAGMENT_SHADER_ARB)); - gAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + gAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; success = gAlphaMaskProgram.createShader(NULL, NULL); } if( !success ) { - mVertexShaderLevel[SHADER_INTERFACE] = 0; + mShaderLevel[SHADER_INTERFACE] = 0; return FALSE; } @@ -3300,36 +3763,79 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() { BOOL success = TRUE; - if (mVertexShaderLevel[SHADER_WINDLIGHT] < 2) + if (mShaderLevel[SHADER_WINDLIGHT] < 2) { gWLSkyProgram.unload(); gWLCloudProgram.unload(); + gWLSunProgram.unload(); + gWLMoonProgram.unload(); return TRUE; } - if (success) - { - gWLSkyProgram.mName = "Windlight Sky Shader"; - //gWLSkyProgram.mFeatures.hasGamma = true; - gWLSkyProgram.mShaderFiles.clear(); - gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyV.glsl", GL_VERTEX_SHADER_ARB)); - gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; - gWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; - success = gWLSkyProgram.createShader(NULL, NULL); - } - - if (success) - { - gWLCloudProgram.mName = "Windlight Cloud Program"; - //gWLCloudProgram.mFeatures.hasGamma = true; - gWLCloudProgram.mShaderFiles.clear(); - gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsV.glsl", GL_VERTEX_SHADER_ARB)); - gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); - gWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; - gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - success = gWLCloudProgram.createShader(NULL, NULL); - } + if (success) + { + gWLSkyProgram.mName = "Windlight Sky Shader"; + //gWLSkyProgram.mFeatures.hasGamma = true; + gWLSkyProgram.mShaderFiles.clear(); + gWLSkyProgram.mFeatures.calculatesAtmospherics = true; + gWLSkyProgram.mFeatures.hasTransport = true; + gWLSkyProgram.mFeatures.hasGamma = true; + gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyV.glsl", GL_VERTEX_SHADER_ARB)); + gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); + gWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; + gWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gWLSkyProgram.createShader(NULL, NULL); + } + + if (success) + { + gWLCloudProgram.mName = "Windlight Cloud Program"; + gWLCloudProgram.mShaderFiles.clear(); + gWLCloudProgram.mFeatures.calculatesAtmospherics = true; + gWLCloudProgram.mFeatures.hasTransport = true; + gWLCloudProgram.mFeatures.hasGamma = true; + gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsV.glsl", GL_VERTEX_SHADER_ARB)); + gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; + gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gWLCloudProgram.createShader(NULL, NULL); + } + + if (success) + { + gWLSunProgram.mName = "Windlight Sun Program"; + gWLSunProgram.mShaderFiles.clear(); + gWLSunProgram.mFeatures.calculatesAtmospherics = true; + gWLSunProgram.mFeatures.hasTransport = true; + gWLSunProgram.mFeatures.hasGamma = true; + gWLSunProgram.mFeatures.hasAtmospherics = true; + gWLSunProgram.mFeatures.isFullbright = true; + gWLSunProgram.mFeatures.disableTextureIndex = true; + gWLSunProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLSunProgram.mShaderFiles.push_back(make_pair("windlight/sunDiscV.glsl", GL_VERTEX_SHADER_ARB)); + gWLSunProgram.mShaderFiles.push_back(make_pair("windlight/sunDiscF.glsl", GL_FRAGMENT_SHADER_ARB)); + gWLSunProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; + gWLSunProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gWLSunProgram.createShader(NULL, NULL); + } + + if (success) + { + gWLMoonProgram.mName = "Windlight Moon Program"; + gWLMoonProgram.mShaderFiles.clear(); + gWLMoonProgram.mFeatures.calculatesAtmospherics = true; + gWLMoonProgram.mFeatures.hasTransport = true; + gWLMoonProgram.mFeatures.hasGamma = true; + gWLMoonProgram.mFeatures.hasAtmospherics = true; + gWLMoonProgram.mFeatures.isFullbright = true; + gWLMoonProgram.mFeatures.disableTextureIndex = true; + gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonV.glsl", GL_VERTEX_SHADER_ARB)); + gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); + gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; + gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + success = gWLMoonProgram.createShader(NULL, NULL); + } return success; } @@ -3338,7 +3844,7 @@ BOOL LLViewerShaderMgr::loadTransformShaders() { BOOL success = TRUE; - if (mVertexShaderLevel[SHADER_TRANSFORM] < 1) + if (mShaderLevel[SHADER_TRANSFORM] < 1) { gTransformPositionProgram.unload(); gTransformTexCoordProgram.unload(); @@ -3350,10 +3856,10 @@ BOOL LLViewerShaderMgr::loadTransformShaders() if (success) { - gTransformPositionProgram.mName = "Position Transform Shader"; + gTransformPositionProgram.mName = "Position Transform Shader"; gTransformPositionProgram.mShaderFiles.clear(); gTransformPositionProgram.mShaderFiles.push_back(make_pair("transform/positionV.glsl", GL_VERTEX_SHADER_ARB)); - gTransformPositionProgram.mShaderLevel = mVertexShaderLevel[SHADER_TRANSFORM]; + gTransformPositionProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; const char* varyings[] = { "position_out", @@ -3368,7 +3874,7 @@ BOOL LLViewerShaderMgr::loadTransformShaders() gTransformTexCoordProgram.mName = "TexCoord Transform Shader"; gTransformTexCoordProgram.mShaderFiles.clear(); gTransformTexCoordProgram.mShaderFiles.push_back(make_pair("transform/texcoordV.glsl", GL_VERTEX_SHADER_ARB)); - gTransformTexCoordProgram.mShaderLevel = mVertexShaderLevel[SHADER_TRANSFORM]; + gTransformTexCoordProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; const char* varyings[] = { "texcoord_out", @@ -3382,7 +3888,7 @@ BOOL LLViewerShaderMgr::loadTransformShaders() gTransformNormalProgram.mName = "Normal Transform Shader"; gTransformNormalProgram.mShaderFiles.clear(); gTransformNormalProgram.mShaderFiles.push_back(make_pair("transform/normalV.glsl", GL_VERTEX_SHADER_ARB)); - gTransformNormalProgram.mShaderLevel = mVertexShaderLevel[SHADER_TRANSFORM]; + gTransformNormalProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; const char* varyings[] = { "normal_out", @@ -3396,7 +3902,7 @@ BOOL LLViewerShaderMgr::loadTransformShaders() gTransformColorProgram.mName = "Color Transform Shader"; gTransformColorProgram.mShaderFiles.clear(); gTransformColorProgram.mShaderFiles.push_back(make_pair("transform/colorV.glsl", GL_VERTEX_SHADER_ARB)); - gTransformColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_TRANSFORM]; + gTransformColorProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; const char* varyings[] = { "color_out", @@ -3410,7 +3916,7 @@ BOOL LLViewerShaderMgr::loadTransformShaders() gTransformTangentProgram.mName = "Binormal Transform Shader"; gTransformTangentProgram.mShaderFiles.clear(); gTransformTangentProgram.mShaderFiles.push_back(make_pair("transform/binormalV.glsl", GL_VERTEX_SHADER_ARB)); - gTransformTangentProgram.mShaderLevel = mVertexShaderLevel[SHADER_TRANSFORM]; + gTransformTangentProgram.mShaderLevel = mShaderLevel[SHADER_TRANSFORM]; const char* varyings[] = { "tangent_out", @@ -3430,8 +3936,7 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void) void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) { - LLWLParamManager::getInstance()->updateShaderUniforms(shader); - LLWaterParamManager::getInstance()->updateShaderUniforms(shader); + LLEnvironment::instance().updateShaderUniforms(shader); } LLViewerShaderMgr::shader_iter LLViewerShaderMgr::beginShaders() const diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 923aa522ad..66cb80657f 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -48,7 +48,7 @@ public: void initAttribsAndUniforms(void); void setShaders(); void unloadShaders(); - S32 getVertexShaderLevel(S32 type); + S32 getShaderLevel(S32 type); BOOL loadBasicShaders(); BOOL loadShadersEffects(); BOOL loadShadersDeferred(); @@ -60,7 +60,7 @@ public: BOOL loadShadersWindLight(); BOOL loadTransformShaders(); - std::vector<S32> mVertexShaderLevel; + std::vector<S32> mShaderLevel; S32 mMaxAvatarShaderLevel; enum EShaderClass @@ -129,24 +129,6 @@ public: /* virtual */ void updateShaderUniforms(LLGLSLShader * shader); private: - - std::vector<std::string> mShinyUniforms; - - //water parameters - std::vector<std::string> mWaterUniforms; - - std::vector<std::string> mWLUniforms; - - //terrain parameters - std::vector<std::string> mTerrainUniforms; - - //glow parameters - std::vector<std::string> mGlowUniforms; - - std::vector<std::string> mGlowExtractUniforms; - - std::vector<std::string> mAvatarUniforms; - // the list of shaders we need to propagate parameters to. std::vector<LLGLSLShader *> mShaderList; @@ -255,6 +237,7 @@ extern LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; extern LLGLSLShader gTerrainProgram; extern LLGLSLShader gTerrainWaterProgram; extern LLGLSLShader gWaterProgram; +extern LLGLSLShader gWaterEdgeProgram; extern LLGLSLShader gUnderWaterProgram; extern LLGLSLShader gGlowProgram; extern LLGLSLShader gGlowExtractProgram; @@ -277,6 +260,8 @@ extern LLGLSLShader gImpostorProgram; // WindLight shader handles extern LLGLSLShader gWLSkyProgram; extern LLGLSLShader gWLCloudProgram; +extern LLGLSLShader gWLSunProgram; +extern LLGLSLShader gWLMoonProgram; // Post Process Shaders extern LLGLSLShader gPostColorFilterProgram; @@ -297,6 +282,7 @@ extern LLGLSLShader gDeferredSkinnedBumpProgram; extern LLGLSLShader gDeferredSkinnedAlphaProgram; extern LLGLSLShader gDeferredBumpProgram; extern LLGLSLShader gDeferredTerrainProgram; +extern LLGLSLShader gDeferredTerrainWaterProgram; extern LLGLSLShader gDeferredTreeProgram; extern LLGLSLShader gDeferredTreeShadowProgram; extern LLGLSLShader gDeferredLightProgram; @@ -331,6 +317,8 @@ extern LLGLSLShader gDeferredAvatarEyesProgram; extern LLGLSLShader gDeferredAvatarAlphaProgram; extern LLGLSLShader gDeferredWLSkyProgram; extern LLGLSLShader gDeferredWLCloudProgram; +extern LLGLSLShader gDeferredWLSunProgram; +extern LLGLSLShader gDeferredWLMoonProgram; extern LLGLSLShader gDeferredStarProgram; extern LLGLSLShader gDeferredFullbrightShinyProgram; extern LLGLSLShader gDeferredSkinnedFullbrightShinyProgram; diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 7d2d6e25c7..6899424cf6 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -31,6 +31,7 @@ #include "llagent.h" #include "llaudioengine.h" #include "llavataractions.h" +#include "llenvironment.h" #include "llfloaterreg.h" #include "llfloatersidepanelcontainer.h" #include "llfloaterworldmap.h" @@ -540,7 +541,9 @@ LLUIImagePtr LLEmbeddedItems::getItemImage(llwchar ext_char) const case LLAssetType::AT_ANIMATION: img_name = "Inv_Animation"; break; case LLAssetType::AT_GESTURE: img_name = "Inv_Gesture"; break; case LLAssetType::AT_MESH: img_name = "Inv_Mesh"; break; - default: img_name = "Inv_Invalid"; break; // use the Inv_Invalid icon for undefined object types (see MAINT-3981) + case LLAssetType::AT_SETTINGS: img_name = "Inv_Settings"; break; + default: img_name = "Inv_Invalid"; break; // use the Inv_Invalid icon for undefined object types (see MAINT-3981) + } return LLUI::getUIImage(img_name); @@ -852,8 +855,18 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, if (getEnabled() && acceptsTextInput()) { + bool supported = false; switch( cargo_type ) { + case DAD_SETTINGS: + { + supported = LLEnvironment::instance().isExtendedEnvironmentEnabled(); + if (!supported && tooltip_msg.empty()) + { + tooltip_msg.assign(LLTrans::getString("TooltipNotecardNotAllowedTypeDrop")); + } + break; + } case DAD_CALLINGCARD: case DAD_TEXTURE: case DAD_SOUND: @@ -867,52 +880,50 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, case DAD_GESTURE: case DAD_MESH: { - LLInventoryItem *item = (LLInventoryItem *)cargo_data; - if( item && allowsEmbeddedItems() ) + supported = true; + break; + } + + default: + supported = false; + break; + } + + LLInventoryItem *item = (LLInventoryItem *)cargo_data; + if (item && allowsEmbeddedItems() && supported) + { + U32 mask_next = item->getPermissions().getMaskNextOwner(); + if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) + { + if( drop ) { - U32 mask_next = item->getPermissions().getMaskNextOwner(); - if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) - { - if( drop ) - { - deselect(); - S32 old_cursor = mCursorPos; - setCursorAtLocalPos( x, y, TRUE ); - S32 insert_pos = mCursorPos; - setCursorPos(old_cursor); - BOOL inserted = insertEmbeddedItem( insert_pos, item ); - if( inserted && (old_cursor > mCursorPos) ) - { - setCursorPos(mCursorPos + 1); - } - - needsReflow(); - - } - *accept = ACCEPT_YES_COPY_MULTI; - } - else + deselect(); + S32 old_cursor = mCursorPos; + setCursorAtLocalPos( x, y, TRUE ); + S32 insert_pos = mCursorPos; + setCursorPos(old_cursor); + BOOL inserted = insertEmbeddedItem( insert_pos, item ); + if( inserted && (old_cursor > mCursorPos) ) { - *accept = ACCEPT_NO; - if (tooltip_msg.empty()) - { - // *TODO: Translate - tooltip_msg.assign("Only items with unrestricted\n" - "'next owner' permissions \n" - "can be attached to notecards."); - } + setCursorPos(mCursorPos + 1); } + + needsReflow(); } - else + *accept = ACCEPT_YES_COPY_MULTI; + } + else + { + *accept = ACCEPT_NO; + if (tooltip_msg.empty()) { - *accept = ACCEPT_NO; + tooltip_msg.assign(LLTrans::getString("TooltipNotecardOwnerRestrictedDrop")); } - break; } - - default: + } + else + { *accept = ACCEPT_NO; - break; } } else @@ -1112,7 +1123,9 @@ BOOL LLViewerTextEditor::openEmbeddedItem(LLPointer<LLInventoryItem> item, llwch case LLAssetType::AT_CALLINGCARD: openEmbeddedCallingcard( item, wc ); return TRUE; - + case LLAssetType::AT_SETTINGS: + openEmbeddedSetting(item, wc); + return TRUE; case LLAssetType::AT_NOTECARD: case LLAssetType::AT_LSL_TEXT: case LLAssetType::AT_CLOTHING: @@ -1187,6 +1200,18 @@ void LLViewerTextEditor::openEmbeddedCallingcard( LLInventoryItem* item, llwchar } } +void LLViewerTextEditor::openEmbeddedSetting(LLInventoryItem* item, llwchar wc) +{ + if (LLEnvironment::instance().isInventoryEnabled()) + { + showCopyToInvDialog(item, wc); + } + else + { + LLNotificationsUtil::add("NoEnvironmentSettings"); + } +} + void LLViewerTextEditor::showUnsavedAlertDialog( LLInventoryItem* item ) { LLSD payload; diff --git a/indra/newview/llviewertexteditor.h b/indra/newview/llviewertexteditor.h index 44f104dde1..a6d7fef409 100644 --- a/indra/newview/llviewertexteditor.h +++ b/indra/newview/llviewertexteditor.h @@ -107,6 +107,7 @@ private: void openEmbeddedSound( LLInventoryItem* item, llwchar wc ); void openEmbeddedLandmark( LLPointer<LLInventoryItem> item_ptr, llwchar wc ); void openEmbeddedCallingcard( LLInventoryItem* item, llwchar wc); + void openEmbeddedSetting(LLInventoryItem* item, llwchar wc); void showCopyToInvDialog( LLInventoryItem* item, llwchar wc ); void showUnsavedAlertDialog( LLInventoryItem* item ); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 41da58f94f..1ba7a7b2b9 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -98,8 +98,8 @@ const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64; const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez; const S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128; const S32 DEFAULT_ICON_DIMENTIONS = 32; -S32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256. -S32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA; +U32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256. +U32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA; BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE; F32 LLViewerTexture::sCurrentTime = 0.0f; F32 LLViewerTexture::sTexelPixelRatio = 1.0f; diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 5d89f9f029..022f937619 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -125,6 +125,8 @@ public: virtual BOOL isMissingAsset() const ; virtual void dump(); // debug info to LL_INFOS() + virtual BOOL isViewerMediaTexture() const { return false; } + /*virtual*/ bool bindDefaultImage(const S32 stage = 0) ; /*virtual*/ bool bindDebugImage(const S32 stage = 0) ; /*virtual*/ void forceImmediateUpdate() ; @@ -225,8 +227,8 @@ public: static S8 sCameraMovingDiscardBias; static F32 sCameraMovingBias; static S32 sMaxSculptRez ; - static S32 sMinLargeImageSize ; - static S32 sMaxSmallImageSize ; + static U32 sMinLargeImageSize ; + static U32 sMaxSmallImageSize ; static BOOL sFreezeImageScalingDown ;//do not scale down image res if set. static F32 sCurrentTime ; @@ -576,6 +578,8 @@ public: BOOL isPlaying() const {return mIsPlaying;} void setMediaImpl() ; + virtual BOOL isViewerMediaTexture() const { return true; } + void initVirtualSize() ; void invalidateMediaImpl() ; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 43e803fe7a..3421b99ba4 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -360,6 +360,8 @@ public: static const std::string beacon_scripted_touch = LLTrans::getString("BeaconScriptedTouch"); static const std::string beacon_sound = LLTrans::getString("BeaconSound"); static const std::string beacon_media = LLTrans::getString("BeaconMedia"); + static const std::string beacon_sun = LLTrans::getString("BeaconSun"); + static const std::string beacon_moon = LLTrans::getString("BeaconMoon"); static const std::string particle_hiding = LLTrans::getString("ParticleHiding"); // Draw the statistics in a light gray @@ -604,7 +606,7 @@ public: addText(xpos, ypos, llformat("%d Unique Textures", LLImageGL::sUniqueCount)); ypos += y_inc; - addText(xpos, ypos, llformat("%d Render Calls", last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize))); + addText(xpos, ypos, llformat("%d Render Calls", (U32)last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize))); ypos += y_inc; addText(xpos, ypos, llformat("%d/%d Objects Active", gObjectList.getNumActiveObjects(), gObjectList.getNumObjects())); @@ -794,6 +796,20 @@ public: } } + static LLUICachedControl<bool> show_sun_beacon("sunbeacon", false); + static LLUICachedControl<bool> show_moon_beacon("moonbeacon", false); + + if (show_sun_beacon) + { + addText(xpos, ypos, beacon_sun); + ypos += y_inc; + } + if (show_moon_beacon) + { + addText(xpos, ypos, beacon_moon); + ypos += y_inc; + } + if(log_texture_traffic) { U32 old_y = ypos ; @@ -1714,7 +1730,7 @@ LLViewerWindow::LLViewerWindow(const Params& p) U32 fsaa_samples) */ // create window - mWindow = LLWindowManager::createWindow(this, + mWindow = LLWindowManager::createWindow(this, p.title, p.name, p.x, p.y, p.width, p.height, 0, p.fullscreen, gHeadlessClient, @@ -1823,11 +1839,6 @@ LLViewerWindow::LLViewerWindow(const Params& p) LLFeatureManager::getInstance()->applyRecommendedSettings(); gSavedSettings.setBOOL("ProbeHardwareOnStartup", FALSE); } - - if (!gGLManager.mHasDepthClamp) - { - LL_INFOS("RenderInit") << "Missing feature GL_ARB_depth_clamp. Void water might disappear in rare cases." << LL_ENDL; - } // If we crashed while initializng GL stuff last time, disable certain features if (gSavedSettings.getBOOL("RenderInitError")) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 321f774210..d13b926930 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2950,7 +2950,7 @@ void LLVOAvatar::idleUpdateLoadingEffect() void LLVOAvatar::idleUpdateWindEffect() { // update wind effect - if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)) + if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)) { F32 hover_strength = 0.f; F32 time_delta = mRippleTimer.getElapsedTimeF32() - mRippleTimeLast; @@ -4651,7 +4651,7 @@ U32 LLVOAvatar::renderSkinned() } } - if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0) + if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0) { if (mNeedsSkin) { @@ -9745,7 +9745,7 @@ void LLVOAvatar::updateImpostors() iter != instances_copy.end(); ++iter) { LLVOAvatar* avatar = (LLVOAvatar*) *iter; - if (!avatar->isDead() && avatar->isVisible() + if (avatar && !avatar->isDead() && avatar->isVisible() && ( (avatar->isImpostor() || LLVOAvatar::AV_DO_NOT_RENDER == avatar->getVisualMuteSettings()) && avatar->needsImpostorUpdate()) ) diff --git a/indra/newview/llvoground.cpp b/indra/newview/llvoground.cpp index 71a7623fb4..52a6395618 100644 --- a/indra/newview/llvoground.cpp +++ b/indra/newview/llvoground.cpp @@ -126,7 +126,7 @@ BOOL LLVOGround::updateGeometry(LLDrawable *drawable) left_dir.normVec(); // Our center top point - LLColor4 ground_color = gSky.getFogColor(); + LLColor4 ground_color = gSky.getSkyFogColor(); ground_color.mV[3] = 1.f; face->setFaceColor(ground_color); diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index c131cb886f..96363045d3 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -48,152 +48,42 @@ #include "llworld.h" #include "pipeline.h" #include "lldrawpoolwlsky.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" +#include "v3colorutil.h" -#undef min -#undef max - -static const S32 NUM_TILES_X = 8; -static const S32 NUM_TILES_Y = 4; -static const S32 NUM_TILES = NUM_TILES_X * NUM_TILES_Y; +#include "llsettingssky.h" +#include "llenvironment.h" -// Heavenly body constants -static const F32 SUN_DISK_RADIUS = 0.5f; -static const F32 MOON_DISK_RADIUS = SUN_DISK_RADIUS * 0.9f; -static const F32 SUN_INTENSITY = 1e5; +#include "lltrace.h" +#include "llfasttimer.h" -// Texture coordinates: -static const LLVector2 TEX00 = LLVector2(0.f, 0.f); -static const LLVector2 TEX01 = LLVector2(0.f, 1.f); -static const LLVector2 TEX10 = LLVector2(1.f, 0.f); -static const LLVector2 TEX11 = LLVector2(1.f, 1.f); - -// Exported globals -LLUUID gSunTextureID = IMG_SUN; -LLUUID gMoonTextureID = IMG_MOON; +#undef min +#undef max -class LLFastLn +namespace { -public: - LLFastLn() - { - mTable[0] = 0; - for( S32 i = 1; i < 257; i++ ) - { - mTable[i] = log((F32)i); - } - } - - F32 ln( F32 x ) - { - const F32 OO_255 = 0.003921568627450980392156862745098f; - const F32 LN_255 = 5.5412635451584261462455391880218f; + const S32 NUM_TILES_X = 8; + const S32 NUM_TILES_Y = 4; + const S32 NUM_TILES = NUM_TILES_X * NUM_TILES_Y; - if( x < OO_255 ) - { - return log(x); - } - else - if( x < 1 ) - { - x *= 255.f; - S32 index = llfloor(x); - F32 t = x - index; - F32 low = mTable[index]; - F32 high = mTable[index + 1]; - return low + t * (high - low) - LN_255; - } - else - if( x <= 255 ) - { - S32 index = llfloor(x); - F32 t = x - index; - F32 low = mTable[index]; - F32 high = mTable[index + 1]; - return low + t * (high - low); - } - else - { - return log( x ); - } - } - - F32 pow( F32 x, F32 y ) - { - return (F32)LL_FAST_EXP(y * ln(x)); - } + // Heavenly body constants + const F32 SUN_DISK_RADIUS = 0.5f; + const F32 MOON_DISK_RADIUS = SUN_DISK_RADIUS * 0.9f; + const F32 SUN_INTENSITY = 1e5; + // Texture coordinates: + const LLVector2 TEX00 = LLVector2(0.f, 0.f); + const LLVector2 TEX01 = LLVector2(0.f, 1.f); + const LLVector2 TEX10 = LLVector2(1.f, 0.f); + const LLVector2 TEX11 = LLVector2(1.f, 1.f); -private: - F32 mTable[257]; // index 0 is unused -}; + const F32 LIGHT_DIRECTION_THRESHOLD = (F32) cosf(DEG_TO_RAD * 1.f); + const F32 COLOR_CHANGE_THRESHOLD = 0.01f; -static LLFastLn gFastLn; + LLTrace::BlockTimerStatHandle FTM_VOSKY_UPDATETIMER("VOSky Update Timer Tick"); + LLTrace::BlockTimerStatHandle FTM_VOSKY_UPDATEFORCED("VOSky Update Forced"); - -// Functions used a lot. - -inline F32 LLHaze::calcPhase(const F32 cos_theta) const -{ - const F32 g2 = mG * mG; - const F32 den = 1 + g2 - 2 * mG * cos_theta; - return (1 - g2) * gFastLn.pow(den, -1.5); -} - -inline void color_pow(LLColor3 &col, const F32 e) -{ - col.mV[0] = gFastLn.pow(col.mV[0], e); - col.mV[1] = gFastLn.pow(col.mV[1], e); - col.mV[2] = gFastLn.pow(col.mV[2], e); -} - -inline LLColor3 color_norm(const LLColor3 &col) -{ - const F32 m = color_max(col); - if (m > 1.f) - { - return 1.f/m * col; - } - else return col; -} - -inline void color_gamma_correct(LLColor3 &col) -{ - const F32 gamma_inv = 1.f/1.2f; - if (col.mV[0] != 0.f) - { - col.mV[0] = gFastLn.pow(col.mV[0], gamma_inv); - } - if (col.mV[1] != 0.f) - { - col.mV[1] = gFastLn.pow(col.mV[1], gamma_inv); - } - if (col.mV[2] != 0.f) - { - col.mV[2] = gFastLn.pow(col.mV[2], gamma_inv); - } -} - -static LLColor3 calc_air_sca_sea_level() -{ - static LLColor3 WAVE_LEN(675, 520, 445); - static LLColor3 refr_ind = refr_ind_calc(WAVE_LEN); - static LLColor3 n21 = refr_ind * refr_ind - LLColor3(1, 1, 1); - static LLColor3 n4 = n21 * n21; - static LLColor3 wl2 = WAVE_LEN * WAVE_LEN * 1e-6f; - static LLColor3 wl4 = wl2 * wl2; - static LLColor3 mult_const = fsigma * 2.0f/ 3.0f * 1e24f * (F_PI * F_PI) * n4; - static F32 dens_div_N = F32( ATM_SEA_LEVEL_NDENS / Ndens2); - return dens_div_N * color_div ( mult_const, wl4 ); + F32Seconds UPDATE_EXPRY(2.0f); } - -// static constants. -LLColor3 const LLHaze::sAirScaSeaLevel = calc_air_sca_sea_level(); -F32 const LLHaze::sAirScaIntense = color_intens(LLHaze::sAirScaSeaLevel); -F32 const LLHaze::sAirScaAvg = LLHaze::sAirScaIntense / 3.f; - - /*************************************** SkyTex ***************************************/ @@ -249,6 +139,32 @@ LLSkyTex::~LLSkyTex() mSkyDirs = NULL; } +S32 LLSkyTex::getResolution() +{ + return sResolution; +} + +S32 LLSkyTex::getCurrent() +{ + return sCurrent; +} + +S32 LLSkyTex::stepCurrent() { + sCurrent++; + sCurrent &= 1; + return sCurrent; +} + +S32 LLSkyTex::getNext() +{ + return ((sCurrent+1) & 1); +} + +S32 LLSkyTex::getWhich(const BOOL curr) +{ + int tex = curr ? sCurrent : getNext(); + return tex; +} void LLSkyTex::initEmpty(const S32 tex) { @@ -289,9 +205,6 @@ void LLSkyTex::create(const F32 brightness) createGLImage(sCurrent); } - - - void LLSkyTex::createGLImage(S32 which) { mTexture[which]->createGLTexture(0, mImageRaw[which], 0, TRUE, LLGLTexture::LOCAL); @@ -300,15 +213,186 @@ void LLSkyTex::createGLImage(S32 which) void LLSkyTex::bindTexture(BOOL curr) { - gGL.getTexUnit(0)->bind(mTexture[getWhich(curr)], true); + int tex = getWhich(curr); + gGL.getTexUnit(0)->bind(mTexture[tex], true); +} + +LLImageRaw* LLSkyTex::getImageRaw(BOOL curr) +{ + int tex = getWhich(curr); + return mImageRaw[tex]; } /*************************************** - Sky + LLHeavenBody ***************************************/ F32 LLHeavenBody::sInterpVal = 0; +LLHeavenBody::LLHeavenBody(const F32 rad) +: mDirectionCached(LLVector3(0,0,0)), + mDirection(LLVector3(0,0,0)), + mIntensity(0.f), + mDiskRadius(rad), + mDraw(FALSE), + mHorizonVisibility(1.f), + mVisibility(1.f), + mVisible(FALSE) +{ + mColor.setToBlack(); + mColorCached.setToBlack(); +} + +const LLQuaternion& LLHeavenBody::getRotation() const +{ + return mRotation; +} + +void LLHeavenBody::setRotation(const LLQuaternion& rot) +{ + mRotation = rot; +} + +const LLVector3& LLHeavenBody::getDirection() const +{ + return mDirection; +} + +void LLHeavenBody::setDirection(const LLVector3 &direction) +{ + mDirection = direction; +} + +void LLHeavenBody::setAngularVelocity(const LLVector3 &ang_vel) +{ + mAngularVelocity = ang_vel; +} + +const LLVector3& LLHeavenBody::getAngularVelocity() const +{ + return mAngularVelocity; +} + +const LLVector3& LLHeavenBody::getDirectionCached() const +{ + return mDirectionCached; +} + +void LLHeavenBody::renewDirection() +{ + mDirectionCached = mDirection; +} + +const LLColor3& LLHeavenBody::getColorCached() const +{ + return mColorCached; +} + +void LLHeavenBody::setColorCached(const LLColor3& c) +{ + mColorCached = c; +} + +const LLColor3& LLHeavenBody::getColor() const +{ + return mColor; +} + +void LLHeavenBody::setColor(const LLColor3& c) +{ + mColor = c; +} + +void LLHeavenBody::renewColor() +{ + mColorCached = mColor; +} + +F32 LLHeavenBody::interpVal() +{ + return sInterpVal; +} + +void LLHeavenBody::setInterpVal(const F32 v) +{ + sInterpVal = v; +} + +LLColor3 LLHeavenBody::getInterpColor() const +{ + return sInterpVal * mColor + (1 - sInterpVal) * mColorCached; +} + +const F32& LLHeavenBody::getVisibility() const +{ + return mVisibility; +} + +void LLHeavenBody::setVisibility(const F32 c) +{ + mVisibility = c; +} + +bool LLHeavenBody::isVisible() const +{ + return mVisible; +} + +void LLHeavenBody::setVisible(const bool v) +{ + mVisible = v; +} + +const F32& LLHeavenBody::getIntensity() const +{ + return mIntensity; +} + +void LLHeavenBody::setIntensity(const F32 c) +{ + mIntensity = c; +} + +void LLHeavenBody::setDiskRadius(const F32 radius) +{ + mDiskRadius = radius; +} + +F32 LLHeavenBody::getDiskRadius() const +{ + return mDiskRadius; +} + +void LLHeavenBody::setDraw(const bool draw) +{ + mDraw = draw; +} + +bool LLHeavenBody::getDraw() const +{ + return mDraw; +} + +const LLVector3& LLHeavenBody::corner(const S32 n) const +{ + return mQuadCorner[n]; +} + +LLVector3& LLHeavenBody::corner(const S32 n) +{ + return mQuadCorner[n]; +} + +const LLVector3* LLHeavenBody::corners() const +{ + return mQuadCorner; +} + +/*************************************** + Sky +***************************************/ + + S32 LLVOSky::sResolution = LLSkyTex::getResolution(); S32 LLVOSky::sTileResX = sResolution/NUM_TILES_X; S32 LLVOSky::sTileResY = sResolution/NUM_TILES_Y; @@ -326,32 +410,15 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mWorldScale(1.f), mBumpSunDir(0.f, 0.f, 1.f) { - bool error = false; - /// WL PARAMS - dome_radius = 1.f; - dome_offset_ratio = 0.f; - sunlight_color = LLColor3(); - ambient = LLColor3(); - gamma = 1.f; - lightnorm = LLVector4(); - blue_density = LLColor3(); - blue_horizon = LLColor3(); - haze_density = 0.f; - haze_horizon = 1.f; - density_multiplier = 0.f; - max_y = 0.f; - glow = LLColor3(); - cloud_shadow = 0.f; - cloud_color = LLColor3(); - cloud_scale = 0.f; - cloud_pos_density1 = LLColor3(); - cloud_pos_density2 = LLColor3(); mInitialized = FALSE; mbCanSelect = FALSE; mUpdateTimer.reset(); + mForceUpdateThrottle.setTimerExpirySec(UPDATE_EXPRY); + mForceUpdateThrottle.reset(); + for (S32 i = 0; i < 6; i++) { mSkyTex[i].init(); @@ -366,33 +433,13 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mAtmHeight = ATM_HEIGHT; mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); - mSunDefaultPosition = LLVector3(LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error)); - if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition")) - { - initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0)); - } - mAmbientScale = gSavedSettings.getF32("SkyAmbientScale"); - mNightColorShift = gSavedSettings.getColor3("SkyNightColorShift"); - mFogColor.mV[VRED] = mFogColor.mV[VGREEN] = mFogColor.mV[VBLUE] = 0.5f; - mFogColor.mV[VALPHA] = 0.0f; - mFogRatio = 1.2f; - mSun.setIntensity(SUN_INTENSITY); mMoon.setIntensity(0.1f * SUN_INTENSITY); - mSunTexturep = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - mSunTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mMoonTexturep = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - mMoonTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mBloomTexturep = LLViewerTextureManager::getFetchedTexture(IMG_BLOOM1); - mBloomTexturep->setNoDelete() ; - mBloomTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mHeavenlyBodyUpdated = FALSE ; mDrawRefl = 0; - mHazeConcentration = 0.f; - mInterpVal = 0.f; + mInterpVal = 0.f; } @@ -406,11 +453,32 @@ LLVOSky::~LLVOSky() void LLVOSky::init() { - const F32 haze_int = color_intens(mHaze.calcSigSca(0)); - mHazeConcentration = haze_int / - (color_intens(LLHaze::calcAirSca(0)) + haze_int); - - calcAtmospherics(); + llassert(!mInitialized); + + // Update sky at least once to get correct initial sun/moon directions and lighting calcs performed + LLEnvironment::instance().getCurrentSky()->update(); + + updateDirections(); + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + // invariants across whole sky tex process... + m_atmosphericsVars.blue_density = psky->getBlueDensity(); + m_atmosphericsVars.blue_horizon = psky->getBlueHorizon(); + m_atmosphericsVars.haze_density = psky->getHazeDensity(); + m_atmosphericsVars.haze_horizon = psky->getHazeHorizon(); + m_atmosphericsVars.density_multiplier = psky->getDensityMultiplier(); + m_atmosphericsVars.max_y = psky->getMaxY(); + m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedSunNorm(); + m_atmosphericsVars.sunlight = psky->getSunlightColor(); + m_atmosphericsVars.ambient = psky->getAmbientColor(); + m_atmosphericsVars.glow = psky->getGlow(); + m_atmosphericsVars.cloud_shadow = psky->getCloudShadow(); + m_atmosphericsVars.dome_radius = psky->getDomeRadius(); + m_atmosphericsVars.dome_offset = psky->getDomeOffset(); + m_atmosphericsVars.light_atten = psky->getLightAttenuation(m_atmosphericsVars.max_y); + m_atmosphericsVars.light_transmittance = psky->getLightTransmittance(); + m_atmosphericsVars.gamma = psky->getGamma(); // Initialize the cached normalized direction vectors for (S32 side = 0; side < 6; ++side) @@ -418,7 +486,7 @@ void LLVOSky::init() for (S32 tile = 0; tile < NUM_TILES; ++tile) { initSkyTextureDirs(side, tile); - createSkyTexture(side, tile); + createSkyTexture(m_atmosphericsVars, side, tile, false); } } @@ -429,9 +497,107 @@ void LLVOSky::init() } initCubeMap(); + mInitialized = true; mHeavenlyBodyUpdated = FALSE ; + + mRainbowMap = LLViewerTextureManager::getFetchedTexture(psky->getRainbowTextureId(), FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + mHaloMap = LLViewerTextureManager::getFetchedTexture(psky->getHaloTextureId(), FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); +} + + +void LLVOSky::calc() +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + // invariants across whole sky tex process... + m_atmosphericsVars.blue_density = psky->getBlueDensity(); + m_atmosphericsVars.blue_horizon = psky->getBlueHorizon(); + m_atmosphericsVars.haze_density = psky->getHazeDensity(); + m_atmosphericsVars.haze_horizon = psky->getHazeHorizon(); + m_atmosphericsVars.density_multiplier = psky->getDensityMultiplier(); + m_atmosphericsVars.max_y = psky->getMaxY(); + m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedSunNorm(); + m_atmosphericsVars.sunlight = psky->getSunlightColor(); + m_atmosphericsVars.ambient = psky->getAmbientColor(); + m_atmosphericsVars.glow = psky->getGlow(); + m_atmosphericsVars.cloud_shadow = psky->getCloudShadow(); + m_atmosphericsVars.dome_radius = psky->getDomeRadius(); + m_atmosphericsVars.dome_offset = psky->getDomeOffset(); + m_atmosphericsVars.light_atten = psky->getLightAttenuation(m_atmosphericsVars.max_y); + m_atmosphericsVars.light_transmittance = psky->getLightTransmittance(); + m_atmosphericsVars.gamma = psky->getGamma(); + + LLColor3 vary_HazeColor; + LLColor3 vary_SunlightColor; + LLColor3 vary_AmbientColor; + { + // Initialize temp variables + LLColor3 sunlight = m_atmosphericsVars.sunlight; + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + LLColor3 light_atten = + (m_atmosphericsVars.blue_density * 1.0 + smear(m_atmosphericsVars.haze_density * 0.25f)) * (m_atmosphericsVars.density_multiplier * m_atmosphericsVars.max_y); + + // Calculate relative weights + LLColor3 temp2(0.f, 0.f, 0.f); + LLColor3 temp1 = m_atmosphericsVars.blue_density + smear(m_atmosphericsVars.haze_density); + LLColor3 blue_weight = componentDiv(m_atmosphericsVars.blue_density, temp1); + LLColor3 haze_weight = componentDiv(smear(m_atmosphericsVars.haze_density), temp1); + + // Compute sunlight from P & lightnorm (for long rays like sky) + /// USE only lightnorm. + // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); + F32 lighty = getSun().getDirection().mV[2]; + temp2.mV[1] = llmax(0.f, lighty); + if(temp2.mV[1] > 0.f) + { + temp2.mV[1] = 1.f / temp2.mV[1]; + } + componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + + // Distance + temp2.mV[2] = m_atmosphericsVars.density_multiplier; + + // Transparency (-> temp1) + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); + + // vary_AtmosAttenuation = temp1; + + //increase ambient when there are more clouds + LLColor3 tmpAmbient = m_atmosphericsVars.ambient + (smear(1.f) - m_atmosphericsVars.ambient) * m_atmosphericsVars.cloud_shadow * 0.5f; + + //haze color + vary_HazeColor = + (m_atmosphericsVars.blue_horizon * blue_weight * (sunlight * (1.f - m_atmosphericsVars.cloud_shadow) + tmpAmbient) + + componentMult(m_atmosphericsVars.haze_horizon * haze_weight, sunlight * (1.f - m_atmosphericsVars.cloud_shadow) * temp2.mV[0] + tmpAmbient) + ); + + //brightness of surface both sunlight and ambient + vary_SunlightColor = componentMult(sunlight, temp1) * 1.f; + vary_SunlightColor.clamp(); + vary_SunlightColor = smear(1.0f) - vary_SunlightColor; + vary_SunlightColor = componentPow(vary_SunlightColor, m_atmosphericsVars.gamma); + vary_SunlightColor = smear(1.0f) - vary_SunlightColor; + vary_AmbientColor = componentMult(tmpAmbient, temp1) * 0.5; + vary_AmbientColor.clamp(); + vary_AmbientColor = smear(1.0f) - vary_AmbientColor; + vary_AmbientColor = componentPow(vary_AmbientColor, m_atmosphericsVars.gamma); + vary_AmbientColor = smear(1.0f) - vary_AmbientColor; + + componentMultBy(vary_HazeColor, LLColor3(1.f, 1.f, 1.f) - temp1); + + } + + mSun.setColor(vary_SunlightColor); + mMoon.setColor(LLColor3(1.0f, 1.0f, 1.0f)); + + mSun.renewDirection(); + mSun.renewColor(); + mMoon.renewDirection(); + mMoon.renewColor(); } void LLVOSky::initCubeMap() @@ -474,15 +640,16 @@ void LLVOSky::restoreGL() { mSkyTex[i].restoreGL(); } - mSunTexturep = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - mSunTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mMoonTexturep = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - mMoonTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mBloomTexturep = LLViewerTextureManager::getFetchedTexture(IMG_BLOOM1); - mBloomTexturep->setNoDelete() ; - mBloomTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - calcAtmospherics(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + if (psky) + { + setSunTextures(psky->getSunTextureId(), psky->getNextSunTextureId()); + setMoonTextures(psky->getMoonTextureId(), psky->getNextMoonTextureId()); + } + + updateDirections(); if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) @@ -498,10 +665,11 @@ void LLVOSky::restoreGL() if(cube_map) { cube_map->init(images); - mForceUpdate = TRUE; } } + mForceUpdate = TRUE; + if (mDrawable) { gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); @@ -541,7 +709,7 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) } } -void LLVOSky::createSkyTexture(const S32 side, const S32 tile) +void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, bool skip_sky_tex) { S32 tile_x = tile % NUM_TILES_X; S32 tile_y = tile / NUM_TILES_X; @@ -550,495 +718,58 @@ void LLVOSky::createSkyTexture(const S32 side, const S32 tile) S32 tile_y_pos = tile_y * sTileResY; S32 x, y; + if (!skip_sky_tex) + { + for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) + { + for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) + { + mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, mSkyTex[side].getDir(x, y)), x, y); + } + } + } + for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) { for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) { - mSkyTex[side].setPixel(calcSkyColorInDir(mSkyTex[side].getDir(x, y)), x, y); - mShinyTex[side].setPixel(calcSkyColorInDir(mSkyTex[side].getDir(x, y), true), x, y); - } - } -} - -static inline LLColor3 componentDiv(LLColor3 const &left, LLColor3 const & right) -{ - return LLColor3(left.mV[0]/right.mV[0], - left.mV[1]/right.mV[1], - left.mV[2]/right.mV[2]); -} - - -static inline LLColor3 componentMult(LLColor3 const &left, LLColor3 const & right) -{ - return LLColor3(left.mV[0]*right.mV[0], - left.mV[1]*right.mV[1], - left.mV[2]*right.mV[2]); -} - - -static inline LLColor3 componentExp(LLColor3 const &v) -{ - return LLColor3(exp(v.mV[0]), - exp(v.mV[1]), - exp(v.mV[2])); -} - -static inline LLColor3 componentPow(LLColor3 const &v, F32 exponent) -{ - return LLColor3(pow(v.mV[0], exponent), - pow(v.mV[1], exponent), - pow(v.mV[2], exponent)); -} - -static inline LLColor3 componentSaturate(LLColor3 const &v) -{ - return LLColor3(std::max(std::min(v.mV[0], 1.f), 0.f), - std::max(std::min(v.mV[1], 1.f), 0.f), - std::max(std::min(v.mV[2], 1.f), 0.f)); -} - - -static inline LLColor3 componentSqrt(LLColor3 const &v) -{ - return LLColor3(sqrt(v.mV[0]), - sqrt(v.mV[1]), - sqrt(v.mV[2])); -} - -static inline void componentMultBy(LLColor3 & left, LLColor3 const & right) -{ - left.mV[0] *= right.mV[0]; - left.mV[1] *= right.mV[1]; - left.mV[2] *= right.mV[2]; -} - -static inline LLColor3 colorMix(LLColor3 const & left, LLColor3 const & right, F32 amount) -{ - return (left + ((right - left) * amount)); -} - -static inline LLColor3 smear(F32 val) -{ - return LLColor3(val, val, val); -} - -void LLVOSky::initAtmospherics(void) -{ - bool error; - - // uniform parameters for convenience - dome_radius = LLWLParamManager::getInstance()->getDomeRadius(); - dome_offset_ratio = LLWLParamManager::getInstance()->getDomeOffset(); - sunlight_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("sunlight_color", error)); - ambient = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("ambient", error)); - //lightnorm = LLWLParamManager::getInstance()->mCurParams.getVector("lightnorm", error); - gamma = LLWLParamManager::getInstance()->mCurParams.getFloat("gamma", error); - blue_density = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_density", error)); - blue_horizon = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("blue_horizon", error)); - haze_density = LLWLParamManager::getInstance()->mCurParams.getFloat("haze_density", error); - haze_horizon = LLWLParamManager::getInstance()->mCurParams.getFloat("haze_horizon", error); - density_multiplier = LLWLParamManager::getInstance()->mCurParams.getFloat("density_multiplier", error); - max_y = LLWLParamManager::getInstance()->mCurParams.getFloat("max_y", error); - glow = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("glow", error)); - cloud_shadow = LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_shadow", error); - cloud_color = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_color", error)); - cloud_scale = LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_scale", error); - cloud_pos_density1 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density1", error)); - cloud_pos_density2 = LLColor3(LLWLParamManager::getInstance()->mCurParams.getVector("cloud_pos_density2", error)); - - // light norm is different. We need the sun's direction, not the light direction - // which could be from the moon. And we need to clamp it - // just like for the gpu - LLVector3 sunDir = gSky.getSunDirection(); - - // CFR_TO_OGL - lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); - unclamped_lightnorm = lightnorm; - if(lightnorm.mV[1] < -0.1f) - { - lightnorm.mV[1] = -0.1f; - } - -} - -LLColor4 LLVOSky::calcSkyColorInDir(const LLVector3 &dir, bool isShiny) -{ - F32 saturation = 0.3f; - if (dir.mV[VZ] < -0.02f) - { - LLColor4 col = LLColor4(llmax(mFogColor[0],0.2f), llmax(mFogColor[1],0.2f), llmax(mFogColor[2],0.22f),0.f); - if (isShiny) - { - LLColor3 desat_fog = LLColor3(mFogColor); - F32 brightness = desat_fog.brightness(); - // So that shiny somewhat shows up at night. - if (brightness < 0.15f) - { - brightness = 0.15f; - desat_fog = smear(0.15f); - } - LLColor3 greyscale = smear(brightness); - desat_fog = desat_fog * saturation + greyscale * (1.0f - saturation); - if (!gPipeline.canUseWindLightShaders()) - { - col = LLColor4(desat_fog, 0.f); - } - else - { - col = LLColor4(desat_fog * 0.5f, 0.f); - } - } - float x = 1.0f-fabsf(-0.1f-dir.mV[VZ]); - x *= x; - col.mV[0] *= x*x; - col.mV[1] *= powf(x, 2.5f); - col.mV[2] *= x*x*x; - return col; - } - - // undo OGL_TO_CFR_ROTATION and negate vertical direction. - LLVector3 Pn = LLVector3(-dir[1] , -dir[2], -dir[0]); - - LLColor3 vary_HazeColor(0,0,0); - LLColor3 vary_CloudColorSun(0,0,0); - LLColor3 vary_CloudColorAmbient(0,0,0); - F32 vary_CloudDensity(0); - LLVector2 vary_HorizontalProjection[2]; - vary_HorizontalProjection[0] = LLVector2(0,0); - vary_HorizontalProjection[1] = LLVector2(0,0); - - calcSkyColorWLVert(Pn, vary_HazeColor, vary_CloudColorSun, vary_CloudColorAmbient, - vary_CloudDensity, vary_HorizontalProjection); - - LLColor3 sky_color = calcSkyColorWLFrag(Pn, vary_HazeColor, vary_CloudColorSun, vary_CloudColorAmbient, - vary_CloudDensity, vary_HorizontalProjection); - if (isShiny) - { - F32 brightness = sky_color.brightness(); - LLColor3 greyscale = smear(brightness); - sky_color = sky_color * saturation + greyscale * (1.0f - saturation); - sky_color *= (0.5f + 0.5f * brightness); - } - return LLColor4(sky_color, 0.0f); -} - -// turn on floating point precision -// in vs2003 for this function. Otherwise -// sky is aliased looking 7:10 - 8:50 -#if LL_MSVC && __MSVC_VER__ < 8 -#pragma optimize("p", on) -#endif - -void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorSun, - LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, - LLVector2 vary_HorizontalProjection[2]) -{ - // project the direction ray onto the sky dome. - F32 phi = acos(Pn[1]); - F32 sinA = sin(F_PI - phi); - if (fabsf(sinA) < 0.01f) - { //avoid division by zero - sinA = 0.01f; - } - - F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; - - Pn *= Plen; - - vary_HorizontalProjection[0] = LLVector2(Pn[0], Pn[2]); - vary_HorizontalProjection[0] /= - 2.f * Plen; - - // Set altitude - if (Pn[1] > 0.f) - { - Pn *= (max_y / Pn[1]); - } - else - { - Pn *= (-32000.f / Pn[1]); - } - - Plen = Pn.length(); - Pn /= Plen; - - // Initialize temp variables - LLColor3 sunlight = sunlight_color; - - // Sunlight attenuation effect (hue and brightness) due to atmosphere - // this is used later for sunlight modulation at various altitudes - LLColor3 light_atten = - (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); - - // Calculate relative weights - LLColor3 temp2(0.f, 0.f, 0.f); - LLColor3 temp1 = blue_density + smear(haze_density); - LLColor3 blue_weight = componentDiv(blue_density, temp1); - LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); - - // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); - - temp2.mV[1] = 1.f / temp2.mV[1]; - componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); - - // Distance - temp2.mV[2] = Plen * density_multiplier; - - // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); - - - // Compute haze glow - temp2.mV[0] = Pn * LLVector3(lightnorm); - - temp2.mV[0] = 1.f - temp2.mV[0]; - // temp2.x is 0 at the sun and increases away from sun - temp2.mV[0] = llmax(temp2.mV[0], .001f); - // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.mV[0] *= glow.mV[0]; - // Higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.mV[0] = pow(temp2.mV[0], glow.mV[2]); - // glow.z should be negative, so we're doing a sort of (1 / "angle") function - - // Add "minimum anti-solar illumination" - temp2.mV[0] += .25f; - - - // Haze color above cloud - vary_HazeColor = (blue_horizon * blue_weight * (sunlight + ambient) - + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + ambient) - ); - - // Increase ambient when there are more clouds - LLColor3 tmpAmbient = ambient + (LLColor3::white - ambient) * cloud_shadow * 0.5f; - - // Dim sunlight by cloud shadow percentage - sunlight *= (1.f - cloud_shadow); - - // Haze color below cloud - LLColor3 additiveColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) - + componentMult(haze_horizon * haze_weight, sunlight * temp2.mV[0] + tmpAmbient) - ); - - // Final atmosphere additive - componentMultBy(vary_HazeColor, LLColor3::white - temp1); - - sunlight = sunlight_color; - temp2.mV[1] = llmax(0.f, lightnorm[1] * 2.f); - temp2.mV[1] = 1.f / temp2.mV[1]; - componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); - - // Attenuate cloud color by atmosphere - temp1 = componentSqrt(temp1); //less atmos opacity (more transparency) below clouds - - // At horizon, blend high altitude sky color towards the darker color below the clouds - vary_HazeColor += - componentMult(additiveColorBelowCloud - vary_HazeColor, LLColor3::white - componentSqrt(temp1)); - - if (Pn[1] < 0.f) - { - // Eric's original: - // LLColor3 dark_brown(0.143f, 0.129f, 0.114f); - LLColor3 dark_brown(0.082f, 0.076f, 0.066f); - LLColor3 brown(0.430f, 0.386f, 0.322f); - LLColor3 sky_lighting = sunlight + ambient; - F32 haze_brightness = vary_HazeColor.brightness(); - - if (Pn[1] < -0.05f) - { - vary_HazeColor = colorMix(dark_brown, brown, -Pn[1] * 0.9f) * sky_lighting * haze_brightness; - } - - if (Pn[1] > -0.1f) - { - vary_HazeColor = colorMix(LLColor3::white * haze_brightness, vary_HazeColor, fabs((Pn[1] + 0.05f) * -20.f)); + mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, mSkyTex[side].getDir(x, y), true), x, y); } } } -#if LL_MSVC && __MSVC_VER__ < 8 -#pragma optimize("p", off) -#endif - -LLColor3 LLVOSky::calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorSun, - LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, - LLVector2 vary_HorizontalProjection[2]) -{ - LLColor3 res; - - LLColor3 color0 = vary_HazeColor; - - if (!gPipeline.canUseWindLightShaders()) - { - LLColor3 color1 = color0 * 2.0f; - color1 = smear(1.f) - componentSaturate(color1); - componentPow(color1, gamma); - res = smear(1.f) - color1; - } - else - { - res = color0; - } - -# ifndef LL_RELEASE_FOR_DOWNLOAD - - LLColor3 color2 = 2.f * color0; - - LLColor3 color3 = LLColor3(1.f, 1.f, 1.f) - componentSaturate(color2); - componentPow(color3, gamma); - color3 = LLColor3(1.f, 1.f, 1.f) - color3; - - static enum { - OUT_DEFAULT = 0, - OUT_SKY_BLUE = 1, - OUT_RED = 2, - OUT_PN = 3, - OUT_HAZE = 4, - } debugOut = OUT_DEFAULT; - - switch(debugOut) - { - case OUT_DEFAULT: - break; - case OUT_SKY_BLUE: - res = LLColor3(0.4f, 0.4f, 0.9f); - break; - case OUT_RED: - res = LLColor3(1.f, 0.f, 0.f); - break; - case OUT_PN: - res = LLColor3(Pn[0], Pn[1], Pn[2]); - break; - case OUT_HAZE: - res = vary_HazeColor; - break; - } -# endif // LL_RELEASE_FOR_DOWNLOAD - return res; -} - -LLColor3 LLVOSky::createDiffuseFromWL(LLColor3 diffuse, LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient) -{ - return componentMult(diffuse, sundiffuse) * 4.0f + - componentMult(ambient, sundiffuse) * 2.0f + sunambient; -} - -LLColor3 LLVOSky::createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient) -{ - return (componentMult(ambient, sundiffuse) + sunambient) * 0.8f; -} - - -void LLVOSky::calcAtmospherics(void) +void LLVOSky::updateDirections(void) { - initAtmospherics(); - - LLColor3 vary_HazeColor; - LLColor3 vary_SunlightColor; - LLColor3 vary_AmbientColor; - { - // Initialize temp variables - LLColor3 sunlight = sunlight_color; - - // Sunlight attenuation effect (hue and brightness) due to atmosphere - // this is used later for sunlight modulation at various altitudes - LLColor3 light_atten = - (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); - - // Calculate relative weights - LLColor3 temp2(0.f, 0.f, 0.f); - LLColor3 temp1 = blue_density + smear(haze_density); - LLColor3 blue_weight = componentDiv(blue_density, temp1); - LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); - - // Compute sunlight from P & lightnorm (for long rays like sky) - /// USE only lightnorm. - // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); - - // and vary_sunlight will work properly with moon light - F32 lighty = unclamped_lightnorm[1]; - if(lighty < LLSky::NIGHTTIME_ELEVATION_COS) - { - lighty = -lighty; - } - - temp2.mV[1] = llmax(0.f, lighty); - if(temp2.mV[1] > 0.f) - { - temp2.mV[1] = 1.f / temp2.mV[1]; - } - componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - // Distance - temp2.mV[2] = density_multiplier; + mLastSunLightingDirection = mSun.getDirection(); + mLastMoonLightingDirection = mMoon.getDirection(); - // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]); + mSun.setDirection(psky->getSunDirection()); + mMoon.setDirection(psky->getMoonDirection()); - // vary_AtmosAttenuation = temp1; + mSun.setRotation(psky->getSunRotation()); + mMoon.setRotation(psky->getMoonRotation()); - //increase ambient when there are more clouds - LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; - - //haze color - vary_HazeColor = - (blue_horizon * blue_weight * (sunlight*(1.f - cloud_shadow) + tmpAmbient) - + componentMult(haze_horizon * haze_weight, sunlight*(1.f - cloud_shadow) * temp2.mV[0] + tmpAmbient) - ); - - //brightness of surface both sunlight and ambient - vary_SunlightColor = componentMult(sunlight, temp1) * 1.f; - vary_SunlightColor.clamp(); - vary_SunlightColor = smear(1.0f) - vary_SunlightColor; - vary_SunlightColor = componentPow(vary_SunlightColor, gamma); - vary_SunlightColor = smear(1.0f) - vary_SunlightColor; - vary_AmbientColor = componentMult(tmpAmbient, temp1) * 0.5; - vary_AmbientColor.clamp(); - vary_AmbientColor = smear(1.0f) - vary_AmbientColor; - vary_AmbientColor = componentPow(vary_AmbientColor, gamma); - vary_AmbientColor = smear(1.0f) - vary_AmbientColor; - - componentMultBy(vary_HazeColor, LLColor3(1.f, 1.f, 1.f) - temp1); - - } - - mSun.setColor(vary_SunlightColor); - mMoon.setColor(LLColor3(1.0f, 1.0f, 1.0f)); + mSun.setColor(psky->getSunlightColor()); + mMoon.setColor(psky->getMoonDiffuse()); mSun.renewDirection(); mSun.renewColor(); mMoon.renewDirection(); mMoon.renewColor(); - - float dp = getToSunLast() * LLVector3(0,0,1.f); - if (dp < 0) - { - dp = 0; - } - - // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio - // between sunlight and point lights in windlight to normalize point lights. - F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); - LLWLParamManager::getInstance()->mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); - - mSunDiffuse = vary_SunlightColor; - mSunAmbient = vary_AmbientColor; - mMoonDiffuse = vary_SunlightColor; - mMoonAmbient = vary_AmbientColor; - - mTotalAmbient = vary_AmbientColor; - mTotalAmbient.setAlpha(1); - - mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(0); } void LLVOSky::idleUpdate(LLAgent &agent, const F64 &time) { } -BOOL LLVOSky::updateSky() -{ +bool LLVOSky::updateSky() +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor4 total_ambient = psky->getTotalAmbient(); + if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))) { return TRUE; @@ -1058,11 +789,13 @@ BOOL LLVOSky::updateSky() const S32 total_no_tiles = 6 * NUM_TILES; const S32 cycle_frame_no = total_no_tiles + 1; - if (mUpdateTimer.getElapsedTimeF32() > 0.001f) + if (mUpdateTimer.getElapsedTimeF32() > 0.025f) { - mUpdateTimer.reset(); + mUpdateTimer.reset(); const S32 frame = next_frame; + mForceUpdate = mForceUpdate || (total_no_tiles == frame); + ++next_frame; next_frame = next_frame % cycle_frame_no; @@ -1070,117 +803,150 @@ BOOL LLVOSky::updateSky() // sInterpVal = (F32)next_frame / cycle_frame_no; LLSkyTex::setInterpVal( mInterpVal ); LLHeavenBody::setInterpVal( mInterpVal ); - calcAtmospherics(); + updateDirections(); + + LLVector3 direction = mSun.getDirection(); + direction.normalize(); + const F32 dot_sun = direction * mLastSunLightingDirection; + const F32 dot_moon = direction * mLastMoonLightingDirection; + + LLColor3 delta_color; + delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0], + mLastTotalAmbient.mV[1] - total_ambient.mV[1], + mLastTotalAmbient.mV[2] - total_ambient.mV[2]); + + bool sun_direction_changed = (dot_sun < LIGHT_DIRECTION_THRESHOLD); + bool moon_direction_changed = (dot_moon < LIGHT_DIRECTION_THRESHOLD); + bool color_changed = (delta_color.length() >= COLOR_CHANGE_THRESHOLD); + + mForceUpdate = mForceUpdate || sun_direction_changed; + mForceUpdate = mForceUpdate || moon_direction_changed; + mForceUpdate = mForceUpdate || color_changed; + mForceUpdate = mForceUpdate || !mInitialized; + + bool is_alm_wl_sky = gPipeline.canUseWindLightShaders(); + + calc(); - if (mForceUpdate || total_no_tiles == frame) + if (mForceUpdate && mForceUpdateThrottle.hasExpired()) { + LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED); + + mForceUpdateThrottle.setTimerExpirySec(UPDATE_EXPRY); + LLSkyTex::stepCurrent(); - - const static F32 LIGHT_DIRECTION_THRESHOLD = (F32) cos(DEG_TO_RAD * 1.f); - const static F32 COLOR_CHANGE_THRESHOLD = 0.01f; - - LLVector3 direction = mSun.getDirection(); - direction.normalize(); - const F32 dot_lighting = direction * mLastLightingDirection; - - LLColor3 delta_color; - delta_color.setVec(mLastTotalAmbient.mV[0] - mTotalAmbient.mV[0], - mLastTotalAmbient.mV[1] - mTotalAmbient.mV[1], - mLastTotalAmbient.mV[2] - mTotalAmbient.mV[2]); - - if ( mForceUpdate - || (((dot_lighting < LIGHT_DIRECTION_THRESHOLD) - || (delta_color.length() > COLOR_CHANGE_THRESHOLD) - || !mInitialized) - && !direction.isExactlyZero())) + + if (!direction.isExactlyZero()) { - mLastLightingDirection = direction; - mLastTotalAmbient = mTotalAmbient; + mLastTotalAmbient = total_ambient; mInitialized = TRUE; if (mCubeMap) { - if (mForceUpdate) - { - updateFog(LLViewerCamera::getInstance()->getFar()); - for (int side = 0; side < 6; side++) - { - for (int tile = 0; tile < NUM_TILES; tile++) - { - createSkyTexture(side, tile); - } - } - - calcAtmospherics(); + updateFog(LLViewerCamera::getInstance()->getFar()); - for (int side = 0; side < 6; side++) + for (int side = 0; side < 6; side++) + { + for (int tile = 0; tile < NUM_TILES; tile++) { - LLImageRaw* raw1 = mSkyTex[side].getImageRaw(TRUE); - LLImageRaw* raw2 = mSkyTex[side].getImageRaw(FALSE); - raw2->copy(raw1); - mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE)); - - raw1 = mShinyTex[side].getImageRaw(TRUE); - raw2 = mShinyTex[side].getImageRaw(FALSE); - raw2->copy(raw1); - mShinyTex[side].createGLImage(mShinyTex[side].getWhich(FALSE)); + createSkyTexture(m_atmosphericsVars, side, tile, is_alm_wl_sky); } - next_frame = 0; } - } - } - /// *TODO really, sky texture and env map should be shared on a single texture - /// I'll let Brad take this at some point + int tex = mSkyTex[0].getWhich(TRUE); - // update the sky texture - for (S32 i = 0; i < 6; ++i) - { - mSkyTex[i].create(1.0f); - mShinyTex[i].create(1.0f); - } - - // update the environment map - if (mCubeMap) - { - std::vector<LLPointer<LLImageRaw> > images; - images.reserve(6); - for (S32 side = 0; side < 6; side++) - { - images.push_back(mShinyTex[side].getImageRaw(TRUE)); + for (int side = 0; side < 6; side++) + { + LLImageRaw* raw1 = nullptr; + LLImageRaw* raw2 = nullptr; + + if (!is_alm_wl_sky) + { + raw1 = mSkyTex[side].getImageRaw(TRUE); + raw2 = mSkyTex[side].getImageRaw(FALSE); + raw2->copy(raw1); + mSkyTex[side].createGLImage(tex); + } + + raw1 = mShinyTex[side].getImageRaw(TRUE); + raw2 = mShinyTex[side].getImageRaw(FALSE); + raw2->copy(raw1); + mShinyTex[side].createGLImage(tex); + } + next_frame = 0; + + // update the sky texture + if (!is_alm_wl_sky) + { + for (S32 i = 0; i < 6; ++i) + { + mSkyTex[i].create(1.0f); + } + } + + for (S32 i = 0; i < 6; ++i) + { + mShinyTex[i].create(1.0f); + } + + // update the environment map + if (mCubeMap) + { + std::vector<LLPointer<LLImageRaw> > images; + images.reserve(6); + for (S32 side = 0; side < 6; side++) + { + images.push_back(mShinyTex[side].getImageRaw(TRUE)); + } + mCubeMap->init(images); + gGL.getTexUnit(0)->disable(); + } } - mCubeMap->init(images); - gGL.getTexUnit(0)->disable(); - } + } gPipeline.markRebuild(gSky.mVOGroundp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); - // *TODO: decide whether we need to update the stars vertex buffer in LLVOWLSky -Brad. - //gPipeline.markRebuild(gSky.mVOWLSkyp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); - mForceUpdate = FALSE; } - else - { - const S32 side = frame / NUM_TILES; - const S32 tile = frame % NUM_TILES; - createSkyTexture(side, tile); - } } if (mDrawable.notNull() && mDrawable->getFace(0) && !mDrawable->getFace(0)->getVertexBuffer()) { gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); } + return TRUE; } void LLVOSky::updateTextures() { - if (mSunTexturep) + if (mSunTexturep[0]) { - mSunTexturep->addTextureStats( (F32)MAX_IMAGE_AREA ); - mMoonTexturep->addTextureStats( (F32)MAX_IMAGE_AREA ); - mBloomTexturep->addTextureStats( (F32)MAX_IMAGE_AREA ); + mSunTexturep[0]->addTextureStats( (F32)MAX_IMAGE_AREA ); + } + + if (mSunTexturep[1]) + { + mSunTexturep[1]->addTextureStats( (F32)MAX_IMAGE_AREA ); + } + + if (mMoonTexturep[0]) + { + mMoonTexturep[0]->addTextureStats( (F32)MAX_IMAGE_AREA ); + } + + if (mMoonTexturep[1]) + { + mMoonTexturep[1]->addTextureStats( (F32)MAX_IMAGE_AREA ); + } + + if (mBloomTexturep[0]) + { + mBloomTexturep[0]->addTextureStats( (F32)MAX_IMAGE_AREA ); + } + + if (mBloomTexturep[1]) + { + mBloomTexturep[1]->addTextureStats( (F32)MAX_IMAGE_AREA ); } } @@ -1198,60 +964,121 @@ LLDrawable *LLVOSky::createDrawable(LLPipeline *pipeline) mFace[FACE_SIDE0 + i] = mDrawable->addFace(poolp, NULL); } - mFace[FACE_SUN] = mDrawable->addFace(poolp, mSunTexturep); - mFace[FACE_MOON] = mDrawable->addFace(poolp, mMoonTexturep); - mFace[FACE_BLOOM] = mDrawable->addFace(poolp, mBloomTexturep); + mFace[FACE_SUN] = mDrawable->addFace(poolp, nullptr); + mFace[FACE_MOON] = mDrawable->addFace(poolp, nullptr); + mFace[FACE_BLOOM] = mDrawable->addFace(poolp, nullptr); return mDrawable; } -//by bao -//fake vertex buffer updating -//to guarantee at least updating one VBO buffer every frame -//to walk around the bug caused by ATI card --> DEV-3855 -// -void LLVOSky::createDummyVertexBuffer() +void LLVOSky::setSunScale(F32 sun_scale) { - if(!mFace[FACE_DUMMY]) - { - LLDrawPoolSky *poolp = (LLDrawPoolSky*) gPipeline.getPool(LLDrawPool::POOL_SKY); - mFace[FACE_DUMMY] = mDrawable->addFace(poolp, NULL); - } + mSunScale = sun_scale; +} - if(!mFace[FACE_DUMMY]->getVertexBuffer()) - { - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB); - buff->allocateBuffer(1, 1, TRUE); - mFace[FACE_DUMMY]->setVertexBuffer(buff); - } +void LLVOSky::setMoonScale(F32 moon_scale) +{ + mMoonScale = moon_scale; } -static LLTrace::BlockTimerStatHandle FTM_RENDER_FAKE_VBO_UPDATE("Fake VBO Update"); +void LLVOSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next) +{ + // We test the UUIDs here because we explicitly do not want the default image returned by getFetchedTexture in that case... + mSunTexturep[0] = sun_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + mSunTexturep[1] = sun_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + + if (mFace[FACE_SUN]) + { + if (mSunTexturep[0]) + { + mSunTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP); + } + + LLViewerTexture* current_tex0 = mFace[FACE_SUN]->getTexture(LLRender::DIFFUSE_MAP); + LLViewerTexture* current_tex1 = mFace[FACE_SUN]->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP); + + if (current_tex0 && (mSunTexturep[0] != current_tex0) && current_tex0->isViewerMediaTexture()) + { + static_cast<LLViewerMediaTexture*>(current_tex0)->removeMediaFromFace(mFace[FACE_SUN]); + } + + if (current_tex1 && (mSunTexturep[1] != current_tex1) && current_tex1->isViewerMediaTexture()) + { + static_cast<LLViewerMediaTexture*>(current_tex1)->removeMediaFromFace(mFace[FACE_SUN]); + } + + mFace[FACE_SUN]->setTexture(LLRender::DIFFUSE_MAP, mSunTexturep[0]); + + if (mSunTexturep[1]) + { + mSunTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); + } + mFace[FACE_SUN]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mSunTexturep[1]); + } +} -void LLVOSky::updateDummyVertexBuffer() -{ - if(!LLVertexBuffer::sEnableVBOs) - return ; +void LLVOSky::setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_texture_next) +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + mMoonTexturep[0] = moon_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(moon_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + mMoonTexturep[1] = moon_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(moon_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + + if (mFace[FACE_MOON]) + { + if (mMoonTexturep[0]) + { + mMoonTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP); + } + mFace[FACE_MOON]->setTexture(LLRender::DIFFUSE_MAP, mMoonTexturep[0]); + + if (mMoonTexturep[1]) + { + mMoonTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); + mFace[FACE_MOON]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mMoonTexturep[1]); + } + } +} - if(mHeavenlyBodyUpdated) - { - mHeavenlyBodyUpdated = FALSE ; - return ; - } +void LLVOSky::setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUID& cloud_noise_texture_next) +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LL_RECORD_BLOCK_TIME(FTM_RENDER_FAKE_VBO_UPDATE) ; + mCloudNoiseTexturep[0] = cloud_noise_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(cloud_noise_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + mCloudNoiseTexturep[1] = cloud_noise_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(cloud_noise_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - if(!mFace[FACE_DUMMY] || !mFace[FACE_DUMMY]->getVertexBuffer()) - createDummyVertexBuffer() ; + if (mCloudNoiseTexturep[0]) + { + mCloudNoiseTexturep[0]->setAddressMode(LLTexUnit::TAM_WRAP); + } - LLStrider<LLVector3> vertices ; - mFace[FACE_DUMMY]->getVertexBuffer()->getVertexStrider(vertices, 0); - *vertices = mCameraPosAgent ; - mFace[FACE_DUMMY]->getVertexBuffer()->flush(); + if (mCloudNoiseTexturep[1]) + { + mCloudNoiseTexturep[1]->setAddressMode(LLTexUnit::TAM_WRAP); + } } -//---------------------------------- -//end of fake vertex buffer updating -//---------------------------------- + +void LLVOSky::setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next) +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLUUID bloom_tex = bloom_texture.isNull() ? psky->GetDefaultBloomTextureId() : bloom_texture; + LLUUID bloom_tex_next = bloom_texture_next.isNull() ? (bloom_texture.isNull() ? psky->GetDefaultBloomTextureId() : bloom_texture) : bloom_texture_next; + + mBloomTexturep[0] = bloom_tex.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(bloom_tex, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + mBloomTexturep[1] = bloom_tex_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(bloom_tex_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + + if (mBloomTexturep[0]) + { + mBloomTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP); + } + + if (mBloomTexturep[1]) + { + mBloomTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); + } +} + static LLTrace::BlockTimerStatHandle FTM_GEO_SKY("Sky Geometry"); BOOL LLVOSky::updateGeometry(LLDrawable *drawable) @@ -1260,13 +1087,14 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) if (mFace[FACE_REFLECTION] == NULL) { LLDrawPoolWater *poolp = (LLDrawPoolWater*) gPipeline.getPool(LLDrawPool::POOL_WATER); - if (gPipeline.getPool(LLDrawPool::POOL_WATER)->getVertexShaderLevel() != 0) + if (gPipeline.getPool(LLDrawPool::POOL_WATER)->getShaderLevel() != 0) { mFace[FACE_REFLECTION] = drawable->addFace(poolp, NULL); } } mCameraPosAgent = drawable->getPositionAgent(); + mEarthCenter.mV[0] = mCameraPosAgent.mV[0]; mEarthCenter.mV[1] = mCameraPosAgent.mV[1]; @@ -1340,64 +1168,40 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) LLVector3 up = right % look_at; right.normalize(); up.normalize(); + + bool draw_sun = updateHeavenlyBodyGeometry(drawable, mSunScale, FACE_SUN, mSun, up, right); + bool draw_moon = updateHeavenlyBodyGeometry(drawable, mMoonScale, FACE_MOON, mMoon, up, right); - const static F32 elevation_factor = 0.0f/sResolution; - const F32 cos_max_angle = cosHorizon(elevation_factor); - mSun.setDraw(updateHeavenlyBodyGeometry(drawable, FACE_SUN, TRUE, mSun, cos_max_angle, up, right)); - mMoon.setDraw(updateHeavenlyBodyGeometry(drawable, FACE_MOON, FALSE, mMoon, cos_max_angle, up, right)); + draw_sun &= LLEnvironment::getInstance()->getIsSunUp(); + draw_moon &= LLEnvironment::getInstance()->getIsMoonUp(); + + mSun.setDraw(draw_sun); + mMoon.setDraw(draw_moon); const F32 water_height = gAgent.getRegion()->getWaterHeight() + 0.01f; // LLWorld::getInstance()->getWaterHeight() + 0.01f; const F32 camera_height = mCameraPosAgent.mV[2]; const F32 height_above_water = camera_height - water_height; - BOOL sun_flag = FALSE; - + bool sun_flag = FALSE; if (mSun.isVisible()) - { - if (mMoon.isVisible()) - { - sun_flag = look_at * mSun.getDirection() > 0; - } - else - { - sun_flag = TRUE; - } + { + sun_flag = !mMoon.isVisible() || ((look_at * mSun.getDirection()) > 0); } - if (height_above_water > 0) - { - BOOL render_ref = gPipeline.getPool(LLDrawPool::POOL_WATER)->getVertexShaderLevel() == 0; - - if (sun_flag) - { - setDrawRefl(0); - if (render_ref) - { - updateReflectionGeometry(drawable, height_above_water, mSun); - } - } - else - { - setDrawRefl(1); - if (render_ref) - { - updateReflectionGeometry(drawable, height_above_water, mMoon); - } - } - } - else - { - setDrawRefl(-1); - } + bool above_water = (height_above_water > 0); + bool render_ref = above_water && gPipeline.getPool(LLDrawPool::POOL_WATER)->getShaderLevel() == 0; + setDrawRefl(above_water ? (sun_flag ? 0 : 1) : -1); + if (render_ref) + { + updateReflectionGeometry(drawable, height_above_water, mSun); + } LLPipeline::sCompiles++; return TRUE; } -BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, const BOOL is_sun, - LLHeavenBody& hb, const F32 cos_max_angle, - const LLVector3 &up, const LLVector3 &right) +bool LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, F32 scale, const S32 f, LLHeavenBody& hb, const LLVector3 &up, const LLVector3 &right) { mHeavenlyBodyUpdated = TRUE ; @@ -1408,52 +1212,39 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons S32 index_offset; LLFace *facep; - LLVector3 to_dir = hb.getDirection(); + + LLQuaternion rot = hb.getRotation(); + LLVector3 to_dir = LLVector3::x_axis * rot; - if (!is_sun) - { - to_dir.mV[2] = llmax(to_dir.mV[2]+0.1f, 0.1f); - } - LLVector3 draw_pos = to_dir * HEAVENLY_BODY_DIST; + LLVector3 hb_right = to_dir % LLVector3::z_axis; + LLVector3 hb_up = hb_right % to_dir; + + // at zenith so math below fails spectacularly + if ((to_dir * LLVector3::z_axis) > 0.99f) + { + hb_right = LLVector3::y_axis_neg * rot; + hb_up = LLVector3::z_axis * rot; + } + LLVector3 draw_pos = to_dir * HEAVENLY_BODY_DIST; - LLVector3 hb_right = to_dir % LLVector3::z_axis; - LLVector3 hb_up = hb_right % to_dir; hb_right.normalize(); hb_up.normalize(); - //const static F32 cos_max_turn = sqrt(3.f) / 2; // 30 degrees - //const F32 cos_turn_right = 1. / (llmax(cos_max_turn, hb_right * right)); - //const F32 cos_turn_up = 1. / llmax(cos_max_turn, hb_up * up); - - const F32 enlargm_factor = ( 1 - to_dir.mV[2] ); + const F32 enlargm_factor = ( 1 - to_dir.mV[2] ); F32 horiz_enlargement = 1 + enlargm_factor * 0.3f; F32 vert_enlargement = 1 + enlargm_factor * 0.2f; - // Parameters for the water reflection - hb.setU(HEAVENLY_BODY_FACTOR * horiz_enlargement * hb.getDiskRadius() * hb_right); - hb.setV(HEAVENLY_BODY_FACTOR * vert_enlargement * hb.getDiskRadius() * hb_up); - // End of parameters for the water reflection + const LLVector3 scaled_right = horiz_enlargement * scale * HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR * hb.getDiskRadius() * hb_right; + const LLVector3 scaled_up = vert_enlargement * scale * HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR * hb.getDiskRadius() * hb_up; - const LLVector3 scaled_right = HEAVENLY_BODY_DIST * hb.getU(); - const LLVector3 scaled_up = HEAVENLY_BODY_DIST * hb.getV(); - - //const LLVector3 scaled_right = horiz_enlargement * HEAVENLY_BODY_SCALE * hb.getDiskRadius() * hb_right;//right; - //const LLVector3 scaled_up = vert_enlargement * HEAVENLY_BODY_SCALE * hb.getDiskRadius() * hb_up;//up; LLVector3 v_clipped[4]; - hb.corner(0) = draw_pos - scaled_right + scaled_up; - hb.corner(1) = draw_pos - scaled_right - scaled_up; - hb.corner(2) = draw_pos + scaled_right + scaled_up; - hb.corner(3) = draw_pos + scaled_right - scaled_up; - + v_clipped[0] = draw_pos - scaled_right + scaled_up; + v_clipped[1] = draw_pos - scaled_right - scaled_up; + v_clipped[2] = draw_pos + scaled_right + scaled_up; + v_clipped[3] = draw_pos + scaled_right - scaled_up; - F32 t_left, t_right; - if (!clip_quad_to_horizon(t_left, t_right, v_clipped, hb.corners(), cos_max_angle)) - { - hb.setVisible(FALSE); - return FALSE; - } hb.setVisible(TRUE); facep = mFace[f]; @@ -1503,164 +1294,9 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons facep->getVertexBuffer()->flush(); - if (is_sun) - { - if ((t_left > 0) && (t_right > 0)) - { - F32 t = (t_left + t_right) * 0.5f; - mSun.setHorizonVisibility(0.5f * (1 + cos(t * F_PI))); - } - else - { - mSun.setHorizonVisibility(); - } - updateSunHaloGeometry(drawable); - } - - return TRUE; -} - - - - -// Clips quads with top and bottom sides parallel to horizon. - -BOOL clip_quad_to_horizon(F32& t_left, F32& t_right, LLVector3 v_clipped[4], - const LLVector3 v_corner[4], const F32 cos_max_angle) -{ - t_left = clip_side_to_horizon(v_corner[1], v_corner[0], cos_max_angle); - t_right = clip_side_to_horizon(v_corner[3], v_corner[2], cos_max_angle); - - if ((t_left >= 1) || (t_right >= 1)) - { - return FALSE; - } - - //const BOOL left_clip = (t_left > 0); - //const BOOL right_clip = (t_right > 0); - - //if (!left_clip && !right_clip) - { - for (S32 vtx = 0; vtx < 4; ++vtx) - { - v_clipped[vtx] = v_corner[vtx]; - } - } -/* else - { - v_clipped[0] = v_corner[0]; - v_clipped[1] = left_clip ? ((1 - t_left) * v_corner[1] + t_left * v_corner[0]) - : v_corner[1]; - v_clipped[2] = v_corner[2]; - v_clipped[3] = right_clip ? ((1 - t_right) * v_corner[3] + t_right * v_corner[2]) - : v_corner[3]; - }*/ - return TRUE; } - -F32 clip_side_to_horizon(const LLVector3& V0, const LLVector3& V1, const F32 cos_max_angle) -{ - const LLVector3 V = V1 - V0; - const F32 k2 = 1.f/(cos_max_angle * cos_max_angle) - 1; - const F32 A = V.mV[0] * V.mV[0] + V.mV[1] * V.mV[1] - k2 * V.mV[2] * V.mV[2]; - const F32 B = V0.mV[0] * V.mV[0] + V0.mV[1] * V.mV[1] - k2 * V0.mV[2] * V.mV[2]; - const F32 C = V0.mV[0] * V0.mV[0] + V0.mV[1] * V0.mV[1] - k2 * V0.mV[2] * V0.mV[2]; - - if (fabs(A) < 1e-7) - { - return -0.1f; // v0 is cone origin and v1 is on the surface of the cone. - } - - const F32 det = sqrt(B*B - A*C); - const F32 t1 = (-B - det) / A; - const F32 t2 = (-B + det) / A; - const F32 z1 = V0.mV[2] + t1 * V.mV[2]; - const F32 z2 = V0.mV[2] + t2 * V.mV[2]; - if (z1 * cos_max_angle < 0) - { - return t2; - } - else if (z2 * cos_max_angle < 0) - { - return t1; - } - else if ((t1 < 0) || (t1 > 1)) - { - return t2; - } - else - { - return t1; - } -} - - -void LLVOSky::updateSunHaloGeometry(LLDrawable *drawable ) -{ -#if 0 - const LLVector3* v_corner = mSun.corners(); - - LLStrider<LLVector3> verticesp; - LLStrider<LLVector3> normalsp; - LLStrider<LLVector2> texCoordsp; - LLStrider<U16> indicesp; - S32 index_offset; - LLFace *face; - - const LLVector3 right = 2 * (v_corner[2] - v_corner[0]); - LLVector3 up = 2 * (v_corner[2] - v_corner[3]); - up.normalize(); - F32 size = right.length(); - up = size * up; - const LLVector3 draw_pos = 0.25 * (v_corner[0] + v_corner[1] + v_corner[2] + v_corner[3]); - - LLVector3 v_glow_corner[4]; - - v_glow_corner[0] = draw_pos - right + up; - v_glow_corner[1] = draw_pos - right - up; - v_glow_corner[2] = draw_pos + right + up; - v_glow_corner[3] = draw_pos + right - up; - - face = mFace[FACE_BLOOM]; - - if (face->mVertexBuffer.isNull()) - { - face->setSize(4, 6); - face->setGeomIndex(0); - face->setIndicesIndex(0); - face->mVertexBuffer = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); - face->mVertexBuffer->allocateBuffer(4, 6, TRUE); - } - - index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); - if (-1 == index_offset) - { - return; - } - - for (S32 vtx = 0; vtx < 4; ++vtx) - { - *(verticesp++) = v_glow_corner[vtx] + mCameraPosAgent; - } - - *(texCoordsp++) = TEX01; - *(texCoordsp++) = TEX00; - *(texCoordsp++) = TEX11; - *(texCoordsp++) = TEX10; - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 1; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 3; -#endif -} - - F32 dtReflection(const LLVector3& p, F32 cos_dir_from_top, F32 sin_dir_from_top, F32 diff_angl_dir) { LLVector3 P = p; @@ -1722,9 +1358,6 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, LLVector3 look_at_right = look_at % LLVector3::z_axis; look_at_right.normalize(); - const static F32 cos_horizon_angle = cosHorizon(0.0f/sResolution); - //const static F32 horizon_angle = acos(cos_horizon_angle); - const F32 enlargm_factor = ( 1 - to_dir.mV[2] ); F32 horiz_enlargement = 1 + enlargm_factor * 0.3f; F32 vert_enlargement = 1 + enlargm_factor * 0.2f; @@ -1739,22 +1372,10 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, LLVector3 top_hb = v_corner[0] = stretch_corner[0] = hb_pos - Right + Up; v_corner[1] = stretch_corner[1] = hb_pos - Right - Up; - F32 dt_hor, dt; - dt_hor = clip_side_to_horizon(v_corner[1], v_corner[0], cos_horizon_angle); - LLVector2 TEX0t = TEX00; LLVector2 TEX1t = TEX10; LLVector3 lower_corner = v_corner[1]; - if ((dt_hor > 0) && (dt_hor < 1)) - { - TEX0t = LLVector2(0, dt_hor); - TEX1t = LLVector2(1, dt_hor); - lower_corner = (1 - dt_hor) * v_corner[1] + dt_hor * v_corner[0]; - } - else - dt_hor = llmax(0.0f, llmin(1.0f, dt_hor)); - top_hb.normalize(); const F32 cos_angle_of_view = fabs(top_hb.mV[VZ]); const F32 extension = llmin (5.0f, 1.0f / cos_angle_of_view); @@ -1766,9 +1387,6 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, stretch_corner[0] = lower_corner + extension * (stretch_corner[0] - lower_corner); stretch_corner[1] = lower_corner + extension * (stretch_corner[1] - lower_corner); - dt = dt_hor; - - F32 cos_dir_from_top[2]; LLVector3 dir = stretch_corner[0]; @@ -1857,9 +1475,8 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, F32 dt_tex = dtReflection(P, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); - dt = dt_tex; - TEX0tt = LLVector2(0, dt); - TEX1tt = LLVector2(1, dt); + TEX0tt = LLVector2(0, dt_tex); + TEX1tt = LLVector2(1, dt_tex); quads++; } else @@ -1870,408 +1487,225 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, LLFace *face = mFace[FACE_REFLECTION]; - if (!face->getVertexBuffer() || quads*4 != face->getGeomCount()) - { - face->setSize(quads * 4, quads * 6); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); - if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) - { - LL_WARNS() << "Failed to allocate Vertex Buffer for vosky to " - << face->getGeomCount() << " vertices and " - << face->getIndicesCount() << " indices" << LL_ENDL; - } - face->setIndicesIndex(0); - face->setGeomIndex(0); - face->setVertexBuffer(buff); - } - - LLStrider<LLVector3> verticesp; - LLStrider<LLVector3> normalsp; - LLStrider<LLVector2> texCoordsp; - LLStrider<U16> indicesp; - S32 index_offset; - - index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); - if (-1 == index_offset) - { - return; - } - - LLColor3 hb_col3 = HB.getInterpColor(); - hb_col3.clamp(); - const LLColor4 hb_col = LLColor4(hb_col3); - - const F32 min_attenuation = 0.4f; - const F32 max_attenuation = 0.7f; - const F32 attenuation = min_attenuation - + cos_angle_of_view * (max_attenuation - min_attenuation); - - LLColor4 hb_refl_col = (1-attenuation) * hb_col + attenuation * mFogColor; - face->setFaceColor(hb_refl_col); - - LLVector3 v_far[2]; - v_far[0] = v_refl_corner[1]; - v_far[1] = v_refl_corner[3]; - - if(dt_clip > 0) - { - if (dt_clip >= 1) - { - for (S32 vtx = 0; vtx < 4; ++vtx) - { - F32 ratio = far_clip / v_refl_corner[vtx].length(); - *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; - } - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); - face->mCenterAgent = draw_pos; - } - else - { - F32 ratio = far_clip / v_refl_corner[1].length(); - v_sprite_corner[1] = v_refl_corner[1] * ratio; - - ratio = far_clip / v_refl_corner[3].length(); - v_sprite_corner[3] = v_refl_corner[3] * ratio; - - v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; - v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; - v_sprite_corner[0] = v_refl_corner[1]; - v_sprite_corner[2] = v_refl_corner[3]; - - for (S32 vtx = 0; vtx < 4; ++vtx) - { - *(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; - } - - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); - face->mCenterAgent = draw_pos; - } - - *(texCoordsp++) = TEX0tt; - *(texCoordsp++) = TEX0t; - *(texCoordsp++) = TEX1tt; - *(texCoordsp++) = TEX1t; - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 1; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 3; - - index_offset += 4; - } - - if (dt_clip < 1) - { - if (dt_clip <= 0) - { - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); - face->mCenterAgent = draw_pos; - } - - const F32 raws_inv = 1.f/raws; - const F32 cols_inv = 1.f/cols; - LLVector3 left = v_refl_corner[0] - v_refl_corner[1]; - LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; - left *= raws_inv; - right *= raws_inv; - - F32 dt_raw = dt; - - for (S32 raw = 0; raw < raws; ++raw) - { - F32 dt_v0 = raw * raws_inv; - F32 dt_v1 = (raw + 1) * raws_inv; - const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; - const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; - const LLVector3 EL = BL + left; - const LLVector3 ER = BR + right; - dt_v0 = dt_raw; - dt_raw = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); - for (S32 col = 0; col < cols; ++col) + if (face) + { + if (!face->getVertexBuffer() || quads * 4 != face->getGeomCount()) + { + face->setSize(quads * 4, quads * 6); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); + if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) { - F32 dt_h0 = col * cols_inv; - *(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; - *(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; - F32 dt_h1 = (col + 1) * cols_inv; - *(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; - *(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; - - *(texCoordsp++) = LLVector2(dt_h0, dt_v1); - *(texCoordsp++) = LLVector2(dt_h0, dt_v0); - *(texCoordsp++) = LLVector2(dt_h1, dt_v1); - *(texCoordsp++) = LLVector2(dt_h1, dt_v0); - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 1; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 3; - - index_offset += 4; + LL_WARNS() << "Failed to allocate Vertex Buffer for vosky to " + << face->getGeomCount() << " vertices and " + << face->getIndicesCount() << " indices" << LL_ENDL; } - } - } - - face->getVertexBuffer()->flush(); + face->setIndicesIndex(0); + face->setGeomIndex(0); + face->setVertexBuffer(buff); + } + + LLStrider<LLVector3> verticesp; + LLStrider<LLVector3> normalsp; + LLStrider<LLVector2> texCoordsp; + LLStrider<U16> indicesp; + S32 index_offset; + + index_offset = face->getGeometry(verticesp, normalsp, texCoordsp, indicesp); + if (-1 == index_offset) + { + return; + } + + LLColor3 hb_col3 = HB.getInterpColor(); + hb_col3.clamp(); + const LLColor4 hb_col = LLColor4(hb_col3); + + const F32 min_attenuation = 0.4f; + const F32 max_attenuation = 0.7f; + const F32 attenuation = min_attenuation + + cos_angle_of_view * (max_attenuation - min_attenuation); + + LLColor4 hb_refl_col = (1 - attenuation) * hb_col + attenuation * getSkyFogColor(); + face->setFaceColor(hb_refl_col); + + LLVector3 v_far[2]; + v_far[0] = v_refl_corner[1]; + v_far[1] = v_refl_corner[3]; + + if (dt_clip > 0) + { + if (dt_clip >= 1) + { + for (S32 vtx = 0; vtx < 4; ++vtx) + { + F32 ratio = far_clip / v_refl_corner[vtx].length(); + *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; + } + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); + face->mCenterAgent = draw_pos; + } + else + { + F32 ratio = far_clip / v_refl_corner[1].length(); + v_sprite_corner[1] = v_refl_corner[1] * ratio; + + ratio = far_clip / v_refl_corner[3].length(); + v_sprite_corner[3] = v_refl_corner[3] * ratio; + + v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; + v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; + v_sprite_corner[0] = v_refl_corner[1]; + v_sprite_corner[2] = v_refl_corner[3]; + + for (S32 vtx = 0; vtx < 4; ++vtx) + { + *(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; + } + + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); + face->mCenterAgent = draw_pos; + } + + *(texCoordsp++) = TEX0tt; + *(texCoordsp++) = TEX0t; + *(texCoordsp++) = TEX1tt; + *(texCoordsp++) = TEX1t; + + *indicesp++ = index_offset + 0; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 1; + + *indicesp++ = index_offset + 1; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 3; + + index_offset += 4; + } + + if (dt_clip < 1) + { + if (dt_clip <= 0) + { + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); + face->mCenterAgent = draw_pos; + } + + const F32 raws_inv = 1.f / raws; + const F32 cols_inv = 1.f / cols; + LLVector3 left = v_refl_corner[0] - v_refl_corner[1]; + LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; + left *= raws_inv; + right *= raws_inv; + + for (S32 raw = 0; raw < raws; ++raw) + { + F32 dt_v0 = raw * raws_inv; + F32 dt_v1 = (raw + 1) * raws_inv; + const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; + const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; + const LLVector3 EL = BL + left; + const LLVector3 ER = BR + right; + dt_v0 = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); + for (S32 col = 0; col < cols; ++col) + { + F32 dt_h0 = col * cols_inv; + *(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; + *(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; + F32 dt_h1 = (col + 1) * cols_inv; + *(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; + *(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; + + *(texCoordsp++) = LLVector2(dt_h0, dt_v1); + *(texCoordsp++) = LLVector2(dt_h0, dt_v0); + *(texCoordsp++) = LLVector2(dt_h1, dt_v1); + *(texCoordsp++) = LLVector2(dt_h1, dt_v0); + + *indicesp++ = index_offset + 0; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 1; + + *indicesp++ = index_offset + 1; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 3; + + index_offset += 4; + } + } + } + + face->getVertexBuffer()->flush(); + } } - - - void LLVOSky::updateFog(const F32 distance) { - if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOG)) - { - if (!LLGLSLShader::sNoFixedFunction) - { - glFogf(GL_FOG_DENSITY, 0); - glFogfv(GL_FOG_COLOR, (F32 *) &LLColor4::white.mV); - glFogf(GL_FOG_END, 1000000.f); - } - return; - } - - const BOOL hide_clip_plane = TRUE; - LLColor4 target_fog(0.f, 0.2f, 0.5f, 0.f); - - const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f; - // LLWorld::getInstance()->getWaterHeight(); - F32 camera_height = gAgentCamera.getCameraPositionAgent().mV[2]; - - F32 near_clip_height = LLViewerCamera::getInstance()->getAtAxis().mV[VZ] * LLViewerCamera::getInstance()->getNear(); - camera_height += near_clip_height; - - F32 fog_distance = 0.f; - LLColor3 res_color[3]; - - LLColor3 sky_fog_color = LLColor3::white; - LLColor3 render_fog_color = LLColor3::white; - - LLVector3 tosun = getToSunLast(); - const F32 tosun_z = tosun.mV[VZ]; - tosun.mV[VZ] = 0.f; - tosun.normalize(); - LLVector3 perp_tosun; - perp_tosun.mV[VX] = -tosun.mV[VY]; - perp_tosun.mV[VY] = tosun.mV[VX]; - LLVector3 tosun_45 = tosun + perp_tosun; - tosun_45.normalize(); - - F32 delta = 0.06f; - tosun.mV[VZ] = delta; - perp_tosun.mV[VZ] = delta; - tosun_45.mV[VZ] = delta; - tosun.normalize(); - perp_tosun.normalize(); - tosun_45.normalize(); - - // Sky colors, just slightly above the horizon in the direction of the sun, perpendicular to the sun, and at a 45 degree angle to the sun. - initAtmospherics(); - res_color[0] = calcSkyColorInDir(tosun); - res_color[1] = calcSkyColorInDir(perp_tosun); - res_color[2] = calcSkyColorInDir(tosun_45); - - sky_fog_color = color_norm(res_color[0] + res_color[1] + res_color[2]); - - F32 full_off = -0.25f; - F32 full_on = 0.00f; - F32 on = (tosun_z - full_off) / (full_on - full_off); - on = llclamp(on, 0.01f, 1.f); - sky_fog_color *= 0.5f * on; - - - // We need to clamp these to non-zero, in order for the gamma correction to work. 0^y = ??? - S32 i; - for (i = 0; i < 3; i++) - { - sky_fog_color.mV[i] = llmax(0.0001f, sky_fog_color.mV[i]); - } - - color_gamma_correct(sky_fog_color); - - render_fog_color = sky_fog_color; - - F32 fog_density = 0.f; - fog_distance = mFogRatio * distance; - - if (camera_height > water_height) - { - LLColor4 fog(render_fog_color); - if (!LLGLSLShader::sNoFixedFunction) - { - glFogfv(GL_FOG_COLOR, fog.mV); - } - mGLFogCol = fog; - - if (hide_clip_plane) - { - // For now, set the density to extend to the cull distance. - const F32 f_log = 2.14596602628934723963618357029f; // sqrt(fabs(log(0.01f))) - fog_density = f_log/fog_distance; - if (!LLGLSLShader::sNoFixedFunction) - { - glFogi(GL_FOG_MODE, GL_EXP2); - } - } - else - { - const F32 f_log = 4.6051701859880913680359829093687f; // fabs(log(0.01f)) - fog_density = (f_log)/fog_distance; - if (!LLGLSLShader::sNoFixedFunction) - { - glFogi(GL_FOG_MODE, GL_EXP); - } - } - } - else - { - F32 depth = water_height - camera_height; - - // get the water param manager variables - float water_fog_density = LLWaterParamManager::getInstance()->getFogDensity(); - LLColor4 water_fog_color(LLDrawPoolWater::sWaterFogColor.mV); - - // adjust the color based on depth. We're doing linear approximations - float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale"); - float depth_modifier = 1.0f - llmin(llmax(depth / depth_scale, 0.01f), - gSavedSettings.getF32("WaterGLFogDepthFloor")); + LLEnvironment& environment = LLEnvironment::instance(); + if (environment.getCurrentSky() != nullptr) + { + LLVector3 light_dir = LLVector3(environment.getClampedLightNorm()); + m_legacyAtmospherics.updateFog(distance, light_dir); + } +} - LLColor4 fogCol = water_fog_color * depth_modifier; - fogCol.setAlpha(1); +void LLVOSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir_cfr, const LLVector3 &moon_dir_cfr) +{ + mSun.setDirection(sun_dir_cfr); + mMoon.setDirection(moon_dir_cfr); - // set the gl fog color - mGLFogCol = fogCol; + // Push the sun "South" as it approaches directly overhead so that we can always see bump mapping + // on the upward facing faces of cubes. + { + // Same as dot product with the up direction + clamp. + F32 sunDot = llmax(0.f, sun_dir_cfr.mV[2]); + sunDot *= sunDot; - // set the density based on what the shaders use - fog_density = water_fog_density * gSavedSettings.getF32("WaterGLFogDensityScale"); + // Create normalized vector that has the sunDir pushed south about an hour and change. + LLVector3 adjustedDir = (sun_dir_cfr + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f; - if (!LLGLSLShader::sNoFixedFunction) - { - glFogfv(GL_FOG_COLOR, (F32 *) &fogCol.mV); - glFogi(GL_FOG_MODE, GL_EXP2); - } - } + // Blend between normal sun dir and adjusted sun dir based on how close we are + // to having the sun overhead. + mBumpSunDir = adjustedDir * sunDot + sun_dir_cfr * (1.0f - sunDot); + mBumpSunDir.normalize(); + } - mFogColor = sky_fog_color; - mFogColor.setAlpha(1); - LLDrawPoolWater::sWaterFogEnd = fog_distance*2.2f; + updateDirections(); - if (!LLGLSLShader::sNoFixedFunction) - { - LLGLSFog gls_fog; - glFogf(GL_FOG_END, fog_distance*2.2f); - glFogf(GL_FOG_DENSITY, fog_density); - glHint(GL_FOG_HINT, GL_NICEST); - } - stop_glerror(); + mForceUpdate = true; } - -// Functions used a lot. -F32 color_norm_pow(LLColor3& col, F32 e, BOOL postmultiply) +void LLVOSky::setSunDirectionCFR(const LLVector3 &sun_dir_cfr) { - F32 mv = color_max(col); - if (0 == mv) - { - return 0; - } + mSun.setDirection(sun_dir_cfr); - col *= 1.f / mv; - color_pow(col, e); - if (postmultiply) - { - col *= mv; - } - return mv; -} + // Push the sun "South" as it approaches directly overhead so that we can always see bump mapping + // on the upward facing faces of cubes. + { + // Same as dot product with the up direction + clamp. + F32 sunDot = llmax(0.f, sun_dir_cfr.mV[2]); + sunDot *= sunDot; -// Returns angle (RADIANs) between the horizontal projection of "v" and the x_axis. -// Range of output is 0.0f to 2pi //359.99999...f -// Returns 0.0f when "v" = +/- z_axis. -F32 azimuth(const LLVector3 &v) -{ - F32 azimuth = 0.0f; - if (v.mV[VX] == 0.0f) - { - if (v.mV[VY] > 0.0f) - { - azimuth = F_PI * 0.5f; - } - else if (v.mV[VY] < 0.0f) - { - azimuth = F_PI * 1.5f;// 270.f; - } - } - else - { - azimuth = (F32) atan(v.mV[VY] / v.mV[VX]); - if (v.mV[VX] < 0.0f) - { - azimuth += F_PI; - } - else if (v.mV[VY] < 0.0f) - { - azimuth += F_PI * 2; - } - } - return azimuth; -} + // Create normalized vector that has the sunDir pushed south about an hour and change. + LLVector3 adjustedDir = (sun_dir_cfr + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f; -void LLVOSky::initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity) -{ - LLVector3 sun_direction = (sun_dir.length() == 0) ? LLVector3::x_axis : sun_dir; - sun_direction.normalize(); - mSun.setDirection(sun_direction); - mSun.renewDirection(); - mSun.setAngularVelocity(sun_ang_velocity); - mMoon.setDirection(-mSun.getDirection()); - mMoon.renewDirection(); - mLastLightingDirection = mSun.getDirection(); + // Blend between normal sun dir and adjusted sun dir based on how close we are + // to having the sun overhead. + mBumpSunDir = adjustedDir * sunDot + sun_dir_cfr * (1.0f - sunDot); + mBumpSunDir.normalize(); + } - calcAtmospherics(); + updateDirections(); - if ( !mInitialized ) - { - init(); - LLSkyTex::stepCurrent(); - } + mForceUpdate = true; } -void LLVOSky::setSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity) +void LLVOSky::setMoonDirectionCFR(const LLVector3 &moon_dir_cfr) { - LLVector3 sun_direction = (sun_dir.length() == 0) ? LLVector3::x_axis : sun_dir; - sun_direction.normalize(); + mMoon.setDirection(moon_dir_cfr); - // Push the sun "South" as it approaches directly overhead so that we can always see bump mapping - // on the upward facing faces of cubes. - LLVector3 newDir = sun_direction; - - // Same as dot product with the up direction + clamp. - F32 sunDot = llmax(0.f, newDir.mV[2]); - sunDot *= sunDot; - - // Create normalized vector that has the sunDir pushed south about an hour and change. - LLVector3 adjustedDir = (newDir + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f; - - // Blend between normal sun dir and adjusted sun dir based on how close we are - // to having the sun overhead. - mBumpSunDir = adjustedDir * sunDot + newDir * (1.0f - sunDot); - mBumpSunDir.normalize(); - - F32 dp = mLastLightingDirection * sun_direction; - mSun.setDirection(sun_direction); - mSun.setAngularVelocity(sun_ang_velocity); - mMoon.setDirection(-sun_direction); - calcAtmospherics(); - if (dp < 0.995f) { //the sun jumped a great deal, update immediately - mForceUpdate = TRUE; - } + updateDirections(); + + mForceUpdate = true; } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 9cfb9773bd..a9ef5474b6 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -30,86 +30,22 @@ #include "stdtypes.h" #include "v3color.h" #include "v4coloru.h" +#include "llquaternion.h" #include "llviewertexture.h" #include "llviewerobject.h" #include "llframetimer.h" +#include "v3colorutil.h" +#include "llsettingssky.h" +#include "lllegacyatmospherics.h" - -////////////////////////////////// -// -// Lots of constants -// -// Will clean these up at some point... -// - -const F32 HORIZON_DIST = 1024.0f; const F32 SKY_BOX_MULT = 16.0f; -const F32 HEAVENLY_BODY_DIST = HORIZON_DIST - 10.f; +const F32 HEAVENLY_BODY_DIST = HORIZON_DIST - 20.f; const F32 HEAVENLY_BODY_FACTOR = 0.1f; const F32 HEAVENLY_BODY_SCALE = HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR; -const F32 EARTH_RADIUS = 6.4e6f; // exact radius = 6.37 x 10^6 m -const F32 ATM_EXP_FALLOFF = 0.000126f; -const F32 ATM_SEA_LEVEL_NDENS = 2.55e25f; -// Somewhat arbitrary: -const F32 ATM_HEIGHT = 100000.f; - -const F32 FIRST_STEP = 5000.f; -const F32 INV_FIRST_STEP = 1.f/FIRST_STEP; -const S32 NO_STEPS = 15; -const F32 INV_NO_STEPS = 1.f/NO_STEPS; - - -// constants used in calculation of scattering coeff of clear air -const F32 sigma = 0.035f; -const F32 fsigma = (6.f + 3.f * sigma) / (6.f-7.f*sigma); -const F64 Ndens = 2.55e25; -const F64 Ndens2 = Ndens*Ndens; - -// HACK: Allow server to change sun and moon IDs. -// I can't figure out how to pass the appropriate -// information into the LLVOSky constructor. JC -extern LLUUID gSunTextureID; -extern LLUUID gMoonTextureID; - - -LL_FORCE_INLINE LLColor3 color_div(const LLColor3 &col1, const LLColor3 &col2) -{ - return LLColor3( - col1.mV[0] / col2.mV[0], - col1.mV[1] / col2.mV[1], - col1.mV[2] / col2.mV[2] ); -} - -LLColor3 color_norm(const LLColor3 &col); -BOOL clip_quad_to_horizon(F32& t_left, F32& t_right, LLVector3 v_clipped[4], - const LLVector3 v_corner[4], const F32 cos_max_angle); -F32 clip_side_to_horizon(const LLVector3& v0, const LLVector3& v1, const F32 cos_max_angle); - -inline F32 color_intens ( const LLColor3 &col ) -{ - return col.mV[0] + col.mV[1] + col.mV[2]; -} - -inline F32 color_max(const LLColor3 &col) -{ - return llmax(col.mV[0], col.mV[1], col.mV[2]); -} - -inline F32 color_max(const LLColor4 &col) -{ - return llmax(col.mV[0], col.mV[1], col.mV[2]); -} - - -inline F32 color_min(const LLColor3 &col) -{ - return llmin(col.mV[0], col.mV[1], col.mV[2]); -} class LLFace; class LLHaze; - class LLSkyTex { friend class LLVOSky; @@ -139,11 +75,11 @@ protected: ~LLSkyTex(); - static S32 getResolution() { return sResolution; } - static S32 getCurrent() { return sCurrent; } - static S32 stepCurrent() { sCurrent++; sCurrent &= 1; return sCurrent; } - static S32 getNext() { return ((sCurrent+1) & 1); } - static S32 getWhich(const BOOL curr) { return curr ? sCurrent : getNext(); } + static S32 getResolution(); + static S32 getCurrent(); + static S32 stepCurrent(); + static S32 getNext(); + static S32 getWhich(const BOOL curr); void initEmpty(const S32 tex); @@ -183,7 +119,7 @@ protected: return col; } - LLImageRaw* getImageRaw(BOOL curr=TRUE) { return mImageRaw[getWhich(curr)]; } + LLImageRaw* getImageRaw(BOOL curr=TRUE); void createGLImage(BOOL curr=TRUE); }; @@ -197,244 +133,70 @@ protected: LLColor3 mColorCached; F32 mIntensity; LLVector3 mDirection; // direction of the local heavenly body + LLQuaternion mRotation; LLVector3 mAngularVelocity; // velocity of the local heavenly body F32 mDiskRadius; - BOOL mDraw; // FALSE - do not draw. + bool mDraw; // FALSE - do not draw. F32 mHorizonVisibility; // number [0, 1] due to how horizon F32 mVisibility; // same but due to other objects being in throng. - BOOL mVisible; + bool mVisible; static F32 sInterpVal; LLVector3 mQuadCorner[4]; - LLVector3 mU; - LLVector3 mV; LLVector3 mO; public: - LLHeavenBody(const F32 rad) : - mDirectionCached(LLVector3(0,0,0)), - mDirection(LLVector3(0,0,0)), - mIntensity(0.f), - mDiskRadius(rad), mDraw(FALSE), - mHorizonVisibility(1.f), mVisibility(1.f), - mVisible(FALSE) - { - mColor.setToBlack(); - mColorCached.setToBlack(); - } + LLHeavenBody(const F32 rad); ~LLHeavenBody() {} - const LLVector3& getDirection() const { return mDirection; } - void setDirection(const LLVector3 &direction) { mDirection = direction; } - void setAngularVelocity(const LLVector3 &ang_vel) { mAngularVelocity = ang_vel; } - const LLVector3& getAngularVelocity() const { return mAngularVelocity; } - - const LLVector3& getDirectionCached() const { return mDirectionCached; } - void renewDirection() { mDirectionCached = mDirection; } + const LLQuaternion& getRotation() const; + void setRotation(const LLQuaternion& rot); - const LLColor3& getColorCached() const { return mColorCached; } - void setColorCached(const LLColor3& c) { mColorCached = c; } - const LLColor3& getColor() const { return mColor; } - void setColor(const LLColor3& c) { mColor = c; } + const LLVector3& getDirection() const; + void setDirection(const LLVector3 &direction); + void setAngularVelocity(const LLVector3 &ang_vel); + const LLVector3& getAngularVelocity() const; - void renewColor() { mColorCached = mColor; } - - static F32 interpVal() { return sInterpVal; } - static void setInterpVal(const F32 v) { sInterpVal = v; } - - LLColor3 getInterpColor() const - { - return sInterpVal * mColor + (1 - sInterpVal) * mColorCached; - } + const LLVector3& getDirectionCached() const; + void renewDirection(); - const F32& getHorizonVisibility() const { return mHorizonVisibility; } - void setHorizonVisibility(const F32 c = 1) { mHorizonVisibility = c; } - const F32& getVisibility() const { return mVisibility; } - void setVisibility(const F32 c = 1) { mVisibility = c; } - F32 getHaloBrighness() const - { - return llmax(0.f, llmin(0.9f, mHorizonVisibility)) * mVisibility; - } - BOOL isVisible() const { return mVisible; } - void setVisible(const BOOL v) { mVisible = v; } + const LLColor3& getColorCached() const; + void setColorCached(const LLColor3& c); + const LLColor3& getColor() const; + void setColor(const LLColor3& c); - const F32& getIntensity() const { return mIntensity; } - void setIntensity(const F32 c) { mIntensity = c; } + void renewColor(); - void setDiskRadius(const F32 radius) { mDiskRadius = radius; } - F32 getDiskRadius() const { return mDiskRadius; } + static F32 interpVal(); + static void setInterpVal(const F32 v); - void setDraw(const BOOL draw) { mDraw = draw; } - BOOL getDraw() const { return mDraw; } + LLColor3 getInterpColor() const; - const LLVector3& corner(const S32 n) const { return mQuadCorner[n]; } - LLVector3& corner(const S32 n) { return mQuadCorner[n]; } - const LLVector3* corners() const { return mQuadCorner; } + const F32& getVisibility() const; + void setVisibility(const F32 c = 1); - const LLVector3& getU() const { return mU; } - const LLVector3& getV() const { return mV; } - void setU(const LLVector3& u) { mU = u; } - void setV(const LLVector3& v) { mV = v; } -}; + bool isVisible() const; + void setVisible(const bool v); + const F32& getIntensity() const; + void setIntensity(const F32 c); -LL_FORCE_INLINE LLColor3 refr_ind_calc(const LLColor3 &wave_length) -{ - LLColor3 refr_ind; - for (S32 i = 0; i < 3; ++i) - { - const F32 wl2 = wave_length.mV[i] * wave_length.mV[i] * 1e-6f; - refr_ind.mV[i] = 6.43e3f + ( 2.95e6f / ( 146.0f - 1.f/wl2 ) ) + ( 2.55e4f / ( 41.0f - 1.f/wl2 ) ); - refr_ind.mV[i] *= 1.0e-8f; - refr_ind.mV[i] += 1.f; - } - return refr_ind; -} + void setDiskRadius(const F32 radius); + F32 getDiskRadius() const; + void setDraw(const bool draw); + bool getDraw() const; -class LLHaze -{ -public: - LLHaze() : mG(0), mFalloff(1), mAbsCoef(0.f) {mSigSca.setToBlack();} - LLHaze(const F32 g, const LLColor3& sca, const F32 fo = 2.f) : - mG(g), mSigSca(0.25f/F_PI * sca), mFalloff(fo), mAbsCoef(0.f) - { - mAbsCoef = color_intens(mSigSca) / sAirScaIntense; - } - - LLHaze(const F32 g, const F32 sca, const F32 fo = 2.f) : mG(g), - mSigSca(0.25f/F_PI * LLColor3(sca, sca, sca)), mFalloff(fo) - { - mAbsCoef = 0.01f * sca / sAirScaAvg; - } - - F32 getG() const { return mG; } - - void setG(const F32 g) - { - mG = g; - } - - const LLColor3& getSigSca() const // sea level - { - return mSigSca; - } - - void setSigSca(const LLColor3& s) - { - mSigSca = s; - mAbsCoef = 0.01f * color_intens(mSigSca) / sAirScaIntense; - } - - void setSigSca(const F32 s0, const F32 s1, const F32 s2) - { - mSigSca = sAirScaAvg * LLColor3 (s0, s1, s2); - mAbsCoef = 0.01f * (s0 + s1 + s2) / 3; - } - - F32 getFalloff() const - { - return mFalloff; - } - - void setFalloff(const F32 fo) - { - mFalloff = fo; - } - - F32 getAbsCoef() const - { - return mAbsCoef; - } - - inline static F32 calcFalloff(const F32 h) - { - return (h <= 0) ? 1.0f : (F32)LL_FAST_EXP(-ATM_EXP_FALLOFF * h); - } - - inline LLColor3 calcSigSca(const F32 h) const - { - return calcFalloff(h * mFalloff) * mSigSca; - } - - inline void calcSigSca(const F32 h, LLColor3 &result) const - { - result = mSigSca; - result *= calcFalloff(h * mFalloff); - } - - LLColor3 calcSigExt(const F32 h) const - { - return calcFalloff(h * mFalloff) * (1 + mAbsCoef) * mSigSca; - } - - F32 calcPhase(const F32 cos_theta) const; - - static inline LLColor3 calcAirSca(const F32 h); - static inline void calcAirSca(const F32 h, LLColor3 &result); - -private: - static LLColor3 const sAirScaSeaLevel; - static F32 const sAirScaIntense; - static F32 const sAirScaAvg; - -protected: - F32 mG; - LLColor3 mSigSca; - F32 mFalloff; // 1 - slow, >1 - faster - F32 mAbsCoef; + const LLVector3& corner(const S32 n) const; + LLVector3& corner(const S32 n); + const LLVector3* corners() const; }; - class LLCubeMap; -// turn on floating point precision -// in vs2003 for this class. Otherwise -// black dots go everywhere from 7:10 - 8:50 -#if LL_MSVC && __MSVC_VER__ < 8 -#pragma optimize("p", on) -#endif - - class LLVOSky : public LLStaticViewerObject { -public: - /// WL PARAMS - F32 dome_radius; - F32 dome_offset_ratio; - LLColor3 sunlight_color; - LLColor3 ambient; - F32 gamma; - LLVector4 lightnorm; - LLVector4 unclamped_lightnorm; - LLColor3 blue_density; - LLColor3 blue_horizon; - F32 haze_density; - F32 haze_horizon; - F32 density_multiplier; - F32 max_y; - LLColor3 glow; - F32 cloud_shadow; - LLColor3 cloud_color; - F32 cloud_scale; - LLColor3 cloud_pos_density1; - LLColor3 cloud_pos_density2; - -public: - void initAtmospherics(void); - void calcAtmospherics(void); - LLColor3 createDiffuseFromWL(LLColor3 diffuse, LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient); - LLColor3 createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient); - - void calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorSun, - LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, - LLVector2 vary_HorizontalProjection[2]); - - LLColor3 calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorSun, - LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, - LLVector2 vary_HorizontalProjection[2]); - -public: +public: enum { FACE_SIDE0, @@ -447,7 +209,6 @@ public: FACE_MOON, // was 7 FACE_BLOOM, // was 8 FACE_REFLECTION, // was 10 - FACE_DUMMY, //for an ATI bug --bao FACE_COUNT }; @@ -461,8 +222,10 @@ public: void cleanupGL(); void restoreGL(); + void calc(); + /*virtual*/ void idleUpdate(LLAgent &agent, const F64 &time); - BOOL updateSky(); + bool updateSky(); // Graphical stuff for objects - maybe broken out into render class // later? @@ -470,65 +233,31 @@ public: /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); - void initSkyTextureDirs(const S32 side, const S32 tile); - void createSkyTexture(const S32 side, const S32 tile); - - LLColor4 calcSkyColorInDir(const LLVector3& dir, bool isShiny = false); - - LLColor3 calcRadianceAtPoint(const LLVector3& pos) const - { - F32 radiance = mBrightnessScaleGuess * mSun.getIntensity(); - return LLColor3(radiance, radiance, radiance); - } - - const LLHeavenBody& getSun() const { return mSun; } + const LLHeavenBody& getSun() const { return mSun; } const LLHeavenBody& getMoon() const { return mMoon; } - const LLVector3& getToSunLast() const { return mSun.getDirectionCached(); } - const LLVector3& getToSun() const { return mSun.getDirection(); } - const LLVector3& getToMoon() const { return mMoon.getDirection(); } - const LLVector3& getToMoonLast() const { return mMoon.getDirectionCached(); } - BOOL isSunUp() const { return mSun.getDirectionCached().mV[2] > -0.05f; } - void calculateColors(); - - LLColor3 getSunDiffuseColor() const { return mSunDiffuse; } - LLColor3 getMoonDiffuseColor() const { return mMoonDiffuse; } - LLColor4 getSunAmbientColor() const { return mSunAmbient; } - LLColor4 getMoonAmbientColor() const { return mMoonAmbient; } - const LLColor4& getTotalAmbientColor() const { return mTotalAmbient; } - LLColor4 getFogColor() const { return mFogColor; } - LLColor4 getGLFogColor() const { return mGLFogCol; } - - BOOL isSameFace(S32 idx, const LLFace* face) const { return mFace[idx] == face; } - - void initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity); + bool isSameFace(S32 idx, const LLFace* face) const { return mFace[idx] == face; } - void setSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity); + // directions provided should already be in CFR coord sys (+x at, +z up, +y right) + void setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir, const LLVector3 &moon_dir); + void setSunDirectionCFR(const LLVector3 &sun_direction); + void setMoonDirectionCFR(const LLVector3 &moon_direction); - BOOL updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 side, const BOOL is_sun, - LLHeavenBody& hb, const F32 sin_max_angle, - const LLVector3 &up, const LLVector3 &right); - - F32 cosHorizon(const F32 delta = 0) const - { - const F32 sin_angle = EARTH_RADIUS/(EARTH_RADIUS + mCameraPosAgent.mV[2]); - return delta - (F32)sqrt(1.f - sin_angle * sin_angle); - } - - void updateSunHaloGeometry(LLDrawable *drawable); + bool updateHeavenlyBodyGeometry(LLDrawable *drawable, F32 scale, const S32 side, LLHeavenBody& hb, const LLVector3 &up, const LLVector3 &right); void updateReflectionGeometry(LLDrawable *drawable, F32 H, const LLHeavenBody& HB); - - const LLHaze& getHaze() const { return mHaze; } - LLHaze& getHaze() { return mHaze; } - F32 getHazeConcentration() const { return mHazeConcentration; } - void setHaze(const LLHaze& h) { mHaze = h; } F32 getWorldScale() const { return mWorldScale; } void setWorldScale(const F32 s) { mWorldScale = s; } void updateFog(const F32 distance); - void setFogRatio(const F32 fog_ratio) { mFogRatio = fog_ratio; } - LLColor4U getFadeColor() const { return mFadeColor; } - F32 getFogRatio() const { return mFogRatio; } + + void setFogRatio(const F32 fog_ratio) { m_legacyAtmospherics.setFogRatio(fog_ratio); } + F32 getFogRatio() const { return m_legacyAtmospherics.getFogRatio(); } + + LLColor4 getSkyFogColor() const { return m_legacyAtmospherics.getFogColor(); } + LLColor4 getGLFogColor() const { return m_legacyAtmospherics.getGLFogColor(); } + + LLColor4U getFadeColor() const; + void setCloudDensity(F32 cloud_density) { mCloudDensity = cloud_density; } void setWind ( const LLVector3& wind ) { mWind = wind.length(); } @@ -538,12 +267,30 @@ public: LLCubeMap *getCubeMap() const { return mCubeMap; } S32 getDrawRefl() const { return mDrawRefl; } void setDrawRefl(const S32 r) { mDrawRefl = r; } - BOOL isReflFace(const LLFace* face) const { return face == mFace[FACE_REFLECTION]; } + bool isReflFace(const LLFace* face) const { return face == mFace[FACE_REFLECTION]; } LLFace* getReflFace() const { return mFace[FACE_REFLECTION]; } - LLViewerTexture* getSunTex() const { return mSunTexturep; } - LLViewerTexture* getMoonTex() const { return mMoonTexturep; } - LLViewerTexture* getBloomTex() const { return mBloomTexturep; } + LLViewerTexture* getSunTex() const { return mSunTexturep[0]; } + LLViewerTexture* getMoonTex() const { return mMoonTexturep[0]; } + LLViewerTexture* getBloomTex() const { return mBloomTexturep[0]; } + LLViewerTexture* getCloudNoiseTex() const { return mCloudNoiseTexturep[0]; } + + LLViewerTexture* getRainbowTex() const { return mRainbowMap; } + LLViewerTexture* getHaloTex() const { return mHaloMap; } + + LLViewerTexture* getSunTexNext() const { return mSunTexturep[1]; } + LLViewerTexture* getMoonTexNext() const { return mMoonTexturep[1]; } + LLViewerTexture* getBloomTexNext() const { return mBloomTexturep[1]; } + LLViewerTexture* getCloudNoiseTexNext() const { return mCloudNoiseTexturep[1]; } + + void setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next); + void setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_texture_next); + void setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUID& cloud_noise_texture_next); + void setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next); + + void setSunScale(F32 sun_scale); + void setMoonScale(F32 sun_scale); + void forceSkyUpdate(void) { mForceUpdate = TRUE; } public: @@ -553,9 +300,20 @@ public: protected: ~LLVOSky(); - LLPointer<LLViewerFetchedTexture> mSunTexturep; - LLPointer<LLViewerFetchedTexture> mMoonTexturep; - LLPointer<LLViewerFetchedTexture> mBloomTexturep; + void updateDirections(void); + + void initSkyTextureDirs(const S32 side, const S32 tile); + void createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, bool skip_sky_tex); + + LLPointer<LLViewerFetchedTexture> mSunTexturep[2]; + LLPointer<LLViewerFetchedTexture> mMoonTexturep[2]; + LLPointer<LLViewerFetchedTexture> mCloudNoiseTexturep[2]; + LLPointer<LLViewerFetchedTexture> mBloomTexturep[2]; + LLPointer<LLViewerFetchedTexture> mRainbowMap; + LLPointer<LLViewerFetchedTexture> mHaloMap; + + F32 mSunScale = 1.0f; + F32 mMoonScale = 1.0f; static S32 sResolution; static S32 sTileResX; @@ -575,73 +333,29 @@ protected: LLColor3 mBrightestPointNew; F32 mBrightnessScaleGuess; LLColor3 mBrightestPointGuess; - LLHaze mHaze; - F32 mHazeConcentration; - BOOL mWeatherChange; + bool mWeatherChange; F32 mCloudDensity; F32 mWind; - BOOL mInitialized; - BOOL mForceUpdate; //flag to force instantaneous update of cubemap - LLVector3 mLastLightingDirection; + bool mInitialized; + bool mForceUpdate; //flag to force instantaneous update of cubemap + LLVector3 mLastSunLightingDirection; + LLVector3 mLastMoonLightingDirection; LLColor3 mLastTotalAmbient; F32 mAmbientScale; LLColor3 mNightColorShift; F32 mInterpVal; - - LLColor4 mFogColor; - LLColor4 mGLFogCol; - - F32 mFogRatio; F32 mWorldScale; - LLColor4 mSunAmbient; - LLColor4 mMoonAmbient; - LLColor4 mTotalAmbient; - LLColor3 mSunDiffuse; - LLColor3 mMoonDiffuse; - LLColor4U mFadeColor; // Color to fade in from - - LLPointer<LLCubeMap> mCubeMap; // Cube map for the environment - S32 mDrawRefl; + LLPointer<LLCubeMap> mCubeMap; // Cube map for the environment + S32 mDrawRefl; LLFrameTimer mUpdateTimer; + LLTimer mForceUpdateThrottle; + bool mHeavenlyBodyUpdated ; -public: - //by bao - //fake vertex buffer updating - //to guarantee at least updating one VBO buffer every frame - //to work around the bug caused by ATI card --> DEV-3855 - // - void createDummyVertexBuffer() ; - void updateDummyVertexBuffer() ; - - BOOL mHeavenlyBodyUpdated ; + AtmosphericsVars m_atmosphericsVars; + LLAtmospherics m_legacyAtmospherics; }; -// turn it off -#if LL_MSVC && __MSVC_VER__ < 8 -#pragma optimize("p", off) -#endif - -// Utility functions -F32 azimuth(const LLVector3 &v); -F32 color_norm_pow(LLColor3& col, F32 e, BOOL postmultiply = FALSE); - - -/* Proportion of light that is scattered into 'path' from 'in' over distance dt. */ -/* assumes that vectors 'path' and 'in' are normalized. Scattering coef / 2pi */ - -inline LLColor3 LLHaze::calcAirSca(const F32 h) -{ - return calcFalloff(h) * sAirScaSeaLevel; -} - -inline void LLHaze::calcAirSca(const F32 h, LLColor3 &result) -{ - result = sAirScaSeaLevel; - result *= calcFalloff(h); -} - - #endif diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 24726e61e8..671f4d49a7 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5859,7 +5859,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) spec_mask = spec_mask | LLVertexBuffer::MAP_EMISSIVE; } - BOOL batch_textures = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 1; + BOOL batch_textures = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 1; if (batch_textures) { diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 3b9b96e9f1..37689e0683 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -32,14 +32,12 @@ #include "llsky.h" #include "lldrawpoolwlsky.h" #include "llface.h" -#include "llwlparammanager.h" #include "llviewercontrol.h" +#include "llenvironment.h" +#include "llsettingssky.h" -#define DOME_SLICES 1 -const F32 LLVOWLSky::DISTANCE_TO_STARS = (HORIZON_DIST - 10.f)*0.25f; - -const U32 LLVOWLSky::MIN_SKY_DETAIL = 3; -const U32 LLVOWLSky::MAX_SKY_DETAIL = 180; +static const U32 MIN_SKY_DETAIL = 8; +static const U32 MAX_SKY_DETAIL = 180; inline U32 LLVOWLSky::getNumStacks(void) { @@ -51,16 +49,6 @@ inline U32 LLVOWLSky::getNumSlices(void) return 2 * llmin(MAX_SKY_DETAIL, llmax(MIN_SKY_DETAIL, gSavedSettings.getU32("WLSkyDetail"))); } -inline U32 LLVOWLSky::getFanNumVerts(void) -{ - return getNumSlices() + 1; -} - -inline U32 LLVOWLSky::getFanNumIndices(void) -{ - return getNumSlices() * 3; -} - inline U32 LLVOWLSky::getStripsNumVerts(void) { return (getNumStacks() - 1) * getNumSlices(); @@ -87,11 +75,6 @@ LLVOWLSky::LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regi initStars(); } -void LLVOWLSky::initSunDirection(LLVector3 const & sun_direction, - LLVector3 const & sun_angular_velocity) -{ -} - void LLVOWLSky::idleUpdate(LLAgent &agent, const F64 &time) { @@ -120,177 +103,31 @@ inline F32 LLVOWLSky::calcPhi(U32 i) F32 t = float(i) / float(getNumStacks()); // ^4 the parameter of the tesselation to bias things toward 0 (the dome's apex) - t = t*t*t*t; - + t *= t; + t *= t; + // invert and square the parameter of the tesselation to bias things toward 1 (the horizon) t = 1.f - t; t = t*t; t = 1.f - t; - return (F_PI / 8.f) * t; -} - -#if !DOME_SLICES -static const F32 Q = (1.f + sqrtf(5.f))/2.f; //golden ratio - -//icosahedron verts (based on asset b0c7b76e-28c6-1f87-a1de-752d5e3cd264, contact Runitai Linden for a copy) -static const LLVector3 icosahedron_vert[] = -{ - LLVector3(0,1.f,Q), - LLVector3(0,-1.f,Q), - LLVector3(0,-1.f,-Q), - LLVector3(0,1.f,-Q), - - LLVector3(Q,0,1.f), - LLVector3(-Q,0,1.f), - LLVector3(-Q,0,-1.f), - LLVector3(Q,0,-1.f), - - LLVector3(1,-Q,0.f), - LLVector3(-1,-Q,0.f), - LLVector3(-1,Q,0.f), - LLVector3(1,Q,0.f), -}; - -//indices -static const U32 icosahedron_ind[] = -{ - 5,0,1, - 10,0,5, - 5,1,9, - 10,5,6, - 6,5,9, - 11,0,10, - 3,11,10, - 3,10,6, - 3,6,2, - 7,3,2, - 8,7,2, - 4,7,8, - 1,4,8, - 9,8,2, - 9,2,6, - 11,3,7, - 4,0,11, - 4,11,7, - 1,0,4, - 1,8,9, -}; - - -//split every triangle in LLVertexBuffer into even fourths (assumes index triangle lists) -void subdivide(LLVertexBuffer& in, LLVertexBuffer* ret) -{ - S32 tri_in = in.getNumIndices()/3; - - ret->allocateBuffer(tri_in*4*3, tri_in*4*3, TRUE); - - LLStrider<LLVector3> vin, vout; - LLStrider<U16> indin, indout; - - ret->getVertexStrider(vout); - in.getVertexStrider(vin); - - ret->getIndexStrider(indout); - in.getIndexStrider(indin); - - - for (S32 i = 0; i < tri_in; i++) - { - LLVector3 v0 = vin[*indin++]; - LLVector3 v1 = vin[*indin++]; - LLVector3 v2 = vin[*indin++]; - - LLVector3 v3 = (v0 + v1) * 0.5f; - LLVector3 v4 = (v1 + v2) * 0.5f; - LLVector3 v5 = (v2 + v0) * 0.5f; - - *vout++ = v0; - *vout++ = v3; - *vout++ = v5; - - *vout++ = v3; - *vout++ = v4; - *vout++ = v5; - - *vout++ = v3; - *vout++ = v1; - *vout++ = v4; - - *vout++ = v5; - *vout++ = v4; - *vout++ = v2; - } - - for (S32 i = 0; i < ret->getNumIndices(); i++) - { - *indout++ = i; - } - -} - -void chop(LLVertexBuffer& in, LLVertexBuffer* out) -{ - //chop off all triangles below horizon - F32 d = LLWLParamManager::sParamMgr->getDomeOffset() * LLWLParamManager::sParamMgr->getDomeRadius(); - - std::vector<LLVector3> vert; - - LLStrider<LLVector3> vin; - LLStrider<U16> index; - - in.getVertexStrider(vin); - in.getIndexStrider(index); - - U32 tri_count = in.getNumIndices()/3; - for (U32 i = 0; i < tri_count; i++) - { - LLVector3 &v1 = vin[index[i*3+0]]; - LLVector3 &v2 = vin[index[i*3+1]]; - LLVector3 &v3 = vin[index[i*3+2]]; - - if (v1.mV[1] > d || - v2.mV[1] > d || - v3.mV[1] > d) - { - v1.mV[1] = llmax(v1.mV[1], d); - v2.mV[1] = llmax(v1.mV[1], d); - v3.mV[1] = llmax(v1.mV[1], d); - - vert.push_back(v1); - vert.push_back(v2); - vert.push_back(v3); - } - } - - out->allocateBuffer(vert.size(), vert.size(), TRUE); - - LLStrider<LLVector3> vout; - out->getVertexStrider(vout); - out->getIndexStrider(index); - - for (U32 i = 0; i < vert.size(); i++) - { - *vout++ = vert[i]; - *index++ = i; - } + return F_PI_BY_TWO * t; } -#endif // !DOME_SLICES void LLVOWLSky::resetVertexBuffers() { - mFanVerts = NULL; mStripsVerts.clear(); - mStarsVerts = NULL; + mStarsVerts = nullptr; + mFsSkyVerts = nullptr; gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); } void LLVOWLSky::cleanupGL() { - mFanVerts = NULL; mStripsVerts.clear(); - mStarsVerts = NULL; + mStarsVerts = nullptr; + mFsSkyVerts = nullptr; LLDrawPoolWLSky::cleanupGL(); } @@ -305,34 +142,48 @@ static LLTrace::BlockTimerStatHandle FTM_GEO_SKY("Windlight Sky Geometry"); BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) { - LL_RECORD_BLOCK_TIME(FTM_GEO_SKY); + LL_RECORD_BLOCK_TIME(FTM_GEO_SKY); LLStrider<LLVector3> vertices; LLStrider<LLVector2> texCoords; LLStrider<U16> indices; -#if DOME_SLICES - { - mFanVerts = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); - if (!mFanVerts->allocateBuffer(getFanNumVerts(), getFanNumIndices(), TRUE)) + if (mFsSkyVerts.isNull()) + { + mFsSkyVerts = new LLVertexBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); + + if (!mFsSkyVerts->allocateBuffer(4, 6, TRUE)) { - LL_WARNS() << "Failed to allocate Vertex Buffer on sky update to " - << getFanNumVerts() << " vertices and " - << getFanNumIndices() << " indices" << LL_ENDL; + LL_WARNS() << "Failed to allocate Vertex Buffer on full screen sky update" << LL_ENDL; } - BOOL success = mFanVerts->getVertexStrider(vertices) - && mFanVerts->getTexCoord0Strider(texCoords) - && mFanVerts->getIndexStrider(indices); + BOOL success = mFsSkyVerts->getVertexStrider(vertices) + && mFsSkyVerts->getTexCoord0Strider(texCoords) + && mFsSkyVerts->getIndexStrider(indices); if(!success) { - LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL; + LL_ERRS() << "Failed updating WindLight fullscreen sky geometry." << LL_ENDL; } - buildFanBuffer(vertices, texCoords, indices); + *vertices++ = LLVector3(-1.0f, -1.0f, 0.0f); + *vertices++ = LLVector3( 1.0f, -1.0f, 0.0f); + *vertices++ = LLVector3(-1.0f, 1.0f, 0.0f); + *vertices++ = LLVector3( 1.0f, 1.0f, 0.0f); - mFanVerts->flush(); - } + *texCoords++ = LLVector2(0.0f, 0.0f); + *texCoords++ = LLVector2(1.0f, 0.0f); + *texCoords++ = LLVector2(0.0f, 1.0f); + *texCoords++ = LLVector2(1.0f, 1.0f); + + *indices++ = 0; + *indices++ = 1; + *indices++ = 2; + *indices++ = 1; + *indices++ = 3; + *indices++ = 2; + + mFsSkyVerts->flush(); + } { const U32 max_buffer_bytes = gSavedSettings.getS32("RenderMaxVBOSize")*1024; @@ -406,85 +257,6 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) LL_INFOS() << "completed in " << llformat("%.2f", timer.getElapsedTimeF32().value()) << "seconds" << LL_ENDL; } -#else - mStripsVerts = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); - - const F32 RADIUS = LLWLParamManager::sParamMgr->getDomeRadius(); - - LLPointer<LLVertexBuffer> temp = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, 0); - temp->allocateBuffer(12, 60, TRUE); - - BOOL success = temp->getVertexStrider(vertices) - && temp->getIndexStrider(indices); - - if (success) - { - for (U32 i = 0; i < 12; i++) - { - *vertices++ = icosahedron_vert[i]; - } - - for (U32 i = 0; i < 60; i++) - { - *indices++ = icosahedron_ind[i]; - } - } - - - LLPointer<LLVertexBuffer> temp2; - - for (U32 i = 0; i < 8; i++) - { - temp2 = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, 0); - subdivide(*temp, temp2); - temp = temp2; - } - - temp->getVertexStrider(vertices); - for (S32 i = 0; i < temp->getNumVerts(); i++) - { - LLVector3 v = vertices[i]; - v.normVec(); - vertices[i] = v*RADIUS; - } - - temp2 = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX, 0); - chop(*temp, temp2); - - mStripsVerts->allocateBuffer(temp2->getNumVerts(), temp2->getNumIndices(), TRUE); - - success = mStripsVerts->getVertexStrider(vertices) - && mStripsVerts->getTexCoordStrider(texCoords) - && mStripsVerts->getIndexStrider(indices); - - LLStrider<LLVector3> v; - temp2->getVertexStrider(v); - LLStrider<U16> ind; - temp2->getIndexStrider(ind); - - if (success) - { - for (S32 i = 0; i < temp2->getNumVerts(); ++i) - { - LLVector3 vert = *v++; - vert.normVec(); - F32 z0 = vert.mV[2]; - F32 x0 = vert.mV[0]; - - vert *= RADIUS; - - *vertices++ = vert; - *texCoords++ = LLVector2((-z0 + 1.f) / 2.f, (-x0 + 1.f) / 2.f); - } - - for (S32 i = 0; i < temp2->getNumIndices(); ++i) - { - *indices++ = *ind++; - } - } - - mStripsVerts->flush(); -#endif updateStarColors(); updateStarGeometry(drawable); @@ -504,6 +276,21 @@ void LLVOWLSky::drawStars(void) } } +void LLVOWLSky::drawFsSky(void) +{ + if (mFsSkyVerts.isNull()) + { + updateGeometry(mDrawable); + } + + LLGLDisable disable_blend(GL_BLEND); + + mFsSkyVerts->setBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK); + mFsSkyVerts->drawRange(LLRender::TRIANGLES, 0, mFsSkyVerts->getNumVerts() - 1, mFsSkyVerts->getNumIndices(), 0); + gPipeline.addTrianglesDrawn(mFsSkyVerts->getNumIndices(), LLRender::TRIANGLES); + LLVertexBuffer::unbind(); +} + void LLVOWLSky::drawDome(void) { if (mStripsVerts.empty()) @@ -511,11 +298,12 @@ void LLVOWLSky::drawDome(void) updateGeometry(mDrawable); } - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); + // This is handled upstream now as we may make different decisions + // for some dome users (the sky) than for others (the clouds) + //LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); const U32 data_mask = LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK; -#if DOME_SLICES std::vector< LLPointer<LLVertexBuffer> >::const_iterator strips_vbo_iter, end_strips; end_strips = mStripsVerts.end(); for(strips_vbo_iter = mStripsVerts.begin(); strips_vbo_iter != end_strips; ++strips_vbo_iter) @@ -531,21 +319,13 @@ void LLVOWLSky::drawDome(void) gPipeline.addTrianglesDrawn(strips_segment->getNumIndices(), LLRender::TRIANGLE_STRIP); } -#else - mStripsVerts->setBuffer(data_mask); - gGL.syncMatrices(); - glDrawRangeElements( - GL_TRIANGLES, - 0, mStripsVerts->getNumVerts()-1, mStripsVerts->getNumIndices(), - GL_UNSIGNED_SHORT, - mStripsVerts->getIndicesPointer()); -#endif - LLVertexBuffer::unbind(); } void LLVOWLSky::initStars() { + const F32 DISTANCE_TO_STARS = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); + // Initialize star map mStarVertices.resize(getStarsNumVerts()); mStarColors.resize(getStarsNumVerts()); @@ -580,72 +360,12 @@ void LLVOWLSky::initStars() } } -void LLVOWLSky::buildFanBuffer(LLStrider<LLVector3> & vertices, - LLStrider<LLVector2> & texCoords, - LLStrider<U16> & indices) -{ - const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); - - U32 i, num_slices; - F32 phi0, theta, x0, y0, z0; - - // paranoia checking for SL-55986/SL-55833 - U32 count_verts = 0; - U32 count_indices = 0; - - // apex - *vertices++ = LLVector3(0.f, RADIUS, 0.f); - *texCoords++ = LLVector2(0.5f, 0.5f); - ++count_verts; - - num_slices = getNumSlices(); - - // and fan in a circle around the apex - phi0 = calcPhi(1); - for(i = 0; i < num_slices; ++i) { - theta = 2.f * F_PI * float(i) / float(num_slices); - - // standard transformation from spherical to - // rectangular coordinates - x0 = sin(phi0) * cos(theta); - y0 = cos(phi0); - z0 = sin(phi0) * sin(theta); - - *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); - // generate planar uv coordinates - // note: x and z are transposed in order for things to animate - // correctly in the global coordinate system where +x is east and - // +y is north - *texCoords++ = LLVector2((-z0 + 1.f) / 2.f, (-x0 + 1.f) / 2.f); - ++count_verts; - - if (i > 0) - { - *indices++ = 0; - *indices++ = i; - *indices++ = i+1; - count_indices += 3; - } - } - - // the last vertex of the last triangle should wrap around to - // the beginning - *indices++ = 0; - *indices++ = num_slices; - *indices++ = 1; - count_indices += 3; - - // paranoia checking for SL-55986/SL-55833 - llassert(getFanNumVerts() == count_verts); - llassert(getFanNumIndices() == count_indices); -} - void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, LLStrider<LLVector3> & vertices, LLStrider<LLVector2> & texCoords, LLStrider<U16> & indices) { - const F32 RADIUS = LLWLParamManager::getInstance()->getDomeRadius(); + const F32 RADIUS = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); U32 i, j, num_slices, num_stacks; F32 phi0, theta, x0, y0, z0; @@ -674,25 +394,15 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, y0 = cos(phi0); z0 = sin(phi0) * sin(theta); - if (i == num_stacks-2) - { - *vertices++ = LLVector3(x0*RADIUS, y0*RADIUS-1024.f*2.f, z0*RADIUS); - } - else if (i == num_stacks-1) - { - *vertices++ = LLVector3(0, y0*RADIUS-1024.f*2.f, 0); - } - else - { - *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); - } + *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); + ++count_verts; // generate planar uv coordinates // note: x and z are transposed in order for things to animate // correctly in the global coordinate system where +x is east and // +y is north - *texCoords++ = LLVector2((-z0 + 1.f) / 2.f, (-x0 + 1.f) / 2.f); + *texCoords++ = LLVector2((-z0 + 1.f) / 2.f, (-x0 + 1.f) / 2.f); } } @@ -818,7 +528,7 @@ BOOL LLVOWLSky::updateStarGeometry(LLDrawable *drawable) LLVector3 left = at%LLVector3(0,0,1); LLVector3 up = at%left; - F32 sc = 0.5f+ll_frand()*1.25f; + F32 sc = 16.0f + (ll_frand() * 20.0f); left *= sc; up *= sc; diff --git a/indra/newview/llvowlsky.h b/indra/newview/llvowlsky.h index 1d419b5fea..73ecf1a717 100644 --- a/indra/newview/llvowlsky.h +++ b/indra/newview/llvowlsky.h @@ -31,17 +31,8 @@ class LLVOWLSky : public LLStaticViewerObject { private: - static const F32 DISTANCE_TO_STARS; - - // anything less than 3 makes it impossible to create a closed dome. - static const U32 MIN_SKY_DETAIL; - // anything bigger than about 180 will cause getStripsNumVerts() to exceed 65535. - static const U32 MAX_SKY_DETAIL; - inline static U32 getNumStacks(void); inline static U32 getNumSlices(void); - inline static U32 getFanNumVerts(void); - inline static U32 getFanNumIndices(void); inline static U32 getStripsNumVerts(void); inline static U32 getStripsNumIndices(void); inline static U32 getStarsNumVerts(void); @@ -50,9 +41,6 @@ private: public: LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); - void initSunDirection(LLVector3 const & sun_direction, - LLVector3 const & sun_angular_velocity); - /*virtual*/ void idleUpdate(LLAgent &agent, const F64 &time); /*virtual*/ BOOL isActive(void) const; /*virtual*/ LLDrawable * createDrawable(LLPipeline *pipeline); @@ -60,6 +48,7 @@ public: void drawStars(void); void drawDome(void); + void drawFsSky(void); // fullscreen sky for advanced atmo void resetVertexBuffers(void); void cleanupGL(); @@ -72,11 +61,6 @@ private: // helper function for initializing the stars. void initStars(); - // helper function for building the fan vertex buffer. - static void buildFanBuffer(LLStrider<LLVector3> & vertices, - LLStrider<LLVector2> & texCoords, - LLStrider<U16> & indices); - // helper function for building the strips vertex buffer. // note begin_stack and end_stack follow stl iterator conventions, // begin_stack is the first stack to be included, end_stack is the first @@ -93,7 +77,7 @@ private: BOOL updateStarGeometry(LLDrawable *drawable); private: - LLPointer<LLVertexBuffer> mFanVerts; + LLPointer<LLVertexBuffer> mFsSkyVerts; std::vector< LLPointer<LLVertexBuffer> > mStripsVerts; LLPointer<LLVertexBuffer> mStarsVerts; diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp deleted file mode 100644 index b484b6d709..0000000000 --- a/indra/newview/llwaterparammanager.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/** - * @file llwaterparammanager.cpp - * @brief Implementation for the LLWaterParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llwaterparammanager.h" - -#include "llrender.h" - -#include "pipeline.h" -#include "llsky.h" - -#include "lldiriterator.h" -#include "llfloaterreg.h" -#include "llsliderctrl.h" -#include "llspinctrl.h" -#include "llcheckboxctrl.h" -#include "lluictrlfactory.h" -#include "llviewercontrol.h" -#include "llviewercamera.h" -#include "llcombobox.h" -#include "lllineeditor.h" -#include "llsdserialize.h" - -#include "v4math.h" -#include "llviewercontrol.h" -#include "lldrawpoolwater.h" -#include "llagent.h" -#include "llagentcamera.h" -#include "llviewerregion.h" - -#include "llwlparammanager.h" -#include "llwaterparamset.h" - -#include "curl/curl.h" - -LLWaterParamManager::LLWaterParamManager() : - mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), - mFogDensity(4, "waterFogDensity", 2), - mUnderWaterFogMod(0.25, "underWaterFogMod"), - mNormalScale(2.f, 2.f, 2.f, "normScale"), - mFresnelScale(0.5f, "fresnelScale"), - mFresnelOffset(0.4f, "fresnelOffset"), - mScaleAbove(0.025f, "scaleAbove"), - mScaleBelow(0.2f, "scaleBelow"), - mBlurMultiplier(0.1f, "blurMultiplier"), - mWave1Dir(.5f, .5f, "wave1Dir"), - mWave2Dir(.5f, .5f, "wave2Dir"), - mDensitySliderValue(1.0f), - mWaterFogKS(1.0f) -{ -} - -LLWaterParamManager::~LLWaterParamManager() -{ -} - -void LLWaterParamManager::loadAllPresets() -{ - // First, load system (coming out of the box) water presets. - loadPresetsFromDir(getSysDir()); - - // Then load user presets. Note that user day presets will modify any system ones already loaded. - loadPresetsFromDir(getUserDir()); -} - -void LLWaterParamManager::loadPresetsFromDir(const std::string& dir) -{ - LL_DEBUGS("AppInit", "Shaders") << "Loading water presets from " << dir << LL_ENDL; - - LLDirIterator dir_iter(dir, "*.xml"); - while (1) - { - std::string file; - if (!dir_iter.next(file)) - { - break; // no more files - } - - std::string path = gDirUtilp->add(dir, file); - if (!loadPreset(path)) - { - LL_WARNS() << "Error loading water preset from " << path << LL_ENDL; - } - } -} - -bool LLWaterParamManager::loadPreset(const std::string& path) -{ - llifstream xml_file; - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - - xml_file.open(path.c_str()); - if (!xml_file) - { - return false; - } - - LL_DEBUGS("AppInit", "Shaders") << "Loading water " << name << LL_ENDL; - - LLSD params_data; - LLPointer<LLSDParser> parser = new LLSDXMLParser(); - parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); - xml_file.close(); - - if (hasParamSet(name)) - { - setParamSet(name, params_data); - } - else - { - addParamSet(name, params_data); - } - - return true; -} - -void LLWaterParamManager::savePreset(const std::string & name) -{ - llassert(!name.empty()); - - // make an empty llsd - LLSD paramsData(LLSD::emptyMap()); - std::string pathName(getUserDir() + LLURI::escape(name) + ".xml"); - - // fill it with LLSD windlight params - paramsData = mParamList[name].getAll(); - - // write to file - llofstream presetsXML(pathName.c_str()); - LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); - formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); - presetsXML.close(); - - propagateParameters(); -} - -void LLWaterParamManager::propagateParameters(void) -{ - // bind the variables only if we're using shaders - if(gPipeline.canUseVertexShaders()) - { - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - } - - bool err; - F32 fog_density_slider = - log(mCurParams.getFloat(mFogDensity.mName, err)) / - log(mFogDensity.mBase); - - setDensitySliderValue(fog_density_slider); -} - -void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) -{ - if (shader->mShaderGroup == LLGLSLShader::SG_WATER) - { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV); -shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV); - shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV); - shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, getFogDensity()); - shader->uniform1f(LLShaderMgr::WATER_FOGKS, mWaterFogKS); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); - } -} - -void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate) -{ - if (params.size() == 0) - { - LL_WARNS() << "Undefined water params" << LL_ENDL; - return; - } - - if (interpolate) - { - LLWLParamManager::getInstance()->mAnimator.startInterpolation(params); - } - else - { - mCurParams.setAll(params); - } -} - -static LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERPARAM("Update Water Params"); - -void LLWaterParamManager::update(LLViewerCamera * cam) -{ - LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERPARAM); - - // update the shaders and the menu - propagateParameters(); - - // only do this if we're dealing with shaders - if(gPipeline.canUseVertexShaders()) - { - //transform water plane to eye space - glh::vec3f norm(0.f, 0.f, 1.f); - glh::vec3f p(0.f, 0.f, gAgent.getRegion()->getWaterHeight()+0.1f); - - F32 modelView[16]; - for (U32 i = 0; i < 16; i++) - { - modelView[i] = (F32) gGLModelView[i]; - } - - glh::matrix4f mat(modelView); - glh::matrix4f invtrans = mat.inverse().transpose(); - glh::vec3f enorm; - glh::vec3f ep; - invtrans.mult_matrix_vec(norm, enorm); - enorm.normalize(); - mat.mult_matrix_vec(p, ep); - - mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); - - LLVector3 sunMoonDir; - if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) - { - sunMoonDir = gSky.getSunDirection(); - } - else - { - sunMoonDir = gSky.getMoonDirection(); - } - sunMoonDir.normVec(); - mWaterFogKS = 1.f/llmax(sunMoonDir.mV[2], WATER_FOG_LIGHT_CLAMP); - - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - } -} - -bool LLWaterParamManager::addParamSet(const std::string& name, LLWaterParamSet& param) -{ - // add a new one if not one there already - preset_map_t::iterator mIt = mParamList.find(name); - if(mIt == mParamList.end()) - { - mParamList[name] = param; - mPresetListChangeSignal(); - return true; - } - - return false; -} - -BOOL LLWaterParamManager::addParamSet(const std::string& name, LLSD const & param) -{ - LLWaterParamSet param_set; - param_set.setAll(param); - return addParamSet(name, param_set); -} - -bool LLWaterParamManager::getParamSet(const std::string& name, LLWaterParamSet& param) -{ - // find it and set it - preset_map_t::iterator mIt = mParamList.find(name); - if(mIt != mParamList.end()) - { - param = mParamList[name]; - param.mName = name; - return true; - } - - return false; -} - -bool LLWaterParamManager::hasParamSet(const std::string& name) -{ - LLWaterParamSet dummy; - return getParamSet(name, dummy); -} - -bool LLWaterParamManager::setParamSet(const std::string& name, LLWaterParamSet& param) -{ - mParamList[name] = param; - - return true; -} - -bool LLWaterParamManager::setParamSet(const std::string& name, const LLSD & param) -{ - // quick, non robust (we won't be working with files, but assets) check - if(!param.isMap()) - { - return false; - } - - mParamList[name].setAll(param); - - return true; -} - -bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_from_disk) -{ - // remove from param list - preset_map_t::iterator it = mParamList.find(name); - if (it == mParamList.end()) - { - LL_WARNS("WindLight") << "No water preset named " << name << LL_ENDL; - return false; - } - - mParamList.erase(it); - - // remove from file system if requested - if (delete_from_disk) - { - if (gDirUtilp->deleteFilesInDir(getUserDir(), LLURI::escape(name) + ".xml") < 1) - { - LL_WARNS("WindLight") << "Error removing water preset " << name << " from disk" << LL_ENDL; - } - } - - // signal interested parties - mPresetListChangeSignal(); - return true; -} - -bool LLWaterParamManager::isSystemPreset(const std::string& preset_name) const -{ - // *TODO: file system access is excessive here. - return gDirUtilp->fileExists(getSysDir() + LLURI::escape(preset_name) + ".xml"); -} - -void LLWaterParamManager::getPresetNames(preset_name_list_t& presets) const -{ - presets.clear(); - - for (preset_map_t::const_iterator it = mParamList.begin(); it != mParamList.end(); ++it) - { - presets.push_back(it->first); - } -} - -void LLWaterParamManager::getPresetNames(preset_name_list_t& user_presets, preset_name_list_t& system_presets) const -{ - user_presets.clear(); - system_presets.clear(); - - for (preset_map_t::const_iterator it = mParamList.begin(); it != mParamList.end(); ++it) - { - if (isSystemPreset(it->first)) - { - system_presets.push_back(it->first); - } - else - { - user_presets.push_back(it->first); - } - } -} - -void LLWaterParamManager::getUserPresetNames(preset_name_list_t& user_presets) const -{ - preset_name_list_t dummy; - getPresetNames(user_presets, dummy); -} - -boost::signals2::connection LLWaterParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) -{ - return mPresetListChangeSignal.connect(cb); -} - -F32 LLWaterParamManager::getFogDensity(void) -{ - bool err; - - F32 fogDensity = mCurParams.getFloat("waterFogDensity", err); - - // modify if we're underwater - const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f; - F32 camera_height = gAgentCamera.getCameraPositionAgent().mV[2]; - if(camera_height <= water_height) - { - // raise it to the underwater fog density modifier - fogDensity = pow(fogDensity, mCurParams.getFloat("underWaterFogMod", err)); - } - - return fogDensity; -} - -// virtual static -void LLWaterParamManager::initSingleton() -{ - LL_DEBUGS("Windlight") << "Initializing water" << LL_ENDL; - loadAllPresets(); -} - -// static -std::string LLWaterParamManager::getSysDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""); -} - -// static -std::string LLWaterParamManager::getUserDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/water", ""); -} diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h deleted file mode 100644 index 3f169e439a..0000000000 --- a/indra/newview/llwaterparammanager.h +++ /dev/null @@ -1,413 +0,0 @@ -/** - * @file llwaterparammanager.h - * @brief Implementation for the LLWaterParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_WATER_PARAMMANAGER_H -#define LL_WATER_PARAMMANAGER_H - -#include <list> -#include <map> -#include "llwaterparamset.h" -#include "llviewercamera.h" -#include "v4color.h" - -const F32 WATER_FOG_LIGHT_CLAMP = 0.3f; - -// color control -struct WaterColorControl { - - F32 mR, mG, mB, mA, mI; /// the values - std::string mName; /// name to use to dereference params - std::string mSliderName; /// name of the slider in menu - bool mHasSliderName; /// only set slider name for true color types - - inline WaterColorControl(F32 red, F32 green, F32 blue, F32 alpha, - F32 intensity, const std::string& n, const std::string& sliderName = LLStringUtil::null) - : mR(red), mG(green), mB(blue), mA(alpha), mI(intensity), mName(n), mSliderName(sliderName) - { - // if there's a slider name, say we have one - mHasSliderName = false; - if (mSliderName != "") { - mHasSliderName = true; - } - } - - inline WaterColorControl & operator = (LLColor4 const & val) - { - mR = val.mV[0]; - mG = val.mV[1]; - mB = val.mV[2]; - mA = val.mV[3]; - return *this; - } - - inline operator LLColor4 (void) const - { - return LLColor4(mR, mG, mB, mA); - } - - inline WaterColorControl & operator = (LLVector4 const & val) - { - mR = val.mV[0]; - mG = val.mV[1]; - mB = val.mV[2]; - mA = val.mV[3]; - return *this; - } - - inline operator LLVector4 (void) const - { - return LLVector4(mR, mG, mB, mA); - } - - inline operator LLVector3 (void) const - { - return LLVector3(mR, mG, mB); - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mR, mG, mB, mA); - } -}; - -struct WaterVector3Control -{ - F32 mX; - F32 mY; - F32 mZ; - - std::string mName; - - // basic constructor - inline WaterVector3Control(F32 valX, F32 valY, F32 valZ, const std::string& n) - : mX(valX), mY(valY), mZ(valZ), mName(n) - { - } - - inline WaterVector3Control & operator = (LLVector3 const & val) - { - mX = val.mV[0]; - mY = val.mV[1]; - mZ = val.mV[2]; - - return *this; - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mX, mY, mZ); - } - -}; - -struct WaterVector2Control -{ - F32 mX; - F32 mY; - - std::string mName; - - // basic constructor - inline WaterVector2Control(F32 valX, F32 valY, const std::string& n) - : mX(valX), mY(valY), mName(n) - { - } - - inline WaterVector2Control & operator = (LLVector2 const & val) - { - mX = val.mV[0]; - mY = val.mV[1]; - - return *this; - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mX, mY); - } -}; - -// float slider control -struct WaterFloatControl -{ - F32 mX; - std::string mName; - F32 mMult; - - inline WaterFloatControl(F32 val, const std::string& n, F32 m=1.0f) - : mX(val), mName(n), mMult(m) - { - } - - inline WaterFloatControl & operator = (LLVector4 const & val) - { - mX = val.mV[0]; - - return *this; - } - - inline operator F32 (void) const - { - return mX; - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mX); - } -}; - -// float slider control -struct WaterExpFloatControl -{ - F32 mExp; - std::string mName; - F32 mBase; - - inline WaterExpFloatControl(F32 val, const std::string& n, F32 b) - : mExp(val), mName(n), mBase(b) - { - } - - inline WaterExpFloatControl & operator = (F32 val) - { - mExp = log(val) / log(mBase); - - return *this; - } - - inline operator F32 (void) const - { - return pow(mBase, mExp); - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, pow(mBase, mExp)); - } -}; - - -/// WindLight parameter manager class - what controls all the wind light shaders -class LLWaterParamManager : public LLSingleton<LLWaterParamManager> -{ - LLSINGLETON(LLWaterParamManager); - ~LLWaterParamManager(); - LOG_CLASS(LLWaterParamManager); -public: - typedef std::list<std::string> preset_name_list_t; - typedef std::map<std::string, LLWaterParamSet> preset_map_t; - typedef boost::signals2::signal<void()> preset_list_signal_t; - - /// save the parameter presets to file - void savePreset(const std::string & name); - - /// send the parameters to the shaders - void propagateParameters(void); - - // display specified water - void applyParams(const LLSD& params, bool interpolate); - - /// update information for the shader - void update(LLViewerCamera * cam); - - /// Update shader uniforms that have changed. - void updateShaderUniforms(LLGLSLShader * shader); - - /// add a param to the list - bool addParamSet(const std::string& name, LLWaterParamSet& param); - - /// add a param to the list - BOOL addParamSet(const std::string& name, LLSD const & param); - - /// get a param from the list - bool getParamSet(const std::string& name, LLWaterParamSet& param); - - /// check whether the preset is in the list - bool hasParamSet(const std::string& name); - - /// set the param in the list with a new param - bool setParamSet(const std::string& name, LLWaterParamSet& param); - - /// set the param in the list with a new param - bool setParamSet(const std::string& name, LLSD const & param); - - /// gets rid of a parameter and any references to it - /// returns true if successful - bool removeParamSet(const std::string& name, bool delete_from_disk); - - /// @return true if the preset comes out of the box - bool isSystemPreset(const std::string& preset_name) const; - - /// @return all named water presets. - const preset_map_t& getPresets() const { return mParamList; } - - /// @return user and system preset names as a single list - void getPresetNames(preset_name_list_t& presets) const; - - /// @return user and system preset names separately - void getPresetNames(preset_name_list_t& user_presets, preset_name_list_t& system_presets) const; - - /// @return list of user presets names - void getUserPresetNames(preset_name_list_t& user_presets) const; - - /// Emitted when a preset gets added or deleted. - boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); - - /// set the normap map we want for water - bool setNormalMapID(const LLUUID& img); - - void setDensitySliderValue(F32 val); - - /// getters for all the different things water param manager maintains - LLUUID getNormalMapID(void); - LLVector2 getWave1Dir(void); - LLVector2 getWave2Dir(void); - F32 getScaleAbove(void); - F32 getScaleBelow(void); - LLVector3 getNormalScale(void); - F32 getFresnelScale(void); - F32 getFresnelOffset(void); - F32 getBlurMultiplier(void); - F32 getFogDensity(void); - LLColor4 getFogColor(void); - -public: - - LLWaterParamSet mCurParams; - - /// Atmospherics - WaterColorControl mFogColor; - WaterExpFloatControl mFogDensity; - WaterFloatControl mUnderWaterFogMod; - - /// wavelet scales and directions - WaterVector3Control mNormalScale; - WaterVector2Control mWave1Dir; - WaterVector2Control mWave2Dir; - - // controls how water is reflected and refracted - WaterFloatControl mFresnelScale; - WaterFloatControl mFresnelOffset; - WaterFloatControl mScaleAbove; - WaterFloatControl mScaleBelow; - WaterFloatControl mBlurMultiplier; - - F32 mDensitySliderValue; - -private: - /*virtual*/ void initSingleton(); - void loadAllPresets(); - void loadPresetsFromDir(const std::string& dir); - bool loadPreset(const std::string& path); - - static std::string getSysDir(); - static std::string getUserDir(); - - LLVector4 mWaterPlane; - F32 mWaterFogKS; - - // list of all the parameters, listed by name - preset_map_t mParamList; - - preset_list_signal_t mPresetListChangeSignal; -}; - -inline void LLWaterParamManager::setDensitySliderValue(F32 val) -{ - val /= 10.0f; - val = 1.0f - val; - val *= val * val; -// val *= val; - mDensitySliderValue = val; -} - -inline LLUUID LLWaterParamManager::getNormalMapID() -{ - return mCurParams.mParamValues["normalMap"].asUUID(); -} - -inline bool LLWaterParamManager::setNormalMapID(const LLUUID& id) -{ - mCurParams.mParamValues["normalMap"] = id; - return true; -} - -inline LLVector2 LLWaterParamManager::getWave1Dir(void) -{ - bool err; - return mCurParams.getVector2("wave1Dir", err); -} - -inline LLVector2 LLWaterParamManager::getWave2Dir(void) -{ - bool err; - return mCurParams.getVector2("wave2Dir", err); -} - -inline F32 LLWaterParamManager::getScaleAbove(void) -{ - bool err; - return mCurParams.getFloat("scaleAbove", err); -} - -inline F32 LLWaterParamManager::getScaleBelow(void) -{ - bool err; - return mCurParams.getFloat("scaleBelow", err); -} - -inline LLVector3 LLWaterParamManager::getNormalScale(void) -{ - bool err; - return mCurParams.getVector3("normScale", err); -} - -inline F32 LLWaterParamManager::getFresnelScale(void) -{ - bool err; - return mCurParams.getFloat("fresnelScale", err); -} - -inline F32 LLWaterParamManager::getFresnelOffset(void) -{ - bool err; - return mCurParams.getFloat("fresnelOffset", err); -} - -inline F32 LLWaterParamManager::getBlurMultiplier(void) -{ - bool err; - return mCurParams.getFloat("blurMultiplier", err); -} - -inline LLColor4 LLWaterParamManager::getFogColor(void) -{ - bool err; - return LLColor4(mCurParams.getVector4("waterFogColor", err)); -} - -#endif diff --git a/indra/newview/llwaterparamset.cpp b/indra/newview/llwaterparamset.cpp deleted file mode 100644 index 9cc91d2246..0000000000 --- a/indra/newview/llwaterparamset.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/** - * @file llwaterparamset.cpp - * @brief Implementation for the LLWaterParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llwaterparamset.h" -#include "llsd.h" - -#include "llwaterparammanager.h" -#include "lluictrlfactory.h" -#include "llsliderctrl.h" -#include "llviewertexturelist.h" -#include "llviewercontrol.h" -#include "lluuid.h" - -#include <llgl.h> - -#include <sstream> - -LLWaterParamSet::LLWaterParamSet(void) : - mName("Unnamed Preset") -{ - LLSD vec4; - LLSD vec3; - LLSD real(0.0f); - - vec4 = LLSD::emptyArray(); - vec4.append(22.f/255.f); - vec4.append(43.f/255.f); - vec4.append(54.f/255.f); - vec4.append(0.f/255.f); - - vec3 = LLSD::emptyArray(); - vec3.append(2); - vec3.append(2); - vec3.append(2); - - LLSD wave1, wave2; - wave1 = LLSD::emptyArray(); - wave2 = LLSD::emptyArray(); - wave1.append(0.5f); - wave1.append(-.17f); - wave2.append(0.58f); - wave2.append(-.67f); - - mParamValues.insert("waterFogColor", vec4); - mParamValues.insert("waterFogDensity", 16.0f); - mParamValues.insert("underWaterFogMod", 0.25f); - mParamValues.insert("normScale", vec3); - mParamValues.insert("fresnelScale", 0.5f); - mParamValues.insert("fresnelOffset", 0.4f); - mParamValues.insert("scaleAbove", 0.025f); - mParamValues.insert("scaleBelow", 0.2f); - mParamValues.insert("blurMultiplier", 0.01f); - mParamValues.insert("wave1Dir", wave1); - mParamValues.insert("wave2Dir", wave2); - mParamValues.insert("normalMap", DEFAULT_WATER_NORMAL); - -} - -void LLWaterParamSet::set(const std::string& paramName, float x) -{ - // handle case where no array - if(mParamValues[paramName].isReal()) - { - mParamValues[paramName] = x; - } - - // handle array - else if(mParamValues[paramName].isArray() && - mParamValues[paramName][0].isReal()) - { - mParamValues[paramName][0] = x; - } -} - -void LLWaterParamSet::set(const std::string& paramName, float x, float y) { - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; -} - -void LLWaterParamSet::set(const std::string& paramName, float x, float y, float z) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; -} - -void LLWaterParamSet::set(const std::string& paramName, float x, float y, float z, float w) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; - mParamValues[paramName][3] = w; -} - -void LLWaterParamSet::set(const std::string& paramName, const float * val) -{ - mParamValues[paramName][0] = val[0]; - mParamValues[paramName][1] = val[1]; - mParamValues[paramName][2] = val[2]; - mParamValues[paramName][3] = val[3]; -} - -void LLWaterParamSet::set(const std::string& paramName, const LLVector4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -void LLWaterParamSet::set(const std::string& paramName, const LLColor4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -LLVector4 LLWaterParamSet::getVector4(const std::string& paramName, bool& error) -{ - - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray() || cur_val.size() != 4) - { - error = true; - return LLVector4(0,0,0,0); - } - - LLVector4 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - val.mV[2] = (F32) cur_val[2].asReal(); - val.mV[3] = (F32) cur_val[3].asReal(); - - error = false; - return val; -} - -LLVector3 LLWaterParamSet::getVector3(const std::string& paramName, bool& error) -{ - - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray()|| cur_val.size() != 3) - { - error = true; - return LLVector3(0,0,0); - } - - LLVector3 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - val.mV[2] = (F32) cur_val[2].asReal(); - - error = false; - return val; -} - -LLVector2 LLWaterParamSet::getVector2(const std::string& paramName, bool& error) -{ - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray() || cur_val.size() != 2) - { - error = true; - return LLVector2(0,0); - } - - LLVector2 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - - error = false; - return val; -} - -F32 LLWaterParamSet::getFloat(const std::string& paramName, bool& error) -{ - - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (cur_val.isArray() && cur_val.size() != 0) - { - error = false; - return (F32) cur_val[0].asReal(); - } - - if(cur_val.isReal()) - { - error = false; - return (F32) cur_val.asReal(); - } - - error = true; - return 0; -} - -// Added for interpolation effect in DEV-33645 -// Based on LLWLParamSet::mix, but written by Jacob without an intimate knowledge of how WindLight works. -// The function definition existed in the header but was never implemented. If you think there is something -// wrong with this, you're probably right. Ask Jacob, Q, or a member of the original WindLight team. -void LLWaterParamSet::mix(LLWaterParamSet& src, LLWaterParamSet& dest, F32 weight) -{ - // Setup - LLSD srcVal, destVal; // LLSD holders for get/set calls, reusable - - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - // If param exists in both src and dest, set the holder variables, otherwise skip - if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) - { - srcVal = src.mParamValues[iter->first]; - destVal = dest.mParamValues[iter->first]; - } - else - { - continue; - } - - if(iter->second.isReal()) // If it's a real, interpolate directly - { - iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); - } - else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those - && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) - { - // Actually do interpolation: old value + (difference in values * factor) - for(int i=0; i < iter->second.size(); ++i) - { - // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation - iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); - } - } - else // Else, skip - { - continue; - } - } -} diff --git a/indra/newview/llwaterparamset.h b/indra/newview/llwaterparamset.h deleted file mode 100644 index 368cb0ccba..0000000000 --- a/indra/newview/llwaterparamset.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @file llwlparamset.h - * @brief Interface for the LLWaterParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_WATER_PARAM_SET_H -#define LL_WATER_PARAM_SET_H - -#include <string> -#include <map> - -#include "v4math.h" -#include "v4color.h" -#include "llviewershadermgr.h" -#include "llstringtable.h" - -class LLWaterParamSet; - -/// A class representing a set of parameter values for the Water shaders. -class LLWaterParamSet -{ - friend class LLWaterParamManager; - -public: - std::string mName; - -private: - - LLSD mParamValues; - std::vector<LLStaticHashedString> mParamHashedNames; - - void updateHashedNames(); - -public: - - LLWaterParamSet(); - - /// Bind this set of parameter values to the uniforms of a particular shader. - void update(LLGLSLShader * shader) const; - - /// set the total llsd - void setAll(const LLSD& val); - - /// get the total llsd - const LLSD& getAll(); - - /// Set a float parameter. - /// \param paramName The name of the parameter to set. - /// \param x The float value to set. - void set(const std::string& paramName, float x); - - /// Set a float2 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - void set(const std::string& paramName, float x, float y); - - /// Set a float3 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - void set(const std::string& paramName, float x, float y, float z); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - /// \param w The w component's value to set. - void set(const std::string& paramName, float x, float y, float z, float w); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val An array of the 4 float values to set the parameter to. - void set(const std::string& paramName, const float * val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLVector4 & val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLColor4 & val); - - /// Get a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector4 getVector4(const std::string& paramName, bool& error); - - /// Get a float3 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector3 getVector3(const std::string& paramName, bool& error); - - /// Get a float2 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector2 getVector2(const std::string& paramName, bool& error); - - /// Get an integer parameter - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - F32 getFloat(const std::string& paramName, bool& error); - - /// interpolate two parameter sets - /// \param src The parameter set to start with - /// \param dest The parameter set to end with - /// \param weight The amount to interpolate - void mix(LLWaterParamSet& src, LLWaterParamSet& dest, - F32 weight); - -}; - -inline void LLWaterParamSet::setAll(const LLSD& val) -{ - if(val.isMap()) { - LLSD::map_const_iterator mIt = val.beginMap(); - for(; mIt != val.endMap(); mIt++) - { - mParamValues[mIt->first] = mIt->second; - } - } - updateHashedNames(); -} - -inline void LLWaterParamSet::updateHashedNames() -{ - mParamHashedNames.clear(); - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - mParamHashedNames.push_back(LLStaticHashedString(iter->first)); - } -} - -inline const LLSD& LLWaterParamSet::getAll() -{ - return mParamValues; -} - -#endif // LL_WaterPARAM_SET_H diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp deleted file mode 100644 index c8879e73eb..0000000000 --- a/indra/newview/llwlanimator.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/** - * @file llwlanimator.cpp - * @brief Implementation for the LLWLAnimator class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llwlanimator.h" -#include "llsky.h" -#include "pipeline.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" - -extern LLControlGroup gSavedSettings; - -F64 LLWLAnimator::INTERP_TOTAL_SECONDS = 3.f; - -LLWLAnimator::LLWLAnimator() : mStartTime(0.f), mDayRate(1.f), mDayTime(0.f), - mIsRunning(FALSE), mIsInterpolating(FALSE), mTimeType(TIME_LINDEN), - mInterpStartTime(), mInterpEndTime() -{ - mInterpBeginWL = new LLWLParamSet(); - mInterpBeginWater = new LLWaterParamSet(); - mInterpEndWater = new LLWaterParamSet(); -} - -void LLWLAnimator::update(LLWLParamSet& curParams) -{ - //llassert(mUseLindenTime != mUseLocalTime); - - F64 curTime; - curTime = getDayTime(); - - // don't do anything if empty - if(mTimeTrack.size() == 0) - { - return; - } - - // start it off - mFirstIt = mTimeTrack.begin(); - mSecondIt = mTimeTrack.begin(); - mSecondIt++; - - // grab the two tween iterators - while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first) - { - mFirstIt++; - mSecondIt++; - } - - // scroll it around when you get to the end - if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime) - { - mSecondIt = mTimeTrack.begin(); - mFirstIt = mTimeTrack.end(); - mFirstIt--; - } - - F32 weight = 0; - - if(mFirstIt->first < mSecondIt->first) - { - - // get the delta time and the proper weight - weight = F32 (curTime - mFirstIt->first) / - (mSecondIt->first - mFirstIt->first); - - // handle the ends - } - else if(mFirstIt->first > mSecondIt->first) - { - - // right edge of time line - if(curTime >= mFirstIt->first) - { - weight = F32 (curTime - mFirstIt->first) / - ((1 + mSecondIt->first) - mFirstIt->first); - // left edge of time line - } - else - { - weight = F32 ((1 + curTime) - mFirstIt->first) / - ((1 + mSecondIt->first) - mFirstIt->first); - } - - // handle same as whatever the last one is - } - else - { - weight = 1; - } - - if(mIsInterpolating) - { - // *TODO_JACOB: this is kind of laggy. Not sure why. The part that lags is the curParams.mix call, and none of the other mixes. It works, though. - clock_t current = clock(); - if(current >= mInterpEndTime) - { - mIsInterpolating = false; - return; - } - - // determine moving target for final interpolation value - // *TODO: this will not work with lazy loading of sky presets. - LLWLParamSet buf = LLWLParamSet(); - buf.setAll(LLWLParamManager::getInstance()->mParamList[mFirstIt->second].getAll()); // just give it some values, otherwise it has no params to begin with (see comment in constructor) - buf.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); // mix to determine moving target for interpolation finish (as below) - - // mix from previous value to moving target - weight = (current - mInterpStartTime) / (INTERP_TOTAL_SECONDS * CLOCKS_PER_SEC); - curParams.mix(*mInterpBeginWL, buf, weight); - - // mix water - LLWaterParamManager::getInstance()->mCurParams.mix(*mInterpBeginWater, *mInterpEndWater, weight); - } - else - { - // do the interpolation and set the parameters - // *TODO: this will not work with lazy loading of sky presets. - curParams.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); - } -} - -F64 LLWLAnimator::getDayTime() -{ - if(!mIsRunning) - { - return mDayTime; - } - else if(mTimeType == TIME_LINDEN) - { - F32 phase = gSky.getSunPhase() / F_PI; - - // we're not solving the non-linear equation that determines sun phase - // we're just linearly interpolating between the major points - - if (phase <= 5.0 / 4.0) - { - // mDayTime from 0.33 to 0.75 (6:00 to 21:00) - mDayTime = (1.0 / 3.0) * phase + (1.0 / 3.0); - } - else if (phase > 7.0 / 4.0) - { - // maximum value for phase is 2 - // mDayTime from 0.25 to 0.33 (3:00 to 6:00) - mDayTime = (1.0 / 3.0) - (1.0 / 3.0) * (2 - phase); - } - else - { - // phase == 3/2 is where day restarts (24:00) - // mDayTime from 0.75 to 0.999 and 0 to 0.25 (21:00 to 03:00) - mDayTime = phase - (1.0 / 2.0); - - if(mDayTime > 1) - { - mDayTime--; - } - } - - return mDayTime; - } - else if(mTimeType == TIME_LOCAL) - { - return getLocalTime(); - } - - // get the time; - mDayTime = (LLTimer::getElapsedSeconds() - mStartTime) / mDayRate; - - // clamp it - if(mDayTime < 0) - { - mDayTime = 0; - } - while(mDayTime > 1) - { - mDayTime--; - } - - return (F32)mDayTime; -} - -void LLWLAnimator::setDayTime(F64 dayTime) -{ - //retroactively set start time; - mStartTime = LLTimer::getElapsedSeconds() - dayTime * mDayRate; - mDayTime = dayTime; - - // clamp it - if(mDayTime < 0) - { - mDayTime = 0; - } - else if(mDayTime > 1) - { - mDayTime = 1; - } -} - - -void LLWLAnimator::setTrack(std::map<F32, LLWLParamKey>& curTrack, - F32 dayRate, F64 dayTime, bool run) -{ - mTimeTrack = curTrack; - mDayRate = dayRate; - setDayTime(dayTime); - - mIsRunning = run; -} - -void LLWLAnimator::startInterpolation(const LLSD& targetWater) -{ - mInterpBeginWL->setAll(LLWLParamManager::getInstance()->mCurParams.getAll()); - mInterpBeginWater->setAll(LLWaterParamManager::getInstance()->mCurParams.getAll()); - - mInterpStartTime = clock(); - mInterpEndTime = mInterpStartTime + clock_t(INTERP_TOTAL_SECONDS) * CLOCKS_PER_SEC; - - // Don't set any ending WL -- this is continuously calculated as the animator updates since it's a moving target - mInterpEndWater->setAll(targetWater); - - mIsInterpolating = true; -} - -std::string LLWLAnimator::timeToString(F32 curTime) -{ - S32 hours; - S32 min; - bool isPM = false; - - // get hours and minutes - hours = (S32) (24.0 * curTime); - curTime -= ((F32) hours / 24.0f); - min = ll_round(24.0f * 60.0f * curTime); - - // handle case where it's 60 - if(min == 60) - { - hours++; - min = 0; - } - - // set for PM - if(hours >= 12 && hours < 24) - { - isPM = true; - } - - // convert to non-military notation - if(hours >= 24) - { - hours = 12; - } - else if(hours > 12) - { - hours -= 12; - } - else if(hours == 0) - { - hours = 12; - } - - // make the string - std::stringstream newTime; - newTime << hours << ":"; - - // double 0 - if(min < 10) - { - newTime << 0; - } - - // finish it - newTime << min << " "; - if(isPM) - { - newTime << "PM"; - } - else - { - newTime << "AM"; - } - - return newTime.str(); -} - -F64 LLWLAnimator::getLocalTime() -{ - char buffer[9]; - time_t rawtime; - struct tm* timeinfo; - - time(&rawtime); - timeinfo = localtime(&rawtime); - strftime(buffer, 9, "%H:%M:%S", timeinfo); - std::string timeStr(buffer); - - F64 tod = ((F64)atoi(timeStr.substr(0,2).c_str())) / 24.f + - ((F64)atoi(timeStr.substr(3,2).c_str())) / 1440.f + - ((F64)atoi(timeStr.substr(6,2).c_str())) / 86400.f; - return tod; -} diff --git a/indra/newview/llwlanimator.h b/indra/newview/llwlanimator.h deleted file mode 100644 index e2e49c7305..0000000000 --- a/indra/newview/llwlanimator.h +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @file llwlanimator.h - * @brief Interface for the LLWLAnimator class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_WL_ANIMATOR_H -#define LL_WL_ANIMATOR_H - -#include "llwlparamset.h" -#include "llenvmanager.h" -#include "llwaterparamset.h" -#include <string> -#include <map> - -class LLWLAnimator { -public: - typedef enum e_time - { - TIME_LINDEN, - TIME_LOCAL, - TIME_CUSTOM - } ETime; - - F64 mStartTime; - F32 mDayRate; - F64 mDayTime; - - // track to play - std::map<F32, LLWLParamKey> mTimeTrack; - std::map<F32, LLWLParamKey>::iterator mFirstIt, mSecondIt; - - // simple constructor - LLWLAnimator(); - - ~LLWLAnimator() - { - delete mInterpBeginWL; - delete mInterpBeginWater; - delete mInterpEndWater; - } - - // update the parameters - void update(LLWLParamSet& curParams); - - // get time in seconds - //F64 getTime(void); - - // returns a float 0 - 1 saying what time of day is it? - F64 getDayTime(void); - - // sets a float 0 - 1 saying what time of day it is - void setDayTime(F64 dayTime); - - // set an animation track - void setTrack(std::map<F32, LLWLParamKey>& track, - F32 dayRate, F64 dayTime = 0, bool run = true); - - void deactivate() - { - mIsRunning = false; - } - - void activate(ETime time) - { - mIsRunning = true; - mTimeType = time; - } - - void startInterpolation(const LLSD& targetWater); - - bool getIsRunning() - { - return mIsRunning; - } - - bool getUseCustomTime() - { - return mTimeType == TIME_CUSTOM; - } - - bool getUseLocalTime() - { - return mTimeType == TIME_LOCAL; - } - - bool getUseLindenTime() - { - return mTimeType == TIME_LINDEN; - } - - void setTimeType(ETime time) - { - mTimeType = time; - } - - ETime getTimeType() - { - return mTimeType; - } - - /// convert the present time to a digital clock time - static std::string timeToString(F32 curTime); - - /// get local time between 0 and 1 - static F64 getLocalTime(); - -private: - ETime mTimeType; - bool mIsRunning, mIsInterpolating; - LLWLParamSet *mInterpBeginWL; - LLWaterParamSet *mInterpBeginWater, *mInterpEndWater; - clock_t mInterpStartTime, mInterpEndTime; - - static F64 INTERP_TOTAL_SECONDS; -}; - -#endif // LL_WL_ANIMATOR_H - diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 106f17f61b..0a331d1823 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -46,6 +46,7 @@ LLWLDayCycle::~LLWLDayCycle() void LLWLDayCycle::loadDayCycle(const LLSD& day_data, LLWLParamKey::EScope scope) { +#if 0 LL_DEBUGS() << "Loading day cycle (day_data.size() = " << day_data.size() << ", scope = " << scope << ")" << LL_ENDL; mTimeMap.clear(); @@ -88,6 +89,7 @@ void LLWLDayCycle::loadDayCycle(const LLSD& day_data, LLWLParamKey::EScope scope // then add the keyframe addKeyframe((F32)day_data[i][0].asReal(), frame); } +#endif } void LLWLDayCycle::loadDayCycleFromFile(const std::string & fileName) @@ -158,35 +160,35 @@ LLSD LLWLDayCycle::asLLSD() return day_data; } -bool LLWLDayCycle::getSkyRefs(std::map<LLWLParamKey, LLWLParamSet>& refs) const -{ - bool result = true; - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - - refs.clear(); - for (std::map<F32, LLWLParamKey>::const_iterator iter = mTimeMap.begin(); iter != mTimeMap.end(); ++iter) - { - const LLWLParamKey& key = iter->second; - if (!wl_mgr.getParamSet(key, refs[key])) - { - LL_WARNS() << "Cannot find sky [" << key.name << "] referenced by a day cycle" << LL_ENDL; - result = false; - } - } - - return result; -} +// bool LLWLDayCycle::getSkyRefs(std::map<LLWLParamKey, LLWLParamSet>& refs) const +// { +// bool result = true; +// LLWLParamManager& wl_mgr = LLWLParamManager::instance(); +// +// refs.clear(); +// for (std::map<F32, LLWLParamKey>::const_iterator iter = mTimeMap.begin(); iter != mTimeMap.end(); ++iter) +// { +// const LLWLParamKey& key = iter->second; +// if (!wl_mgr.getParamSet(key, refs[key])) +// { +// LL_WARNS() << "Cannot find sky [" << key.name << "] referenced by a day cycle" << LL_ENDL; +// result = false; +// } +// } +// +// return result; +// } bool LLWLDayCycle::getSkyMap(LLSD& sky_map) const { - std::map<LLWLParamKey, LLWLParamSet> refs; - - if (!getSkyRefs(refs)) - { - return false; - } - - sky_map = LLWLParamManager::createSkyMap(refs); +// std::map<LLWLParamKey, LLWLParamSet> refs; +// +// if (!getSkyRefs(refs)) +// { +// return false; +// } +// +// sky_map = LLWLParamManager::createSkyMap(refs); return true; } @@ -235,23 +237,23 @@ bool LLWLDayCycle::changeKeyframeTime(F32 oldTime, F32 newTime) return addKeyframe(newTime, frame); } -bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key) -{ - LL_DEBUGS() << "Changing key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; - - // just remove and add back - // make sure param exists - LLWLParamSet tmp; - bool stat = LLWLParamManager::getInstance()->getParamSet(key, tmp); - if(stat == false) - { - LL_DEBUGS() << "Failed to change key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; - return stat; - } - - mTimeMap[time] = key; - return true; -} +// bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key) +// { +// LL_DEBUGS() << "Changing key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; +// +// // just remove and add back +// // make sure param exists +// LLWLParamSet tmp; +// bool stat = LLWLParamManager::getInstance()->getParamSet(key, tmp); +// if(stat == false) +// { +// LL_DEBUGS() << "Failed to change key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; +// return stat; +// } +// +// mTimeMap[time] = key; +// return true; +// } bool LLWLDayCycle::removeKeyframe(F32 time) @@ -285,19 +287,19 @@ bool LLWLDayCycle::getKeytime(LLWLParamKey frame, F32& key_time) const return false; } -bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) -{ - // just scroll on through till you find it - std::map<F32, LLWLParamKey>::iterator mIt = mTimeMap.find(time); - if(mIt != mTimeMap.end()) - { - return LLWLParamManager::getInstance()->getParamSet(mIt->second, param); - } - - // return error if not found - LL_DEBUGS() << "Key " << time << " not found" << LL_ENDL; - return false; -} +// bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) +// { +// // just scroll on through till you find it +// std::map<F32, LLWLParamKey>::iterator mIt = mTimeMap.find(time); +// if(mIt != mTimeMap.end()) +// { +// return LLWLParamManager::getInstance()->getParamSet(mIt->second, param); +// } +// +// // return error if not found +// LL_DEBUGS() << "Key " << time << " not found" << LL_ENDL; +// return false; +// } bool LLWLDayCycle::getKeyedParamName(F32 time, std::string & name) { diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index c8585564ed..2f9a2e5c4a 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -32,10 +32,8 @@ class LLWLDayCycle; #include <vector> #include <map> #include <string> -#include "llwlparamset.h" -#include "llwlanimator.h" +#include "llenvmanager.h" struct LLWLParamKey; -#include "llenvmanager.h" // for LLEnvKey::EScope class LLWLDayCycle { @@ -78,7 +76,7 @@ public: LLSD asLLSD(); // get skies referenced by this day cycle - bool getSkyRefs(std::map<LLWLParamKey, LLWLParamSet>& refs) const; +// bool getSkyRefs(std::map<LLWLParamKey, LLWLParamSet>& refs) const; // get referenced skies as LLSD bool getSkyMap(LLSD& sky_map) const; @@ -110,7 +108,7 @@ public: /// get the param set at a given time /// returns true if found one - bool getKeyedParam(F32 time, LLWLParamSet& param); +// bool getKeyedParam(F32 time, LLWLParamSet& param); /// get the name /// returns true if it found one diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index ea65a0c6d9..6b8374fd48 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -30,15 +30,15 @@ #include "llagent.h" #include "llviewerregion.h" -#include "llenvmanager.h" #include "llnotificationsutil.h" #include "llcorehttputil.h" +#include "llparcel.h" /**** * LLEnvironmentRequest ****/ // static -bool LLEnvironmentRequest::initiate() +bool LLEnvironmentRequest::initiate(LLEnvironment::environment_apply_fn cb) { LLViewerRegion* cur_region = gAgent.getRegion(); @@ -51,15 +51,15 @@ bool LLEnvironmentRequest::initiate() if (!cur_region->capabilitiesReceived()) { LL_INFOS("WindlightCaps") << "Deferring windlight settings request until we've got region caps" << LL_ENDL; - cur_region->setCapabilitiesReceivedCallback(boost::bind(&LLEnvironmentRequest::onRegionCapsReceived, _1)); + cur_region->setCapabilitiesReceivedCallback([cb](LLUUID region_id) { LLEnvironmentRequest::onRegionCapsReceived(region_id, cb); }); return false; } - return doRequest(); + return doRequest(cb); } // static -void LLEnvironmentRequest::onRegionCapsReceived(const LLUUID& region_id) +void LLEnvironmentRequest::onRegionCapsReceived(const LLUUID& region_id, LLEnvironment::environment_apply_fn cb) { if (region_id != gAgent.getRegion()->getRegionID()) { @@ -68,23 +68,26 @@ void LLEnvironmentRequest::onRegionCapsReceived(const LLUUID& region_id) } LL_DEBUGS("WindlightCaps") << "Received region capabilities" << LL_ENDL; - doRequest(); + doRequest(cb); } // static -bool LLEnvironmentRequest::doRequest() +bool LLEnvironmentRequest::doRequest(LLEnvironment::environment_apply_fn cb) { std::string url = gAgent.getRegionCapability("EnvironmentSettings"); if (url.empty()) { LL_INFOS("WindlightCaps") << "Skipping windlight setting request - we don't have this capability" << LL_ENDL; // region is apparently not capable of this; don't respond at all + // (there shouldn't be any regions where this is the case... but + LL_INFOS("ENVIRONMENT") << "No legacy windlight caps... just set the region to be the default day." << LL_ENDL; + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId()); return false; } std::string coroname = LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", - boost::bind(&LLEnvironmentRequest::environmentRequestCoro, url)); + [url, cb]() { LLEnvironmentRequest::environmentRequestCoro(url, cb); }); LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL; return true; @@ -93,7 +96,7 @@ bool LLEnvironmentRequest::doRequest() S32 LLEnvironmentRequest::sLastRequest = 0; //static -void LLEnvironmentRequest::environmentRequestCoro(std::string url) +void LLEnvironmentRequest::environmentRequestCoro(std::string url, LLEnvironment::environment_apply_fn cb) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); S32 requestId = ++LLEnvironmentRequest::sLastRequest; @@ -103,6 +106,8 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + LL_WARNS("WindlightCaps") << "Using legacy Windlight caps." << LL_ENDL; + if (requestId != LLEnvironmentRequest::sLastRequest) { LL_INFOS("WindlightCaps") << "Got superseded by another responder; ignoring..." << LL_ENDL; @@ -114,11 +119,12 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) if (!status) { LL_WARNS("WindlightCaps") << "Got an error, not using region windlight... " << LL_ENDL; - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(LLSD()); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId()); + return; } result = result["content"]; - LL_INFOS("WindlightCaps") << "Received region windlight settings" << LL_ENDL; + LL_INFOS("WindlightCaps") << "Received region legacy windlight settings" << LL_ENDL; LLUUID regionId; if (gAgent.getRegion()) @@ -134,7 +140,12 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) return; } - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(result); + if (cb) + { + LLEnvironment::EnvironmentInfo::ptr_t pinfo = LLEnvironment::EnvironmentInfo::extractLegacy(result); + + cb(INVALID_PARCEL_ID, pinfo); + } } @@ -146,7 +157,7 @@ clock_t LLEnvironmentApply::UPDATE_WAIT_SECONDS = clock_t(3.f); clock_t LLEnvironmentApply::sLastUpdate = clock_t(0.f); // static -bool LLEnvironmentApply::initiateRequest(const LLSD& content) +bool LLEnvironmentApply::initiateRequest(const LLSD& content, LLEnvironment::environment_apply_fn cb) { clock_t current = clock(); @@ -162,7 +173,7 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) sLastUpdate = current; // Send update request. - std::string url = gAgent.getRegionCapability("EnvironmentSettings"); + std::string url = gAgent.getRegionCapability("ExtEnvironment"); if (url.empty()) { LL_WARNS("WindlightCaps") << "Applying windlight settings not supported" << LL_ENDL; @@ -174,11 +185,11 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content) std::string coroname = LLCoros::instance().launch("LLEnvironmentApply::environmentApplyCoro", - boost::bind(&LLEnvironmentApply::environmentApplyCoro, url, content)); + [url, content, cb]() { LLEnvironmentApply::environmentApplyCoro(url, content, cb); }); return true; } -void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) +void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content, LLEnvironment::environment_apply_fn cb) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -242,13 +253,11 @@ void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) } LL_DEBUGS("WindlightCaps") << "Success in applying windlight settings to region " << result["regionID"].asUUID() << LL_ENDL; - LLEnvManagerNew::instance().onRegionSettingsApplyResponse(true); } while (false); if (!notify.isUndefined()) { LLNotificationsUtil::add("WLRegionApplyFail", notify); - LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); } } diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index eb2bbf9553..b09d2df60f 100644 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -29,19 +29,20 @@ #include "llviewerprecompiledheaders.h" #include "llcoros.h" +#include "llenvironment.h" class LLEnvironmentRequest { LOG_CLASS(LLEnvironmentRequest); public: /// @return true if request was successfully sent - static bool initiate(); + static bool initiate(LLEnvironment::environment_apply_fn cb); private: - static void onRegionCapsReceived(const LLUUID& region_id); - static bool doRequest(); + static void onRegionCapsReceived(const LLUUID& region_id, LLEnvironment::environment_apply_fn cb); + static bool doRequest(LLEnvironment::environment_apply_fn cb); - static void environmentRequestCoro(std::string url); + static void environmentRequestCoro(std::string url, LLEnvironment::environment_apply_fn cb); static S32 sLastRequest; }; @@ -51,13 +52,15 @@ class LLEnvironmentApply LOG_CLASS(LLEnvironmentApply); public: /// @return true if request was successfully sent - static bool initiateRequest(const LLSD& content); + static bool initiateRequest(const LLSD& content, LLEnvironment::environment_apply_fn cb); private: static clock_t sLastUpdate; static clock_t UPDATE_WAIT_SECONDS; - static void environmentApplyCoro(std::string url, LLSD content); + static void environmentApplyCoro(std::string url, LLSD content, LLEnvironment::environment_apply_fn cb); }; + + #endif // LL_LLWLHANDLERS_H diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp deleted file mode 100644 index 4b4393b07b..0000000000 --- a/indra/newview/llwlparammanager.cpp +++ /dev/null @@ -1,710 +0,0 @@ -/** - * @file llwlparammanager.cpp - * @brief Implementation for the LLWLParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llwlparammanager.h" - -#include "pipeline.h" -#include "llsky.h" - -#include "lldiriterator.h" -#include "llfloaterreg.h" -#include "llsliderctrl.h" -#include "llspinctrl.h" -#include "llcheckboxctrl.h" -#include "lluictrlfactory.h" -#include "llviewercamera.h" -#include "llcombobox.h" -#include "lllineeditor.h" -#include "llsdserialize.h" - -#include "v4math.h" -#include "llviewerdisplay.h" -#include "llviewercontrol.h" -#include "llviewerwindow.h" -#include "lldrawpoolwater.h" -#include "llagent.h" -#include "llviewerregion.h" - -#include "llwlparamset.h" -#include "llpostprocess.h" - -#include "llviewershadermgr.h" -#include "llglslshader.h" - -#include "curl/curl.h" -#include "llstreamtools.h" - -LLWLParamManager::LLWLParamManager() : - - //set the defaults for the controls - - /// Sun Delta Terrain tweak variables. - mSunDeltaYaw(180.0f), - mSceneLightStrength(2.0f), - mWLGamma(1.0f, "gamma"), - - mBlueHorizon(0.25f, 0.25f, 1.0f, 1.0f, "blue_horizon", "WLBlueHorizon"), - mHazeDensity(1.0f, "haze_density"), - mBlueDensity(0.25f, 0.25f, 0.25f, 1.0f, "blue_density", "WLBlueDensity"), - mDensityMult(1.0f, "density_multiplier", 1000), - mHazeHorizon(1.0f, "haze_horizon"), - mMaxAlt(4000.0f, "max_y"), - - // Lighting - mLightnorm(0.f, 0.707f, -0.707f, 1.f, "lightnorm"), - mSunlight(0.5f, 0.5f, 0.5f, 1.0f, "sunlight_color", "WLSunlight"), - mAmbient(0.5f, 0.75f, 1.0f, 1.19f, "ambient", "WLAmbient"), - mGlow(18.0f, 0.0f, -0.01f, 1.0f, "glow"), - - // Clouds - mCloudColor(0.5f, 0.5f, 0.5f, 1.0f, "cloud_color", "WLCloudColor"), - mCloudMain(0.5f, 0.5f, 0.125f, 1.0f, "cloud_pos_density1"), - mCloudCoverage(0.0f, "cloud_shadow"), - mCloudDetail(0.0f, 0.0f, 0.0f, 1.0f, "cloud_pos_density2"), - mDistanceMult(1.0f, "distance_multiplier"), - mCloudScale(0.42f, "cloud_scale"), - - // sky dome - mDomeOffset(0.96f), - mDomeRadius(15000.f) -{ -} - -LLWLParamManager::~LLWLParamManager() -{ -} - -void LLWLParamManager::clearParamSetsOfScope(LLWLParamKey::EScope scope) -{ - if (LLWLParamKey::SCOPE_LOCAL == scope) - { - LL_WARNS("Windlight") << "Tried to clear windlight sky presets from local system! This shouldn't be called..." << LL_ENDL; - return; - } - - std::set<LLWLParamKey> to_remove; - for(std::map<LLWLParamKey, LLWLParamSet>::iterator iter = mParamList.begin(); iter != mParamList.end(); ++iter) - { - if(iter->first.scope == scope) - { - to_remove.insert(iter->first); - } - } - - for(std::set<LLWLParamKey>::iterator iter = to_remove.begin(); iter != to_remove.end(); ++iter) - { - mParamList.erase(*iter); - } -} - -// returns all skies referenced by the day cycle, with their final names -// side effect: applies changes to all internal structures! -std::map<LLWLParamKey, LLWLParamSet> LLWLParamManager::finalizeFromDayCycle(LLWLParamKey::EScope scope) -{ - LL_DEBUGS() << "mDay before finalizing:" << LL_ENDL; - { - for (std::map<F32, LLWLParamKey>::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter) - { - LLWLParamKey& key = iter->second; - LL_DEBUGS() << iter->first << "->" << key.name << LL_ENDL; - } - } - - std::map<LLWLParamKey, LLWLParamSet> final_references; - - // Move all referenced to desired scope, renaming if necessary - // First, save skies referenced - std::map<LLWLParamKey, LLWLParamSet> current_references; // all skies referenced by the day cycle, with their current names - // guard against skies with same name and different scopes - std::set<std::string> inserted_names; - std::map<std::string, unsigned int> conflicted_names; // integer later used as a count, for uniquely renaming conflicts - - LLWLDayCycle& cycle = mDay; - for(std::map<F32, LLWLParamKey>::iterator iter = cycle.mTimeMap.begin(); - iter != cycle.mTimeMap.end(); - ++iter) - { - LLWLParamKey& key = iter->second; - std::string desired_name = key.name; - replace_newlines_with_whitespace(desired_name); // already shouldn't have newlines, but just in case - if(inserted_names.find(desired_name) == inserted_names.end()) - { - inserted_names.insert(desired_name); - } - else - { - // make exist in map - conflicted_names[desired_name] = 0; - } - current_references[key] = mParamList[key]; - } - - // forget all old skies in target scope, and rebuild, renaming as needed - clearParamSetsOfScope(scope); - for(std::map<LLWLParamKey, LLWLParamSet>::iterator iter = current_references.begin(); iter != current_references.end(); ++iter) - { - const LLWLParamKey& old_key = iter->first; - - std::string desired_name(old_key.name); - replace_newlines_with_whitespace(desired_name); - - LLWLParamKey new_key(desired_name, scope); // name will be replaced later if necessary - - // if this sky is one with a non-unique name, rename via appending a number - // an existing preset of the target scope gets to keep its name - if (scope != old_key.scope && conflicted_names.find(desired_name) != conflicted_names.end()) - { - std::string& new_name = new_key.name; - - do - { - // if this executes more than once, this is an absurdly pathological case - // (e.g. "x" repeated twice, but "x 1" already exists, so need to use "x 2") - std::stringstream temp; - temp << desired_name << " " << (++conflicted_names[desired_name]); - new_name = temp.str(); - } while (inserted_names.find(new_name) != inserted_names.end()); - - // yay, found one that works - inserted_names.insert(new_name); // track names we consume here; shouldn't be necessary due to ++int? but just in case - - // *TODO factor out below into a rename()? - - LL_INFOS("Windlight") << "Renamed " << old_key.name << " (scope" << old_key.scope << ") to " - << new_key.name << " (scope " << new_key.scope << ")" << LL_ENDL; - - // update name in sky - iter->second.mName = new_name; - - // update keys in day cycle - for(std::map<F32, LLWLParamKey>::iterator frame = cycle.mTimeMap.begin(); frame != cycle.mTimeMap.end(); ++frame) - { - if (frame->second == old_key) - { - frame->second = new_key; - } - } - - // add to master sky map - mParamList[new_key] = iter->second; - } - - final_references[new_key] = iter->second; - } - - LL_DEBUGS() << "mDay after finalizing:" << LL_ENDL; - { - for (std::map<F32, LLWLParamKey>::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter) - { - LLWLParamKey& key = iter->second; - LL_DEBUGS() << iter->first << "->" << key.name << LL_ENDL; - } - } - - return final_references; -} - -// static -LLSD LLWLParamManager::createSkyMap(std::map<LLWLParamKey, LLWLParamSet> refs) -{ - LLSD skies = LLSD::emptyMap(); - for(std::map<LLWLParamKey, LLWLParamSet>::iterator iter = refs.begin(); iter != refs.end(); ++iter) - { - skies.insert(iter->first.name, iter->second.getAll()); - } - return skies; -} - -void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD& sky_presets) -{ - for(LLSD::map_const_iterator iter = sky_presets.beginMap(); iter != sky_presets.endMap(); ++iter) - { - LLWLParamSet set; - set.setAll(iter->second); - mParamList[LLWLParamKey(iter->first, scope)] = set; - } -} - -void LLWLParamManager::refreshRegionPresets(const LLSD& region_sky_presets) -{ - // Remove all region sky presets because they may belong to a previously visited region. - clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); - - // Add all sky presets belonging to the current region. - addAllSkies(LLEnvKey::SCOPE_REGION, region_sky_presets); -} - -void LLWLParamManager::loadAllPresets() -{ - // First, load system (coming out of the box) sky presets. - loadPresetsFromDir(getSysDir()); - - // Then load user presets. Note that user day presets will modify any system ones already loaded. - loadPresetsFromDir(getUserDir()); -} - -void LLWLParamManager::loadPresetsFromDir(const std::string& dir) -{ - LL_INFOS("AppInit", "Shaders") << "Loading sky presets from " << dir << LL_ENDL; - - LLDirIterator dir_iter(dir, "*.xml"); - while (1) - { - std::string file; - if (!dir_iter.next(file)) - { - break; // no more files - } - - std::string path = gDirUtilp->add(dir, file); - if (!loadPreset(path)) - { - LL_WARNS() << "Error loading sky preset from " << path << LL_ENDL; - } - } -} - -bool LLWLParamManager::loadPreset(const std::string& path) -{ - llifstream xml_file; - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - - xml_file.open(path.c_str()); - if (!xml_file) - { - return false; - } - - LL_DEBUGS("AppInit", "Shaders") << "Loading sky " << name << LL_ENDL; - - LLSD params_data; - LLPointer<LLSDParser> parser = new LLSDXMLParser(); - parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); - xml_file.close(); - - LLWLParamKey key(name, LLEnvKey::SCOPE_LOCAL); - if (hasParamSet(key)) - { - setParamSet(key, params_data); - } - else - { - addParamSet(key, params_data); - } - - return true; -} - -void LLWLParamManager::savePreset(LLWLParamKey key) -{ - llassert(key.scope == LLEnvKey::SCOPE_LOCAL && !key.name.empty()); - - // make an empty llsd - LLSD paramsData(LLSD::emptyMap()); - std::string pathName(getUserDir() + escapeString(key.name) + ".xml"); - - // fill it with LLSD windlight params - paramsData = mParamList[key].getAll(); - - // write to file - llofstream presetsXML(pathName.c_str()); - LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); - formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); - presetsXML.close(); - - propagateParameters(); -} - -void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) -{ - if (gPipeline.canUseWindLightShaders()) - { - mCurParams.update(shader); - } - - if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) - { - shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - } - - else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) - { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV); - } - - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); - -} - -static LLTrace::BlockTimerStatHandle FTM_UPDATE_WLPARAM("Update Windlight Params"); - -void LLWLParamManager::propagateParameters(void) -{ - LL_RECORD_BLOCK_TIME(FTM_UPDATE_WLPARAM); - - LLVector4 sunDir; - LLVector4 moonDir; - - // set the sun direction from SunAngle and EastAngle - F32 sinTheta = sin(mCurParams.getEastAngle()); - F32 cosTheta = cos(mCurParams.getEastAngle()); - - F32 sinPhi = sin(mCurParams.getSunAngle()); - F32 cosPhi = cos(mCurParams.getSunAngle()); - - sunDir.mV[0] = -sinTheta * cosPhi; - sunDir.mV[1] = sinPhi; - sunDir.mV[2] = cosTheta * cosPhi; - sunDir.mV[3] = 0; - - moonDir = -sunDir; - - // is the normal from the sun or the moon - if(sunDir.mV[1] >= 0) - { - mLightDir = sunDir; - } - else if(sunDir.mV[1] < 0 && sunDir.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) - { - // clamp v1 to 0 so sun never points up and causes weirdness on some machines - LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); - vec.mV[1] = 0; - vec.normVec(); - mLightDir = LLVector4(vec, 0.f); - } - else - { - mLightDir = moonDir; - } - - // calculate the clamp lightnorm for sky (to prevent ugly banding in sky - // when haze goes below the horizon - mClampedLightDir = sunDir; - - if (mClampedLightDir.mV[1] < -0.1f) - { - mClampedLightDir.mV[1] = -0.1f; - } - - mCurParams.set("lightnorm", mLightDir); - - // bind the variables for all shaders only if we're using WindLight - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && (gPipeline.canUseWindLightShaders() - || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - - // get the cfr version of the sun's direction - LLVector3 cfrSunDir(sunDir.mV[2], sunDir.mV[0], sunDir.mV[1]); - - // set direction and don't allow overriding - gSky.setSunDirection(cfrSunDir, LLVector3(0,0,0)); - gSky.setOverrideSun(TRUE); -} - -void LLWLParamManager::update(LLViewerCamera * cam) -{ - LL_RECORD_BLOCK_TIME(FTM_UPDATE_WLPARAM); - - // update clouds, sun, and general - mCurParams.updateCloudScrolling(); - - // update only if running - if(mAnimator.getIsRunning()) - { - mAnimator.update(mCurParams); - } - - // update the shaders and the menu - propagateParameters(); - - F32 camYaw = cam->getYaw(); - - stop_glerror(); - - // *TODO: potential optimization - this block may only need to be - // executed some of the time. For example for water shaders only. - { - F32 camYawDelta = mSunDeltaYaw * DEG_TO_RAD; - - LLVector3 lightNorm3(mLightDir); - lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); - mRotatedLightDir = LLVector4(lightNorm3, 0.f); - - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && (gPipeline.canUseWindLightShaders() - || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - } -} - -bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time) -{ - mDay.loadDayCycle(params, scope); - resetAnimator(time, true); // set to specified time and start animator - return true; -} - -void LLWLParamManager::setDefaultDay() -{ - mDay.loadDayCycleFromFile("Default.xml"); -} - -bool LLWLParamManager::applySkyParams(const LLSD& params) -{ - mAnimator.deactivate(); - mCurParams.setAll(params); - return true; -} - -void LLWLParamManager::setDefaultSky() -{ - getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams); -} - - -void LLWLParamManager::resetAnimator(F32 curTime, bool run) -{ - mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate, - curTime, run); - - return; -} - -bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) -{ - // add a new one if not one there already - std::map<LLWLParamKey, LLWLParamSet>::iterator mIt = mParamList.find(key); - if(mIt == mParamList.end()) - { - llassert(!key.name.empty()); - // *TODO: validate params - mParamList[key] = param; - mPresetListChangeSignal(); - return true; - } - - return false; -} - -BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) -{ - LLWLParamSet param_set; - param_set.setAll(param); - return addParamSet(key, param_set); -} - -bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) -{ - // find it and set it - std::map<LLWLParamKey, LLWLParamSet>::iterator mIt = mParamList.find(key); - if(mIt != mParamList.end()) - { - param = mParamList[key]; - param.mName = key.name; - return true; - } - - return false; -} - -bool LLWLParamManager::hasParamSet(const LLWLParamKey& key) -{ - LLWLParamSet dummy; - return getParamSet(key, dummy); -} - -bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) -{ - llassert(!key.name.empty()); - // *TODO: validate params - mParamList[key] = param; - - return true; -} - -bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) -{ - llassert(!key.name.empty()); - // *TODO: validate params - - // quick, non robust (we won't be working with files, but assets) check - // this might not actually be true anymore.... - if(!param.isMap()) - { - return false; - } - - LLWLParamSet param_set; - param_set.setAll(param); - return setParamSet(key, param_set); -} - -void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) -{ - // *NOTE: Removing a sky preset invalidates day cycles that refer to it. - - if (key.scope == LLEnvKey::SCOPE_REGION) - { - LL_WARNS() << "Removing region skies not supported" << LL_ENDL; - llassert(key.scope == LLEnvKey::SCOPE_LOCAL); - return; - } - - // remove from param list - std::map<LLWLParamKey, LLWLParamSet>::iterator it = mParamList.find(key); - if (it == mParamList.end()) - { - LL_WARNS("WindLight") << "No sky preset named " << key.name << LL_ENDL; - return; - } - - mParamList.erase(it); - mDay.removeReferencesTo(key); - - // remove from file system if requested - if (delete_from_disk) - { - std::string path_name(getUserDir()); - std::string escaped_name = escapeString(key.name); - - if(gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml") < 1) - { - LL_WARNS("WindLight") << "Error removing sky preset " << key.name << " from disk" << LL_ENDL; - } - } - - // signal interested parties - mPresetListChangeSignal(); -} - -bool LLWLParamManager::isSystemPreset(const std::string& preset_name) const -{ - // *TODO: file system access is excessive here. - return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); -} - -void LLWLParamManager::getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const -{ - region.clear(); - user.clear(); - sys.clear(); - - for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) - { - const LLWLParamKey& key = it->first; - const std::string& name = key.name; - - if (key.scope == LLEnvKey::SCOPE_REGION) - { - region.push_back(name); - } - else - { - if (isSystemPreset(name)) - { - sys.push_back(name); - } - else - { - user.push_back(name); - } - } - } -} - -void LLWLParamManager::getUserPresetNames(preset_name_list_t& user) const -{ - preset_name_list_t region, sys; // unused - getPresetNames(region, user, sys); -} - -void LLWLParamManager::getPresetKeys(preset_key_list_t& keys) const -{ - keys.clear(); - - for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) - { - keys.push_back(it->first); - } -} - -boost::signals2::connection LLWLParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) -{ - return mPresetListChangeSignal.connect(cb); -} - -// virtual static -void LLWLParamManager::initSingleton() -{ - LL_DEBUGS("Windlight") << "Initializing sky" << LL_ENDL; - - loadAllPresets(); - - // but use linden time sets it to what the estate is - mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); -} - -// static -std::string LLWLParamManager::getSysDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""); -} - -// static -std::string LLWLParamManager::getUserDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/skies", ""); -} - -// static -std::string LLWLParamManager::escapeString(const std::string& str) -{ - // Don't use LLURI::escape() because it doesn't encode '-' characters - // which may break handling of some system presets like "A-12AM". - char* curl_str = curl_escape(str.c_str(), str.size()); - std::string escaped_str(curl_str); - curl_free(curl_str); - - return escaped_str; -} diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h deleted file mode 100644 index 61f86b747f..0000000000 --- a/indra/newview/llwlparammanager.h +++ /dev/null @@ -1,323 +0,0 @@ -/** - * @file llwlparammanager.h - * @brief Implementation for the LLWLParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_WLPARAMMANAGER_H -#define LL_WLPARAMMANAGER_H - -#include <list> -#include <map> -#include "llwlparamset.h" -#include "llwlanimator.h" -#include "llwldaycycle.h" -#include "llviewercamera.h" -#include "lltrans.h" - -class LLGLSLShader; - -// color control -struct WLColorControl { - - F32 r, g, b, i; /// the values - std::string mName; /// name to use to dereference params - std::string mSliderName; /// name of the slider in menu - bool hasSliderName; /// only set slider name for true color types - bool isSunOrAmbientColor; /// flag for if it's the sun or ambient color controller - bool isBlueHorizonOrDensity; /// flag for if it's the Blue Horizon or Density color controller - - inline WLColorControl(F32 red, F32 green, F32 blue, F32 intensity, - const std::string& n, const std::string& sliderName = LLStringUtil::null) - : r(red), g(green), b(blue), i(intensity), mName(n), mSliderName(sliderName) - { - // if there's a slider name, say we have one - hasSliderName = false; - if (mSliderName != "") { - hasSliderName = true; - } - - // if it's the sun controller - isSunOrAmbientColor = false; - if (mSliderName == "WLSunlight" || mSliderName == "WLAmbient") { - isSunOrAmbientColor = true; - } - - isBlueHorizonOrDensity = false; - if (mSliderName == "WLBlueHorizon" || mSliderName == "WLBlueDensity") { - isBlueHorizonOrDensity = true; - } - } - - inline WLColorControl & operator = (LLVector4 const & val) { - r = val.mV[0]; - g = val.mV[1]; - b = val.mV[2]; - i = val.mV[3]; - return *this; - } - - inline operator LLVector4 (void) const { - return LLVector4(r, g, b, i); - } - - inline operator LLVector3 (void) const { - return LLVector3(r, g, b); - } - - inline void update(LLWLParamSet & params) const { - params.set(mName, r, g, b, i); - } -}; - -// float slider control -struct WLFloatControl { - F32 x; - std::string mName; - F32 mult; - - inline WLFloatControl(F32 val, const std::string& n, F32 m=1.0f) - : x(val), mName(n), mult(m) - { - } - - inline WLFloatControl & operator = (F32 val) { - x = val; - return *this; - } - - inline operator F32 (void) const { - return x; - } - - inline void update(LLWLParamSet & params) const { - params.set(mName, x); - } -}; - -/// WindLight parameter manager class - what controls all the wind light shaders -class LLWLParamManager : public LLSingleton<LLWLParamManager> -{ - LLSINGLETON(LLWLParamManager); - ~LLWLParamManager(); - LOG_CLASS(LLWLParamManager); - -public: - typedef std::list<std::string> preset_name_list_t; - typedef std::list<LLWLParamKey> preset_key_list_t; - typedef boost::signals2::signal<void()> preset_list_signal_t; - - /// save the parameter presets to file - void savePreset(const LLWLParamKey key); - - /// Set shader uniforms dirty, so they'll update automatically. - void propagateParameters(void); - - /// Update shader uniforms that have changed. - void updateShaderUniforms(LLGLSLShader * shader); - - /// setup the animator to run - void resetAnimator(F32 curTime, bool run); - - /// update information camera dependent parameters - void update(LLViewerCamera * cam); - - /// apply specified day cycle, setting time to noon by default - bool applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time = 0.5); - - /// Apply Default.xml map - void setDefaultDay(); - - /// apply specified fixed sky params - bool applySkyParams(const LLSD& params); - - void setDefaultSky(); - - // get where the light is pointing - inline LLVector4 getLightDir(void) const; - - // get where the light is pointing - inline LLVector4 getClampedLightDir(void) const; - - // get where the light is pointing - inline LLVector4 getRotatedLightDir(void) const; - - /// get the dome's offset - inline F32 getDomeOffset(void) const; - - /// get the radius of the dome - inline F32 getDomeRadius(void) const; - - /// add a param set (preset) to the list - bool addParamSet(const LLWLParamKey& key, LLWLParamSet& param); - - /// add a param set (preset) to the list - BOOL addParamSet(const LLWLParamKey& key, LLSD const & param); - - /// get a param set (preset) from the list - bool getParamSet(const LLWLParamKey& key, LLWLParamSet& param); - - /// check whether the preset is in the list - bool hasParamSet(const LLWLParamKey& key); - - /// set the param in the list with a new param - bool setParamSet(const LLWLParamKey& key, LLWLParamSet& param); - - /// set the param in the list with a new param - bool setParamSet(const LLWLParamKey& key, LLSD const & param); - - /// gets rid of a parameter and any references to it - /// ignores "delete_from_disk" if the scope is not local - void removeParamSet(const LLWLParamKey& key, bool delete_from_disk); - - /// clear parameter mapping of a given scope - void clearParamSetsOfScope(LLEnvKey::EScope scope); - - /// @return true if the preset comes out of the box - bool isSystemPreset(const std::string& preset_name) const; - - /// @return user and system preset names as a single list - void getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const; - - /// @return user preset names - void getUserPresetNames(preset_name_list_t& user) const; - - /// @return keys of all known presets - void getPresetKeys(preset_key_list_t& keys) const; - - /// Emitted when a preset gets added or deleted. - boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); - - /// add all skies in LLSD using the given scope - void addAllSkies(LLEnvKey::EScope scope, const LLSD& preset_map); - - /// refresh region-scope presets - void refreshRegionPresets(const LLSD& region_sky_presets); - - // returns all skies referenced by the current day cycle (in mDay), with their final names - // side effect: applies changes to all internal structures! (trashes all unreferenced skies in scope, keys in day cycle rescoped to scope, etc.) - std::map<LLWLParamKey, LLWLParamSet> finalizeFromDayCycle(LLWLParamKey::EScope scope); - - // returns all skies in map (intended to be called with output from a finalize) - static LLSD createSkyMap(std::map<LLWLParamKey, LLWLParamSet> map); - - /// escape string in a way different from LLURI::escape() - static std::string escapeString(const std::string& str); - - // helper variables - LLWLAnimator mAnimator; - - /// actual direction of the sun - LLVector4 mLightDir; - - /// light norm adjusted so haze works correctly - LLVector4 mRotatedLightDir; - - /// clamped light norm for shaders that - /// are adversely affected when the sun goes below the - /// horizon - LLVector4 mClampedLightDir; - - // list of params and how they're cycled for days - LLWLDayCycle mDay; - - LLWLParamSet mCurParams; - - /// Sun Delta Terrain tweak variables. - F32 mSunDeltaYaw; - WLFloatControl mWLGamma; - - F32 mSceneLightStrength; - - /// Atmospherics - WLColorControl mBlueHorizon; - WLFloatControl mHazeDensity; - WLColorControl mBlueDensity; - WLFloatControl mDensityMult; - WLFloatControl mHazeHorizon; - WLFloatControl mMaxAlt; - - /// Lighting - WLColorControl mLightnorm; - WLColorControl mSunlight; - WLColorControl mAmbient; - WLColorControl mGlow; - - /// Clouds - WLColorControl mCloudColor; - WLColorControl mCloudMain; - WLFloatControl mCloudCoverage; - WLColorControl mCloudDetail; - WLFloatControl mDistanceMult; - WLFloatControl mCloudScale; - - /// sky dome - F32 mDomeOffset; - F32 mDomeRadius; - - -private: - - friend class LLWLAnimator; - - void loadAllPresets(); - void loadPresetsFromDir(const std::string& dir); - bool loadPreset(const std::string& path); - - static std::string getSysDir(); - static std::string getUserDir(); - - /*virtual*/ void initSingleton(); - // list of all the parameters, listed by name - std::map<LLWLParamKey, LLWLParamSet> mParamList; - - preset_list_signal_t mPresetListChangeSignal; -}; - -inline F32 LLWLParamManager::getDomeOffset(void) const -{ - return mDomeOffset; -} - -inline F32 LLWLParamManager::getDomeRadius(void) const -{ - return mDomeRadius; -} - -inline LLVector4 LLWLParamManager::getLightDir(void) const -{ - return mLightDir; -} - -inline LLVector4 LLWLParamManager::getClampedLightDir(void) const -{ - return mClampedLightDir; -} - -inline LLVector4 LLWLParamManager::getRotatedLightDir(void) const -{ - return mRotatedLightDir; -} - -#endif - diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp deleted file mode 100644 index 066cb9a0ac..0000000000 --- a/indra/newview/llwlparamset.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/** - * @file llwlparamset.cpp - * @brief Implementation for the LLWLParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llwlparamset.h" -#include "llwlanimator.h" - -#include "llwlparammanager.h" -#include "llglslshader.h" -#include "lluictrlfactory.h" -#include "llsliderctrl.h" -#include "pipeline.h" - -#include <llgl.h> - -#include <sstream> - -static LLStaticHashedString sStarBrightness("star_brightness"); -static LLStaticHashedString sPresetNum("preset_num"); -static LLStaticHashedString sSunAngle("sun_angle"); -static LLStaticHashedString sEastAngle("east_angle"); -static LLStaticHashedString sEnableCloudScroll("enable_cloud_scroll"); -static LLStaticHashedString sCloudScrollRate("cloud_scroll_rate"); -static LLStaticHashedString sLightNorm("lightnorm"); -static LLStaticHashedString sCloudDensity("cloud_pos_density1"); -static LLStaticHashedString sCloudScale("cloud_scale"); -static LLStaticHashedString sCloudShadow("cloud_shadow"); -static LLStaticHashedString sDensityMultiplier("density_multiplier"); -static LLStaticHashedString sDistanceMultiplier("distance_multiplier"); -static LLStaticHashedString sHazeDensity("haze_density"); -static LLStaticHashedString sHazeHorizon("haze_horizon"); -static LLStaticHashedString sMaxY("max_y"); - -LLWLParamSet::LLWLParamSet(void) : - mName("Unnamed Preset"), - mCloudScrollXOffset(0.f), mCloudScrollYOffset(0.f) -{} - -static LLTrace::BlockTimerStatHandle FTM_WL_PARAM_UPDATE("WL Param Update"); - -void LLWLParamSet::update(LLGLSLShader * shader) const -{ - LL_RECORD_BLOCK_TIME(FTM_WL_PARAM_UPDATE); - LLSD::map_const_iterator i = mParamValues.beginMap(); - std::vector<LLStaticHashedString>::const_iterator n = mParamHashedNames.begin(); - for(;(i != mParamValues.endMap()) && (n != mParamHashedNames.end());++i, n++) - { - const LLStaticHashedString& param = *n; - - // check that our pre-hashed names are still tracking the mParamValues map correctly - // - llassert(param.String() == i->first); - - if (param == sStarBrightness || param == sPresetNum || param == sSunAngle || - param == sEastAngle || param == sEnableCloudScroll || - param == sCloudScrollRate || param == sLightNorm ) - { - continue; - } - - if (param == sCloudDensity) - { - LLVector4 val; - val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; - val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; - val.mV[2] = (F32) i->second[2].asReal(); - val.mV[3] = (F32) i->second[3].asReal(); - - stop_glerror(); - shader->uniform4fv(param, 1, val.mV); - stop_glerror(); - } - else if (param == sCloudScale || param == sCloudShadow || - param == sDensityMultiplier || param == sDistanceMultiplier || - param == sHazeDensity || param == sHazeHorizon || - param == sMaxY ) - { - F32 val = (F32) i->second[0].asReal(); - - stop_glerror(); - shader->uniform1f(param, val); - stop_glerror(); - } - else // param is the uniform name - { - // handle all the different cases - if (i->second.isArray() && i->second.size() == 4) - { - LLVector4 val; - - val.mV[0] = (F32) i->second[0].asReal(); - val.mV[1] = (F32) i->second[1].asReal(); - val.mV[2] = (F32) i->second[2].asReal(); - val.mV[3] = (F32) i->second[3].asReal(); - - stop_glerror(); - shader->uniform4fv(param, 1, val.mV); - stop_glerror(); - } - else if (i->second.isReal()) - { - F32 val = (F32) i->second.asReal(); - - stop_glerror(); - shader->uniform1f(param, val); - stop_glerror(); - } - else if (i->second.isInteger()) - { - S32 val = (S32) i->second.asInteger(); - - stop_glerror(); - shader->uniform1i(param, val); - stop_glerror(); - } - else if (i->second.isBoolean()) - { - S32 val = (i->second.asBoolean() ? 1 : 0); - - stop_glerror(); - shader->uniform1i(param, val); - stop_glerror(); - } - } - } - - if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) - { - shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); - } else { - shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); - } -} - -void LLWLParamSet::set(const std::string& paramName, float x) -{ - // handle case where no array - if(mParamValues[paramName].isReal()) - { - mParamValues[paramName] = x; - } - - // handle array - else if(mParamValues[paramName].isArray() && - mParamValues[paramName][0].isReal()) - { - mParamValues[paramName][0] = x; - } -} - -void LLWLParamSet::set(const std::string& paramName, float x, float y) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; -} - -void LLWLParamSet::set(const std::string& paramName, float x, float y, float z) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; -} - -void LLWLParamSet::set(const std::string& paramName, float x, float y, float z, float w) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; - mParamValues[paramName][3] = w; -} - -void LLWLParamSet::set(const std::string& paramName, const float * val) -{ - mParamValues[paramName][0] = val[0]; - mParamValues[paramName][1] = val[1]; - mParamValues[paramName][2] = val[2]; - mParamValues[paramName][3] = val[3]; -} - -void LLWLParamSet::set(const std::string& paramName, const LLVector4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -void LLWLParamSet::set(const std::string& paramName, const LLColor4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -LLVector4 LLWLParamSet::getVector(const std::string& paramName, bool& error) -{ - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray()) - { - error = true; - return LLVector4(0,0,0,0); - } - - LLVector4 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - val.mV[2] = (F32) cur_val[2].asReal(); - val.mV[3] = (F32) cur_val[3].asReal(); - - error = false; - return val; -} - -F32 LLWLParamSet::getFloat(const std::string& paramName, bool& error) -{ - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (cur_val.isArray() && cur_val.size() != 0) - { - error = false; - return (F32) cur_val[0].asReal(); - } - - if(cur_val.isReal()) - { - error = false; - return (F32) cur_val.asReal(); - } - - error = true; - return 0; -} - -void LLWLParamSet::setSunAngle(float val) -{ - // keep range 0 - 2pi - if(val > F_TWO_PI || val < 0) - { - F32 num = val / F_TWO_PI; - num -= floor(num); - val = F_TWO_PI * num; - } - - mParamValues["sun_angle"] = val; -} - - -void LLWLParamSet::setEastAngle(float val) -{ - // keep range 0 - 2pi - if(val > F_TWO_PI || val < 0) - { - F32 num = val / F_TWO_PI; - num -= floor(num); - val = F_TWO_PI * num; - } - - mParamValues["east_angle"] = val; -} - -void LLWLParamSet::mix(LLWLParamSet& src, LLWLParamSet& dest, F32 weight) -{ - // set up the iterators - - // keep cloud positions and coverage the same - /// TODO masking will do this later - F32 cloudPos1X = (F32) mParamValues["cloud_pos_density1"][0].asReal(); - F32 cloudPos1Y = (F32) mParamValues["cloud_pos_density1"][1].asReal(); - F32 cloudPos2X = (F32) mParamValues["cloud_pos_density2"][0].asReal(); - F32 cloudPos2Y = (F32) mParamValues["cloud_pos_density2"][1].asReal(); - F32 cloudCover = (F32) mParamValues["cloud_shadow"][0].asReal(); - - LLSD srcVal; - LLSD destVal; - - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - // If param exists in both src and dest, set the holder variables, otherwise skip - if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) - { - srcVal = src.mParamValues[iter->first]; - destVal = dest.mParamValues[iter->first]; - } - else - { - continue; - } - - if(iter->second.isReal()) // If it's a real, interpolate directly - { - iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); - } - else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those - && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) - { - // Actually do interpolation: old value + (difference in values * factor) - for(int i=0; i < iter->second.size(); ++i) - { - // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation - iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); - } - } - else // Else, skip - { - continue; - } - } - - // now mix the extra parameters - setStarBrightness((1 - weight) * (F32) src.getStarBrightness() - + weight * (F32) dest.getStarBrightness()); - - llassert(src.getSunAngle() >= - F_PI && - src.getSunAngle() <= 3 * F_PI); - llassert(dest.getSunAngle() >= - F_PI && - dest.getSunAngle() <= 3 * F_PI); - llassert(src.getEastAngle() >= 0 && - src.getEastAngle() <= 4 * F_PI); - llassert(dest.getEastAngle() >= 0 && - dest.getEastAngle() <= 4 * F_PI); - - // sun angle and east angle require some handling to make sure - // they go in circles. Yes quaternions would work better. - F32 srcSunAngle = src.getSunAngle(); - F32 destSunAngle = dest.getSunAngle(); - F32 srcEastAngle = src.getEastAngle(); - F32 destEastAngle = dest.getEastAngle(); - - if(fabsf(srcSunAngle - destSunAngle) > F_PI) - { - if(srcSunAngle > destSunAngle) - { - destSunAngle += 2 * F_PI; - } - else - { - srcSunAngle += 2 * F_PI; - } - } - - if(fabsf(srcEastAngle - destEastAngle) > F_PI) - { - if(srcEastAngle > destEastAngle) - { - destEastAngle += 2 * F_PI; - } - else - { - srcEastAngle += 2 * F_PI; - } - } - - setSunAngle((1 - weight) * srcSunAngle + weight * destSunAngle); - setEastAngle((1 - weight) * srcEastAngle + weight * destEastAngle); - - // now setup the sun properly - - // reset those cloud positions - mParamValues["cloud_pos_density1"][0] = cloudPos1X; - mParamValues["cloud_pos_density1"][1] = cloudPos1Y; - mParamValues["cloud_pos_density2"][0] = cloudPos2X; - mParamValues["cloud_pos_density2"][1] = cloudPos2Y; - mParamValues["cloud_shadow"][0] = cloudCover; -} - -void LLWLParamSet::updateCloudScrolling(void) -{ - static LLTimer s_cloud_timer; - - F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - - if(getEnableCloudScrollX()) - { - mCloudScrollXOffset += F32(delta_t * (getCloudScrollX() - 10.f) / 100.f); - } - if(getEnableCloudScrollY()) - { - mCloudScrollYOffset += F32(delta_t * (getCloudScrollY() - 10.f) / 100.f); - } -} - -void LLWLParamSet::updateHashedNames() -{ - mParamHashedNames.clear(); - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - mParamHashedNames.push_back(LLStaticHashedString(iter->first)); - } -} - diff --git a/indra/newview/llwlparamset.h b/indra/newview/llwlparamset.h deleted file mode 100644 index 6e5f1d3a4b..0000000000 --- a/indra/newview/llwlparamset.h +++ /dev/null @@ -1,246 +0,0 @@ -/** - * @file llwlparamset.h - * @brief Interface for the LLWLParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_WLPARAM_SET_H -#define LL_WLPARAM_SET_H - -#include <string> -#include <map> -#include <vector> - -#include "v4math.h" -#include "v4color.h" -#include "llstaticstringtable.h" - -class LLWLParamSet; -class LLGLSLShader; - -/// A class representing a set of parameter values for the WindLight shaders. -class LLWLParamSet { - - friend class LLWLParamManager; - -public: - std::string mName; - -private: - - LLSD mParamValues; - std::vector<LLStaticHashedString> mParamHashedNames; - - float mCloudScrollXOffset, mCloudScrollYOffset; - - void updateHashedNames(); - -public: - - LLWLParamSet(); - - /// Update this set of shader uniforms from the parameter values. - void update(LLGLSLShader * shader) const; - - /// set the total llsd - void setAll(const LLSD& val); - - /// get the total llsd - const LLSD& getAll(); - - - /// Set a float parameter. - /// \param paramName The name of the parameter to set. - /// \param x The float value to set. - void set(const std::string& paramName, float x); - - /// Set a float2 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - void set(const std::string& paramName, float x, float y); - - /// Set a float3 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - void set(const std::string& paramName, float x, float y, float z); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - /// \param w The w component's value to set. - void set(const std::string& paramName, float x, float y, float z, float w); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val An array of the 4 float values to set the parameter to. - void set(const std::string& paramName, const float * val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLVector4 & val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLColor4 & val); - - /// Get a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector4 getVector(const std::string& paramName, bool& error); - - /// Get a float parameter - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - F32 getFloat(const std::string& paramName, bool& error); - - - // specific getters and setters - - - /// set the star's brightness - /// \param val brightness value - void setStarBrightness(F32 val); - - /// get the star brightness value; - F32 getStarBrightness(); - - void setSunAngle(F32 val); - F32 getSunAngle(); - - void setEastAngle(F32 val); - F32 getEastAngle(); - - - - /// set the cloud scroll x enable value - /// \param val scroll x value - void setEnableCloudScrollX(bool val); - - /// get the scroll x enable value; - bool getEnableCloudScrollX(); - - /// set the star's brightness - /// \param val scroll y bool value - void setEnableCloudScrollY(bool val); - - /// get the scroll enable y value; - bool getEnableCloudScrollY(); - - /// set the cloud scroll x enable value - /// \param val scroll x value - void setCloudScrollX(F32 val); - - /// get the scroll x enable value; - F32 getCloudScrollX(); - - /// set the star's brightness - /// \param val scroll y bool value - void setCloudScrollY(F32 val); - - /// get the scroll enable y value; - F32 getCloudScrollY(); - - /// interpolate two parameter sets - /// \param src The parameter set to start with - /// \param dest The parameter set to end with - /// \param weight The amount to interpolate - void mix(LLWLParamSet& src, LLWLParamSet& dest, - F32 weight); - - void updateCloudScrolling(void); -}; - -inline void LLWLParamSet::setAll(const LLSD& val) -{ - if(val.isMap()) { - mParamValues = val; - } - - updateHashedNames(); -} - -inline const LLSD& LLWLParamSet::getAll() -{ - return mParamValues; -} - -inline void LLWLParamSet::setStarBrightness(float val) { - mParamValues["star_brightness"] = val; -} - -inline F32 LLWLParamSet::getStarBrightness() { - return (F32) mParamValues["star_brightness"].asReal(); -} - -inline F32 LLWLParamSet::getSunAngle() { - return (F32) mParamValues["sun_angle"].asReal(); -} - -inline F32 LLWLParamSet::getEastAngle() { - return (F32) mParamValues["east_angle"].asReal(); -} - - -inline void LLWLParamSet::setEnableCloudScrollX(bool val) { - mParamValues["enable_cloud_scroll"][0] = val; -} - -inline bool LLWLParamSet::getEnableCloudScrollX() { - return mParamValues["enable_cloud_scroll"][0].asBoolean(); -} - -inline void LLWLParamSet::setEnableCloudScrollY(bool val) { - mParamValues["enable_cloud_scroll"][1] = val; -} - -inline bool LLWLParamSet::getEnableCloudScrollY() { - return mParamValues["enable_cloud_scroll"][1].asBoolean(); -} - - -inline void LLWLParamSet::setCloudScrollX(F32 val) { - mParamValues["cloud_scroll_rate"][0] = val; -} - -inline F32 LLWLParamSet::getCloudScrollX() { - return (F32) mParamValues["cloud_scroll_rate"][0].asReal(); -} - -inline void LLWLParamSet::setCloudScrollY(F32 val) { - mParamValues["cloud_scroll_rate"][1] = val; -} - -inline F32 LLWLParamSet::getCloudScrollY() { - return (F32) mParamValues["cloud_scroll_rate"][1].asReal(); -} - - -#endif // LL_WLPARAM_SET_H - diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index cee47a591e..a519b5a957 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -873,6 +873,57 @@ void LLWorld::waterHeightRegionInfo(std::string const& sim_name, F32 water_heigh } } +void LLWorld::precullWaterObjects(LLCamera& camera, LLCullResult* cull, bool include_void_water) +{ + if (!gAgent.getRegion()) + { + return; + } + + if (mRegionList.empty()) + { + LL_WARNS() << "No regions!" << LL_ENDL; + return; + } + + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) + { + LLViewerRegion* regionp = *iter; + LLVOWater* waterp = regionp->getLand().getWaterObj(); + if (waterp && waterp->mDrawable) + { + waterp->mDrawable->setVisible(camera); + cull->pushDrawable(waterp->mDrawable); + } + } + + if (include_void_water) + { + for (std::list<LLVOWater*>::iterator iter = mHoleWaterObjects.begin(); + iter != mHoleWaterObjects.end(); ++ iter) + { + LLVOWater* waterp = *iter; + if (waterp && waterp->mDrawable) + { + waterp->mDrawable->setVisible(camera); + cull->pushDrawable(waterp->mDrawable); + } + } + } + + S32 dir; + for (dir = 0; dir < 8; dir++) + { + LLVOWater* waterp = mEdgeWaterObjects[dir]; + if (waterp && waterp->mDrawable) + { + waterp->mDrawable->setVisible(camera); + cull->pushDrawable(waterp->mDrawable); + } + } +} + void LLWorld::updateWaterObjects() { if (!gAgent.getRegion()) diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index c9ac241d5a..9722448746 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -138,6 +138,9 @@ public: LLViewerTexture *getDefaultWaterTexture(); void updateWaterObjects(); + + void precullWaterObjects(LLCamera& camera, LLCullResult* cull, bool include_void_water); + void waterHeightRegionInfo(std::string const& sim_name, F32 water_height); void shiftRegions(const LLVector3& offset); diff --git a/indra/newview/llxmlrpclistener.cpp b/indra/newview/llxmlrpclistener.cpp index 7bc8af4a0b..0693d08dfb 100644 --- a/indra/newview/llxmlrpclistener.cpp +++ b/indra/newview/llxmlrpclistener.cpp @@ -105,29 +105,12 @@ public: def(CURLE_UNSUPPORTED_PROTOCOL); /* 1 */ def(CURLE_FAILED_INIT); /* 2 */ def(CURLE_URL_MALFORMAT); /* 3 */ - def(CURLE_URL_MALFORMAT_USER); /* 4 - NOT USED */ def(CURLE_COULDNT_RESOLVE_PROXY); /* 5 */ def(CURLE_COULDNT_RESOLVE_HOST); /* 6 */ def(CURLE_COULDNT_CONNECT); /* 7 */ - def(CURLE_FTP_WEIRD_SERVER_REPLY); /* 8 */ - def(CURLE_FTP_ACCESS_DENIED); /* 9 a service was denied by the FTP server - due to lack of access - when login fails - this is not returned. */ - def(CURLE_FTP_USER_PASSWORD_INCORRECT); /* 10 - NOT USED */ - def(CURLE_FTP_WEIRD_PASS_REPLY); /* 11 */ - def(CURLE_FTP_WEIRD_USER_REPLY); /* 12 */ - def(CURLE_FTP_WEIRD_PASV_REPLY); /* 13 */ - def(CURLE_FTP_WEIRD_227_FORMAT); /* 14 */ - def(CURLE_FTP_CANT_GET_HOST); /* 15 */ - def(CURLE_FTP_CANT_RECONNECT); /* 16 */ - def(CURLE_FTP_COULDNT_SET_BINARY); /* 17 */ def(CURLE_PARTIAL_FILE); /* 18 */ - def(CURLE_FTP_COULDNT_RETR_FILE); /* 19 */ - def(CURLE_FTP_WRITE_ERROR); /* 20 */ - def(CURLE_FTP_QUOTE_ERROR); /* 21 */ def(CURLE_HTTP_RETURNED_ERROR); /* 22 */ def(CURLE_WRITE_ERROR); /* 23 */ - def(CURLE_MALFORMAT_USER); /* 24 - NOT USED */ def(CURLE_UPLOAD_FAILED); /* 25 - failed upload "command" */ def(CURLE_READ_ERROR); /* 26 - could open/read from file */ def(CURLE_OUT_OF_MEMORY); /* 27 */ @@ -135,29 +118,18 @@ public: instead of a memory allocation error if CURL_DOES_CONVERSIONS is defined */ - def(CURLE_OPERATION_TIMEOUTED); /* 28 - the timeout time was reached */ - def(CURLE_FTP_COULDNT_SET_ASCII); /* 29 - TYPE A failed */ - def(CURLE_FTP_PORT_FAILED); /* 30 - FTP PORT operation failed */ - def(CURLE_FTP_COULDNT_USE_REST); /* 31 - the REST command failed */ - def(CURLE_FTP_COULDNT_GET_SIZE); /* 32 - the SIZE command failed */ + def(CURLE_OPERATION_TIMEDOUT); /* 28 - the timeout time was reached */ def(CURLE_HTTP_RANGE_ERROR); /* 33 - RANGE "command" didn't work */ def(CURLE_HTTP_POST_ERROR); /* 34 */ def(CURLE_SSL_CONNECT_ERROR); /* 35 - wrong when connecting with SSL */ def(CURLE_BAD_DOWNLOAD_RESUME); /* 36 - couldn't resume download */ def(CURLE_FILE_COULDNT_READ_FILE); /* 37 */ - def(CURLE_LDAP_CANNOT_BIND); /* 38 */ - def(CURLE_LDAP_SEARCH_FAILED); /* 39 */ def(CURLE_LIBRARY_NOT_FOUND); /* 40 */ def(CURLE_FUNCTION_NOT_FOUND); /* 41 */ def(CURLE_ABORTED_BY_CALLBACK); /* 42 */ def(CURLE_BAD_FUNCTION_ARGUMENT); /* 43 */ - def(CURLE_BAD_CALLING_ORDER); /* 44 - NOT USED */ def(CURLE_INTERFACE_FAILED); /* 45 - CURLOPT_INTERFACE failed */ - def(CURLE_BAD_PASSWORD_ENTERED); /* 46 - NOT USED */ def(CURLE_TOO_MANY_REDIRECTS ); /* 47 - catch endless re-direct loops */ - def(CURLE_UNKNOWN_TELNET_OPTION); /* 48 - User specified an unknown option */ - def(CURLE_TELNET_OPTION_SYNTAX ); /* 49 - Malformed telnet option */ - def(CURLE_OBSOLETE); /* 50 - NOT USED */ def(CURLE_SSL_PEER_CERTIFICATE); /* 51 - peer's certificate wasn't ok */ def(CURLE_GOT_NOTHING); /* 52 - when this is a specific error */ def(CURLE_SSL_ENGINE_NOTFOUND); /* 53 - SSL crypto engine not found */ @@ -165,26 +137,19 @@ public: default */ def(CURLE_SEND_ERROR); /* 55 - failed sending network data */ def(CURLE_RECV_ERROR); /* 56 - failure in receiving network data */ - def(CURLE_SHARE_IN_USE); /* 57 - share is in use */ + def(CURLE_SSL_CERTPROBLEM); /* 58 - problem with the local certificate */ def(CURLE_SSL_CIPHER); /* 59 - couldn't use specified cipher */ def(CURLE_SSL_CACERT); /* 60 - problem with the CA cert (path?) */ def(CURLE_BAD_CONTENT_ENCODING); /* 61 - Unrecognized transfer encoding */ - def(CURLE_LDAP_INVALID_URL); /* 62 - Invalid LDAP URL */ + def(CURLE_FILESIZE_EXCEEDED); /* 63 - Maximum file size exceeded */ - def(CURLE_FTP_SSL_FAILED); /* 64 - Requested FTP SSL level failed */ + def(CURLE_SEND_FAIL_REWIND); /* 65 - Sending the data requires a rewind that failed */ def(CURLE_SSL_ENGINE_INITFAILED); /* 66 - failed to initialise ENGINE */ def(CURLE_LOGIN_DENIED); /* 67 - user); password or similar was not accepted and we failed to login */ - def(CURLE_TFTP_NOTFOUND); /* 68 - file not found on server */ - def(CURLE_TFTP_PERM); /* 69 - permission problem on server */ - def(CURLE_TFTP_DISKFULL); /* 70 - out of disk space on server */ - def(CURLE_TFTP_ILLEGAL); /* 71 - Illegal TFTP operation */ - def(CURLE_TFTP_UNKNOWNID); /* 72 - Unknown transfer ID */ - def(CURLE_TFTP_EXISTS); /* 73 - File already exists */ - def(CURLE_TFTP_NOSUCHUSER); /* 74 - No such user */ def(CURLE_CONV_FAILED); /* 75 - conversion failed */ def(CURLE_CONV_REQD); /* 76 - caller must register conversion callbacks using curl_easy_setopt options diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 40d6d325ba..c3bccfd19b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -88,6 +88,7 @@ #include "llvocache.h" #include "llvoground.h" #include "llvosky.h" +#include "llvowlsky.h" #include "llvotree.h" #include "llvovolume.h" #include "llvosurfacepatch.h" @@ -100,8 +101,6 @@ #include "llviewerstats.h" #include "llviewerjoystick.h" #include "llviewerdisplay.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" #include "llspatialpartition.h" #include "llmutelist.h" #include "lltoolpie.h" @@ -116,6 +115,8 @@ #include "llprogressview.h" #include "llcleanup.h" +#include "llenvironment.h" + #ifdef _DEBUG // Debug indices is disabled for now for debug performance - djs 4/24/02 //#define DEBUG_INDICES @@ -253,6 +254,11 @@ LLTrace::BlockTimerStatHandle FTM_PIPELINE("Pipeline"); LLTrace::BlockTimerStatHandle FTM_CLIENT_COPY("Client Copy"); LLTrace::BlockTimerStatHandle FTM_RENDER_DEFERRED("Deferred Shading"); +LLTrace::BlockTimerStatHandle FTM_RENDER_UI_HUD("HUD"); +LLTrace::BlockTimerStatHandle FTM_RENDER_UI_3D("3D"); +LLTrace::BlockTimerStatHandle FTM_RENDER_UI_2D("2D"); +LLTrace::BlockTimerStatHandle FTM_RENDER_UI_DEBUG_TEXT("Debug Text"); +LLTrace::BlockTimerStatHandle FTM_RENDER_UI_SCENE_MON("Scene Mon"); static LLTrace::BlockTimerStatHandle FTM_STATESORT_DRAWABLE("Sort Drawables"); static LLTrace::BlockTimerStatHandle FTM_STATESORT_POSTSORT("Post Sort"); @@ -298,62 +304,6 @@ void drawBoxOutline(const LLVector3& pos, const LLVector3& size); U32 nhpo2(U32 v); LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage); -glh::matrix4f glh_copy_matrix(F32* src) -{ - glh::matrix4f ret; - ret.set_value(src); - return ret; -} - -glh::matrix4f glh_get_current_modelview() -{ - return glh_copy_matrix(gGLModelView); -} - -glh::matrix4f glh_get_current_projection() -{ - return glh_copy_matrix(gGLProjection); -} - -glh::matrix4f glh_get_last_modelview() -{ - return glh_copy_matrix(gGLLastModelView); -} - -glh::matrix4f glh_get_last_projection() -{ - return glh_copy_matrix(gGLLastProjection); -} - -void glh_copy_matrix(const glh::matrix4f& src, F32* dst) -{ - for (U32 i = 0; i < 16; i++) - { - dst[i] = src.m[i]; - } -} - -void glh_set_current_modelview(const glh::matrix4f& mat) -{ - glh_copy_matrix(mat, gGLModelView); -} - -void glh_set_current_projection(glh::matrix4f& mat) -{ - glh_copy_matrix(mat, gGLProjection); -} - -glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar) -{ - glh::matrix4f ret( - 2.f/(right-left), 0.f, 0.f, -(right+left)/(right-left), - 0.f, 2.f/(top-bottom), 0.f, -(top+bottom)/(top-bottom), - 0.f, 0.f, -2.f/(zfar-znear), -(zfar+znear)/(zfar-znear), - 0.f, 0.f, 0.f, 1.f); - - return ret; -} - void display_update_camera(); //---------------------------------------- @@ -386,6 +336,7 @@ bool LLPipeline::sShadowRender = false; bool LLPipeline::sWaterReflections = false; bool LLPipeline::sRenderGlow = false; bool LLPipeline::sReflectionRender = false; +bool LLPipeline::sDistortionRender = false; bool LLPipeline::sImpostorRender = false; bool LLPipeline::sImpostorRenderAlphaDepthPass = false; bool LLPipeline::sUnderWaterRender = false; @@ -398,6 +349,7 @@ bool LLPipeline::sMemAllocationThrottled = false; S32 LLPipeline::sVisibleLightCount = 0; F32 LLPipeline::sMinRenderSize = 0.f; bool LLPipeline::sRenderingHUDs; +F32 LLPipeline::sDistortionWaterClipPlaneMargin = 1.0001f; // EventHost API LLPipeline listener. static LLPipelineListener sPipelineListener; @@ -906,6 +858,9 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY) return ret; } + // must be even to avoid a stripe in the horizontal shadow blur +inline U32 BlurHappySize(U32 x, U32 scale) { return (((x*scale)+1)&~1); } + bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { refreshCachedSettings(); @@ -973,62 +928,72 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mDeferredLight.release(); } - F32 scale = RenderShadowResolutionScale; + F32 scale = RenderShadowResolutionScale; + U32 sun_shadow_map_width = BlurHappySize(resX, scale); + U32 sun_shadow_map_height = BlurHappySize(resY, scale); if (shadow_detail > 0) - { //allocate 4 sun shadow maps - U32 sun_shadow_map_width = ((U32(resX*scale)+1)&~1); // must be even to avoid a stripe in the horizontal shadow blur - for (U32 i = 0; i < 4; i++) - { - if (!mShadow[i].allocate(sun_shadow_map_width,U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false; - if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false; - } - } - else - { + { //allocate 4 sun shadow maps for (U32 i = 0; i < 4; i++) - { - mShadow[i].release(); - mShadowOcclusion[i].release(); - } - } + { + if (!mShadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + { + return false; + } + + if (!mShadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + { + return false; + } + } + } + else + { + for (U32 i = 0; i < 4; i++) + { + releaseShadowTarget(i); + } + } - U32 width = (U32) (resX*scale); - U32 height = width; + U32 width = (U32) (resX*scale); + U32 height = width; - if (shadow_detail > 1) - { //allocate two spot shadow maps - U32 spot_shadow_map_width = width; - for (U32 i = 4; i < 6; i++) - { - if (!mShadow[i].allocate(spot_shadow_map_width, height, 0, TRUE, FALSE)) return false; - if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE)) return false; - } - } - else - { - for (U32 i = 4; i < 6; i++) - { - mShadow[i].release(); - mShadowOcclusion[i].release(); - } - } + if (shadow_detail > 1) + { //allocate two spot shadow maps + U32 spot_shadow_map_width = width; + U32 spot_shadow_map_height = height; + for (U32 i = 4; i < 6; i++) + { + if (!mShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) + { + return false; + } + if (!mShadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) + { + return false; + } + } + } + else + { + for (U32 i = 4; i < 6; i++) + { + releaseShadowTarget(i); + } + } + + //HACK make screenbuffer allocations start failing after 30 seconds + if (gSavedSettings.getBOOL("SimulateFBOFailure")) + { + return false; + } + } + else + { + mDeferredLight.release(); + + releaseShadowTargets(); - //HACK make screenbuffer allocations start failing after 30 seconds - if (gSavedSettings.getBOOL("SimulateFBOFailure")) - { - return false; - } - } - else - { - mDeferredLight.release(); - - for (U32 i = 0; i < 6; i++) - { - mShadow[i].release(); - mShadowOcclusion[i].release(); - } mFXAABuffer.release(); mScreen.release(); mDeferredScreen.release(); //make sure to release any render targets that share a depth buffer with mDeferredScreen first @@ -1223,47 +1188,38 @@ void LLPipeline::releaseScreenBuffers() mDeferredDepth.release(); mDeferredLight.release(); mOcclusionDepth.release(); - - for (U32 i = 0; i < 6; i++) - { - mShadow[i].release(); - mShadowOcclusion[i].release(); - } + releaseShadowTargets(); } +void LLPipeline::releaseShadowTarget(U32 index) +{ + mShadow[index].release(); + mShadowOcclusion[index].release(); +} + +void LLPipeline::releaseShadowTargets() +{ + for (U32 i = 0; i < 6; i++) + { + releaseShadowTarget(i); + } +} + void LLPipeline::createGLBuffers() { stop_glerror(); assertInitialized(); updateRenderDeferred(); + if (LLPipeline::sWaterReflections) + { //water reflection texture + U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - bool materials_in_water = false; - -#if MATERIALS_IN_REFLECTIONS - materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); -#endif - - if (LLPipeline::sWaterReflections) - { //water reflection texture - U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - - // Set up SRGB targets if we're doing deferred-path reflection rendering - // - if (LLPipeline::sRenderDeferred && materials_in_water) - { - mWaterRef.allocate(res,res,GL_SRGB8_ALPHA8,TRUE,FALSE); - //always use FBO for mWaterDis so it can be used for avatar texture bakes - mWaterDis.allocate(res,res,GL_SRGB8_ALPHA8,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); - } - else - { - mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); - //always use FBO for mWaterDis so it can be used for avatar texture bakes - mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); - } - } + mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); + //always use FBO for mWaterDis so it can be used for avatar texture bakes + mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true); + } mHighlight.allocate(256,256,GL_RGBA, FALSE, FALSE); @@ -1436,13 +1392,13 @@ bool LLPipeline::canUseWindLightShaders() const { return (!LLPipeline::sDisableShaders && gWLSkyProgram.mProgramObject != 0 && - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1); + LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1); } bool LLPipeline::canUseWindLightShadersOnObjects() const { return (canUseWindLightShaders() - && LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0); + && LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0); } bool LLPipeline::canUseAntiAliasing() const @@ -1471,7 +1427,7 @@ void LLPipeline::enableShadows(const bool enable_shadows) S32 LLPipeline::getMaxLightingDetail() const { - /*if (mVertexShaderLevel[SHADER_OBJECT] >= LLDrawPoolSimple::SHADER_LEVEL_LOCAL_LIGHTS) + /*if (mShaderLevel[SHADER_OBJECT] >= LLDrawPoolSimple::SHADER_LEVEL_LOCAL_LIGHTS) { return 3; } @@ -2299,7 +2255,7 @@ void LLPipeline::checkReferences(LLDrawInfo* draw_info) void LLPipeline::checkReferences(LLSpatialGroup* group) { -#if 0 +#if CHECK_PIPELINE_REFERENCES if (sCull) { for (LLCullResult::sg_iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) @@ -2417,7 +2373,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl if (to_texture) { - if (LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderDeferred && can_use_occlusion) { mOcclusionDepth.bindTarget(); } @@ -2444,91 +2400,58 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLGLDisable test(GL_ALPHA_TEST); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLGLDepthTest depth(GL_TRUE, GL_FALSE); - //setup a clip plane in projection matrix for reflection renders (prevents flickering from occlusion culling) - LLViewerRegion* region = gAgent.getRegion(); - LLPlane plane; + bool bound_shader = false; + if (gPipeline.canUseVertexShaders() && LLGLSLShader::sCurBoundShader == 0) + { //if no shader is currently bound, use the occlusion shader instead of fixed function if we can + // (shadow render uses a special shader that clamps to clip planes) + bound_shader = true; + gOcclusionCubeProgram.bind(); + } + + if (sUseOcclusion > 1) + { + if (mCubeVB.isNull()) + { //cube VB will be used for issuing occlusion queries + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + } + mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + } + + camera.disableUserClipPlane(); - if (planep) - { - plane = *planep; - } - else - { - if (region) - { - LLVector3 pnorm; - F32 height = region->getWaterHeight(); - if (water_clip < 0) - { //camera is above water, clip plane points up - pnorm.setVec(0,0,1); - plane.setVec(pnorm, -height); - } - else if (water_clip > 0) - { //camera is below water, clip plane points down - pnorm = LLVector3(0,0,-1); - plane.setVec(pnorm, height); - } - } - } - - glh::matrix4f modelview = glh_get_last_modelview(); - glh::matrix4f proj = glh_get_last_projection(); - LLGLUserClipPlane clip(plane, modelview, proj, water_clip != 0 && LLPipeline::sReflectionRender); + bool use_far_clip = LLPipeline::sUseFarClip; - LLGLDepthTest depth(GL_TRUE, GL_FALSE); + LLPipeline::sUseFarClip = false; - bool bound_shader = false; - if (gPipeline.canUseVertexShaders() && LLGLSLShader::sCurBoundShader == 0) - { //if no shader is currently bound, use the occlusion shader instead of fixed function if we can - // (shadow render uses a special shader that clamps to clip planes) - bound_shader = true; - gOcclusionCubeProgram.bind(); - } - - if (sUseOcclusion > 1) - { - if (mCubeVB.isNull()) - { //cube VB will be used for issuing occlusion queries - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); - } - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - } - - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); - iter != LLWorld::getInstance()->getRegionList().end(); ++iter) - { - LLViewerRegion* region = *iter; - if (water_clip != 0) - { - LLPlane plane(LLVector3(0,0, (F32) -water_clip), (F32) water_clip*region->getWaterHeight()); - camera.setUserClipPlane(plane); - } - else - { - camera.disableUserClipPlane(); - } + for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); + iter != LLWorld::getInstance()->getRegionList().end(); ++iter) + { + LLViewerRegion* region = *iter; + + for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) + { + LLSpatialPartition* part = region->getSpatialPartition(i); + if (part) + { + if (hasRenderType(part->mDrawableType)) + { + part->cull(camera); + } + } + } - for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) - { - LLSpatialPartition* part = region->getSpatialPartition(i); - if (part) - { - if (hasRenderType(part->mDrawableType)) - { - part->cull(camera); - } - } - } + //scan the VO Cache tree + LLVOCachePartition* vo_part = region->getVOCachePartition(); + if(vo_part) + { + bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe/* && !gViewerWindow->getProgressView()->getVisible()*/; + vo_part->cull(camera, do_occlusion_cull); + } + } - //scan the VO Cache tree - LLVOCachePartition* vo_part = region->getVOCachePartition(); - if(vo_part) - { - bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe/* && !gViewerWindow->getProgressView()->getVisible()*/; - vo_part->cull(camera, do_occlusion_cull); - } - } + LLPipeline::sUseFarClip = use_far_clip; if (bound_shader) { @@ -2556,6 +2479,28 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl gSky.mVOGroundp->mDrawable->setVisible(camera); sCull->pushDrawable(gSky.mVOGroundp->mDrawable); } + + + if (hasRenderType(LLPipeline::RENDER_TYPE_WL_SKY) && + gPipeline.canUseWindLightShaders() && + gSky.mVOWLSkyp.notNull() && + gSky.mVOWLSkyp->mDrawable.notNull()) + { + gSky.mVOWLSkyp->mDrawable->setVisible(camera); + sCull->pushDrawable(gSky.mVOWLSkyp->mDrawable); + } + +// not currently enabled as it causes reflection/distortion map +// rendering to occur every frame instead of periodically for visible near water +#if PRECULL_WATER_OBJECTS + bool render_water = !sReflectionRender && (hasRenderType(LLPipeline::RENDER_TYPE_WATER) || hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER)); + + if (render_water) + { + LLWorld::getInstance()->precullWaterObjects(camera, sCull, render_water); + } +#endif + gGL.matrixMode(LLRender::MM_PROJECTION); @@ -2563,14 +2508,14 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - if (sUseOcclusion > 1) + if (sUseOcclusion > 1) { gGL.setColorMask(true, false); } if (to_texture) { - if (LLPipeline::sRenderDeferred) + if (LLPipeline::sRenderDeferred && can_use_occlusion) { mOcclusionDepth.flush(); } @@ -2656,7 +2601,7 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d { scratch_space->copyContents(source, 0, 0, source.getWidth(), source.getHeight(), - 0, 0, scratch_space->getWidth(), scratch_space->getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); + 0, 0, scratch_space->getWidth(), scratch_space->getHeight(), source.hasStencil() ? (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) : GL_COLOR_BUFFER_BIT, GL_NEAREST); } dest.bindTarget(); @@ -4138,6 +4083,12 @@ void LLPipeline::renderHighlights() glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); gGL.setColorMask(false, false); + + if (LLGLSLShader::sNoFixedFunction) + { + gHighlightProgram.bind(); + } + for (std::set<HighlightItem>::iterator iter = mHighlightSet.begin(); iter != mHighlightSet.end(); ++iter) { renderHighlight(iter->mItem->getVObj(), 1.f); @@ -4219,7 +4170,7 @@ void LLPipeline::renderHighlights() //gGL.setSceneBlendType(LLRender::BT_ALPHA); } - if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightProgram.bind(); gGL.diffuseColor4f(1,1,1,0.5f); @@ -4266,7 +4217,7 @@ void LLPipeline::renderHighlights() // have touch-handlers. mHighlightFaces.clear(); - if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0) + if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0) { gHighlightProgram.unbind(); } @@ -4275,7 +4226,7 @@ void LLPipeline::renderHighlights() if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::NORMAL_MAP)) { color.setVec(1.0f, 0.5f, 0.5f, 0.5f); - if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightNormalProgram.bind(); gGL.diffuseColor4f(1,1,1,0.5f); @@ -4296,7 +4247,7 @@ void LLPipeline::renderHighlights() facep->renderSelected(mFaceSelectImagep, color); } - if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightNormalProgram.unbind(); } @@ -4305,7 +4256,7 @@ void LLPipeline::renderHighlights() if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::SPECULAR_MAP)) { color.setVec(0.0f, 0.3f, 1.0f, 0.8f); - if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightSpecularProgram.bind(); gGL.diffuseColor4f(1,1,1,0.5f); @@ -4326,7 +4277,7 @@ void LLPipeline::renderHighlights() facep->renderSelected(mFaceSelectImagep, color); } - if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightSpecularProgram.unbind(); } @@ -4673,6 +4624,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) } gGLLastMatrix = NULL; + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(gGLModelView); gGL.setColorMask(true, false); @@ -4759,16 +4711,16 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) } gGLLastMatrix = NULL; + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(gGLModelView); if (occlude) { occlude = false; - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); LLGLSLShader::bindNoShader(); doOcclusion(camera); gGLLastMatrix = NULL; + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(gGLModelView); } } @@ -5983,6 +5935,12 @@ void LLPipeline::setupAvatarLights(bool for_edit) { assertInitialized(); + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); + + bool sun_up = environment.getIsSunUp(); + + if (for_edit) { LLColor4 diffuse(1.f, 1.f, 1.f, 0.f); @@ -5996,13 +5954,6 @@ void LLPipeline::setupAvatarLights(bool for_edit) LLLightState* light = gGL.getLight(1); - if (LLPipeline::sRenderDeferred) - { - /*diffuse.mV[0] = powf(diffuse.mV[0], 2.2f); - diffuse.mV[1] = powf(diffuse.mV[1], 2.2f); - diffuse.mV[2] = powf(diffuse.mV[2], 2.2f);*/ - } - mHWLightColors[1] = diffuse; light->setDiffuse(diffuse); @@ -6015,14 +5966,16 @@ void LLPipeline::setupAvatarLights(bool for_edit) light->setSpotExponent(0.f); light->setSpotCutoff(180.f); } - else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini) + else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini) { - LLVector3 opposite_pos = -1.f * mSunDir; - LLVector3 orthog_light_pos = mSunDir % LLVector3::z_axis; + LLVector3 light_dir = sun_up ? LLVector3(mSunDir) : LLVector3(mMoonDir); + LLVector3 opposite_pos = -light_dir; + LLVector3 orthog_light_pos = light_dir % LLVector3::z_axis; LLVector4 backlight_pos = LLVector4(lerp(opposite_pos, orthog_light_pos, 0.3f), 0.0f); backlight_pos.normalize(); - - LLColor4 light_diffuse = mSunDiffuse; + + LLColor4 light_diffuse = sun_up ? mSunDiffuse : mMoonDiffuse; + LLColor4 backlight_diffuse(1.f - light_diffuse.mV[VRED], 1.f - light_diffuse.mV[VGREEN], 1.f - light_diffuse.mV[VBLUE], 1.f); F32 max_component = 0.001f; for (S32 i = 0; i < 3; i++) @@ -6033,7 +5986,7 @@ void LLPipeline::setupAvatarLights(bool for_edit) } } F32 backlight_mag; - if (gSky.getSunDirection().mV[2] >= LLSky::NIGHTTIME_ELEVATION_COS) + if (LLEnvironment::instance().getIsSunUp()) { backlight_mag = BACKLIGHT_DAY_MAGNITUDE_OBJECT; } @@ -6043,13 +5996,6 @@ void LLPipeline::setupAvatarLights(bool for_edit) } backlight_diffuse *= backlight_mag / max_component; - if (LLPipeline::sRenderDeferred) - { - /*backlight_diffuse.mV[0] = powf(backlight_diffuse.mV[0], 2.2f); - backlight_diffuse.mV[1] = powf(backlight_diffuse.mV[1], 2.2f); - backlight_diffuse.mV[2] = powf(backlight_diffuse.mV[2], 2.2f);*/ - } - mHWLightColors[1] = backlight_diffuse; LLLightState* light = gGL.getLight(1); @@ -6241,51 +6187,62 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) void LLPipeline::setupHWLights(LLDrawPool* pool) { assertInitialized(); + + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); // Ambient if (!LLGLSLShader::sNoFixedFunction) { gGL.syncMatrices(); - LLColor4 ambient = gSky.getTotalAmbientColor(); + LLColor4 ambient = psky->getTotalAmbient(); gGL.setAmbientLightColor(ambient); } - // Light 0 = Sun or Moon (All objects) - { - if (gSky.getSunDirection().mV[2] >= LLSky::NIGHTTIME_ELEVATION_COS) - { - mSunDir.setVec(gSky.getSunDirection()); - mSunDiffuse.setVec(gSky.getSunDiffuseColor()); - } - else - { - mSunDir.setVec(gSky.getMoonDirection()); - mSunDiffuse.setVec(gSky.getMoonDiffuseColor()); - } + // Ambient + if (!LLGLSLShader::sNoFixedFunction) + { + gGL.syncMatrices(); + LLColor4 ambient = psky->getTotalAmbient(); + gGL.setAmbientLightColor(ambient); + } - F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]); - if (max_color > 1.f) - { - mSunDiffuse *= 1.f/max_color; - } - mSunDiffuse.clamp(); + bool sun_up = environment.getIsSunUp(); - LLVector4 light_pos(mSunDir, 0.0f); - LLColor4 light_diffuse = mSunDiffuse; + // Light 0 = Sun or Moon (All objects) + { + LLVector4 sun_dir(environment.getSunDirection(), 0.0f); + LLVector4 moon_dir(environment.getMoonDirection(), 0.0f); - if (LLPipeline::sRenderDeferred) - { - /*light_diffuse.mV[0] = powf(light_diffuse.mV[0], 2.2f); - light_diffuse.mV[1] = powf(light_diffuse.mV[1], 2.2f); - light_diffuse.mV[2] = powf(light_diffuse.mV[2], 2.2f);*/ - } + mSunDir.setVec(sun_dir); + mMoonDir.setVec(moon_dir); + mSunDiffuse.setVec(psky->getSunDiffuse()); + mMoonDiffuse.setVec(psky->getMoonDiffuse()); - mHWLightColors[0] = light_diffuse; + F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]); + if (max_color > 1.f) + { + mSunDiffuse *= 1.f/max_color; + } + mSunDiffuse.clamp(); - LLLightState* light = gGL.getLight(0); - light->setPosition(light_pos); - light->setDiffuse(light_diffuse); - light->setAmbient(LLColor4::black); + max_color = llmax(mMoonDiffuse.mV[0], mMoonDiffuse.mV[1], mMoonDiffuse.mV[2]); + if (max_color > 1.f) + { + mMoonDiffuse *= 1.f/max_color; + } + mMoonDiffuse.clamp(); + + LLVector4 light_dir = sun_up ? mSunDir : mMoonDir; + + mHWLightColors[0] = mSunDiffuse; + + LLLightState* light = gGL.getLight(0); + light->setPosition(light_dir); + + light->setDiffuse(mSunDiffuse); + light->setDiffuseB(mMoonDiffuse); + light->setAmbient(LLColor4::black); light->setSpecular(LLColor4::black); light->setConstantAttenuation(1.f); light->setLinearAttenuation(0.f); @@ -6379,7 +6336,9 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light_state->setSpotCutoff(90.f); light_state->setSpotExponent(2.f); - const LLColor4 specular(0.f, 0.f, 0.f, 0.f); + LLVector3 spotParams = light->getSpotLightParams(); + + const LLColor4 specular(0.f, 0.f, 0.f, spotParams[2]); light_state->setSpecular(specular); } else // omnidirectional (point) light @@ -6388,7 +6347,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light_state->setSpotCutoff(180.f); // we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight - const LLColor4 specular(0.f, 0.f, 0.f, 1.f); + const LLColor4 specular(0.f, 0.f, 1.f, 0.f); light_state->setSpecular(specular); } cur_light++; @@ -6433,6 +6392,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light->setPosition(light_pos_gl); light->setDiffuse(light_color); + light->setDiffuseB(light_color * 0.25f); light->setAmbient(LLColor4::black); light->setSpecular(LLColor4::black); light->setQuadraticAttenuation(0.f); @@ -6502,7 +6462,7 @@ void LLPipeline::enableLights(U32 mask) mLightMask = mask; stop_glerror(); - LLColor4 ambient = gSky.getTotalAmbientColor(); + LLColor4 ambient = LLEnvironment::instance().getCurrentSky()->getTotalAmbient(); gGL.setAmbientLightColor(ambient); } } @@ -8169,113 +8129,117 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) static LLTrace::BlockTimerStatHandle FTM_BIND_DEFERRED("Bind Deferred"); -void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 noise_map) +void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) { LL_RECORD_BLOCK_TIME(FTM_BIND_DEFERRED); - if (noise_map == 0xFFFFFFFF) - { - noise_map = mNoiseMap; - } - - shader.bind(); - S32 channel = 0; - channel = shader.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); - if (channel > -1) - { - mDeferredScreen.bindTexture(0,channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); - if (channel > -1) - { - mDeferredScreen.bindTexture(1, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - channel = shader.enableTexture(LLShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); - if (channel > -1) - { - mDeferredScreen.bindTexture(2, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, mDeferredDepth.getUsage()); - if (channel > -1) - { - gGL.getTexUnit(channel)->bind(&mDeferredDepth, TRUE); - stop_glerror(); - - //glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); - //glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); - - stop_glerror(); - - glh::matrix4f projection = glh_get_current_projection(); - glh::matrix4f inv_proj = projection.inverse(); - - shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); - shader.uniform4f(LLShaderMgr::VIEWPORT, (F32) gGLViewport[0], - (F32) gGLViewport[1], - (F32) gGLViewport[2], - (F32) gGLViewport[3]); - } - - channel = shader.enableTexture(LLShaderMgr::DEFERRED_NOISE); - if (channel > -1) - { - gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, noise_map); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); - if (channel > -1) - { - gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); - } - - stop_glerror(); - - channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); - if (channel > -1) - { - if (light_index > 0) - { - mScreen.bindTexture(0, channel); - } - else - { - mDeferredLight.bindTexture(0, channel); - } - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - channel = shader.enableTexture(LLShaderMgr::DEFERRED_BLOOM); - if (channel > -1) - { - mGlow[1].bindTexture(0, channel); - } - - stop_glerror(); - - for (U32 i = 0; i < 4; i++) - { - channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE); - stop_glerror(); - if (channel > -1) - { - stop_glerror(); - gGL.getTexUnit(channel)->bind(&mShadow[i], TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); - stop_glerror(); - } - } + LLRenderTarget* deferred_target = &mDeferredScreen; + LLRenderTarget* deferred_depth_target = &mDeferredDepth; + LLRenderTarget* deferred_light_target = &mDeferredLight; + + shader.bind(); + S32 channel = 0; + channel = shader.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage()); + if (channel > -1) + { + deferred_target->bindTexture(0,channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); + if (channel > -1) + { + deferred_target->bindTexture(1, channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); + if (channel > -1) + { + deferred_target->bindTexture(2, channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); + if (channel > -1) + { + gGL.getTexUnit(channel)->bind(deferred_depth_target, TRUE); + stop_glerror(); + } + + glh::matrix4f projection = get_current_projection(); + glh::matrix4f inv_proj = projection.inverse(); + + if (shader.getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX) != -1) + { + shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); + } + + if (shader.getUniformLocation(LLShaderMgr::VIEWPORT) != -1) + { + shader.uniform4f(LLShaderMgr::VIEWPORT, (F32) gGLViewport[0], + (F32) gGLViewport[1], + (F32) gGLViewport[2], + (F32) gGLViewport[3]); + } + + if (sReflectionRender && !shader.getUniformLocation(LLShaderMgr::MODELVIEW_MATRIX)) + { + shader.uniformMatrix4fv(LLShaderMgr::MODELVIEW_MATRIX, 1, FALSE, mReflectionModelView.m); + } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_NOISE); + if (channel > -1) + { + gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); + if (channel > -1) + { + gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); + } + + stop_glerror(); + + light_target = light_target ? light_target : deferred_light_target; + channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, light_target->getUsage()); + if (channel > -1) + { + light_target->bindTexture(0, channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + channel = shader.enableTexture(LLShaderMgr::DEFERRED_BLOOM); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel); + } + + stop_glerror(); + + for (U32 i = 0; i < 4; i++) + { + LLRenderTarget* shadow_target = getShadowTarget(i); + if (shadow_target) + { + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE); + stop_glerror(); + if (channel > -1) + { + stop_glerror(); + gGL.getTexUnit(channel)->bind(getShadowTarget(i), TRUE); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + stop_glerror(); + } + } + } for (U32 i = 4; i < 6; i++) { @@ -8284,14 +8248,18 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n if (channel > -1) { stop_glerror(); - gGL.getTexUnit(channel)->bind(&mShadow[i], TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); + LLRenderTarget* shadow_target = getShadowTarget(i); + if (shadow_target) + { + gGL.getTexUnit(channel)->bind(shadow_target, TRUE); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); - stop_glerror(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + stop_glerror(); + } } } @@ -8330,50 +8298,86 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n } } - shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); - shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); - shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); - shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); - - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_RADIUS, RenderSSAOScale); - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_MAX_RADIUS, RenderSSAOMaxScale); - - F32 ssao_factor = RenderSSAOFactor; - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR, ssao_factor); - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR_INV, 1.0/ssao_factor); - - LLVector3 ssao_effect = RenderSSAOEffect; - F32 matrix_diag = (ssao_effect[0] + 2.0*ssao_effect[1])/3.0; - F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1])/3.0; - // This matrix scales (proj of color onto <1/rt(3),1/rt(3),1/rt(3)>) by - // value factor, and scales remainder by saturation factor - F32 ssao_effect_mat[] = { matrix_diag, matrix_nondiag, matrix_nondiag, - matrix_nondiag, matrix_diag, matrix_nondiag, - matrix_nondiag, matrix_nondiag, matrix_diag}; - shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_SSAO_EFFECT_MAT, 1, GL_FALSE, ssao_effect_mat); - - //F32 shadow_offset_error = 1.f + RenderShadowOffsetError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); - F32 shadow_bias_error = RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2])/3000.f; - - shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); - shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear()*2.f); - shader.uniform1f (LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset); //*shadow_offset_error); - shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, RenderShadowBias+shadow_bias_error); - shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_OFFSET, RenderSpotShadowOffset); - shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_BIAS, RenderSpotShadowBias); - - shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); - shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mShadow[0].getWidth(), mShadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mShadow[4].getWidth(), mShadow[4].getHeight()); - shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); - shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - + if (gAtmosphere) + { + // bind precomputed textures necessary for calculating sun and sky luminance + channel = shader.enableTexture(LLShaderMgr::TRANSMITTANCE_TEX, LLTexUnit::TT_TEXTURE); + if (channel > -1) + { + shader.bindTexture(LLShaderMgr::TRANSMITTANCE_TEX, gAtmosphere->getTransmittance()); + } - if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) - { - glh::matrix4f norm_mat = glh_get_current_modelview().inverse().transpose(); - shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); - } + channel = shader.enableTexture(LLShaderMgr::SCATTER_TEX, LLTexUnit::TT_TEXTURE_3D); + if (channel > -1) + { + shader.bindTexture(LLShaderMgr::SCATTER_TEX, gAtmosphere->getScattering()); + } + + channel = shader.enableTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, LLTexUnit::TT_TEXTURE_3D); + if (channel > -1) + { + shader.bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getMieScattering()); + } + + channel = shader.enableTexture(LLShaderMgr::ILLUMINANCE_TEX, LLTexUnit::TT_TEXTURE); + if (channel > -1) + { + shader.bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance()); + } + } + + shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); + shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); + shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); + + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_RADIUS, RenderSSAOScale); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_MAX_RADIUS, RenderSSAOMaxScale); + + F32 ssao_factor = RenderSSAOFactor; + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR, ssao_factor); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR_INV, 1.0/ssao_factor); + + LLVector3 ssao_effect = RenderSSAOEffect; + F32 matrix_diag = (ssao_effect[0] + 2.0*ssao_effect[1])/3.0; + F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1])/3.0; + // This matrix scales (proj of color onto <1/rt(3),1/rt(3),1/rt(3)>) by + // value factor, and scales remainder by saturation factor + F32 ssao_effect_mat[] = { matrix_diag, matrix_nondiag, matrix_nondiag, + matrix_nondiag, matrix_diag, matrix_nondiag, + matrix_nondiag, matrix_nondiag, matrix_diag}; + shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_SSAO_EFFECT_MAT, 1, GL_FALSE, ssao_effect_mat); + + //F32 shadow_offset_error = 1.f + RenderShadowOffsetError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); + F32 shadow_bias_error = RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2])/3000.f; + F32 shadow_bias = RenderShadowBias + shadow_bias_error; + + shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, deferred_target->getWidth(), deferred_target->getHeight()); + shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear()*2.f); + shader.uniform1f (LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset); //*shadow_offset_error); + shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, shadow_bias); + shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_OFFSET, RenderSpotShadowOffset); + shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_BIAS, RenderSpotShadowBias); + + shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); + shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); + shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mShadow[0].getWidth(), mShadow[0].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mShadow[4].getWidth(), mShadow[4].getHeight()); + shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); + shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); + + shader.uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); + shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + + LLEnvironment& environment = LLEnvironment::instance(); + shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + shader.uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, environment.getCurrentSky()->getSunMoonGlowFactor()); + + if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) + { + glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); + shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); + } } LLColor3 pow3f(LLColor3 v, F32 f) @@ -8404,1149 +8408,629 @@ static LLTrace::BlockTimerStatHandle FTM_PROJECTORS("Projectors"); static LLTrace::BlockTimerStatHandle FTM_POST("Post"); -void LLPipeline::renderDeferredLighting() -{ - if (!sCull) - { - return; - } - - { - LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); - - LLViewerCamera* camera = LLViewerCamera::getInstance(); - { - LLGLDepthTest depth(GL_TRUE); - mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), - 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } - - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); - - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); - } - - //ati doesn't seem to love actually using the stencil buffer on FBO's - LLGLDisable stencil(GL_STENCIL_TEST); - //glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); - //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - gGL.setColorMask(true, true); - - //draw a cube around every light - LLVertexBuffer::unbind(); - - LLGLEnable cull(GL_CULL_FACE); - LLGLEnable blend(GL_BLEND); - - glh::matrix4f mat = glh_copy_matrix(gGLModelView); - - LLStrider<LLVector3> vert; - mDeferredVB->getVertexStrider(vert); - - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - - { - setupHWLights(NULL); //to set mSunDir; - LLVector4 dir(mSunDir, 0.f); - glh::vec4f tc(dir.mV); - mat.mult_matrix_vec(tc); - mTransformedSunDir.set(tc.v); - } - - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - if (RenderDeferredSSAO || RenderShadowDetail > 0) - { - mDeferredLight.bindTarget(); - { //paint shadow/SSAO light map (direct lighting lightmap) - LL_RECORD_BLOCK_TIME(FTM_SUN_SHADOW); - bindDeferredShader(gDeferredSunProgram, 0); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - glClearColor(1,1,1,1); - mDeferredLight.clear(GL_COLOR_BUFFER_BIT); - glClearColor(0,0,0,0); - - glh::matrix4f inv_trans = glh_get_current_modelview().inverse().transpose(); - - const U32 slice = 32; - F32 offset[slice*3]; - for (U32 i = 0; i < 4; i++) - { - for (U32 j = 0; j < 8; j++) - { - glh::vec3f v; - v.set_value(sinf(6.284f/8*j), cosf(6.284f/8*j), -(F32) i); - v.normalize(); - inv_trans.mult_matrix_vec(v); - v.normalize(); - offset[(i*8+j)*3+0] = v.v[0]; - offset[(i*8+j)*3+1] = v.v[2]; - offset[(i*8+j)*3+2] = v.v[1]; - } - } - - gDeferredSunProgram.uniform3fv(sOffset, slice, offset); - gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight()); - - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } - - unbindDeferredShader(gDeferredSunProgram); - } - mDeferredLight.flush(); - } - - if (RenderDeferredSSAO) - { //soften direct lighting lightmap - LL_RECORD_BLOCK_TIME(FTM_SOFTEN_SHADOW); - //blur lightmap - mScreen.bindTarget(); - glClearColor(1,1,1,1); - mScreen.clear(GL_COLOR_BUFFER_BIT); - glClearColor(0,0,0,0); - - bindDeferredShader(gDeferredBlurLightProgram); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - LLVector3 go = RenderShadowGaussian; - const U32 kern_length = 4; - F32 blur_size = RenderShadowBlurSize; - F32 dist_factor = RenderShadowBlurDistFactor; - - // sample symmetrically with the middle sample falling exactly on 0.0 - F32 x = 0.f; - - LLVector3 gauss[32]; // xweight, yweight, offset - - for (U32 i = 0; i < kern_length; i++) - { - gauss[i].mV[0] = llgaussian(x, go.mV[0]); - gauss[i].mV[1] = llgaussian(x, go.mV[1]); - gauss[i].mV[2] = x; - x += 1.f; - } - - gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); - gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); - gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); - gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length/2.f - 0.5f)); - - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } - - mScreen.flush(); - unbindDeferredShader(gDeferredBlurLightProgram); - - bindDeferredShader(gDeferredBlurLightProgram, 1); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - mDeferredLight.bindTarget(); - - gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); - - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } - mDeferredLight.flush(); - unbindDeferredShader(gDeferredBlurLightProgram); - } - - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - - mScreen.bindTarget(); - // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky - glClearColor(0,0,0,0); - mScreen.clear(GL_COLOR_BUFFER_BIT); - - if (RenderDeferredAtmospheric) - { //apply sunlight contribution - LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS); - bindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); - { - LLGLDepthTest depth(GL_FALSE); - LLGLDisable blend(GL_BLEND); - LLGLDisable test(GL_ALPHA_TEST); - - //full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - } - - unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); - } - - { //render non-deferred geometry (fullbright, alpha, etc) - LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - gPipeline.pushRenderTypeMask(); - - gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - - - renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); - gPipeline.popRenderTypeMask(); - } - - bool render_local = RenderLocalLights; - - if (render_local) - { - gGL.setSceneBlendType(LLRender::BT_ADD); - std::list<LLVector4> fullscreen_lights; - LLDrawable::drawable_list_t spot_lights; - LLDrawable::drawable_list_t fullscreen_spot_lights; - - for (U32 i = 0; i < 2; i++) - { - mTargetShadowSpotLight[i] = NULL; - } - - std::list<LLVector4> light_colors; - - LLVertexBuffer::unbind(); - - { - bindDeferredShader(gDeferredLightProgram); - - if (mCubeVB.isNull()) - { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); - } - - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) - { - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); - if (!volume) - { - continue; - } - - if (volume->isAttachment()) - { - if (!sRenderAttachedLights) - { - continue; - } - } - - const LLViewerObject *vobj = drawablep->getVObj(); - if(vobj && vobj->getAvatar() - && (vobj->getAvatar()->isTooComplex() || vobj->getAvatar()->isInMuteList())) - { - continue; - } - - LLVector4a center; - center.load3(drawablep->getPositionAgent().mV); - const F32* c = center.getF32ptr(); - F32 s = volume->getLightRadius()*1.5f; - - LLColor3 col = volume->getLightColor(); - - if (col.magVecSquared() < 0.001f) - { - continue; - } - - if (s <= 0.001f) - { - continue; - } - - LLVector4a sa; - sa.splat(s); - if (camera->AABBInFrustumNoFarClip(center, sa) == 0) - { - continue; - } - - sVisibleLightCount++; - - if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || - camera->getOrigin().mV[0] < c[0] - s - 0.2f || - camera->getOrigin().mV[1] > c[1] + s + 0.2f || - camera->getOrigin().mV[1] < c[1] - s - 0.2f || - camera->getOrigin().mV[2] > c[2] + s + 0.2f || - camera->getOrigin().mV[2] < c[2] - s - 0.2f) - { //draw box if camera is outside box - if (render_local) - { - if (volume->isLightSpotlight()) - { - drawablep->getVOVolume()->updateSpotLightPriority(); - spot_lights.push_back(drawablep); - continue; - } - - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - LL_RECORD_BLOCK_TIME(FTM_LOCAL_LIGHTS); - gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - gGL.syncMatrices(); - - mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); - stop_glerror(); - } - } - else - { - if (volume->isLightSpotlight()) - { - drawablep->getVOVolume()->updateSpotLightPriority(); - fullscreen_spot_lights.push_back(drawablep); - continue; - } - - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); - - fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); - light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); - } - } - unbindDeferredShader(gDeferredLightProgram); - } - - if (!spot_lights.empty()) - { - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - bindDeferredShader(gDeferredSpotLightProgram); - - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); - - for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) - { - LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); - - LLVector4a center; - center.load3(drawablep->getPositionAgent().mV); - const F32* c = center.getF32ptr(); - F32 s = volume->getLightRadius()*1.5f; - - sVisibleLightCount++; - - setupSpotLight(gDeferredSpotLightProgram, drawablep); - - LLColor3 col = volume->getLightColor(); - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - gGL.syncMatrices(); - - mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); - } - gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); - unbindDeferredShader(gDeferredSpotLightProgram); - } - - //reset mDeferredVB to fullscreen triangle - mDeferredVB->getVertexStrider(vert); - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - - { - LLGLDepthTest depth(GL_FALSE); - - //full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - U32 count = 0; - - const U32 max_count = LL_DEFERRED_MULTI_LIGHT_COUNT; - LLVector4 light[max_count]; - LLVector4 col[max_count]; - - F32 far_z = 0.f; - - while (!fullscreen_lights.empty()) - { - LL_RECORD_BLOCK_TIME(FTM_FULLSCREEN_LIGHTS); - light[count] = fullscreen_lights.front(); - fullscreen_lights.pop_front(); - col[count] = light_colors.front(); - light_colors.pop_front(); - - /*col[count].mV[0] = powf(col[count].mV[0], 2.2f); - col[count].mV[1] = powf(col[count].mV[1], 2.2f); - col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ - - far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); - //col[count] = pow4fsrgb(col[count], 2.2f); - count++; - if (count == max_count || fullscreen_lights.empty()) - { - U32 idx = count-1; - bindDeferredShader(gDeferredMultiLightProgram[idx]); - gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); - gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); - far_z = 0.f; - count = 0; - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - unbindDeferredShader(gDeferredMultiLightProgram[idx]); - } - } - - bindDeferredShader(gDeferredMultiSpotLightProgram); - - gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) - { - LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); - - LLVector3 center = drawablep->getPositionAgent(); - F32* c = center.mV; - F32 s = volume->getLightRadius()*1.5f; - - sVisibleLightCount++; - - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); - - setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); - - LLColor3 col = volume->getLightColor(); - - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); - gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - - gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); - unbindDeferredShader(gDeferredMultiSpotLightProgram); - - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - } - } - - gGL.setColorMask(true, true); - } - - mScreen.flush(); - - //gamma correct lighting - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); - - { - LLGLDepthTest depth(GL_FALSE, GL_FALSE); - - LLVector2 tc1(0,0); - LLVector2 tc2((F32) mScreen.getWidth()*2, - (F32) mScreen.getHeight()*2); - - mScreen.bindTarget(); - // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); - //mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - S32 channel = 0; - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); - if (channel > -1) - { - mScreen.bindTexture(0,channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight()); - - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); - - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1,-1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1,3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3,-1); - - gGL.end(); - - gGL.getTexUnit(channel)->unbind(mScreen.getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); - mScreen.flush(); - } - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - mScreen.bindTarget(); - - { //render non-deferred geometry (alpha, fullbright, glow) - LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); - - pushRenderTypeMask(); - andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, - LLPipeline::RENDER_TYPE_FULLBRIGHT, - LLPipeline::RENDER_TYPE_VOLUME, - LLPipeline::RENDER_TYPE_GLOW, - LLPipeline::RENDER_TYPE_BUMP, - LLPipeline::RENDER_TYPE_PASS_SIMPLE, - LLPipeline::RENDER_TYPE_PASS_ALPHA, - LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_BUMP, - LLPipeline::RENDER_TYPE_PASS_POST_BUMP, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, - LLPipeline::RENDER_TYPE_PASS_GLOW, - LLPipeline::RENDER_TYPE_PASS_GRASS, - LLPipeline::RENDER_TYPE_PASS_SHINY, - LLPipeline::RENDER_TYPE_PASS_INVISIBLE, - LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, - LLPipeline::RENDER_TYPE_AVATAR, - LLPipeline::RENDER_TYPE_ALPHA_MASK, - LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, - END_RENDER_TYPES); - - renderGeomPostDeferred(*LLViewerCamera::getInstance()); - popRenderTypeMask(); - } - - { - //render highlights, etc. - renderHighlights(); - mHighlightFaces.clear(); - - renderDebug(); - - LLVertexBuffer::unbind(); - - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) - { - // Render debugging beacons. - gObjectList.renderObjectBeacons(); - gObjectList.resetObjectBeacons(); - } - } - - mScreen.flush(); - -} - -void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) +void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) { - if (!sCull) - { - return; - } - - { - LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); - - LLViewerCamera* camera = LLViewerCamera::getInstance(); - - { - LLGLDepthTest depth(GL_TRUE); - mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), - 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); - } - - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); - - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) - { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); - } - - //ati doesn't seem to love actually using the stencil buffer on FBO's - LLGLDisable stencil(GL_STENCIL_TEST); - //glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); - //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - gGL.setColorMask(true, true); - - //draw a cube around every light - LLVertexBuffer::unbind(); - - LLGLEnable cull(GL_CULL_FACE); - LLGLEnable blend(GL_BLEND); - - glh::matrix4f mat = glh_copy_matrix(gGLModelView); - - LLStrider<LLVector3> vert; - mDeferredVB->getVertexStrider(vert); - - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); - - { - setupHWLights(NULL); //to set mSunDir; - LLVector4 dir(mSunDir, 0.f); - glh::vec4f tc(dir.mV); - mat.mult_matrix_vec(tc); - mTransformedSunDir.set(tc.v); - } - - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - if (RenderDeferredSSAO || RenderShadowDetail > 0) - { - mDeferredLight.bindTarget(); - { //paint shadow/SSAO light map (direct lighting lightmap) - LL_RECORD_BLOCK_TIME(FTM_SUN_SHADOW); - bindDeferredShader(gDeferredSunProgram); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - glClearColor(1,1,1,1); - mDeferredLight.clear(GL_COLOR_BUFFER_BIT); - glClearColor(0,0,0,0); - - glh::matrix4f inv_trans = glh_get_current_modelview().inverse().transpose(); - - const U32 slice = 32; - F32 offset[slice*3]; - for (U32 i = 0; i < 4; i++) - { - for (U32 j = 0; j < 8; j++) - { - glh::vec3f v; - v.set_value(sinf(6.284f/8*j), cosf(6.284f/8*j), -(F32) i); - v.normalize(); - inv_trans.mult_matrix_vec(v); - v.normalize(); - offset[(i*8+j)*3+0] = v.v[0]; - offset[(i*8+j)*3+1] = v.v[2]; - offset[(i*8+j)*3+2] = v.v[1]; - } - } - - gDeferredSunProgram.uniform3fv(LLShaderMgr::DEFERRED_SHADOW_OFFSET, slice, offset); - gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight()); - - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } - - unbindDeferredShader(gDeferredSunProgram); - } - mDeferredLight.flush(); - } - - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - stop_glerror(); - gGL.popMatrix(); - stop_glerror(); - - target->bindTarget(); - - //clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky - glClearColor(0,0,0,0); - target->clear(GL_COLOR_BUFFER_BIT); - - if (RenderDeferredAtmospheric) - { //apply sunlight contribution - LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS); - bindDeferredShader(gDeferredSoftenProgram); - { - LLGLDepthTest depth(GL_FALSE); - LLGLDisable blend(GL_BLEND); - LLGLDisable test(GL_ALPHA_TEST); - - //full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - } - - unbindDeferredShader(gDeferredSoftenProgram); - } - - { //render non-deferred geometry (fullbright, alpha, etc) - LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - gPipeline.pushRenderTypeMask(); - - gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - - - renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); - gPipeline.popRenderTypeMask(); - } - - bool render_local = RenderLocalLights; - - if (render_local) - { - gGL.setSceneBlendType(LLRender::BT_ADD); - std::list<LLVector4> fullscreen_lights; - LLDrawable::drawable_list_t spot_lights; - LLDrawable::drawable_list_t fullscreen_spot_lights; - - for (U32 i = 0; i < 2; i++) - { - mTargetShadowSpotLight[i] = NULL; - } - - std::list<LLVector4> light_colors; + if (!sCull) + { + return; + } - LLVertexBuffer::unbind(); + LLRenderTarget* deferred_target = &mDeferredScreen; + LLRenderTarget* deferred_depth_target = &mDeferredDepth; + LLRenderTarget* deferred_light_target = &mDeferredLight; - { - bindDeferredShader(gDeferredLightProgram); - - if (mCubeVB.isNull()) - { - mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); - } - - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) - { - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); - if (!volume) - { - continue; - } - - if (volume->isAttachment()) - { - if (!sRenderAttachedLights) - { - continue; - } - } - - - LLVector4a center; - center.load3(drawablep->getPositionAgent().mV); - const F32* c = center.getF32ptr(); - F32 s = volume->getLightRadius()*1.5f; - - LLColor3 col = volume->getLightColor(); - - if (col.magVecSquared() < 0.001f) - { - continue; - } - - if (s <= 0.001f) - { - continue; - } - - LLVector4a sa; - sa.splat(s); - if (camera->AABBInFrustumNoFarClip(center, sa) == 0) - { - continue; - } + { + LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); + LLViewerCamera* camera = LLViewerCamera::getInstance(); + { + LLGLDepthTest depth(GL_TRUE); + deferred_depth_target->copyContents(*deferred_target, 0, 0, deferred_target->getWidth(), deferred_target->getHeight(), + 0, 0, deferred_depth_target->getWidth(), deferred_depth_target->getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } - sVisibleLightCount++; - - if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || - camera->getOrigin().mV[0] < c[0] - s - 0.2f || - camera->getOrigin().mV[1] > c[1] + s + 0.2f || - camera->getOrigin().mV[1] < c[1] - s - 0.2f || - camera->getOrigin().mV[2] > c[2] + s + 0.2f || - camera->getOrigin().mV[2] < c[2] - s - 0.2f) - { //draw box if camera is outside box - if (render_local) - { - if (volume->isLightSpotlight()) - { - drawablep->getVOVolume()->updateSpotLightPriority(); - spot_lights.push_back(drawablep); - continue; - } - - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - LL_RECORD_BLOCK_TIME(FTM_LOCAL_LIGHTS); - gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - gGL.syncMatrices(); - - mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); - stop_glerror(); - } - } - else - { - if (volume->isLightSpotlight()) - { - drawablep->getVOVolume()->updateSpotLightPriority(); - fullscreen_spot_lights.push_back(drawablep); - continue; - } + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); - - fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); - light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); - } - } - unbindDeferredShader(gDeferredLightProgram); - } + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) + { + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); + } - if (!spot_lights.empty()) - { - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - bindDeferredShader(gDeferredSpotLightProgram); + //ati doesn't seem to love actually using the stencil buffer on FBO's + LLGLDisable stencil(GL_STENCIL_TEST); + //glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); + //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + gGL.setColorMask(true, true); + + //draw a cube around every light + LLVertexBuffer::unbind(); - gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + LLGLEnable cull(GL_CULL_FACE); + LLGLEnable blend(GL_BLEND); - for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) - { - LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); - LLDrawable* drawablep = *iter; + glh::matrix4f mat = copy_matrix(gGLModelView); - LLVOVolume* volume = drawablep->getVOVolume(); + LLStrider<LLVector3> vert; + mDeferredVB->getVertexStrider(vert); + + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); - LLVector4a center; - center.load3(drawablep->getPositionAgent().mV); - const F32* c = center.getF32ptr(); - F32 s = volume->getLightRadius()*1.5f; + setupHWLights(NULL); //to set mSun/MoonDir; - sVisibleLightCount++; + glh::vec4f tc(mSunDir.mV); + mat.mult_matrix_vec(tc); + mTransformedSunDir.set(tc.v); - setupSpotLight(gDeferredSpotLightProgram, drawablep); - - LLColor3 col = volume->getLightColor(); - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); - gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - gGL.syncMatrices(); - - mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); - } - gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); - unbindDeferredShader(gDeferredSpotLightProgram); - } + glh::vec4f tc_moon(mMoonDir.mV); + mat.mult_matrix_vec(tc_moon); + mTransformedMoonDir.set(tc_moon.v); - //reset mDeferredVB to fullscreen triangle - mDeferredVB->getVertexStrider(vert); - vert[0].set(-1,1,0); - vert[1].set(-1,-3,0); - vert[2].set(3,1,0); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); - { - LLGLDepthTest depth(GL_FALSE); + if (RenderDeferredSSAO || RenderShadowDetail > 0) + { + deferred_light_target->bindTarget(); + { //paint shadow/SSAO light map (direct lighting lightmap) + LL_RECORD_BLOCK_TIME(FTM_SUN_SHADOW); + bindDeferredShader(gDeferredSunProgram, deferred_light_target); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + glClearColor(1,1,1,1); + deferred_light_target->clear(GL_COLOR_BUFFER_BIT); + glClearColor(0,0,0,0); + + glh::matrix4f inv_trans = get_current_modelview().inverse().transpose(); + + const U32 slice = 32; + F32 offset[slice*3]; + for (U32 i = 0; i < 4; i++) + { + for (U32 j = 0; j < 8; j++) + { + glh::vec3f v; + v.set_value(sinf(6.284f/8*j), cosf(6.284f/8*j), -(F32) i); + v.normalize(); + inv_trans.mult_matrix_vec(v); + v.normalize(); + offset[(i*8+j)*3+0] = v.v[0]; + offset[(i*8+j)*3+1] = v.v[2]; + offset[(i*8+j)*3+2] = v.v[1]; + } + } + + gDeferredSunProgram.uniform3fv(sOffset, slice, offset); + gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, deferred_light_target->getWidth(), deferred_light_target->getHeight()); + + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + + unbindDeferredShader(gDeferredSunProgram); + } + deferred_light_target->flush(); + } + + if (RenderDeferredSSAO) + { //soften direct lighting lightmap + LL_RECORD_BLOCK_TIME(FTM_SOFTEN_SHADOW); + //blur lightmap + screen_target->bindTarget(); + glClearColor(1,1,1,1); + screen_target->clear(GL_COLOR_BUFFER_BIT); + glClearColor(0,0,0,0); + + bindDeferredShader(gDeferredBlurLightProgram); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + LLVector3 go = RenderShadowGaussian; + const U32 kern_length = 4; + F32 blur_size = RenderShadowBlurSize; + F32 dist_factor = RenderShadowBlurDistFactor; + + // sample symmetrically with the middle sample falling exactly on 0.0 + F32 x = 0.f; + + LLVector3 gauss[32]; // xweight, yweight, offset + + for (U32 i = 0; i < kern_length; i++) + { + gauss[i].mV[0] = llgaussian(x, go.mV[0]); + gauss[i].mV[1] = llgaussian(x, go.mV[1]); + gauss[i].mV[2] = x; + x += 1.f; + } - //full screen blit - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); + gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); + gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); + gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); + gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length/2.f - 0.5f)); + + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + + screen_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); - U32 count = 0; + bindDeferredShader(gDeferredBlurLightProgram, screen_target); - const U32 max_count = LL_DEFERRED_MULTI_LIGHT_COUNT; - LLVector4 light[max_count]; - LLVector4 col[max_count]; + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + deferred_light_target->bindTarget(); - F32 far_z = 0.f; + gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); - while (!fullscreen_lights.empty()) - { - LL_RECORD_BLOCK_TIME(FTM_FULLSCREEN_LIGHTS); - light[count] = fullscreen_lights.front(); - fullscreen_lights.pop_front(); - col[count] = light_colors.front(); - light_colors.pop_front(); - - /*col[count].mV[0] = powf(col[count].mV[0], 2.2f); - col[count].mV[1] = powf(col[count].mV[1], 2.2f); - col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ - - far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); - //col[count] = pow4fsrgb(col[count], 2.2f); - count++; - if (count == max_count || fullscreen_lights.empty()) - { - U32 idx = count-1; - bindDeferredShader(gDeferredMultiLightProgram[idx]); - gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); - gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); - far_z = 0.f; - count = 0; - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } - } - - unbindDeferredShader(gDeferredMultiLightProgram[0]); + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + deferred_light_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); + } - bindDeferredShader(gDeferredMultiSpotLightProgram); + stop_glerror(); + gGL.popMatrix(); + stop_glerror(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + stop_glerror(); + gGL.popMatrix(); + stop_glerror(); + + screen_target->bindTarget(); + // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky + glClearColor(0,0,0,0); + screen_target->clear(GL_COLOR_BUFFER_BIT); + + if (RenderDeferredAtmospheric) + { //apply sunlight contribution + LLGLSLShader& soften_shader = LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram; - gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS); + bindDeferredShader(soften_shader); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + LLEnvironment& environment = LLEnvironment::instance(); + soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) - { - LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); - LLDrawable* drawablep = *iter; - - LLVOVolume* volume = drawablep->getVOVolume(); + { + LLGLDepthTest depth(GL_FALSE); + LLGLDisable blend(GL_BLEND); + LLGLDisable test(GL_ALPHA_TEST); + + //full screen blit + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + } - LLVector3 center = drawablep->getPositionAgent(); - F32* c = center.mV; - F32 s = volume->getLightRadius()*1.5f; + unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); + } - sVisibleLightCount++; + { //render non-deferred geometry (fullbright, alpha, etc) + LLGLDisable blend(GL_BLEND); + LLGLDisable stencil(GL_STENCIL_TEST); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + gPipeline.pushRenderTypeMask(); + + gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::END_RENDER_TYPES); + + + renderGeomPostDeferred(*LLViewerCamera::getInstance(), false); + gPipeline.popRenderTypeMask(); + } - glh::vec3f tc(c); - mat.mult_matrix_vec(tc); - - setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); + bool render_local = RenderLocalLights; + + if (render_local) + { + gGL.setSceneBlendType(LLRender::BT_ADD); + std::list<LLVector4> fullscreen_lights; + LLDrawable::drawable_list_t spot_lights; + LLDrawable::drawable_list_t fullscreen_spot_lights; - LLColor3 col = volume->getLightColor(); - - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); - gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); - gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - } + for (U32 i = 0; i < 2; i++) + { + mTargetShadowSpotLight[i] = NULL; + } - gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); - unbindDeferredShader(gDeferredMultiSpotLightProgram); + std::list<LLVector4> light_colors; - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - } - } + LLVertexBuffer::unbind(); - gGL.setColorMask(true, true); - } + { + bindDeferredShader(gDeferredLightProgram); + + if (mCubeVB.isNull()) + { + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB); + } + + mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter) + { + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + if (!volume) + { + continue; + } + + if (volume->isAttachment()) + { + if (!sRenderAttachedLights) + { + continue; + } + } + + const LLViewerObject *vobj = drawablep->getVObj(); + if(vobj && vobj->getAvatar() && vobj->getAvatar()->isInMuteList()) + { + continue; + } + + LLVector4a center; + center.load3(drawablep->getPositionAgent().mV); + const F32* c = center.getF32ptr(); + F32 s = volume->getLightRadius()*1.5f; + + LLColor3 col = volume->getLightColor(); + + if (col.magVecSquared() < 0.001f) + { + continue; + } + + if (s <= 0.001f) + { + continue; + } + + LLVector4a sa; + sa.splat(s); + if (camera->AABBInFrustumNoFarClip(center, sa) == 0) + { + continue; + } + + sVisibleLightCount++; + + if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || + camera->getOrigin().mV[0] < c[0] - s - 0.2f || + camera->getOrigin().mV[1] > c[1] + s + 0.2f || + camera->getOrigin().mV[1] < c[1] - s - 0.2f || + camera->getOrigin().mV[2] > c[2] + s + 0.2f || + camera->getOrigin().mV[2] < c[2] - s - 0.2f) + { //draw box if camera is outside box + if (render_local) + { + if (volume->isLightSpotlight()) + { + drawablep->getVOVolume()->updateSpotLightPriority(); + spot_lights.push_back(drawablep); + continue; + } + + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + LL_RECORD_BLOCK_TIME(FTM_LOCAL_LIGHTS); + gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + gGL.syncMatrices(); + + mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); + stop_glerror(); + } + } + else + { + if (volume->isLightSpotlight()) + { + drawablep->getVOVolume()->updateSpotLightPriority(); + fullscreen_spot_lights.push_back(drawablep); + continue; + } + + glh::vec3f tc(c); + mat.mult_matrix_vec(tc); + + fullscreen_lights.push_back(LLVector4(tc.v[0], tc.v[1], tc.v[2], s)); + light_colors.push_back(LLVector4(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f)); + } + } + unbindDeferredShader(gDeferredLightProgram); + } - /*target->flush(); + if (!spot_lights.empty()) + { + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + bindDeferredShader(gDeferredSpotLightProgram); + + mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + + for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) + { + LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + + LLVector4a center; + center.load3(drawablep->getPositionAgent().mV); + const F32* c = center.getF32ptr(); + F32 s = volume->getLightRadius()*1.5f; + + sVisibleLightCount++; + + setupSpotLight(gDeferredSpotLightProgram, drawablep); + + LLColor3 col = volume->getLightColor(); + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + gGL.syncMatrices(); + + mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); + } + gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); + unbindDeferredShader(gDeferredSpotLightProgram); + } - //gamma correct lighting - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); + //reset mDeferredVB to fullscreen triangle + mDeferredVB->getVertexStrider(vert); + vert[0].set(-1,1,0); + vert[1].set(-1,-3,0); + vert[2].set(3,1,0); - { - LLGLDepthTest depth(GL_FALSE, GL_FALSE); + { + LLGLDepthTest depth(GL_FALSE); + + //full screen blit + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + U32 count = 0; + + const U32 max_count = LL_DEFERRED_MULTI_LIGHT_COUNT; + LLVector4 light[max_count]; + LLVector4 col[max_count]; + + F32 far_z = 0.f; + + while (!fullscreen_lights.empty()) + { + LL_RECORD_BLOCK_TIME(FTM_FULLSCREEN_LIGHTS); + light[count] = fullscreen_lights.front(); + fullscreen_lights.pop_front(); + col[count] = light_colors.front(); + light_colors.pop_front(); + + /*col[count].mV[0] = powf(col[count].mV[0], 2.2f); + col[count].mV[1] = powf(col[count].mV[1], 2.2f); + col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ + + far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); + //col[count] = pow4fsrgb(col[count], 2.2f); + count++; + if (count == max_count || fullscreen_lights.empty()) + { + U32 idx = count-1; + bindDeferredShader(gDeferredMultiLightProgram[idx]); + gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); + gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); + far_z = 0.f; + count = 0; + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + unbindDeferredShader(gDeferredMultiLightProgram[idx]); + } + } + + bindDeferredShader(gDeferredMultiSpotLightProgram); + + gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + + for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) + { + LL_RECORD_BLOCK_TIME(FTM_PROJECTORS); + LLDrawable* drawablep = *iter; + + LLVOVolume* volume = drawablep->getVOVolume(); + + LLVector3 center = drawablep->getPositionAgent(); + F32* c = center.mV; + F32 s = volume->getLightRadius()*1.5f; + + sVisibleLightCount++; + + glh::vec3f tc(c); + mat.mult_matrix_vec(tc); + + setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); + + LLColor3 col = volume->getLightColor(); + + /*col.mV[0] = powf(col.mV[0], 2.2f); + col.mV[1] = powf(col.mV[1], 2.2f); + col.mV[2] = powf(col.mV[2], 2.2f);*/ + + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + + gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); + unbindDeferredShader(gDeferredMultiSpotLightProgram); + + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + } + } - LLVector2 tc1(0,0); - LLVector2 tc2((F32) target->getWidth()*2, - (F32) target->getHeight()*2); - - target->bindTarget(); - // Apply gamma correction to the frame here. - gDeferredPostGammaCorrectProgram.bind(); - //mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - S32 channel = 0; - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, target->getUsage()); - if (channel > -1) - { - target->bindTexture(0,channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - } - - gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, target->getWidth(), target->getHeight()); - - F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); + gGL.setColorMask(true, true); + } + + screen_target->flush(); + + //gamma correct lighting + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + { + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + LLVector2 tc1(0,0); + LLVector2 tc2((F32) screen_target->getWidth()*2, + (F32) screen_target->getHeight()*2); + + screen_target->bindTarget(); + // Apply gamma correction to the frame here. + gDeferredPostGammaCorrectProgram.bind(); + //mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + S32 channel = 0; + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage()); + if (channel > -1) + { + screen_target->bindTexture(0,channel); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + } + + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screen_target->getWidth(), screen_target->getHeight()); + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); - - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); - gGL.vertex2f(-1,-1); - - gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); - gGL.vertex2f(-1,3); - - gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); - gGL.vertex2f(3,-1); - - gGL.end(); - - gGL.getTexUnit(channel)->unbind(target->getUsage()); - gDeferredPostGammaCorrectProgram.unbind(); - target->flush(); - } + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); + gGL.vertex2f(-1,-1); + + gGL.texCoord2f(tc1.mV[0], tc2.mV[1]); + gGL.vertex2f(-1,3); + + gGL.texCoord2f(tc2.mV[0], tc1.mV[1]); + gGL.vertex2f(3,-1); + + gGL.end(); + + gGL.getTexUnit(channel)->unbind(screen_target->getUsage()); + gDeferredPostGammaCorrectProgram.unbind(); + screen_target->flush(); + } + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + + screen_target->bindTarget(); + + { //render non-deferred geometry (alpha, fullbright, glow) + LLGLDisable blend(GL_BLEND); + LLGLDisable stencil(GL_STENCIL_TEST); + + pushRenderTypeMask(); + andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_FULLBRIGHT, + LLPipeline::RENDER_TYPE_VOLUME, + LLPipeline::RENDER_TYPE_GLOW, + LLPipeline::RENDER_TYPE_BUMP, + LLPipeline::RENDER_TYPE_PASS_SIMPLE, + LLPipeline::RENDER_TYPE_PASS_ALPHA, + LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_BUMP, + LLPipeline::RENDER_TYPE_PASS_POST_BUMP, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, + LLPipeline::RENDER_TYPE_PASS_GLOW, + LLPipeline::RENDER_TYPE_PASS_GRASS, + LLPipeline::RENDER_TYPE_PASS_SHINY, + LLPipeline::RENDER_TYPE_PASS_INVISIBLE, + LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_ALPHA_MASK, + LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, + END_RENDER_TYPES); + + renderGeomPostDeferred(*LLViewerCamera::getInstance()); + popRenderTypeMask(); + } - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); + { + //render highlights, etc. + renderHighlights(); + mHighlightFaces.clear(); - target->bindTarget();*/ + renderDebug(); - { //render non-deferred geometry (alpha, fullbright, glow) - LLGLDisable blend(GL_BLEND); - LLGLDisable stencil(GL_STENCIL_TEST); + LLVertexBuffer::unbind(); - pushRenderTypeMask(); - andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, - LLPipeline::RENDER_TYPE_FULLBRIGHT, - LLPipeline::RENDER_TYPE_VOLUME, - LLPipeline::RENDER_TYPE_GLOW, - LLPipeline::RENDER_TYPE_BUMP, - LLPipeline::RENDER_TYPE_PASS_SIMPLE, - LLPipeline::RENDER_TYPE_PASS_ALPHA, - LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_BUMP, - LLPipeline::RENDER_TYPE_PASS_POST_BUMP, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, - LLPipeline::RENDER_TYPE_PASS_GLOW, - LLPipeline::RENDER_TYPE_PASS_GRASS, - LLPipeline::RENDER_TYPE_PASS_SHINY, - LLPipeline::RENDER_TYPE_PASS_INVISIBLE, - LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY, - LLPipeline::RENDER_TYPE_AVATAR, - LLPipeline::RENDER_TYPE_ALPHA_MASK, - LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK, - END_RENDER_TYPES); - - renderGeomPostDeferred(*LLViewerCamera::getInstance()); - popRenderTypeMask(); - } + if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) + { + // Render debugging beacons. + gObjectList.renderObjectBeacons(); + gObjectList.resetObjectBeacons(); + gSky.addSunMoonBeacons(); + } + } - //target->flush(); + screen_target->flush(); } void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) @@ -9578,7 +9062,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) LLMatrix4 light_mat(quat, LLVector4(origin,1.f)); glh::matrix4f light_to_agent((F32*) light_mat.mMatrix); - glh::matrix4f light_to_screen = glh_get_current_modelview() * light_to_agent; + glh::matrix4f light_to_screen = get_current_modelview() * light_to_agent; glh::matrix4f screen_to_light = light_to_screen.inverse(); @@ -9690,46 +9174,50 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { - stop_glerror(); - shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); - shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); - shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); - shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, mDeferredScreen.getUsage()); - shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); - shader.disableTexture(LLShaderMgr::DIFFUSE_MAP); - shader.disableTexture(LLShaderMgr::DEFERRED_BLOOM); - - for (U32 i = 0; i < 4; i++) - { - if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); - } - } + LLRenderTarget* deferred_target = &mDeferredScreen; + LLRenderTarget* deferred_depth_target = &mDeferredDepth; + LLRenderTarget* deferred_light_target = &mDeferredLight; + + stop_glerror(); + shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, deferred_light_target->getUsage()); + shader.disableTexture(LLShaderMgr::DIFFUSE_MAP); + shader.disableTexture(LLShaderMgr::DEFERRED_BLOOM); + + for (U32 i = 0; i < 4; i++) + { + if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + } + } - for (U32 i = 4; i < 6; i++) - { - if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); - } - } + for (U32 i = 4; i < 6; i++) + { + if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + } + } - shader.disableTexture(LLShaderMgr::DEFERRED_NOISE); - shader.disableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); + shader.disableTexture(LLShaderMgr::DEFERRED_NOISE); + shader.disableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); - S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) - { - LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; - if (cube_map) - { - cube_map->disable(); - } - } - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->activate(); - shader.unbind(); + S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); + if (channel > -1) + { + LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; + if (cube_map) + { + cube_map->disable(); + } + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->activate(); + shader.unbind(); } inline float sgn(float a) @@ -9740,325 +9228,276 @@ inline float sgn(float a) } void LLPipeline::generateWaterReflection(LLCamera& camera_in) -{ - if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate) - { - bool skip_avatar_update = false; - if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) - { - skip_avatar_update = true; - } - - if (!skip_avatar_update) - { - gAgentAvatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON); - } - LLVertexBuffer::unbind(); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - - LLCamera camera = camera_in; - camera.setFar(camera.getFar()*0.87654321f); - LLPipeline::sReflectionRender = true; - - gPipeline.pushRenderTypeMask(); - - glh::matrix4f projection = glh_get_current_projection(); - glh::matrix4f mat; +{ + if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate) + { + bool skip_avatar_update = false; + if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) + { + skip_avatar_update = true; + } - stop_glerror(); - LLPlane plane; + LLCamera camera = camera_in; - F32 height = gAgent.getRegion()->getWaterHeight(); - F32 to_clip = fabsf(camera.getOrigin().mV[2]-height); - F32 pad = -to_clip*0.05f; //amount to "pad" clip plane by + camera.setFar(camera_in.getFar() * 0.75f); - //plane params - LLVector3 pnorm; - F32 pd; + bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - S32 water_clip = 0; - if (!LLViewerCamera::getInstance()->cameraUnderWater()) - { //camera is above water, clip plane points up - pnorm.setVec(0,0,1); - pd = -height; - plane.setVec(pnorm, pd); - water_clip = -1; - } - else - { //camera is below water, clip plane points down - pnorm = LLVector3(0,0,-1); - pd = height; - plane.setVec(pnorm, pd); - water_clip = 1; - } + LLPipeline::sReflectionRender = true; - bool materials_in_water = false; + gPipeline.pushRenderTypeMask(); -#if MATERIALS_IN_REFLECTIONS - materials_in_water = gSavedSettings.getS32("RenderWaterMaterials"); -#endif + glh::matrix4f projection = get_current_projection(); + glh::matrix4f mat; - if (!LLViewerCamera::getInstance()->cameraUnderWater()) - { //generate planar reflection map + S32 detail = RenderReflectionDetail; - //disable occlusion culling for reflection map for now - S32 occlusion = LLPipeline::sUseOcclusion; - LLPipeline::sUseOcclusion = 0; - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glClearColor(0,0,0,0); + F32 water_height = gAgent.getRegion()->getWaterHeight(); + F32 camera_height = camera_in.getOrigin().mV[2]; + F32 distance_to_water = (water_height < camera_height) ? (camera_height - water_height) : (water_height - camera_height); - mWaterRef.bindTarget(); + LLVector3 reflection_offset = LLVector3(0, 0, distance_to_water * 2.0f); + LLVector3 camera_look_at = camera_in.getAtAxis(); + LLVector3 reflection_look_at = LLVector3(camera_look_at.mV[VX], camera_look_at.mV[VY], -camera_look_at.mV[VZ]); + LLVector3 reflect_origin = camera_in.getOrigin() - reflection_offset; + LLVector3 reflect_interest_point = reflect_origin + (reflection_look_at * 5.0f); - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0; - gGL.setColorMask(true, true); - mWaterRef.clear(); - gGL.setColorMask(true, false); + camera.setOriginAndLookAt(reflect_origin, LLVector3::z_axis, reflect_interest_point); - mWaterRef.getViewport(gGLViewport); + //plane params + LLPlane plane; + LLVector3 pnorm; + S32 water_clip = 0; + if (!camera_is_underwater) + { //camera is above water, clip plane points up + pnorm.setVec(0,0,1); + plane.setVec(pnorm, -water_height); + water_clip = 1; + } + else + { //camera is below water, clip plane points down + pnorm = LLVector3(0,0,-1); + plane.setVec(pnorm, water_height); + water_clip = -1; + } - stop_glerror(); + S32 occlusion = LLPipeline::sUseOcclusion; - gGL.pushMatrix(); + //disable occlusion culling for reflection map for now + //LLPipeline::sUseOcclusion = 0; - mat.set_scale(glh::vec3f(1,1,-1)); - mat.set_translate(glh::vec3f(0,0,height*2.f)); + glh::matrix4f current = get_current_modelview(); - glh::matrix4f current = glh_get_current_modelview(); + if (!LLViewerCamera::getInstance()->cameraUnderWater()) + { //generate planar reflection map + + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0; - mat = current * mat; + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); - glh_set_current_modelview(mat); - gGL.loadMatrix(mat.m); + glh::matrix4f mat; + camera.getOpenGLTransform(mat.m); - LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE); + glh::matrix4f scal; + scal.set_scale(glh::vec3f(1, 1, -1)); + mat = scal * mat; - glh::matrix4f inv_mat = mat.inverse(); + // convert from CFR to OGL coord sys... + mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat; - glh::vec3f origin(0,0,0); - inv_mat.mult_matrix_vec(origin); + mReflectionModelView = mat; - camera.setOrigin(origin.v); + set_current_modelview(mat); + gGL.loadMatrix(mat.m); - glCullFace(GL_FRONT); + LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE); - static LLCullResult ref_result; + glCullFace(GL_FRONT); - if (LLDrawPoolWater::sNeedsReflectionUpdate) - { - //initial sky pass (no user clip plane) - { //mask out everything but the sky - gPipeline.pushRenderTypeMask(); - gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); + if (LLDrawPoolWater::sNeedsReflectionUpdate) + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + glClearColor(0,0,0,0); + mWaterRef.bindTarget(); + + gGL.setColorMask(true, true); + mWaterRef.clear(); + gGL.setColorMask(true, false); + mWaterRef.getViewport(gGLViewport); + + //initial sky pass (no user clip plane) + { //mask out everything but the sky + gPipeline.pushRenderTypeMask(); + gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::END_RENDER_TYPES); + + updateCull(camera, mSky); + stateSort(camera, mSky); + gPipeline.grabReferences(mSky); + + renderGeom(camera, TRUE); + + gPipeline.popRenderTypeMask(); + } + + gPipeline.pushRenderTypeMask(); + + clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER, + LLPipeline::RENDER_TYPE_VOIDWATER, + LLPipeline::RENDER_TYPE_GROUND, + LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::END_RENDER_TYPES); + + if (detail > 0) + { //mask out selected geometry based on reflection detail + if (detail < 4) + { + clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES); + if (detail < 3) + { + clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES); + if (detail < 2) + { + clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES); + } + } + } + + LLGLUserClipPlane clip_plane(plane, mReflectionModelView, projection); + LLGLDisable cull(GL_CULL_FACE); + updateCull(camera, mReflectedObjects, -water_clip, &plane); + stateSort(camera, mReflectedObjects); + gPipeline.grabReferences(mReflectedObjects); + renderGeom(camera); + + } + gPipeline.popRenderTypeMask(); + mWaterRef.flush(); + } + + glCullFace(GL_BACK); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + + set_current_modelview(current); + } - static LLCullResult result; - updateCull(camera, result); - stateSort(camera, result); + //LLPipeline::sUseOcclusion = occlusion; - if (LLPipeline::sRenderDeferred && materials_in_water) - { - mWaterRef.flush(); + camera.setOrigin(camera_in.getOrigin()); + //render distortion map + static bool last_update = true; + if (last_update) + { + gPipeline.pushRenderTypeMask(); - gPipeline.grabReferences(result); - gPipeline.mDeferredScreen.bindTarget(); - gGL.setColorMask(true, true); - glClearColor(0,0,0,0); - gPipeline.mDeferredScreen.clear(); + camera.setFar(camera_in.getFar()); + clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER, + LLPipeline::RENDER_TYPE_VOIDWATER, + LLPipeline::RENDER_TYPE_GROUND, + END_RENDER_TYPES); + + bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - renderGeomDeferred(camera); - } - else - { - renderGeom(camera, TRUE); - } + // intentionally inverted so that distortion map contents (objects under the water when we're above it) + // will properly include water fog effects + LLPipeline::sUnderWaterRender = !camera_is_underwater; - gPipeline.popRenderTypeMask(); - } + if (LLPipeline::sUnderWaterRender) + { + clearRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::RENDER_TYPE_WL_SKY, + END_RENDER_TYPES); + } + LLViewerCamera::updateFrustumPlanes(camera); - gGL.setColorMask(true, false); - gPipeline.pushRenderTypeMask(); - - clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER, - LLPipeline::RENDER_TYPE_VOIDWATER, - LLPipeline::RENDER_TYPE_GROUND, - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); - - S32 detail = RenderReflectionDetail; - if (detail > 0) - { //mask out selected geometry based on reflection detail - if (detail < 4) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES); - if (detail < 3) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES); - if (detail < 2) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES); - } - } - } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + if (LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsDistortionUpdate) + { + LLPipeline::sDistortionRender = true; - LLGLUserClipPlane clip_plane(plane, mat, projection); - LLGLDisable cull(GL_CULL_FACE); - updateCull(camera, ref_result, -water_clip, &plane); - stateSort(camera, ref_result); - } + LLColor3 col = LLEnvironment::instance().getCurrentWater()->getWaterFogColor(); + glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); - if (LLDrawPoolWater::sNeedsDistortionUpdate) - { - if (RenderReflectionDetail > 0) - { - gPipeline.grabReferences(ref_result); - LLGLUserClipPlane clip_plane(plane, mat, projection); + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; - if (LLPipeline::sRenderDeferred && materials_in_water) - { - renderGeomDeferred(camera); - } - else - { - renderGeom(camera); - } - } - } + mWaterDis.bindTarget(); + mWaterDis.getViewport(gGLViewport); - if (LLPipeline::sRenderDeferred && materials_in_water) - { - gPipeline.mDeferredScreen.flush(); - renderDeferredLightingToRT(&mWaterRef); - } + //clip out geometry on the same side of water as the camera w/ enough margin to not include the water geo itself, + // but not so much as to clip out parts of avatars that should be seen under the water in the distortion map + LLPlane plane(-pnorm, water_height * LLPipeline::sDistortionWaterClipPlaneMargin); - gPipeline.popRenderTypeMask(); - } - glCullFace(GL_BACK); - gGL.popMatrix(); - mWaterRef.flush(); - glh_set_current_modelview(current); - LLPipeline::sUseOcclusion = occlusion; - } + LLGLUserClipPlane clip_plane(plane, current, projection); - camera.setOrigin(camera_in.getOrigin()); - //render distortion map - static bool last_update = true; - if (last_update) - { - camera.setFar(camera_in.getFar()); - clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER, - LLPipeline::RENDER_TYPE_VOIDWATER, - LLPipeline::RENDER_TYPE_GROUND, - END_RENDER_TYPES); - stop_glerror(); + gGL.setColorMask(true, true); + mWaterDis.clear(); + gGL.setColorMask(true, false); - LLPipeline::sUnderWaterRender = ! LLViewerCamera::getInstance()->cameraUnderWater(); + // ignore clip plane if we're underwater and viewing distortion map of objects above waterline + if (camera_is_underwater) + { + clip_plane.disable(); + } - if (LLPipeline::sUnderWaterRender) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_GROUND, - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::RENDER_TYPE_WL_SKY, - END_RENDER_TYPES); - } - LLViewerCamera::updateFrustumPlanes(camera); + updateCull(camera, mRefractedObjects, water_clip, &plane); + stateSort(camera, mRefractedObjects); + gPipeline.grabReferences(mRefractedObjects); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - LLColor4& col = LLDrawPoolWater::sWaterFogColor; - glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); - mWaterDis.bindTarget(); - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; - - mWaterDis.getViewport(gGLViewport); - - if (!LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsReflectionUpdate) - { - //clip out geometry on the same side of water as the camera - mat = glh_get_current_modelview(); - LLPlane plane(-pnorm, -(pd+pad)); + renderGeom(camera); - LLGLUserClipPlane clip_plane(plane, mat, projection); - static LLCullResult result; - updateCull(camera, result, water_clip, &plane); - stateSort(camera, result); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + + LLWorld::getInstance()->renderPropertyLines(); + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } - gGL.setColorMask(true, true); - mWaterDis.clear(); - + mWaterDis.flush(); + } - gGL.setColorMask(true, false); + LLPipeline::sDistortionRender = false; - - if (LLPipeline::sRenderDeferred && materials_in_water) - { - mWaterDis.flush(); - gPipeline.mDeferredScreen.bindTarget(); - gGL.setColorMask(true, true); - glClearColor(0,0,0,0); - gPipeline.mDeferredScreen.clear(); - gPipeline.grabReferences(result); - renderGeomDeferred(camera); - } - else - { - renderGeom(camera); + gPipeline.popRenderTypeMask(); + } + last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate; - if (LLGLSLShader::sNoFixedFunction) - { - gUIProgram.bind(); - } - - LLWorld::getInstance()->renderPropertyLines(); - - if (LLGLSLShader::sNoFixedFunction) - { - gUIProgram.unbind(); - } - } + gPipeline.popRenderTypeMask(); - if (LLPipeline::sRenderDeferred && materials_in_water) - { - gPipeline.mDeferredScreen.flush(); - renderDeferredLightingToRT(&mWaterDis); - } - } + LLPipeline::sUseOcclusion = occlusion; + LLPipeline::sUnderWaterRender = false; + LLPipeline::sReflectionRender = false; - mWaterDis.flush(); - LLPipeline::sUnderWaterRender = false; - - } - last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate; + LLDrawPoolWater::sNeedsReflectionUpdate = FALSE; + LLDrawPoolWater::sNeedsDistortionUpdate = FALSE; - LLPipeline::sReflectionRender = false; + if (!LLRenderTarget::sUseFBO) + { + glClear(GL_DEPTH_BUFFER_BIT); + } + glClearColor(0.f, 0.f, 0.f, 0.f); + gViewerWindow->setup3DViewport(); - if (!LLRenderTarget::sUseFBO) - { - glClear(GL_DEPTH_BUFFER_BIT); - } - glClearColor(0.f, 0.f, 0.f, 0.f); - gViewerWindow->setup3DViewport(); - gPipeline.popRenderTypeMask(); - LLDrawPoolWater::sNeedsReflectionUpdate = FALSE; - LLDrawPoolWater::sNeedsDistortionUpdate = FALSE; - LLPlane npnorm(-pnorm, -pd); - LLViewerCamera::getInstance()->setUserClipPlane(npnorm); - - LLGLState::checkStates(); + LLGLState::checkStates(); - if (!skip_avatar_update) - { - gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); - } + if (!skip_avatar_update) + { + gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); + } - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - } + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + } } glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) @@ -10130,6 +9569,12 @@ glh::matrix4f scale_translate_to_fit(const LLVector3 min, const LLVector3 max) static LLTrace::BlockTimerStatHandle FTM_SHADOW_RENDER("Render Shadows"); static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA("Alpha Shadow"); static LLTrace::BlockTimerStatHandle FTM_SHADOW_SIMPLE("Simple Shadow"); +static LLTrace::BlockTimerStatHandle FTM_SHADOW_GEOM("Shadow Geom"); + +static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_MASKED("Alpha Masked"); +static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_BLEND("Alpha Blend"); +static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_TREE("Alpha Tree"); +static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA_GRASS("Alpha Grass"); void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, LLCullResult &result, bool use_shader, bool use_occlusion, U32 target_width) { @@ -10184,107 +9629,138 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGL.loadMatrix(proj.m); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - gGL.loadMatrix(gGLModelView); + gGL.loadMatrix(view.m); stop_glerror(); gGLLastMatrix = NULL; - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - stop_glerror(); - - LLVertexBuffer::unbind(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + stop_glerror(); + + LLEnvironment& environment = LLEnvironment::instance(); - { - if (!use_shader) - { //occlusion program is general purpose depth-only no-textures - gOcclusionProgram.bind(); - } - else - { - gDeferredShadowProgram.bind(); - } + LLVertexBuffer::unbind(); - gGL.diffuseColor4f(1,1,1,1); - gGL.setColorMask(false, false); - - LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE); - - gGL.getTexUnit(0)->disable(); - for (U32 i = 0; i < sizeof(types)/sizeof(U32); ++i) - { - renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); - } - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - if (!use_shader) - { - gOcclusionProgram.unbind(); - } - } - - if (use_shader) - { - gDeferredShadowProgram.unbind(); - renderGeomShadow(shadow_cam); - gDeferredShadowProgram.bind(); - } - else - { - renderGeomShadow(shadow_cam); - } + { + if (!use_shader) + { //occlusion program is general purpose depth-only no-textures + gOcclusionProgram.bind(); + } + else + { + gDeferredShadowProgram.bind(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + } - { - LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA); - gDeferredShadowAlphaMaskProgram.bind(); - gDeferredShadowAlphaMaskProgram.uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + gGL.diffuseColor4f(1,1,1,1); - U32 mask = LLVertexBuffer::MAP_VERTEX | - LLVertexBuffer::MAP_TEXCOORD0 | - LLVertexBuffer::MAP_COLOR | - LLVertexBuffer::MAP_TEXTURE_INDEX; + S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail"); - renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE); - renderMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, TRUE, TRUE); - gDeferredShadowAlphaMaskProgram.setMinimumAlpha(0.598f); - renderObjects(LLRenderPass::PASS_ALPHA, mask, TRUE, TRUE); + // if not using VSM, disable color writes + if (shadow_detail <= 2) + { + gGL.setColorMask(false, false); + } - mask = mask & ~LLVertexBuffer::MAP_TEXTURE_INDEX; + LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE); + + gGL.getTexUnit(0)->disable(); + for (U32 i = 0; i < sizeof(types)/sizeof(U32); ++i) + { + renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); + } + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + if (!use_shader) + { + gOcclusionProgram.unbind(); + } + } + + if (use_shader) + { + LL_RECORD_BLOCK_TIME(FTM_SHADOW_GEOM); + + gDeferredShadowProgram.unbind(); + renderGeomShadow(shadow_cam); + gDeferredShadowProgram.bind(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + } + else + { + LL_RECORD_BLOCK_TIME(FTM_SHADOW_GEOM); + + renderGeomShadow(shadow_cam); + } + + { + LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA); + + gDeferredShadowAlphaMaskProgram.bind(); + gDeferredShadowAlphaMaskProgram.uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + gDeferredShadowAlphaMaskProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + + U32 mask = LLVertexBuffer::MAP_VERTEX | + LLVertexBuffer::MAP_TEXCOORD0 | + LLVertexBuffer::MAP_COLOR | + LLVertexBuffer::MAP_TEXTURE_INDEX; - gDeferredTreeShadowProgram.bind(); - renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, mask); - renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, mask); - renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, mask); - renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, mask); - - gDeferredTreeShadowProgram.setMinimumAlpha(0.598f); - renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); - } + { + LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_MASKED); + renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE); + renderMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, TRUE, TRUE); + } - //glCullFace(GL_BACK); + { + LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_BLEND); + gDeferredShadowAlphaMaskProgram.setMinimumAlpha(0.598f); + renderObjects(LLRenderPass::PASS_ALPHA, mask, TRUE, TRUE); + } - gDeferredShadowCubeProgram.bind(); - gGLLastMatrix = NULL; - gGL.loadMatrix(gGLModelView); + mask = mask & ~LLVertexBuffer::MAP_TEXTURE_INDEX; - LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID-1]; + { + LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_TREE); + gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, mask); + renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, mask); + renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, mask); + renderMaskedObjects(LLRenderPass::PASS_NORMMAP_MASK, mask); + } - doOcclusion(shadow_cam, occlusion_source, occlusion_target); + { + LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA_GRASS); + gDeferredTreeShadowProgram.setMinimumAlpha(0.598f); + renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE); + } + } - if (use_shader) - { - gDeferredShadowProgram.unbind(); - } - - gGL.setColorMask(true, true); - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - gGLLastMatrix = NULL; + //glCullFace(GL_BACK); + + gDeferredShadowCubeProgram.bind(); + gGLLastMatrix = NULL; + gGL.loadMatrix(gGLModelView); - LLPipeline::sUseOcclusion = occlude; - LLPipeline::sShadowRender = false; + LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID-1]; + + doOcclusion(shadow_cam, occlusion_source, occlusion_target); + + if (use_shader) + { + gDeferredShadowProgram.unbind(); + } + + gGL.setColorMask(true, true); + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + gGLLastMatrix = NULL; + + LLPipeline::sUseOcclusion = occlude; + LLPipeline::sShadowRender = false; } static LLTrace::BlockTimerStatHandle FTM_VISIBLE_CLOUD("Visible Cloud"); @@ -10502,6 +9978,11 @@ void LLPipeline::generateHighlight(LLCamera& camera) gGL.setColorMask(true, true); mHighlight.clear(); + if (LLGLSLShader::sNoFixedFunction) + { + gHighlightProgram.bind(); + } + gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); for (std::set<HighlightItem>::iterator iter = mHighlightSet.begin(); iter != mHighlightSet.end(); ) { @@ -10536,780 +10017,856 @@ void LLPipeline::generateHighlight(LLCamera& camera) } } +LLRenderTarget* LLPipeline::getShadowTarget(U32 i) +{ + return &mShadow[i]; +} static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow"); +static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SETUP("Sun Shadow Setup"); +static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_RENDER_DIRECTIONAL("Render Dir"); +static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SPOT_SETUP("Spot Shadow Setup"); +static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SPOT_RENDER("Spot Shadow Render"); void LLPipeline::generateSunShadow(LLCamera& camera) { - if (!sRenderDeferred || RenderShadowDetail <= 0) - { - return; - } - - LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW); - - bool skip_avatar_update = false; - if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) - { - - skip_avatar_update = true; - } - - if (!skip_avatar_update) - { - gAgentAvatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON); - } - - F64 last_modelview[16]; - F64 last_projection[16]; - for (U32 i = 0; i < 16; i++) - { //store last_modelview of world camera - last_modelview[i] = gGLLastModelView[i]; - last_projection[i] = gGLLastProjection[i]; - } - - pushRenderTypeMask(); - andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE, - LLPipeline::RENDER_TYPE_ALPHA, - LLPipeline::RENDER_TYPE_GRASS, - LLPipeline::RENDER_TYPE_FULLBRIGHT, - LLPipeline::RENDER_TYPE_BUMP, - LLPipeline::RENDER_TYPE_VOLUME, - LLPipeline::RENDER_TYPE_AVATAR, - LLPipeline::RENDER_TYPE_TREE, - LLPipeline::RENDER_TYPE_TERRAIN, - LLPipeline::RENDER_TYPE_WATER, - LLPipeline::RENDER_TYPE_VOIDWATER, - LLPipeline::RENDER_TYPE_PASS_ALPHA, - LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_GRASS, - LLPipeline::RENDER_TYPE_PASS_SIMPLE, - LLPipeline::RENDER_TYPE_PASS_BUMP, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, - LLPipeline::RENDER_TYPE_PASS_SHINY, - LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, - LLPipeline::RENDER_TYPE_PASS_MATERIAL, - LLPipeline::RENDER_TYPE_PASS_MATERIAL_ALPHA, - LLPipeline::RENDER_TYPE_PASS_MATERIAL_ALPHA_MASK, - LLPipeline::RENDER_TYPE_PASS_MATERIAL_ALPHA_EMISSIVE, - LLPipeline::RENDER_TYPE_PASS_SPECMAP, - LLPipeline::RENDER_TYPE_PASS_SPECMAP_BLEND, - LLPipeline::RENDER_TYPE_PASS_SPECMAP_MASK, - LLPipeline::RENDER_TYPE_PASS_SPECMAP_EMISSIVE, - LLPipeline::RENDER_TYPE_PASS_NORMMAP, - LLPipeline::RENDER_TYPE_PASS_NORMMAP_BLEND, - LLPipeline::RENDER_TYPE_PASS_NORMMAP_MASK, - LLPipeline::RENDER_TYPE_PASS_NORMMAP_EMISSIVE, - LLPipeline::RENDER_TYPE_PASS_NORMSPEC, - LLPipeline::RENDER_TYPE_PASS_NORMSPEC_BLEND, - LLPipeline::RENDER_TYPE_PASS_NORMSPEC_MASK, - LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE, - END_RENDER_TYPES); - - gGL.setColorMask(false, false); - - //get sun view matrix - - //store current projection/modelview matrix - glh::matrix4f saved_proj = glh_get_current_projection(); - glh::matrix4f saved_view = glh_get_current_modelview(); - glh::matrix4f inv_view = saved_view.inverse(); - - glh::matrix4f view[6]; - glh::matrix4f proj[6]; - - //clip contains parallel split distances for 3 splits - LLVector3 clip = RenderShadowClipPlanes; - - //F32 slope_threshold = gSavedSettings.getF32("RenderShadowSlopeThreshold"); - - //far clip on last split is minimum of camera view distance and 128 - mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]); - - clip = RenderShadowOrthoClipPlanes; - mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); - - //currently used for amount to extrude frusta corners for constructing shadow frusta - //LLVector3 n = RenderShadowNearDist; - //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; - - //put together a universal "near clip" plane for shadow frusta - LLPlane shadow_near_clip; - { - LLVector3 p = gAgent.getPositionAgent(); - p += mSunDir * RenderFarClip*2.f; - shadow_near_clip.setVec(p, mSunDir); - } - - LLVector3 lightDir = -mSunDir; - lightDir.normVec(); - - glh::vec3f light_dir(lightDir.mV); - - //create light space camera matrix - - LLVector3 at = lightDir; - - LLVector3 up = camera.getAtAxis(); - - if (fabsf(up*lightDir) > 0.75f) - { - up = camera.getUpAxis(); - } - - /*LLVector3 left = up%at; - up = at%left;*/ - - up.normVec(); - at.normVec(); - - - LLCamera main_camera = camera; - - F32 near_clip = 0.f; - { - //get visible point cloud - std::vector<LLVector3> fp; - - main_camera.calcAgentFrustumPlanes(main_camera.mAgentFrustum); - - LLVector3 min,max; - getVisiblePointCloud(main_camera,min,max,fp); - - if (fp.empty()) - { - if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) - { - mShadowCamera[0] = main_camera; - mShadowExtents[0][0] = min; - mShadowExtents[0][1] = max; - - mShadowFrustPoints[0].clear(); - mShadowFrustPoints[1].clear(); - mShadowFrustPoints[2].clear(); - mShadowFrustPoints[3].clear(); - } - popRenderTypeMask(); - - if (!skip_avatar_update) - { - gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); - } - - return; - } - - //get good split distances for frustum - for (U32 i = 0; i < fp.size(); ++i) - { - glh::vec3f v(fp[i].mV); - saved_view.mult_matrix_vec(v); - fp[i].setVec(v.v); - } - - min = fp[0]; - max = fp[0]; - - //get camera space bounding box - for (U32 i = 1; i < fp.size(); ++i) - { - update_min_max(min, max, fp[i]); - } - - near_clip = -max.mV[2]; - F32 far_clip = -min.mV[2]*2.f; - - //far_clip = llmin(far_clip, 128.f); - far_clip = llmin(far_clip, camera.getFar()); + if (!sRenderDeferred || RenderShadowDetail <= 0) + { + if (mNeedsShadowTargetClear) + { + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - F32 range = far_clip-near_clip; + for (S32 j = 0; j < 6; j++) + { + LLRenderTarget* shadow_target = getShadowTarget(j); + if (shadow_target) + { + shadow_target->bindTarget(); + shadow_target->clear(); + shadow_target->flush(); + } + } + mNeedsShadowTargetClear = false; + } - LLVector3 split_exp = RenderShadowSplitExponent; + return; + } + + mNeedsShadowTargetClear = true; + + LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW); + + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); + + bool skip_avatar_update = false; + if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) + { + skip_avatar_update = true; + } + + F64 last_modelview[16]; + F64 last_projection[16]; + for (U32 i = 0; i < 16; i++) + { //store last_modelview of world camera + last_modelview[i] = gGLLastModelView[i]; + last_projection[i] = gGLLastProjection[i]; + } + + pushRenderTypeMask(); + andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE, + LLPipeline::RENDER_TYPE_ALPHA, + LLPipeline::RENDER_TYPE_GRASS, + LLPipeline::RENDER_TYPE_FULLBRIGHT, + LLPipeline::RENDER_TYPE_BUMP, + LLPipeline::RENDER_TYPE_VOLUME, + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_TREE, + LLPipeline::RENDER_TYPE_TERRAIN, + LLPipeline::RENDER_TYPE_WATER, + LLPipeline::RENDER_TYPE_VOIDWATER, + LLPipeline::RENDER_TYPE_PASS_ALPHA, + LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_GRASS, + LLPipeline::RENDER_TYPE_PASS_SIMPLE, + LLPipeline::RENDER_TYPE_PASS_BUMP, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT, + LLPipeline::RENDER_TYPE_PASS_SHINY, + LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY, + LLPipeline::RENDER_TYPE_PASS_MATERIAL, + LLPipeline::RENDER_TYPE_PASS_MATERIAL_ALPHA, + LLPipeline::RENDER_TYPE_PASS_MATERIAL_ALPHA_MASK, + LLPipeline::RENDER_TYPE_PASS_MATERIAL_ALPHA_EMISSIVE, + LLPipeline::RENDER_TYPE_PASS_SPECMAP, + LLPipeline::RENDER_TYPE_PASS_SPECMAP_BLEND, + LLPipeline::RENDER_TYPE_PASS_SPECMAP_MASK, + LLPipeline::RENDER_TYPE_PASS_SPECMAP_EMISSIVE, + LLPipeline::RENDER_TYPE_PASS_NORMMAP, + LLPipeline::RENDER_TYPE_PASS_NORMMAP_BLEND, + LLPipeline::RENDER_TYPE_PASS_NORMMAP_MASK, + LLPipeline::RENDER_TYPE_PASS_NORMMAP_EMISSIVE, + LLPipeline::RENDER_TYPE_PASS_NORMSPEC, + LLPipeline::RENDER_TYPE_PASS_NORMSPEC_BLEND, + LLPipeline::RENDER_TYPE_PASS_NORMSPEC_MASK, + LLPipeline::RENDER_TYPE_PASS_NORMSPEC_EMISSIVE, + END_RENDER_TYPES); + + S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail"); + + // if not using VSM, disable color writes + if (shadow_detail <= 2) + { + gGL.setColorMask(false, false); + } + + bool sun_up = environment.getIsSunUp(); + bool moon_up = environment.getIsMoonUp(); + bool ignore_shadows = (shadow_detail == 0) + || (sun_up && (mSunDiffuse == LLColor4::black)) + || (moon_up && (mMoonDiffuse == LLColor4::black)) + || !(sun_up || moon_up); + + if (ignore_shadows) + { //sun diffuse is totally black, shadows don't matter + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + + for (S32 j = 0; j < 4; j++) + { + LLRenderTarget* shadow_target = getShadowTarget(j); + if (shadow_target) + { + shadow_target->bindTarget(); + shadow_target->clear(); + shadow_target->flush(); + } + } - F32 da = 1.f-llmax( fabsf(lightDir*up), fabsf(lightDir*camera.getLeftAxis()) ); - - da = powf(da, split_exp.mV[2]); + if (shadow_detail == 0) + { + for (S32 j = 4; j < 6; j++) + { + LLRenderTarget* shadow_target = getShadowTarget(j); + if (shadow_target) + { + shadow_target->bindTarget(); + shadow_target->clear(); + shadow_target->flush(); + } + } + } + } - F32 sxp = split_exp.mV[1] + (split_exp.mV[0]-split_exp.mV[1])*da; - - for (U32 i = 0; i < 4; ++i) - { - F32 x = (F32)(i+1)/4.f; - x = powf(x, sxp); - mSunClipPlanes.mV[i] = near_clip+range*x; - } + //get sun view matrix + + //store current projection/modelview matrix + glh::matrix4f saved_proj = get_current_projection(); + glh::matrix4f saved_view = get_current_modelview(); + glh::matrix4f inv_view = saved_view.inverse(); - mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding - } + glh::matrix4f view[6]; + glh::matrix4f proj[6]; + + //clip contains parallel split distances for 3 splits + LLVector3 clip = RenderShadowClipPlanes; - // convenience array of 4 near clip plane distances - F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; - + //F32 slope_threshold = gSavedSettings.getF32("RenderShadowSlopeThreshold"); - if (mSunDiffuse == LLColor4::black) - { //sun diffuse is totally black, shadows don't matter - LLGLDepthTest depth(GL_TRUE); + //far clip on last split is minimum of camera view distance and 128 + mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]); - for (S32 j = 0; j < 4; j++) - { - mShadow[j].bindTarget(); - mShadow[j].clear(); - mShadow[j].flush(); - } - } - else - { - for (S32 j = 0; j < 4; j++) - { - if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) - { - mShadowFrustPoints[j].clear(); - } + clip = RenderShadowOrthoClipPlanes; + mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j); + //currently used for amount to extrude frusta corners for constructing shadow frusta + //LLVector3 n = RenderShadowNearDist; + //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; - //restore render matrices - glh_set_current_modelview(saved_view); - glh_set_current_projection(saved_proj); + LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir); - LLVector3 eye = camera.getOrigin(); + //put together a universal "near clip" plane for shadow frusta + LLPlane shadow_near_clip; + { + LLVector3 p = gAgent.getPositionAgent(); + p += caster_dir * RenderFarClip*2.f; + shadow_near_clip.setVec(p, caster_dir); + } - //camera used for shadow cull/render - LLCamera shadow_cam; - - //create world space camera frustum for this split - shadow_cam = camera; - shadow_cam.setFar(16.f); - - LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); + LLVector3 lightDir = -caster_dir; + lightDir.normVec(); - LLVector3* frust = shadow_cam.mAgentFrustum; + glh::vec3f light_dir(lightDir.mV); - LLVector3 pn = shadow_cam.getAtAxis(); - - LLVector3 min, max; - - //construct 8 corners of split frustum section - for (U32 i = 0; i < 4; i++) - { - LLVector3 delta = frust[i+4]-eye; - delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f; - delta.normVec(); - F32 dp = delta*pn; - frust[i] = eye + (delta*dist[j]*0.75f)/dp; - frust[i+4] = eye + (delta*dist[j+1]*1.25f)/dp; - } - - shadow_cam.calcAgentFrustumPlanes(frust); - shadow_cam.mFrustumCornerDist = 0.f; - - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) - { - mShadowCamera[j] = shadow_cam; - } + //create light space camera matrix + + LLVector3 at = lightDir; - std::vector<LLVector3> fp; + LLVector3 up = camera.getAtAxis(); - if (!gPipeline.getVisiblePointCloud(shadow_cam, min, max, fp, lightDir)) - { - //no possible shadow receivers - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) - { - mShadowExtents[j][0] = LLVector3(); - mShadowExtents[j][1] = LLVector3(); - mShadowCamera[j+4] = shadow_cam; - } + if (fabsf(up*lightDir) > 0.75f) + { + up = camera.getUpAxis(); + } - mShadow[j].bindTarget(); - { - LLGLDepthTest depth(GL_TRUE); - mShadow[j].clear(); - } - mShadow[j].flush(); + /*LLVector3 left = up%at; + up = at%left;*/ - mShadowError.mV[j] = 0.f; - mShadowFOV.mV[j] = 0.f; + up.normVec(); + at.normVec(); + + LLCamera main_camera = camera; + + F32 near_clip = 0.f; + { + //get visible point cloud + std::vector<LLVector3> fp; - continue; - } + main_camera.calcAgentFrustumPlanes(main_camera.mAgentFrustum); + + LLVector3 min,max; + getVisiblePointCloud(main_camera,min,max,fp); - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) - { - mShadowExtents[j][0] = min; - mShadowExtents[j][1] = max; - mShadowFrustPoints[j] = fp; - } - + if (fp.empty()) + { + if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) + { + mShadowCamera[0] = main_camera; + mShadowExtents[0][0] = min; + mShadowExtents[0][1] = max; + + mShadowFrustPoints[0].clear(); + mShadowFrustPoints[1].clear(); + mShadowFrustPoints[2].clear(); + mShadowFrustPoints[3].clear(); + } + popRenderTypeMask(); - //find a good origin for shadow projection - LLVector3 origin; + if (!skip_avatar_update) + { + gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); + } - //get a temporary view projection - view[j] = look(camera.getOrigin(), lightDir, -up); + return; + } - std::vector<LLVector3> wpf; + //get good split distances for frustum + for (U32 i = 0; i < fp.size(); ++i) + { + glh::vec3f v(fp[i].mV); + saved_view.mult_matrix_vec(v); + fp[i].setVec(v.v); + } - for (U32 i = 0; i < fp.size(); i++) - { - glh::vec3f p = glh::vec3f(fp[i].mV); - view[j].mult_matrix_vec(p); - wpf.push_back(LLVector3(p.v)); - } + min = fp[0]; + max = fp[0]; - min = wpf[0]; - max = wpf[0]; + //get camera space bounding box + for (U32 i = 1; i < fp.size(); ++i) + { + update_min_max(min, max, fp[i]); + } - for (U32 i = 0; i < fp.size(); ++i) - { //get AABB in camera space - update_min_max(min, max, wpf[i]); - } + near_clip = -max.mV[2]; + F32 far_clip = -min.mV[2]*2.f; - // Construct a perspective transform with perspective along y-axis that contains - // points in wpf - //Known: - // - far clip plane - // - near clip plane - // - points in frustum - //Find: - // - origin + //far_clip = llmin(far_clip, 128.f); + far_clip = llmin(far_clip, camera.getFar()); - //get some "interesting" points of reference - LLVector3 center = (min+max)*0.5f; - LLVector3 size = (max-min)*0.5f; - LLVector3 near_center = center; - near_center.mV[1] += size.mV[1]*2.f; - - - //put all points in wpf in quadrant 0, reletive to center of min/max - //get the best fit line using least squares - F32 bfm = 0.f; - F32 bfb = 0.f; + F32 range = far_clip-near_clip; - for (U32 i = 0; i < wpf.size(); ++i) - { - wpf[i] -= center; - wpf[i].mV[0] = fabsf(wpf[i].mV[0]); - wpf[i].mV[2] = fabsf(wpf[i].mV[2]); - } + LLVector3 split_exp = RenderShadowSplitExponent; - if (!wpf.empty()) - { - F32 sx = 0.f; - F32 sx2 = 0.f; - F32 sy = 0.f; - F32 sxy = 0.f; - - for (U32 i = 0; i < wpf.size(); ++i) - { - sx += wpf[i].mV[0]; - sx2 += wpf[i].mV[0]*wpf[i].mV[0]; - sy += wpf[i].mV[1]; - sxy += wpf[i].mV[0]*wpf[i].mV[1]; - } - - bfm = (sy*sx-wpf.size()*sxy)/(sx*sx-wpf.size()*sx2); - bfb = (sx*sxy-sy*sx2)/(sx*sx-bfm*sx2); - } - - { - // best fit line is y=bfm*x+bfb - - //find point that is furthest to the right of line - F32 off_x = -1.f; - LLVector3 lp; - - for (U32 i = 0; i < wpf.size(); ++i) - { - //y = bfm*x+bfb - //x = (y-bfb)/bfm - F32 lx = (wpf[i].mV[1]-bfb)/bfm; - - lx = wpf[i].mV[0]-lx; - - if (off_x < lx) - { - off_x = lx; - lp = wpf[i]; - } - } + F32 da = 1.f-llmax( fabsf(lightDir*up), fabsf(lightDir*camera.getLeftAxis()) ); + + da = powf(da, split_exp.mV[2]); - //get line with slope bfm through lp - // bfb = y-bfm*x - bfb = lp.mV[1]-bfm*lp.mV[0]; + F32 sxp = split_exp.mV[1] + (split_exp.mV[0]-split_exp.mV[1])*da; + + for (U32 i = 0; i < 4; ++i) + { + F32 x = (F32)(i+1)/4.f; + x = powf(x, sxp); + mSunClipPlanes.mV[i] = near_clip+range*x; + } - //calculate error - mShadowError.mV[j] = 0.f; + mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding + } - for (U32 i = 0; i < wpf.size(); ++i) - { - F32 lx = (wpf[i].mV[1]-bfb)/bfm; - mShadowError.mV[j] += fabsf(wpf[i].mV[0]-lx); - } + // convenience array of 4 near clip plane distances + F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; - mShadowError.mV[j] /= wpf.size(); - mShadowError.mV[j] /= size.mV[0]; + if (!ignore_shadows) + { + for (S32 j = 0; j < 4; j++) + { + LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW_SETUP); - if (mShadowError.mV[j] > RenderShadowErrorCutoff) - { //just use ortho projection - mShadowFOV.mV[j] = -1.f; - origin.clearVec(); - proj[j] = gl_ortho(min.mV[0], max.mV[0], - min.mV[1], max.mV[1], - -max.mV[2], -min.mV[2]); - } - else - { - //origin is where line x = 0; - origin.setVec(0,bfb,0); + if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) + { + mShadowFrustPoints[j].clear(); + } - F32 fovz = 1.f; - F32 fovx = 1.f; - - LLVector3 zp; - LLVector3 xp; + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j); - for (U32 i = 0; i < wpf.size(); ++i) - { - LLVector3 atz = wpf[i]-origin; - atz.mV[0] = 0.f; - atz.normVec(); - if (fovz > -atz.mV[1]) - { - zp = wpf[i]; - fovz = -atz.mV[1]; - } - - LLVector3 atx = wpf[i]-origin; - atx.mV[2] = 0.f; - atx.normVec(); - if (fovx > -atx.mV[1]) - { - fovx = -atx.mV[1]; - xp = wpf[i]; - } - } + //restore render matrices + set_current_modelview(saved_view); + set_current_projection(saved_proj); - fovx = acos(fovx); - fovz = acos(fovz); + LLVector3 eye = camera.getOrigin(); - F32 cutoff = llmin((F32) RenderShadowFOVCutoff, 1.4f); - - mShadowFOV.mV[j] = fovx; - - if (fovx < cutoff && fovz > cutoff) - { - //x is a good fit, but z is too big, move away from zp enough so that fovz matches cutoff - F32 d = zp.mV[2]/tan(cutoff); - F32 ny = zp.mV[1] + fabsf(d); + //camera used for shadow cull/render + LLCamera shadow_cam; + + //create world space camera frustum for this split + shadow_cam = camera; + shadow_cam.setFar(16.f); + + LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - origin.mV[1] = ny; + LLVector3* frust = shadow_cam.mAgentFrustum; - fovz = 1.f; - fovx = 1.f; + LLVector3 pn = shadow_cam.getAtAxis(); + + LLVector3 min, max; - for (U32 i = 0; i < wpf.size(); ++i) - { - LLVector3 atz = wpf[i]-origin; - atz.mV[0] = 0.f; - atz.normVec(); - fovz = llmin(fovz, -atz.mV[1]); - - LLVector3 atx = wpf[i]-origin; - atx.mV[2] = 0.f; - atx.normVec(); - fovx = llmin(fovx, -atx.mV[1]); - } + //construct 8 corners of split frustum section + for (U32 i = 0; i < 4; i++) + { + LLVector3 delta = frust[i+4]-eye; + delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f; + delta.normVec(); + F32 dp = delta*pn; + frust[i] = eye + (delta*dist[j]*0.75f)/dp; + frust[i+4] = eye + (delta*dist[j+1]*1.25f)/dp; + } + + shadow_cam.calcAgentFrustumPlanes(frust); + shadow_cam.mFrustumCornerDist = 0.f; + + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + { + mShadowCamera[j] = shadow_cam; + } - fovx = acos(fovx); - fovz = acos(fovz); + std::vector<LLVector3> fp; - mShadowFOV.mV[j] = cutoff; - } + if (!gPipeline.getVisiblePointCloud(shadow_cam, min, max, fp, lightDir)) + { + //no possible shadow receivers + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + { + mShadowExtents[j][0] = LLVector3(); + mShadowExtents[j][1] = LLVector3(); + mShadowCamera[j+4] = shadow_cam; + } + + LLRenderTarget* shadow_target = getShadowTarget(j); + if (shadow_target) + { + shadow_target->bindTarget(); + { + LLGLDepthTest depth(GL_TRUE); + shadow_target->clear(); + } + shadow_target->flush(); + } + + mShadowError.mV[j] = 0.f; + mShadowFOV.mV[j] = 0.f; - - origin += center; - - F32 ynear = -(max.mV[1]-origin.mV[1]); - F32 yfar = -(min.mV[1]-origin.mV[1]); - - if (ynear < 0.1f) //keep a sensible near clip plane - { - F32 diff = 0.1f-ynear; - origin.mV[1] += diff; - ynear += diff; - yfar += diff; - } - - if (fovx > cutoff) - { //just use ortho projection - origin.clearVec(); - mShadowError.mV[j] = -1.f; - proj[j] = gl_ortho(min.mV[0], max.mV[0], - min.mV[1], max.mV[1], - -max.mV[2], -min.mV[2]); - } - else - { - //get perspective projection - view[j] = view[j].inverse(); + continue; + } - glh::vec3f origin_agent(origin.mV); - - //translate view to origin - view[j].mult_matrix_vec(origin_agent); + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + { + mShadowExtents[j][0] = min; + mShadowExtents[j][1] = max; + mShadowFrustPoints[j] = fp; + } + - eye = LLVector3(origin_agent.v); + //find a good origin for shadow projection + LLVector3 origin; - if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) - { - mShadowFrustOrigin[j] = eye; - } - - view[j] = look(LLVector3(origin_agent.v), lightDir, -up); + //get a temporary view projection + view[j] = look(camera.getOrigin(), lightDir, -up); - F32 fx = 1.f/tanf(fovx); - F32 fz = 1.f/tanf(fovz); + std::vector<LLVector3> wpf; - proj[j] = glh::matrix4f(-fx, 0, 0, 0, - 0, (yfar+ynear)/(ynear-yfar), 0, (2.f*yfar*ynear)/(ynear-yfar), - 0, 0, -fz, 0, - 0, -1.f, 0, 0); - } - } - } + for (U32 i = 0; i < fp.size(); i++) + { + glh::vec3f p = glh::vec3f(fp[i].mV); + view[j].mult_matrix_vec(p); + wpf.push_back(LLVector3(p.v)); + } - //shadow_cam.setFar(128.f); - shadow_cam.setOriginAndLookAt(eye, up, center); + min = wpf[0]; + max = wpf[0]; - shadow_cam.setOrigin(0,0,0); + for (U32 i = 0; i < fp.size(); ++i) + { //get AABB in camera space + update_min_max(min, max, wpf[i]); + } - glh_set_current_modelview(view[j]); - glh_set_current_projection(proj[j]); + // Construct a perspective transform with perspective along y-axis that contains + // points in wpf + //Known: + // - far clip plane + // - near clip plane + // - points in frustum + //Find: + // - origin + + //get some "interesting" points of reference + LLVector3 center = (min+max)*0.5f; + LLVector3 size = (max-min)*0.5f; + LLVector3 near_center = center; + near_center.mV[1] += size.mV[1]*2.f; + + + //put all points in wpf in quadrant 0, reletive to center of min/max + //get the best fit line using least squares + F32 bfm = 0.f; + F32 bfb = 0.f; - LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); + for (U32 i = 0; i < wpf.size(); ++i) + { + wpf[i] -= center; + wpf[i].mV[0] = fabsf(wpf[i].mV[0]); + wpf[i].mV[2] = fabsf(wpf[i].mV[2]); + } - //shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR); - shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip); + if (!wpf.empty()) + { + F32 sx = 0.f; + F32 sx2 = 0.f; + F32 sy = 0.f; + F32 sxy = 0.f; + + for (U32 i = 0; i < wpf.size(); ++i) + { + sx += wpf[i].mV[0]; + sx2 += wpf[i].mV[0]*wpf[i].mV[0]; + sy += wpf[i].mV[1]; + sxy += wpf[i].mV[0]*wpf[i].mV[1]; + } + + bfm = (sy*sx-wpf.size()*sxy)/(sx*sx-wpf.size()*sx2); + bfb = (sx*sxy-sy*sx2)/(sx*sx-bfm*sx2); + } + + { + // best fit line is y=bfm*x+bfb + + //find point that is furthest to the right of line + F32 off_x = -1.f; + LLVector3 lp; + + for (U32 i = 0; i < wpf.size(); ++i) + { + //y = bfm*x+bfb + //x = (y-bfb)/bfm + F32 lx = (wpf[i].mV[1]-bfb)/bfm; + + lx = wpf[i].mV[0]-lx; + + if (off_x < lx) + { + off_x = lx; + lp = wpf[i]; + } + } + + //get line with slope bfm through lp + // bfb = y-bfm*x + bfb = lp.mV[1]-bfm*lp.mV[0]; + + //calculate error + mShadowError.mV[j] = 0.f; + + for (U32 i = 0; i < wpf.size(); ++i) + { + F32 lx = (wpf[i].mV[1]-bfb)/bfm; + mShadowError.mV[j] += fabsf(wpf[i].mV[0]-lx); + } + + mShadowError.mV[j] /= wpf.size(); + mShadowError.mV[j] /= size.mV[0]; + + if (mShadowError.mV[j] > RenderShadowErrorCutoff) + { //just use ortho projection + mShadowFOV.mV[j] = -1.f; + origin.clearVec(); + proj[j] = gl_ortho(min.mV[0], max.mV[0], + min.mV[1], max.mV[1], + -max.mV[2], -min.mV[2]); + } + else + { + //origin is where line x = 0; + origin.setVec(0,bfb,0); + + F32 fovz = 1.f; + F32 fovx = 1.f; + + LLVector3 zp; + LLVector3 xp; + + for (U32 i = 0; i < wpf.size(); ++i) + { + LLVector3 atz = wpf[i]-origin; + atz.mV[0] = 0.f; + atz.normVec(); + if (fovz > -atz.mV[1]) + { + zp = wpf[i]; + fovz = -atz.mV[1]; + } + + LLVector3 atx = wpf[i]-origin; + atx.mV[2] = 0.f; + atx.normVec(); + if (fovx > -atx.mV[1]) + { + fovx = -atx.mV[1]; + xp = wpf[i]; + } + } + + fovx = acos(fovx); + fovz = acos(fovz); + + F32 cutoff = llmin((F32) RenderShadowFOVCutoff, 1.4f); + + mShadowFOV.mV[j] = fovx; + + if (fovx < cutoff && fovz > cutoff) + { + //x is a good fit, but z is too big, move away from zp enough so that fovz matches cutoff + F32 d = zp.mV[2]/tan(cutoff); + F32 ny = zp.mV[1] + fabsf(d); + + origin.mV[1] = ny; + + fovz = 1.f; + fovx = 1.f; + + for (U32 i = 0; i < wpf.size(); ++i) + { + LLVector3 atz = wpf[i]-origin; + atz.mV[0] = 0.f; + atz.normVec(); + fovz = llmin(fovz, -atz.mV[1]); + + LLVector3 atx = wpf[i]-origin; + atx.mV[2] = 0.f; + atx.normVec(); + fovx = llmin(fovx, -atx.mV[1]); + } + + fovx = acos(fovx); + fovz = acos(fovz); + + mShadowFOV.mV[j] = cutoff; + } + + + origin += center; + + F32 ynear = -(max.mV[1]-origin.mV[1]); + F32 yfar = -(min.mV[1]-origin.mV[1]); + + if (ynear < 0.1f) //keep a sensible near clip plane + { + F32 diff = 0.1f-ynear; + origin.mV[1] += diff; + ynear += diff; + yfar += diff; + } + + if (fovx > cutoff) + { //just use ortho projection + origin.clearVec(); + mShadowError.mV[j] = -1.f; + proj[j] = gl_ortho(min.mV[0], max.mV[0], + min.mV[1], max.mV[1], + -max.mV[2], -min.mV[2]); + } + else + { + //get perspective projection + view[j] = view[j].inverse(); + + glh::vec3f origin_agent(origin.mV); + + //translate view to origin + view[j].mult_matrix_vec(origin_agent); + + eye = LLVector3(origin_agent.v); + + if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + { + mShadowFrustOrigin[j] = eye; + } + + view[j] = look(LLVector3(origin_agent.v), lightDir, -up); + + F32 fx = 1.f/tanf(fovx); + F32 fz = 1.f/tanf(fovz); + + proj[j] = glh::matrix4f(-fx, 0, 0, 0, + 0, (yfar+ynear)/(ynear-yfar), 0, (2.f*yfar*ynear)/(ynear-yfar), + 0, 0, -fz, 0, + 0, -1.f, 0, 0); + } + } + } - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + //shadow_cam.setFar(128.f); + shadow_cam.setOriginAndLookAt(eye, up, center); - glh_set_current_modelview(view[j]); - glh_set_current_projection(proj[j]); + shadow_cam.setOrigin(0,0,0); - for (U32 i = 0; i < 16; i++) - { - gGLLastModelView[i] = mShadowModelview[j].m[i]; - gGLLastProjection[i] = mShadowProjection[j].m[i]; - } + set_current_modelview(view[j]); + set_current_projection(proj[j]); - mShadowModelview[j] = view[j]; - mShadowProjection[j] = proj[j]; + LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - - mSunShadowMatrix[j] = trans*proj[j]*view[j]*inv_view; - - stop_glerror(); + //shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR); + shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip); - mShadow[j].bindTarget(); - mShadow[j].getViewport(gGLViewport); - mShadow[j].clear(); - - U32 target_width = mShadow[j].getWidth(); + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - { - static LLCullResult result[4]; + set_current_modelview(view[j]); + set_current_projection(proj[j]); - renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, TRUE, target_width); - } + for (U32 i = 0; i < 16; i++) + { + gGLLastModelView[i] = mShadowModelview[j].m[i]; + gGLLastProjection[i] = mShadowProjection[j].m[i]; + } - mShadow[j].flush(); - - if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) - { - LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - mShadowCamera[j+4] = shadow_cam; - } - } - } + mShadowModelview[j] = view[j]; + mShadowProjection[j] = proj[j]; - - //hack to disable projector shadows - bool gen_shadow = RenderShadowDetail > 1; + + mSunShadowMatrix[j] = trans*proj[j]*view[j]*inv_view; + + stop_glerror(); - if (gen_shadow) - { - LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); - F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + LLRenderTarget* shadow_target = getShadowTarget(j); - //update shadow targets - for (U32 i = 0; i < 2; i++) - { //for each current shadow - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); + if (shadow_target) + { + shadow_target->bindTarget(); + shadow_target->getViewport(gGLViewport); + shadow_target->clear(); - if (mShadowSpotLight[i].notNull() && - (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || - mShadowSpotLight[i] == mTargetShadowSpotLight[1])) - { //keep this spotlight - mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); - } - else - { //fade out this light - mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); - - if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) - { //faded out, grab one of the pending spots (whichever one isn't already taken) - if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) - { - mShadowSpotLight[i] = mTargetShadowSpotLight[0]; - } - else - { - mShadowSpotLight[i] = mTargetShadowSpotLight[1]; - } - } - } - } + U32 target_width = shadow_target->getWidth(); - for (S32 i = 0; i < 2; i++) - { - glh_set_current_modelview(saved_view); - glh_set_current_projection(saved_proj); + { + LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW_RENDER_DIRECTIONAL); - if (mShadowSpotLight[i].isNull()) - { - continue; - } + static LLCullResult result[4]; + renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, TRUE, target_width); + } - LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); + shadow_target->flush(); + } - if (!volume) - { - mShadowSpotLight[i] = NULL; - continue; - } + if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) + { + LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); + mShadowCamera[j+4] = shadow_cam; + } + } + } - LLDrawable* drawable = mShadowSpotLight[i]; + + //hack to disable projector shadows + bool gen_shadow = RenderShadowDetail > 1; + + if (gen_shadow) + { + LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW_SPOT_SETUP); + + LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + + //update shadow targets + for (U32 i = 0; i < 2; i++) + { //for each current shadow + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); + + if (mShadowSpotLight[i].notNull() && + (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || + mShadowSpotLight[i] == mTargetShadowSpotLight[1])) + { //keep this spotlight + mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); + } + else + { //fade out this light + mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); + + if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) + { //faded out, grab one of the pending spots (whichever one isn't already taken) + if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) + { + mShadowSpotLight[i] = mTargetShadowSpotLight[0]; + } + else + { + mShadowSpotLight[i] = mTargetShadowSpotLight[1]; + } + } + } + } - LLVector3 params = volume->getSpotLightParams(); - F32 fov = params.mV[0]; + for (S32 i = 0; i < 2; i++) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); - //get agent->light space matrix (modelview) - LLVector3 center = drawable->getPositionAgent(); - LLQuaternion quat = volume->getRenderRotation(); + if (mShadowSpotLight[i].isNull()) + { + continue; + } - //get near clip plane - LLVector3 scale = volume->getScale(); - LLVector3 at_axis(0,0,-scale.mV[2]*0.5f); - at_axis *= quat; + LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); - LLVector3 np = center+at_axis; - at_axis.normVec(); + if (!volume) + { + mShadowSpotLight[i] = NULL; + continue; + } - //get origin that has given fov for plane np, at_axis, and given scale - F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f); + LLDrawable* drawable = mShadowSpotLight[i]; - LLVector3 origin = np - at_axis*dist; + LLVector3 params = volume->getSpotLightParams(); + F32 fov = params.mV[0]; - LLMatrix4 mat(quat, LLVector4(origin, 1.f)); + //get agent->light space matrix (modelview) + LLVector3 center = drawable->getPositionAgent(); + LLQuaternion quat = volume->getRenderRotation(); - view[i+4] = glh::matrix4f((F32*) mat.mMatrix); + //get near clip plane + LLVector3 scale = volume->getScale(); + LLVector3 at_axis(0,0,-scale.mV[2]*0.5f); + at_axis *= quat; - view[i+4] = view[i+4].inverse(); + LLVector3 np = center+at_axis; + at_axis.normVec(); - //get perspective matrix - F32 near_clip = dist+0.01f; - F32 width = scale.mV[VX]; - F32 height = scale.mV[VY]; - F32 far_clip = dist+volume->getLightRadius()*1.5f; + //get origin that has given fov for plane np, at_axis, and given scale + F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f); - F32 fovy = fov * RAD_TO_DEG; - F32 aspect = width/height; - - proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip); + LLVector3 origin = np - at_axis*dist; - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - glh_set_current_modelview(view[i+4]); - glh_set_current_projection(proj[i+4]); + view[i+4] = glh::matrix4f((F32*) mat.mMatrix); - mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view; - - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i+4].m[j]; - gGLLastProjection[j] = mShadowProjection[i+4].m[j]; - } + view[i+4] = view[i+4].inverse(); - mShadowModelview[i+4] = view[i+4]; - mShadowProjection[i+4] = proj[i+4]; + //get perspective matrix + F32 near_clip = dist+0.01f; + F32 width = scale.mV[VX]; + F32 height = scale.mV[VY]; + F32 far_clip = dist+volume->getLightRadius()*1.5f; - LLCamera shadow_cam = camera; - shadow_cam.setFar(far_clip); - shadow_cam.setOrigin(origin); + F32 fovy = fov * RAD_TO_DEG; + F32 aspect = width/height; + + proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip); - LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - stop_glerror(); + set_current_modelview(view[i+4]); + set_current_projection(proj[i+4]); - mShadow[i+4].bindTarget(); - mShadow[i+4].getViewport(gGLViewport); - mShadow[i+4].clear(); + mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view; + + for (U32 j = 0; j < 16; j++) + { + gGLLastModelView[j] = mShadowModelview[i+4].m[j]; + gGLLastProjection[j] = mShadowProjection[i+4].m[j]; + } - U32 target_width = mShadow[i+4].getWidth(); + mShadowModelview[i+4] = view[i+4]; + mShadowProjection[i+4] = proj[i+4]; - static LLCullResult result[2]; + LLCamera shadow_cam = camera; + shadow_cam.setFar(far_clip); + shadow_cam.setOrigin(origin); - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); + LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width); + stop_glerror(); - mShadow[i+4].flush(); - } - } - else - { //no spotlight shadows - mShadowSpotLight[0] = mShadowSpotLight[1] = NULL; - } + LLRenderTarget* shadow_target = getShadowTarget(i + 4); + if (shadow_target) + { + LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW_SPOT_RENDER); - if (!CameraOffset) - { - glh_set_current_modelview(saved_view); - glh_set_current_projection(saved_proj); - } - else - { - glh_set_current_modelview(view[1]); - glh_set_current_projection(proj[1]); - gGL.loadMatrix(view[1].m); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadMatrix(proj[1].m); - gGL.matrixMode(LLRender::MM_MODELVIEW); - } - gGL.setColorMask(true, false); + shadow_target->bindTarget(); + shadow_target->getViewport(gGLViewport); + shadow_target->clear(); + + U32 target_width = shadow_target->getWidth(); - for (U32 i = 0; i < 16; i++) - { - gGLLastModelView[i] = last_modelview[i]; - gGLLastProjection[i] = last_projection[i]; - } + static LLCullResult result[2]; + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); - popRenderTypeMask(); + renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width); - if (!skip_avatar_update) - { - gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); - } + shadow_target->flush(); + } + } + } + else + { //no spotlight shadows + mShadowSpotLight[0] = mShadowSpotLight[1] = NULL; + } + + + if (!CameraOffset) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); + } + else + { + set_current_modelview(view[1]); + set_current_projection(proj[1]); + gGL.loadMatrix(view[1].m); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.loadMatrix(proj[1].m); + gGL.matrixMode(LLRender::MM_MODELVIEW); + } + gGL.setColorMask(true, false); + + for (U32 i = 0; i < 16; i++) + { + gGLLastModelView[i] = last_modelview[i]; + gGLLastProjection[i] = last_projection[i]; + } + + popRenderTypeMask(); + + if (!skip_avatar_update) + { + gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); + } } void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture) @@ -11468,7 +11025,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG; F32 aspect = tdim.mV[0]/tdim.mV[1]; glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f); - glh_set_current_projection(persp); + set_current_projection(persp); gGL.loadMatrix(persp.m); gGL.matrixMode(LLRender::MM_MODELVIEW); @@ -11479,7 +11036,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat; gGL.loadMatrix(mat.m); - glh_set_current_modelview(mat); + set_current_modelview(mat); glClearColor(0.0f,0.0f,0.0f,0.0f); gGL.setColorMask(true, true); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 29fe1cbd33..b4a8ca004e 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -61,14 +61,7 @@ bool compute_min_max(LLMatrix4& box, LLVector2& min, LLVector2& max); // Shouldn bool LLRayAABB(const LLVector3 ¢er, const LLVector3 &size, const LLVector3& origin, const LLVector3& dir, LLVector3 &coord, F32 epsilon = 0); bool setup_hud_matrices(); // use whole screen to render hud bool setup_hud_matrices(const LLRect& screen_region); // specify portion of screen (in pixels) to render hud attachments from (for picking) -glh::matrix4f glh_copy_matrix(F32* src); -glh::matrix4f glh_get_current_modelview(); -void glh_set_current_modelview(const glh::matrix4f& mat); -glh::matrix4f glh_get_current_projection(); -void glh_set_current_projection(glh::matrix4f& mat); -glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar); -glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar); -glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up); + extern LLTrace::BlockTimerStatHandle FTM_RENDER_GEOMETRY; extern LLTrace::BlockTimerStatHandle FTM_RENDER_GRASS; @@ -91,6 +84,11 @@ extern LLTrace::BlockTimerStatHandle FTM_STATESORT; extern LLTrace::BlockTimerStatHandle FTM_PIPELINE; extern LLTrace::BlockTimerStatHandle FTM_CLIENT_COPY; +extern LLTrace::BlockTimerStatHandle FTM_RENDER_UI_HUD; +extern LLTrace::BlockTimerStatHandle FTM_RENDER_UI_3D; +extern LLTrace::BlockTimerStatHandle FTM_RENDER_UI_2D; +extern LLTrace::BlockTimerStatHandle FTM_RENDER_UI_DEBUG_TEXT; +extern LLTrace::BlockTimerStatHandle FTM_RENDER_UI_SCENE_MON; class LLPipeline { @@ -213,6 +211,8 @@ public: U32 addObject(LLViewerObject *obj); void enableShadows(const bool enable_shadows); + void releaseShadowTargets(); + void releaseShadowTarget(U32 index); // void setLocalLighting(const bool local_lighting); // bool isLocalLightingEnabled() const; @@ -278,15 +278,17 @@ public: void renderGeomDeferred(LLCamera& camera); void renderGeomPostDeferred(LLCamera& camera, bool do_occlusion=true); void renderGeomShadow(LLCamera& camera); - void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, U32 noise_map = 0xFFFFFFFF); + void bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target = nullptr); void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep); void unbindDeferredShader(LLGLSLShader& shader); - void renderDeferredLighting(); - void renderDeferredLightingToRT(LLRenderTarget* target); - + void renderDeferredLighting(LLRenderTarget* light_target); + void postDeferredGammaCorrect(LLRenderTarget* screen_target); + void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); + LLRenderTarget* getShadowTarget(U32 i); + void generateHighlight(LLCamera& camera); void renderHighlight(const LLViewerObject* obj, F32 fade); void setHighlightObject(LLDrawable* obj) { mHighlightObject = obj; } @@ -576,6 +578,7 @@ public: static bool sDynamicLOD; static bool sPickAvatar; static bool sReflectionRender; + static bool sDistortionRender; static bool sImpostorRender; static bool sImpostorRenderAlphaDepthPass; static bool sUnderWaterRender; @@ -589,6 +592,7 @@ public: static S32 sVisibleLightCount; static F32 sMinRenderSize; static bool sRenderingHUDs; + static F32 sDistortionWaterClipPlaneMargin; static LLTrace::EventStatHandle<S64> sStatBatchSize; @@ -607,6 +611,10 @@ public: LLRenderTarget mHighlight; LLRenderTarget mPhysicsDisplay; + LLCullResult mSky; + LLCullResult mReflectedObjects; + LLCullResult mRefractedObjects; + //utility buffer for rendering post effects, gets abused by renderDeferredLighting LLPointer<LLVertexBuffer> mDeferredVB; @@ -625,22 +633,14 @@ public: glh::matrix4f mSunShadowMatrix[6]; glh::matrix4f mShadowModelview[6]; glh::matrix4f mShadowProjection[6]; - glh::matrix4f mGIMatrix; - glh::matrix4f mGIMatrixProj; - glh::matrix4f mGIModelview; - glh::matrix4f mGIProjection; - glh::matrix4f mGINormalMatrix; - glh::matrix4f mGIInvProj; - LLVector2 mGIRange; - F32 mGILightRadius; - - LLPointer<LLDrawable> mShadowSpotLight[2]; - F32 mSpotLightFade[2]; - LLPointer<LLDrawable> mTargetShadowSpotLight[2]; + glh::matrix4f mReflectionModelView; + + LLPointer<LLDrawable> mShadowSpotLight[2]; + F32 mSpotLightFade[2]; + LLPointer<LLDrawable> mTargetShadowSpotLight[2]; LLVector4 mSunClipPlanes; LLVector4 mSunOrthoClipPlanes; - LLVector2 mScreenScale; //water reflection texture @@ -657,9 +657,14 @@ public: U32 mTrueNoiseMap; U32 mLightFunc; - LLColor4 mSunDiffuse; - LLVector3 mSunDir; - LLVector3 mTransformedSunDir; + LLColor4 mSunDiffuse; + LLColor4 mMoonDiffuse; + LLVector4 mSunDir; + LLVector4 mMoonDir; + bool mNeedsShadowTargetClear; + + LLVector4 mTransformedSunDir; + LLVector4 mTransformedMoonDir; bool mInitialized; bool mVertexShadersEnabled; diff --git a/indra/newview/roles_constants.h b/indra/newview/roles_constants.h index 24792dd731..fecf5f9d4a 100644 --- a/indra/newview/roles_constants.h +++ b/indra/newview/roles_constants.h @@ -52,7 +52,6 @@ enum LLRoleChangeType // // KNOWN HOLES: use these for any single bit powers you need -// bit 0x1 << 46 // bit 0x1 << 52 and above // These powers were removed to make group roles simpler @@ -103,6 +102,7 @@ const U64 GP_LAND_ALLOW_CREATE = 0x1LL << 25; // Bypass Create/Edit Objects Re const U64 GP_LAND_ALLOW_LANDMARK = 0x1LL << 26; // Bypass Landmark Restriction const U64 GP_LAND_ALLOW_SET_HOME = 0x1LL << 28; // Bypass Set Home Point Restriction const U64 GP_LAND_ALLOW_HOLD_EVENT = 0x1LL << 41; // Allowed to hold events on group-owned land +const U64 GP_LAND_ALLOW_ENVIRONMENT = 0x1LL << 46; // Allowed to change the environment // Parcel Access const U64 GP_LAND_MANAGE_ALLOWED = 0x1LL << 29; // Manage Allowed List @@ -164,6 +164,7 @@ const U64 GP_DEFAULT_OFFICER = GP_DEFAULT_MEMBER // Superset of GP_DEFAULT_MEMBE | GP_LAND_ALLOW_EDIT_LAND | GP_LAND_ALLOW_FLY | GP_LAND_ALLOW_CREATE + | GP_LAND_ALLOW_ENVIRONMENT | GP_LAND_ALLOW_LANDMARK | GP_LAND_CHANGE_IDENTITY | GP_LAND_CHANGE_MEDIA diff --git a/indra/newview/skins/default/textures/icons/Inv_Settings.png b/indra/newview/skins/default/textures/icons/Inv_Settings.png Binary files differnew file mode 100644 index 0000000000..c43ba349c4 --- /dev/null +++ b/indra/newview/skins/default/textures/icons/Inv_Settings.png diff --git a/indra/newview/skins/default/textures/icons/Inv_SettingsDay.png b/indra/newview/skins/default/textures/icons/Inv_SettingsDay.png Binary files differnew file mode 100644 index 0000000000..258ade1327 --- /dev/null +++ b/indra/newview/skins/default/textures/icons/Inv_SettingsDay.png diff --git a/indra/newview/skins/default/textures/icons/Inv_SettingsSky.png b/indra/newview/skins/default/textures/icons/Inv_SettingsSky.png Binary files differnew file mode 100644 index 0000000000..77858b23c3 --- /dev/null +++ b/indra/newview/skins/default/textures/icons/Inv_SettingsSky.png diff --git a/indra/newview/skins/default/textures/icons/Inv_SettingsWater.png b/indra/newview/skins/default/textures/icons/Inv_SettingsWater.png Binary files differnew file mode 100644 index 0000000000..46fb58c3f2 --- /dev/null +++ b/indra/newview/skins/default/textures/icons/Inv_SettingsWater.png diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 2540ee148d..beffe71863 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -323,6 +323,12 @@ with the same filename but different name <texture name="Inv_Underpants" file_name="icons/Inv_Underpants.png" preload="false" /> <texture name="Inv_Undershirt" file_name="icons/Inv_Undershirt.png" preload="false" /> <texture name="Inv_Link" file_name="icons/Inv_Link.png" preload="false" /> + + <texture name="Inv_Settings" file_name="icons/Inv_Settings.png" preload="false" /> + <texture name="Inv_SettingsSky" file_name="icons/Inv_SettingsSky.png" preload="false" /> + <texture name="Inv_SettingsWater" file_name="icons/Inv_SettingsWater.png" preload="false" /> + <texture name="Inv_SettingsDay" file_name="icons/Inv_SettingsDay.png" preload="false" /> + <texture name="Inv_Invalid" file_name="icons/Inv_Invalid.png" preload="false" /> <texture name="Inv_Unknown" file_name="icons/Inv_UnknownObject.png" preload="false" /> <texture name="Inv_VersionFolderClosed" file_name="icons/Inv_VersionFolderClosed.png" preload="false" /> @@ -684,6 +690,20 @@ with the same filename but different name <texture name="Vertical Drag Handle" file_name="widgets/vertical_drag_handle.png" scale.left="2" scale.right="7" scale.bottom="8" scale.top="120" scale_type="scale_outer"/> + <texture name="VirtualTrackball_Moon_Back" file_name="widgets/track_control_moon_back.png" /> + <texture name="VirtualTrackball_Moon_Front" file_name="widgets/track_control_moon_front.png" /> + <texture name="VirtualTrackball_Rotate_Bottom" file_name="widgets/track_control_rotate_bottom.png" /> + <texture name="VirtualTrackball_Rotate_Left" file_name="widgets/track_control_rotate_left_side.png" /> + <texture name="VirtualTrackball_Rotate_Right" file_name="widgets/track_control_rotate_right_side.png" /> + <texture name="VirtualTrackball_Rotate_Top" file_name="widgets/track_control_rotate_top.png" /> + <texture name="VirtualTrackball_Rotate_Bottom_Active" file_name="widgets/track_control_rotate_bottom_active.png" /> + <texture name="VirtualTrackball_Rotate_Left_Active" file_name="widgets/track_control_rotate_left_side_active.png" /> + <texture name="VirtualTrackball_Rotate_Right_Active" file_name="widgets/track_control_rotate_right_side_active.png" /> + <texture name="VirtualTrackball_Rotate_Top_Active" file_name="widgets/track_control_rotate_top_active.png" /> + <texture name="VirtualTrackball_Sphere" file_name="widgets/track_control_sphere.png" /> + <texture name="VirtualTrackball_Sun_Back" file_name="widgets/track_control_sun_back.png" /> + <texture name="VirtualTrackball_Sun_Front" file_name="widgets/track_control_sun_front.png" /> + <texture name="Volume_Background" file_name="windows/Volume_Background.png" preload="false" scale.left="6" scale.top="33" scale.right="63" scale.bottom="10" /> diff --git a/indra/newview/skins/default/textures/widgets/SliderThumb_Disabled.png b/indra/newview/skins/default/textures/widgets/SliderThumb_Disabled.png Binary files differindex b627232012..8888e134d1 100644 --- a/indra/newview/skins/default/textures/widgets/SliderThumb_Disabled.png +++ b/indra/newview/skins/default/textures/widgets/SliderThumb_Disabled.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_moon_back.png b/indra/newview/skins/default/textures/widgets/track_control_moon_back.png Binary files differnew file mode 100644 index 0000000000..30f538d35b --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_moon_back.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_moon_front.png b/indra/newview/skins/default/textures/widgets/track_control_moon_front.png Binary files differnew file mode 100644 index 0000000000..d3882c5e4c --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_moon_front.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_bottom.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_bottom.png Binary files differnew file mode 100644 index 0000000000..232c812aae --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_bottom.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_bottom_active.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_bottom_active.png Binary files differnew file mode 100644 index 0000000000..911618b08e --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_bottom_active.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_left_side.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_left_side.png Binary files differnew file mode 100644 index 0000000000..bcc78fc5e4 --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_left_side.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_left_side_active.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_left_side_active.png Binary files differnew file mode 100644 index 0000000000..2fe04b93f1 --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_left_side_active.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_right_side.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_right_side.png Binary files differnew file mode 100644 index 0000000000..d0827abf28 --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_right_side.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_right_side_active.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_right_side_active.png Binary files differnew file mode 100644 index 0000000000..824051562f --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_right_side_active.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_top.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_top.png Binary files differnew file mode 100644 index 0000000000..13a5e9c2e8 --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_top.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_rotate_top_active.png b/indra/newview/skins/default/textures/widgets/track_control_rotate_top_active.png Binary files differnew file mode 100644 index 0000000000..9a7493703b --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_rotate_top_active.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_sphere.png b/indra/newview/skins/default/textures/widgets/track_control_sphere.png Binary files differnew file mode 100644 index 0000000000..a13b7725ea --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_sphere.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_sun_back.png b/indra/newview/skins/default/textures/widgets/track_control_sun_back.png Binary files differnew file mode 100644 index 0000000000..23c89068f8 --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_sun_back.png diff --git a/indra/newview/skins/default/textures/widgets/track_control_sun_front.png b/indra/newview/skins/default/textures/widgets/track_control_sun_front.png Binary files differnew file mode 100644 index 0000000000..6dfdc04423 --- /dev/null +++ b/indra/newview/skins/default/textures/widgets/track_control_sun_front.png diff --git a/indra/newview/skins/default/xui/da/strings.xml b/indra/newview/skins/default/xui/da/strings.xml index 74d160dfae..80d75e3194 100644 --- a/indra/newview/skins/default/xui/da/strings.xml +++ b/indra/newview/skins/default/xui/da/strings.xml @@ -560,6 +560,9 @@ Prøv venligst om lidt igen. <string name="mesh"> mesh </string> + <string name="settings"> + indstillinger + </string> <string name="AvatarEditingAppearance"> (Redigering Udseende) </string> diff --git a/indra/newview/skins/default/xui/de/floater_about_land.xml b/indra/newview/skins/default/xui/de/floater_about_land.xml index 1e18ab20e8..4345c0ef15 100644 --- a/indra/newview/skins/default/xui/de/floater_about_land.xml +++ b/indra/newview/skins/default/xui/de/floater_about_land.xml @@ -465,5 +465,6 @@ Nur große Parzellen können in der Suche aufgeführt werden. </panel> </panel> <panel label="ERLEBNISSE" name="land_experiences_panel"/> + <panel label="UMGEBUNG" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/de/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/de/floater_delete_env_preset.xml deleted file mode 100644 index ae7d5ef77d..0000000000 --- a/indra/newview/skins/default/xui/de/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="UMGEB.-VOREINST. LÖSCHEN"> - <string name="title_water"> - Wasser-Voreinstellung löschen - </string> - <string name="title_sky"> - Himmel-Voreinstellung löschen - </string> - <string name="title_day_cycle"> - Tageszyklus löschen - </string> - <string name="label_water"> - Voreinstellung: - </string> - <string name="label_sky"> - Voreinstellung: - </string> - <string name="label_day_cycle"> - Tageszyklus: - </string> - <string name="msg_confirm_deletion"> - Möchten Sie die ausgewählte Voreinstellung wirklich löschen? - </string> - <string name="msg_sky_is_referenced"> - Eine Voreinstellung, auf die sich ein Tageszyklus bezieht, kann nicht gelöscht werden. - </string> - <string name="combo_label"> - -Voreinstellung auswählen- - </string> - <text name="label"> - Voreinstellung: - </text> - <button label="Löschen" name="delete"/> - <button label="Abbrechen" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/de/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/de/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..dd53b470d0 --- /dev/null +++ b/indra/newview/skins/default/xui/de/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="Tageszyklus bearbeiten"> + <string name="title_new"> + Neuen Tageszyklus erstellen + </string> + <string name="title_edit"> + Tageszyklus bearbeiten + </string> + <string name="hint_new"> + Geben Sie einen Namen für den Tageszyklus ein, passen Sie die Steuerungen an, um den Tageszyklus zu erstellen, und klicken Sie auf „Speichern“. + </string> + <string name="hint_edit"> + Um den Tageszyklus zu bearbeiten, passen Sie die unten angezeigten Steuerungen an und klicken Sie auf „Speichern“. + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + Himmel [ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + Name des Tageszyklus: + </text> + <button label="Importieren" name="btn_import" tool_tip="Alte Einstellungen von Datenträger importieren."/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="Himmel 4" name="sky4_track"/> + <button label="Himmel 3" name="sky3_track"/> + <button label="Himmel 2" name="sky2_track"/> + <button label="Bodenhöhe" name="sky1_track"/> + <button label="Wasser" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="Schritt vor"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="Schritt zurück"/> + </layout_panel> + </layout_stack> + <button label="Frame hinzufügen" name="add_frame"/> + <button label="Frame laden" name="btn_load_frame"/> + <button label="Frame löschen" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + Wählen Sie einen Schlüssel-Frame aus der obigen Zeitlinie, um die Einstellungen zu bearbeiten. + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="Wasser" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="Atmosphäre und Beleuchtung" name="atmosphere_panel"/> + <panel label="Wolken" name="clouds_panel"/> + <panel label="Sonne und Mond" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="Speichern" name="save_btn"/> + <button label="Abbrechen" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/de/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/de/floater_fixedenvironment.xml new file mode 100644 index 0000000000..c18e333571 --- /dev/null +++ b/indra/newview/skins/default/xui/de/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="Festgelegte Umgebung"> + <string name="edit_sky"> + Himmel bearbeiten: + </string> + <string name="edit_water"> + Wasser bearbeiten: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="Laden" name="btn_load" tool_tip="Einstellungen aus dem Inventar laden"/> + <button label="Importieren" name="btn_import" tool_tip="Alte Einstellungen von Datenträger importieren."/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="Speichern" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="Abbrechen" name="btn_cancel" tool_tip="Zur zuletzt gespeicherten Version zurückkehren"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/de/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/de/floater_inventory_view_finder.xml index cdacabec90..b361b88aa8 100644 --- a/indra/newview/skins/default/xui/de/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/de/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="Sounds" name="check_sound"/> <check_box label="Texturen" name="check_texture"/> <check_box label="Fotos" name="check_snapshot"/> + <check_box label="Einstellungen" name="check_settings"/> <button label="Alle" label_selected="Alle" name="All"/> <button label="Keine" label_selected="Keine" name="None"/> <check_box label="Ordner immer anzeigen" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/de/floater_my_environments.xml b/indra/newview/skins/default/xui/de/floater_my_environments.xml new file mode 100644 index 0000000000..16f7d6f646 --- /dev/null +++ b/indra/newview/skins/default/xui/de/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="Orte" name="my_environments" title="MEINE UMGEBUNGEN"> + <layout_stack> + <layout_panel label="Filter" name="filter_panel"> + <check_box label="Tage" name="chk_days"/> + <check_box label="Himmel" name="chk_skies"/> + <check_box label="Wasser" name="chk_water"/> + </layout_panel> + <layout_panel label="Umgebungen" name="list_panel"> + <check_box initial_value="false" label="Leere Ordner anzeigen" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="Weitere Optionen"/> + <menu_button name="btn_newsettings" tool_tip="Neue Einstellung erstellen"/> + <button name="btn_del" tool_tip="Diese Einstellung löschen"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/de/floater_settings_picker.xml b/indra/newview/skins/default/xui/de/floater_settings_picker.xml new file mode 100644 index 0000000000..1d8951078f --- /dev/null +++ b/indra/newview/skins/default/xui/de/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="AUSWÄHLEN: EINSTELLUNGEN"> + <floater.string name="choose_picture"> + Klicken, um ein Bild auszuwählen + </floater.string> + <floater.string name="pick title"> + Auswahl: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="Texturen filtern" name="flt_inventory_search"/> + <check_box initial_value="false" label="Ordner anzeigen" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="OK" label_selected="OK" name="btn_select"/> + <button label="Abbrechen" label_selected="Abbrechen" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/de/menu_inventory.xml b/indra/newview/skins/default/xui/de/menu_inventory.xml index e02d464a3d..8aafd16221 100644 --- a/indra/newview/skins/default/xui/de/menu_inventory.xml +++ b/indra/newview/skins/default/xui/de/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="Aktivieren" name="Marketplace Activate"/> <menu_item_call label="Deaktivieren" name="Marketplace Deactivate"/> <menu_item_call label="Teilen" name="Share"/> - <menu_item_call label="Kaufen" name="Task Buy"/> <menu_item_call label="Öffnen" name="Task Open"/> <menu_item_call label="Abspielen" name="Task Play"/> <menu_item_call label="Eigenschaften" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="Neues Haar" name="New Hair"/> <menu_item_call label="Neue Augen" name="New Eyes"/> </menu> + <menu label="Neue Einstellungen" name="New Settings"> + <menu_item_call label="Neuer Himmel" name="New Sky"/> + <menu_item_call label="Neues Wasser" name="New Water"/> + <menu_item_call label="Neuer Tageszyklus" name="New Day Cycle"/> + </menu> <menu label="Als Standard verwenden für" name="upload_def"> <menu_item_call label="Hochgeladene Bilder" name="Image uploads"/> <menu_item_call label="Hochgeladene Sounds" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="Bearbeiten" name="Wearable Edit"/> <menu_item_call label="Hinzufügen" name="Wearable Add"/> <menu_item_call label="Ausziehen" name="Take Off"/> + <menu_item_call label="Nur auf mich anwenden" name="Settings Apply Local"/> + <menu_item_call label="Auf Parzelle anwenden" name="Settings Apply Parcel"/> + <menu_item_call label="Auf Region anwenden" name="Settings Apply Region"/> <menu_item_call label="In Marktplatz-Auflistungen kopieren" name="Marketplace Copy"/> <menu_item_call label="In Marktplatz-Auflistungen verschieben" name="Marketplace Move"/> <menu_item_call label="--keine Optionen--" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/de/menu_inventory_add.xml b/indra/newview/skins/default/xui/de/menu_inventory_add.xml index af70c08ba1..4b4e96045d 100644 --- a/indra/newview/skins/default/xui/de/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/de/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="Sound ([COST] L$)..." name="Upload Sound"/> <menu_item_call label="Animation ([COST] L$)..." name="Upload Animation"/> <menu_item_call label="Modell..." name="Upload Model"/> - <menu_item_call label="Modellassistent..." name="Upload Model Wizard"/> <menu_item_call label="Mehrfach-Upload ([COST] L$ pro Datei)..." name="Bulk Upload"/> - <menu_item_call label="Hochlade-Berechtigungen (Standard) festlegen" name="perm prefs"/> </menu> <menu_item_call label="Neuer Ordner" name="New Folder"/> <menu_item_call label="Neues Skript" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="Neues Haar" name="New Hair"/> <menu_item_call label="Neue Augen" name="New Eyes"/> </menu> + <menu label="Neue Einstellungen" name="New Settings"> + <menu_item_call label="Neuer Himmel" name="New Sky"/> + <menu_item_call label="Neues Wasser" name="New Water"/> + <menu_item_call label="Neuer Tageszyklus" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/de/menu_save_settings.xml b/indra/newview/skins/default/xui/de/menu_save_settings.xml new file mode 100644 index 0000000000..458c3fdc14 --- /dev/null +++ b/indra/newview/skins/default/xui/de/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="Speichern" name="save_settings"/> + <menu_item_check label="Speichern unter" name="save_as_new_settings"/> + <menu_item_check label="Festlegen" name="commit_changes"/> + <menu_item_check label="Nur auf mich anwenden" name="apply_local"/> + <menu_item_check label="Auf Parzelle anwenden" name="apply_parcel"/> + <menu_item_check label="Auf Region anwenden" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/de/menu_settings_add.xml b/indra/newview/skins/default/xui/de/menu_settings_add.xml new file mode 100644 index 0000000000..ebf6c2b314 --- /dev/null +++ b/indra/newview/skins/default/xui/de/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="Neuer Himmel" name="New Sky"/> + <menu_item_call label="Neues Wasser" name="New Water"/> + <menu_item_call label="Neuer Tageszyklus" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/de/menu_settings_gear.xml b/indra/newview/skins/default/xui/de/menu_settings_gear.xml new file mode 100644 index 0000000000..4be4675899 --- /dev/null +++ b/indra/newview/skins/default/xui/de/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="Bearbeiten" name="edit_settings"/> + <menu_item_call label="Nur auf mich anwenden" name="Settings Apply Local"/> + <menu_item_call label="Auf Parzelle anwenden" name="Settings Apply Parcel"/> + <menu_item_call label="Auf Region anwenden" name="Settings Apply Region"/> + <menu_item_call label="Kopieren" name="copy_settings"/> + <menu_item_call label="Einfügen" name="paste_settings"/> + <menu_item_call label="UUID kopieren" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/de/menu_viewer.xml b/indra/newview/skins/default/xui/de/menu_viewer.xml index a71b9b8ef9..b4d5b96803 100644 --- a/indra/newview/skins/default/xui/de/menu_viewer.xml +++ b/indra/newview/skins/default/xui/de/menu_viewer.xml @@ -77,30 +77,14 @@ <menu_item_check label="Parzelleneigenschaften" name="Parcel Properties"/> <menu_item_check label="Menü „Erweitert“" name="Show Advanced Menu"/> </menu> - <menu label="Sonne" name="Sun"> + <menu label="Umgebung" name="Environment"> <menu_item_check label="Sonnenaufgang" name="Sunrise"/> <menu_item_check label="Mittag" name="Noon"/> <menu_item_check label="Sonnenuntergang" name="Sunset"/> <menu_item_check label="Mitternacht" name="Midnight"/> - <menu_item_check label="Regionseinstellungen verwenden" name="Use Region Settings"/> - </menu> - <menu label="Umwelt-Editor" name="Environment Editor"> - <menu_item_call label="Umwelt-Einstellungen..." name="Environment Settings"/> - <menu label="Wasser-Voreinstellungen" name="Water Presets"> - <menu_item_call label="Neue Voreinstellung..." name="new_water_preset"/> - <menu_item_call label="Voreinstellung bearbeiten..." name="edit_water_preset"/> - <menu_item_call label="Voreinstellung löschen..." name="delete_water_preset"/> - </menu> - <menu label="Himmel-Voreinstellungen" name="Sky Presets"> - <menu_item_call label="Neue Voreinstellung..." name="new_sky_preset"/> - <menu_item_call label="Voreinstellung bearbeiten..." name="edit_sky_preset"/> - <menu_item_call label="Voreinstellung löschen..." name="delete_sky_preset"/> - </menu> - <menu label="Tag-Voreinstellungen" name="Day Presets"> - <menu_item_call label="Neue Voreinstellung..." name="new_day_preset"/> - <menu_item_call label="Voreinstellung bearbeiten..." name="edit_day_preset"/> - <menu_item_call label="Voreinstellung löschen..." name="delete_day_preset"/> - </menu> + <menu_item_check label="Gemeinsame Umgebung verwenden" name="Use Shared Environment"/> + <menu_item_call label="Meine Umgebungen..." name="my_environs"/> + <menu_item_check label="Wolken pausieren" name="pause_clouds"/> </menu> </menu> <menu label="Bauen" name="BuildTools"> diff --git a/indra/newview/skins/default/xui/de/notifications.xml b/indra/newview/skins/default/xui/de/notifications.xml index 43af1d8655..164ae7a9d4 100644 --- a/indra/newview/skins/default/xui/de/notifications.xml +++ b/indra/newview/skins/default/xui/de/notifications.xml @@ -1889,7 +1889,7 @@ Tausende Regionen werden verändert und der Spaceserver wird dadurch stark belas <usetemplate canceltext="Abbrechen" name="yesnocancelbuttons" notext="Alle Grundbesitze" yestext="Diesen Grundbesitz"/> </notification> <notification label="Grundbesitz wählen" name="EstateBannedAgentRemove"> - Einwohner nur für diesen Grundbesitz oder für alle [ALL_ESTATES] von der Bannliste entfernen? + Den Einwohner nur für diesen Grundbesitz oder für [ALL_ESTATES] von der Bannliste entfernen? <usetemplate canceltext="Abbrechen" name="yesnocancelbuttons" notext="Alle Grundbesitze" yestext="Diesen Grundbesitz"/> </notification> <notification label="Grundbesitz wählen" name="EstateManagerAdd"> @@ -1936,6 +1936,10 @@ Tausende Regionen werden verändert und der Spaceserver wird dadurch stark belas Durch Deaktivieren dieser Option können Einstellungen der Parzellenbesitzer zum Schutz vor Belästigungen, zur Aufrechterhaltung der Privatsphäre oder zum Schutz von Minderjährigen vor nicht altersgemäßen Inhalten aufgehoben werden. Bitte sprechen Sie mit den Parzellenbesitzern, falls erforderlich. <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + Durch Deaktivieren dieser Option können jegliche benutzerdefinierten Umgebungen entfernt werden, die von den Parzelleneigentümern zu den Parzellen hinzugefügt wurden. Bitte sprechen Sie mit den Parzellenbesitzern, falls erforderlich. + <usetemplate name="okbutton" yestext="OK"/> + </notification> <notification name="RegionEntryAccessBlocked"> Die Region, die Sie besuchen möchten, enthält Inhalte, die Ihre aktuellen Einstellungen überschreiten. Sie können Ihre Einstellungen unter „Ich“ > „Einstellungen“ > „Allgemein“ ändern. <usetemplate name="okbutton" yestext="OK"/> @@ -4364,4 +4368,40 @@ Wählen Sie eine kleinere Landfläche aus. [REASON] <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="FailedToFindSettings"> + Die Einstellungen für [NAME] konnten nicht aus der Datenbank geladen werden. + </notification> + <notification name="FailedToLoadSettingsApply"> + Diese Einstellungen können nicht auf die Umgebung angewendet werden. + </notification> + <notification name="FailedToBuildSettingsDay"> + Diese Einstellungen können nicht auf die Umgebung angewendet werden. + </notification> + <notification name="NoEnvironmentSettings"> + Diese Region unterstützt keine Umgebungseinstellungen. + </notification> + <notification name="WLImportFail"> + Alter Windlight-Einstellungen aus [FILE] können nicht importiert werden. + </notification> + <notification name="WLParcelApplyFail"> + Die Umgebung für diese Parzelle kann nicht eingestellt werden. +Bitte eine Parzelle eingeben oder auswählen, für die Sie die Änderungsrechte besitzen. + </notification> + <notification name="SettingsUnsuported"> + Einstellungen werden von dieser Region nicht unterstützt. +Bitte wechseln sie zu einer Region mit aktivierten Einstellungen und versuchen Sie es erneut. + </notification> + <notification name="SettingsConfirmLoss"> + Sie werden die Änderungen an diesem [TYPE] mit der Bezeichnung "[NAME]" verlieren. +Möchten Sie diesen Vorgang wirklich fortsetzen? + <usetemplate ignoretext="Sind Sie sicher, dass Sie die Änderungen verlieren möchten?" name="okcancelignore" notext="Nein" yestext="Ja"/> + </notification> + <notification name="SettingsMakeNoTrans"> + Sie versuchen, nicht transferierbare Einstellungen in diesen Tageszyklus zu importieren. Wenn Sie fortfahren, verlieren die von Ihnen bearbeiteten Einstellungen ebenfalls ihre Transferierbarkeit. + +Diese Änderung kann nicht rückgängig gemacht werden. + +Möchten Sie diesen Vorgang wirklich fortsetzen? + <usetemplate ignoretext="Sind Sie sicher, dass Sie die Transferierbarkeit der Einstellungen aufgeben möchten?" name="okcancelignore" notext="Nein" yestext="Ja"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/de/panel_region_environment.xml b/indra/newview/skins/default/xui/de/panel_region_environment.xml index 089a3ae5fc..04b6926485 100644 --- a/indra/newview/skins/default/xui/de/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/de/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="Umgebung" name="panel_env_info"> - <text name="water_settings_title"> - Wählen Sie die Wasser- und Himmel-/Tageszykluseinstellungen aus, die alle Besucher Ihrer Region sehen sollen. Mehr Infos - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Second Life-Standard verwenden" name="use_sl_default_settings"/> - <radio_item label="Folgende Einstellungen verwenden" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - Wassereinstellung - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-Voreinstellung auswählen-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - Himmel/Tageszyklus - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="Fester Himmel" name="my_sky_settings"/> - <radio_item label="Tageszyklus" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-Voreinstellung auswählen-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-Voreinstellung auswählen-" name="item0"/> - </combo_box> - </panel> - <button label="Anwenden" name="apply_btn"/> - <button label="Abbrechen" name="cancel_btn"/> + <string name="str_label_use_default"> + Standardeinstellungen verwenden + </string> + <string name="str_label_use_region"> + Regionseinstellungen verwenden + </string> + <string name="str_unknow_inventory"> + Unbekannt + </string> + <string name="str_altitude_desription"> + Himmel [INDEX]([ALTITUDE]m) + </string> + <string name="str_no_parcel"> + Es ist keine Parzelle ausgewählt. Umgebungseinstellungen sind deaktiviert. + </string> + <string name="str_cross_region"> + Umgebungseinstellungen sind außerhalb der Regionsgrenzen nicht verfügbar. + </string> + <string name="str_legacy"> + Umgebungseinstellungen sind für diese Region nicht verfügbar + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="Einstellungen aus dem Inventar" name="rdo_use_inv_setting"/> + <radio_item label="Benutzerdefinierte Umgebung" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + Unbekannt + </line_editor> + <button label="Umgebung bearbeiten" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + Boden + </text> + <text name="alt1"> + Himmel [INDEX]([ALTITUDE]m) + </text> + <text name="alt2"> + Himmel [INDEX]([ALTITUDE]m) + </text> + <text name="alt3"> + Himmel [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="Parzelleneigentümer können die Umgebung außer Kraft setzen" name="chk_allow_override"/> + <button label="Anwenden" name="btn_apply"/> + <button label="Zurücksetzen" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/de/panel_region_estate.xml b/indra/newview/skins/default/xui/de/panel_region_estate.xml index 2a7b654954..dd8a562cb7 100644 --- a/indra/newview/skins/default/xui/de/panel_region_estate.xml +++ b/indra/newview/skins/default/xui/de/panel_region_estate.xml @@ -26,7 +26,7 @@ <check_box label="Direktteleport zulassen" name="allow_direct_teleport"/> <button label="Übernehmen" name="apply_btn"/> <text name="estate_manager_label"> - Grundbesitzsverwalter: + Grundbesitzverwalter: </text> <text name="allow_resident_label"> Immer zugelassen: diff --git a/indra/newview/skins/default/xui/de/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/de/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..f14e3fe47f --- /dev/null +++ b/indra/newview/skins/default/xui/de/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Atmosphäre und Beleuchtung" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/de/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/de/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..9d78728eed --- /dev/null +++ b/indra/newview/skins/default/xui/de/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Wolken" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/de/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/de/panel_settings_sky_density.xml new file mode 100644 index 0000000000..d7ee6308d8 --- /dev/null +++ b/indra/newview/skins/default/xui/de/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Dichte" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Rayleigh-Exponentialterm:" name="rayleigh_exponential"/> + <slider label="Rayleigh-Exponentialskala:" name="rayleigh_exponential_scale"/> + <slider label="Rayleigh-Linearterm:" name="rayleigh_linear"/> + <slider label="Rayleigh-Konstantenterm:" name="rayleigh_constant"/> + <slider label="Rayleigh-Maximalhöhe:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Mie-Exponentialterm:" name="mie_exponential"/> + <slider label="Mie-Exponentialskala:" name="mie_exponential_scale"/> + <slider label="Mie-Linearterm:" name="mie_linear"/> + <slider label="Mie-Konstantenterm:" name="mie_constant"/> + <slider label="Mie-Anisofaktor." name="mie_aniso_factor"/> + <slider label="Mie-Maximalhöhe:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Absorptions-Exponentialterm:" name="absorption_exponential"/> + <slider label="Absorptions-Exponentialskala:" name="absorption_exponential_scale"/> + <slider label="Absorptions-Linearterm:" name="absorption_linear"/> + <slider label="Absorptions-Konstantenterm:" name="absorption_constant"/> + <slider label="Absorptions-Maximalhöhe:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/de/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/de/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..7778a9fbc3 --- /dev/null +++ b/indra/newview/skins/default/xui/de/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Sonne und Mond" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/de/panel_settings_water.xml b/indra/newview/skins/default/xui/de/panel_settings_water.xml new file mode 100644 index 0000000000..f11f50dcce --- /dev/null +++ b/indra/newview/skins/default/xui/de/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Wasser" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + Fresnel-Versatz: + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X:" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/de/strings.xml b/indra/newview/skins/default/xui/de/strings.xml index cde04d8d69..f80b1ee1ec 100644 --- a/indra/newview/skins/default/xui/de/strings.xml +++ b/indra/newview/skins/default/xui/de/strings.xml @@ -635,6 +635,15 @@ Warten Sie kurz und versuchen Sie dann noch einmal, sich anzumelden. <string name="BUTTON_HELP"> Hilfe anzeigen </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + Objekte dieses Typs können nicht an +die Region angehängt werden. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + An Notizkarten können nur Objekte +ohne Einschränkungen für den +nächsten Eigentümer angehängt werden. + </string> <string name="Searching"> Suchen... </string> @@ -786,6 +795,9 @@ besuchen Sie bitte http://secondlife.com/support <string name="symbolic link"> Link </string> + <string name="settings blob"> + Einstellungen + </string> <string name="symbolic folder link"> Link zu Ordner </string> @@ -2489,6 +2501,9 @@ Falls diese Meldung weiterhin angezeigt wird, wenden Sie sich unter http://suppo <string name="RegionSettings"> Regionseinstellungen </string> + <string name="NoEnvironmentSettings"> + Diese Region unterstützt keine Umgebungseinstellungen. + </string> <string name="ClassifiedClicksTxt"> Klicks: [TELEPORT] teleportieren, [MAP] Karte, [PROFILE] Profil </string> @@ -4831,6 +4846,15 @@ Missbrauchsbericht <string name="Female - Wow"> Weiblich - Wow </string> + <string name="New Daycycle"> + Neuer Tageszyklus + </string> + <string name="New Water"> + Neues Wasser + </string> + <string name="New Sky"> + Neuer Himmel + </string> <string name="/bow"> /verbeugen </string> diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 535af317d9..37c4e3ff8d 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -2106,8 +2106,20 @@ Only large parcels can be listed in search. top="0" help_topic="land_experiences_tab" name="land_experiences_panel" - class="land_experiences_panel" + class="land_experiences_panel" filename="panel_region_experiences.xml"> </panel> + <panel + border="true" + follows="all" + label="ENVIRONMENT" + layout="topleft" + left="0" + top="0" + help_topic="land_environment_tab" + name="land_environment_panel" + class="land_environment_panel" + filename="panel_region_environment.xml"> + </panel> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/en/floater_beacons.xml b/indra/newview/skins/default/xui/en/floater_beacons.xml index 3d29356b22..d5947fc0af 100644 --- a/indra/newview/skins/default/xui/en/floater_beacons.xml +++ b/indra/newview/skins/default/xui/en/floater_beacons.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <floater legacy_header_height="18" - height="245" + height="310" layout="topleft" name="beacons" help_topic="beacons" @@ -12,7 +12,7 @@ width="240"> <panel follows="left|top|right|bottom" - height="240" + height="305" layout="topleft" left="10" name="beacons_panel" @@ -143,6 +143,43 @@ <check_box.commit_callback function="Beacons.UICheck" /> </check_box> + <view_border + bevel_style="in" + height="0" + layout="topleft" + left="0" + name="cost_text_border" + top_pad="5" + width="220"/> + <text + follows="all" + height="16" + font="SansSerif" + left="0" + top_pad="7" + name="label_objects" + text_color="White" + type="string"> + Show direction to: + </text> + <check_box + control_name="sunbeacon" + height="16" + label="Sun" + layout="topleft" + name="sun" > + <check_box.commit_callback + function="Beacons.UICheck" /> + </check_box> + <check_box + control_name="moonbeacon" + height="16" + label="Moon" + layout="topleft" + name="moon" > + <check_box.commit_callback + function="Beacons.UICheck" /> + </check_box> </panel> </floater> diff --git a/indra/newview/skins/default/xui/en/floater_bulk_perms.xml b/indra/newview/skins/default/xui/en/floater_bulk_perms.xml index e7ab3cacdc..b4577f54e6 100644 --- a/indra/newview/skins/default/xui/en/floater_bulk_perms.xml +++ b/indra/newview/skins/default/xui/en/floater_bulk_perms.xml @@ -156,7 +156,20 @@ name="icon_texture" tool_tip="Textures" left_pad="2" /> - + <check_box + control_name="BulkChangeIncludeSettings" + height="16" + name="check_settings" + left="245" + top="25" + width="16" /> + <icon + height="16" + image_name="Inv_Settings" + mouse_opaque="true" + name="icon_setting" + tool_tip="Environment settings" + left_pad="2" /> <button height="23" layout="topleft" diff --git a/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml deleted file mode 100644 index b5de4166f6..0000000000 --- a/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<floater - legacy_header_height="18" - height="130" - help_topic="" - layout="topleft" - name="Delete Env Preset" - save_rect="true" - title="DELETE ENV PRESET" - width="550"> - - <string name="title_water">Delete Water Preset</string> - <string name="title_sky">Delete Sky Preset</string> - <string name="title_day_cycle">Delete Day Cycle</string> - - <string name="label_water">Preset:</string> - <string name="label_sky">Preset:</string> - <string name="label_day_cycle">Day cycle:</string> - - <string name="msg_confirm_deletion">Are you sure you want to delete the selected preset?</string> - <string name="msg_sky_is_referenced">Cannot remove a preset that is referenced by some day cycle(s).</string> - - <string name="combo_label">-Select a preset-</string> - - <text - follows="top|left|right" - font="SansSerif" - height="10" - layout="topleft" - left="50" - name="label" - top="60" - width="60"> - Preset: - </text> - <combo_box - follows="top|left" - layout="topleft" - left_pad="10" - name="preset_combo" - top_delta="-5" - width="200"/> - <button - follows="bottom|right" - height="23" - label="Delete" - layout="topleft" - left_pad="15" - name="delete" - width="70"/> - <button - follows="bottom|right" - height="23" - label="Cancel" - layout="topleft" - left_pad="5" - name="cancel" - width="70"/> -</floater> diff --git a/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml deleted file mode 100644 index d9a3ad0c4b..0000000000 --- a/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml +++ /dev/null @@ -1,485 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<floater - legacy_header_height="18" - height="381" - layout="topleft" - name="Edit Day cycle" - help_topic="day_presets" - save_rect="true" - title="Edit Day Cycle" - width="705"> - - <string name="title_new">Create a New Day Cycle</string> - <string name="title_edit">Edit Day Cycle</string> - <string name="hint_new">Name your day cycle, adjust the controls to create it, and click "Save".</string> - <string name="hint_edit">To edit your day cycle, adjust the controls below and click "Save".</string> - <string name="combo_label">-Select a preset-</string> - - <text - follows="top|left|right" - height="10" - layout="topleft" - left="10" - name="hint" - top="25" - width="685" /> - <text - follows="top|left|right" - font="SansSerif" - height="10" - layout="topleft" - left="10" - name="label" - top_pad="25" - width="120"> - Preset Name: - </text> - <combo_box - allow_text_entry="true" - follows="top|left" - layout="topleft" - left_pad="10" - max_chars="100" - name="day_cycle_combo" - top_delta="-5" - width="200" /> - <line_editor - height="20" - left_delta="0" - name="day_cycle_name" - top_delta="0" - visible="true" - width="200" /> - <text - follows="top|left|right" - height="95" - layout="topleft" - left_pad="10" - name="note" - top_delta="0" - width="345" - wrap="true"> - Note: if you change the name of your preset, you will be creating a new preset and the existing preset will not be changed. - </text> - <!--======== Controls panel ========--> - <text - follows="left|top|right" - height="10" - layout="topleft" - left="10" - name="hint_item1" - top="100" - width="300"> - - Click on a tab to edit the specific sky settings and time. - </text> - <text - follows="left|top|right" - height="10" - layout="topleft" - name="hint_item2" - top_pad="10" - width="300"> - - Click and drag the tabs to set the transition times. - </text> - <text - follows="left|top|right" - height="10" - layout="topleft" - name="hint_item3" - top_pad="10" - width="300"> - - Use the scrubber to preview your day cycle. - </text> - <panel - follows="top|left" - height="100" - name="day_cycle_slider_panel" - layout="topleft" - left_delta="25" - top_pad="15" - width="660"> - <multi_slider - can_edit_text="true" - control_name="WLTimeSlider" - decimal_digits="0" - draw_track="false" - follows="bottom" - height="10" - increment="0.0833333" - initial_value="0" - layout="topleft" - left="20" - max_sliders="20" - max_val="24" - name="WLTimeSlider" - show_text="false" - top_pad="0" - use_triangle="true" - width="525" /> - <multi_slider - can_edit_text="true" - control_name="WLDayCycleKeys" - decimal_digits="0" - follows="bottom" - height="10" - increment="0.0833333" - initial_value="0" - layout="topleft" - left_delta="0" - max_sliders="20" - max_val="24" - name="WLDayCycleKeys" - show_text="false" - top_pad="15" - width="525" /> - <button - height="20" - label="Add Key" - label_selected="Add Key" - layout="topleft" - left_pad="20" - name="WLAddKey" - top_delta="-18" - width="96" /> - <button - height="20" - label="Delete Key" - label_selected="Delete Key" - layout="topleft" - name="WLDeleteKey" - top_pad="5" - width="96" /> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left="8" - name="WL12am" - top="74" - width="55"> - 12am - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL3am" - top_delta="0" - width="55"> - 3am - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL6am" - top_delta="0" - width="55"> - 6am - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL9amHash" - top_delta="0" - width="55"> - 9am - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL12pmHash" - top_delta="0" - width="55"> - 12pm - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL3pm" - top_delta="0" - width="55"> - 3pm - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL6pm" - top_delta="0" - width="55"> - 6pm - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL9pm" - top_delta="0" - width="55"> - 9pm - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="10" - name="WL12am2" - top_delta="0" - width="55"> - 12am - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left="20" - name="WL12amHash" - top="54" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="11" - layout="topleft" - left_pad="59" - name="WL3amHash" - top_delta="3" - width="6"> - I - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="59" - name="WL6amHash" - top_delta="-3" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="11" - layout="topleft" - left_pad="59" - name="WL9amHash2" - top_delta="3" - width="6"> - I - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="59" - name="WL12pmHash2" - top_delta="-3" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="11" - layout="topleft" - left_pad="59" - name="WL3pmHash" - top_delta="3" - width="6"> - I - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="59" - name="WL6pmHash" - top_delta="-3" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="11" - layout="topleft" - left_pad="59" - name="WL9pmHash" - top_delta="3" - width="6"> - I - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="59" - name="WL12amHash2" - top_delta="-3" - width="6"> - | - </text> - </panel> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="16" - layout="topleft" - left_delta="192" - name="WLCurKeyPresetText" - top_pad="10" - width="80"> - Sky Setting: - </text> - <combo_box - height="18" - label="Preset" - layout="topleft" - left_pad="5" - name="WLSkyPresets" - width="205" /> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-40" - name="WLCurKeyTimeText" - top_pad="15" - width="35"> - Time: - </text> - <time - follows="left|top" - height="16" - label_width="0" - layout="topleft" - left_pad="3" - name="time" - top_delta="-1" - value="6:00 AM" - width="75"/> - <view_border - bevel_style="none" - follows="top|left" - height="0" - layout="topleft" - left="10" - name="horiz_separator" - top_pad="20" - width="685"/> - <loading_indicator - height="23" - layout="topleft" - left="25" - name="progress_indicator" - top="350" - visible="false" - width="23" /> - <check_box - follows="top|left" - height="10" - label="Make this my new day cycle" - layout="topleft" - left="310" - name="make_default_cb" - top_delta="13" - width="230"/> - <button - follows="bottom|right" - height="23" - label="Save" - layout="topleft" - left_pad="0" - name="save" - top_delta="-13" - width="70"/> - <button - follows="bottom|right" - height="23" - label="Cancel" - layout="topleft" - left_pad="15" - name="cancel" - top_delta="0" - width="70"/> - </floater> diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..1b5bd90748 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -0,0 +1,652 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + layout="topleft" + name="env_edit_extdaycycle" + help_topic="day_presets" + save_rect="false" + title="Edit Day Cycle" + width="705" + height="700" + min_width="705" + min_height="700" + single_instance="true" + can_resize="false"> + + <!-- obsolete?, add as hint for 'save' button? --> + <string name="title_new">Create a New Day Cycle</string> + <string name="title_edit">Edit Day Cycle</string> + <string name="hint_new">Name your day cycle, adjust the controls to create it, and click "Save".</string> + <string name="hint_edit">To edit your day cycle, adjust the controls below and click "Save".</string> + + <!-- Substitutions --> + <string name="time_label"> ([HH]:[MM])</string> + <string name="sky_track_label">Sky [ALT]</string> + <string name="sky_label">Sky</string> + <string name="water_label">Water</string> + + <string name="commit_parcel">Apply To Parcel</string> + <string name="commit_region">Apply To Region</string> + + <!-- Layout --> + <layout_stack name="outer_stack" + width="705" + height="700" + follows="all" + animate="false" + top="0" + orientation="vertical"> + <layout_panel name="name_and_import" + border="false" + auto_resize="false" + user_resize="false" + height="29" + min_height="29" + background_visible="false"> + <!-- This layout_panel is for loading legacy presets --> + <text + follows="top|left" + font="SansSerif" + height="10" + layout="topleft" + name="label" + left="15" + top="5" + width="105"> + Day Cycle Name: + </text> + <line_editor + follows="top|left" + layout="topleft" + left_pad="10" + max_length_bytes="100" + name="day_cycle_name" + prevalidate_callback="ascii" + top="5" + width="200" + height="21" /> + <button + height="23" + label="Import" + follows="right|top" + right="-10" + font="SansSerif" + top_delta="0" + name="btn_import" + tool_tip="Import legacy settings from disk." + width="96" /> + </layout_panel> + <layout_panel name="content" + border="false" + auto_resize="true" + user_resize="false" + background_visible="false"> + <layout_stack name="content_stack" + width="705" + follows="all" + animate="false" + top="0" + orientation="vertical"> + <layout_panel name="timeline_track_selection" + border="false" + bevel_style="in" + auto_resize="false" + user_resize="false" + height="150" + min_height="0" + visible="true"> + <panel name="timeline_layers" + border="false" + follows="left|top" + height="150" + width="110" + top_pad="0" + min_height="0" + visible="true"> + <button + follows="left|top" + height="23" + label="Sky 4" + layout="topleft" + top_pad="5" + left="10" + name="sky4_track" + width="100"> + <button.commit_callback + function="DayCycle.Track" + parameter="4" /> + </button> + <button + follows="left|top" + height="23" + label="Sky 3" + layout="topleft" + top_pad="0" + left="10" + name="sky3_track" + width="100"> + <button.commit_callback + function="DayCycle.Track" + parameter="3" /> + </button> + <button + follows="left|top" + height="23" + label="Sky 2" + layout="topleft" + top_pad="0" + left="10" + name="sky2_track" + width="100"> + <button.commit_callback + function="DayCycle.Track" + parameter="2" /> + </button> + <button + follows="left|top" + height="23" + label="Ground Level" + layout="topleft" + top_pad="0" + left="10" + name="sky1_track" + width="100"> + <button.commit_callback + function="DayCycle.Track" + parameter="1" /> + </button> + <button + follows="left|top" + height="23" + label="Water" + layout="topleft" + top_pad="0" + left="10" + name="water_track" + width="100"> + <button.commit_callback + function="DayCycle.Track" + parameter="0" /> + </button> + </panel> + <panel name="timeline" + border="true" + follows="left|top" + height="150" + min_height="0" + width="595" + min_width="595" + left_pad="0" + visible="true"> + <!-- Todo: These 5 tests might be subjected to a change to be dynamically generated, consider using layout_stack to get dynamic width adjustment--> + <text + follows="left|top" + height="15" + layout="topleft" + left="10" + name="p0" + top_pad="5" + value="0%[DSC]" + width="80" /> + <text + follows="left|top|right" + height="15" + layout="topleft" + left_pad="37" + name="p1" + top_delta="0" + value="25%[DSC]" + width="80" /> + <text + follows="left|top|right" + height="15" + layout="topleft" + left_pad="42" + name="p2" + top_delta="0" + value="50%[DSC]" + width="80" /> + <text + follows="left|top|right" + height="15" + layout="topleft" + left_pad="42" + name="p3" + top_delta="0" + value="75%[DSC]" + width="80" /> + <text + follows="left|top|right" + height="15" + layout="topleft" + left_pad="42" + name="p4" + top_delta="0" + value="100%[DSC]" + width="80" /> + <multi_slider + decimal_digits="0" + draw_track="false" + follows="bottom" + height="10" + increment="0.005" + overlap_threshold="0.026" + initial_value="0" + layout="topleft" + left="10" + max_sliders="1" + max_val="1" + name="WLTimeSlider" + show_text="false" + top_pad="0" + use_triangle="true" + width="525" /> + + <multi_slider + decimal_digits="0" + follows="bottom" + height="12" + increment="0.005" + overlap_threshold="0.026" + loop_overlap="true" + initial_value="0" + layout="topleft" + left="10" + max_sliders="20" + max_val="1" + name="WLDayCycleFrames" + show_text="false" + thumb_highlight_color="white" + thumb_width="12" + top_pad="15" + width="525" /> + + <text + follows="left|bottom" + height="20" + layout="topleft" + left_pad="0" + name="current_time" + value="[PRCNT]%[DSC]" + top_delta="-5" + width="70" /> + + <layout_stack + follows="all" + height="200" + animate="false" + top_pad="5" + left="0" + orientation="horizontal"> + <layout_panel + border="false" + bevel_style="in" + auto_resize="false" + user_resize="false" + height="150" + width="200" + min_height="0" + visible="true"> + <button + follows="top|left" + height="23" + width="90" + label="Clone From" + left="10" + top_pad="10" + name="copy_track" /> + <button + follows="top|left" + height="23" + width="90" + label="Load From" + top_pad="0" + left_delta="0" + name="load_track" /> + <button + follows="top|left" + height="23" + width="90" + label="Clear" + top_pad="0" + left_delta="0" + name="clear_track" /> + + </layout_panel> + <layout_panel + border="false" + bevel_style="in" + auto_resize="false" + user_resize="false" + height="150" + width="200" + min_height="0" + visible="true"> + <layout_stack + name="progress_control" + follows="top|left" + height="25" + width="83" + layout="topleft" + animate="false" + left="31" + top="40" + orientation="horizontal"> + + <layout_panel + name="skip_back" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25"> + <button + name="skip_back_btn" + follows="top" + image_overlay="SkipBackward_Off" + image_disabled="PushButton_Disabled" + image_disabled_selected="PushButton_Disabled" + image_selected="PushButton_Selected" + image_unselected="PushButton_Off" + hover_glow_amount="0.15" + auto_resize="false" + width="25" + height="25" + layout="topleft" + tool_tip="Step back" + top="0" + left="0"> + <button.commit_callback + function="DayCycle.PlayActions" + parameter="back" /> + </button> + </layout_panel> + + <layout_panel + name="play_layout" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25"> + <button + name="play_btn" + follows="top" + image_overlay="Play_Off" + image_disabled="PushButton_Disabled" + image_disabled_selected="PushButton_Disabled" + image_selected="PushButton_Selected" + image_unselected="PushButton_Off" + hover_glow_amount="0.15" + auto_resize="false" + layout="topleft" + height="25" + width="25" + left="0" + top="0"> + <button.commit_callback + function="DayCycle.PlayActions" + parameter="play" /> + </button> + </layout_panel> + + <layout_panel + name="pause_layout" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25" + visible="false"> + <button + name="pause_btn" + follows="top" + image_overlay="Pause_Off" + image_disabled="PushButton_Disabled" + image_disabled_selected="PushButton_Disabled" + image_selected="PushButton_Selected" + image_unselected="PushButton_Off" + hover_glow_amount="0.15" + auto_resize="false" + layout="topleft" + height="25" + width="25" + left="0" + top="0"> + <button.commit_callback + function="DayCycle.PlayActions" + parameter="pause" /> + </button> + </layout_panel> + + <layout_panel + name="skip_forward" + mouse_opaque="false" + auto_resize="false" + layout="topleft" + top="0" + height="25" + min_width="25" + width="25"> + <button + name="skip_forward_btn" + follows="top" + image_overlay="SkipForward_Off" + image_disabled="PushButton_Disabled" + image_disabled_selected="PushButton_Disabled" + image_selected="PushButton_Selected" + image_unselected="PushButton_Off" + hover_glow_amount="0.15" + width="25" + height="25" + layout="topleft" + tool_tip="Step forward" + top="0"> + <button.commit_callback + function="DayCycle.PlayActions" + parameter="forward" /> + </button> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel + border="false" + bevel_style="in" + auto_resize="false" + user_resize="false" + width="190" + height="150" + min_height="0" + visible="true"> + <button + + follows="top|right" + height="23" + width="90" + right="-10" + top_pad="10" + label="Add [FRAME]" + name="add_frame" /> + <button + follows="top|left" + height="23" + width="90" + label="Load [FRAME]" + top_pad="0" + left_delta="0" + name="btn_load_frame" /> + <button + follows="left|top" + height="23" + width="90" + label="Delete [FRAME]" + top_pad="0" + left_delta="0" + name="delete_frame" /> + </layout_panel> + </layout_stack> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls" + auto_resize="false" + user_resize="false" + height="30" + width="700" + min_height="30" + visible="true"> + <!--bg_alpha_color="blue" + background_visible="true" --> + <text + name="icn_lock_edit" + follows="bottom" + height="10" + layout="bottomleft" + left_delta="15" + top_pad="15" + font="SansSerif" + text_color="Yellow" + width="500"> + Select a key frame from the timeline above to edit settings. + </text> + </layout_panel> + <layout_panel name="frame_settings_water" + auto_resize="true" + user_resize="false" + height="420" + width="700" + min_height="0" + visible="false"> + <tab_container + follows="all" + halign="left" + height="420" + layout="topleft" + left="0" + name="water_tabs" + tab_position="top" + tab_width="140" + tab_padding_right="3" + top_pad="0" + width="700"> + <panel + border="true" + class="panel_settings_water" + filename="panel_settings_water.xml" + label="Water" + layout="topleft" + left_delta="0" + top_pad="5" + name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky" + auto_resize="true" + user_resize="false" + height="420" + width="700" + min_height="0" + visible="true"> + <tab_container + follows="all" + halign="left" + height="420" + visible="true" + layout="topleft" + left="0" + name="sky_tabs" + tab_position="top" + tab_width="140" + tab_padding_right="3" + top_pad="0" + width="700"> + <panel + border="true" + class="panel_settings_atmos" + filename="panel_settings_sky_atmos.xml" + label="Atmosphere & Lighting" + layout="topleft" + left_delta="0" + top_pad="5" + name="atmosphere_panel" /> + <panel + border="true" + class="panel_settings_cloud" + filename="panel_settings_sky_clouds.xml" + label="Clouds" + layout="topleft" + left_delta="0" + top_pad="5" + name="clouds_panel" /> + <panel + border="true" + class="panel_settings_sunmoon" + filename="panel_settings_sky_sunmoon.xml" + label="Sun & Moon" + layout="topleft" + left_delta="0" + top_pad="5" + name="moon_panel" /> + <!-- added programatically so it doesn't show up whether we want it or not + <panel + border="true" + class="panel_settings_density" + filename="panel_settings_sky_density.xml" + label="Density" + layout="topleft" + left_delta="0" + top_pad="5" + name="density_panel" /> + --> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons" + auto_resize="false" + user_resize="false" + height="26" + min_height="26" + visible="true" + width="700"> + <button + follows="top|left" + height="23" + label="Save" + left="5" + top_pad="0" + name="save_btn" + width="156" /> + + <button + follows="top|left" + height="23" + name="btn_flyout" + label="" + layout="topleft" + left_pad="-20" + top="0" + image_selected="SegmentedBtn_Right_Selected_Press" + image_unselected="SegmentedBtn_Right_Off" + image_pressed="SegmentedBtn_Right_Press" + image_pressed_selected="SegmentedBtn_Right_Selected_Press" + image_overlay="Arrow_Small_Up" + width="20"/> + + <button + follows="top|left" + height="23" + label="Cancel" + layout="topleft" + left_pad="10" + name="cancel_btn" + width="150" /> + + </layout_panel> + </layout_stack> + +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml deleted file mode 100644 index 56233d91ee..0000000000 --- a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml +++ /dev/null @@ -1,953 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<floater - legacy_header_height="18" - height="375" - layout="topleft" - name="Edit Sky Preset" - help_topic="sky_preset" - save_rect="true" - title="Edit Sky Preset" - width="840"> - - <string name="title_new">Create a New Sky Preset</string> - <string name="title_edit">Edit Sky Preset</string> - <string name="hint_new">Name your preset, adjust the controls to create it, and click "Save".</string> - <string name="hint_edit">To edit your sky preset, adjust the controls and click "Save".</string> - <string name="combo_label">-Select a preset-</string> - - <text - follows="top|left|right" - height="10" - layout="topleft" - left="30" - name="hint" - top="25" - width="700"> - To edit your preset, adjust the controls then click "Save" - </text> - <text - follows="top|left|right" - font="SansSerif" - height="10" - layout="topleft" - left="30" - name="label" - top_pad="25" - width="120"> - Preset Name: - </text> - <combo_box - allow_text_entry="true" - follows="top|left" - layout="topleft" - left_pad="10" - max_chars="100" - name="sky_preset_combo" - top_delta="-5" - width="200"/> - <line_editor - height="20" - left_delta="0" - name="sky_preset_name" - top_delta="0" - width="200" /> - <text - follows="top|left|right" - height="40" - layout="topleft" - left_pad="10" - name="note" - top_delta="0" - width="405" - wrap="true"> - Note: if you change the name of your preset, you will be creating a new preset and the existing preset will not be changed. - </text> - <!--======== Controls panel ========--> - <view_border - bevel_style="none" - follows="top|left" - height="203" - layout="topleft" - left="25" - name="panel_water_preset" - top="122" - visible="true" - width="790"/> - <tab_container - follows="left|top" - height="225" - halign="center" - layout="topleft" - left="22" - name="WindLight Tabs" - tab_position="top" - top="101" - width="794"> - <panel - border="true" - bevel_style="none" - follows="left|top|right|bottom" - height="196" - label="ATMOSPHERE" - layout="topleft" - left="1" - help_topic="sky_preset_atmosphere" - mouse_opaque="false" - name="Atmosphere" - top="60" - width="698"> - - <!--======== Tab Panel I. I conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left="40" - name="BHText" - top="25" - width="200"> - Blue Horizon - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="37" - label_height="0" - layout="topleft" - left_delta="0" - name="WLBlueHorizon" - top_pad="6" - width="60" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="0" - top_pad="20" - name="BDensText" - width="200"> - Haze Horizon - </text> - <slider - control_name="WLHazeHorizon" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.25" - layout="topleft" - left_delta="0" - top_pad="6" - name="WLHazeHorizon" - width="200" /> - - <!--======== Tab Panel I. II conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="55" - name="BDensText2" - top="25" - width="200"> - Blue Density - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="37" - label_height="0" - layout="topleft" - left_delta="0" - name="WLBlueDensity" - top_pad="6" - width="60" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="0" - name="HDText" - top_pad="20" - width="200"> - Haze Density - </text> - <slider - control_name="WLHazeDensity" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.7" - layout="topleft" - left_delta="0" - max_val="4" - name="WLHazeDensity" - top_pad="6" - width="200" /> - - <!--======== Tab Panel I. III conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="55" - name="DensMultText" - top="25" - width="200"> - Density Multiplier - </text> - <slider - control_name="WLDensityMult" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.1" - layout="topleft" - left_delta="15" - max_val="0.9" - name="WLDensityMult" - top_pad="6" - width="200" /> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-15" - name="WLDistanceMultText" - top_pad="20" - width="200"> - Distance Multiplier - </text> - <slider - control_name="WLDistancMult" - decimal_digits="1" - follows="left|top" - height="10" - initial_value="1.0" - layout="topleft" - left_delta="15" - max_val="100" - name="WLDistanceMult" - top_pad="6" - width="200" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-15" - name="MaxAltText" - top_pad="20" - width="200"> - Max Altitude - </text> - <slider - control_name="WLMaxAltitude" - decimal_digits="0" - follows="left|top" - height="10" - increment="1" - initial_value="500" - layout="topleft" - left_delta="15" - max_val="4000" - name="WLMaxAltitude" - top_pad="6" - width="200" /> - </panel> - <panel - border="true" - bevel_style="none" - follows="left|top|right|bottom" - height="196" - label="LIGHTING" - layout="topleft" - left_delta="0" - help_topic="sky_preset_lighting" - name="Lighting" - top_delta="4" - width="698"> - - <!--======== Tab Panel II. I conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left="20" - name="SLCText" - top="25" - width="150"> - Sun/Moon Color - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="37" - label_height="0" - layout="topleft" - left_delta="10" - name="WLSunlight" - top_pad="6" - width="60" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-10" - name="WLAmbientText" - top_pad="20" - width="150"> - Ambient - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="37" - label_height="0" - layout="topleft" - left_delta="10" - name="WLAmbient" - top_pad="6" - width="60" /> - - <!--======== Tab Panel II. II conlumn of controls ========--> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="100" - name="SunGlowText" - top="25" - width="200"> - Sun Glow - </text> - <slider - control_name="WLGlowB" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.1" - label="Focus " - layout="topleft" - left_delta="10" - max_val="0.5" - name="WLGlowB" - top_pad="6" - width="200" /> - <slider - control_name="WLGlowR" - decimal_digits="2" - follows="top|left" - height="10" - increment="0.01" - initial_value="0.25" - label="Size " - layout="topleft" - left_delta="0" - max_val="1.99" - min_val="1" - name="WLGlowR" - top_pad="6" - width="200" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-10" - name="WLStarText" - top_pad="20" - width="200"> - Star Brightness - </text> - <slider - control_name="WLStarAlpha" - decimal_digits="2" - follows="top|left" - height="10" - increment="0.01" - initial_value="0" - layout="topleft" - left_delta="10" - max_val="2" - name="WLStarAlpha" - top_pad="6" - width="200" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-10" - name="SceneGammaText" - top_pad="20" - width="200"> - Scene Gamma - </text> - <slider - control_name="WLGamma" - decimal_digits="2" - follows="top|left" - height="10" - increment="0.01" - initial_value="2.0" - layout="topleft" - left_delta="10" - max_val="10" - name="WLGamma" - top_pad="6" - width="200" /> - - <!--======== Tab Panel II. III conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="60" - name="TODText" - top="25" - width="200"> - Sun/Moon Position - </text> - <multi_slider - can_edit_text="true" - control_name="WLSunPos" - decimal_digits="0" - follows="bottom" - height="10" - increment="0.0833333" - initial_value="0" - layout="topleft" - left_delta="0" - max_sliders="1" - max_val="24" - name="WLSunPos" - show_text="false" - top_pad="0" - width="300" /> - - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_delta="2" - name="WL12amHash" - top_pad="6" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="66" - name="WL6amHash" - top_delta="0" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="67" - name="WL12pmHash2" - top_delta="0" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="67" - name="WL6pmHash" - top_delta="0" - width="6"> - | - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - font="SansSerif" - height="14" - layout="topleft" - left_pad="67" - name="WL12amHash2" - top_delta="0" - width="6"> - | - </text> - - - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_delta="-300" - name="WL12am" - top="74" - width="55"> - 12am - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="20" - name="WL6am" - top_delta="0" - width="55"> - 6am - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="15" - name="WL12pmHash" - top_delta="0" - width="55"> - 12pm - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="18" - name="WL6pm" - top_delta="0" - width="55"> - 6pm - </text> - <text - type="string" - length="1" - border_visible="true" - follows="left|top|right" - height="16" - layout="topleft" - left_pad="15" - name="WL12am2" - top_delta="0" - width="55"> - 12am - </text> - - <time - follows="left|top" - height="16" - label_width="0" - layout="topleft" - left_delta="-175" - name="WLDayTime" - top_pad="15" - value="6:00 AM" - width="75"/> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-106" - name="WLEastAngleText" - top_pad="24" - width="200"> - East Angle - </text> - <slider - control_name="WLEastAngle" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.0" - layout="topleft" - left_delta="10" - name="WLEastAngle" - top_pad="6" - width="200" /> - - </panel> - <panel - border="true" - bevel_style="none" - follows="left|top|right|bottom" - height="196" - label="CLOUDS" - layout="topleft" - left_delta="0" - mouse_opaque="false" - help_topic="sky_preset_clouds" - name="Clouds" - top_delta="4" - width="698"> - - <!--======== Tab Panel III. I conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left="40" - name="WLCloudColorText" - top="25" - width="200"> - Cloud Color - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="37" - label_height="0" - layout="topleft" - left_delta="0" - name="WLCloudColor" - top_pad="6" - width="60" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="0" - name="WLCloudColorText2" - top_pad="20" - width="200"> - Cloud XY/Density - </text> - <slider - control_name="WLCloudX" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.5" - label="X" - layout="topleft" - left_delta="0" - top_pad="6" - name="WLCloudX" - width="200" /> - <slider - control_name="WLCloudY" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.5" - label="Y" - layout="topleft" - left_delta="0" - top_pad="6" - name="WLCloudY" - width="200" /> - <slider - control_name="WLCloudDensity" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="1.0" - label="D" - layout="topleft" - left_delta="0" - name="WLCloudDensity" - top_pad="6" - width="200" /> - - <!--======== Tab Panel III. II conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="55" - name="WLCloudCoverageText" - top="15" - width="200"> - Cloud Coverage - </text> - <slider - control_name="WLCloudCoverage" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.5" - layout="topleft" - left_delta="15" - name="WLCloudCoverage" - top_pad="6" - width="200" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-15" - name="WLCloudScaleText" - top_pad="20" - width="200"> - Cloud Scale - </text> - <slider - control_name="WLCloudScale" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="1.0" - layout="topleft" - left_delta="15" - min_val="0.01" - name="WLCloudScale" - top_pad="6" - width="200" /> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-13" - name="WLCloudDetailText" - top_pad="20" - width="200"> - Cloud Detail (XY/Density) - </text> - <slider - control_name="WLCloudDetailX" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.5" - label="X" - layout="topleft" - left_delta="0" - top_pad="6" - name="WLCloudDetailX" - width="200" /> - <slider - control_name="WLCloudDetailY" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.5" - label="Y" - layout="topleft" - left_delta="0" - name="WLCloudDetailY" - top_pad="6" - width="200" /> - <slider - control_name="WLCloudDetailDensity" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="1.0" - label="D" - layout="topleft" - left_delta="0" - name="WLCloudDetailDensity" - top_pad="6" - width="200" /> - - <!--======== Tab Panel III. III conlumn of controls ========--> - - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="55" - name="WLCloudScrollXText" - top="15" - width="150"> - Cloud Scroll X - </text> - <check_box - control_name="WLCloudLockX" - follows="left|top" - height="16" - label="Lock" - layout="topleft" - left_delta="150" - name="WLCloudLockX" - top_delta="0" - width="200" /> - <slider - control_name="WLCloudScrollX" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.5" - layout="topleft" - left_delta="-135" - max_val="10" - min_val="-10" - name="WLCloudScrollX" - top_pad="6" - width="200" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-15" - name="WLCloudScrollYText" - top_pad="20" - width="150"> - Cloud Scroll Y - </text> - <check_box - control_name="WLCloudLockY" - follows="left|top" - height="16" - label="Lock" - layout="topleft" - left_delta="150" - name="WLCloudLockY" - width="200" /> - <slider - control_name="WLCloudScrollY" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.5" - layout="topleft" - left_delta="-135" - max_val="10" - min_val="-10" - name="WLCloudScrollY" - top_pad="6" - width="200" /> - </panel> - </tab_container> -<!--======== End of Controls panel ========--> - - <check_box - follows="top|left" - height="10" - label="Make this preset my new sky setting" - layout="topleft" - left="380" - name="make_default_cb" - top_pad="30" - width="280"/> - <button - follows="bottom|right" - height="23" - label="Save" - layout="topleft" - left_pad="0" - name="save" - width="70"/> - <button - follows="bottom|right" - height="23" - label="Cancel" - layout="topleft" - left_pad="15" - name="cancel" - width="70"/> - </floater> diff --git a/indra/newview/skins/default/xui/en/floater_edit_water_preset.xml b/indra/newview/skins/default/xui/en/floater_edit_water_preset.xml deleted file mode 100644 index 905983e7fa..0000000000 --- a/indra/newview/skins/default/xui/en/floater_edit_water_preset.xml +++ /dev/null @@ -1,448 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<floater - legacy_header_height="18" - height="375" - layout="topleft" - name="Edit Water Preset" - help_topic="water_preset" - save_rect="true" - title="Edit Water Preset" - width="725"> - - <string name="title_new">Create a New Water Preset</string> - <string name="title_edit">Edit a Water Preset</string> - <string name="hint_new">Name your preset, adjust the controls to create it, and click "Save".</string> - <string name="hint_edit">To edit your water preset, adjust the controls and click "Save".</string> - <string name="combo_label">-Select a preset-</string> - - <text - follows="top|left|right" - height="10" - layout="topleft" - left="30" - name="hint" - top="25" - width="680"> - To edit your preset, adjust the controls then click "Save" - </text> - - <text - follows="top|left|right" - font="SansSerif" - height="10" - layout="topleft" - left="30" - name="label" - top_pad="25" - width="120"> - Preset Name: - </text> - - <combo_box - allow_text_entry="true" - follows="top|left" - layout="topleft" - left_pad="10" - max_chars="100" - name="water_preset_combo" - top_delta="-5" - width="200"/> - - <line_editor - height="20" - left_delta="0" - name="water_preset_name" - top_delta="0" - width="200" /> - - <text - follows="top|left|right" - height="40" - layout="topleft" - left_pad="10" - name="note" - top_delta="0" - width="340" - wrap="true"> - Note: if you change the name of your preset, you will be creating a new preset and the existing preset will not be changed. - </text> - - <!--======== Controls panel ========--> - <panel - border="false" - bevel_style="none" - follows="top|left" - height="230" - layout="topleft" - left="10" - name="panel_water_preset" - top="100" - width="700"> - -<!--======== I conlumn of controls ========--> - <text - follows="left|top|right" - height="10" - font="SansSerif" - layout="topleft" - left="10" - name="water_color_label" - top="5" - width="215"> - Water Fog Color - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="37" - label_height="0" - layout="topleft" - left_delta="15" - name="WaterFogColor" - top_pad="8" - width="60" /> - - - <text - follows="left|top|right" - font="SansSerif" - layout="topleft" - left_delta="-15" - top_pad="10" - name="water_fog_density_label" - width="215"> - Fog Density Exponent - </text> - <slider - decimal_digits="1" - follows="left|top" - height="10" - initial_value="0" - layout="topleft" - left_delta="15" - max_val="10" - name="WaterFogDensity" - top_pad="10" - width="200"/> - - - <text - follows="left|top|right" - font="SansSerif" - layout="topleft" - left_delta="-15" - top_pad="15" - name="underwater_fog_modifier_label" - width="215"> - Underwater Fog Modifier - </text> - <slider - decimal_digits="1" - follows="left|top" - height="10" - initial_value="0" - layout="topleft" - left_delta="15" - max_val="10" - name="WaterUnderWaterFogMod" - top_pad="10" - width="200"/> - - - <text - follows="left|top|right" - font="SansSerif" - layout="topleft" - left_delta="-15" - name="BHText" - top_pad="15" - width="215"> - Big Wave Direction - </text> - <slider - control_name="WaterWave1DirX" - decimal_digits="2" - follows="left|top" - increment="0.01" - initial_value="0.7" - label="X" - layout="topleft" - max_val="4" - min_val="-4" - name="WaterWave1DirX" - top_pad="10" - width="216"/> - <slider - control_name="WaterWave1DirY" - decimal_digits="2" - follows="left|top" - increment="0.01" - initial_value="0.7" - label="Y" - layout="topleft" - max_val="4" - min_val="-4" - name="WaterWave1DirY" - top_pad="5" - width="216"/> - -<!--======== II conlumn of controls ========--> - - <text - follows="left|top|right" - font="SansSerif" - height="10" - layout="topleft" - left_pad="20" - name="BDensText" - top="5" - width="215"> - Reflection Wavelet Scale - </text> - <slider - control_name="WaterNormalScaleX" - decimal_digits="1" - follows="left|top" - initial_value="0.7" - layout="topleft" - left_delta="15" - max_val="10" - name="WaterNormalScaleX" - top_pad="10" - width="200"/> - <slider - control_name="WaterNormalScaleY" - decimal_digits="1" - follows="left|top" - initial_value="0.7" - layout="topleft" - max_val="10" - name="WaterNormalScaleY" - top_pad="6" - width="200"/> - <slider - control_name="WaterNormalScaleZ" - decimal_digits="1" - follows="left|top" - initial_value="0.7" - layout="topleft" - max_val="10" - name="WaterNormalScaleZ" - top_pad="6" - width="200"/> - - - <text - follows="left|top|right" - font="SansSerif" - layout="topleft" - left_delta="-15" - name="HDText" - top_pad="16" - width="215"> - Fresnel Scale - </text> - <slider - control_name="WaterFresnelScale" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0.7" - layout="topleft" - left_delta="15" - name="WaterFresnelScale" - top_pad="10" - width="200"/> - <text - follows="left|top|right" - font="SansSerif" - layout="topleft" - left_delta="-15" - name="FresnelOffsetText" - top_pad="15" - width="215"> - Fresnel Offset - </text> - <slider - control_name="WaterFresnelOffset" - decimal_digits="2" - follows="left" - increment="0.01" - initial_value="0.7" - layout="topleft" - left_delta="15" - name="WaterFresnelOffset" - top_pad="10" - width="200"/> - - - <text - follows="left|top|right" - font="SansSerif" - layout="topleft" - left_delta="-15" - name="BHText2" - top_pad="15" - width="215"> - Little Wave Direction - </text> - <slider - control_name="WaterWave2DirX" - decimal_digits="2" - follows="left|top" - increment="0.01" - initial_value="0.7" - label="X" - layout="topleft" - max_val="4" - min_val="-4" - name="WaterWave2DirX" - top_pad="10" - width="216" /> - <slider - control_name="WaterWave2DirY" - decimal_digits="2" - follows="left|top" - increment="0.01" - initial_value="0.7" - label="Y" - layout="topleft" - max_val="4" - min_val="-4" - name="WaterWave2DirY" - top_pad="6" - width="216" /> - -<!--======== III conlumn of contorls ========--> - - <text - follows="left|top|right" - font="SansSerif" - height="16" - layout="topleft" - left_pad="20" - name="DensMultText" - top="5" - width="215"> - Refract Scale Above - </text> - <slider - control_name="WaterScaleAbove" - decimal_digits="2" - follows="left|top" - increment="0.01" - initial_value="0.1" - layout="topleft" - left_delta="15" - name="WaterScaleAbove" - top_pad="5" - width="200" /> - - <text - type="string" - length="1" - follows="left|top|right" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-15" - name="WaterScaleBelowText" - top_pad="15" - width="215"> - Refract Scale Below - </text> - <slider - control_name="WaterScaleBelow" - decimal_digits="2" - follows="left|top" - height="10" - increment="0.01" - initial_value="0" - layout="topleft" - left_delta="15" - name="WaterScaleBelow" - top_pad="5" - width="200"/> - - <text - follows="left|top|right" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-15" - name="MaxAltText" - top_pad="15" - width="215"> - Blur Multiplier - </text> - <slider - control_name="WaterBlurMult" - follows="left|top" - height="10" - increment="0.001" - initial_value="0" - layout="topleft" - left_delta="15" - max_val="0.16" - name="WaterBlurMult" - top_pad="5" - width="200"/> - - <text - follows="left|top|right" - font="SansSerif" - height="16" - layout="topleft" - left_delta="-15" - name="BHText3" - top_pad="15" - width="215"> - Normal Map - </text> - <texture_picker - height="80" - layout="topleft" - left_delta="15" - name="WaterNormalMap" - top_pad="5" - width="100" /> - </panel> -<!--======== End of Controls panel ========--> - - <view_border - bevel_style="none" - follows="top|left" - height="0" - layout="topleft" - left="10" - name="horiz_separator" - top_pad="5" - width="700"/> - <check_box - follows="top|left" - height="10" - label="Make this preset my new water setting" - layout="topleft" - left="275" - name="make_default_cb" - top_pad="20" - width="280"/> - <button - follows="bottom|right" - height="23" - label="Save" - layout="topleft" - left_pad="0" - name="save" - width="70"/> - <button - follows="bottom|right" - height="23" - label="Cancel" - layout="topleft" - left_pad="15" - name="cancel" - width="70"/> - - </floater> diff --git a/indra/newview/skins/default/xui/en/floater_environment_settings.xml b/indra/newview/skins/default/xui/en/floater_environment_settings.xml deleted file mode 100644 index 1b1cafaca6..0000000000 --- a/indra/newview/skins/default/xui/en/floater_environment_settings.xml +++ /dev/null @@ -1,162 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<floater - legacy_header_height="18" - height="328" - layout="topleft" - name="Environment Editor Floater" - help_topic="environment_editor_floater" - save_rect="true" - title="ENVIRONMENT SETTINGS" - width="540"> - - <text - follows="top|left|right" - height="15" - layout="topleft" - left="20" - name="note" - top="25" - width="510" - wrap="true"> - Use the options below to customize the environment settings for your viewer. - </text> - - <view_border - bevel_style="none" - follows="top|left" - height="237" - layout="topleft" - left="20" - name="border" - top_pad="8" - width="500"/> - <radio_group - follows="top|left" - height="45" - layout="topleft" - left_delta="10" - name="region_settings_radio_group" - top_delta="20" - width="200"> - <radio_item - label="Use region settings" - layout="topleft" - name="use_region_settings"/> - <radio_item - label="Customize my environment" - layout="topleft" - name="use_my_settings" - top_pad="20"/> - </radio_group> - - <panel - height="170" - layout="topleft" - left="50" - name="user_environment_settings" - top_pad="0" - width="470"> - - <text - follows="top|left|right" - font="SansSerifItalic" - height="15" - layout="topleft" - left_delta="0" - name="note" - top_pad="0" - width="470" - wrap="true"> - Note: your custom settings will not be visible to other users. - </text> - - <!-- Water Setting --> - <text - name="water_settings_title" - follows="top|left" - height="16" - layout="topleft" - left="50" - top="40" - width="200"> - Water Setting - </text> - <combo_box - follows="top|left" - left_pad="2" - name="water_settings_preset_combo" - top_delta="-5" - width="200"> - <combo_box.item - label="-Select a preset-" - name="item0"/> - </combo_box> - - - <!-- Sky/Day Cycle Settings --> - <text - name="sky_dayc_settings_title" - follows="top|left" - height="16" - layout="topleft" - left="50" - top_pad="20" - width="100"> - Sky / Day Cycle - </text> - <radio_group - layout="topleft" - left_delta="50" - name="sky_dayc_settings_radio_group" - top_pad="10" - height="50" - width="150"> - <radio_item - layout="topleft" - label="Fixed sky" - name="my_sky_settings"/> - <radio_item - layout="topleft" - label="Day cycle" - name="my_dayc_settings" - top_pad="25"/> - </radio_group> - <combo_box - follows="top|left" - left_pad="2" - name="sky_settings_preset_combo" - top_delta="-7" - width="200"> - <combo_box.item - label="-Select a preset-" - name="item0"/> - </combo_box> - <combo_box - follows="top|left" - name="dayc_settings_preset_combo" - top_delta="36" - width="200"> - <combo_box.item - label="-Select a preset-" - name="item0"/> - </combo_box> - </panel> - - <button - follows="left|top" - height="23" - label="OK" - layout="topleft" - right="-130" - name="ok_btn" - top_pad="10" - width="100" /> - <button - follows="left|top" - height="23" - label="Cancel" - layout="topleft" - left_pad="10" - name="cancel_btn" - width="100" /> -</floater> diff --git a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml new file mode 100644 index 0000000000..348c0ce195 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + can_tear_off="false" + can_resize="false" + can_drag_on_left="false" + can_close="true" + can_dock="false" + bevel_style="in" + height="550" + layout="topleft" + name="Fixed Environment" + save_rect="true" + title="Fixed Environment" + save_visibility="false" + help_topic="fixed_environment" + single_instance="true" + width="750"> + <string name="edit_sky">Edit Sky:</string> + <string name="edit_water">Edit Water:</string> + <layout_stack name="floater_stack" + left="5" + top="5" + right="-5" + bottom="-5" + follows="left|top|right|bottom" + orientation="vertical"> + <layout_panel name="info_panel" + auto_resize="false" + user_resize="false" + min_height="60"> + <text + follows="left|top" + top_delta="30" + left_delta="10" + width="35" + height="20" + font="SansSerif"> + Name: + </text> + <line_editor + follows="left|top" + top_delta="-2" + left_delta="45" + width="250" + name="settings_name" + prevalidate_callback="ascii" + max_length_chars="32" + height="20"/> + <button + height="23" + label="Load" + follows="left|top" + left_delta="260" + font="SansSerif" + top_delta="-2" + name="btn_load" + tool_tip="Load a settings from inventory" + width="96" /> + <button + height="23" + label="Import" + follows="right|top" + right="-10" + font="SansSerif" + top_delta="0" + name="btn_import" + tool_tip="Import legacy settings from disk." + width="96" /> + </layout_panel> + <layout_panel name="tab_area" + auto_resize="true" + user_resize="false" + height="11" + min_height="0" + visible="true"> + <tab_container + follows="all" + halign="left" + layout="topleft" + left="0" + name="tab_settings" + tab_position="top" + tab_width="120" + tab_padding_right="3"> + <!-- Tabs inserted here in code --> + </tab_container> + </layout_panel> + <layout_panel name="button_panel" + follows="left|top|right|bottom" + auto_resize="false" + user_resize="false" + height="40" + visible="true"> + <layout_stack + follows="bottom|left|right" + height="23" + layout="topleft" + mouse_opaque="false" + name="button_bar_ls" + left="0" + orientation="horizontal" + top="0" + width="313"> + <layout_panel + follows="bottom|left|right" + height="23" + layout="bottomleft" + left="0" + mouse_opaque="false" + name="save_btn_lp" + auto_resize="true" + width="156"> + <button + follows="bottom|left|right" + height="23" + label="Save" + left="1" + layout="topleft" + name="btn_commit" + top="0" + width="155" /> + <button + follows="bottom|right" + height="23" + name="btn_flyout" + label="" + layout="topleft" + left_pad="-20" + tab_stop="false" + top="0" + image_selected="SegmentedBtn_Right_Selected_Press" + image_unselected="SegmentedBtn_Right_Off" + image_pressed="SegmentedBtn_Right_Press" + image_pressed_selected="SegmentedBtn_Right_Selected_Press" + image_overlay="Arrow_Small_Up" + width="20"/> + </layout_panel> + <layout_panel + follows="bottom|left|right" + height="23" + layout="bottomleft" + left_pad="3" + mouse_opaque="false" + name="revert_btn_lp" + auto_resize="true" + width="147"> + <button + follows="bottom|right" + height="23" + right="-1" + label="Cancel" + layout="topleft" + name="btn_cancel" + top="0" + tool_tip="Revert to last saved version" + width="147" /> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml index 1b4992b4ca..7142fea0ea 100644 --- a/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/en/floater_inventory_view_finder.xml @@ -2,7 +2,7 @@ <floater legacy_header_height="18" can_minimize="false" - height="468" + height="488" layout="topleft" name="Inventory Finder" help_topic="inventory_finder" @@ -212,6 +212,23 @@ name="check_snapshot" top_delta="0" width="126" /> + <icon + height="16" + image_name="Inv_Settings" + layout="topleft" + left="8" + mouse_opaque="true" + name="icon_settings" + top="262" + width="16" /> + <check_box + height="16" + label="Settings" + layout="topleft" + left_pad="2" + name="check_settings" + top_delta="0" + width="126" /> <button follows="left|top" height="20" @@ -220,7 +237,7 @@ layout="topleft" left="8" name="All" - top="262" + top="282" width="100" /> <button height="20" @@ -274,7 +291,7 @@ width="260"/> <check_box height="16" - top="352" + top="372" label="Since Logoff" layout="topleft" left_delta="0" @@ -290,7 +307,7 @@ layout="topleft" left_delta="0" name="- OR -" - top="370" + top="390" width="144"> - OR - </text> @@ -298,7 +315,7 @@ height="16" layout="topleft" name="date_search_direction" - top="388" + top="408" left="8" width="270"> <radio_item @@ -368,6 +385,6 @@ layout="topleft" name="Close" right="-6" - top="434" + top="454" width="76" /> </floater> diff --git a/indra/newview/skins/default/xui/en/floater_my_environments.xml b/indra/newview/skins/default/xui/en/floater_my_environments.xml new file mode 100644 index 0000000000..c9238b80b3 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_my_environments.xml @@ -0,0 +1,193 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<floater + positioning="cascading" + save_rect="true" + single_instance="true" + reuse_instance="true" + legacy_header_height="18" + can_resize="true" + height="465" + name="my_environments" + help_topic="my_environments" + title="MY ENVIRONMENTS" + background_visible="true" + label="Places" + layout="topleft" + min_height="350" + min_width="265" + width="313"> + <layout_stack + follows="all" + layout="topleft" + left="5" + top="20" + right="-5" + bottom="-5" + orientation="vertical"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="false" + user_resize="true" + tab_group="1" + height="24" + name="filter_panel" + label="Filters" + font="SansSerifBold"> + <icon + height="16" + image_name="Inv_SettingsDay" + layout="topleft" + mouse_opaque="true" + name="icon_settingsdays" + left="4" + width="16" /> + <check_box + height="16" + label="Days" + layout="topleft" + left_pad="2" + name="chk_days" + top_delta="0" + width="60" /> + <icon + height="16" + image_name="Inv_SettingsSky" + layout="topleft" + mouse_opaque="true" + name="icon_settingsskies" + left_pad="10" + width="16" /> + <check_box + height="16" + label="Skies" + layout="topleft" + left_pad="2" + name="chk_skies" + top_delta="0" + width="60" /> + <icon + height="16" + image_name="Inv_SettingsWater" + layout="topleft" + mouse_opaque="true" + name="icon_settingswater" + left_pad="10" + width="16" /> + <check_box + height="16" + label="Water" + layout="topleft" + left_pad="2" + name="chk_water" + top_delta="0" + width="60" /> + </layout_panel> + <layout_panel + auto_resize="true" + user_resize="true" + tab_group="1" + name="list_panel" + label="Environments" + font="SansSerifBold"> + <panel + name="pnl_inv_wrap" + label="pnl_inv_wrap" + follows="all" + layout="topleft" + left="2" + top="2" + right="-2" + bottom="-2" + background_visible="true" + bg_alpha_color="DkGray2" + border="true"> + <asset_filtered_inv_panel + left="0" + top="0" + right="-1" + bottom="-1" + allow_multi_select="false" + follows="all" + layout="topleft" + name="pnl_settings" + filter_asset_type="settings"/> + </panel> + </layout_panel> + <layout_panel + auto_resize="false" + user_resize="false" + tab_group="1" + height="14"> + <check_box + follows="left|bottom" + height="14" + initial_value="false" + label="Show Empty Folders" + layout="topleft" + name="chk_showfolders" + top="2" + left_delta="-1" + width="200" /> + </layout_panel> + <layout_panel + auto_resize="false" + user_resize="true" + tab_group="1" + height="31" + name="pnl_control" + font="SansSerifBold"> + <panel + background_visible="true" + bevel_style="none" + top_pad="1" + follows="top|left|right" + height="30" + label="bottom_panel" + layout="topleft" + left="0" + name="pnl_bottom"> + <menu_button + follows="bottom|left" + height="18" + image_disabled="OptionsMenu_Disabled" + image_selected="OptionsMenu_Press" + image_unselected="OptionsMenu_Off" + layout="topleft" + left="10" + menu_filename="menu_settings_gear.xml" + name="btn_gear" + top="5" + tool_tip="More options" + width="18" /> + <menu_button + follows="bottom|left" + font="SansSerifBigBold" + height="18" + image_selected="AddItem_Press" + image_unselected="AddItem_Off" + image_disabled="AddItem_Disabled" + layout="topleft" + left_pad="5" + menu_filename="menu_settings_add.xml" + name="btn_newsettings" + tool_tip="Make new setting" + top_delta="0" + width="18" /> + <button + follows="bottom|right" + font="SansSerifBigBold" + height="18" + image_selected="TrashItem_Press" + image_unselected="TrashItem_Off" + image_disabled="TrashItem_Disabled" + layout="topleft" + name="btn_del" + right="-5" + tool_tip="Remove selected item" + top_delta="0" + width="18" /> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_perms_default.xml b/indra/newview/skins/default/xui/en/floater_perms_default.xml index 1c3af49bfe..49dc719a24 100644 --- a/indra/newview/skins/default/xui/en/floater_perms_default.xml +++ b/indra/newview/skins/default/xui/en/floater_perms_default.xml @@ -488,6 +488,67 @@ left_pad="0" top_delta="0" width="100" /> + <text + name="label_13" + type="string" + length="1" + follows="left|top" + height="16" + layout="topleft" + left="0" + tool_tip="Set default permissions for when Environment settings are created" + width="100"> + Settings + </text> + <icon + follows="left|top" + height="16" + image_name="Inv_Settings" + layout="topleft" + left_pad="2" + width="18"/> + <check_box + height="16" + layout="topleft" + name="env_settings_c" + left_pad="45" + top_delta="0" + value="true" + enabled="false" + width="100"> + </check_box> + <check_box + control_name="SettingsNextOwnerModify" + height="16" + layout="topleft" + name="env_settings_m" + left_pad="0" + top_delta="0" + width="100" /> + <check_box + control_name="SettingsNextOwnerTransfer" + height="16" + layout="topleft" + name="env_settings_t" + left_pad="0" + top_delta="0" + width="100" /> + <check_box + enabled="false" + height="16" + layout="topleft" + name="env_settings_s" + left_pad="0" + top_delta="0" + width="120" /> + <check_box + enabled="false" + height="16" + layout="topleft" + name="env_settings_e" + left_pad="0" + top_delta="0" + width="100" /> </panel> <button height="20" diff --git a/indra/newview/skins/default/xui/en/floater_pick_track.xml b/indra/newview/skins/default/xui/en/floater_pick_track.xml new file mode 100644 index 0000000000..d8a9877be2 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_pick_track.xml @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> + +<floater + legacy_header_height="0" + can_minimize="false" + can_resize="true" + height="140" + layout="topleft" + min_height="140" + min_width="225" + name="track picker" + help_topic="track_picker" + title="PICK: TRACK" + width="225"> + <layout_stack name="adjuster" + follows="all" + animate="false" + top="0" + left="6" + right="-6" + bottom="-10" + orientation="vertical"> + <layout_panel name="pnl_desc" + border="false" + auto_resize="false" + user_resize="false" + height="11" + min_height="10" + bg_alpha_color="blue" + background_visible="false"> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left="5" + name="select_description" + mouse_opaque="false" + top="0" + width="300"> + Select source sky: + </text> + </layout_panel> + <layout_panel name="pnl_traks" + border="false" + auto_resize="true" + user_resize="false" + height="29" + min_height="29" + bg_alpha_color="blue" + background_visible="false"> + <radio_group + follows="all" + height="60" + layout="topleft" + top="0" + left="3" + right="-3" + bottom="-3" + name="track_selection" + width="100"> + <radio_item + height="20" + label="Sky4 [ALT]" + layout="topleft" + left="0" + name="radio_sky4" + value="4" + top="0" + width="90" /> + <radio_item + height="20" + label="Sky3 [ALT]" + layout="topleft" + left="0" + name="radio_sky3" + value="3" + top_delta="20" + width="90" /> + <radio_item + height="20" + label="Sky2 [ALT]" + layout="topleft" + left="0" + name="radio_sky2" + value="2" + top_delta="20" + width="90" /> + <radio_item + height="20" + label="Ground" + layout="topleft" + left="0" + name="radio_sky1" + value="1" + top_delta="20" + width="90" /> + </radio_group> + </layout_panel> + <layout_panel name="pnl_ok_cancel" + border="false" + auto_resize="false" + user_resize="false" + height="29" + min_height="29"> + <button + follows="top|left" + height="20" + label="OK" + label_selected="OK" + layout="topleft" + left="2" + top="2" + name="btn_select" + width="100" /> + <button + follows="top|left" + height="20" + label="Cancel" + label_selected="Cancel" + layout="topleft" + left_delta="110" + top_delta="0" + name="btn_cancel" + width="100" /> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index c2500951a6..4b202ec21e 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -819,6 +819,22 @@ function="Pref.VertexShaderEnable" /> </check_box> + <!-- + <check_box + control_name="RenderUseAdvancedAtmospherics" + height="16" + initial_value="true" + label="Advanced Atmospherics" + layout="topleft" + left="480" + name="UseAdvancedAtmo" + top_delta="16" + width="240"> + <check_box.commit_callback + function="Pref.AdvancedAtmosphericsEnable" /> + </check_box> + --> + <text type="string" length="1" diff --git a/indra/newview/skins/default/xui/en/floater_settings_picker.xml b/indra/newview/skins/default/xui/en/floater_settings_picker.xml new file mode 100644 index 0000000000..132d23492f --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_settings_picker.xml @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + legacy_header_height="18" + can_minimize="false" + can_resize="true" + height="330" + layout="topleft" + min_height="330" + min_width="225" + name="settings picker" + help_topic="settings_picker" + title="PICK: SETTINGS" + width="225"> + + <!-- top static --> + <floater.string + name="pick title"> + Pick: + </floater.string> + <floater.string + name="pick_track"> + SELECT TRACK + </floater.string> + <floater.string + name="pick_settings"> + SELECT SETTINGS + </floater.string> + + <floater.string + name="track_water"> + Water + </floater.string> + <floater.string + name="track_ground"> + Ground + </floater.string> + <floater.string + name="track_sky"> + Sky[NUM] + </floater.string> + + <layout_stack name="test_stack" + follows="all" + animate="false" + top="20" + left="6" + right="-6" + bottom="-10" + orientation="vertical"> + <layout_panel name="inv_list" + border="false" + auto_resize="true" + user_resize="false" + height="29" + min_height="29" + bg_alpha_color="blue" + background_visible="false"> + <filter_editor + follows="left|top|right" + height="23" + label="Filter Textures" + layout="topleft" + left="4" + name="flt_inventory_search" + top="4" + right="-2" /> + <panel + name="pnl_inv_wrap" + follows="all" + layout="topleft" + left="2" + top="2" + right="-2" + bottom="-2" + background_visible="true" + bg_alpha_color="DkGray2"> + <asset_filtered_inv_panel + allow_multi_select="false" + allow_drag="false" + accepts_drag_and_drop="false" + suppress_folder_menu="true" + bg_visible="true" + bg_alpha_color="DkGray2" + border="false" + follows="all" + left_delta="0" + name="pnl_inventory" + top="1" + right="-4" + bottom="-1" + filter_asset_type="settings" /> + </panel> + </layout_panel> + <layout_panel name="pnl_combo" + border="false" + auto_resize="false" + user_resize="false" + visible="true" + height="29" + bg_alpha_color="blue" + background_visible="false"> + <combo_box + allow_text_entry="false" + follows="left|top" + height="23" + left="10" + max_chars="100" + mouse_opaque="true" + name="track_selection" + top="1" + width="190"/> + </layout_panel> + <layout_panel name="temp" + border="false" + auto_resize="false" + user_resize="false" + height="29" + min_height="29"> + <button + follows="top|left" + height="20" + label="OK" + label_selected="OK" + layout="topleft" + left="2" + top="2" + name="btn_select" + width="100" /> + <button + follows="top|left" + height="20" + label="Cancel" + label_selected="Cancel" + layout="topleft" + left_delta="110" + top_delta="0" + name="btn_cancel" + width="100" /> + </layout_panel> + </layout_stack> + + <!-- middle: inventory mode --> + <!-- + + +--> + <!-- bottom static --> + <!-- + --> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml b/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml index a04050e7eb..a3ed22f422 100644 --- a/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml +++ b/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml @@ -1,226 +1,226 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <floater - can_resize="true" - can_close="true" - bevel_style="in" - height="300" - layout="topleft" - min_height="40" - min_width="420" - name="Test Floater" - title="LAYOUTSTACK TESTS" - width="420"> - <layout_stack name="test_stack" - left="0" - top="0" - width="100" - height="250" - follows="left|top|bottom" - orientation="vertical"> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - min_height="0" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - min_height="0" - visible="false" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - min_height="0" - visible="true" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - min_height="0" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - </layout_stack> - <layout_stack name="test_stack" - left_pad="5" - top="0" - width="100" - height="250" - follows="left|top|bottom" - orientation="vertical"> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="100" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - visible="false" - bg_alpha_color="blue" - height="100" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="fixed" - auto_resize="false" - user_resize="true" - height="50" - min_height="10" - bg_alpha_color="green" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="black">fixed</text> - </layout_panel> - <layout_panel name="fixed" + can_resize="true" + can_close="true" + bevel_style="in" + height="300" + layout="topleft" + min_height="40" + min_width="420" + name="Test Floater" + title="LAYOUTSTACK TESTS" + width="420"> + <layout_stack name="test_stack" + left="0" + top="0" + width="100" + height="250" + follows="left|top|bottom" + orientation="vertical"> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + min_height="0" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + min_height="0" + visible="false" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + min_height="0" + visible="true" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + min_height="0" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + </layout_stack> + <layout_stack name="test_stack" + left_pad="5" + top="0" + width="100" + height="250" + follows="left|top|bottom" + orientation="vertical"> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="100" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + visible="false" + bg_alpha_color="blue" + height="100" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="fixed" + auto_resize="false" + user_resize="true" + height="50" + min_height="10" + bg_alpha_color="green" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="black">fixed</text> + </layout_panel> + <layout_panel name="fixed" auto_resize="false" - user_resize="true" + user_resize="true" height="50" min_height="10" bg_alpha_color="green" background_visible="true"> - <text follows="top|left|right" halign="center" text_color="black">fixed</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="100" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="100" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="100" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="100" - visible="true" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - </layout_stack> - <layout_stack name="test_stack" - left_pad="5" - top="0" - width="100" - height="250" - follows="left|top|bottom" - orientation="vertical"> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - height="11" - bg_alpha_color="blue" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="fixed" + <text follows="top|left|right" halign="center" text_color="black">fixed</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="100" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="100" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="100" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="100" + visible="true" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + </layout_stack> + <layout_stack name="test_stack" + left_pad="5" + top="0" + width="100" + height="250" + follows="left|top|bottom" + orientation="vertical"> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + height="11" + bg_alpha_color="blue" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="fixed" auto_resize="false" - user_resize="true" + user_resize="true" height="50" bg_alpha_color="green" background_visible="true"> - <text follows="top|left|right" halign="center" text_color="black">fixed</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - </layout_stack> - <layout_stack name="test_stack" - left_pad="5" - top="0" - width="100" - height="250" - follows="left|top|bottom" - orientation="vertical"> - <layout_panel name="fixed" + <text follows="top|left|right" halign="center" text_color="black">fixed</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + </layout_stack> + <layout_stack name="test_stack" + left_pad="5" + top="0" + width="100" + height="250" + follows="left|top|bottom" + orientation="vertical"> + <layout_panel name="fixed" auto_resize="false" - user_resize="true" + user_resize="true" height="50" bg_alpha_color="green" background_visible="true"> - <text follows="top|left|right" halign="center" text_color="black">fixed</text> - </layout_panel> - <layout_panel name="fixed" + <text follows="top|left|right" halign="center" text_color="black">fixed</text> + </layout_panel> + <layout_panel name="fixed" auto_resize="false" - user_resize="true" + user_resize="true" height="50" bg_alpha_color="green" background_visible="true"> - <text follows="top|left|right" halign="center" text_color="black">fixed</text> - </layout_panel> - <layout_panel name="fixed" + <text follows="top|left|right" halign="center" text_color="black">fixed</text> + </layout_panel> + <layout_panel name="fixed" auto_resize="false" - user_resize="true" + user_resize="true" height="50" bg_alpha_color="green" background_visible="true"> - <text follows="top|left|right" halign="center" text_color="black">fixed</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - min_height="0" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - min_height="0" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - bg_alpha_color="blue" - height="11" - min_height="0" - background_visible="true"> - <text follows="top|left|right" halign="center" text_color="white">flex</text> - </layout_panel> - </layout_stack> + <text follows="top|left|right" halign="center" text_color="black">fixed</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + min_height="0" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + min_height="0" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + <layout_panel name="flex" + auto_resize="true" + user_resize="true" + bg_alpha_color="blue" + height="11" + min_height="0" + background_visible="true"> + <text follows="top|left|right" halign="center" text_color="white">flex</text> + </layout_panel> + </layout_stack> </floater> diff --git a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml index 53618b684b..90e2bb0923 100644 --- a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml +++ b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml @@ -152,7 +152,7 @@ name="inventory search editor" top="20" width="231" /> - <inventory_panel + <asset_filtered_inv_panel allow_multi_select="false" bg_visible="true" bg_alpha_color="DkGray2" @@ -163,7 +163,8 @@ left_delta="0" name="inventory panel" top_pad="4" - width="231" /> + width="231" + filter_asset_type="texture"/> <check_box height="14" initial_value="false" diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml index 3ea9e77a03..33ecb4477a 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory.xml @@ -314,6 +314,41 @@ </menu_item_call> </menu> <menu + label="New Settings" + layout="topleft" + name="New Settings"> + <menu_item_call + label="New Sky" + layout="topleft" + name="New Sky"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="sky"/> + <menu_item_call.on_enable + function="Inventory.EnvironmentEnabled" /> + </menu_item_call> + <menu_item_call + label="New Water" + layout="topleft" + name="New Water"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="water"/> + <menu_item_call.on_enable + function="Inventory.EnvironmentEnabled" /> + </menu_item_call> + <menu_item_call + label="New Day Cycle" + layout="topleft" + name="New Day Cycle"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="daycycle"/> + <menu_item_call.on_enable + function="Inventory.EnvironmentEnabled" /> + </menu_item_call> + </menu> + <menu label="Use as default for" layout="topleft" name="upload_def"> @@ -826,6 +861,25 @@ function="Inventory.DoToSelected" parameter="take_off" /> </menu_item_call> + <menu_item_separator + layout="topleft" + name="Settings Separator" /> + <menu_item_call + name="Settings Apply Local" + layout="topleft" + label="Apply Only To Myself"> + <menu_item_call.on_click + function="Inventory.DoToSelected" + parameter="apply_settings_local" /> + </menu_item_call> + <menu_item_call + name="Settings Apply Parcel" + layout="topleft" + label="Apply To Parcel"> + <menu_item_call.on_click + function="Inventory.DoToSelected" + parameter="apply_settings_parcel" /> + </menu_item_call> <menu_item_separator layout="topleft" name="Marketplace Separator" /> diff --git a/indra/newview/skins/default/xui/en/menu_inventory_add.xml b/indra/newview/skins/default/xui/en/menu_inventory_add.xml index afeb1bf226..0caae9f2ef 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory_add.xml @@ -1,248 +1,285 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <menu - layout="topleft" - left="0" - mouse_opaque="false" - can_tear_off="false" - name="menu_inventory_add" - visible="false"> - <menu - create_jump_keys="true" - label="Upload" - layout="topleft" - name="upload" - tear_off="true"> - <menu_item_call - label="Image (L$[COST])..." - layout="topleft" - name="Upload Image" - shortcut="control|U"> - <menu_item_call.on_click - function="File.UploadImage" - parameter="" /> - <menu_item_call.on_enable - function="File.EnableUpload" /> - </menu_item_call> - <menu_item_call - label="Sound (L$[COST])..." - layout="topleft" - name="Upload Sound"> - <menu_item_call.on_click - function="File.UploadSound" - parameter="" /> - <menu_item_call.on_enable - function="File.EnableUpload" /> - </menu_item_call> - <menu_item_call - label="Animation (L$[COST])..." - layout="topleft" - name="Upload Animation"> - <menu_item_call.on_click - function="File.UploadAnim" - parameter="" /> - <menu_item_call.on_enable - function="File.EnableUpload" /> - </menu_item_call> - <menu_item_call - label="Model..." - layout="topleft" - name="Upload Model"> - <menu_item_call.on_click - function="File.UploadModel" - parameter="" /> - <menu_item_call.on_enable - function="File.EnableUploadModel" /> - <menu_item_call.on_visible - function="File.VisibleUploadModel"/> - </menu_item_call> - <menu_item_call - label="Bulk (L$[COST] per file)..." - layout="topleft" - name="Bulk Upload"> - <menu_item_call.on_click - function="File.UploadBulk" - parameter="" /> - </menu_item_call> - </menu> + layout="topleft" + left="0" + mouse_opaque="false" + can_tear_off="false" + name="menu_inventory_add" + visible="false"> + <menu + create_jump_keys="true" + label="Upload" + layout="topleft" + name="upload" + tear_off="true"> + <menu_item_call + label="Image (L$[COST])..." + layout="topleft" + name="Upload Image" + shortcut="control|U"> + <menu_item_call.on_click + function="File.UploadImage" + parameter="" /> + <menu_item_call.on_enable + function="File.EnableUpload" /> + </menu_item_call> + <menu_item_call + label="Sound (L$[COST])..." + layout="topleft" + name="Upload Sound"> + <menu_item_call.on_click + function="File.UploadSound" + parameter="" /> + <menu_item_call.on_enable + function="File.EnableUpload" /> + </menu_item_call> + <menu_item_call + label="Animation (L$[COST])..." + layout="topleft" + name="Upload Animation"> + <menu_item_call.on_click + function="File.UploadAnim" + parameter="" /> + <menu_item_call.on_enable + function="File.EnableUpload" /> + </menu_item_call> + <menu_item_call + label="Model..." + layout="topleft" + name="Upload Model"> + <menu_item_call.on_click + function="File.UploadModel" + parameter="" /> + <menu_item_call.on_enable + function="File.EnableUploadModel" /> + <menu_item_call.on_visible + function="File.VisibleUploadModel"/> + </menu_item_call> + <menu_item_call + label="Bulk (L$[COST] per file)..." + layout="topleft" + name="Bulk Upload"> + <menu_item_call.on_click + function="File.UploadBulk" + parameter="" /> + </menu_item_call> + </menu> - <menu_item_call - label="New Folder" - layout="topleft" - name="New Folder"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="category" /> - </menu_item_call> - <menu_item_call - label="New Script" - layout="topleft" - name="New Script"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="lsl" /> - </menu_item_call> - <menu_item_call - label="New Notecard" - layout="topleft" - name="New Note"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="notecard" /> - </menu_item_call> - <menu_item_call - label="New Gesture" - layout="topleft" - name="New Gesture"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="gesture" /> - </menu_item_call> - <menu - height="175" - label="New Clothes" - layout="topleft" - left_delta="0" - mouse_opaque="false" - name="New Clothes" - top_pad="514" - width="125"> - <menu_item_call - label="New Shirt" - layout="topleft" - name="New Shirt"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="shirt" /> - </menu_item_call> - <menu_item_call - label="New Pants" - layout="topleft" - name="New Pants"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="pants" /> - </menu_item_call> - <menu_item_call - label="New Shoes" - layout="topleft" - name="New Shoes"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="shoes" /> - </menu_item_call> - <menu_item_call - label="New Socks" - layout="topleft" - name="New Socks"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="socks" /> - </menu_item_call> - <menu_item_call - label="New Jacket" - layout="topleft" - name="New Jacket"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="jacket" /> - </menu_item_call> - <menu_item_call - label="New Skirt" - layout="topleft" - name="New Skirt"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="skirt" /> - </menu_item_call> - <menu_item_call - label="New Gloves" - layout="topleft" - name="New Gloves"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="gloves" /> - </menu_item_call> - <menu_item_call - label="New Undershirt" - layout="topleft" - name="New Undershirt"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="undershirt" /> - </menu_item_call> - <menu_item_call - label="New Underpants" - layout="topleft" - name="New Underpants"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="underpants" /> - </menu_item_call> - <menu_item_call - label="New Alpha" - layout="topleft" - name="New Alpha"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="alpha" /> - </menu_item_call> - <menu_item_call - label="New Tattoo" - layout="topleft" - name="New Tattoo"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="tattoo" /> - </menu_item_call> - <menu_item_call - label="New Physics" - layout="topleft" - name="New Physics"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="physics" /> - </menu_item_call> - </menu> - <menu - height="85" - label="New Body Parts" - layout="topleft" - left_delta="0" - mouse_opaque="false" - name="New Body Parts" - top_pad="514" - width="118"> - <menu_item_call - label="New Shape" - layout="topleft" - name="New Shape"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="shape" /> - </menu_item_call> - <menu_item_call - label="New Skin" - layout="topleft" - name="New Skin"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="skin" /> - </menu_item_call> - <menu_item_call - label="New Hair" - layout="topleft" - name="New Hair"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="hair" /> - </menu_item_call> - <menu_item_call - label="New Eyes" - layout="topleft" - name="New Eyes"> - <menu_item_call.on_click - function="Inventory.DoCreate" - parameter="eyes" /> - </menu_item_call> - </menu> + <menu_item_call + label="New Folder" + layout="topleft" + name="New Folder"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="category" /> + </menu_item_call> + <menu_item_call + label="New Script" + layout="topleft" + name="New Script"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="lsl" /> + </menu_item_call> + <menu_item_call + label="New Notecard" + layout="topleft" + name="New Note"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="notecard" /> + </menu_item_call> + <menu_item_call + label="New Gesture" + layout="topleft" + name="New Gesture"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="gesture" /> + </menu_item_call> + <menu + height="175" + label="New Clothes" + layout="topleft" + left_delta="0" + mouse_opaque="false" + name="New Clothes" + top_pad="514" + width="125"> + <menu_item_call + label="New Shirt" + layout="topleft" + name="New Shirt"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="shirt" /> + </menu_item_call> + <menu_item_call + label="New Pants" + layout="topleft" + name="New Pants"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="pants" /> + </menu_item_call> + <menu_item_call + label="New Shoes" + layout="topleft" + name="New Shoes"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="shoes" /> + </menu_item_call> + <menu_item_call + label="New Socks" + layout="topleft" + name="New Socks"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="socks" /> + </menu_item_call> + <menu_item_call + label="New Jacket" + layout="topleft" + name="New Jacket"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="jacket" /> + </menu_item_call> + <menu_item_call + label="New Skirt" + layout="topleft" + name="New Skirt"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="skirt" /> + </menu_item_call> + <menu_item_call + label="New Gloves" + layout="topleft" + name="New Gloves"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="gloves" /> + </menu_item_call> + <menu_item_call + label="New Undershirt" + layout="topleft" + name="New Undershirt"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="undershirt" /> + </menu_item_call> + <menu_item_call + label="New Underpants" + layout="topleft" + name="New Underpants"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="underpants" /> + </menu_item_call> + <menu_item_call + label="New Alpha" + layout="topleft" + name="New Alpha"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="alpha" /> + </menu_item_call> + <menu_item_call + label="New Tattoo" + layout="topleft" + name="New Tattoo"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="tattoo" /> + </menu_item_call> + <menu_item_call + label="New Physics" + layout="topleft" + name="New Physics"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="physics" /> + </menu_item_call> + </menu> + <menu + height="85" + label="New Body Parts" + layout="topleft" + left_delta="0" + mouse_opaque="false" + name="New Body Parts" + top_pad="514" + width="118"> + <menu_item_call + label="New Shape" + layout="topleft" + name="New Shape"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="shape" /> + </menu_item_call> + <menu_item_call + label="New Skin" + layout="topleft" + name="New Skin"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="skin" /> + </menu_item_call> + <menu_item_call + label="New Hair" + layout="topleft" + name="New Hair"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="hair" /> + </menu_item_call> + <menu_item_call + label="New Eyes" + layout="topleft" + name="New Eyes"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="eyes" /> + </menu_item_call> + </menu> + <menu + label="New Settings" + layout="topleft" + name="New Settings"> + <menu_item_call + label="New Sky" + layout="topleft" + name="New Sky"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="sky"/> + <menu_item_call.on_enable + function="Inventory.EnvironmentEnabled" /> + + </menu_item_call> + <menu_item_call + label="New Water" + layout="topleft" + name="New Water"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="water"/> + <menu_item_call.on_enable + function="Inventory.EnvironmentEnabled" /> + + </menu_item_call> + <menu_item_call + label="New Day Cycle" + layout="topleft" + name="New Day Cycle"> + <menu_item_call.on_click + function="Inventory.DoCreate" + parameter="daycycle"/> + <menu_item_call.on_enable + function="Inventory.EnvironmentEnabled" /> + </menu_item_call> + </menu> </menu>
\ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/menu_save_settings.xml b/indra/newview/skins/default/xui/en/menu_save_settings.xml new file mode 100644 index 0000000000..84dacaa8b8 --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_save_settings.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<toggleable_menu + height="602" + layout="topleft" + mouse_opaque="false" + name="save_settings_menu" + width="120"> + <menu_item_check + name="save_settings" + label="Save"> + <menu_item_check.on_check + function="FlyoutCombo.Button.Check" + userdata="save" /> + <menu_item_check.on_click + function="FlyoutCombo.Button.Action" + userdata="save"/> + </menu_item_check> + <menu_item_check + name="save_as_new_settings" + label="Save As"> + <menu_item_check.on_check + function="FlyoutCombo.Button.Check" + userdata="saveas" /> + <menu_item_check.on_click + function="FlyoutCombo.Button.Action" + userdata="saveas" /> + </menu_item_check> + <menu_item_check + name="commit_changes" + label="Commit"> + <menu_item_check.on_check + function="FlyoutCombo.Button.Check" + userdata="commit" /> + <menu_item_check.on_click + function="FlyoutCombo.Button.Action" + userdata="commit" /> + </menu_item_check> + <menu_item_check + name="apply_local" + label="Apply Only To Myself"> + <menu_item_check.on_check + function="FlyoutCombo.Button.Check" + userdata="local" /> + <menu_item_check.on_click + function="FlyoutCombo.Button.Action" + userdata="local" /> + </menu_item_check> + <menu_item_check + name="apply_parcel" + label="Apply To Parcel"> + <menu_item_check.on_check + function="FlyoutCombo.Button.Check" + userdata="parcel" /> + <menu_item_check.on_click + function="FlyoutCombo.Button.Action" + userdata="parcel" /> + </menu_item_check> + <menu_item_check + name="apply_region" + label="Apply To Region"> + <menu_item_check.on_check + function="FlyoutCombo.Button.Check" + userdata="region" /> + <menu_item_check.on_click + function="FlyoutCombo.Button.Action" + userdata="region" /> + </menu_item_check> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/en/menu_settings_add.xml b/indra/newview/skins/default/xui/en/menu_settings_add.xml new file mode 100644 index 0000000000..a4782cfdc3 --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_settings_add.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<toggleable_menu + layout="topleft" + mouse_opaque="false" + name="menu_settings_add" + visible="false"> + <menu_item_call + label="New Sky" + layout="topleft" + name="New Sky"> + <menu_item_call.on_click + function="MyEnvironments.DoCreate" + parameter="sky"/> + <menu_item_call.on_enable + function="MyEnvironments.EnvironmentEnabled" /> + </menu_item_call> + <menu_item_call + label="New Water" + layout="topleft" + name="New Water"> + <menu_item_call.on_click + function="MyEnvironments.DoCreate" + parameter="water"/> + <menu_item_call.on_enable + function="MyEnvironments.EnvironmentEnabled" /> + </menu_item_call> + <menu_item_call + label="New Day Cycle" + layout="topleft" + name="New Day Cycle"> + <menu_item_call.on_click + function="MyEnvironments.DoCreate" + parameter="daycycle"/> + <menu_item_call.on_enable + function="MyEnvironments.EnvironmentEnabled" /> + </menu_item_call> +</toggleable_menu>
\ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/menu_settings_gear.xml b/indra/newview/skins/default/xui/en/menu_settings_gear.xml new file mode 100644 index 0000000000..ea8e328407 --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_settings_gear.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<toggleable_menu + layout="topleft" + mouse_opaque="false" + name="menu_settings_gear" + visible="false"> + <menu_item_call + label="Edit" + layout="topleft" + name="edit_settings"> + <on_click + function="MyEnvironments.DoEdit" /> + <on_enable + function="MyEnvironments.EnableAction" + parameter="edit" /> + </menu_item_call> + <menu_item_separator + layout="topleft" + name="Separator" /> + <menu_item_call + name="Settings Apply Local" + layout="topleft" + label="Apply Only To Myself"> + <menu_item_call.on_click + function="MyEnvironments.DoApply" + parameter="local" /> + </menu_item_call> + <menu_item_call + name="Settings Apply Parcel" + layout="topleft" + label="Apply To Parcel"> + <menu_item_call.on_click + function="MyEnvironments.DoApply" + parameter="parcel" /> + <menu_item_call.on_enable + function="MyEnvironments.CanApply" + parameter="parcel"/> + </menu_item_call> + <menu_item_call + name="Settings Apply Region" + layout="topleft" + label="Apply To Region"> + <menu_item_call.on_click + function="MyEnvironments.DoApply" + parameter="region" /> + <menu_item_call.on_enable + function="MyEnvironments.CanApply" + parameter="region"/> + </menu_item_call> + <menu_item_separator + layout="topleft" + name="Separator" /> + <menu_item_call + label="Copy" + layout="topleft" + name="copy_settings"> + <on_click + function="MyEnvironments.CopyPaste" + parameter="copy" /> + <on_enable + function="MyEnvironments.EnableAction" + parameter="copy" /> + </menu_item_call> + <menu_item_call + label="Paste" + layout="topleft" + name="paste_settings"> + <on_click + function="MyEnvironments.CopyPaste" + parameter="paste" /> + <on_enable + function="MyEnvironments.EnableAction" + parameter="paste" /> + </menu_item_call> + <menu_item_call + label="Copy UUID" + layout="topleft" + name="copy_uuid"> + <on_click + function="MyEnvironments.CopyPaste" + parameter="copy_uuid" /> + <on_enable + function="MyEnvironments.EnableAction" + parameter="copy_uuid" /> + </menu_item_call> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 42744b561f..f676df5e8b 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -652,8 +652,8 @@ <menu create_jump_keys="true" - label="Sun" - name="Sun" + label="Environment" + name="Environment" tear_off="true"> <menu_item_check label="Sunrise" @@ -697,10 +697,9 @@ function="World.EnableEnvSettings" parameter="midnight" /> </menu_item_check> - <menu_item_separator/> <menu_item_check - label="Use Region Settings" - name="Use Region Settings"> + label="Use Shared Environment" + name="Use Shared Environment"> <menu_item_check.on_click function="World.EnvSettings" parameter="region" /> @@ -708,9 +707,29 @@ function="World.EnableEnvSettings" parameter="region" /> </menu_item_check> + <menu_item_separator/> + <menu_item_call + label="My Environments..." + name="my_environs"> + <menu_item_call.on_click + function="World.EnvSettings" + parameter="my_environs" /> + </menu_item_call> + <menu_item_separator/> + <menu_item_check + label="Pause Clouds" + name="pause_clouds"> + <menu_item_check.on_click + function="World.EnvSettings" + parameter="pause_clouds" /> + <menu_item_check.on_check + function="World.EnableEnvSettings" + parameter="pause_clouds" /> + </menu_item_check> + </menu> - +<!-- <menu create_jump_keys="true" label="Environment Editor" @@ -726,7 +745,7 @@ </menu_item_call> <menu_item_separator/> - + <menu name="Water Presets" label="Water Presets"> @@ -744,18 +763,8 @@ function="World.EnvPreset" parameter="edit_water"/> </menu_item_call> - <menu_item_call - label="Delete preset..." - name="delete_water_preset"> - <menu_item_call.on_click - function="World.EnvPreset" - parameter="delete_water"/> - <menu_item_call.on_enable - function="World.EnableEnvPreset" - parameter="delete_water"/> - </menu_item_call> </menu> - + <menu name="Sky Presets" label="Sky Presets"> @@ -773,16 +782,6 @@ function="World.EnvPreset" parameter="edit_sky"/> </menu_item_call> - <menu_item_call - label="Delete preset..." - name="delete_sky_preset"> - <menu_item_call.on_click - function="World.EnvPreset" - parameter="delete_sky"/> - <menu_item_call.on_enable - function="World.EnableEnvPreset" - parameter="delete_sky"/> - </menu_item_call> </menu> <menu @@ -802,19 +801,9 @@ function="World.EnvPreset" parameter="edit_day_cycle"/> </menu_item_call> - <menu_item_call - label="Delete preset..." - name="delete_day_preset"> - <menu_item_call.on_click - function="World.EnvPreset" - parameter="delete_day_cycle"/> - <menu_item_call.on_enable - function="World.EnableEnvPreset" - parameter="delete_day_cycle"/> - </menu_item_call> </menu> </menu> - +--> </menu> <menu diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 8780149d85..8d6a787133 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -4846,6 +4846,20 @@ Unchecking this option may remove restrictions that parcel owners have added to <notification icon="alertmodal.tga" + name="EstateParcelEnvironmentOverride" + type="alertmodal"> +Unchecking this option will remove any custom environments that parcel owners have added to their parcels. Please discuss with your parcel owners as needed. +Do you wish to proceed? + <tag>confirm</tag> + <usetemplate + name="okcancelbuttons" + notext="Cancel" + yestext="OK"/> + </notification> + + + <notification + icon="alertmodal.tga" name="RegionEntryAccessBlocked" type="alertmodal"> <tag>fail</tag> @@ -6103,7 +6117,23 @@ This day cycle file references a missing sky file: [SKY]. icon="alertmodal.tga" name="WLRegionApplyFail" type="alertmodal"> -Sorry, the settings couldn't be applied to the region. Leaving the region and then returning may help rectify the problem. The reason given was: [FAIL_REASON] +Sorry, the settings couldn't be applied to the region. Reason: [FAIL_REASON] + </notification> + + <notification + icon="alertmodal.tga" + name="WLLocalTextureDayBlock" + type="alertmodal"> +A Local texture is in use on track [TRACK], frame #[FRAMENO] ([FRAME]%) in field [FIELD]. +Settings may not be saved using local textures. + </notification> + + <notification + icon="alertmodal.tga" + name="WLLocalTextureFixedBlock" + type="alertmodal"> +A local texture is in use in field [FIELD]. +Settings may not be saved using local textures. </notification> <notification @@ -11209,4 +11239,177 @@ Cannot create large prims that intersect other residents. Please re-try when ot yestext="OK"/> </notification> + <notification + icon="notify.tga" + name="FailedToFindSettings" + persist="true" + type="alertmodal"> +Could not load the settings for [NAME] from the database. + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="FailedToLoadSettingsApply" + persist="true" + type="alertmodal"> +Unable to apply those settings to the environment. + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="FailedToBuildSettingsDay" + persist="true" + type="alertmodal"> +Unable to apply those settings to the environment. + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="NoEnvironmentSettings" + persist="true" + type="alertmodal"> +This Region does not support environmental settings. + <tag>fail</tag> + </notification> + + <notification + icon="alertmodal.tga" + label="Save Outfit" + name="SaveSettingAs" + type="alertmodal"> + <unique/> + Save current environmental settings as: + <tag>confirm</tag> + <form name="form"> + <input name="message" type="text"> + [DESC] (new) + </input> + <button + default="true" + index="0" + name="OK" + text="OK"/> + <button + index="1" + name="Cancel" + text="Cancel"/> + </form> + </notification> + + <notification + icon="notify.tga" + name="WLImportFail" + persist="true" + type="alertmodal"> +Unable to import legacy Windlight settings [NAME] from +[FILE]. + +[REASONS] + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="WLParcelApplyFail" + persist="true" + type="alertmodal"> +Unable to set the environment for this parcel. +Please enter or select a parcel that you have rights to modify. + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="SettingsUnsuported" + persist="true" + type="alertmodal"> +Settings are not supported on this region. +Please move to a settings enabled region and retry your action. + <tag>fail</tag> + </notification> + + <notification + icon="alertmodal.tga" + name="SettingsConfirmLoss" + type="alertmodal"> +You are about to lose the changes you have made to this [TYPE] named "[NAME]". +Are you sure you want to continue? + <tag>confirm</tag> + <usetemplate + ignoretext="Are you sure you want to lose changes?" + name="okcancelignore" + notext="No" + yestext="Yes"/> + </notification> + + <notification + icon="alertmodal.tga" + name="SettingsConfirmReset" + type="alertmodal"> +You are about to remove all applied settings. +Are you sure you want to continue? + <tag>confirm</tag> + <usetemplate + name="okcancelbuttons" + notext="No" + yestext="Yes"/> + </notification> + + <notification + icon="alertmodal.tga" + name="SettingsMakeNoTrans" + type="alertmodal"> +You are about to import non-transferable settings into this daycycle. Continuing will cause the settings you are editing to become non-transferable also. + +This change can not be undone. + +Are you sure you want to continue? + <tag>confirm</tag> + <usetemplate + ignoretext="Are you sure you want to make settings non-transferable?" + name="okcancelignore" + notext="No" + yestext="Yes"/> + </notification> + + <notification + icon="notify.tga" + name="NoEditFromLibrary" + persist="true" + type="alertmodal"> +You may not edit settings directly from the libary. +Please copy to your own inventory and try again. + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="EnvironmentApplyFailed" + persist="true" + type="alertmodal"> +We have encountered an issue with these settings. They can not be saved or applied at this time. + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="TrackLoadFailed" + persist="true" + type="alertmodal"> +Unable to load the track into [TRACK]. + <tag>fail</tag> + </notification> + + <notification + icon="notify.tga" + name="TrackLoadMismatch" + persist="true" + type="alertmodal"> +Unable to load the track from [TRACK1] into [TRACK2]. + <tag>fail</tag> + </notification> + </notifications> diff --git a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml index 3f13cea58e..afce9f6eb5 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml @@ -1,556 +1,556 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <!-- Side tray Outfit Edit panel --> <panel - background_visible="true" - border="false" - height="600" - follows="all" - layout="topleft" - help_topic="edit_outfit" - left="0" - min_height="350" - name="outfit_edit" - top="0" - width="320"> - <string - name="No Outfit" - value="No Outfit"/> - <string - name="unsaved_changes" - value="Unsaved Changes"/> - <string - name="now_editing" - value="Now Editing"/> - <string - name="folder_view_off" - value="Hierarchy_View_Disabled" - translate="false"/> - <string - name="folder_view_on" - value="Hierarchy_View_On" - translate="false"/> - <string - name="list_view_off" - value="List_View_Disabled" - translate="false"/> - <string - name="list_view_on" - value="List_View_On" - translate="false"/> + background_visible="true" + border="false" + height="600" + follows="all" + layout="topleft" + help_topic="edit_outfit" + left="0" + min_height="350" + name="outfit_edit" + top="0" + width="320"> + <string + name="No Outfit" + value="No Outfit"/> + <string + name="unsaved_changes" + value="Unsaved Changes"/> + <string + name="now_editing" + value="Now Editing"/> + <string + name="folder_view_off" + value="Hierarchy_View_Disabled" + translate="false"/> + <string + name="folder_view_on" + value="Hierarchy_View_On" + translate="false"/> + <string + name="list_view_off" + value="List_View_Disabled" + translate="false"/> + <string + name="list_view_on" + value="List_View_On" + translate="false"/> - <panel.string - name="not_available"> - (N\A) - </panel.string> - <panel.string - name="unknown"> - (unknown) - </panel.string> + <panel.string + name="not_available"> + (N\A) + </panel.string> + <panel.string + name="unknown"> + (unknown) + </panel.string> - <!-- Wearables filtering strings --> - <string name="Filter.All" value="All"/> - <string name="Filter.Clothes/Body" value="Clothes/Body"/> - <string name="Filter.Objects" value="Objects"/> - <string name="Filter.Clothing" value="Clothing"/> - <string name="Filter.Bodyparts" value="Body parts"/> + <!-- Wearables filtering strings --> + <string name="Filter.All" value="All"/> + <string name="Filter.Clothes/Body" value="Clothes/Body"/> + <string name="Filter.Objects" value="Objects"/> + <string name="Filter.Clothing" value="Clothing"/> + <string name="Filter.Bodyparts" value="Body parts"/> - <string - name="replace_body_part" - value="Click to replace your existing shape"/> + <string + name="replace_body_part" + value="Click to replace your existing shape"/> - <button - follows="top|left" - height="24" - image_hover_unselected="BackButton_Over" - image_pressed="BackButton_Press" - image_unselected="BackButton_Off" - layout="topleft" - name="back_btn" - left="5" - tab_stop="false" - top="1" - width="30" - use_draw_context_alpha="false" /> - <text - follows="top|left|right" - font="SansSerifHugeBold" - height="26" - layout="topleft" - left_pad="10" - name="title" - text_color="LtGray" - top="0" - value="Edit Outfit" - use_ellipses="true" - width="275" /> + <button + follows="top|left" + height="24" + image_hover_unselected="BackButton_Over" + image_pressed="BackButton_Press" + image_unselected="BackButton_Off" + layout="topleft" + name="back_btn" + left="5" + tab_stop="false" + top="1" + width="30" + use_draw_context_alpha="false" /> + <text + follows="top|left|right" + font="SansSerifHugeBold" + height="26" + layout="topleft" + left_pad="10" + name="title" + text_color="LtGray" + top="0" + value="Edit Outfit" + use_ellipses="true" + width="275" /> - <!-- "HEADER WITH ICON, STATUS TEXT AND OUTFIT NAME" --> - <panel - background_visible="true" - bg_alpha_color="DkGray2" - bevel_style="none" - follows="top|left|right" - height="40" - layout="topleft" - left="6" - name="header_panel" - top_pad="5" - width="311"> - <icon - follows="left|top" - height="31" - image_name="Shirt_Large" - left="2" - mouse_opaque="false" - name="outfit_icon" - top="2" - scale_image="true" - visible="true" - width="31" /> - <panel - bevel_style="none" - follows="top|left|right" - height="37" - layout="topleft" - left_pad="5" - name="outfit_name_and_status" - top="2" - width="270"> - <text - follows="top|left|right" - font="SansSerifSmallBold" - height="13" - layout="topleft" - name="status" - text_color="EmphasisColor" - top="2" - value="Now editing..." - use_ellipses="true" - width="245" /> - <text - follows="bottom|left|right" - font="SansSerifLargeBold" - height="18" - layout="topleft" - name="curr_outfit_name" - parse_urls="false" - text_color="LtGray" - top_pad="2" - value="[Current Outfit]" - use_ellipses="true" - width="245" /> - <loading_indicator - follows="right|top" - height="24" - layout="topleft" - right="-2" - name="edit_outfit_loading_indicator" - top="6" - width="24" /> - </panel> - </panel> + <!-- "HEADER WITH ICON, STATUS TEXT AND OUTFIT NAME" --> + <panel + background_visible="true" + bg_alpha_color="DkGray2" + bevel_style="none" + follows="top|left|right" + height="40" + layout="topleft" + left="6" + name="header_panel" + top_pad="5" + width="311"> + <icon + follows="left|top" + height="31" + image_name="Shirt_Large" + left="2" + mouse_opaque="false" + name="outfit_icon" + top="2" + scale_image="true" + visible="true" + width="31" /> + <panel + bevel_style="none" + follows="top|left|right" + height="37" + layout="topleft" + left_pad="5" + name="outfit_name_and_status" + top="2" + width="270"> + <text + follows="top|left|right" + font="SansSerifSmallBold" + height="13" + layout="topleft" + name="status" + text_color="EmphasisColor" + top="2" + value="Now editing..." + use_ellipses="true" + width="245" /> + <text + follows="bottom|left|right" + font="SansSerifLargeBold" + height="18" + layout="topleft" + name="curr_outfit_name" + parse_urls="false" + text_color="LtGray" + top_pad="2" + value="[Current Outfit]" + use_ellipses="true" + width="245" /> + <loading_indicator + follows="right|top" + height="24" + layout="topleft" + right="-2" + name="edit_outfit_loading_indicator" + top="6" + width="24" /> + </panel> + </panel> - <!-- LIST OF WEARABLES (CURRENT OUTFIT/ WEARABLES TO ADD) --> - <!-- *NOTE: border_size is used to calculate space between layout panels and also to calculate resize bar's height. + <!-- LIST OF WEARABLES (CURRENT OUTFIT/ WEARABLES TO ADD) --> + <!-- *NOTE: border_size is used to calculate space between layout panels and also to calculate resize bar's height. Required height for dragbar (icon in spec) is 10, so resizebar height should be 10 px. It is calculated as border_size + 2*UIResizeBarOverlap --> - <layout_stack - animate="true" - border_size="8" - clip="false" - default_tab_group="2" - follows="all" - height="465" - width="313" - layout="topleft" - orientation="vertical" - name="im_panels" - tab_group="1" - top_pad="5" - left="5"> - <layout_panel - layout="topleft" - height="187" - min_height="155" - name="outfit_wearables_panel" - width="313" - auto_resize="true" - user_resize="true"> + <layout_stack + animate="true" + border_size="8" + clip="false" + default_tab_group="2" + follows="all" + height="465" + width="313" + layout="topleft" + orientation="vertical" + name="im_panels" + tab_group="1" + top_pad="5" + left="5"> + <layout_panel + layout="topleft" + height="187" + min_height="155" + name="outfit_wearables_panel" + width="313" + auto_resize="true" + user_resize="true"> - <layout_stack - animate="true" - border_size="0" - follows="all" - height="185" - width="313" - orientation="vertical" - layout="topleft" - name="filter_panels" - top="0" - left="0"> - <layout_panel - auto_resize="true" - background_visible="false" - layout="topleft" - height="154" - name="add_button_and_combobox" - width="311" - visible="true"> + <layout_stack + animate="true" + border_size="0" + follows="all" + height="185" + width="313" + orientation="vertical" + layout="topleft" + name="filter_panels" + top="0" + left="0"> + <layout_panel + auto_resize="true" + background_visible="false" + layout="topleft" + height="154" + name="add_button_and_combobox" + width="311" + visible="true"> - <!-- List containing items from the COF and Base outfit --> - <panel - background_visible="false" - class="cof_wearables" - filename="panel_cof_wearables.xml" - follows="all" - height="129" - layout="topleft" - left="1" - name="cof_wearables_list" - top="0" - width="311" /> + <!-- List containing items from the COF and Base outfit --> + <panel + background_visible="false" + class="cof_wearables" + filename="panel_cof_wearables.xml" + follows="all" + height="129" + layout="topleft" + left="1" + name="cof_wearables_list" + top="0" + width="311" /> - <button - follows="left|bottom" - height="22" - image_pressed="PushButton_Press" - image_pressed_selected="PushButton_Selected_Press" - image_selected="PushButton_Selected_Press" - is_toggle="true" - label="Add More..." - layout="topleft" - left="2" - name="show_add_wearables_btn" - top_pad="2" - tool_tip="Open/Close" - width="125" /> + <button + follows="left|bottom" + height="22" + image_pressed="PushButton_Press" + image_pressed_selected="PushButton_Selected_Press" + image_selected="PushButton_Selected_Press" + is_toggle="true" + label="Add More..." + layout="topleft" + left="2" + name="show_add_wearables_btn" + top_pad="2" + tool_tip="Open/Close" + width="125" /> - <combo_box - follows="left|right|bottom" - height="22" - layout="topleft" - left_pad="5" - name="list_view_filter_combobox" - top_delta="0" - visible="false" - width="152"/> - <combo_box - follows="left|right|bottom" - height="22" - layout="topleft" - left_delta="0" - name="folder_view_filter_combobox" - top_delta="0" - visible="false" - width="152"/> + <combo_box + follows="left|right|bottom" + height="22" + layout="topleft" + left_pad="5" + name="list_view_filter_combobox" + top_delta="0" + visible="false" + width="152"/> + <combo_box + follows="left|right|bottom" + height="22" + layout="topleft" + left_delta="0" + name="folder_view_filter_combobox" + top_delta="0" + visible="false" + width="152"/> - <button - follows="bottom|right" - height="22" - image_overlay="Search_Icon" - image_pressed="PushButton_Press" - image_pressed_selected="PushButton_Selected_Press" - image_selected="PushButton_Selected_Press" - is_toggle="true" - layout="topleft" - name="filter_button" - right="-5" - top_delta="0" - visible="false" - width="20" /> - </layout_panel> + <button + follows="bottom|right" + height="22" + image_overlay="Search_Icon" + image_pressed="PushButton_Press" + image_pressed_selected="PushButton_Selected_Press" + image_selected="PushButton_Selected_Press" + is_toggle="true" + layout="topleft" + name="filter_button" + right="-5" + top_delta="0" + visible="false" + width="20" /> + </layout_panel> - <layout_panel - auto_resize="false" - background_visible="true" - bg_alpha_color="DkGray2" - height="30" - name="filter_panel" - width="311" - visible="false"> + <layout_panel + auto_resize="false" + background_visible="true" + bg_alpha_color="DkGray2" + height="30" + name="filter_panel" + width="311" + visible="false"> - <filter_editor - background_image="TextField_Search_Off" - enabled="true" - follows="left|right|top" - label="Filter Inventory Wearables" - layout="topleft" - left="5" - width="290" - height="25" - name="look_item_filter" - search_button_visible="true" - text_color="black" - visible="true"/> + <filter_editor + background_image="TextField_Search_Off" + enabled="true" + follows="left|right|top" + label="Filter Inventory Wearables" + layout="topleft" + left="5" + width="290" + height="25" + name="look_item_filter" + search_button_visible="true" + text_color="black" + visible="true"/> - </layout_panel> - </layout_stack> - </layout_panel> + </layout_panel> + </layout_stack> + </layout_panel> - <layout_panel background_visible="false" - bg_alpha_color="DkGray2" - auto_resize="true" - height="450" - min_height="80" - name="add_wearables_panel" - width="313" - tab_group="2" - user_resize="true" - visible="false"> + <layout_panel background_visible="false" + bg_alpha_color="DkGray2" + auto_resize="true" + height="450" + min_height="80" + name="add_wearables_panel" + width="313" + tab_group="2" + user_resize="true" + visible="false"> - <!-- this icon represent dragbar between layout panels. + <!-- this icon represent dragbar between layout panels. This is a workaround implemented in EXT-7255 becouse of an issue with layout stack (EXT-7471) --> - <icon follows="left|top|right" - height="10" - image_name="Dragbar" - left="0" - top_pad="-9" - width="313" /> - <inventory_panel allow_multi_select="true" - background_visible="false" - border="false" - follows="left|top|right|bottom" - height="418" - layout="topleft" - left="0" - mouse_opaque="false" - name="folder_view" - top_pad="0" - width="313" - visible="false"/> - <panel name="filtered_wearables_panel" - background_opaque="true" - background_visible="false" - layout="topleft" - follows="left|top|right|bottom" - border="false" - height="418" - left="0" - mouse_opaque="false" - width="310" - top_delta="0" - visible="true"> - <wearable_items_list color="0.107 0.107 0.107 1" - name="list_view" - allow_select="true" - layout="topleft" - follows="all" - multi_select="true" - width="313" - height="418" - left="0" - top="0"/> - </panel> - <button follows="bottom|left" - height="22" - left="2" - label="Wear Item" - layout="topleft" - name="plus_btn" - top_pad="5" - width="130" /> - </layout_panel> - </layout_stack> + <icon follows="left|top|right" + height="10" + image_name="Dragbar" + left="0" + top_pad="-9" + width="313" /> + <inventory_panel allow_multi_select="true" + background_visible="false" + border="false" + follows="left|top|right|bottom" + height="418" + layout="topleft" + left="0" + mouse_opaque="false" + name="folder_view" + top_pad="0" + width="313" + visible="false"/> + <panel name="filtered_wearables_panel" + background_opaque="true" + background_visible="false" + layout="topleft" + follows="left|top|right|bottom" + border="false" + height="418" + left="0" + mouse_opaque="false" + width="310" + top_delta="0" + visible="true"> + <wearable_items_list color="0.107 0.107 0.107 1" + name="list_view" + allow_select="true" + layout="topleft" + follows="all" + multi_select="true" + width="313" + height="418" + left="0" + top="0"/> + </panel> + <button follows="bottom|left" + height="22" + left="2" + label="Wear Item" + layout="topleft" + name="plus_btn" + top_pad="5" + width="130" /> + </layout_panel> + </layout_stack> - <!-- BUTTON BAR --> - <panel - background_visible="true" - bevel_style="none" - follows="bottom|left|right" - height="27" - layout="topleft" - left="5" - name="no_add_wearables_button_bar" - top_pad="0" - width="313"> - <menu_button - follows="bottom|left" - height="25" - image_hover_unselected="Toolbar_Left_Over" - image_overlay="OptionsMenu_Off" - image_selected="Toolbar_Left_Selected" - image_unselected="Toolbar_Left_Off" - layout="topleft" - left="0" - name="gear_menu_btn" - top="1" - width="31" /> - <icon - follows="bottom|left|right" - height="25" - image_name="Toolbar_Middle_Off" - layout="topleft" - left_pad="1" - name="dummy_right_icon" - width="250" /> - <button - follows="bottom|right" - height="25" - image_hover_unselected="Toolbar_Right_Over" - image_overlay="Shop" - image_selected="Toolbar_Right_Selected" - image_unselected="Toolbar_Right_Off" - layout="topleft" - left_pad="1" - name="shop_btn_1" - top="1" - tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it" - width="31" /> - </panel> + <!-- BUTTON BAR --> + <panel + background_visible="true" + bevel_style="none" + follows="bottom|left|right" + height="27" + layout="topleft" + left="5" + name="no_add_wearables_button_bar" + top_pad="0" + width="313"> + <menu_button + follows="bottom|left" + height="25" + image_hover_unselected="Toolbar_Left_Over" + image_overlay="OptionsMenu_Off" + image_selected="Toolbar_Left_Selected" + image_unselected="Toolbar_Left_Off" + layout="topleft" + left="0" + name="gear_menu_btn" + top="1" + width="31" /> + <icon + follows="bottom|left|right" + height="25" + image_name="Toolbar_Middle_Off" + layout="topleft" + left_pad="1" + name="dummy_right_icon" + width="250" /> + <button + follows="bottom|right" + height="25" + image_hover_unselected="Toolbar_Right_Over" + image_overlay="Shop" + image_selected="Toolbar_Right_Selected" + image_unselected="Toolbar_Right_Off" + layout="topleft" + left_pad="1" + name="shop_btn_1" + top="1" + tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it" + width="31" /> + </panel> - <!-- BUTTON BAR - WEARABLES ADDING MODE --> - <panel - background_visible="true" - bevel_style="none" - follows="left|right|bottom" - height="27" - layout="topleft" - left="5" - name="add_wearables_button_bar" - top_delta="0" - visible="false" - width="313"> - <menu_button - follows="bottom|left" - height="25" - image_hover_unselected="Toolbar_Left_Over" - image_overlay="OptionsMenu_Off" - image_selected="Toolbar_Left_Selected" - image_unselected="Toolbar_Left_Off" - layout="topleft" - left="0" - name="wearables_gear_menu_btn" - top="1" - width="31" /> - <button - follows="bottom|left" - height="25" - image_hover_unselected="Toolbar_Middle_Over" - image_overlay="Hierarchy_View_Disabled" - image_selected="Toolbar_Middle_Selected" - image_unselected="Toolbar_Middle_Off" - is_toggle="true" - layout="topleft" - left_pad="1" - name="folder_view_btn" - top="1" - width="31" /> - <button - follows="bottom|left" - height="25" - image_hover_unselected="Toolbar_Middle_Over" - image_overlay="List_View_On" - image_selected="Toolbar_Middle_Selected" - image_unselected="Toolbar_Middle_Off" - is_toggle="true" - layout="topleft" - left_pad="1" - name="list_view_btn" - top="1" - width="31" /> - <icon - follows="bottom|left|right" - height="25" - image_name="Toolbar_Middle_Off" - layout="topleft" - left_pad="1" - name="dummy_right_icon" - width="186" > - </icon> - <button - follows="bottom|right" - height="25" - image_hover_unselected="Toolbar_Right_Over" - image_overlay="Shop" - image_selected="Toolbar_Right_Selected" - image_unselected="Toolbar_Right_Off" - layout="topleft" - left_pad="1" - name="shop_btn_2" - top="1" - tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it" - width="31" /> - </panel> + <!-- BUTTON BAR - WEARABLES ADDING MODE --> + <panel + background_visible="true" + bevel_style="none" + follows="left|right|bottom" + height="27" + layout="topleft" + left="5" + name="add_wearables_button_bar" + top_delta="0" + visible="false" + width="313"> + <menu_button + follows="bottom|left" + height="25" + image_hover_unselected="Toolbar_Left_Over" + image_overlay="OptionsMenu_Off" + image_selected="Toolbar_Left_Selected" + image_unselected="Toolbar_Left_Off" + layout="topleft" + left="0" + name="wearables_gear_menu_btn" + top="1" + width="31" /> + <button + follows="bottom|left" + height="25" + image_hover_unselected="Toolbar_Middle_Over" + image_overlay="Hierarchy_View_Disabled" + image_selected="Toolbar_Middle_Selected" + image_unselected="Toolbar_Middle_Off" + is_toggle="true" + layout="topleft" + left_pad="1" + name="folder_view_btn" + top="1" + width="31" /> + <button + follows="bottom|left" + height="25" + image_hover_unselected="Toolbar_Middle_Over" + image_overlay="List_View_On" + image_selected="Toolbar_Middle_Selected" + image_unselected="Toolbar_Middle_Off" + is_toggle="true" + layout="topleft" + left_pad="1" + name="list_view_btn" + top="1" + width="31" /> + <icon + follows="bottom|left|right" + height="25" + image_name="Toolbar_Middle_Off" + layout="topleft" + left_pad="1" + name="dummy_right_icon" + width="186" > + </icon> + <button + follows="bottom|right" + height="25" + image_hover_unselected="Toolbar_Right_Over" + image_overlay="Shop" + image_selected="Toolbar_Right_Selected" + image_unselected="Toolbar_Right_Off" + layout="topleft" + left_pad="1" + name="shop_btn_2" + top="1" + tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it" + width="31" /> + </panel> - <!-- SAVE AND REVERT BUTTONS --> - <panel - follows="left|right|bottom" - height="30" - layout="topleft" - left="4" - top_pad="2" - name="save_revert_button_bar" - width="300"> - <layout_stack - follows="bottom|left|right" - height="23" - layout="topleft" - mouse_opaque="false" - name="button_bar_ls" - left="0" - orientation="horizontal" - top="0" - width="313"> - <layout_panel - follows="bottom|left|right" - height="23" - layout="bottomleft" - left="0" - mouse_opaque="false" - name="save_btn_lp" - auto_resize="true" - width="156"> - <button - follows="bottom|left|right" - height="23" - label="Save" - left="1" - layout="topleft" - name="save_btn" - top="0" - width="155" /> - <button - follows="bottom|right" - height="23" - name="save_flyout_btn" - label="" - layout="topleft" - left_pad="-20" - tab_stop="false" - top="0" - image_selected="SegmentedBtn_Right_Selected_Press" - image_unselected="SegmentedBtn_Right_Off" - image_pressed="SegmentedBtn_Right_Press" - image_pressed_selected="SegmentedBtn_Right_Selected_Press" - image_overlay="Arrow_Small_Up" - width="20"/> - </layout_panel> - <layout_panel - follows="bottom|left|right" - height="23" - layout="bottomleft" - left_pad="3" - mouse_opaque="false" - name="revert_btn_lp" - auto_resize="true" - width="147"> - <button - follows="bottom|left|right" - height="23" - left="0" - label="Undo Changes" - layout="topleft" - name="revert_btn" - top="0" - tool_tip="Revert to last saved version" - width="147" /> - </layout_panel> - </layout_stack> - </panel> + <!-- SAVE AND REVERT BUTTONS --> + <panel + follows="left|right|bottom" + height="30" + layout="topleft" + left="4" + top_pad="2" + name="save_revert_button_bar" + width="300"> + <layout_stack + follows="bottom|left|right" + height="23" + layout="topleft" + mouse_opaque="false" + name="button_bar_ls" + left="0" + orientation="horizontal" + top="0" + width="313"> + <layout_panel + follows="bottom|left|right" + height="23" + layout="bottomleft" + left="0" + mouse_opaque="false" + name="save_btn_lp" + auto_resize="true" + width="156"> + <button + follows="bottom|left|right" + height="23" + label="Save" + left="1" + layout="topleft" + name="save_btn" + top="0" + width="155" /> + <button + follows="bottom|right" + height="23" + name="save_flyout_btn" + label="" + layout="topleft" + left_pad="-20" + tab_stop="false" + top="0" + image_selected="SegmentedBtn_Right_Selected_Press" + image_unselected="SegmentedBtn_Right_Off" + image_pressed="SegmentedBtn_Right_Press" + image_pressed_selected="SegmentedBtn_Right_Selected_Press" + image_overlay="Arrow_Small_Up" + width="20"/> + </layout_panel> + <layout_panel + follows="bottom|left|right" + height="23" + layout="bottomleft" + left_pad="3" + mouse_opaque="false" + name="revert_btn_lp" + auto_resize="true" + width="147"> + <button + follows="bottom|left|right" + height="23" + left="0" + label="Undo Changes" + layout="topleft" + name="revert_btn" + top="0" + tool_tip="Revert to last saved version" + width="147" /> + </layout_panel> + </layout_stack> + </panel> </panel> diff --git a/indra/newview/skins/default/xui/en/panel_region_environment.xml b/indra/newview/skins/default/xui/en/panel_region_environment.xml index aa38c49fae..bac27f7457 100644 --- a/indra/newview/skins/default/xui/en/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml @@ -1,149 +1,880 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <panel - border="true" - follows="top|left" - height="300" - label="Environment" - layout="topleft" - help_topic="panel_region_environment_tab" - name="panel_env_info" - width="530"> - <text - name="water_settings_title" - follows="top|left" - height="30" - layout="topleft" - left="50" - top_pad="20" - width="430" - wrap="true"> - Select the Water and Sky/Day Cycle Settings you would like all visitors to your region to see. More info - </text> - <view_border - bevel_style="none" - follows="top|left" - height="237" - layout="topleft" - left="50" - name="border" - top="60" - width="430"/> - <radio_group - follows="top|left" - height="45" - layout="topleft" - left_delta="10" - name="region_settings_radio_group" - top_delta="20" - width="200"> - <radio_item - label="Use Second Life default" - layout="topleft" - name="use_sl_default_settings"/> - <radio_item - label="Use the following settings" - layout="topleft" - name="use_my_settings" - top_pad="20"/> - </radio_group> - <panel - follows="top|left" - height="150" - layout="topleft" - left="50" - name="user_environment_settings" - top_pad="20" - width="430"> - <text - name="water_settings_title" - follows="top|left" - height="16" - layout="topleft" - left="50" - top_pad="0" - width="160"> - Water Setting - </text> - <combo_box - follows="top|left" - left_pad="2" - name="water_settings_preset_combo" - top_delta="-7" - width="200"> - <combo_box.item - label="-Select a preset-" - name="item0"/> - </combo_box> - <text - name="sky_dayc_settings_title" - follows="top|left" - height="16" - layout="topleft" - left="50" - top_pad="30" - width="100"> - Sky / Day Cycle - </text> - <radio_group - layout="topleft" - left_delta="50" - name="sky_dayc_settings_radio_group" - top_pad="10" - height="50" - width="110"> - <radio_item - layout="topleft" - label="Fixed sky" - name="my_sky_settings"/> - <radio_item - layout="topleft" - label="Day cycle" - name="my_dayc_settings" - top_pad="25"/> - </radio_group> - <combo_box - follows="top|left" - left_pad="2" - name="sky_settings_preset_combo" - top_delta="-7" - width="200"> - <combo_box.item - label="-Select a preset-" - name="item0"/> - </combo_box> - <combo_box - follows="top|left" - name="dayc_settings_preset_combo" - top_delta="36" - width="200"> - <combo_box.item - label="-Select a preset-" - name="item0"/> - </combo_box> - </panel> - <button - follows="left|top" - height="23" - label="Apply" - layout="topleft" - right="-160" - name="apply_btn" - top_pad="10" - width="100" /> - <button - follows="left|top" - height="23" - label="Cancel" - layout="topleft" - left_pad="10" - name="cancel_btn" - width="100" /> - <loading_indicator - height="23" - left="50" - name="progress_indicator" - top_delta="0" - visible="false" - width="23" /> + border="true" + follows="all" + height="375" + label="Environment" + layout="topleft" + help_topic="panel_region_environment_tab" + name="panel_env_info" + width="530"> + <string name="str_label_use_default">Use Default Settings</string> + <string name="str_label_use_region">Use Region Settings</string> + <string name="str_altitude_desription">Sky [INDEX]([ALTITUDE]m)</string> + <string name="str_no_parcel">No parcel is selected. Environmental settings are disabled.</string> + <string name="str_cross_region">Environmental settings are not available across region boundries.</string> + <string name="str_legacy">Environmental settings are not available on this region.</string> + <string name="str_disallowed">The estate manager does not allow changing parcel environments in this region.</string> + <string name="str_too_small">The parcel must be at least 128 square meters to support an environment.</string> + <string name="str_empty">(empty)</string> + <string name="str_region_env">(region environment)</string> + <layout_stack + width="530" + height="367" + auto_resize="true" + follows="all" + layout="topleft" + animate="false" + orientation="vertical"> + <layout_panel + auto_resize="true" + user_resize="false" + name="pnl_environment_disabled" + visible="false"> + <text follows="top|left|bottom|right" + halign="center" + valign="top" + top_pad="40" + name="txt_environment_disabled" + text_color="white"> + ... + </text> + </layout_panel> + <layout_panel + auto_resize="true" + user_resize="false" + min_height="0" + name="pnl_environment_config" + visible="true"> + <layout_stack + xxxwidth="530" + xxxheight="367" + follows="all" + layout="topleft" + animate="false" + orientation="horizontal"> + <layout_panel + auto_resize="true" + user_resize="false" + min_height="0" + top="0" + name="pnl_environment_config" + visible="true"> + <layout_stack + follows="all" + layout="topleft" + animate="false" + orientation="vertical"> + <layout_panel + min_height="140" + follows="all" + border="true" + bevel_style="in" + name="pnl_environment_current"> + <text follows="top|left" + font="SansSerif" + halign="left" + text_color="white" + left="5" + top="2">Select Environment</text> + <button + follows="top|left" + top_pad="20" + left_delta="10" + layout="topleft" + height="23" + label="[USEDEFAULT]" + width="120" + name="btn_usedefault"/> + <button + follows="top|left" + top_pad="5" + left_delta="0" + layout="topleft" + height="23" + label="Use Inventory" + width="120" + name="btn_select_inventory"/> + <button + follows="top|left" + top_pad="5" + left_delta="0" + layout="topleft" + height="23" + label="Customize" + width="120" + name="btn_edit"/> + <check_box + height="20" + label="Parcel Owners May Override Environment" + layout="topleft" + left_delta="0" + top_pad="10" + name="chk_allow_override" + width="200" /> + </layout_panel> + <layout_panel + min_height="130" + follows="all" + border="true" + bevel_style="in" + name="pnl_environment_length"> + <text + font="SansSerif" + follows="top|left|right" + halign="left" + text_color="white" + left="5" + top="2">Day Settings</text> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="10" + top_pad="16" + width="200"> + Day Length (hours) + </text> + <slider + can_edit_text="true" + auto_resize="true" + decimal_digits="1" + follows="top|left|right" + layout="topleft" + increment="0.5" + height="20" + width="237" + left="10" + top_pad="0" + right="-10" + initial_value="4" + name="sld_day_length" + min_val="4" + max_val="168" /> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="0" + top_pad="5" + width="200"> + Day Offset (hours) + </text> + <slider + can_edit_text="true" + decimal_digits="1" + follows="top|left|right" + layout="topleft" + height="20" + width="237" + increment="0.5" + initial_value="-8" + left="10" + top_pad="0" + right="-10" + name="sld_day_offset" + min_val="-11.5" + max_val="12" /> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="0" + top_pad="5" + width="200"> + Apparent Time of Day: + </text> + <text + name="lbl_apparent_time" + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="10" + top_pad="5" + width="200"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + <layout_panel + follows="bottom" + border="true" + bevel_style="in" + name="pnl_environment_buttons"> +<!-- used to be buttons, but now spacer. +--> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel + auto_resize="true" + user_resize="false" + min_height="0" + top="0" + name="pnl_environment_altitudes" + visible="true"> + <!-- Three movable panels first so that they will be 'below' slider--> + <panel + follows="top|left" + height="26" + width="360" + layout="topleft" + visible="true" + left="1" + top="30" + name="pnl_alt1"> + <text + type="string" + length="1" + follows="left|top" + layout="topleft" + height="24" + width="52" + left_delta="2" + top_pad="1" + halign="right" + name="txt_alt1"> + Sky [INDEX] + [ALTITUDE]m + </text> + <line_editor + follows="left|top" + enabled="false" + top_delta="3" + left_pad="21" + height="20" + layout="topleft" + name="edt_invname_alt1" + width="155"> + Unknown + </line_editor> + <settings_drop_target + height="20" + top_delta="0" + left_delta="0" + follows="top|left" + layout="topleft" + name="sdt_alt1" + tool_tip="Drag a setting from Inventory onto this target box to select it as current sky." + width="155" /> + </panel> + <panel + follows="top|left" + height="26" + width="360" + layout="topleft" + visible="true" + left="1" + top="60" + name="pnl_alt2"> + <text + type="string" + length="1" + follows="left|top" + layout="topleft" + height="24" + width="52" + left_delta="2" + top_pad="1" + halign="right" + name="txt_alt2"> + Sky [INDEX] + [ALTITUDE]m + </text> + <line_editor + follows="left|top" + enabled="false" + top_delta="3" + left_pad="21" + height="20" + layout="topleft" + name="edt_invname_alt2" + width="155"> + Unknown + </line_editor> + <settings_drop_target + height="20" + top_delta="0" + left_delta="0" + follows="top|left" + layout="topleft" + name="sdt_alt2" + tool_tip="Drag a setting from Inventory onto this target box to select it as current sky." + width="155" /> + </panel> + <panel + follows="top|left" + height="26" + width="360" + layout="topleft" + visible="true" + left="1" + top="90" + name="pnl_alt3"> + <text + type="string" + length="1" + follows="left|top" + layout="topleft" + height="25" + width="52" + left_delta="2" + top_pad="1" + halign="right" + name="txt_alt3"> + Sky [INDEX] + [ALTITUDE]m + </text> + <line_editor + follows="left|top" + enabled="false" + top_delta="3" + left_pad="21" + xxxleft="-160" + height="20" + layout="topleft" + name="edt_invname_alt3" + width="155"> + Unknown + </line_editor> + <settings_drop_target + height="20" + top_delta="0" + left_delta="0" + follows="top|left" + layout="topleft" + name="sdt_alt3" + tool_tip="Drag a setting from Inventory onto this target box to select it as current sky." + width="155" /> + </panel> + <text follows="top|left" + font="SansSerif" + halign="left" + text_color="white" + left="5" + top="2">Sky Altitudes</text> + <!-- Divider icons also should be under slider to not interfer with clicks--> + <icon + color="LtGray" + height="2" + width="17" + image_name="Rounded_Square" + layout="topleft" + left="57" + top="89" + name="mark0"/> + <icon + color="LtGray" + height="2" + width="17" + image_name="Rounded_Square" + layout="topleft" + left_delta="0" + top_delta="69" + name="mark1"/> + <icon + color="LtGray" + height="2" + width="17" + image_name="Rounded_Square" + layout="topleft" + left_delta="0" + top_delta="69" + name="mark2"/> + <multi_slider + height="270" + follows="top|left" + orientation="vertical" + increment="25" + min_val="100" + max_val="4000" + thumb_image="Inv_SettingsSky" + thumb_width="17" + thumb_highlight_color="white" + decimal_digits="0" + draw_track="true" + overlap_threshold="100" + initial_value="0" + layout="topleft" + left="57" + max_sliders="3" + name="sld_altitudes" + show_text="false" + top="20" + use_triangle="false" + width="17"> + <slider name="sld1" + value="1000"/> + <slider name="sld2" + value="2000"/> + <slider name="sld3" + value="3000"/> + </multi_slider> + <panel + follows="top|left" + height="21" + width="360" + layout="topleft" + visible="true" + left="1" + top_pad="10" + name="pnl_ground"> + <text + type="string" + length="1" + follows="left|top" + layout="topleft" + height="12" + width="52" + left_delta="2" + top_pad="2" + halign="right" + name="txt_ground"> + Ground + </text> + <icon + follows="top|left" + height="17" + width="17" + image_name="Inv_SettingsSky" + layout="topleft" + name="icon_ground" + mouse_opaque="false" + visible="true" + top_delta="-3" + left_pad="2"/> + <line_editor + follows="left|top" + enabled="false" + top_delta="-1" + left_pad="2" + xxxleft="-160" + height="20" + layout="topleft" + name="edt_invname_ground" + width="155"> + Unknown + </line_editor> + <settings_drop_target + height="20" + top_delta="0" + left_delta="0" + follows="top|left" + layout="topleft" + name="sdt_ground" + tool_tip="Drag a setting from Inventory onto this target box to select it as the ground level sky." + width="155" /> + </panel> + <panel + follows="top|left" + height="21" + width="360" + layout="topleft" + visible="true" + left="1" + top_pad="10" + name="pnl_water"> + <text + type="string" + length="1" + follows="left|top" + layout="topleft" + height="12" + width="52" + left_delta="2" + top_pad="2" + halign="right" + name="txt_water"> + Water + </text> + <icon + follows="left|top" + height="17" + width="17" + image_name="Inv_SettingsWater" + layout="topleft" + name="icon_water" + mouse_opaque="false" + visible="true" + top_delta="-3" + left_pad="2"/> + <line_editor + follows="left|top" + enabled="false" + top_delta="-1" + left_pad="2" + height="20" + layout="topleft" + name="edt_invname_water" + width="155"> + Unknown + </line_editor> + <settings_drop_target + height="20" + top_delta="0" + left_delta="0" + follows="top|left" + layout="topleft" + name="sdt_water" + tool_tip="Drag a setting from Inventory onto this target box to select it as current water." + width="155" /> + </panel> + <button + follows="top|right" + layout="topleft" + height="23" + width="100" + label="Reset" + right="-10" + top_pad="4" + tool_tip="Reset to default altitudes" + name="btn_rst_altitudes" /> + </layout_panel> + </layout_stack> + </layout_panel> + <!-- + <layout_panel + auto_resize="false" + user_resize="false" + height="155" + min_height="0" + name="pnl_environment_config" + visible="true"> + <layout_stack + left="5" + top="0" + right="-5" + bottom="-1" + layout="topleft" + follows="all" + animate="false" + orientation="horizontal"> + <layout_panel + background_visible="true" + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + width="260" + min_width="260" + name="pnl_environment_current"> + <text follows="top|left" + font="SansSerif" + halign="left" + text_color="white" + top="2">Current Environment</text> + <radio_group + height="90" + layout="topleft" + top_pad="8" + left_delta="10" + name="rdg_environment_select"> + <radio_item + label="[USEDEFAULT]" + layout="topleft" + name="rdo_use_xxx_setting" + height="20"/> + <radio_item + label="Settings From Inventory" + layout="topleft" + valign="top" + name="rdo_use_inv_setting" + height="20"/> + <radio_item + top_pad="25" + label="Custom Environment" + layout="topleft" + height="20" + name="rdo_use_custom_setting"/> + </radio_group> + <line_editor + follows="top|left" + enabled="false" + left_delta="20" + top_delta="50" + height="20" + layout="topleft" + name="edt_inventory_name" + width="200"> + Unknown + </line_editor> + <settings_drop_target + height="20" + top_pad="-20" + follows="top|left" + layout="topleft" + name="sdt_drop_target" + tool_tip="Drag a setting from Inventory onto this target box to select it as current evironment." + width="200" /> + <button + name="btn_select_inventory" + follows="top|left" + image_overlay="Command_Inventory_Icon" + auto_resize="false" + layout="topleft" + height="20" + width="20" + left_delta="205" + top_delta="0"/> + <button + follows="top|left" + top_pad="25" + left_delta="-205" + layout="topleft" + height="23" + label="Edit Environment" + width="120" + name="btn_edit"/> + + </layout_panel> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + width="260" + min_width="260" + background_visible="true" + name="pnl_environment_length"> + <text + font="SansSerif" + follows="top|left|right" + halign="left" + text_color="white" + top="2">Day Settings</text> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="10" + top_pad="14" + width="200"> + Day Length (hours) + </text> + <slider + can_edit_text="true" + decimal_digits="1" + follows="left|top" + height="20" + increment="0.5" + initial_value="4" + layout="topleft" + left_delta="0" + top_pad="6" + name="sld_day_length" + min_val="4" + max_val="168" + width="180" /> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="0" + top_pad="10" + width="200"> + Day Offset (hours) + </text> + <slider + can_edit_text="true" + decimal_digits="1" + follows="left|top" + height="20" + increment="0.5" + initial_value="-8" + layout="topleft" + left_delta="0" + top_pad="6" + name="sld_day_offset" + min_val="-12" + max_val="12" + width="180" /> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="0" + top_pad="10" + width="200"> + Apparent Time of Day: + </text> + <text + name="lbl_apparent_time" + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_delta="10" + top_pad="5" + width="200"> + [HH]:[MM][AP] ([PRC]%) + </text> + + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel + auto_resize="false" + user_resize="false" + height="155" + min_height="0" + name="pnl_environment_altitudes" + visible="true"> + <panel + left="5" + top="0" + bottom="-1" + width="260" + follows="left|top|bottom" + background_visible="true" + border="true" + bevel_style="in" + name="cnt_panel"> + <text follows="top|left" + font="SansSerif" + halign="left" + text_color="white" + top="2">Sky Altitudes</text> + <multi_slider + decimal_digits="0" + follows="bottom" + height="123" + width="17" + orientation="vertical" + increment="10" + overlap_threshold="100" + min_val="100" + max_val="4000" + layout="topleft" + left="15" + top="20" + max_sliders="20" + name="sld_altitudes" + show_text="false" + thumb_image="Inv_SettingsSky" + thumb_width="17" + thumb_highlight_color="white"> + <slider name="sld1" + value="200"/> + <slider name="sld2" + value="400"/> + <slider name="sld3" + value="600"/> + </multi_slider> + <icon + follows="left|top" + height="17" + width="17" + image_name="Inv_SettingsSky" + layout="topleft" + name="icon_ground" + mouse_opaque="false" + visible="true" + left_delta="0" + top_pad="-9"/> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left_pad="3" + top_delta="2" + width="200" + name="ground"> + Ground + </text> + <text + type="string" + length="1" + follows="left" + height="12" + layout="topleft" + left="35" + top="30" + width="200" + name="alt1"> + Sky [INDEX]([ALTITUDE]m) + </text> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left="35" + top="40" + width="200" + name="alt2"> + Sky [INDEX]([ALTITUDE]m) + </text> + <text + type="string" + length="1" + follows="left|top" + height="12" + layout="topleft" + left="35" + top="50" + width="200" + name="alt3"> + Sky [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel + auto_resize="true" + user_resize="false" + height="0" + min_height="0" + name="pnl_auto_adjust" + visible="true"/> + <layout_panel + auto_resize="false" + user_resize="false" + height="59" + min_height="59" + name="pnl_environment_buttons"> + <check_box + height="20" + label="Parcel Owners May Override Environment" + layout="topleft" + left="10" + top="0" + name="chk_allow_override" + width="200" /> + <button + follows="top|left" + height="23" + label="Apply" + top_pad="5" + name="btn_apply" + width="100" /> + <button + follows="top|left" + height="23" + label="Reset" + layout="topleft" + left_pad="10" + top_delta="0" + name="btn_cancel" + width="100" /> + + </layout_panel> +--> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..e6fdc76de1 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml @@ -0,0 +1,322 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + border="true" + follows="all" + label="Atmosphere & Lighting" + layout="topleft" + left="0" + name="panel_settings_sky_atmos" + top="0"> + <layout_stack + follows="all" + layout="topleft" + left="5" + top="5" + right="-5" + bottom="-5" + orientation="vertical"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="false" + user_resize="false" + visible="true" + height="75"> + + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="15" + top_pad="15" + width="80"> + Ambient Color: + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="37" + label_height="0" + layout="topleft" + left_delta="0" + name="ambient_light" + top_pad="5" + width="60" /> + <text + follows="left" + height="10" + layout="topleft" + left_delta="90" + top_delta="-15" + width="80"> + Blue Horizon: + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="37" + label_height="0" + layout="topleft" + left_delta="0" + name="blue_horizon" + top_pad="5" + width="60" /> + <text + follows="left" + height="10" + layout="topleft" + left_delta="90" + top_delta="-15" + width="80"> + Blue Density: + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="37" + label_height="0" + layout="topleft" + left_delta="0" + name="blue_density" + top_pad="5" + width="60" /> + </layout_panel> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true"> + <layout_stack name="atmosphere1" + left="5" + top="5" + right="-5" + bottom="-5" + follows="left|top|right|bottom" + orientation="hoizontal"> + <layout_panel + border="false" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + min_width="225"> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="15" + top_pad="15" + width="80"> + Haze Horizon: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="5" + name="haze_horizon" + top_delta="20" + width="207" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="80"> + Haze Density: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="5" + name="haze_density" + top_delta="20" + width="207" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="80"> + Moisture Level: + </text> + <slider + decimal_digits="3" + follows="left|top" + height="14" + increment="0.001" + initial_value="0" + left_delta="5" + top_delta="20" + layout="topleft" + min_val="0" + max_val="1" + name="moisture_level" + width="207" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="80"> + Droplet Radius: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="14" + increment="0.01" + initial_value="0" + left_delta="5" + top_delta="20" + layout="topleft" + min_val="5.0" + max_val="1000.0" + name="droplet_radius" + width="207" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="80"> + Ice Level: + </text> + <slider + decimal_digits="1" + follows="left|top" + height="14" + increment="0.1" + initial_value="0" + left_delta="5" + top_delta="20" + layout="topleft" + min_val="0" + max_val="1" + name="ice_level" + width="207" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="80"> + Scene Gamma: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + max_val="20" + name="scene_gamma" + top_delta="20" + width="207" + can_edit_text="true"/> + </layout_panel> + <layout_panel + border="false" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + min_width="225"> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="15" + top_pad="15" + width="200"> + Density Multiplier: + </text> + <slider + decimal_digits="4" + follows="left|top" + height="16" + increment="0.0001" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0.0001" + max_val="2" + name="density_multip" + top_delta="20" + width="219" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="200"> + Distance Multiplier: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1000" + name="distance_multip" + top_delta="20" + width="219" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="200"> + Maximum Altitude: + </text> + <slider + decimal_digits="1" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="10000" + name="max_alt" + top_delta="20" + width="219" + can_edit_text="true"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..50d4c52a10 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml @@ -0,0 +1,271 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + border="true" + follows="all" + label="Clouds" + layout="topleft" + left="0" + help_topic="land_general_tab" + name="panel_settings_sky_clouds" + top="0"> + <layout_stack + follows="all" + layout="topleft" + left="5" + top="5" + right="-5" + bottom="-5" + orientation="hoizontal"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="75"> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="15" + top_pad="15" + width="80"> + Cloud Color: + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="37" + label_height="0" + layout="topleft" + left_delta="0" + name="cloud_color" + top_pad="5" + width="60" /> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="0" + top_delta="47" + width="200"> + Cloud Coverage: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1" + name="cloud_coverage" + top_delta="20" + width="214" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="200"> + Cloud Scale: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0.01" + max_val="3" + name="cloud_scale" + top_delta="20" + width="214" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="200"> + Cloud Variance: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1.0" + name="cloud_variance" + top_delta="20" + width="214" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="25" + width="200"> + Cloud Scroll: + </text> + <xy_vector + follows="left|top" + name="cloud_scroll_xy" + width="120" + height="145" + visible="true" + left_delta="0" + top_delta="21" + min_val_x="-30" + max_val_x="30" + min_val_y="-30" + max_val_y="30" + logarithmic="1"/> + + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="160" + top_delta="-20" + width="200"> + Cloud Image: + </text> + <texture_picker + height="123" + layout="topleft" + left_delta="5" + name="cloud_map" + top_pad="10" + width="100"/> + </layout_panel> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="75"> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="15" + top_pad="15" + width="200"> + Cloud Density: + </text> + <slider + label="X" + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1" + name="cloud_density_x" + top_delta="20" + width="200" + can_edit_text="true"/> + <slider + label="Y" + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="0" + min_val="0" + max_val="1" + name="cloud_density_y" + top_delta="20" + width="200" + can_edit_text="true"/> + <slider + label="D" + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="0" + min_val="0" + max_val="3" + name="cloud_density_d" + top_delta="20" + width="200" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="35" + width="200"> + Cloud Detail: + </text> + <slider + label="X" + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1" + name="cloud_detail_x" + top_delta="20" + width="200" + can_edit_text="true"/> + <slider + label="Y" + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="0" + min_val="0" + max_val="1" + name="cloud_detail_y" + top_delta="20" + width="200" + can_edit_text="true"/> + <slider + label="D" + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="0" + min_val="0" + max_val="1" + name="cloud_detail_d" + top_delta="20" + width="200" + can_edit_text="true"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml new file mode 100644 index 0000000000..b3a33961bc --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml @@ -0,0 +1,273 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + border="true" + follows="all" + label="Density" + layout="topleft" + left="0" + help_topic="sky_density" + name="panel_settings_sky_density" + top="0"> + <layout_stack + follows="all" + layout="topleft" + left="5" + top="5" + right="-5" + bottom="-5" + orientation="vertical"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="12"> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1" + name="rayleigh_exponential" + label="Rayleigh Exponential Term:" + top_pad="12" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.000001" + initial_value="0" + layout="topleft" + min_val="-0.01" + max_val="0.01" + name="rayleigh_exponential_scale" + label="Rayleigh Exponential Scale:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.000001" + initial_value="0" + layout="topleft" + min_val="0" + max_val="0.00001" + name="rayleigh_linear" + label="Rayleigh Linear Term:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + min_val="0" + max_val="1" + name="rayleigh_constant" + label="Rayleigh Constant Term:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="1" + follows="left|top" + height="14" + initial_value="0" + layout="topleft" + min_val="1000" + max_val="40000" + name="rayleigh_max_altitude" + label="Rayleigh Max Altitude:" + width="400" + label_width="160" + can_edit_text="true"/> + </layout_panel> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="14"> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="3.0" + name="mie_exponential" + label="Mie Exponential Term:" + top_pad="12" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + min_val="-0.01" + max_val="0.01" + name="mie_exponential_scale" + label="Mie Exponential Scale:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.000001" + initial_value="0" + layout="topleft" + min_val="0" + max_val="0.000004" + name="mie_linear" + label="Mie Linear Term:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + min_val="0" + max_val="1" + name="mie_constant" + label="Mie Constant Term:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="2" + follows="left|top" + height="14" + increment="0.01" + initial_value="0" + layout="topleft" + min_val="0.2" + max_val="1.8" + name="mie_aniso_factor" + label="Mie Aniso Factor:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="1" + follows="left|top" + height="14" + increment="0.1" + initial_value="0" + layout="topleft" + min_val="1000" + max_val="30000" + name="mie_max_altitude" + label="Mie Max Altitude:" + width="400" + label_width="160" + can_edit_text="true"/> + </layout_panel> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="12"> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1" + name="absorption_exponential" + label="Absorption Exponential Term:" + top_pad="8" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + min_val="-1" + max_val="1" + name="absorption_exponential_scale" + label="Absorption Exponential Scale:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + min_val="0" + max_val="1" + name="absorption_linear" + label="Absorption Linear Term:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="6" + follows="left|top" + height="14" + increment="0.0000001" + initial_value="0" + layout="topleft" + min_val="0" + max_val="1" + name="absorption_constant" + label="Absorption Constant Term:" + width="400" + label_width="160" + can_edit_text="true"/> + <slider + decimal_digits="1" + follows="left|top" + height="14" + increment="0.1" + initial_value="0" + layout="topleft" + min_val="1000" + max_val="25000" + name="absorption_max_altitude" + label="Absorption Max Altitude:" + width="400" + label_width="160" + can_edit_text="true"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..bbba5ba729 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml @@ -0,0 +1,317 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + border="true" + follows="all" + label="Sun & Moon" + layout="topleft" + left="0" + name="panel_settings_sky_hbodies" + top="0"> + <layout_stack + follows="all" + layout="topleft" + left="5" + top="5" + right="-5" + bottom="-5" + orientation="horizontal"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="400"> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="15" + top_pad="15" + font="SansSerifBold" + width="120"> + Sun & Stars + </text> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="10" + top_delta="30" + width="100"> + Position: + </text> + <sun_moon_trackball + name="sun_rotation" + follows="left|top" + left_delta="0" + top_delta="20" + height="150" + width="150" + thumb_mode="sun" /> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="160" + top_delta="-20" + width="200"> + Image: + </text> + <texture_picker + height="123" + layout="topleft" + left_delta="5" + name="sun_image" + top_pad="10" + width="100"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="110" + width="80"> + Scale: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0.25" + max_val="20" + name="sun_scale" + top_delta="15" + width="130" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="20" + width="80"> + Color: + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="37" + label_height="0" + layout="topleft" + left_delta="5" + name="sun_moon_color" + top_pad="5" + width="60" /> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-160" + top_delta="27" + width="200"> + Glow Focus: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="-2" + max_val="2" + name="glow_focus" + top_delta="15" + width="250" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="22" + width="200"> + Glow Size: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="1.99" + name="glow_size" + top_delta="15" + width="250" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="22" + width="200"> + Star Brightness: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="500" + name="star_brightness" + top_delta="15" + width="250" + can_edit_text="true"/> + + <check_box + control_name="sunbeacon" + width="60" + height="16" + label="Show Beacon" + layout="topleft" + name="sunbeacon" + right="-50" + bottom="-10" + follows="bottom|right"/> + + </layout_panel> + <layout_panel + border="false" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="400"> + <layout_stack + left="5" + top="5" + right="-5" + bottom="-5" + follows="left|top|right|bottom" + orientation="vertical"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + height="220"> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="15" + top_pad="15" + font="SansSerifBold" + width="80"> + Moon + </text> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="10" + top_delta="30" + width="100"> + Position: + </text> + <sun_moon_trackball + name="moon_rotation" + follows="left|top" + left_delta="0" + top_delta="20" + height="150" + width="150" + thumb_mode="moon" /> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="160" + top_delta="-20" + width="200"> + Image: + </text> + <texture_picker + height="123" + layout="topleft" + left_delta="5" + name="moon_image" + top_pad="10" + width="100"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="110" + width="80"> + Scale: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0.25" + max_val="20" + name="moon_scale" + top_delta="15" + width="130" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="22" + width="200"> + Brightness: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0.0" + max_val="1.0" + name="moon_brightness" + top_delta="15" + width="130" + can_edit_text="true"/> + <check_box + control_name="moonbeacon" + width="60" + height="16" + label="Show Beacon" + layout="topleft" + name="moonbeacon" + right="-50" + bottom="-10" + follows="bottom|right"/> + + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/en/panel_settings_water.xml b/indra/newview/skins/default/xui/en/panel_settings_water.xml new file mode 100644 index 0000000000..991ce25bec --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_water.xml @@ -0,0 +1,374 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + border="true" + follows="all" + label="Water" + layout="topleft" + left="0" + help_topic="land_general_tab" + name="panel_settings_water" + top="0"> + <layout_stack name="water_stack1" + follows="all" + layout="topleft" + left="5" + top="5" + right="-5" + bottom="-5" + orientation="vertical"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="false" + user_resize="false" + visible="true" + height="105"> + <text + follows="left|top" + height="20" + font="SansSerif" + layout="topleft" + left="5" + top="5" + width="215"> + Water Fog: + </text> + <text + follows="left|top" + height="10" + layout="left|top" + left_delta="15" + top_delta="0" + width="60"> + Color: + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="37" + label_height="0" + layout="topleft" + left_delta="0" + name="water_fog_color" + top_pad="5" + width="60" /> + <text + follows="left|top" + height="10" + top_delta="-15" + left_delta="80" + width="150"> + Density Exponent: + </text> + <slider + decimal_digits="1" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="top" + left_delta="15" + min_val="-10" + max_val="10" + name="water_fog_density" + top_delta="5" + width="150" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + top_delta="25" + left_delta="-15" + width="150"> + Underwater Modifier:</text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="top" + left_delta="15" + min_val="0.0" + max_val="20.0" + name="water_underwater_mod" + top_delta="20" + width="150" + can_edit_text="true"/> + + <text + follows="left|top|right" + height="10" + layout="topleft" + left_delta="165" + top_delta="-53" + width="150"> + Fresnel Scale: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0.7" + layout="topleft" + left_delta="5" + name="water_fresnel_scale" + top_delta="15" + width="150" + can_edit_text="true"/> + <text + follows="left|top|right" + layout="topleft" + left_delta="-5" + name="FresnelOffsetText" + top_delta="25" + width="150"> + Fresnel Offset: + </text> + <slider + decimal_digits="2" + follows="left|top" + increment="0.01" + initial_value="0.7" + height="16" + layout="topleft" + left_delta="5" + name="water_fresnel_offset" + top_pad="5" + width="150" + can_edit_text="true"/> + + </layout_panel> + <layout_panel + auto_resize="true" + user_resize="false" + visible="true"> + <layout_stack name="water_stack2" + left="5" + top="5" + right="-5" + bottom="-5" + follows="left|top|right|bottom" + orientation="horizontal"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + min_width="460" + width="50"> + <text + follows="left|top|right" + height="16" + layout="topleft" + left="15" + top="5" + width="215"> + Normal Map + </text> + <texture_picker + height="84" + layout="topleft" + left_delta="0" + name="water_normal_map" + top_pad="5" + width="61"/> + + <text + follows="left|top" + height="16" + width="120" + layout="topleft" + top_delta="-20" + left_delta="175"> + Large Wave Speed + </text> + <xy_vector + follows="top|left" + name="water_wave1_xy" + width="120" + height="145" + visible="true" + left_delta="0" + top_delta="21" + min_val_x="-20" + max_val_x="20" + increment_x="0.01f" + min_val_y="-20" + max_val_y="20" + increment_y="0.01f" + arrow_color="white"/> + + <text + follows="left|top" + height="16" + layout="topleft" + top_delta="-20" + left_delta="140"> + Small Wave Speed + </text> + <xy_vector + follows="top|left" + name="water_wave2_xy" + width="120" + height="145" + visible="true" + left_delta="0" + top_delta="21" + min_val_x="-20" + max_val_x="20" + min_val_y="-20" + max_val_y="20" + increment_x="0.01f" + increment_y="0.01f" + arrow_color="white"/> + + <text + follows="left|top|right" + height="16" + layout="topleft" + left="10" + top="90" + width="215"> + Reflection Wavelet Scale + </text> + <slider + decimal_digits="1" + follows="left|top" + increment="0.01" + height="16" + initial_value="0.7" + layout="topleft" + label="X:" + left_delta="10" + max_val="10" + name="water_normal_scale_x" + top_pad="5" + width="150" + can_edit_text="true"/> + <slider + decimal_digits="1" + follows="left|top" + increment="0.01" + initial_value="0.7" + height="16" + layout="topleft" + max_val="10" + name="water_normal_scale_y" + top_pad="6" + label="Y:" + width="150" + can_edit_text="true"/> + <slider + decimal_digits="1" + follows="left|top" + increment="0.01" + initial_value="0.7" + height="16" + layout="topleft" + max_val="10" + name="water_normal_scale_z" + top_pad="6" + label="Z:" + width="150" + can_edit_text="true"/> + + </layout_panel> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="false" + width="50" + visible="true"> + <text + follows="left|top" + height="20" + font="SansSerif" + layout="topleft" + left="5" + top="5" + width="215"> + Refraction And Blur: + </text> + <text + follows="left|top|right" + height="16" + layout="topleft" + top_delta="25" + left_delta="5" + width="215"> + Refraction Scale (Above) + </text> + <slider + control_name="water_scale_above" + decimal_digits="2" + follows="left|top" + increment="0.01" + initial_value="0.1" + height="16" + layout="topleft" + left_delta="5" + min_val="0" + max_val="3" + name="water_scale_above" + top_pad="5" + width="200" + can_edit_text="true" /> + <text + type="string" + length="1" + follows="left|top|right" + height="16" + layout="topleft" + left_delta="-5" + top_pad="5" + width="215"> + Refraction Scale (Below) + </text> + <slider + control_name="water_scale_below" + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="3" + name="water_scale_below" + top_pad="5" + width="200" + can_edit_text="true"/> + <text + follows="left|top|right" + font="SansSerif" + height="16" + layout="topleft" + left_delta="-5" + top_pad="5" + width="215"> + Blur Multiplier + </text> + <slider + control_name="water_blur_multip" + follows="left|top" + height="16" + increment="0.001" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="-0.5" + max_val="0.5" + name="water_blur_multip" + top_pad="5" + width="200" + can_edit_text="true"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/en/role_actions.xml b/indra/newview/skins/default/xui/en/role_actions.xml index f79d752fdb..bda08f3421 100644 --- a/indra/newview/skins/default/xui/en/role_actions.xml +++ b/indra/newview/skins/default/xui/en/role_actions.xml @@ -92,7 +92,10 @@ <action description="Toggle various About Land > Options settings" longdescription="Toggle 'Safe (no damage)', 'Fly', and allow other Residents to: 'Edit Terrain', 'Build', 'Create Landmarks', and 'Run Scripts' on group-owned land in About Land > Options tab." name="land options" value="22" /> - </action_set> + <action description="Modify environment settings and day cycle." + longdescription="Change the environment settings and day cycle from the About Land > Environment tab." + name="land change environment" value="46" /> + </action_set> <action_set description="These Abilities include powers which allow Members to bypass restrictions on group-owned parcels." name="Parcel Powers"> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index f5f4b4acab..71133f582f 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -315,6 +315,17 @@ Please try logging in again in a minute.</string> <string name="BUTTON_DOCK">Dock</string> <string name="BUTTON_HELP">Show Help</string> + <!-- ToolTips for notecards --> + <string name="TooltipNotecardNotAllowedTypeDrop"> +Items of this type can't be attached +to notecards on this region. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> +Only items with unrestricted +'next owner' permissions +"can be attached to notecards. + </string> + <!-- searching - generic --> <string name="Searching">Searching...</string> <string name="NoneFound">None found.</string> @@ -367,6 +378,11 @@ Error in upload request. Please visit http://secondlife.com/support for help fixing this problem. </string> + <!-- Settings errors --> + <string name="SettingValidationError">Validation failed for importing settings [NAME]</string> + <string name="SettingImportFileError">Could not open file [FILE]</string> + <string name="SettingParseFileError">Could not open file [FILE]</string> + <string name="SettingTranslateError">Could not translate legacy windlight [NAME]</string> <!-- Asset Type human readable names: these will replace variable [TYPE] in notification FailedToFindWearable* --> <!-- Will also replace [OBJECTTYPE] in notifications: UserGiveItem, ObjectGiveItem --> <string name="texture">texture</string> @@ -393,9 +409,10 @@ http://secondlife.com/support for help fixing this problem. <string name="simstate">simstate</string> <string name="favorite">favorite</string> <string name="symbolic link">link</string> - <string name="symbolic folder link">folder link</string> - <string name="mesh">mesh</string> - + <string name="settings blob">settings</string> + <string name="symbolic folder link">folder link</string> + <string name="mesh">mesh</string> + <!-- llvoavatar. Displayed in the avatar chat bubble --> <string name="AvatarEditingAppearance">(Editing Appearance)</string> <string name="AvatarAway">Away</string> @@ -519,6 +536,7 @@ http://secondlife.com/support for help fixing this problem. <string name="ManageEstateSilently">Manage your estates silently</string> <string name="ChangeYourDefaultAnimations">Change your default animations</string> <string name="ForceSitAvatar">Force your avatar to sit</string> + <string name="ChangeEnvSettings">Change your environment settings</string> <string name="NotConnected">Not Connected</string> <string name="AgentNameSubst">(You)</string> <!-- Substitution for agent name --> @@ -2768,6 +2786,14 @@ If you continue to receive this message, please contact Second Life support for <!-- Environment settings --> <string name="LocalSettings">Local Settings</string> <string name="RegionSettings">Region Settings</string> + <string name="NoEnvironmentSettings">This Region does not support environmental settings.</string> + + <string name="EnvironmentSun">Sun</string> + <string name="EnvironmentMoon">Moon</string> + <string name="EnvironmentBloom">Bloom</string> + <string name="EnvironmentCloudNoise">Cloud Noise</string> + <string name="EnvironmentNormalMap">Normal Map</string> + <string name="EnvironmentTransparent">Transparent</string> <!-- panel classified --> <string name="ClassifiedClicksTxt">Clicks: [TELEPORT] teleport, [MAP] map, [PROFILE] profile</string> @@ -3849,6 +3875,11 @@ Abuse Report</string> <string name="Female - Shrug">Female - Shrug</string> <string name="Female - Stick tougue out">Female - Stick tongue out</string> <string name="Female - Wow">Female - Wow</string> + <!-- settings --> + <string name="New Daycycle">New Daycycle</string> + <string name="New Water">New Water</string> + <string name="New Sky">New Sky</string> + <string name="/bow">/bow</string> <string name="/clap">/clap</string> @@ -4068,6 +4099,8 @@ Try enclosing path to the editor with double quotes. <string name="BeaconScriptedTouch">Viewing scripted object with touch function beacons (red)</string> <string name="BeaconSound">Viewing sound beacons (yellow)</string> <string name="BeaconMedia">Viewing media beacons (white)</string> + <string name="BeaconSun">Viewing sun direction beacon (orange)</string> + <string name="BeaconMoon">Viewing moon direction beacon (purple)</string> <string name="ParticleHiding">Hiding Particles</string> <!-- commands --> @@ -4191,6 +4224,8 @@ Try enclosing path to the editor with double quotes. <string name="ExperiencePermission10">control your camera</string> <string name="ExperiencePermission11">teleport you</string> <string name="ExperiencePermission12">automatically accept experience permissions</string> + <string name="ExperiencePermission16">force your avatar to sit</string> + <string name="ExperiencePermission17">change your environment settings</string> <string name="ExperiencePermissionShortUnknown">perform an unknown operation: [Permission]</string> <string name="ExperiencePermissionShort1">Take Controls</string> <string name="ExperiencePermissionShort3">Trigger Animations</string> @@ -4199,6 +4234,8 @@ Try enclosing path to the editor with double quotes. <string name="ExperiencePermissionShort10">Control Camera</string> <string name="ExperiencePermissionShort11">Teleport</string> <string name="ExperiencePermissionShort12">Permission</string> + <string name="ExperiencePermissionShort16">Sit</string> + <string name="ExperiencePermissionShort17">Environment</string> <!-- Conversation log messages --> <string name="logging_calls_disabled_log_empty"> diff --git a/indra/newview/skins/default/xui/en/widgets/density_ctrl.xml b/indra/newview/skins/default/xui/en/widgets/density_ctrl.xml new file mode 100644 index 0000000000..0f3f0159db --- /dev/null +++ b/indra/newview/skins/default/xui/en/widgets/density_ctrl.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<densityctrl + border="true" + follows="all" + label="Density" + name="density_ctrl" + layout="topleft" + left="0" + top="0" + width="320" + height="240"> + <text + follows="left|top" + height="11" + layout="topleft" + left="15" + top_pad="-5" + width="120"> +Exponential Term + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left="15" + min_val="0" + max_val="1" + name="level_exponential" + top_delta="15" + width="200" + can_edit_text="true"/> + + <view + left_pad="15" + top="15" + name="preview_image" + height="140" + width="140" + follows="left|top" + /> + <text + follows="left|top" + height="11" + layout="topleft" + left="15" + top_pad="-5" + width="120"> +Exponential Scale Factor + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left="15" + min_val="0" + max_val="1" + name="exponential_scale" + top_delta="15" + width="200" + can_edit_text="true"/> + + <text + follows="left|top" + height="11" + layout="topleft" + left="15" + top_pad="-5" + width="120"> +Linear Term + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left="15" + min_val="0" + max_val="1" + name="level_linear" + top_delta="15" + width="200" + can_edit_text="true"/> + + <text + follows="left|top" + height="11" + layout="topleft" + left="15" + top_pad="-5" + width="120"> +Constant Term + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left="15" + min_val="0" + max_val="1" + name="level_constant" + top_delta="15" + width="200" + can_edit_text="true"/> + + <text + follows="left|top" + height="11" + layout="topleft" + left="15" + top_pad="15" + width="80"> +Max Altitude + </text> + <slider + decimal_digits="0" + follows="left|top" + height="16" + increment="1" + initial_value="0" + layout="topleft" + left="15" + min_val="1000" + max_val="40000" + name="max_altitude" + top_delta="15" + width="200" + can_edit_text="true"/> + + <text + follows="left|top" + height="11" + layout="topleft" + name="aniso_factor_label" + left="15" + top_pad="15" + width="80"> +Anisotropy Factor + </text> + <slider + decimal_digits="0" + follows="left|top" + height="16" + increment="1" + initial_value="0" + layout="topleft" + left="15" + min_val="1000" + max_val="40000" + name="aniso_factor" + top_delta="15" + width="200" + can_edit_text="true"/> +</densityctrl> diff --git a/indra/newview/skins/default/xui/en/widgets/joystick_quat.xml b/indra/newview/skins/default/xui/en/widgets/joystick_quat.xml new file mode 100644 index 0000000000..a190da3909 --- /dev/null +++ b/indra/newview/skins/default/xui/en/widgets/joystick_quat.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<joystick_rotate + image_selected="Cam_Rotate_In" + image_unselected="Cam_Rotate_Out" + scale_image="false" + mouse_opaque="false" + held_down_delay.seconds="0"/> diff --git a/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml b/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml index a190da3909..cbf721b346 100644 --- a/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml +++ b/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<joystick_rotate +<joystick_quat image_selected="Cam_Rotate_In" image_unselected="Cam_Rotate_Out" - scale_image="false" + scale_image="true" mouse_opaque="false" held_down_delay.seconds="0"/> diff --git a/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml b/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml new file mode 100644 index 0000000000..9fa77855c0 --- /dev/null +++ b/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<sun_moon_trackball + name="virtualtrackball" + width="150" + height="150" + user_resize="false" + increment_angle_mouse="1.5f" + increment_angle_btn="1.0f" + image_sphere="VirtualTrackball_Sphere" + image_moon_back="VirtualTrackball_Moon_Back" + image_moon_front="VirtualTrackball_Moon_Front" + image_sun_back="VirtualTrackball_Sun_Back" + image_sun_front="VirtualTrackball_Sun_Front"> + + <sun_moon_trackball.border + visible="true"/> + + <sun_moon_trackball.labelN + font="SansSerif" + name="labelN" + valign="bottom" + halign="left" + label="N"/> + <sun_moon_trackball.labelS + font="SansSerif" + name="labelS" + valign="top" + halign="left" + label="S"/> + <sun_moon_trackball.labelW + font="SansSerif" + name="labelW" + valign="top" + halign="right" + label="W"/> + <sun_moon_trackball.labelE + font="SansSerif" + name="labelE" + valign="top" + halign="left" + label="E"/> + + <sun_moon_trackball.button_rotate_top + name="btn_rotate_top" + image_unselected="VirtualTrackball_Rotate_Top" + image_selected="VirtualTrackball_Rotate_Top_Active" + image_disabled="Blank" /> + + <sun_moon_trackball.button_rotate_bottom + name="btn_rotate_bottom" + image_unselected="VirtualTrackball_Rotate_Bottom" + image_selected="VirtualTrackball_Rotate_Bottom_Active" + image_disabled="Blank" /> + + <sun_moon_trackball.button_rotate_left + name="btn_rotate_left" + image_unselected="VirtualTrackball_Rotate_Left" + image_selected="VirtualTrackball_Rotate_Left_Active" + image_disabled="Blank" /> + + <sun_moon_trackball.button_rotate_right + name="btn_rotate_right" + image_unselected="VirtualTrackball_Rotate_Right" + image_selected="VirtualTrackball_Rotate_Right_Active" + image_disabled="Blank" /> + +</sun_moon_trackball> + diff --git a/indra/newview/skins/default/xui/en/widgets/xy_vector.xml b/indra/newview/skins/default/xui/en/widgets/xy_vector.xml new file mode 100644 index 0000000000..93ae26a6ad --- /dev/null +++ b/indra/newview/skins/default/xui/en/widgets/xy_vector.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<xy_vector + name="xyvector" + width="120" + height="140" + decimal_digits="1" + label_width="16" + padding="4" + edit_bar_height="18" + user_resize="false"> + + <xy_vector.border + visible="true"/> + + <xy_vector.x_entry + name="XEntry" + tab_stop="true" + label="X:"/> + <xy_vector.y_entry + name="YEntry" + tab_stop="true" + label="Y:"/> + + <xy_vector.touch_area + name="TouchArea" + bevel_style="in" + border_visible="true"/> + +</xy_vector> diff --git a/indra/newview/skins/default/xui/es/floater_about_land.xml b/indra/newview/skins/default/xui/es/floater_about_land.xml index b5da302762..857b39361a 100644 --- a/indra/newview/skins/default/xui/es/floater_about_land.xml +++ b/indra/newview/skins/default/xui/es/floater_about_land.xml @@ -467,5 +467,6 @@ los media: </panel> </panel> <panel label="EXPERIENCIAS" name="land_experiences_panel"/> + <panel label="ENTORNO" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/es/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/es/floater_delete_env_preset.xml deleted file mode 100644 index bd0910e5d4..0000000000 --- a/indra/newview/skins/default/xui/es/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="ELIMINAR EL ENV PREDEFINIDO"> - <string name="title_water"> - Eliminar el agua predefinida - </string> - <string name="title_sky"> - Eliminar cielo predefinido - </string> - <string name="title_day_cycle"> - Eliminar ciclo del día - </string> - <string name="label_water"> - Predefinido: - </string> - <string name="label_sky"> - Predefinido: - </string> - <string name="label_day_cycle"> - Ciclo del día: - </string> - <string name="msg_confirm_deletion"> - ¿Estás seguro de que quieres eliminar el valor predefinido seleccionado? - </string> - <string name="msg_sky_is_referenced"> - No se puede quitar un valor predefinido al que se hace referencia en otro u otros ciclos del día. - </string> - <string name="combo_label"> - -Selecciona un valor predefinido- - </string> - <text name="label"> - Predefinido: - </text> - <button label="Eliminar" name="delete"/> - <button label="Cancelar" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/es/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/es/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..7521b2aed3 --- /dev/null +++ b/indra/newview/skins/default/xui/es/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="Editar Ciclo del día"> + <string name="title_new"> + Crear un Nuevo ciclo del día + </string> + <string name="title_edit"> + Editar Ciclo del día + </string> + <string name="hint_new"> + Asigna un nombre al ciclo del día, ajusta los controles para crearlo y selecciona "Guardar". + </string> + <string name="hint_edit"> + Para editar el ciclo del día, ajusta los controles siguientes y selecciona "Guardar". + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + Cielo [ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + Nombre del Ciclo del día: + </text> + <button label="Importar" name="btn_import" tool_tip="Importar configuración legado desde disco."/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="Cielo 4" name="sky4_track"/> + <button label="Cielo 3" name="sky3_track"/> + <button label="Cielo 2" name="sky2_track"/> + <button label="Nivel del terreno" name="sky1_track"/> + <button label="Agua" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="Ir hacia atrás"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="Ir hacia adelante"/> + </layout_panel> + </layout_stack> + <button label="Añadir Marco" name="add_frame"/> + <button label="Cargar Marco" name="btn_load_frame"/> + <button label="Borrar Marco" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + Seleccionar un marco clave de la línea de tiempo indicada arriba para editar los parámetros. + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="Agua" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="Atmósfera e Iluminación" name="atmosphere_panel"/> + <panel label="Nubes" name="clouds_panel"/> + <panel label="Sol y Luna" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="Guardar" name="save_btn"/> + <button label="Cancelar" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/es/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/es/floater_fixedenvironment.xml new file mode 100644 index 0000000000..d17dcaad01 --- /dev/null +++ b/indra/newview/skins/default/xui/es/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="Entorno fijo"> + <string name="edit_sky"> + Editar Cielo: + </string> + <string name="edit_water"> + Editar Agua: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="Cargar" name="btn_load" tool_tip="Cargar una configuración del inventario"/> + <button label="Importar" name="btn_import" tool_tip="Importar configuración legado desde disco."/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="Guardar" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="Cancelar" name="btn_cancel" tool_tip="Volver a la última versión guardada"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/es/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/es/floater_inventory_view_finder.xml index 5698e39bee..4f3c177976 100644 --- a/indra/newview/skins/default/xui/es/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/es/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="Sonidos" name="check_sound"/> <check_box label="Texturas" name="check_texture"/> <check_box label="Fotos" name="check_snapshot"/> + <check_box label="Opciones" name="check_settings"/> <button label="Todos" label_selected="Todo" name="All"/> <button label="Ninguno" label_selected="Nada" name="None"/> <check_box label="Mostrar siempre las carpetas" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/es/floater_my_environments.xml b/indra/newview/skins/default/xui/es/floater_my_environments.xml new file mode 100644 index 0000000000..9032ac7aa3 --- /dev/null +++ b/indra/newview/skins/default/xui/es/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="Lugares" name="my_environments" title="MIS ENTORNOS..."> + <layout_stack> + <layout_panel label="Filtros" name="filter_panel"> + <check_box label="Días" name="chk_days"/> + <check_box label="Cielos" name="chk_skies"/> + <check_box label="Agua" name="chk_water"/> + </layout_panel> + <layout_panel label="Entornos" name="list_panel"> + <check_box initial_value="false" label="Mostrar Carpetas Vacías" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="Más opciones"/> + <menu_button name="btn_newsettings" tool_tip="Crear una opción nueva"/> + <button name="btn_del" tool_tip="Borrar esta opción"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/es/floater_settings_picker.xml b/indra/newview/skins/default/xui/es/floater_settings_picker.xml new file mode 100644 index 0000000000..d537391c48 --- /dev/null +++ b/indra/newview/skins/default/xui/es/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="DESTACADO: CONFIGURACIÓN"> + <floater.string name="choose_picture"> + Pulsa para elegir una imagen + </floater.string> + <floater.string name="pick title"> + Destacado: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="Filtrar las texturas" name="flt_inventory_search"/> + <check_box initial_value="false" label="Ver las carpetas" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="OK" label_selected="OK" name="btn_select"/> + <button label="Cancelar" label_selected="Cancelar" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/es/menu_inventory.xml b/indra/newview/skins/default/xui/es/menu_inventory.xml index c5bc301608..a49be406ba 100644 --- a/indra/newview/skins/default/xui/es/menu_inventory.xml +++ b/indra/newview/skins/default/xui/es/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="Activar" name="Marketplace Activate"/> <menu_item_call label="Desactivar" name="Marketplace Deactivate"/> <menu_item_call label="Compartir" name="Share"/> - <menu_item_call label="Comprar" name="Task Buy"/> <menu_item_call label="Abrir" name="Task Open"/> <menu_item_call label="Ejecutar" name="Task Play"/> <menu_item_call label="Propiedades" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="Pelo nuevo" name="New Hair"/> <menu_item_call label="Ojos nuevos" name="New Eyes"/> </menu> + <menu label="Nueva configuración" name="New Settings"> + <menu_item_call label="Nuevo Cielo" name="New Sky"/> + <menu_item_call label="Nueva Agua" name="New Water"/> + <menu_item_call label="Nuevo Ciclo del día" name="New Day Cycle"/> + </menu> <menu label="Usar como valor predeterminado para" name="upload_def"> <menu_item_call label="Imágenes subidas" name="Image uploads"/> <menu_item_call label="Sonidos subidos" name="Sound uploads"/> @@ -102,6 +106,9 @@ <menu_item_call label="Editar" name="Wearable Edit"/> <menu_item_call label="Añadir" name="Wearable Add"/> <menu_item_call label="Quitarse" name="Take Off"/> + <menu_item_call label="Aplicar sólo a Mi mismo" name="Settings Apply Local"/> + <menu_item_call label="Aplicar a la Parcela" name="Settings Apply Parcel"/> + <menu_item_call label="Aplicar a la Región" name="Settings Apply Region"/> <menu_item_call label="Copiar en artículos del Mercado" name="Marketplace Copy"/> <menu_item_call label="Mover a artículos del Mercado" name="Marketplace Move"/> <menu_item_call label="--sin opciones--" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/es/menu_inventory_add.xml b/indra/newview/skins/default/xui/es/menu_inventory_add.xml index f17cfe4ceb..c06f5e2156 100644 --- a/indra/newview/skins/default/xui/es/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/es/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="Sonido ([COST] L$)..." name="Upload Sound"/> <menu_item_call label="Animación ([COST] L$)..." name="Upload Animation"/> <menu_item_call label="Modelo..." name="Upload Model"/> - <menu_item_call label="Asistente de modelo..." name="Upload Model Wizard"/> <menu_item_call label="Masivo ([COST] L$ por archivo)..." name="Bulk Upload"/> - <menu_item_call label="Configurar los permisos por defecto de subida" name="perm prefs"/> </menu> <menu_item_call label="Carpeta nueva" name="New Folder"/> <menu_item_call label="Script nuevo" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="Pelo nuevo" name="New Hair"/> <menu_item_call label="Ojos nuevos" name="New Eyes"/> </menu> + <menu label="Nueva Configuración" name="New Settings"> + <menu_item_call label="Nuevo Cielo" name="New Sky"/> + <menu_item_call label="Nueva Agua" name="New Water"/> + <menu_item_call label="Nuevo Ciclo del día" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/es/menu_save_settings.xml b/indra/newview/skins/default/xui/es/menu_save_settings.xml new file mode 100644 index 0000000000..164763427d --- /dev/null +++ b/indra/newview/skins/default/xui/es/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="Guardar" name="save_settings"/> + <menu_item_check label="Guardar como" name="save_as_new_settings"/> + <menu_item_check label="Asignar" name="commit_changes"/> + <menu_item_check label="Aplicar sólo a Mi mismo" name="apply_local"/> + <menu_item_check label="Aplicar a la Parcela" name="apply_parcel"/> + <menu_item_check label="Aplicar a la Región" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/es/menu_settings_add.xml b/indra/newview/skins/default/xui/es/menu_settings_add.xml new file mode 100644 index 0000000000..82bd384ab5 --- /dev/null +++ b/indra/newview/skins/default/xui/es/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="Nuevo Cielo" name="New Sky"/> + <menu_item_call label="Nueva Agua" name="New Water"/> + <menu_item_call label="Nuevo Ciclo del día" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/es/menu_settings_gear.xml b/indra/newview/skins/default/xui/es/menu_settings_gear.xml new file mode 100644 index 0000000000..5d1b43933f --- /dev/null +++ b/indra/newview/skins/default/xui/es/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="Editar" name="edit_settings"/> + <menu_item_call label="Aplicar sólo a Mi mismo" name="Settings Apply Local"/> + <menu_item_call label="Aplicar a la Parcela" name="Settings Apply Parcel"/> + <menu_item_call label="Aplicar a la Región" name="Settings Apply Region"/> + <menu_item_call label="Copiar" name="copy_settings"/> + <menu_item_call label="Pegar" name="paste_settings"/> + <menu_item_call label="Copiar la UUID" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/es/menu_viewer.xml b/indra/newview/skins/default/xui/es/menu_viewer.xml index beb6c76c27..4f407e4b1a 100644 --- a/indra/newview/skins/default/xui/es/menu_viewer.xml +++ b/indra/newview/skins/default/xui/es/menu_viewer.xml @@ -77,30 +77,14 @@ <menu_item_check label="Propiedades de la parcela" name="Parcel Properties"/> <menu_item_check label="Menú Avanzado" name="Show Advanced Menu"/> </menu> - <menu label="Dom" name="Sun"> + <menu label="Entorno" name="Environment"> <menu_item_check label="Amanecer" name="Sunrise"/> <menu_item_check label="Mediodía" name="Noon"/> <menu_item_check label="Atardecer" name="Sunset"/> <menu_item_check label="Medianoche" name="Midnight"/> - <menu_item_check label="Usar Configuración de la Región" name="Use Region Settings"/> - </menu> - <menu label="Editor de entorno" name="Environment Editor"> - <menu_item_call label="Configuración del entorno..." name="Environment Settings"/> - <menu label="Agua predefinida" name="Water Presets"> - <menu_item_call label="Nuevo predefinido..." name="new_water_preset"/> - <menu_item_call label="Editar predefinido..." name="edit_water_preset"/> - <menu_item_call label="Eliminar predefinido..." name="delete_water_preset"/> - </menu> - <menu label="Cielos predefinidos" name="Sky Presets"> - <menu_item_call label="Nuevo predefinido..." name="new_sky_preset"/> - <menu_item_call label="Editar predefinido..." name="edit_sky_preset"/> - <menu_item_call label="Eliminar predefinido..." name="delete_sky_preset"/> - </menu> - <menu label="Días predefinidos" name="Day Presets"> - <menu_item_call label="Nuevo predefinido..." name="new_day_preset"/> - <menu_item_call label="Editar predefinido..." name="edit_day_preset"/> - <menu_item_call label="Eliminar predefinido..." name="delete_day_preset"/> - </menu> + <menu_item_check label="Usar entorno compartido" name="Use Shared Environment"/> + <menu_item_call label="Mis entornos..." name="my_environs"/> + <menu_item_check label="Pausar Nubes" name="pause_clouds"/> </menu> </menu> <menu label="Construir" name="BuildTools"> @@ -297,7 +281,6 @@ <menu_item_check label="Formas del físico" name="Physics Shapes"/> <menu_item_check label="Actualizar el tipo" name="Update Type"/> <menu_item_check label="Información sobre el nivel de detalle" name="LOD Info"/> - <menu_item_check label="Recuento de triángulo" name="Triangle Count"/> <menu_item_check label="Crear cola" name="Build Queue"/> <menu_item_check label="Partículas" name="Particles"/> <menu_item_check label="Articulaciones" name="Joints"/> @@ -372,7 +355,6 @@ <menu_item_check label="Show Collision Skeleton" name="Show Collision Skeleton"/> <menu_item_check label="Mostrar los huesos" name="Show Bones"/> <menu_item_check label="Display Agent Target" name="Display Agent Target"/> - <menu_item_check label="Mostrar las medidas impostoras" name="Show Impostor Extents"/> <menu_item_call label="Debug Avatar Textures" name="Debug Avatar Textures"/> </menu> <menu_item_check label="HTTP Textures" name="HTTP Textures"/> diff --git a/indra/newview/skins/default/xui/es/notifications.xml b/indra/newview/skins/default/xui/es/notifications.xml index 70825eadbe..f4f0d0a3ed 100644 --- a/indra/newview/skins/default/xui/es/notifications.xml +++ b/indra/newview/skins/default/xui/es/notifications.xml @@ -1880,7 +1880,7 @@ Se cambiarán miles de regiones, y se provocará un colapso en el espacio del se <usetemplate canceltext="Cancelar" name="yesnocancelbuttons" notext="Todos los estados" yestext="Este estado"/> </notification> <notification label="Seleccionar el estado" name="EstateBannedAgentRemove"> - ¿Quitar de la lista de prohibición de acceso a este residente para que acceda sólo a este estado o a [ALL_ESTATES]? + ¿Quitar a este Residente de la lista de acceso prohibido para este estado únicamente o para [ALL_ESTATES]? <usetemplate canceltext="Cancelar" name="yesnocancelbuttons" notext="Todos los estados" yestext="Este estado"/> </notification> <notification label="Seleccionar el estado" name="EstateManagerAdd"> @@ -1927,6 +1927,10 @@ Se cambiarán miles de regiones, y se provocará un colapso en el espacio del se Si esta opción no está seleccionada, se anularán las restricciones establecidas por los dueños de parcelas para evitar provocaciones, mantener la privacidad o proteger a los residentes menores de material para adultos. Por favor, consulte con los dueños de parcelas según sea necesario. <usetemplate name="okbutton" yestext="Aceptar"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + Si esta opción no está seleccionada, se anularán los entornos personalizados añadidos por los dueños a sus parcelas. Por favor, consulta con los dueños de parcelas según sea necesario. + <usetemplate name="okbutton" yestext="OK"/> + </notification> <notification name="RegionEntryAccessBlocked"> Tus preferencias de contenido actuales te impiden visitar la región que has seleccionado. Puedes cambiar las preferencias en Yo > Preferencias > General. <usetemplate name="okbutton" yestext="OK"/> @@ -4346,4 +4350,40 @@ Prueba a seleccionar un terreno más pequeño. [REASON] <usetemplate name="okbutton" yestext="Aceptar"/> </notification> + <notification name="FailedToFindSettings"> + No se pudo cargar la configuración para [NAME] a partir de la base de datos. + </notification> + <notification name="FailedToLoadSettingsApply"> + No se pudo aplicar esa configuración al entorno. + </notification> + <notification name="FailedToBuildSettingsDay"> + No se pudo aplicar esa configuración al entorno. + </notification> + <notification name="NoEnvironmentSettings"> + Esta región no es compatible con las opciones de entorno. + </notification> + <notification name="WLImportFail"> + No se pudo importar la configuración de Viento de luz legado de [FILE]. + </notification> + <notification name="WLParcelApplyFail"> + No se pudo configurar el entorno para esta parcela. +Por favor ingresa o selecciona una parcela cuyos derechos puedes modificar. + </notification> + <notification name="SettingsUnsuported"> + La configuración de entorno no está disponible en esta región. +Por favor accede a una región cuya configuración esté disponible y vuelve a intentar. + </notification> + <notification name="SettingsConfirmLoss"> + Estás a punto de perder los cambios que realizaste en este [TYPE] llamado "[NAME]". +¿Estás seguro de que deseas continuar? + <usetemplate ignoretext="¿Estás seguro de que quieres perder los cambios?" name="okcancelignore" notext="No" yestext="Sí"/> + </notification> + <notification name="SettingsMakeNoTrans"> + Estás a punto de importar parámetros no transferibles a este ciclo del día. Si continúas, las opciones que estás editando pasarán a ser no transferibles también. + +Este cambio no se puede deshacer. + +¿Estás seguro de que deseas continuar? + <usetemplate ignoretext="¿Estás seguro de que quieres que esta opción sea no transferible?" name="okcancelignore" notext="No" yestext="Sí"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/es/panel_region_environment.xml b/indra/newview/skins/default/xui/es/panel_region_environment.xml index a73f1deed4..98d4e7513c 100644 --- a/indra/newview/skins/default/xui/es/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/es/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="Entorno" name="panel_env_info"> - <text name="water_settings_title"> - Selecciona la configuración de agua y cielo/ciclo del día que deseas que vean todos los visitantes de tu región. Más información - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Usar los valores predeterminados de Second Life" name="use_sl_default_settings"/> - <radio_item label="Usar la configuración siguiente" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - Configuración de agua - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-Selecciona un valor predefinido-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - Cielo/Ciclo del día - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="Cielo invariable" name="my_sky_settings"/> - <radio_item label="Ciclo del día" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-Selecciona un valor predefinido-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-Selecciona un valor predefinido-" name="item0"/> - </combo_box> - </panel> - <button label="Aplicar" name="apply_btn"/> - <button label="Cancelar" name="cancel_btn"/> + <string name="str_label_use_default"> + Usar la configuración predeterminada + </string> + <string name="str_label_use_region"> + Usar Configuración de la Región + </string> + <string name="str_unknow_inventory"> + Desconocido + </string> + <string name="str_altitude_desription"> + Cielo [INDEX]([ALTITUDE]m) + </string> + <string name="str_no_parcel"> + No se ha seleccionado ninguna parcela. Las opciones de entorno están desactivadas. + </string> + <string name="str_cross_region"> + Las opciones de entorno no están disponibles en las fronteras de regiones. + </string> + <string name="str_legacy"> + La configuración de entorno no está disponible en esta región. + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="Configuración del Inventario" name="rdo_use_inv_setting"/> + <radio_item label="Entorno personalizado" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + Desconocido + </line_editor> + <button label="Editar Entorno" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100." name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + Terreno + </text> + <text name="alt1"> + Cielo [INDEX]([ALTITUDE]m) + </text> + <text name="alt2"> + Cielo [INDEX]([ALTITUDE]m) + </text> + <text name="alt3"> + Cielo [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="Los propietarios de parcelas pueden borrar el entorno" name="chk_allow_override"/> + <button label="Aplicar" name="btn_apply"/> + <button label="Restablecer" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/es/panel_region_estate.xml b/indra/newview/skins/default/xui/es/panel_region_estate.xml index 7e12b0e599..ae62976486 100644 --- a/indra/newview/skins/default/xui/es/panel_region_estate.xml +++ b/indra/newview/skins/default/xui/es/panel_region_estate.xml @@ -26,17 +26,17 @@ <check_box label="Permitir el teleporte a cualquier punto" name="allow_direct_teleport"/> <button label="Aplicar" name="apply_btn"/> <text name="estate_manager_label"> - Administradores del estado: + Administradores de estado: </text> <text name="allow_resident_label"> - Siempre permitido: + Siempre autorizado: </text> <button label="Añadir..." name="add_estate_manager_btn"/> <button label="Quitar..." name="remove_estate_manager_btn"/> <button label="Añadir..." name="add_allowed_avatar_btn"/> <button label="Quitar..." name="remove_allowed_avatar_btn"/> <text name="allow_group_label"> - Grupos siempre permitidos: + Grupos siempre autorizados: </text> <text name="ban_resident_label"> Siempre prohibido: diff --git a/indra/newview/skins/default/xui/es/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/es/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..bce312dc18 --- /dev/null +++ b/indra/newview/skins/default/xui/es/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Atmósfera e Iluminación" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/es/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/es/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..0aa6f1e41a --- /dev/null +++ b/indra/newview/skins/default/xui/es/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Nubes" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/es/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/es/panel_settings_sky_density.xml new file mode 100644 index 0000000000..743f901c7f --- /dev/null +++ b/indra/newview/skins/default/xui/es/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Densidad" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Período exponencial Rayleigh:" name="rayleigh_exponential"/> + <slider label="Escala exponencial Rayleigh:" name="rayleigh_exponential_scale"/> + <slider label="Período lineal Rayleigh:" name="rayleigh_linear"/> + <slider label="Período constante Rayleigh:" name="rayleigh_constant"/> + <slider label="Altitud máxima Rayleigh:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Período exponencial Mie:" name="mie_exponential"/> + <slider label="Escala exponencial Mie:" name="mie_exponential_scale"/> + <slider label="Período lineal Mie:" name="mie_linear"/> + <slider label="Período constante Mie:" name="mie_constant"/> + <slider label="Factor Aniso Mie:" name="mie_aniso_factor"/> + <slider label="Altitud máxima Mie:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Período exponencial de Absorción:" name="absorption_exponential"/> + <slider label="Escala exponencial de Absorción:" name="absorption_exponential_scale"/> + <slider label="Período lineal de Absorción:" name="absorption_linear"/> + <slider label="Período constante de Absorción:" name="absorption_constant"/> + <slider label="Altitud máxima de Absorción:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/es/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/es/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..f322369063 --- /dev/null +++ b/indra/newview/skins/default/xui/es/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Sol y Luna" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/es/panel_settings_water.xml b/indra/newview/skins/default/xui/es/panel_settings_water.xml new file mode 100644 index 0000000000..c0d0cb5636 --- /dev/null +++ b/indra/newview/skins/default/xui/es/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Agua" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + Compensación Fresnel: + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X:" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/es/strings.xml b/indra/newview/skins/default/xui/es/strings.xml index 36a2711a5c..a6bda0dabe 100644 --- a/indra/newview/skins/default/xui/es/strings.xml +++ b/indra/newview/skins/default/xui/es/strings.xml @@ -627,6 +627,15 @@ Intenta iniciar sesión de nuevo en unos instantes. <string name="BUTTON_HELP"> Ver la Ayuda </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + Los objetos de este tipo no se pueden adjuntar +a las notas de esta región. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + Sólo los objetos con permisos +«próximo propietario» sin restricciones +pueden adjuntarse a las notas. + </string> <string name="Searching"> Buscando... </string> @@ -775,6 +784,9 @@ http://secondlife.com/support para obtener ayuda sobre cómo solucionar este pro <string name="symbolic link"> el enlace </string> + <string name="settings blob"> + opciones + </string> <string name="symbolic folder link"> enlace de la carpeta </string> @@ -2460,6 +2472,9 @@ Si sigues recibiendo el mismo mensaje, solicita ayuda al personal de asistencia <string name="RegionSettings"> Configuración de la región </string> + <string name="NoEnvironmentSettings"> + Esta región no es compatible con las opciones de entorno. + </string> <string name="ClassifiedClicksTxt"> Clics: [TELEPORT] teleportes, [MAP] mapa, [PROFILE] perfil </string> @@ -4742,6 +4757,15 @@ Denuncia de infracción <string name="Female - Wow"> Mujer - Admiración </string> + <string name="New Daycycle"> + Nuevo Ciclo del día + </string> + <string name="New Water"> + Nueva Agua + </string> + <string name="New Sky"> + Nuevo Cielo + </string> <string name="/bow"> /reverencia </string> diff --git a/indra/newview/skins/default/xui/fr/floater_about_land.xml b/indra/newview/skins/default/xui/fr/floater_about_land.xml index 42d7709c99..2c7bfcd282 100644 --- a/indra/newview/skins/default/xui/fr/floater_about_land.xml +++ b/indra/newview/skins/default/xui/fr/floater_about_land.xml @@ -472,5 +472,6 @@ musique : </panel> </panel> <panel label="EXPÉRIENCES" name="land_experiences_panel"/> + <panel label="ENVIRONNEMENT" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/fr/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/fr/floater_delete_env_preset.xml deleted file mode 100644 index c666a25c10..0000000000 --- a/indra/newview/skins/default/xui/fr/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="SUPPRIMER PRÉRÉGLAGE ENV."> - <string name="title_water"> - Supprimer un préréglage de l'eau - </string> - <string name="title_sky"> - Supprimer un préréglage du ciel - </string> - <string name="title_day_cycle"> - Supprimer un cycle du jour - </string> - <string name="label_water"> - Préréglage : - </string> - <string name="label_sky"> - Préréglage : - </string> - <string name="label_day_cycle"> - Cycle du jour : - </string> - <string name="msg_confirm_deletion"> - Voulez-vous vraiment supprimer le préréglage sélectionné ? - </string> - <string name="msg_sky_is_referenced"> - Impossible de supprimer un préréglage référencé dans un ou plusieurs cycles du jour. - </string> - <string name="combo_label"> - -Sélectionner un préréglage- - </string> - <text name="label"> - Préréglage : - </text> - <button label="Supprimer" name="delete"/> - <button label="Annuler" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/fr/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/fr/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..de79028bb6 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="Modifier un cycle du jour"> + <string name="title_new"> + Créer un nouveau cycle du jour + </string> + <string name="title_edit"> + Modifier un cycle du jour + </string> + <string name="hint_new"> + Donner un nom au cycle du jour, ajuster les contrôles afin de le créer, puis cliquez sur « Enregistrer ». + </string> + <string name="hint_edit"> + Pour modifier le cycle du jour, ajustez les contrôles ci-dessous, puis cliquez sur « Enregistrer ». + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + Ciel [ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + Nom du cycle du jour : + </text> + <button label="Importer" name="btn_import" tool_tip="Importer les paramètres hérités du disque."/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="Ciel 4" name="sky4_track"/> + <button label="Ciel 3" name="sky3_track"/> + <button label="Ciel 2" name="sky2_track"/> + <button label="Niveau du sol" name="sky1_track"/> + <button label="Eau" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="Reculer"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="Avancer"/> + </layout_panel> + </layout_stack> + <button label="Ajouter un cadre" name="add_frame"/> + <button label="Charger un cadre" name="btn_load_frame"/> + <button label="Supprimer le cadre" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + Sélectionnez un cadre clé à partir du calendrier ci-dessus pour modifier les paramètres. + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="Eau" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="Atmosphère et éclairage" name="atmosphere_panel"/> + <panel label="Nuages" name="clouds_panel"/> + <panel label="Soleil et lune" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="Enregistrer" name="save_btn"/> + <button label="Annuler" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/fr/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/fr/floater_fixedenvironment.xml new file mode 100644 index 0000000000..515a1d2843 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="Environnement fixe"> + <string name="edit_sky"> + Modifier le ciel : + </string> + <string name="edit_water"> + Modifier l'eau + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="Charger" name="btn_load" tool_tip="Charger des paramètres à partir de l'inventaire"/> + <button label="Importer" name="btn_import" tool_tip="Importer les paramètres hérités du disque."/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="Enregistrer" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="Annuler" name="btn_cancel" tool_tip="Rétablir la dernière version enregistrée"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/fr/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/fr/floater_inventory_view_finder.xml index 471dddf448..4e20431cc4 100644 --- a/indra/newview/skins/default/xui/fr/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/fr/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="Sons" name="check_sound"/> <check_box label="Textures" name="check_texture"/> <check_box label="Photos" name="check_snapshot"/> + <check_box label="Paramètres" name="check_settings"/> <button label="Tout" label_selected="Tout" name="All"/> <button bottom_delta="0" label="Aucun" label_selected="Aucun" name="None"/> <check_box label="Toujours montrer les dossiers" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/fr/floater_my_environments.xml b/indra/newview/skins/default/xui/fr/floater_my_environments.xml new file mode 100644 index 0000000000..2214a2dab9 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="Endroits" name="my_environments" title="MES ENVIRONNEMENTS"> + <layout_stack> + <layout_panel label="Filtres" name="filter_panel"> + <check_box label="Jours" name="chk_days"/> + <check_box label="Ciels" name="chk_skies"/> + <check_box label="Eau" name="chk_water"/> + </layout_panel> + <layout_panel label="Environnements" name="list_panel"> + <check_box initial_value="false" label="Afficher les dossiers vides" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="Plus d'options"/> + <menu_button name="btn_newsettings" tool_tip="Créer un nouveau paramètre"/> + <button name="btn_del" tool_tip="Supprimer ce paramètre"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/fr/floater_settings_picker.xml b/indra/newview/skins/default/xui/fr/floater_settings_picker.xml new file mode 100644 index 0000000000..d92a4c27ae --- /dev/null +++ b/indra/newview/skins/default/xui/fr/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="CHOISIR : PARAMÈTRES"> + <floater.string name="choose_picture"> + Cliquer pour sélectionner une image. + </floater.string> + <floater.string name="pick title"> + Choisir : + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="Filtrer les textures" name="flt_inventory_search"/> + <check_box initial_value="false" label="Afficher les dossiers" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="OK" label_selected="OK" name="btn_select"/> + <button label="Annuler" label_selected="Annuler" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/fr/menu_inventory.xml b/indra/newview/skins/default/xui/fr/menu_inventory.xml index c8bd7dc130..2b946cf64f 100644 --- a/indra/newview/skins/default/xui/fr/menu_inventory.xml +++ b/indra/newview/skins/default/xui/fr/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="Activer" name="Marketplace Activate"/> <menu_item_call label="Désactiver" name="Marketplace Deactivate"/> <menu_item_call label="Partager" name="Share"/> - <menu_item_call label="Acheter" name="Task Buy"/> <menu_item_call label="Ouvrir" name="Task Open"/> <menu_item_call label="Jouer" name="Task Play"/> <menu_item_call label="Propriétés" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="Nouveaux cheveux" name="New Hair"/> <menu_item_call label="Nouveaux yeux" name="New Eyes"/> </menu> + <menu label="Nouveaux paramètres" name="New Settings"> + <menu_item_call label="Nouveau ciel" name="New Sky"/> + <menu_item_call label="Nouvelle eau" name="New Water"/> + <menu_item_call label="Nouveau cycle du jour" name="New Day Cycle"/> + </menu> <menu label="Utiliser comme défaut pour" name="upload_def"> <menu_item_call label="Chargements d’images" name="Image uploads"/> <menu_item_call label="Chargements de sons" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="Modifier" name="Wearable Edit"/> <menu_item_call label="Ajouter" name="Wearable Add"/> <menu_item_call label="Enlever" name="Take Off"/> + <menu_item_call label="Appliquer uniquement à moi-même" name="Settings Apply Local"/> + <menu_item_call label="Appliquer à la parcelle" name="Settings Apply Parcel"/> + <menu_item_call label="Appliquer à la région" name="Settings Apply Region"/> <menu_item_call label="Copier dans les annonces Place du marché" name="Marketplace Copy"/> <menu_item_call label="Déplacer dans les annonces Place du marché" name="Marketplace Move"/> <menu_item_call label="--aucune option--" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/fr/menu_inventory_add.xml b/indra/newview/skins/default/xui/fr/menu_inventory_add.xml index 1076af44d9..b4801d2498 100644 --- a/indra/newview/skins/default/xui/fr/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/fr/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="Son ([COST] L$)..." name="Upload Sound"/> <menu_item_call label="Animation ([COST] L$)..." name="Upload Animation"/> <menu_item_call label="Modèle..." name="Upload Model"/> - <menu_item_call label="Assistant Modèle..." name="Upload Model Wizard"/> <menu_item_call label="Lot ([COST] L$ par fichier)..." name="Bulk Upload"/> - <menu_item_call label="Définir les droits de chargement par défaut" name="perm prefs"/> </menu> <menu_item_call label="Nouveau dossier" name="New Folder"/> <menu_item_call label="Nouveau script" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="Nouveaux cheveux" name="New Hair"/> <menu_item_call label="Nouveaux yeux" name="New Eyes"/> </menu> + <menu label="Nouveaux paramètres" name="New Settings"> + <menu_item_call label="Nouveau ciel" name="New Sky"/> + <menu_item_call label="Nouvelle eau" name="New Water"/> + <menu_item_call label="Nouveau cycle du jour" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/fr/menu_save_settings.xml b/indra/newview/skins/default/xui/fr/menu_save_settings.xml new file mode 100644 index 0000000000..34a3f00925 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="Enregistrer" name="save_settings"/> + <menu_item_check label="Enregistrer sous" name="save_as_new_settings"/> + <menu_item_check label="Valider" name="commit_changes"/> + <menu_item_check label="Appliquer uniquement à moi-même" name="apply_local"/> + <menu_item_check label="Appliquer à la parcelle" name="apply_parcel"/> + <menu_item_check label="Appliquer à la région" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/fr/menu_settings_add.xml b/indra/newview/skins/default/xui/fr/menu_settings_add.xml new file mode 100644 index 0000000000..cbd7cba494 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="Nouveau ciel" name="New Sky"/> + <menu_item_call label="Nouvelle eau" name="New Water"/> + <menu_item_call label="Nouveau cycle du jour" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/fr/menu_settings_gear.xml b/indra/newview/skins/default/xui/fr/menu_settings_gear.xml new file mode 100644 index 0000000000..a4e52d373b --- /dev/null +++ b/indra/newview/skins/default/xui/fr/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="Modifier" name="edit_settings"/> + <menu_item_call label="Appliquer uniquement à moi-même" name="Settings Apply Local"/> + <menu_item_call label="Appliquer à la parcelle" name="Settings Apply Parcel"/> + <menu_item_call label="Appliquer à la région" name="Settings Apply Region"/> + <menu_item_call label="Copier" name="copy_settings"/> + <menu_item_call label="Coller" name="paste_settings"/> + <menu_item_call label="Copier l’UUID" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/fr/menu_viewer.xml b/indra/newview/skins/default/xui/fr/menu_viewer.xml index 3980ca8e02..185820fb63 100644 --- a/indra/newview/skins/default/xui/fr/menu_viewer.xml +++ b/indra/newview/skins/default/xui/fr/menu_viewer.xml @@ -77,30 +77,14 @@ <menu_item_check label="Propriétés de la parcelle" name="Parcel Properties"/> <menu_item_check label="Menu Avancé" name="Show Advanced Menu"/> </menu> - <menu label="Soleil" name="Sun"> + <menu label="Environnement" name="Environment"> <menu_item_check label="Aube" name="Sunrise"/> <menu_item_check label="Midi" name="Noon"/> <menu_item_check label="Coucher de soleil" name="Sunset"/> <menu_item_check label="Minuit" name="Midnight"/> - <menu_item_check label="Utiliser les réglages de la région" name="Use Region Settings"/> - </menu> - <menu label="Éditeur d'environnement" name="Environment Editor"> - <menu_item_call label="Paramètres d'environnement..." name="Environment Settings"/> - <menu label="Préréglages de l'eau" name="Water Presets"> - <menu_item_call label="Nouveau préréglage..." name="new_water_preset"/> - <menu_item_call label="Modifier un préréglage..." name="edit_water_preset"/> - <menu_item_call label="Supprimer un préréglage..." name="delete_water_preset"/> - </menu> - <menu label="Préréglages du ciel" name="Sky Presets"> - <menu_item_call label="Nouveau préréglage..." name="new_sky_preset"/> - <menu_item_call label="Modifier un préréglage..." name="edit_sky_preset"/> - <menu_item_call label="Supprimer un préréglage..." name="delete_sky_preset"/> - </menu> - <menu label="Préréglages du jour" name="Day Presets"> - <menu_item_call label="Nouveau préréglage..." name="new_day_preset"/> - <menu_item_call label="Modifier un préréglage..." name="edit_day_preset"/> - <menu_item_call label="Supprimer un préréglage..." name="delete_day_preset"/> - </menu> + <menu_item_check label="Utiliser l'environnement partagé" name="Use Shared Environment"/> + <menu_item_call label="Mes environnements..." name="my_environs"/> + <menu_item_check label="Pause des nuages" name="pause_clouds"/> </menu> </menu> <menu label="Construire" name="BuildTools"> @@ -312,7 +296,6 @@ <menu_item_check label="Zone de texture" name="Texture Area"/> <menu_item_check label="Zone de face" name="Face Area"/> <menu_item_check label="Infos sur le niveau de détail" name="LOD Info"/> - <menu_item_check label="Nombre de triangles" name="Triangle Count"/> <menu_item_check label="File d'attente pour la construction" name="Build Queue"/> <menu_item_check label="Lumières" name="Lights"/> <menu_item_check label="Particules" name="Particles"/> @@ -425,7 +408,6 @@ <menu_item_check label="Afficher le squelette de collision" name="Show Collision Skeleton"/> <menu_item_check label="Voir les os" name="Show Bones"/> <menu_item_check label="Afficher la cible de l'avatar" name="Display Agent Target"/> - <menu_item_check label="Afficher les étendues d'imposteur" name="Show Impostor Extents"/> <menu_item_call label="Dump Attachments" name="Dump Attachments"/> <menu_item_call label="Débogage des textures des avatars" name="Debug Avatar Textures"/> <menu_item_call label="Dump Local Textures" name="Dump Local Textures"/> diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml index 74abecf760..dd6fe2f3db 100644 --- a/indra/newview/skins/default/xui/fr/notifications.xml +++ b/indra/newview/skins/default/xui/fr/notifications.xml @@ -1872,7 +1872,7 @@ Cette action modifiera des milliers de régions et sera difficile à digérer po <usetemplate canceltext="Annuler" name="yesnocancelbuttons" notext="Tous les domaines" yestext="Ce domaine"/> </notification> <notification label="Choisir le domaine" name="EstateBannedAgentRemove"> - Supprimer ce résident de la liste des résidents bannis pour ce domaine uniquement ou pour [ALL_ESTATES] ? + Supprimer ce résident de la liste des résidents interdits pour ce domaine uniquement ou pour [ALL_ESTATES] ? <usetemplate canceltext="Annuler" name="yesnocancelbuttons" notext="Tous les domaines" yestext="Ce domaine"/> </notification> <notification label="Choisir le domaine" name="EstateManagerAdd"> @@ -1919,6 +1919,10 @@ Cette action modifiera des milliers de régions et sera difficile à digérer po Le fait de décocher cette option est susceptible de lever les restrictions que les propriétaires des parcelles ont ajouté pour éviter tout différend, maintenir la confidentialité ou protéger les jeunes résidents contre tout contenu réservé aux adultes. Veuillez discuter avec les propriétaires du terrain si nécessaire. <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + Le fait de décocher cette option est susceptible de lever les restrictions que les propriétaires des parcelles ont ajouté à leurs parcelles. Veuillez discuter avec les propriétaires du terrain si nécessaire. + <usetemplate name="okbutton" yestext="OK"/> + </notification> <notification name="RegionEntryAccessBlocked"> La région que vous essayez de visiter comporte du contenu dont le niveau dépasse celui de vos préférences actuelles. Vous pouvez modifier vos préférences en accédant à Moi > Préférences > Général. <usetemplate name="okbutton" yestext="OK"/> @@ -4349,4 +4353,40 @@ Veuillez sélectionner un terrain plus petit. [REASON] <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="FailedToFindSettings"> + Impossible de charger les paramètres de [NAME] à partir de la base de données. + </notification> + <notification name="FailedToLoadSettingsApply"> + Impossible d'appliquer ces paramètres à l'environnement. + </notification> + <notification name="FailedToBuildSettingsDay"> + Impossible d'appliquer ces paramètres à l'environnement. + </notification> + <notification name="NoEnvironmentSettings"> + Cette région ne prend pas en charge les paramètres environnementaux. + </notification> + <notification name="WLImportFail"> + Impossible d'importer les paramètres Windlight hérités depuis [FICHIER]. + </notification> + <notification name="WLParcelApplyFail"> + Impossible de définir l'environnement pour cette parcelle. +Veuillez entrer ou sélectionner une parcelle que vous avez le droit de modifier. + </notification> + <notification name="SettingsUnsuported"> + Les paramètres ne sont pas pris en charge dans cette région. +Veuillez vous déplacer dans une région où les paramètres sont activés et relancer votre action. + </notification> + <notification name="SettingsConfirmLoss"> + Vous êtes sur le point de perdre les modifications que vous avez apportées à ce [TYPE] nommé "[NOM]". +Voulez-vous vraiment continuer ? + <usetemplate ignoretext="Voulez-vous vraiment perdre les modifications ?" name="okcancelignore" notext="Non" yestext="Oui"/> + </notification> + <notification name="SettingsMakeNoTrans"> + Vous êtes sur le point d'importer des paramètres non transférables dans ce cycle de jour. Si vous continuez, les paramètres que vous modifiez deviennent également non transférables. + +Cette modification ne peut être être annulée. + +Voulez-vous vraiment continuer ? + <usetemplate ignoretext="Voulez-vous vraiment que ces paramètres soient non transférables ?" name="okcancelignore" notext="Non" yestext="Oui"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/fr/panel_region_environment.xml b/indra/newview/skins/default/xui/fr/panel_region_environment.xml index a5be812ee5..64cee04e88 100644 --- a/indra/newview/skins/default/xui/fr/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/fr/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="Environnement" name="panel_env_info"> - <text name="water_settings_title"> - Sélectionnez les réglages d'eau et de ciel/cycle du jour que vous souhaitez afficher pour tous les résidents visitant votre région. En savoir plus - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Utiliser les réglages par défaut de Second Life" name="use_sl_default_settings"/> - <radio_item label="Utiliser les réglages suivants" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - Réglage de l'eau - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-Sélectionner un préréglage-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - Ciel / Cycle du jour - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="Ciel fixe" name="my_sky_settings"/> - <radio_item label="Cycle du jour" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-Sélectionner un préréglage-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-Sélectionner un préréglage-" name="item0"/> - </combo_box> - </panel> - <button label="Appliquer" name="apply_btn"/> - <button label="Annuler" name="cancel_btn"/> + <string name="str_label_use_default"> + Utiliser les réglages par défaut + </string> + <string name="str_label_use_region"> + Utiliser les réglages de la région + </string> + <string name="str_unknow_inventory"> + Inconnu(e) + </string> + <string name="str_altitude_desription"> + Ciel [INDEX]([ALTITUDE]m) + </string> + <string name="str_no_parcel"> + Aucune parcelle n'est sélectionnée. Les paramètres environnementaux sont désactivés.. + </string> + <string name="str_cross_region"> + Les paramètres environnementaux ne sont pas disponibles dans les limites des régions. + </string> + <string name="str_legacy"> + Les paramètres environnementaux ne sont pas disponibles dans cette région. + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="Paramètres de l'inventaire" name="rdo_use_inv_setting"/> + <radio_item label="Personnaliser l'environnement" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + Inconnu(e) + </line_editor> + <button label="Modifier l'environnement" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + Sol + </text> + <text name="alt1"> + Ciel [INDEX]([ALTITUDE]m) + </text> + <text name="alt2"> + Ciel [INDEX]([ALTITUDE]m) + </text> + <text name="alt3"> + Ciel [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="Les propriétaires de parcelle peuvent neutraliser l'environnement" name="chk_allow_override"/> + <button label="Appliquer" name="btn_apply"/> + <button label="Réinitialiser" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/fr/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/fr/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..1d6491c7e7 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Atmosphère et éclairage" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/fr/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/fr/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..180f09653e --- /dev/null +++ b/indra/newview/skins/default/xui/fr/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Nuages" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/fr/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/fr/panel_settings_sky_density.xml new file mode 100644 index 0000000000..107858dc20 --- /dev/null +++ b/indra/newview/skins/default/xui/fr/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Densité" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Terme exponentiel de Rayleigh :" name="rayleigh_exponential"/> + <slider label="Échelle exponentielle de Rayleigh :" name="rayleigh_exponential_scale"/> + <slider label="Terme linéaire de Rayleigh :" name="rayleigh_linear"/> + <slider label="Terme constant de Rayleigh :" name="rayleigh_constant"/> + <slider label="Altitude maximum de Rayleigh :" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Terme exponentiel de mie :" name="mie_exponential"/> + <slider label="Échelle exponentielle de mie :" name="mie_exponential_scale"/> + <slider label="Terme linéaire de mie :" name="mie_linear"/> + <slider label="Terme constant de mie :" name="mie_constant"/> + <slider label="Facteur aniso de mie :" name="mie_aniso_factor"/> + <slider label="Altitude maximum de mie :" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Terme exponentiel d'absorption :" name="absorption_exponential"/> + <slider label="Échelle exponentielle d'absorption :" name="absorption_exponential_scale"/> + <slider label="Terme linéaire d'absorption :" name="absorption_linear"/> + <slider label="Terme constant d'absorption :" name="absorption_constant"/> + <slider label="Altitude maximale d'absorption :" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/fr/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/fr/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..5da3dff01c --- /dev/null +++ b/indra/newview/skins/default/xui/fr/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Soleil et lune" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/fr/panel_settings_water.xml b/indra/newview/skins/default/xui/fr/panel_settings_water.xml new file mode 100644 index 0000000000..4e85d71c1f --- /dev/null +++ b/indra/newview/skins/default/xui/fr/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Eau" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + Capteur Fresnel Offset : + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X :" name="water_normal_scale_x"/> + <slider label="Y :" name="water_normal_scale_y"/> + <slider label="Z :" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml index 7f5851b51d..5cd3c563bf 100644 --- a/indra/newview/skins/default/xui/fr/strings.xml +++ b/indra/newview/skins/default/xui/fr/strings.xml @@ -636,6 +636,14 @@ Veuillez réessayer de vous connecter dans une minute. <string name="BUTTON_HELP"> Afficher l'aide </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + Les éléments de ce type ne peuvent pas être attachés aux notes de cette région. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + Seuls des éléments avec des droits +illimités pour le prochain propriétaire +peuvent être joints aux notes. + </string> <string name="Searching"> Recherche... </string> @@ -787,6 +795,9 @@ http://secondlife.com/support pour vous aider à résoudre ce problème. <string name="symbolic link"> lien </string> + <string name="settings blob"> + paramètres + </string> <string name="symbolic folder link"> lien du dossier </string> @@ -2490,6 +2501,9 @@ Si vous continuez de recevoir ce message, contactez l’assistance Second Life <string name="RegionSettings"> Réglages de la région </string> + <string name="NoEnvironmentSettings"> + Cette région ne prend pas en charge les paramètres environnementaux. + </string> <string name="ClassifiedClicksTxt"> Clics : [TELEPORT] téléportation, [MAP] carte, [PROFILE] profil </string> @@ -4832,6 +4846,15 @@ du rapport d'infraction <string name="Female - Wow"> Femme - Ouah ! </string> + <string name="New Daycycle"> + Nouveau cycle du jour + </string> + <string name="New Water"> + Nouvelle eau + </string> + <string name="New Sky"> + Nouveau ciel + </string> <string name="/bow"> /s'incliner </string> diff --git a/indra/newview/skins/default/xui/it/floater_about_land.xml b/indra/newview/skins/default/xui/it/floater_about_land.xml index 67c46b6b62..8237400786 100644 --- a/indra/newview/skins/default/xui/it/floater_about_land.xml +++ b/indra/newview/skins/default/xui/it/floater_about_land.xml @@ -472,5 +472,6 @@ Media: </panel> </panel> <panel label="ESPERIENZE" name="land_experiences_panel"/> + <panel label="AMBIENTE" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/it/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/it/floater_delete_env_preset.xml deleted file mode 100644 index 31cf01fc7b..0000000000 --- a/indra/newview/skins/default/xui/it/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="CANCELLA VALORE PREDEFINITO AMB"> - <string name="title_water"> - Cancella valore predefinito acqua - </string> - <string name="title_sky"> - Cancella valore predefinito cielo - </string> - <string name="title_day_cycle"> - Cancella ciclo giornata - </string> - <string name="label_water"> - Valore predefinito: - </string> - <string name="label_sky"> - Valore predefinito: - </string> - <string name="label_day_cycle"> - Ciclo giornata: - </string> - <string name="msg_confirm_deletion"> - Sei sicuro di volere eliminare il valore predefinito selezionato? - </string> - <string name="msg_sky_is_referenced"> - Impossibile rimuovere un valore predefinito che viene utilizzato in uno o più cicli di giornata. - </string> - <string name="combo_label"> - -Seleziona un valore predefinito- - </string> - <text name="label"> - Valore predefinito: - </text> - <button label="Elimina" name="delete"/> - <button label="Annulla" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/it/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/it/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..b878d735cc --- /dev/null +++ b/indra/newview/skins/default/xui/it/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="Modifica ciclo giornata"> + <string name="title_new"> + Crea un nuovo ciclo giornata + </string> + <string name="title_edit"> + Modifica ciclo giornata + </string> + <string name="hint_new"> + Dai un nome al ciclo della giornata, regola i controlli per crearlo e fai clic su "Salva". + </string> + <string name="hint_edit"> + Per modificare il ciclo della giornata, regola i controlli seguenti e fai clic su "Salva". + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + Cielo [ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + Nome ciclo giornata: + </text> + <button label="Importa" name="btn_import" tool_tip="Importa impostazioni legacy dal disco."/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="Cielo 4:" name="sky4_track"/> + <button label="Cielo 3:" name="sky3_track"/> + <button label="Cielo 2:" name="sky2_track"/> + <button label="Suolo" name="sky1_track"/> + <button label="Acqua" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="Passo indietro"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="Passo avanti"/> + </layout_panel> + </layout_stack> + <button label="Aggiungi fotogramma" name="add_frame"/> + <button label="Carica fotogramma" name="btn_load_frame"/> + <button label="Elimina fotogramma" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + Seleziona un fotogramma chiave dalla cronologia degli eventi qui sopra per modificare le impostazioni. + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="Acqua" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="Atmosfera e illuminazione" name="atmosphere_panel"/> + <panel label="Nuvole" name="clouds_panel"/> + <panel label="Sole e luna" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="Salva" name="save_btn"/> + <button label="Annulla" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/it/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/it/floater_fixedenvironment.xml new file mode 100644 index 0000000000..4ca13a5891 --- /dev/null +++ b/indra/newview/skins/default/xui/it/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="Ambiente stabilito"> + <string name="edit_sky"> + Modifica cielo: + </string> + <string name="edit_water"> + Modifica acqua: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="Carica" name="btn_load" tool_tip="Carica impostazioni dall’inventario"/> + <button label="Importa" name="btn_import" tool_tip="Importa impostazioni legacy dal disco."/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="Salva" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="Annulla" name="btn_cancel" tool_tip="Ripristina l'ultima versione salvata"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/it/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/it/floater_inventory_view_finder.xml index fe41b8ca65..c12c031198 100644 --- a/indra/newview/skins/default/xui/it/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/it/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="Suoni" name="check_sound"/> <check_box label="Texture" name="check_texture"/> <check_box label="Fotografie" name="check_snapshot"/> + <check_box label="Impostazioni" name="check_settings"/> <button label="Tutto" label_selected="Tutto" name="All"/> <button label="Nulla" label_selected="Nulla" name="None"/> <check_box label="Mostra sempre le cartelle" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/it/floater_my_environments.xml b/indra/newview/skins/default/xui/it/floater_my_environments.xml new file mode 100644 index 0000000000..b6668a26a6 --- /dev/null +++ b/indra/newview/skins/default/xui/it/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="Luoghi" name="my_environments" title="I MIEI AMBIENTI"> + <layout_stack> + <layout_panel label="Filtri" name="filter_panel"> + <check_box label="Giorni" name="chk_days"/> + <check_box label="Cieli" name="chk_skies"/> + <check_box label="Acqua" name="chk_water"/> + </layout_panel> + <layout_panel label="Ambienti" name="list_panel"> + <check_box initial_value="false" label="Mostra cartelle vuote" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="Altre opzioni"/> + <menu_button name="btn_newsettings" tool_tip="Crea nuova impostazione"/> + <button name="btn_del" tool_tip="Elimina questa impostazione"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/it/floater_settings_picker.xml b/indra/newview/skins/default/xui/it/floater_settings_picker.xml new file mode 100644 index 0000000000..f94c19e23d --- /dev/null +++ b/indra/newview/skins/default/xui/it/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="SCEGLI: IMPOSTAZIONI"> + <floater.string name="choose_picture"> + Fai clic per scegliere una fotografia + </floater.string> + <floater.string name="pick title"> + Scegli: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="Filtro texture" name="flt_inventory_search"/> + <check_box initial_value="false" label="Mostra cartelle" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="OK" label_selected="OK" name="btn_select"/> + <button label="Annulla" label_selected="Annulla" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/it/menu_inventory.xml b/indra/newview/skins/default/xui/it/menu_inventory.xml index de6855ca97..8b316f8d09 100644 --- a/indra/newview/skins/default/xui/it/menu_inventory.xml +++ b/indra/newview/skins/default/xui/it/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="Attiva" name="Marketplace Activate"/> <menu_item_call label="Disattiva" name="Marketplace Deactivate"/> <menu_item_call label="Condividi" name="Share"/> - <menu_item_call label="Compra" name="Task Buy"/> <menu_item_call label="Apri" name="Task Open"/> <menu_item_call label="Esegui" name="Task Play"/> <menu_item_call label="Proprietà" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="Nuovi capelli" name="New Hair"/> <menu_item_call label="Nuovi occhi" name="New Eyes"/> </menu> + <menu label="Nuove impostazioni" name="New Settings"> + <menu_item_call label="Nuovo cielo" name="New Sky"/> + <menu_item_call label="Nuova acqua" name="New Water"/> + <menu_item_call label="Nuovo ciclo giornata" name="New Day Cycle"/> + </menu> <menu label="Usa come impostazione predefinita per" name="upload_def"> <menu_item_call label="Caricamenti immagini" name="Image uploads"/> <menu_item_call label="Caricamenti suoni" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="Modifica" name="Wearable Edit"/> <menu_item_call label="Aggiungi" name="Wearable Add"/> <menu_item_call label="Togli" name="Take Off"/> + <menu_item_call label="Applica solo a me stesso" name="Settings Apply Local"/> + <menu_item_call label="Applica al lotto" name="Settings Apply Parcel"/> + <menu_item_call label="Applica alla regione" name="Settings Apply Region"/> <menu_item_call label="Copia negli annunci Marketplace" name="Marketplace Copy"/> <menu_item_call label="Sposta negli annunci Marketplace" name="Marketplace Move"/> <menu_item_call label="--nessuna opzione--" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/it/menu_inventory_add.xml b/indra/newview/skins/default/xui/it/menu_inventory_add.xml index 62da61cd6b..1178401b22 100644 --- a/indra/newview/skins/default/xui/it/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/it/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="Suono ([COST]L$)..." name="Upload Sound"/> <menu_item_call label="Animazione ([COST]L$)..." name="Upload Animation"/> <menu_item_call label="Modella..." name="Upload Model"/> - <menu_item_call label="Procedura guidata modellazione..." name="Upload Model Wizard"/> <menu_item_call label="In blocco ([COST]L$ per file)..." name="Bulk Upload"/> - <menu_item_call label="Definisci diritti di caricamento predefiniti" name="perm prefs"/> </menu> <menu_item_call label="Nuova cartella" name="New Folder"/> <menu_item_call label="Nuovo script" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="Nuovi capelli" name="New Hair"/> <menu_item_call label="Nuovi occhi" name="New Eyes"/> </menu> + <menu label="Nuove impostazioni" name="New Settings"> + <menu_item_call label="Nuovo cielo" name="New Sky"/> + <menu_item_call label="Nuova acqua" name="New Water"/> + <menu_item_call label="Nuovo ciclo giornata" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/it/menu_save_settings.xml b/indra/newview/skins/default/xui/it/menu_save_settings.xml new file mode 100644 index 0000000000..80c0ef90a6 --- /dev/null +++ b/indra/newview/skins/default/xui/it/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="Salva" name="save_settings"/> + <menu_item_check label="Salva con nome" name="save_as_new_settings"/> + <menu_item_check label="Esegui" name="commit_changes"/> + <menu_item_check label="Applica solo a me stesso" name="apply_local"/> + <menu_item_check label="Applica al lotto" name="apply_parcel"/> + <menu_item_check label="Applica alla regione" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/it/menu_settings_add.xml b/indra/newview/skins/default/xui/it/menu_settings_add.xml new file mode 100644 index 0000000000..69fcacc374 --- /dev/null +++ b/indra/newview/skins/default/xui/it/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="Nuovo cielo" name="New Sky"/> + <menu_item_call label="Nuova acqua" name="New Water"/> + <menu_item_call label="Nuovo ciclo giornata" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/it/menu_settings_gear.xml b/indra/newview/skins/default/xui/it/menu_settings_gear.xml new file mode 100644 index 0000000000..6a879814fc --- /dev/null +++ b/indra/newview/skins/default/xui/it/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="Modifica" name="edit_settings"/> + <menu_item_call label="Applica solo a me stesso" name="Settings Apply Local"/> + <menu_item_call label="Applica al lotto" name="Settings Apply Parcel"/> + <menu_item_call label="Applica alla regione" name="Settings Apply Region"/> + <menu_item_call label="Copia" name="copy_settings"/> + <menu_item_call label="Incolla" name="paste_settings"/> + <menu_item_call label="Copia UUID" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/it/menu_viewer.xml b/indra/newview/skins/default/xui/it/menu_viewer.xml index 825d127287..c3f48c0963 100644 --- a/indra/newview/skins/default/xui/it/menu_viewer.xml +++ b/indra/newview/skins/default/xui/it/menu_viewer.xml @@ -77,30 +77,14 @@ <menu_item_check label="Proprietà del lotto" name="Parcel Properties"/> <menu_item_check label="Menu Avanzato" name="Show Advanced Menu"/> </menu> - <menu label="Dom" name="Sun"> + <menu label="Ambiente" name="Environment"> <menu_item_check label="Alba" name="Sunrise"/> <menu_item_check label="Mezzogiorno" name="Noon"/> <menu_item_check label="Tramonto" name="Sunset"/> <menu_item_check label="Mezzanotte" name="Midnight"/> - <menu_item_check label="Usa impostazioni regione" name="Use Region Settings"/> - </menu> - <menu label="Editor ambiente" name="Environment Editor"> - <menu_item_call label="Impostazioni ambiente..." name="Environment Settings"/> - <menu label="Valori predefiniti acqua" name="Water Presets"> - <menu_item_call label="Nuovo valore predefinito..." name="new_water_preset"/> - <menu_item_call label="Modifica valore predefinito..." name="edit_water_preset"/> - <menu_item_call label="Elimina valore predefinito..." name="delete_water_preset"/> - </menu> - <menu label="Valori predefiniti cielo" name="Sky Presets"> - <menu_item_call label="Nuovo valore predefinito..." name="new_sky_preset"/> - <menu_item_call label="Modifica valore predefinito..." name="edit_sky_preset"/> - <menu_item_call label="Elimina valore predefinito..." name="delete_sky_preset"/> - </menu> - <menu label="Valori predefiniti giorno" name="Day Presets"> - <menu_item_call label="Nuovo valore predefinito..." name="new_day_preset"/> - <menu_item_call label="Modifica valore predefinito..." name="edit_day_preset"/> - <menu_item_call label="Elimina valore predefinito..." name="delete_day_preset"/> - </menu> + <menu_item_check label="Utilizza ambienti condivisi" name="Use Shared Environment"/> + <menu_item_call label="I miei ambienti..." name="my_environs"/> + <menu_item_check label="Ferma nuvole" name="pause_clouds"/> </menu> </menu> <menu label="Costruisci" name="BuildTools"> @@ -297,7 +281,6 @@ <menu_item_check label="Forme fisica" name="Physics Shapes"/> <menu_item_check label="Aggiorna tipo" name="Update Type"/> <menu_item_check label="Info livello dettaglio" name="LOD Info"/> - <menu_item_check label="Conteggio triangolo" name="Triangle Count"/> <menu_item_check label="Crea coda" name="Build Queue"/> <menu_item_check label="Particelle" name="Particles"/> <menu_item_check label="Giunti" name="Joints"/> @@ -372,7 +355,6 @@ <menu_item_check label="Mostra schemi collisione" name="Show Collision Skeleton"/> <menu_item_check label="Mostra ossa" name="Show Bones"/> <menu_item_check label="Mostra bersaglio" name="Display Agent Target"/> - <menu_item_check label="Mostra Impostor Extents" name="Show Impostor Extents"/> <menu_item_call label="Debug texture dell'avatar" name="Debug Avatar Textures"/> </menu> <menu_item_check label="Texture HTTP" name="HTTP Textures"/> diff --git a/indra/newview/skins/default/xui/it/notifications.xml b/indra/newview/skins/default/xui/it/notifications.xml index d1a47535d8..c0f7df5227 100644 --- a/indra/newview/skins/default/xui/it/notifications.xml +++ b/indra/newview/skins/default/xui/it/notifications.xml @@ -1876,7 +1876,7 @@ Cambierà migliaia di regioni e produrrà seri problemi ai vari server. <usetemplate canceltext="Annulla" name="yesnocancelbuttons" notext="Tutte le proprietà" yestext="Questa proprietà"/> </notification> <notification label="Seleziona la proprietà" name="EstateBannedAgentRemove"> - Rimuovi questo residente dalla lista dei residenti bloccati nell'accesso solo a questa proprietà oppure per [ALL_ESTATES]? + Vuoi rimuovere questo Residente dall’elenco degli espulsi solo per questa proprietà immobiliare oppure per [ALL_ESTATES]? <usetemplate canceltext="Annulla" name="yesnocancelbuttons" notext="Tutte le proprietà" yestext="Questa proprietà"/> </notification> <notification label="Seleziona la proprietà" name="EstateManagerAdd"> @@ -1923,6 +1923,10 @@ Cambierà migliaia di regioni e produrrà seri problemi ai vari server. Togliendo la spunta a questa opzione potrebbero essere rimosse le restrizioni che i proprietari di lotti hanno aggiunto per tenere lontani disturbatori, mantenere la privacy, o evitare che minorenni abbiano accesso a materiale per adulti. Parla con i proprietari del tuo lotto se ce n’è bisogno. <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + Togliendo la spunta a questa opzione potrebbero essere rimosse le impostazioni personalizzate che i proprietari hanno aggiunto ai loro lotti. Parlane con i proprietari del tuo lotto se ce n’è bisogno. + <usetemplate name="okbutton" yestext="OK"/> + </notification> <notification name="RegionEntryAccessBlocked"> La regione che cerchi di visitare include contenuti che non corripondono al livello selezionato nelle preferenze. Per cambiare le preferenze seleziona Io > Preferenze > Generale. <usetemplate name="okbutton" yestext="OK"/> @@ -4348,4 +4352,40 @@ Prova a selezionare un pezzo di terreno più piccolo. [REASON] <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="FailedToFindSettings"> + Non abbiamo potuto caricare le impostazioni per [NAME] dal database. + </notification> + <notification name="FailedToLoadSettingsApply"> + Impossibile applicare le impostazioni all’ambiente. + </notification> + <notification name="FailedToBuildSettingsDay"> + Impossibile applicare le impostazioni all’ambiente. + </notification> + <notification name="NoEnvironmentSettings"> + Questa regione non supporta le impostazioni per l’ambiente. + </notification> + <notification name="WLImportFail"> + Impossibile importare le impostazioni legacy vento e luce da [FILE]. + </notification> + <notification name="WLParcelApplyFail"> + Impossibile impostare l’ambiente per questo lotto. +Inserisci o seleziona un lotto che hai il diritto di modificare. + </notification> + <notification name="SettingsUnsuported"> + Questa regione non supporta le impostazioni ambientali. +Spostati in una regione che abbia le impostazioni abilitate e riprova. + </notification> + <notification name="SettingsConfirmLoss"> + Stai per perdere le modifiche che hai fatto a questo [TYPE] chiamato “[NAME]”. +Vuoi continuare? + <usetemplate ignoretext="Sei sicuro di voler perdere le modifiche apportate?" name="okcancelignore" notext="No" yestext="Sì"/> + </notification> + <notification name="SettingsMakeNoTrans"> + Stai per importare impostazioni non trasferibili in questo ciclo giornata Continuando, anche le impostazione che stai modificando diventeranno non trasferibili. + +Questo cambiamento non può essere annullato. + +Vuoi continuare? + <usetemplate ignoretext="Sei sicuro di voler rendere le impostazioni non trasferibili?" name="okcancelignore" notext="No" yestext="Sì"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/it/panel_region_environment.xml b/indra/newview/skins/default/xui/it/panel_region_environment.xml index d7d9658e26..9a18836c55 100644 --- a/indra/newview/skins/default/xui/it/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/it/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="Ambiente" name="panel_env_info"> - <text name="water_settings_title"> - Seleziona le impostazioni del ciclo dell'acqua e del cielo/giornata che vuoi che vedano tutti coloro che visitano la tua regione. Maggiori informazioni - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Usa valori predefiniti di Second Life" name="use_sl_default_settings"/> - <radio_item label="Usa le impostazioni seguenti" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - Impostazione Acqua - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-Seleziona un valore predefinito-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - Ciclo cielo / giornata - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="Cielo fisso" name="my_sky_settings"/> - <radio_item label="Ciclo giornata" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-Seleziona un valore predefinito-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-Seleziona un valore predefinito-" name="item0"/> - </combo_box> - </panel> - <button label="Applica" name="apply_btn"/> - <button label="Annulla" name="cancel_btn"/> + <string name="str_label_use_default"> + Usa impostazioni predefinite + </string> + <string name="str_label_use_region"> + Usa impostazioni regione + </string> + <string name="str_unknow_inventory"> + Sconosciuto + </string> + <string name="str_altitude_desription"> + Cielo [INDEX]([ALTITUDE]m) + </string> + <string name="str_no_parcel"> + Non è stato selezionato alcun lotto. Le impostazioni ambientali sono disabilitate. + </string> + <string name="str_cross_region"> + Le impostazioni ambientali non sono disponibili oltre i confini della regione. + </string> + <string name="str_legacy"> + Le impostazioni ambientali non sono disponibili per questa regione. + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="Impostazioni da inventario" name="rdo_use_inv_setting"/> + <radio_item label="Ambiente personalizzato" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + Sconosciuto + </line_editor> + <button label="Modifica ambiente" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + Suolo + </text> + <text name="alt1"> + Cielo [INDEX]([ALTITUDE]m) + </text> + <text name="alt2"> + Cielo [INDEX]([ALTITUDE]m) + </text> + <text name="alt3"> + Cielo [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="I proprietari del lotto possono ignorare l’ambiente" name="chk_allow_override"/> + <button label="Applica" name="btn_apply"/> + <button label="Reimposta" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/it/panel_region_estate.xml b/indra/newview/skins/default/xui/it/panel_region_estate.xml index 3983d25111..525458d163 100644 --- a/indra/newview/skins/default/xui/it/panel_region_estate.xml +++ b/indra/newview/skins/default/xui/it/panel_region_estate.xml @@ -26,10 +26,10 @@ <check_box label="Permetti teleport diretto" name="allow_direct_teleport"/> <button label="Applica" name="apply_btn"/> <text name="estate_manager_label"> - Manager delle proprietà: + Gestori delle proprietà immobiliari: </text> <text name="allow_resident_label"> - Sempre consentito: + Sempre consentiti: </text> <button label="Aggiungi..." name="add_estate_manager_btn"/> <button label="Rimuovi..." name="remove_estate_manager_btn"/> @@ -39,7 +39,7 @@ Gruppi sempre consentiti: </text> <text name="ban_resident_label"> - Sempre escluso: + Sempre espulsi: </text> <button label="Aggiungi..." name="add_allowed_group_btn"/> <button label="Rimuovi..." name="remove_allowed_group_btn"/> diff --git a/indra/newview/skins/default/xui/it/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/it/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..b2d27b93fc --- /dev/null +++ b/indra/newview/skins/default/xui/it/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Atmosfera e illuminazione" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/it/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/it/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..e4dd5e00c0 --- /dev/null +++ b/indra/newview/skins/default/xui/it/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Nuvole" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/it/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/it/panel_settings_sky_density.xml new file mode 100644 index 0000000000..3142d1442a --- /dev/null +++ b/indra/newview/skins/default/xui/it/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Densità" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Termine esponenziale Rayleigh:" name="rayleigh_exponential"/> + <slider label="Scala esponenziale Rayleigh:" name="rayleigh_exponential_scale"/> + <slider label="Termine lineare Rayleigh:" name="rayleigh_linear"/> + <slider label="Termine costante Rayleigh:" name="rayleigh_constant"/> + <slider label="Altitudine massima Rayleigh:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Termine esponenziale Mie:" name="mie_exponential"/> + <slider label="Scala esponenziale Mie:" name="mie_exponential_scale"/> + <slider label="Termine lineare Mie:" name="mie_linear"/> + <slider label="Termine costante Mie:" name="mie_constant"/> + <slider label="Fattore diverso Mie:" name="mie_aniso_factor"/> + <slider label="Altitudine massima Mie:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Termine esponenziale di assorbimento:" name="absorption_exponential"/> + <slider label="Scala esponenziale di assorbimento:" name="absorption_exponential_scale"/> + <slider label="Termine lineare di assorbimento:" name="absorption_linear"/> + <slider label="Termine costante di assorbimento:" name="absorption_constant"/> + <slider label="Altitudine massima di assorbimento:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/it/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/it/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..505d5dea08 --- /dev/null +++ b/indra/newview/skins/default/xui/it/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Sole e luna" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/it/panel_settings_water.xml b/indra/newview/skins/default/xui/it/panel_settings_water.xml new file mode 100644 index 0000000000..a353732a12 --- /dev/null +++ b/indra/newview/skins/default/xui/it/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Acqua" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + Spostamento Fresnel + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X:" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/it/strings.xml b/indra/newview/skins/default/xui/it/strings.xml index 918e655ab6..455ccf87eb 100644 --- a/indra/newview/skins/default/xui/it/strings.xml +++ b/indra/newview/skins/default/xui/it/strings.xml @@ -632,6 +632,15 @@ Prova ad accedere nuovamente tra un minuto. <string name="BUTTON_HELP"> Mostra Aiuto </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + Oggetti di questo tipo non possono essere allegati +ai biglietti in questa regione. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + Solamente gli oggetti con autorizzazioni illimitate +al “proprietario successivo” possono +essere allegati ai biglietti. + </string> <string name="Searching"> Ricerca in corso... </string> @@ -780,6 +789,9 @@ http://secondlife.com/support per risolvere il problema. <string name="symbolic link"> link </string> + <string name="settings blob"> + impostazioni + </string> <string name="symbolic folder link"> link alla cartella </string> @@ -2468,6 +2480,9 @@ Se continui a ricevere questo messaggio, contatta l'assistenza Second Life <string name="RegionSettings"> Impostazioni regione </string> + <string name="NoEnvironmentSettings"> + Questa regione non supporta le impostazioni per l’ambiente. + </string> <string name="ClassifiedClicksTxt"> Clicca: [TELEPORT] teleport, [MAP] mappa, [PROFILE] profilo </string> @@ -4747,6 +4762,15 @@ Segnala abuso <string name="Female - Wow"> Femmina - Accipicchia </string> + <string name="New Daycycle"> + Nuovo ciclo giornata + </string> + <string name="New Water"> + Nuova acqua + </string> + <string name="New Sky"> + Nuovo cielo + </string> <string name="/bow"> /inchino </string> diff --git a/indra/newview/skins/default/xui/ja/floater_about_land.xml b/indra/newview/skins/default/xui/ja/floater_about_land.xml index df94daad8e..12201a3475 100644 --- a/indra/newview/skins/default/xui/ja/floater_about_land.xml +++ b/indra/newview/skins/default/xui/ja/floater_about_land.xml @@ -466,5 +466,6 @@ </panel> </panel> <panel label="体験" name="land_experiences_panel"/> + <panel label="環境" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/ja/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/ja/floater_delete_env_preset.xml deleted file mode 100644 index 6467a69956..0000000000 --- a/indra/newview/skins/default/xui/ja/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="環境の事前設定を削除"> - <string name="title_water"> - 水の事前設定を削除 - </string> - <string name="title_sky"> - 空の事前設定を削除 - </string> - <string name="title_day_cycle"> - デイサイクルを削除 - </string> - <string name="label_water"> - 事前設定: - </string> - <string name="label_sky"> - 事前設定: - </string> - <string name="label_day_cycle"> - デイサイクル: - </string> - <string name="msg_confirm_deletion"> - 選択された事前設定を削除しますか? - </string> - <string name="msg_sky_is_referenced"> - デイサイクルの参照先として使われている事前設定は削除できません。 - </string> - <string name="combo_label"> - - 事前設定を選択 - - </string> - <text name="label"> - 事前設定: - </text> - <button label="削除" name="delete"/> - <button label="キャンセル" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/ja/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/ja/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..33df12db4b --- /dev/null +++ b/indra/newview/skins/default/xui/ja/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="デイサイクルを編集"> + <string name="title_new"> + 新しいデイサイクルを作成 + </string> + <string name="title_edit"> + デイサイクルを編集 + </string> + <string name="hint_new"> + 新しいデイサイクルに名前をつけ、希望の設定に調節して、「保存」をクリックします。 + </string> + <string name="hint_edit"> + 自分で作成したデイサイクルを編集するには、希望の設定に調節して、「保存」をクリックします。 + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + 空 [ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + デイサイクル名: + </text> + <button label="インポート" name="btn_import" tool_tip="ディスクから過去の設定をインポートする。"/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="空 4" name="sky4_track"/> + <button label="空 3" name="sky3_track"/> + <button label="空 2" name="sky2_track"/> + <button label="地表レベル" name="sky1_track"/> + <button label="水" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="後ろに移動"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="前に移動"/> + </layout_panel> + </layout_stack> + <button label="フレームを追加" name="add_frame"/> + <button label="フレームを読み込み" name="btn_load_frame"/> + <button label="フレームを削除" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + 上部のタイムラインからキーフレームを選択し、設定を編集します。 + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="水" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="大気&光" name="atmosphere_panel"/> + <panel label="雲" name="clouds_panel"/> + <panel label="太陽&月" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="保存" name="save_btn"/> + <button label="キャンセル" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ja/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/ja/floater_fixedenvironment.xml new file mode 100644 index 0000000000..bec18d95ce --- /dev/null +++ b/indra/newview/skins/default/xui/ja/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="固定された環境"> + <string name="edit_sky"> + 空を編集: + </string> + <string name="edit_water"> + 水を編集: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="ロード" name="btn_load" tool_tip="インベントリから設定をロードする"/> + <button label="インポート" name="btn_import" tool_tip="ディスクから過去の設定をインポートする。"/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="保存" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="キャンセル" name="btn_cancel" tool_tip="最後に保存された状態に戻す"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ja/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/ja/floater_inventory_view_finder.xml index da63b54eab..425cb7ad81 100644 --- a/indra/newview/skins/default/xui/ja/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/ja/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="サウンド" name="check_sound"/> <check_box label="テクスチャ" name="check_texture"/> <check_box label="スナップショット" name="check_snapshot"/> + <check_box label="設定" name="check_settings"/> <button label="すべて" label_selected="すべて" name="All"/> <button label="なし" label_selected="なし" name="None"/> <check_box label="常にフォルダを表示" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/ja/floater_my_environments.xml b/indra/newview/skins/default/xui/ja/floater_my_environments.xml new file mode 100644 index 0000000000..5ef9c3d82c --- /dev/null +++ b/indra/newview/skins/default/xui/ja/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="場所" name="my_environments" title="私の環境"> + <layout_stack> + <layout_panel label="フィルター" name="filter_panel"> + <check_box label="日間" name="chk_days"/> + <check_box label="空" name="chk_skies"/> + <check_box label="水" name="chk_water"/> + </layout_panel> + <layout_panel label="環境" name="list_panel"> + <check_box initial_value="false" label="空のフォルダを表示" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="その他のオプションを表示"/> + <menu_button name="btn_newsettings" tool_tip="新規設定を作成"/> + <button name="btn_del" tool_tip="この設定を削除"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ja/floater_settings_picker.xml b/indra/newview/skins/default/xui/ja/floater_settings_picker.xml new file mode 100644 index 0000000000..16d5dbe983 --- /dev/null +++ b/indra/newview/skins/default/xui/ja/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="選択:設定"> + <floater.string name="choose_picture"> + クリックして写真を選択する + </floater.string> + <floater.string name="pick title"> + 選択: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="テクスチャをフィルター" name="flt_inventory_search"/> + <check_box initial_value="false" label="フォルダを表示" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="OK" label_selected="OK" name="btn_select"/> + <button label="キャンセル" label_selected="キャンセル" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ja/menu_inventory.xml b/indra/newview/skins/default/xui/ja/menu_inventory.xml index 0b06b77901..faa01bc229 100644 --- a/indra/newview/skins/default/xui/ja/menu_inventory.xml +++ b/indra/newview/skins/default/xui/ja/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="有効にする" name="Marketplace Activate"/> <menu_item_call label="無効にする" name="Marketplace Deactivate"/> <menu_item_call label="共有" name="Share"/> - <menu_item_call label="購入" name="Task Buy"/> <menu_item_call label="開く" name="Task Open"/> <menu_item_call label="再生" name="Task Play"/> <menu_item_call label="プロパティ" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="新しい髪" name="New Hair"/> <menu_item_call label="新しい眼" name="New Eyes"/> </menu> + <menu label="新しい設定" name="New Settings"> + <menu_item_call label="新しい空" name="New Sky"/> + <menu_item_call label="新しい水" name="New Water"/> + <menu_item_call label="新しいデイサイクル" name="New Day Cycle"/> + </menu> <menu label="次のデフォルトとして使用" name="upload_def"> <menu_item_call label="画像のアップロード" name="Image uploads"/> <menu_item_call label="サウンドのアップロード" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="編集" name="Wearable Edit"/> <menu_item_call label="追加" name="Wearable Add"/> <menu_item_call label="取り外す" name="Take Off"/> + <menu_item_call label="自分にのみ適用" name="Settings Apply Local"/> + <menu_item_call label="区画に適用" name="Settings Apply Parcel"/> + <menu_item_call label="リージョンに適用" name="Settings Apply Region"/> <menu_item_call label="マーケットプレイスのリストにコピー" name="Marketplace Copy"/> <menu_item_call label="マーケットプレイスのリストに移動" name="Marketplace Move"/> <menu_item_call label="--オプションなし--" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/ja/menu_inventory_add.xml b/indra/newview/skins/default/xui/ja/menu_inventory_add.xml index ae5ddbb78f..b8c9c8f25e 100644 --- a/indra/newview/skins/default/xui/ja/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/ja/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="サウンド (L$[COST] )..." name="Upload Sound"/> <menu_item_call label="アニメーション (L$ [COST] )..." name="Upload Animation"/> <menu_item_call label="モデル" name="Upload Model"/> - <menu_item_call label="モデルウィザード" name="Upload Model Wizard"/> <menu_item_call label="一括 (ファイルにつき L$[COST] )..." name="Bulk Upload"/> - <menu_item_call label="デフォルトのアップロード権限を設定" name="perm prefs"/> </menu> <menu_item_call label="新規フォルダ" name="New Folder"/> <menu_item_call label="新規スクリプト" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="新しい髪" name="New Hair"/> <menu_item_call label="新しい目" name="New Eyes"/> </menu> + <menu label="新しい設定" name="New Settings"> + <menu_item_call label="新しい空" name="New Sky"/> + <menu_item_call label="新しい水" name="New Water"/> + <menu_item_call label="新しいデイサイクル" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/ja/menu_save_settings.xml b/indra/newview/skins/default/xui/ja/menu_save_settings.xml new file mode 100644 index 0000000000..44fb1fb30b --- /dev/null +++ b/indra/newview/skins/default/xui/ja/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="保存" name="save_settings"/> + <menu_item_check label="別名で保存" name="save_as_new_settings"/> + <menu_item_check label="約束する" name="commit_changes"/> + <menu_item_check label="自分にのみ適用" name="apply_local"/> + <menu_item_check label="区画に適用" name="apply_parcel"/> + <menu_item_check label="リージョンに適用" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/ja/menu_settings_add.xml b/indra/newview/skins/default/xui/ja/menu_settings_add.xml new file mode 100644 index 0000000000..814ad9c1a6 --- /dev/null +++ b/indra/newview/skins/default/xui/ja/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="新しい空" name="New Sky"/> + <menu_item_call label="新しい水" name="New Water"/> + <menu_item_call label="新しいデイサイクル" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/ja/menu_settings_gear.xml b/indra/newview/skins/default/xui/ja/menu_settings_gear.xml new file mode 100644 index 0000000000..afce43fb25 --- /dev/null +++ b/indra/newview/skins/default/xui/ja/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="編集" name="edit_settings"/> + <menu_item_call label="自分にのみ適用" name="Settings Apply Local"/> + <menu_item_call label="区画に適用" name="Settings Apply Parcel"/> + <menu_item_call label="リージョンに適用" name="Settings Apply Region"/> + <menu_item_call label="コピー" name="copy_settings"/> + <menu_item_call label="貼り付け" name="paste_settings"/> + <menu_item_call label="UUIDをコピー" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/ja/menu_viewer.xml b/indra/newview/skins/default/xui/ja/menu_viewer.xml index 93d15517cd..6dcb4e0ef3 100644 --- a/indra/newview/skins/default/xui/ja/menu_viewer.xml +++ b/indra/newview/skins/default/xui/ja/menu_viewer.xml @@ -77,30 +77,14 @@ <menu_item_check label="区画プロパティ" name="Parcel Properties"/> <menu_item_check label="アドバンスメニュー" name="Show Advanced Menu"/> </menu> - <menu label="日" name="Sun"> + <menu label="環境" name="Environment"> <menu_item_check label="日の出" name="Sunrise"/> <menu_item_check label="正午" name="Noon"/> <menu_item_check label="日没" name="Sunset"/> <menu_item_check label="深夜" name="Midnight"/> - <menu_item_check label="リージョンの設定を使用" name="Use Region Settings"/> - </menu> - <menu label="自然環境エディター" name="Environment Editor"> - <menu_item_call label="自然環境の設定..." name="Environment Settings"/> - <menu label="水の事前設定" name="Water Presets"> - <menu_item_call label="新しい事前設定..." name="new_water_preset"/> - <menu_item_call label="事前設定を編集..." name="edit_water_preset"/> - <menu_item_call label="事前設定を削除..." name="delete_water_preset"/> - </menu> - <menu label="空の事前設定" name="Sky Presets"> - <menu_item_call label="新しい事前設定..." name="new_sky_preset"/> - <menu_item_call label="事前設定を編集..." name="edit_sky_preset"/> - <menu_item_call label="事前設定を削除..." name="delete_sky_preset"/> - </menu> - <menu label="デイの事前設定" name="Day Presets"> - <menu_item_call label="新しい事前設定..." name="new_day_preset"/> - <menu_item_call label="事前設定を編集..." name="edit_day_preset"/> - <menu_item_call label="事前設定を削除..." name="delete_day_preset"/> - </menu> + <menu_item_check label="共有された環境を使用" name="Use Shared Environment"/> + <menu_item_call label="私の環境…" name="my_environs"/> + <menu_item_check label="雲を一時停止" name="pause_clouds"/> </menu> </menu> <menu label="制作" name="BuildTools"> @@ -312,7 +296,6 @@ <menu_item_check label="テクスチャの範囲" name="Texture Area"/> <menu_item_check label="側面" name="Face Area"/> <menu_item_check label="LOD 情報" name="LOD Info"/> - <menu_item_check label="三角形の数" name="Triangle Count"/> <menu_item_check label="制作キュー" name="Build Queue"/> <menu_item_check label="光" name="Lights"/> <menu_item_check label="パーティクル" name="Particles"/> @@ -425,7 +408,6 @@ <menu_item_check label="骨組みの衝突判定を表示する" name="Show Collision Skeleton"/> <menu_item_check label="骨を表示" name="Show Bones"/> <menu_item_check label="エージェントのターゲットを表示する" name="Display Agent Target"/> - <menu_item_check label="インポスターの範囲を表示" name="Show Impostor Extents"/> <menu_item_call label="アタッチメントをダンプ" name="Dump Attachments"/> <menu_item_call label="アバターテクスチャをデバッグ" name="Debug Avatar Textures"/> <menu_item_call label="ローカルテクスチャをダンプ" name="Dump Local Textures"/> diff --git a/indra/newview/skins/default/xui/ja/notifications.xml b/indra/newview/skins/default/xui/ja/notifications.xml index 99ba5b2655..7bdae9c2bc 100644 --- a/indra/newview/skins/default/xui/ja/notifications.xml +++ b/indra/newview/skins/default/xui/ja/notifications.xml @@ -1907,7 +1907,7 @@ http://wiki.secondlife.com/wiki/Setting_your_display_name を参照してくだ <usetemplate canceltext="取り消し" name="yesnocancelbuttons" notext="すべての不動産" yestext="この不動産"/> </notification> <notification label="不動産を選択" name="EstateBannedAgentRemove"> - この住人が、この不動産限定、または [ALL_ESTATES] にアクセスできるように、禁止リストから削除しますか? + この住人をこの不動産の立入禁止リストからのみ削除しますか?それとも [ALL_ESTATES] の立入禁止リストから削除しますか? <usetemplate canceltext="取り消し" name="yesnocancelbuttons" notext="すべての不動産" yestext="この不動産"/> </notification> <notification label="不動産を選択" name="EstateManagerAdd"> @@ -1954,6 +1954,10 @@ http://wiki.secondlife.com/wiki/Setting_your_display_name を参照してくだ このオプションをオフにすると、嫌がらせの防止やプライバシーの維持、18 才以下の住人を Adult コンテンツから守るために区画所有者が加えた制限が解除される可能性があります。必要に応じて区画所有者と相談してください。 <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + このオプションをオフにすると、区画所有者がその区画に加えたカスタム環境が削除されることがあります。必要に応じて区画所有者と相談してください。 + <usetemplate name="okbutton" yestext="OK"/> + </notification> <notification name="RegionEntryAccessBlocked"> 訪問しようとしている地域(リージョン)には現在の環境設定を超えるコンテンツが含まれています。「ミー」 > 「環境設定」 > 「一般」を選択して、環境設定を変更できます。 <usetemplate name="okbutton" yestext="OK"/> @@ -4384,4 +4388,40 @@ M キーを押して変更します。 [REASON] <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="FailedToFindSettings"> + データベースから [NAME] の設定の読み込みができませんでした。 + </notification> + <notification name="FailedToLoadSettingsApply"> + 環境にこれらの設定を適用することができません。 + </notification> + <notification name="FailedToBuildSettingsDay"> + 環境にこれらの設定を適用することができません。 + </notification> + <notification name="NoEnvironmentSettings"> + このリージョンは環境設定をサポートしていません。 + </notification> + <notification name="WLImportFail"> + [FILE] から過去のウインドライトの設定をインポートできません。 + </notification> + <notification name="WLParcelApplyFail"> + この区画で環境を設定することはできません。 +変更する権限のある区画を入力または選択してください。 + </notification> + <notification name="SettingsUnsuported"> + このリージョンでは設定をサポートしていません。 +設定に対応しているリージョンに移動し、アクションを再試行してください。 + </notification> + <notification name="SettingsConfirmLoss"> + "[NAME]"。と名付けられたこの [TYPE] に加えられた変更が失われます。 +続けますか? + <usetemplate ignoretext="変更を失いますがよろしいですか?" name="okcancelignore" notext="いいえ" yestext="はい"/> + </notification> + <notification name="SettingsMakeNoTrans"> + このデイサイクルに移行不可の設定をインポートしようとしています。このまま続けると、編集中の設定も移行不可になります。 + +この変更は元に戻すことができません。 + +続けますか? + <usetemplate ignoretext="設定を移行不可にしますか?" name="okcancelignore" notext="いいえ" yestext="はい"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/ja/panel_region_environment.xml b/indra/newview/skins/default/xui/ja/panel_region_environment.xml index a2981012dc..7ef6aab7de 100644 --- a/indra/newview/skins/default/xui/ja/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/ja/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="環境" name="panel_env_info"> - <text name="water_settings_title"> - あなたのリージョンを訪れるユーザーに見せたい、水と空/デイサイクルの設定を選択します。詳細 - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Second Life のデフォルト設定を使用" name="use_sl_default_settings"/> - <radio_item label="次の設定を使用" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - 水の設定 - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="- 事前設定を選択 -" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - 空 / デイサイクル - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="空の固定" name="my_sky_settings"/> - <radio_item label="デイサイクル" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="- 事前設定を選択 -" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="- 事前設定を選択 -" name="item0"/> - </combo_box> - </panel> - <button label="適用" name="apply_btn"/> - <button label="キャンセル" name="cancel_btn"/> + <string name="str_label_use_default"> + 既定の設定を使用 + </string> + <string name="str_label_use_region"> + リージョンの設定を使用 + </string> + <string name="str_unknow_inventory"> + 不明 + </string> + <string name="str_altitude_desription"> + 空 [INDEX]([ALTITUDE]m) + </string> + <string name="str_no_parcel"> + 区画が選択されていません。環境設定が無効になっています。 + </string> + <string name="str_cross_region"> + リージョンの境界では環境設定ができません。 + </string> + <string name="str_legacy"> + このリージョンで環境設定はできません。 + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="インベントリからの設定" name="rdo_use_inv_setting"/> + <radio_item label="環境のカスタマイズ" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + 不明 + </line_editor> + <button label="環境を編集" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + 地面 + </text> + <text name="alt1"> + 空 [INDEX]([ALTITUDE]m) + </text> + <text name="alt2"> + 空 [INDEX]([ALTITUDE]m) + </text> + <text name="alt3"> + 空 [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="区画所有者が環境を上書きすることがあります" name="chk_allow_override"/> + <button label="適用" name="btn_apply"/> + <button label="リセット" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/ja/panel_region_estate.xml b/indra/newview/skins/default/xui/ja/panel_region_estate.xml index 77c7406952..385c16dfab 100644 --- a/indra/newview/skins/default/xui/ja/panel_region_estate.xml +++ b/indra/newview/skins/default/xui/ja/panel_region_estate.xml @@ -26,25 +26,25 @@ <check_box label="直接テレポートを許可" name="allow_direct_teleport"/> <button label="適用" name="apply_btn"/> <text name="estate_manager_label"> - 不動産マネージャー: + 不動産マネージャー: </text> <text name="allow_resident_label"> 常に許可: </text> <button label="追加..." name="add_estate_manager_btn"/> - <button label="削除..." name="remove_estate_manager_btn"/> + <button label="削除…" name="remove_estate_manager_btn"/> <button label="追加..." name="add_allowed_avatar_btn"/> - <button label="削除..." name="remove_allowed_avatar_btn"/> + <button label="削除…" name="remove_allowed_avatar_btn"/> <text name="allow_group_label"> - グループを常に許可: + 常に許可されたグループ: </text> <text name="ban_resident_label"> 常に禁止: </text> <button label="追加..." name="add_allowed_group_btn"/> - <button label="削除..." name="remove_allowed_group_btn"/> + <button label="削除…" name="remove_allowed_group_btn"/> <button label="追加..." name="add_banned_avatar_btn"/> - <button label="削除..." name="remove_banned_avatar_btn"/> + <button label="削除…" name="remove_banned_avatar_btn"/> <button label="メッセージを不動産に送信..." name="message_estate_btn"/> <button label="不動産から住人を追い出す..." name="kick_user_from_estate_btn"/> </panel> diff --git a/indra/newview/skins/default/xui/ja/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/ja/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..56fab14f7c --- /dev/null +++ b/indra/newview/skins/default/xui/ja/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="大気&光" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/ja/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/ja/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..232530c5f8 --- /dev/null +++ b/indra/newview/skins/default/xui/ja/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="雲" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/ja/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/ja/panel_settings_sky_density.xml new file mode 100644 index 0000000000..1dc7d6c594 --- /dev/null +++ b/indra/newview/skins/default/xui/ja/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="密度" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="レイリー指数項:" name="rayleigh_exponential"/> + <slider label="レイリー指数スケール:" name="rayleigh_exponential_scale"/> + <slider label="レイリー線形項:" name="rayleigh_linear"/> + <slider label="レイリー定数項:" name="rayleigh_constant"/> + <slider label="レイリー最大高度:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="レイリー指数項:" name="mie_exponential"/> + <slider label="Mie指数スケール:" name="mie_exponential_scale"/> + <slider label="Mie線形項:" name="mie_linear"/> + <slider label="Mie定数項:" name="mie_constant"/> + <slider label="Mie不等要素:" name="mie_aniso_factor"/> + <slider label="Mie最大高度:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="吸収指数項:" name="absorption_exponential"/> + <slider label="吸収指数スケール:" name="absorption_exponential_scale"/> + <slider label="吸収線形項:" name="absorption_linear"/> + <slider label="吸収定数項:" name="absorption_constant"/> + <slider label="吸収最大高度:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/ja/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/ja/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..31220f1bea --- /dev/null +++ b/indra/newview/skins/default/xui/ja/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="太陽&月" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/ja/panel_settings_water.xml b/indra/newview/skins/default/xui/ja/panel_settings_water.xml new file mode 100644 index 0000000000..6a86ad9a04 --- /dev/null +++ b/indra/newview/skins/default/xui/ja/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="水" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + フレネル・オフセット + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X:" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/ja/strings.xml b/indra/newview/skins/default/xui/ja/strings.xml index bcf4698bb0..80fa306157 100644 --- a/indra/newview/skins/default/xui/ja/strings.xml +++ b/indra/newview/skins/default/xui/ja/strings.xml @@ -635,6 +635,15 @@ support@secondlife.com にお問い合わせください。 <string name="BUTTON_HELP"> ヘルプを表示 </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + このタイプのアイテムは、このリージョンのノートカードに +添付することができません。 + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + 制限のない「次の所有者」の +許可のみノートカードに +添付できます。 + </string> <string name="Searching"> 検索中... </string> @@ -786,6 +795,9 @@ support@secondlife.com にお問い合わせください。 <string name="symbolic link"> リンク </string> + <string name="settings blob"> + 設定 + </string> <string name="symbolic folder link"> フォルダのリンク </string> @@ -2488,6 +2500,9 @@ support@secondlife.com にお問い合わせください。 <string name="RegionSettings"> リージョン(地域)の設定 </string> + <string name="NoEnvironmentSettings"> + このリージョンは環境設定をサポートしていません。 + </string> <string name="ClassifiedClicksTxt"> クリック数: [TELEPORT] テレポート、 [MAP] 地図、 [PROFILE] プロフィール </string> @@ -4830,6 +4845,15 @@ www.secondlife.com から最新バージョンをダウンロードしてくだ <string name="Female - Wow"> 女性 - Wow </string> + <string name="New Daycycle"> + 新しいデイサイクル + </string> + <string name="New Water"> + 新しい水 + </string> + <string name="New Sky"> + 新しい空 + </string> <string name="/bow"> /おじぎする </string> diff --git a/indra/newview/skins/default/xui/pl/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/pl/floater_delete_env_preset.xml deleted file mode 100644 index fc750715c6..0000000000 --- a/indra/newview/skins/default/xui/pl/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<floater name="Delete Env Preset" title="USUŃ UST. OTOCZENIA"> - <string name="title_water"> - Usuń Ustawienie wody - </string> - <string name="title_sky"> - Usuń Ustawienie nieba - </string> - <string name="title_day_cycle"> - Usuń cykl dnia - </string> - <string name="label_water"> - Wybierz: - </string> - <string name="label_sky"> - Wybierz: - </string> - <string name="label_day_cycle"> - Cykl dnia: - </string> - <string name="msg_confirm_deletion"> - Masz absolutną pewność, że chcesz usunąć wybrane Ustawienie? - </string> - <string name="msg_sky_is_referenced"> - Nie można usunąć Ustawienia odwołującego się do jakiegoś cyklu dnia. - </string> - <string name="combo_label"> - -Wybierz Ustawienie- - </string> - <text name="label"> - Wybierz: - </text> - <button label="Usuń" name="delete" /> - <button label="Anuluj" name="cancel" /> -</floater> diff --git a/indra/newview/skins/default/xui/pl/menu_viewer.xml b/indra/newview/skins/default/xui/pl/menu_viewer.xml index e6ad1faee6..5190723660 100644 --- a/indra/newview/skins/default/xui/pl/menu_viewer.xml +++ b/indra/newview/skins/default/xui/pl/menu_viewer.xml @@ -84,17 +84,14 @@ <menu name="Water Presets" label="Ustawienia wody"> <menu_item_call label="Nowe Ustawienie..." name="new_water_preset" /> <menu_item_call label="Edytuj Ustawienie..." name="edit_water_preset" /> - <menu_item_call label="Usuń Ustawienie..." name="delete_water_preset" /> </menu> <menu name="Sky Presets" label="Ustawienia nieba"> <menu_item_call label="Nowe Ustawienie..." name="new_sky_preset" /> <menu_item_call label="Edytuj Ustawienie..." name="edit_sky_preset" /> - <menu_item_call label="Usuń Ustawienie..." name="delete_sky_preset" /> </menu> <menu name="Day Presets" label="Ustawienia pory dnia"> <menu_item_call label="Nowe Ustawienie..." name="new_day_preset" /> <menu_item_call label="Edytuj Ustawienie..." name="edit_day_preset" /> - <menu_item_call label="Usuń Ustawienie..." name="delete_day_preset" /> </menu> </menu> </menu> diff --git a/indra/newview/skins/default/xui/pl/strings.xml b/indra/newview/skins/default/xui/pl/strings.xml index 9aece1221d..91fea234d2 100644 --- a/indra/newview/skins/default/xui/pl/strings.xml +++ b/indra/newview/skins/default/xui/pl/strings.xml @@ -710,6 +710,9 @@ Spróbuj zalogować się ponownie za minutę. <string name="mesh"> mesz </string> + <string name="settings"> + ustawień + </string> <string name="AvatarEditingAppearance"> (Edycja wyglądu) </string> diff --git a/indra/newview/skins/default/xui/pt/floater_about_land.xml b/indra/newview/skins/default/xui/pt/floater_about_land.xml index 6039b7fd4a..8807428bd3 100644 --- a/indra/newview/skins/default/xui/pt/floater_about_land.xml +++ b/indra/newview/skins/default/xui/pt/floater_about_land.xml @@ -467,5 +467,6 @@ Mídia: </panel> </panel> <panel label="EXPERIÊNCIAS" name="land_experiences_panel"/> + <panel label="AMBIENTE" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/pt/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/pt/floater_delete_env_preset.xml deleted file mode 100644 index 2434f67d6c..0000000000 --- a/indra/newview/skins/default/xui/pt/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="EXCLUIR PREDEFINIÇÃO ENV"> - <string name="title_water"> - Excluir predefinição da água - </string> - <string name="title_sky"> - Excluir predefinição de céu - </string> - <string name="title_day_cycle"> - Excluir ciclo de dias - </string> - <string name="label_water"> - Predefinição: - </string> - <string name="label_sky"> - Predefinição: - </string> - <string name="label_day_cycle"> - Ciclos de dias: - </string> - <string name="msg_confirm_deletion"> - Tem certeza de que quer excluir a predefinição selecionada? - </string> - <string name="msg_sky_is_referenced"> - Não é possível remover uma predefinição que está referenciada por algum(ns) ciclo(s) de dias. - </string> - <string name="combo_label"> - -Selecionar uma prefefinição- - </string> - <text name="label"> - Predefinição: - </text> - <button label="Excluir" name="delete"/> - <button label="Cancelar" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/pt/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/pt/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..893fed04ec --- /dev/null +++ b/indra/newview/skins/default/xui/pt/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="Editar ciclo de dias"> + <string name="title_new"> + Criar um ciclo de dias + </string> + <string name="title_edit"> + Editar ciclo de dias + </string> + <string name="hint_new"> + Nomeie o seu ciclo de dias, ajustar os controles para criá-lo e clique em “Salvar”. + </string> + <string name="hint_edit"> + Editar o seu ciclo de dias, ajustar os controles para criá-lo e clique em “Salvar”. + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + Céu [ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + Nome do ciclo de dias: + </text> + <button label="Importar" name="btn_import" tool_tip="Importar configurações do legado do disco."/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="Céu 4" name="sky4_track"/> + <button label="Céu 3" name="sky3_track"/> + <button label="Céu 2" name="sky2_track"/> + <button label="A nível do chão" name="sky1_track"/> + <button label="Água" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="Passo para trás"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="Passo para frente"/> + </layout_panel> + </layout_stack> + <button label="Adicionar uma estrutura" name="add_frame"/> + <button label="Carregar uma estrutura" name="btn_load_frame"/> + <button label="Excluir uma estrutura" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + Selecionar uma estrutura chave da linha do tempo acima para editar as configurações. + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="Água" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="Atmosfera e Claridade" name="atmosphere_panel"/> + <panel label="Nuvens" name="clouds_panel"/> + <panel label="Sol e Lua" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="Salvar" name="save_btn"/> + <button label="Cancelar" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/pt/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/pt/floater_fixedenvironment.xml new file mode 100644 index 0000000000..c969aac74e --- /dev/null +++ b/indra/newview/skins/default/xui/pt/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="Ambiente consertado"> + <string name="edit_sky"> + Editar céu: + </string> + <string name="edit_water"> + Editar água: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="Carregar" name="btn_load" tool_tip="Carregar as configurações de inventário"/> + <button label="Importar" name="btn_import" tool_tip="Importar configurações do legado do disco."/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="Salvar" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="Cancelar" name="btn_cancel" tool_tip="Voltar à última versão salva"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/pt/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/pt/floater_inventory_view_finder.xml index 3f66fd07b9..c50d7dcda0 100644 --- a/indra/newview/skins/default/xui/pt/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/pt/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="Sons" name="check_sound"/> <check_box label="Texturas" name="check_texture"/> <check_box label="Fotos" name="check_snapshot"/> + <check_box label="Configurações" name="check_settings"/> <button label="Tudo" label_selected="Tudo" name="All"/> <button label="Nenhum" label_selected="Nenhum" name="None"/> <check_box label="Sempre mostrar as pastas" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/pt/floater_my_environments.xml b/indra/newview/skins/default/xui/pt/floater_my_environments.xml new file mode 100644 index 0000000000..36a4c1dcc6 --- /dev/null +++ b/indra/newview/skins/default/xui/pt/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="Lugares" name="my_environments" title="MEUS AMBIENTES"> + <layout_stack> + <layout_panel label="Filtros" name="filter_panel"> + <check_box label="Dias" name="chk_days"/> + <check_box label="Céus" name="chk_skies"/> + <check_box label="Água" name="chk_water"/> + </layout_panel> + <layout_panel label="Ambientes" name="list_panel"> + <check_box initial_value="false" label="Mostrar pastas vazias" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="Mais opções"/> + <menu_button name="btn_newsettings" tool_tip="Criar nova configuração"/> + <button name="btn_del" tool_tip="Excluir esta configuração"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/pt/floater_settings_picker.xml b/indra/newview/skins/default/xui/pt/floater_settings_picker.xml new file mode 100644 index 0000000000..787348c6d6 --- /dev/null +++ b/indra/newview/skins/default/xui/pt/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="ESCOLHER: CONFIGURAÇÕES"> + <floater.string name="choose_picture"> + Clique para selecionar uma imagem + </floater.string> + <floater.string name="pick title"> + Escolher: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="Filtrar texturas" name="flt_inventory_search"/> + <check_box initial_value="false" label="Exibir pastas" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="OK" label_selected="OK" name="btn_select"/> + <button label="Cancelar" label_selected="Cancelar" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/pt/menu_inventory.xml b/indra/newview/skins/default/xui/pt/menu_inventory.xml index b99ddc67d2..195ee52f3d 100644 --- a/indra/newview/skins/default/xui/pt/menu_inventory.xml +++ b/indra/newview/skins/default/xui/pt/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="Ativar" name="Marketplace Activate"/> <menu_item_call label="Desativar" name="Marketplace Deactivate"/> <menu_item_call label="Compartilhar" name="Share"/> - <menu_item_call label="Comprar" name="Task Buy"/> <menu_item_call label="Abrir" name="Task Open"/> <menu_item_call label="Executar" name="Task Play"/> <menu_item_call label="Propriedades" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="Novo cabelo" name="New Hair"/> <menu_item_call label="Novos olhos" name="New Eyes"/> </menu> + <menu label="Novas configurações" name="New Settings"> + <menu_item_call label="Novo céu" name="New Sky"/> + <menu_item_call label="Nova água" name="New Water"/> + <menu_item_call label="Novo ciclo de dias" name="New Day Cycle"/> + </menu> <menu label="Usar como padrão para" name="upload_def"> <menu_item_call label="Envios de imagem" name="Image uploads"/> <menu_item_call label="Envios de som" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="Editar" name="Wearable Edit"/> <menu_item_call label="Adicionar" name="Wearable Add"/> <menu_item_call label="Tirar" name="Take Off"/> + <menu_item_call label="Aplicar somente a mim" name="Settings Apply Local"/> + <menu_item_call label="Aplicar ao lote" name="Settings Apply Parcel"/> + <menu_item_call label="Aplicar para a região" name="Settings Apply Region"/> <menu_item_call label="Copiar para Listagens do Marketplace" name="Marketplace Copy"/> <menu_item_call label="Mover para Listagens do Marketplace" name="Marketplace Move"/> <menu_item_call label="--Sem opções--" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/pt/menu_inventory_add.xml b/indra/newview/skins/default/xui/pt/menu_inventory_add.xml index 7a7ebc50af..1303973913 100644 --- a/indra/newview/skins/default/xui/pt/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/pt/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="Som (L$[COST])..." name="Upload Sound"/> <menu_item_call label="Animação (L$[COST])..." name="Upload Animation"/> <menu_item_call label="Modelar..." name="Upload Model"/> - <menu_item_call label="Assistente de modelagem..." name="Upload Model Wizard"/> <menu_item_call label="Volume (L$[COST] per file)..." name="Bulk Upload"/> - <menu_item_call label="Autorizações de upload padrão" name="perm prefs"/> </menu> <menu_item_call label="Nova pasta" name="New Folder"/> <menu_item_call label="Novo script" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="Novo cabelo" name="New Hair"/> <menu_item_call label="Novos olhos" name="New Eyes"/> </menu> + <menu label="Novas configurações" name="New Settings"> + <menu_item_call label="Novo céu" name="New Sky"/> + <menu_item_call label="Nova água" name="New Water"/> + <menu_item_call label="Novo ciclo de dias" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/pt/menu_save_settings.xml b/indra/newview/skins/default/xui/pt/menu_save_settings.xml new file mode 100644 index 0000000000..9af5d01629 --- /dev/null +++ b/indra/newview/skins/default/xui/pt/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="Salvar" name="save_settings"/> + <menu_item_check label="Salvar como" name="save_as_new_settings"/> + <menu_item_check label="Enviar" name="commit_changes"/> + <menu_item_check label="Aplicar somente a mim" name="apply_local"/> + <menu_item_check label="Aplicar ao lote" name="apply_parcel"/> + <menu_item_check label="Aplicar para a região" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/pt/menu_settings_add.xml b/indra/newview/skins/default/xui/pt/menu_settings_add.xml new file mode 100644 index 0000000000..3bd87e6c12 --- /dev/null +++ b/indra/newview/skins/default/xui/pt/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="Novo céu" name="New Sky"/> + <menu_item_call label="Nova água" name="New Water"/> + <menu_item_call label="Novo ciclo de dias" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/pt/menu_settings_gear.xml b/indra/newview/skins/default/xui/pt/menu_settings_gear.xml new file mode 100644 index 0000000000..55817b22e0 --- /dev/null +++ b/indra/newview/skins/default/xui/pt/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="Editar" name="edit_settings"/> + <menu_item_call label="Aplicar somente a mim" name="Settings Apply Local"/> + <menu_item_call label="Aplicar ao lote" name="Settings Apply Parcel"/> + <menu_item_call label="Aplicar para a região" name="Settings Apply Region"/> + <menu_item_call label="Copiar" name="copy_settings"/> + <menu_item_call label="Colar" name="paste_settings"/> + <menu_item_call label="Copiar UUID" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/pt/menu_viewer.xml b/indra/newview/skins/default/xui/pt/menu_viewer.xml index 1d0953e756..fddc9f6abf 100644 --- a/indra/newview/skins/default/xui/pt/menu_viewer.xml +++ b/indra/newview/skins/default/xui/pt/menu_viewer.xml @@ -77,30 +77,14 @@ <menu_item_check label="Propriedades do lote" name="Parcel Properties"/> <menu_item_check label="Menu avançado" name="Show Advanced Menu"/> </menu> - <menu label="Dom" name="Sun"> - <menu_item_check label="Nascer do sol" name="Sunrise"/> + <menu label="Ambiente" name="Environment"> + <menu_item_check label="Nascer-do-sol" name="Sunrise"/> <menu_item_check label="Meio-dia" name="Noon"/> - <menu_item_check label="Pôr do sol" name="Sunset"/> + <menu_item_check label="Pôr-do-sol" name="Sunset"/> <menu_item_check label="Meia-noite" name="Midnight"/> - <menu_item_check label="Usar as configurações da região" name="Use Region Settings"/> - </menu> - <menu label="Editor de ambientes" name="Environment Editor"> - <menu_item_call label="Configurações do ambiente..." name="Environment Settings"/> - <menu label="Predefinições da água" name="Water Presets"> - <menu_item_call label="Nova predefinição..." name="new_water_preset"/> - <menu_item_call label="Editar predefinição..." name="edit_water_preset"/> - <menu_item_call label="Excluir predefinição..." name="delete_water_preset"/> - </menu> - <menu label="Predefinições de céu" name="Sky Presets"> - <menu_item_call label="Nova predefinição..." name="new_sky_preset"/> - <menu_item_call label="Editar predefinição..." name="edit_sky_preset"/> - <menu_item_call label="Excluir predefinição..." name="delete_sky_preset"/> - </menu> - <menu label="Predefinições do dia" name="Day Presets"> - <menu_item_call label="Nova predefinição..." name="new_day_preset"/> - <menu_item_call label="Editar predefinição..." name="edit_day_preset"/> - <menu_item_call label="Excluir predefinição..." name="delete_day_preset"/> - </menu> + <menu_item_check label="Use o ambiente compartilhado" name="Use Shared Environment"/> + <menu_item_call label="Meu ambiente..." name="my_environs"/> + <menu_item_check label="Pausar as nuvens" name="pause_clouds"/> </menu> </menu> <menu label="Construir" name="BuildTools"> @@ -297,7 +281,6 @@ <menu_item_check label="Formas físicas" name="Physics Shapes"/> <menu_item_check label="Tipo de atualização" name="Update Type"/> <menu_item_check label="Dados LOD" name="LOD Info"/> - <menu_item_check label="Contar triângulo" name="Triangle Count"/> <menu_item_check label="Fila de construção" name="Build Queue"/> <menu_item_check label="Partículas" name="Particles"/> <menu_item_check label="Junções" name="Joints"/> @@ -372,7 +355,6 @@ <menu_item_check label="Show Collision Skeleton" name="Show Collision Skeleton"/> <menu_item_check label="Exibir ossos" name="Show Bones"/> <menu_item_check label="Display Agent Target" name="Display Agent Target"/> - <menu_item_check label="Mostrar as extensões do impostor" name="Show Impostor Extents"/> <menu_item_call label="Depurar texturas do avatar" name="Debug Avatar Textures"/> </menu> <menu_item_check label="Texturas HTTP" name="HTTP Textures"/> diff --git a/indra/newview/skins/default/xui/pt/notifications.xml b/indra/newview/skins/default/xui/pt/notifications.xml index 5c848034d8..75c3b0ec58 100644 --- a/indra/newview/skins/default/xui/pt/notifications.xml +++ b/indra/newview/skins/default/xui/pt/notifications.xml @@ -1864,7 +1864,7 @@ Isto mudará milhares de regiões e fará o spaceserver soluçar. <usetemplate canceltext="Cancelar" name="yesnocancelbuttons" notext="Todas as Propriedades" yestext="Esta Propriedade"/> </notification> <notification label="Selecione a propriedade" name="EstateBannedAgentRemove"> - Remover este residente da lista de banidos para acesso a esta propriedade apenas ou para [ALL_ESTATES]? + Remover este Residente da lista de banimento para acessar esta propriedade somente ou para [ALL_ESTATES]? <usetemplate canceltext="Cancelar" name="yesnocancelbuttons" notext="Todas as Propriedades" yestext="Esta Propriedade"/> </notification> <notification label="Selecione a propriedade" name="EstateManagerAdd"> @@ -1911,6 +1911,10 @@ Isto mudará milhares de regiões e fará o spaceserver soluçar. Ao desselecionar esta opção, você pode remover as restrições que os proprietários dos terrenos adicionaram para evitar problemas, manter a privacidade ou proteger residentes menores de idade contra conteúdo adulto. Por favor, discuta com os seus proprietários de terreno conforme necessário. <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + Desmarcando esta opção pode remover quaisquer ambientes personalizados que os proprietários tenham adicionado aos seus lotes.. Por favor, discuta com os seus proprietários de terreno conforme necessário. + <usetemplate name="okbutton" yestext="OK"/> + </notification> <notification name="RegionEntryAccessBlocked"> A região que você está tentando visitar tem conteúdo que excede suas preferências atuais. Você pode alterar suas preferências acessando Eu > Preferências > Geral. <usetemplate name="okbutton" yestext="OK"/> @@ -4336,4 +4340,40 @@ Tente selecionar uma quantidade menor de terreno. [REASON] <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="FailedToFindSettings"> + Não pode carregar as configurações para [NAME] da base de dados. + </notification> + <notification name="FailedToLoadSettingsApply"> + Não foi possível aplicar aquelas configurações para o ambiente. + </notification> + <notification name="FailedToBuildSettingsDay"> + Não foi possível aplicar aquelas configurações para o ambiente. + </notification> + <notification name="NoEnvironmentSettings"> + Esta Região não suporta as configurações do ambiente. + </notification> + <notification name="WLImportFail"> + Não foi possível importar as configurações do legado Windlight de [FILE]. + </notification> + <notification name="WLParcelApplyFail"> + Não é possível definir o ambiente para este lote. +Inserir ou selecionar um lote que você tem direitos para modificar. + </notification> + <notification name="SettingsUnsuported"> + As configurações não são suportadas para esta região. +Mude para uma configuração permitida para a região ou tente novamente realizar a ação. + </notification> + <notification name="SettingsConfirmLoss"> + Você está prestes a perder as alterações que você fez para este [TYPE] com o nome "[NAME]". +Tem certeza de que deseja continuar? + <usetemplate ignoretext="Tem certeza de que deseja perder as alterações?" name="okcancelignore" notext="Não" yestext="Sim"/> + </notification> + <notification name="SettingsMakeNoTrans"> + Você está prestes a importar configurações não transferíveis para este ciclo de dias. Caso continue, transformará as configurações que você está editando não transferível também. + +Esta alteração não pode ser desfeita. + +Tem certeza de que deseja continuar? + <usetemplate ignoretext="Tem certeza de que deseja tornar as configurações não transferível?" name="okcancelignore" notext="Não" yestext="Sim"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/pt/panel_region_environment.xml b/indra/newview/skins/default/xui/pt/panel_region_environment.xml index 7593c50941..f57bf7eb4d 100644 --- a/indra/newview/skins/default/xui/pt/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/pt/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="Ambiente" name="panel_env_info"> - <text name="water_settings_title"> - Selecionar a Água e o Céu/Configurações de Ciclo de Dias que você gostaria que todos os visitantes da sua região visse. Mais informações - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Use o padrão Second Life" name="use_sl_default_settings"/> - <radio_item label="Use as seguintes configurações" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - Configurações da água - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-Selecionar uma prefefinição-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - Céu / Ciclo de dias - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="Céu fixo" name="my_sky_settings"/> - <radio_item label="Ciclos de dias" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-Selecionar uma prefefinição-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-Selecionar uma prefefinição-" name="item0"/> - </combo_box> - </panel> - <button label="Aplicar" name="apply_btn"/> - <button label="Cancelar" name="cancel_btn"/> + <string name="str_label_use_default"> + Usar as configurações padrões + </string> + <string name="str_label_use_region"> + Usar as configurações da região + </string> + <string name="str_unknow_inventory"> + Desconhecido + </string> + <string name="str_altitude_desription"> + Céu [INDEX]([ALTITUDE]m) + </string> + <string name="str_no_parcel"> + Nenhum lote está selecionado. As configurações do ambiente estão desativadas. + </string> + <string name="str_cross_region"> + As configurações do ambiente não estão disponíveis além das fronteiras da região. + </string> + <string name="str_legacy"> + As configurações do ambiente não estão disponíveis nesta região. + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="Configurações de inventário" name="rdo_use_inv_setting"/> + <radio_item label="Personalizar o ambiente" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + Desconhecido + </line_editor> + <button label="Editar o ambiente" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + Chão + </text> + <text name="alt1"> + Céu [INDEX]([ALTITUDE]m) + </text> + <text name="alt2"> + Céu [INDEX]([ALTITUDE]m) + </text> + <text name="alt3"> + Céu [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="Os proprietários do lote podem desconsiderar o ambiente" name="chk_allow_override"/> + <button label="Aplicar" name="btn_apply"/> + <button label="Redefinir" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/pt/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/pt/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..25c27cd6e6 --- /dev/null +++ b/indra/newview/skins/default/xui/pt/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Atmosfera e Claridade" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/pt/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/pt/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..70f814138a --- /dev/null +++ b/indra/newview/skins/default/xui/pt/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Nuvens" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/pt/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/pt/panel_settings_sky_density.xml new file mode 100644 index 0000000000..14143a928a --- /dev/null +++ b/indra/newview/skins/default/xui/pt/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Densidade" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Espelhar termo exponencial:" name="rayleigh_exponential"/> + <slider label="Espelhar escala exponencial:" name="rayleigh_exponential_scale"/> + <slider label="Espelhar termo linear:" name="rayleigh_linear"/> + <slider label="Espelhar termo constante:" name="rayleigh_constant"/> + <slider label="Espelhar altitude máxima:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Mie termo exponencial:" name="mie_exponential"/> + <slider label="Mie escala exponencial:" name="mie_exponential_scale"/> + <slider label="Mie termo linear:" name="mie_linear"/> + <slider label="Mie termo constante:" name="mie_constant"/> + <slider label="Mie fator aniso:" name="mie_aniso_factor"/> + <slider label="Mie altitude máxima:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Absorção termo exponencial:" name="absorption_exponential"/> + <slider label="Absorção escala exponencial:" name="absorption_exponential_scale"/> + <slider label="Absorção termo linear:" name="absorption_linear"/> + <slider label="Absorção termo constante:" name="absorption_constant"/> + <slider label="Absorção altitude máxima:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/pt/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/pt/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..df3a023f20 --- /dev/null +++ b/indra/newview/skins/default/xui/pt/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Sol e Lua" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/pt/panel_settings_water.xml b/indra/newview/skins/default/xui/pt/panel_settings_water.xml new file mode 100644 index 0000000000..9a6e6462bd --- /dev/null +++ b/indra/newview/skins/default/xui/pt/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Água" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + Offset fresnel: + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/pt/strings.xml b/indra/newview/skins/default/xui/pt/strings.xml index ecf90ef787..4c23e48b89 100644 --- a/indra/newview/skins/default/xui/pt/strings.xml +++ b/indra/newview/skins/default/xui/pt/strings.xml @@ -592,6 +592,15 @@ Aguarde um minuto antes que tentar logar-se novamente. <string name="BUTTON_HELP"> Mostrar ajuda </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + Os itens deste tipo não podem ser anexados +às anotações desta região. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + Somente itens com permissões irrestritas +do 'próximo proprietário’ "pode +ser anexado às anotações." + </string> <string name="Searching"> Buscando... </string> @@ -740,6 +749,9 @@ http://secondlife.com/support para ajuda ao resolver este problema. <string name="symbolic link"> link </string> + <string name="settings blob"> + configurações + </string> <string name="symbolic folder link"> link da pasta </string> @@ -2428,6 +2440,9 @@ Se você continuar a receber essa mensagem, entre em contato com o suporte do Se <string name="RegionSettings"> Configurações da região </string> + <string name="NoEnvironmentSettings"> + Esta Região não suporta as configurações do ambiente. + </string> <string name="ClassifiedClicksTxt"> Cliques: [TELEPORT] teletransporte, [MAP] mapa, [PROFILE] perfil </string> @@ -4706,6 +4721,15 @@ Denunciar abuso <string name="Female - Wow"> Wow - feminino </string> + <string name="New Daycycle"> + Novo ciclo de dias + </string> + <string name="New Water"> + Nova água + </string> + <string name="New Sky"> + Novo céu + </string> <string name="/bow"> /reverência </string> diff --git a/indra/newview/skins/default/xui/ru/floater_about_land.xml b/indra/newview/skins/default/xui/ru/floater_about_land.xml index 50402633f2..575f30b4e9 100644 --- a/indra/newview/skins/default/xui/ru/floater_about_land.xml +++ b/indra/newview/skins/default/xui/ru/floater_about_land.xml @@ -462,5 +462,6 @@ </panel> </panel> <panel label="ПРИКЛЮЧЕНИЯ" name="land_experiences_panel"/> + <panel label="СРЕДА" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/ru/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/ru/floater_delete_env_preset.xml deleted file mode 100644 index 1ae278f03b..0000000000 --- a/indra/newview/skins/default/xui/ru/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="УДАЛЕНИЕ НАСТРОЙКИ СРЕДЫ"> - <string name="title_water"> - Удалить настройку воды - </string> - <string name="title_sky"> - Удалить настройку неба - </string> - <string name="title_day_cycle"> - Удалить суточный цикл - </string> - <string name="label_water"> - Настройка: - </string> - <string name="label_sky"> - Настройка: - </string> - <string name="label_day_cycle"> - Суточный цикл: - </string> - <string name="msg_confirm_deletion"> - Действительно удалить выбранную настройку? - </string> - <string name="msg_sky_is_referenced"> - Нельзя удалить настройку, которая используется в некоторых суточных циклах. - </string> - <string name="combo_label"> - -Выбор настройки- - </string> - <text name="label"> - Настройка: - </text> - <button label="Удалить" name="delete"/> - <button label="Отмена" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/ru/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/ru/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..a4ed7250fc --- /dev/null +++ b/indra/newview/skins/default/xui/ru/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="Изменить суточный цикл"> + <string name="title_new"> + Создать суточный цикл + </string> + <string name="title_edit"> + Изменить суточный цикл + </string> + <string name="hint_new"> + Введите имя суточного цикла, задайте его параметры с помощью элементов управления и нажмите кнопку «Сохранить». + </string> + <string name="hint_edit"> + Чтобы изменить суточный цикл, задайте его параметры с помощью элементов управления ниже и нажмите кнопку «Сохранить». + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + Небо \[ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + Название суточного цикла: + </text> + <button label="Импортировать" name="btn_import" tool_tip="Импортировать устаревшие параметры с диска."/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="Небо 4" name="sky4_track"/> + <button label="Небо 3" name="sky3_track"/> + <button label="Небо 2" name="sky2_track"/> + <button label="Уровень земли" name="sky1_track"/> + <button label="Вода" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="Шаг назад"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="Шаг вперед"/> + </layout_panel> + </layout_stack> + <button label="Добавить фрейм" name="add_frame"/> + <button label="Загрузить фрейм" name="btn_load_frame"/> + <button label="Удалить фрейм" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + Выбрать ключевой фрейм на временной шкале для изменения настроек. + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="Вода" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="Атмосфера и освещение" name="atmosphere_panel"/> + <panel label="Облака" name="clouds_panel"/> + <panel label="Солнце и луна" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="Сохранить" name="save_btn"/> + <button label="Отмена" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ru/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/ru/floater_fixedenvironment.xml new file mode 100644 index 0000000000..c6e405ffe1 --- /dev/null +++ b/indra/newview/skins/default/xui/ru/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="Фиксированная среда"> + <string name="edit_sky"> + Изменить небо: + </string> + <string name="edit_water"> + Изменить настройки воды: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="Загрузить" name="btn_load" tool_tip="Загрузить настройки из инвентарного списка"/> + <button label="Импортировать" name="btn_import" tool_tip="Импортировать устаревшие параметры с диска."/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="Сохранить" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="Отмена" name="btn_cancel" tool_tip="Вернуться к последней сохраненной версии"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ru/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/ru/floater_inventory_view_finder.xml index ce6b89cb82..7c1d3b52c5 100644 --- a/indra/newview/skins/default/xui/ru/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/ru/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="Звуки" name="check_sound"/> <check_box label="Текстуры" name="check_texture"/> <check_box label="Снимки" name="check_snapshot"/> + <check_box label="Настройки" name="check_settings"/> <button label="Все" label_selected="Все" name="All"/> <button label="Нет" label_selected="Нет" name="None"/> <check_box label="Всегда показывать папки" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/ru/floater_my_environments.xml b/indra/newview/skins/default/xui/ru/floater_my_environments.xml new file mode 100644 index 0000000000..1233139e12 --- /dev/null +++ b/indra/newview/skins/default/xui/ru/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="Места" name="my_environments" title="МОЯ СРЕДА"> + <layout_stack> + <layout_panel label="Фильтры" name="filter_panel"> + <check_box label="Дни" name="chk_days"/> + <check_box label="Небеса" name="chk_skies"/> + <check_box label="Вода" name="chk_water"/> + </layout_panel> + <layout_panel label="Окружающая среда" name="list_panel"> + <check_box initial_value="false" label="Показать пустые папки" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="Дополнительные параметры"/> + <menu_button name="btn_newsettings" tool_tip="Создать новый параметр"/> + <button name="btn_del" tool_tip="Удалить этот параметр"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ru/floater_settings_picker.xml b/indra/newview/skins/default/xui/ru/floater_settings_picker.xml new file mode 100644 index 0000000000..09dd29b73e --- /dev/null +++ b/indra/newview/skins/default/xui/ru/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="ВЫБРАТЬ: НАСТРОЙКИ"> + <floater.string name="choose_picture"> + Щелкните для выбора изображения + </floater.string> + <floater.string name="pick title"> + Выбрать: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="Фильтровать текстуры" name="flt_inventory_search"/> + <check_box initial_value="false" label="Показать папки" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="OK" label_selected="OK" name="btn_select"/> + <button label="Отмена" label_selected="Отмена" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/ru/menu_inventory.xml b/indra/newview/skins/default/xui/ru/menu_inventory.xml index 3404ae29a3..e39cbedca1 100644 --- a/indra/newview/skins/default/xui/ru/menu_inventory.xml +++ b/indra/newview/skins/default/xui/ru/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="Активировать" name="Marketplace Activate"/> <menu_item_call label="Деактивировать" name="Marketplace Deactivate"/> <menu_item_call label="Поделиться" name="Share"/> - <menu_item_call label="Купить" name="Task Buy"/> <menu_item_call label="Открыть" name="Task Open"/> <menu_item_call label="Воспроизвести" name="Task Play"/> <menu_item_call label="Свойства" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="Новые волосы" name="New Hair"/> <menu_item_call label="Новые глаза" name="New Eyes"/> </menu> + <menu label="Новые настройки" name="New Settings"> + <menu_item_call label="Новое небо" name="New Sky"/> + <menu_item_call label="Новая вода" name="New Water"/> + <menu_item_call label="Новый суточный цикл" name="New Day Cycle"/> + </menu> <menu label="Использовать по умолчанию для" name="upload_def"> <menu_item_call label="Переданные изображения" name="Image uploads"/> <menu_item_call label="Переданные звуки" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="Изменить" name="Wearable Edit"/> <menu_item_call label="Добавить" name="Wearable Add"/> <menu_item_call label="Снять" name="Take Off"/> + <menu_item_call label="Применять только к себе" name="Settings Apply Local"/> + <menu_item_call label="Применить к участку" name="Settings Apply Parcel"/> + <menu_item_call label="Применить к региону" name="Settings Apply Region"/> <menu_item_call label="Копировать в списки товаров торгового центра" name="Marketplace Copy"/> <menu_item_call label="Переместить в списки товаров торгового центра" name="Marketplace Move"/> <menu_item_call label="- нет действий -" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/ru/menu_inventory_add.xml b/indra/newview/skins/default/xui/ru/menu_inventory_add.xml index 9a240c653e..0a9f00411b 100644 --- a/indra/newview/skins/default/xui/ru/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/ru/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="Звук (L$[COST])..." name="Upload Sound"/> <menu_item_call label="Анимация (L$[COST])..." name="Upload Animation"/> <menu_item_call label="Модель..." name="Upload Model"/> - <menu_item_call label="Мастер моделирования..." name="Upload Model Wizard"/> <menu_item_call label="Все сразу (L$[COST] за файл)..." name="Bulk Upload"/> - <menu_item_call label="Установить разрешения на передачу по умолчанию" name="perm prefs"/> </menu> <menu_item_call label="Новая папка" name="New Folder"/> <menu_item_call label="Новый скрипт" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="Новые волосы" name="New Hair"/> <menu_item_call label="Новые глаза" name="New Eyes"/> </menu> + <menu label="Новые настройки" name="New Settings"> + <menu_item_call label="Новое небо" name="New Sky"/> + <menu_item_call label="Новая вода" name="New Water"/> + <menu_item_call label="Новый суточный цикл" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/ru/menu_save_settings.xml b/indra/newview/skins/default/xui/ru/menu_save_settings.xml new file mode 100644 index 0000000000..daebb9af3d --- /dev/null +++ b/indra/newview/skins/default/xui/ru/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="Сохранить" name="save_settings"/> + <menu_item_check label="Сохранить как" name="save_as_new_settings"/> + <menu_item_check label="Подтвердить" name="commit_changes"/> + <menu_item_check label="Применять только к себе" name="apply_local"/> + <menu_item_check label="Применить к участку" name="apply_parcel"/> + <menu_item_check label="Применить к региону" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/ru/menu_settings_add.xml b/indra/newview/skins/default/xui/ru/menu_settings_add.xml new file mode 100644 index 0000000000..a3ef976424 --- /dev/null +++ b/indra/newview/skins/default/xui/ru/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="Новое небо" name="New Sky"/> + <menu_item_call label="Новая вода" name="New Water"/> + <menu_item_call label="Новый суточный цикл" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/ru/menu_settings_gear.xml b/indra/newview/skins/default/xui/ru/menu_settings_gear.xml new file mode 100644 index 0000000000..6e6dfd331d --- /dev/null +++ b/indra/newview/skins/default/xui/ru/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="Изменить" name="edit_settings"/> + <menu_item_call label="Применять только к себе" name="Settings Apply Local"/> + <menu_item_call label="Применить к участку" name="Settings Apply Parcel"/> + <menu_item_call label="Применить к региону" name="Settings Apply Region"/> + <menu_item_call label="Копировать" name="copy_settings"/> + <menu_item_call label="Вставить" name="paste_settings"/> + <menu_item_call label="Копировать UUID" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/ru/menu_viewer.xml b/indra/newview/skins/default/xui/ru/menu_viewer.xml index 67ebda684a..8e94c4f5fd 100644 --- a/indra/newview/skins/default/xui/ru/menu_viewer.xml +++ b/indra/newview/skins/default/xui/ru/menu_viewer.xml @@ -75,30 +75,14 @@ <menu_item_check label="Свойства участка" name="Parcel Properties"/> <menu_item_check label="Меню «Дополнительно»" name="Show Advanced Menu"/> </menu> - <menu label="Солнце" name="Sun"> + <menu label="Окружающая среда" name="Environment"> <menu_item_check label="Восход" name="Sunrise"/> <menu_item_check label="Полдень" name="Noon"/> <menu_item_check label="Закат" name="Sunset"/> <menu_item_check label="Полночь" name="Midnight"/> - <menu_item_check label="Использовать настройки региона" name="Use Region Settings"/> - </menu> - <menu label="Редактор среды" name="Environment Editor"> - <menu_item_call label="Настройки среды..." name="Environment Settings"/> - <menu label="Настройки воды" name="Water Presets"> - <menu_item_call label="Новая настройка..." name="new_water_preset"/> - <menu_item_call label="Изменить настройку..." name="edit_water_preset"/> - <menu_item_call label="Удалить настройку..." name="delete_water_preset"/> - </menu> - <menu label="Настройки неба" name="Sky Presets"> - <menu_item_call label="Новая настройка..." name="new_sky_preset"/> - <menu_item_call label="Изменить настройку..." name="edit_sky_preset"/> - <menu_item_call label="Удалить настройку..." name="delete_sky_preset"/> - </menu> - <menu label="Суточные настройки" name="Day Presets"> - <menu_item_call label="Новая настройка..." name="new_day_preset"/> - <menu_item_call label="Изменить настройку..." name="edit_day_preset"/> - <menu_item_call label="Удалить настройку..." name="delete_day_preset"/> - </menu> + <menu_item_check label="Использование окружающей среды" name="Use Shared Environment"/> + <menu_item_call label="Моя среда…" name="my_environs"/> + <menu_item_check label="Приостановить движение облаков" name="pause_clouds"/> </menu> </menu> <menu label="Строительство" name="BuildTools"> @@ -309,7 +293,6 @@ <menu_item_check label="Площадь текстуры" name="Texture Area"/> <menu_item_check label="Площадь грани" name="Face Area"/> <menu_item_check label="Данные об уровнях детализации" name="LOD Info"/> - <menu_item_check label="Количество треугольников" name="Triangle Count"/> <menu_item_check label="Очередь построителя" name="Build Queue"/> <menu_item_check label="Освещение" name="Lights"/> <menu_item_check label="Частицы" name="Particles"/> @@ -422,7 +405,6 @@ <menu_item_check label="Показать скелет" name="Show Collision Skeleton"/> <menu_item_check label="Показать кости" name="Show Bones"/> <menu_item_check label="Отобразить действие агента" name="Display Agent Target"/> - <menu_item_check label="Показать пределы импостера" name="Show Impostor Extents"/> <menu_item_call label="Вывод присоединений" name="Dump Attachments"/> <menu_item_call label="Отладка текстур аватара" name="Debug Avatar Textures"/> <menu_item_call label="Вывод локальных текстур" name="Dump Local Textures"/> diff --git a/indra/newview/skins/default/xui/ru/notifications.xml b/indra/newview/skins/default/xui/ru/notifications.xml index d752bf254e..e46e569a39 100644 --- a/indra/newview/skins/default/xui/ru/notifications.xml +++ b/indra/newview/skins/default/xui/ru/notifications.xml @@ -1872,7 +1872,7 @@ <usetemplate canceltext="Отмена" name="yesnocancelbuttons" notext="Для всех землевладений" yestext="Для этого землевладения"/> </notification> <notification label="Выбрать землевладение" name="EstateBannedAgentRemove"> - Удалить этого жителя из списка запрета доступа только для этого землевладения или для [ALL_ESTATES]? + Удалить этого жителя из списка заблокированного доступа только для этого землевладения или для [ALL_ESTATES]? <usetemplate canceltext="Отмена" name="yesnocancelbuttons" notext="Для всех землевладений" yestext="Для этого землевладения"/> </notification> <notification label="Выбрать землевладение" name="EstateManagerAdd"> @@ -1919,6 +1919,10 @@ При снятии этой опции вы можете удалить ограничения, которые владельцы участка добавили для предотвращения провокационных сообщений, сохранения конфиденциальности и защиты несовершеннолетных жителей от материала для взрослых. При необходимости обсудите со своими владельцами участков. <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + При снятии этой опции вы можете удалить пользовательскую среду, которую владельцы участка добавили для своего участка. При необходимости обсудите со своими владельцами участков. + <usetemplate name="okbutton" yestext="OK"/> + </notification> <notification name="RegionEntryAccessBlocked"> Вы пытаетесь посетить регион, контент в котором не соответствует вашим настройкам. Попробуйте изменить настройки в меню «Я > Настройки > Общие». <usetemplate name="okbutton" yestext="OK"/> @@ -4349,4 +4353,40 @@ [REASON] <usetemplate name="okbutton" yestext="OK"/> </notification> + <notification name="FailedToFindSettings"> + Не удалось загрузить настройки для \[NAME] из базы данных. + </notification> + <notification name="FailedToLoadSettingsApply"> + Невозможно применить эти параметры для этой среды. + </notification> + <notification name="FailedToBuildSettingsDay"> + Невозможно применить эти параметры для этой среды. + </notification> + <notification name="NoEnvironmentSettings"> + Этот регион не поддерживает параметры среды. + </notification> + <notification name="WLImportFail"> + Невозможно импортировать устаревшие параметры для эффекта Windlight из \[FILE]. + </notification> + <notification name="WLParcelApplyFail"> + Невозможно установить параметры среды для этого участка. +Введите или выберите участок, которые вы вправе изменять. + </notification> + <notification name="SettingsUnsuported"> + Параметры среды не поддерживаются в этом регионе. +Перейдите в регион с поддерживаемыми параметрами и повторите действие. + </notification> + <notification name="SettingsConfirmLoss"> + Вы потеряете изменения, внесенные в этот \[TYPE] под именем "[NAME]". +Вы уверены, что хотите продолжить? + <usetemplate ignoretext="Вы уверены, что не хотите сохранить изменения?" name="okcancelignore" notext="Нет" yestext="Да"/> + </notification> + <notification name="SettingsMakeNoTrans"> + Вы собираетесь импортировать непереносимые настройки в этот суточный цикл. В случае дальнейшего изменения в этих параметрах они также станут непереносимыми. + +Это изменение не подлежит отмене. + +Вы уверены, что хотите продолжить? + <usetemplate ignoretext="Вы уверены, что хотите сделать настройки непереносимыми?" name="okcancelignore" notext="Нет" yestext="Да"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/ru/panel_region_environment.xml b/indra/newview/skins/default/xui/ru/panel_region_environment.xml index 8057176cfb..a98e7bf106 100644 --- a/indra/newview/skins/default/xui/ru/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/ru/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="Среда" name="panel_env_info"> - <text name="water_settings_title"> - Настройки воды и неба/суточного цикла определяют, каким посетители увидят ваш регион. Дополнительная информация - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Использовать настройки Second Life по умолчанию" name="use_sl_default_settings"/> - <radio_item label="Использовать следующие настройки" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - Настройка воды - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-Выбор настройки-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - Небо/суточный цикл - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="Зафиксированное небо" name="my_sky_settings"/> - <radio_item label="Суточный цикл" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-Выбор настройки-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-Выбор настройки-" name="item0"/> - </combo_box> - </panel> - <button label="Применить" name="apply_btn"/> - <button label="Отмена" name="cancel_btn"/> + <string name="str_label_use_default"> + Использовать пользовательские настройки + </string> + <string name="str_label_use_region"> + Использовать настройки региона + </string> + <string name="str_unknow_inventory"> + Неизвестно + </string> + <string name="str_altitude_desription"> + Небо \[INDEX](\[ALTITUDE]m) + </string> + <string name="str_no_parcel"> + Не выбрано ни одного участка. Настройки среды отключены. + </string> + <string name="str_cross_region"> + Параметры среды недоступны в рамках этого региона. + </string> + <string name="str_legacy"> + Параметры среды недоступны в этом регионе. + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="Настройки из инвентарного списка" name="rdo_use_inv_setting"/> + <radio_item label="Пользовательская среда" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + Неизвестно + </line_editor> + <button label="Изменить параметры окружающей среды" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + Земля + </text> + <text name="alt1"> + Небо \[INDEX](\[ALTITUDE]m) + </text> + <text name="alt2"> + Небо \[INDEX](\[ALTITUDE]m) + </text> + <text name="alt3"> + Небо \[INDEX](\[ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="Владельцы участков могут менять окружающую среду" name="chk_allow_override"/> + <button label="Применить" name="btn_apply"/> + <button label="Сброс" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/ru/panel_region_estate.xml b/indra/newview/skins/default/xui/ru/panel_region_estate.xml index be93edf730..843fcaa9f8 100644 --- a/indra/newview/skins/default/xui/ru/panel_region_estate.xml +++ b/indra/newview/skins/default/xui/ru/panel_region_estate.xml @@ -36,7 +36,7 @@ <button label="Добавить..." name="add_allowed_avatar_btn"/> <button label="Удалить..." name="remove_allowed_avatar_btn"/> <text name="allow_group_label"> - Группы всегда разрешены: + Допуск групп всегда разрешен: </text> <text name="ban_resident_label"> Всегда заблокированы: diff --git a/indra/newview/skins/default/xui/ru/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/ru/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..9c4c502694 --- /dev/null +++ b/indra/newview/skins/default/xui/ru/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Атмосфера и освещение" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/ru/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/ru/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..46b4b10125 --- /dev/null +++ b/indra/newview/skins/default/xui/ru/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Облака" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/ru/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/ru/panel_settings_sky_density.xml new file mode 100644 index 0000000000..8886ceb539 --- /dev/null +++ b/indra/newview/skins/default/xui/ru/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Плотность" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Экспоненциальный член Рэлея:" name="rayleigh_exponential"/> + <slider label="Экспоненциальная шкала Рэлея:" name="rayleigh_exponential_scale"/> + <slider label="Линейный член Рэлея:" name="rayleigh_linear"/> + <slider label="Постоянный член Рэлея:" name="rayleigh_constant"/> + <slider label="Максимальная высота Рэлея:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Экспоненциальный член Мие:" name="mie_exponential"/> + <slider label="Экспоненциальная шкала Мие:" name="mie_exponential_scale"/> + <slider label="Линейный член Мие:" name="mie_linear"/> + <slider label="Постоянный член Мие:" name="mie_constant"/> + <slider label="Анизо-фактор Мие:" name="mie_aniso_factor"/> + <slider label="Максимальная высота Мие:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Экспоненциальный член абсорбции:" name="absorption_exponential"/> + <slider label="Экспоненциальная шкала абсорбции:" name="absorption_exponential_scale"/> + <slider label="Линейный член абсорбции:" name="absorption_linear"/> + <slider label="Постоянный член абсорбции:" name="absorption_constant"/> + <slider label="Максимальная высота абсорбции:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/ru/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/ru/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..863cc13e6b --- /dev/null +++ b/indra/newview/skins/default/xui/ru/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Солнце и луна" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/ru/panel_settings_water.xml b/indra/newview/skins/default/xui/ru/panel_settings_water.xml new file mode 100644 index 0000000000..de8b15ac19 --- /dev/null +++ b/indra/newview/skins/default/xui/ru/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Вода" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + Угловая зависимость: + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X:" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/ru/strings.xml b/indra/newview/skins/default/xui/ru/strings.xml index 267c717189..dc4741e9bd 100644 --- a/indra/newview/skins/default/xui/ru/strings.xml +++ b/indra/newview/skins/default/xui/ru/strings.xml @@ -636,6 +636,15 @@ support@secondlife.com. <string name="BUTTON_HELP"> Показать справку </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + Элементы этого типа не могут быть занесены в +карточку для комментариев в этом регионе. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + Только элементы с безусловным разрешением +‘следующего владельца’ можно внести +в карточки для комментариев. + </string> <string name="Searching"> Поиск... </string> @@ -784,6 +793,9 @@ support@secondlife.com. <string name="symbolic link"> ссылку </string> + <string name="settings blob"> + настройки + </string> <string name="symbolic folder link"> ссылку на папку </string> @@ -2487,6 +2499,9 @@ support@secondlife.com. <string name="RegionSettings"> Региональные настройки </string> + <string name="NoEnvironmentSettings"> + Этот регион не поддерживает параметры среды. + </string> <string name="ClassifiedClicksTxt"> Щелчки: телепорт [TELEPORT], карта [MAP], профиль [PROFILE] </string> @@ -4826,6 +4841,15 @@ support@secondlife.com. <string name="Female - Wow"> Женщина – ух ты! </string> + <string name="New Daycycle"> + Новый суточный цикл + </string> + <string name="New Water"> + Новая вода + </string> + <string name="New Sky"> + Новое небо + </string> <string name="/bow"> /поклониться </string> diff --git a/indra/newview/skins/default/xui/tr/floater_about_land.xml b/indra/newview/skins/default/xui/tr/floater_about_land.xml index 1f4decb056..f09ea5397b 100644 --- a/indra/newview/skins/default/xui/tr/floater_about_land.xml +++ b/indra/newview/skins/default/xui/tr/floater_about_land.xml @@ -462,5 +462,6 @@ Sadece büyük parseller aramada görünür. </panel> </panel> <panel label="DENEYİMLER" name="land_experiences_panel"/> + <panel label="ORTAM" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/tr/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/tr/floater_delete_env_preset.xml deleted file mode 100644 index 7634bea642..0000000000 --- a/indra/newview/skins/default/xui/tr/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="ORTAM ÖN AYARINI SİL"> - <string name="title_water"> - Su Ön Ayarını Sil - </string> - <string name="title_sky"> - Gökyüzü Ön Ayarını Sil - </string> - <string name="title_day_cycle"> - Gün Döngüsünü Sil - </string> - <string name="label_water"> - Ön Ayar: - </string> - <string name="label_sky"> - Ön Ayar: - </string> - <string name="label_day_cycle"> - Gün döngüsü: - </string> - <string name="msg_confirm_deletion"> - Seçili ön ayarı silmek istediğinizden emin misiniz? - </string> - <string name="msg_sky_is_referenced"> - Bazı gün döngüleri tarafından referans alınan bir ön ayar kaldırılamaz. - </string> - <string name="combo_label"> - -Bir ön ayar seçin- - </string> - <text name="label"> - Ön Ayar: - </text> - <button label="Sil" name="delete"/> - <button label="İptal Et" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/tr/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/tr/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..41d3842a94 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="Gün Döngüsünü Düzenle"> + <string name="title_new"> + Yeni bir Gün Döngüsü Oluştur + </string> + <string name="title_edit"> + Gün Döngüsünü Düzenle + </string> + <string name="hint_new"> + Gün döngünüze ad verin, bunu oluşturmak için denetimleri ayarlayın ve "Kaydet" düğmesine tıklayın. + </string> + <string name="hint_edit"> + Gün döngünüzü düzenlemek için, alttaki denetimleri ayarlayın ve "Kaydet" düğmesine tıklayın. + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + Gökyüzü [ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + Gün Döngüsü Adı: + </text> + <button label="İçeri Aktar" name="btn_import" tool_tip="Eski ayarları diskten içeri aktarın."/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="Gökyüzü 4" name="sky4_track"/> + <button label="Gökyüzü 3" name="sky3_track"/> + <button label="Gökyüzü 2" name="sky2_track"/> + <button label="Zemin Seviyesi" name="sky1_track"/> + <button label="Su" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="%0 [DSC]"/> + <text name="p1" value="%25 [DSC]"/> + <text name="p2" value="%50 [DSC]"/> + <text name="p3" value="%75 [DSC]"/> + <text name="p4" value="%100 [DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="%[PRCNT] [DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="Geri çekil"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="İleri çık"/> + </layout_panel> + </layout_stack> + <button label="Çerçeve Ekle" name="add_frame"/> + <button label="Çerçeve Yükle" name="btn_load_frame"/> + <button label="Çerçeve Sil" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + Ayarları düzenlemek için yukarıdaki zaman çizelgesinden bir anahtar çerçeve seçin. + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="Su" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="Atmosfer ve Aydınlatma" name="atmosphere_panel"/> + <panel label="Bulutlar" name="clouds_panel"/> + <panel label="Güneş ve Ay" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="Kaydet" name="save_btn"/> + <button label="İptal Et" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/tr/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/tr/floater_fixedenvironment.xml new file mode 100644 index 0000000000..8a8757c86c --- /dev/null +++ b/indra/newview/skins/default/xui/tr/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="Sabit Ortam"> + <string name="edit_sky"> + Gökyüzünü Düzenle: + </string> + <string name="edit_water"> + Suyu Düzenle: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="Yükle" name="btn_load" tool_tip="Envanterden bir ayar yükle"/> + <button label="İçeri Aktar" name="btn_import" tool_tip="Eski ayarları diskten içeri aktarın."/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="Kaydet" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="İptal Et" name="btn_cancel" tool_tip="Son kaydedilen sürüme dön"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/tr/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/tr/floater_inventory_view_finder.xml index 6c04b64275..accb1ed71c 100644 --- a/indra/newview/skins/default/xui/tr/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/tr/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="Sesler" name="check_sound"/> <check_box label="Dokular" name="check_texture"/> <check_box label="Anlık Görüntüler" name="check_snapshot"/> + <check_box label="Ayarlar" name="check_settings"/> <button label="Tümü" label_selected="Tümü" name="All"/> <button label="Hiçbiri" label_selected="Hiçbiri" name="None"/> <check_box label="Klasörleri her zaman göster" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/tr/floater_my_environments.xml b/indra/newview/skins/default/xui/tr/floater_my_environments.xml new file mode 100644 index 0000000000..21df7ef003 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="Yerler" name="my_environments" title="ORTAMLARIM"> + <layout_stack> + <layout_panel label="Filtreler" name="filter_panel"> + <check_box label="Günler" name="chk_days"/> + <check_box label="Gökler" name="chk_skies"/> + <check_box label="Su" name="chk_water"/> + </layout_panel> + <layout_panel label="Ortamlar" name="list_panel"> + <check_box initial_value="false" label="Boş Klasörleri Göster" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="Diğer seçenekler"/> + <menu_button name="btn_newsettings" tool_tip="Yeni ayar oluştur"/> + <button name="btn_del" tool_tip="Bu ayarı sil"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/tr/floater_settings_picker.xml b/indra/newview/skins/default/xui/tr/floater_settings_picker.xml new file mode 100644 index 0000000000..bbc8af04c3 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="SEÇİM: AYARLAR"> + <floater.string name="choose_picture"> + Bir resim seçmek için tıklayın + </floater.string> + <floater.string name="pick title"> + Seçim: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="Dokuları Filtrele" name="flt_inventory_search"/> + <check_box initial_value="false" label="Klasörleri göster" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="Tamam" label_selected="Tamam" name="btn_select"/> + <button label="İptal Et" label_selected="İptal Et" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/tr/menu_inventory.xml b/indra/newview/skins/default/xui/tr/menu_inventory.xml index 1e8dfc7d68..1ffc1ea07e 100644 --- a/indra/newview/skins/default/xui/tr/menu_inventory.xml +++ b/indra/newview/skins/default/xui/tr/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="Etkinleştir" name="Marketplace Activate"/> <menu_item_call label="Devre Dışı Bırak" name="Marketplace Deactivate"/> <menu_item_call label="Paylaş" name="Share"/> - <menu_item_call label="Satın Al" name="Task Buy"/> <menu_item_call label="Aç" name="Task Open"/> <menu_item_call label="Oyna" name="Task Play"/> <menu_item_call label="Özellikler" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="Yeni Saç" name="New Hair"/> <menu_item_call label="Yeni Gözler" name="New Eyes"/> </menu> + <menu label="Yeni Ayarlar" name="New Settings"> + <menu_item_call label="Yeni Gökyüzü" name="New Sky"/> + <menu_item_call label="Yeni Su" name="New Water"/> + <menu_item_call label="Yeni Gün Döngüsü" name="New Day Cycle"/> + </menu> <menu label="Şunun için varsayılan olarak kullan" name="upload_def"> <menu_item_call label="Karşıya yüklenen görüntüler" name="Image uploads"/> <menu_item_call label="Karşıya yüklenen sesler" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="Düzenle" name="Wearable Edit"/> <menu_item_call label="Ekle" name="Wearable Add"/> <menu_item_call label="Çıkar" name="Take Off"/> + <menu_item_call label="Sadece Kendime Uygula" name="Settings Apply Local"/> + <menu_item_call label="Parsele Uygula" name="Settings Apply Parcel"/> + <menu_item_call label="Bölgeye Uygula" name="Settings Apply Region"/> <menu_item_call label="Pazaryeri İlanlarına Kopyala" name="Marketplace Copy"/> <menu_item_call label="Pazaryeri İlanlarına Taşı" name="Marketplace Move"/> <menu_item_call label="--seçenek yok--" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/tr/menu_inventory_add.xml b/indra/newview/skins/default/xui/tr/menu_inventory_add.xml index db2a9a2c8c..2f8f450738 100644 --- a/indra/newview/skins/default/xui/tr/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/tr/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="Ses (L$[COST])..." name="Upload Sound"/> <menu_item_call label="Animasyon (L$[COST])..." name="Upload Animation"/> <menu_item_call label="Model..." name="Upload Model"/> - <menu_item_call label="Model Sihirbazı..." name="Upload Model Wizard"/> <menu_item_call label="Toplu (dosya başına L$[COST])..." name="Bulk Upload"/> - <menu_item_call label="Varsayılan Karşıya Yükleme İzinlerini Ayarla" name="perm prefs"/> </menu> <menu_item_call label="Yeni Klasör" name="New Folder"/> <menu_item_call label="Yeni Komut Dosyası" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="Yeni Saç" name="New Hair"/> <menu_item_call label="Yeni Gözler" name="New Eyes"/> </menu> + <menu label="Yeni Ayarlar" name="New Settings"> + <menu_item_call label="Yeni Gökyüzü" name="New Sky"/> + <menu_item_call label="Yeni Su" name="New Water"/> + <menu_item_call label="Yeni Gün Döngüsü" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/tr/menu_save_settings.xml b/indra/newview/skins/default/xui/tr/menu_save_settings.xml new file mode 100644 index 0000000000..dad150a54b --- /dev/null +++ b/indra/newview/skins/default/xui/tr/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="Kaydet" name="save_settings"/> + <menu_item_check label="Farklı Kaydet" name="save_as_new_settings"/> + <menu_item_check label="Yürüt" name="commit_changes"/> + <menu_item_check label="Sadece Kendime Uygula" name="apply_local"/> + <menu_item_check label="Parsele Uygula" name="apply_parcel"/> + <menu_item_check label="Bölgeye Uygula" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/tr/menu_settings_add.xml b/indra/newview/skins/default/xui/tr/menu_settings_add.xml new file mode 100644 index 0000000000..0afd8a7893 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="Yeni Gökyüzü" name="New Sky"/> + <menu_item_call label="Yeni Su" name="New Water"/> + <menu_item_call label="Yeni Gün Döngüsü" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/tr/menu_settings_gear.xml b/indra/newview/skins/default/xui/tr/menu_settings_gear.xml new file mode 100644 index 0000000000..f0d04a9e68 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="Düzenle" name="edit_settings"/> + <menu_item_call label="Sadece Kendime Uygula" name="Settings Apply Local"/> + <menu_item_call label="Parsele Uygula" name="Settings Apply Parcel"/> + <menu_item_call label="Bölgeye Uygula" name="Settings Apply Region"/> + <menu_item_call label="Kopyala" name="copy_settings"/> + <menu_item_call label="Yapıştır" name="paste_settings"/> + <menu_item_call label="UUID'yi Kopyala" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/tr/menu_viewer.xml b/indra/newview/skins/default/xui/tr/menu_viewer.xml index e43ca504f7..384c89b028 100644 --- a/indra/newview/skins/default/xui/tr/menu_viewer.xml +++ b/indra/newview/skins/default/xui/tr/menu_viewer.xml @@ -75,30 +75,14 @@ <menu_item_check label="Parsel Özellikleri" name="Parcel Properties"/> <menu_item_check label="Gelişmiş Menü" name="Show Advanced Menu"/> </menu> - <menu label="Güneş" name="Sun"> + <menu label="Ortam" name="Environment"> <menu_item_check label="Gün doğumu" name="Sunrise"/> <menu_item_check label="Öğle" name="Noon"/> <menu_item_check label="Gün batımı" name="Sunset"/> <menu_item_check label="Gece yarısı" name="Midnight"/> - <menu_item_check label="Bölge Ayarlarını Kullan" name="Use Region Settings"/> - </menu> - <menu label="Ortam Düzenleyici" name="Environment Editor"> - <menu_item_call label="Ortam Ayarları..." name="Environment Settings"/> - <menu label="Su Ön Ayarları" name="Water Presets"> - <menu_item_call label="Yeni ön ayar..." name="new_water_preset"/> - <menu_item_call label="Ön ayarı düzenle..." name="edit_water_preset"/> - <menu_item_call label="Ön ayarı sil..." name="delete_water_preset"/> - </menu> - <menu label="Gökyüzü Ön Ayarları" name="Sky Presets"> - <menu_item_call label="Yeni ön ayar..." name="new_sky_preset"/> - <menu_item_call label="Ön ayarı düzenle..." name="edit_sky_preset"/> - <menu_item_call label="Ön ayarı sil..." name="delete_sky_preset"/> - </menu> - <menu label="Gün Ön Ayarları" name="Day Presets"> - <menu_item_call label="Yeni ön ayar..." name="new_day_preset"/> - <menu_item_call label="Ön ayarı düzenle..." name="edit_day_preset"/> - <menu_item_call label="Ön ayarı sil..." name="delete_day_preset"/> - </menu> + <menu_item_check label="Ortak Ortam Kullan" name="Use Shared Environment"/> + <menu_item_call label="Ortamlarım..." name="my_environs"/> + <menu_item_check label="Bulutları Duraklat" name="pause_clouds"/> </menu> </menu> <menu label="İnşa Et" name="BuildTools"> @@ -310,7 +294,6 @@ <menu_item_check label="Doku Alanı" name="Texture Area"/> <menu_item_check label="Yüz Alanı" name="Face Area"/> <menu_item_check label="Ayrıntı Seviyesi Bilgisi" name="LOD Info"/> - <menu_item_check label="Üçgen Sayısı" name="Triangle Count"/> <menu_item_check label="İnşa Kuyruğu" name="Build Queue"/> <menu_item_check label="Işıklar" name="Lights"/> <menu_item_check label="Parçacıklar" name="Particles"/> @@ -423,7 +406,6 @@ <menu_item_check label="Çarpışma İskeletini Göster" name="Show Collision Skeleton"/> <menu_item_check label="Kemikleri Göster" name="Show Bones"/> <menu_item_check label="Aracı Hedefini Göster" name="Display Agent Target"/> - <menu_item_check label="Düşük Grafik Özellikli Avatar Kapsamını Göster" name="Show Impostor Extents"/> <menu_item_call label="Aksesuarların Dökümünü Al" name="Dump Attachments"/> <menu_item_call label="Avatar Dokuları İçin Hata Ayıklama" name="Debug Avatar Textures"/> <menu_item_call label="Yerel Dokuların Dökümünü Al" name="Dump Local Textures"/> diff --git a/indra/newview/skins/default/xui/tr/notifications.xml b/indra/newview/skins/default/xui/tr/notifications.xml index d72d89f1f5..7651e4078b 100644 --- a/indra/newview/skins/default/xui/tr/notifications.xml +++ b/indra/newview/skins/default/xui/tr/notifications.xml @@ -1873,7 +1873,7 @@ Binlerce bölgeyi değiştirecek ve alan sunucusunu kesintiye uğratacaktır. <usetemplate canceltext="İptal" name="yesnocancelbuttons" notext="Tüm Gayrimenkuller" yestext="Bu Gayrimenkul"/> </notification> <notification label="Gayrimenkul seç" name="EstateBannedAgentRemove"> - Bu Sakin sadece bu gayrimenkul için mi yasaklı listesinden çıkarılsın, yoksa [ALL_ESTATES] için mi? + Bu Sakin sadece bu gayrimenkul için mi yoksa [ALL_ESTATES] için mi erişim yasağı listesinden çıkarılsın? <usetemplate canceltext="İptal" name="yesnocancelbuttons" notext="Tüm Gayrimenkuller" yestext="Bu Gayrimenkul"/> </notification> <notification label="Gayrimenkul seç" name="EstateManagerAdd"> @@ -1920,6 +1920,10 @@ Binlerce bölgeyi değiştirecek ve alan sunucusunu kesintiye uğratacaktır. Bu seçeneğin onay işaretini kaldırmak, parsel sahiplerinin rahatsızlık veren oyuncuları bunu yapmasını engellemek, gizliliği sürdürmek ve yaşı tutmayan sakinleri yetişkin içeriklerden korumak için ekledikleri kısıtlamaları kaldırabilir. Lütfen gerekli olduğunda parsel sahiplerinizle tartışın. <usetemplate name="okbutton" yestext="Tamam"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + Bu seçeneğin onay işaretinin kaldırılması, parsel sahiplerinin kendi parsellerine eklemiş oldukları tüm özel ortamları kaldırabilir. Lütfen gerektiğinde parsel sahiplerinizle tartışın. + <usetemplate name="okbutton" yestext="Tamam"/> + </notification> <notification name="RegionEntryAccessBlocked"> Ziyaret etmeye çalıştığınız bölge, mevcut tercihlerinizi aşan içeriğe sahip. Ben > Tercihler > Genel sekmesini kullanarak tercihlerinizi değiştirebilirsiniz. <usetemplate name="okbutton" yestext="Tamam"/> @@ -4342,4 +4346,40 @@ Daha küçük bir arazi parçası seçmeyi deneyin. [REASON] <usetemplate name="okbutton" yestext="Tamam"/> </notification> + <notification name="FailedToFindSettings"> + [NAME] ile ilgili ayarlar veritabanından yüklenemedi. + </notification> + <notification name="FailedToLoadSettingsApply"> + Bu değişiklikler ortama uygulanamıyor. + </notification> + <notification name="FailedToBuildSettingsDay"> + Bu değişiklikler ortama uygulanamıyor. + </notification> + <notification name="NoEnvironmentSettings"> + Bu Bölge ortam ayarlarını desteklemiyor. + </notification> + <notification name="WLImportFail"> + Eski Windlight ayarları [FILE] dosyasından içeri aktarılamıyor. + </notification> + <notification name="WLParcelApplyFail"> + Bu parsele ait ortam ayarlanamıyor. +Lütfen değişiklik yapma hakkına sahip olduğunuz bir parsel girin veya seçin. + </notification> + <notification name="SettingsUnsuported"> + Ayarlar bu bölgede desteklenmiyor. +Lütfen ayarların etkin olduğu bir bölgeye gidin ve eyleminizi yeniden deneyin. + </notification> + <notification name="SettingsConfirmLoss"> + "[NAME]" adlı bu [TYPE] öğesinde yaptığınız değişiklikleri kaybetmek üzeresiniz. +Devam etmek istediğinizden emin misiniz? + <usetemplate ignoretext="Değişiklikleri kaybetmek istediğinizden emin misiniz?" name="okcancelignore" notext="Hayır" yestext="Evet"/> + </notification> + <notification name="SettingsMakeNoTrans"> + Aktarılamayan ayarları bu gün döngüsüne aktarmak üzeresiniz. Bu işleme devam etmeniz düzenlemekte olduğunuz ayarların da aktarılamaz olmasına neden olacaktır. + +Bu değişiklik geri alınamaz. + +Devam etmek istediğinizden emin misiniz? + <usetemplate ignoretext="Ayarları aktarılamaz hale getirmek istediğinizden emin misiniz?" name="okcancelignore" notext="Hayır" yestext="Evet"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/tr/panel_region_environment.xml b/indra/newview/skins/default/xui/tr/panel_region_environment.xml index b5f505f25f..af409a424d 100644 --- a/indra/newview/skins/default/xui/tr/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/tr/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="Ortam" name="panel_env_info"> - <text name="water_settings_title"> - Bölgenize gelen tüm ziyaretçilerin görmesini istediğiniz Su ve Gökyüzü/Gündüz Döngüsü Ayarlarını seçin. Ek bilgi - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="Second Life varsayılanını kullan" name="use_sl_default_settings"/> - <radio_item label="Aşağıdaki ayarları kullan" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - Su Ayarı - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-Bir ön ayar seçin-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - Gökyüzü / Gün Döngüsü - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="Sabit gökyüzü" name="my_sky_settings"/> - <radio_item label="Gün döngüsü" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-Bir ön ayar seçin-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-Bir ön ayar seçin-" name="item0"/> - </combo_box> - </panel> - <button label="Uygula" name="apply_btn"/> - <button label="İptal Et" name="cancel_btn"/> + <string name="str_label_use_default"> + Varsayılan Ayarları Kullan + </string> + <string name="str_label_use_region"> + Bölge Ayarlarını Kullan + </string> + <string name="str_unknow_inventory"> + Bilinmiyor + </string> + <string name="str_altitude_desription"> + Gökyüzü [INDEX]([ALTITUDE] m) + </string> + <string name="str_no_parcel"> + Parsel seçilmedi. Ortam ayarları devre dışı. + </string> + <string name="str_cross_region"> + Ortam ayarları bölge sınırları dahilinde kullanılamıyor. + </string> + <string name="str_legacy"> + Ortam ayarları bu bölgede kullanılamıyor. + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="Envanterden Gelen Ayarlar" name="rdo_use_inv_setting"/> + <radio_item label="Özel Ortam" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + Bilinmiyor + </line_editor> + <button label="Ortamı Düzenle" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] (% [PRC]) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + Zemin + </text> + <text name="alt1"> + Gökyüzü [INDEX]([ALTITUDE] m) + </text> + <text name="alt2"> + Gökyüzü [INDEX]([ALTITUDE] m) + </text> + <text name="alt3"> + Gökyüzü [INDEX]([ALTITUDE] m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="Parsel Sahipleri Ortamı Geçersiz Kılabilir" name="chk_allow_override"/> + <button label="Uygula" name="btn_apply"/> + <button label="Sıfırla" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/tr/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/tr/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..9bc23a5507 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Atmosfer ve Aydınlatma" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/tr/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/tr/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..5dd31546cd --- /dev/null +++ b/indra/newview/skins/default/xui/tr/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Bulutlar" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/tr/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/tr/panel_settings_sky_density.xml new file mode 100644 index 0000000000..1d2aa30921 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Yoğunluk" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Rayleigh Üstel Terim:" name="rayleigh_exponential"/> + <slider label="Rayleigh Üstel Skala:" name="rayleigh_exponential_scale"/> + <slider label="Rayleigh Lineer Terim:" name="rayleigh_linear"/> + <slider label="Rayleigh Sabit Terim:" name="rayleigh_constant"/> + <slider label="Rayleigh Maks. İrtifa:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Mie Üstel Terim:" name="mie_exponential"/> + <slider label="Mie Üstel Skala:" name="mie_exponential_scale"/> + <slider label="Mie Lineer Terim:" name="mie_linear"/> + <slider label="Mie Sabit Terim:" name="mie_constant"/> + <slider label="Mie Anizotropi Faktörü:" name="mie_aniso_factor"/> + <slider label="Mie Maks. İrtifa:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Absorpsiyon Üstel Terim:" name="absorption_exponential"/> + <slider label="Absorpsiyon Üstel Skala:" name="absorption_exponential_scale"/> + <slider label="Absorpsiyon Lineer Terim:" name="absorption_linear"/> + <slider label="Absorpsiyon Sabit Terim:" name="absorption_constant"/> + <slider label="Absorpsiyon Maks. İrtifa:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/tr/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/tr/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..bcd7cd077f --- /dev/null +++ b/indra/newview/skins/default/xui/tr/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Güneş ve Ay" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/tr/panel_settings_water.xml b/indra/newview/skins/default/xui/tr/panel_settings_water.xml new file mode 100644 index 0000000000..9537a2b494 --- /dev/null +++ b/indra/newview/skins/default/xui/tr/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="Su" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + Fresnel Dengeleme: + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X:" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/tr/strings.xml b/indra/newview/skins/default/xui/tr/strings.xml index b574420793..16bad98bc4 100644 --- a/indra/newview/skins/default/xui/tr/strings.xml +++ b/indra/newview/skins/default/xui/tr/strings.xml @@ -636,6 +636,15 @@ Lütfen bir dakika içerisinde tekrar oturum açmayı deneyin. <string name="BUTTON_HELP"> Yardımı Göster </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + Bu türe ait öğeler bu bölgedeki +not kartlarına eklenemez. + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + Sadece kısıtlamasız 'sonraki sahip' +izinlerini içeren öğeler not +kartlarına eklenebilir. + </string> <string name="Searching"> Arıyor... </string> @@ -784,6 +793,9 @@ http://secondlife.com/support adresini ziyaret edin. <string name="symbolic link"> bağlantı </string> + <string name="settings blob"> + ayarlar + </string> <string name="symbolic folder link"> klasör bağlantısı </string> @@ -2487,6 +2499,9 @@ Bu mesaj size gelmeye devam ederse lütfen http://support.secondlife.com adresin <string name="RegionSettings"> Bölge Ayarları </string> + <string name="NoEnvironmentSettings"> + Bu Bölge ortam ayarlarını desteklemiyor. + </string> <string name="ClassifiedClicksTxt"> Tıklamalar: [TELEPORT] ışınlama, [MAP] harita, [PROFILE] profil </string> @@ -4827,6 +4842,15 @@ Bu iletiyi almaya devam ederseniz, lütfen [SUPPORT_SITE] bölümüne başvurun. <string name="Female - Wow"> Kadın - Vay be </string> + <string name="New Daycycle"> + Yeni Gün döngüsü + </string> + <string name="New Water"> + Yeni Su + </string> + <string name="New Sky"> + Yeni Gökyüzü + </string> <string name="/bow"> /selamlama </string> diff --git a/indra/newview/skins/default/xui/zh/floater_about_land.xml b/indra/newview/skins/default/xui/zh/floater_about_land.xml index badd00bc6d..cf6dd11b98 100644 --- a/indra/newview/skins/default/xui/zh/floater_about_land.xml +++ b/indra/newview/skins/default/xui/zh/floater_about_land.xml @@ -462,5 +462,6 @@ </panel> </panel> <panel label="體驗" name="land_experiences_panel"/> + <panel label="環境" name="land_environment_panel"/> </tab_container> </floater> diff --git a/indra/newview/skins/default/xui/zh/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/zh/floater_delete_env_preset.xml deleted file mode 100644 index 4aafb31952..0000000000 --- a/indra/newview/skins/default/xui/zh/floater_delete_env_preset.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<floater name="Delete Env Preset" title="刪除環境自訂配置"> - <string name="title_water"> - 刪除水的自訂配置 - </string> - <string name="title_sky"> - 刪除天空自訂配置 - </string> - <string name="title_day_cycle"> - 刪除日循環 - </string> - <string name="label_water"> - 自訂配置: - </string> - <string name="label_sky"> - 自訂配置: - </string> - <string name="label_day_cycle"> - 日循環: - </string> - <string name="msg_confirm_deletion"> - 確定要刪除所選自訂配置? - </string> - <string name="msg_sky_is_referenced"> - 無法刪除日循環有所指涉的自訂配置。 - </string> - <string name="combo_label"> - -選擇一個自訂配置- - </string> - <text name="label"> - 自訂配置: - </text> - <button label="刪除" name="delete"/> - <button label="取消" name="cancel"/> -</floater> diff --git a/indra/newview/skins/default/xui/zh/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/zh/floater_edit_ext_day_cycle.xml new file mode 100644 index 0000000000..2b2f7757eb --- /dev/null +++ b/indra/newview/skins/default/xui/zh/floater_edit_ext_day_cycle.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="env_edit_extdaycycle" title="編輯日循環"> + <string name="title_new"> + 新建一個日循環 + </string> + <string name="title_edit"> + 編輯日循環 + </string> + <string name="hint_new"> + 為日循環定名,調整各項控制確定細節,再點按「儲存」。 + </string> + <string name="hint_edit"> + 若要編輯你的日循環,請調整下方各項控制,再點按「儲存」。 + </string> + <string name="time_label"> + ([HH]:[MM]) + </string> + <string name="sky_track_label"> + 天空[ALT] + </string> + <layout_stack name="outer_stack"> + <layout_panel name="name_and_import"> + <text name="label"> + 日循環名稱: + </text> + <button label="匯入" name="btn_import" tool_tip="從磁碟匯入舊設定。"/> + </layout_panel> + <layout_panel name="content"> + <layout_stack name="content_stack"> + <layout_panel name="timeline_track_selection"> + <panel name="timeline_layers"> + <button label="天空 4" name="sky4_track"/> + <button label="天空 3" name="sky3_track"/> + <button label="天空 2" name="sky2_track"/> + <button label="地面水平" name="sky1_track"/> + <button label="水文" name="water_track"/> + </panel> + <panel name="timeline"> + <text name="p0" value="0%[DSC]"/> + <text name="p1" value="25%[DSC]"/> + <text name="p2" value="50%[DSC]"/> + <text name="p3" value="75%[DSC]"/> + <text name="p4" value="100%[DSC]"/> + <multi_slider initial_value="0" name="WLTimeSlider"/> + <multi_slider initial_value="0" name="WLDayCycleFrames"/> + <text name="current_time" value="[PRCNT]%[DSC]"/> + <layout_stack name="progress_control"> + <layout_panel name="skip_back"> + <button name="skip_back_btn" tool_tip="倒轉"/> + </layout_panel> + <layout_panel name="skip_forward"> + <button name="skip_forward_btn" tool_tip="快轉"/> + </layout_panel> + </layout_stack> + <button label="新增幀" name="add_frame"/> + <button label="載入幀" name="btn_load_frame"/> + <button label="刪除幀" name="delete_frame"/> + </panel> + </layout_panel> + <layout_panel name="frame_edit_controls"> + <text name="icn_lock_edit"> + 從上方的時間線選擇一個關鍵幀以編輯設定。 + </text> + </layout_panel> + <layout_panel name="frame_settings_water"> + <tab_container name="water_tabs"> + <panel label="水文" name="water_panel"/> + </tab_container> + </layout_panel> + <layout_panel name="frame_settings_sky"> + <tab_container name="sky_tabs"> + <panel label="大氣與照明" name="atmosphere_panel"/> + <panel label="雲彩" name="clouds_panel"/> + <panel label="日與月" name="moon_panel"/> + </tab_container> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="buttons"> + <button label="儲存" name="save_btn"/> + <button label="取消" name="cancel_btn"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/zh/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/zh/floater_fixedenvironment.xml new file mode 100644 index 0000000000..9246cbfd27 --- /dev/null +++ b/indra/newview/skins/default/xui/zh/floater_fixedenvironment.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="Fixed Environment" title="固定環境"> + <string name="edit_sky"> + 編輯天空: + </string> + <string name="edit_water"> + 編輯水文: + </string> + <layout_stack name="floater_stack"> + <layout_panel name="info_panel"> + <button label="載入" name="btn_load" tool_tip="從收納區載入設定"/> + <button label="匯入" name="btn_import" tool_tip="從磁碟匯入舊設定。"/> + </layout_panel> + <layout_panel name="button_panel"> + <layout_stack name="button_bar_ls"> + <layout_panel name="save_btn_lp"> + <button label="儲存" name="btn_commit"/> + </layout_panel> + <layout_panel name="revert_btn_lp"> + <button label="取消" name="btn_cancel" tool_tip="恢復上一個已儲存版本"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/zh/floater_inventory_view_finder.xml b/indra/newview/skins/default/xui/zh/floater_inventory_view_finder.xml index 9001615d89..ae05396cc5 100644 --- a/indra/newview/skins/default/xui/zh/floater_inventory_view_finder.xml +++ b/indra/newview/skins/default/xui/zh/floater_inventory_view_finder.xml @@ -12,6 +12,7 @@ <check_box label="聲音" name="check_sound"/> <check_box label="材質" name="check_texture"/> <check_box label="快照" name="check_snapshot"/> + <check_box label="設定" name="check_settings"/> <button label="全部" label_selected="全部" name="All"/> <button label="無" label_selected="無" name="None"/> <check_box label="固定顯示資料夾" name="check_show_empty"/> diff --git a/indra/newview/skins/default/xui/zh/floater_my_environments.xml b/indra/newview/skins/default/xui/zh/floater_my_environments.xml new file mode 100644 index 0000000000..be33d456da --- /dev/null +++ b/indra/newview/skins/default/xui/zh/floater_my_environments.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater label="地點" name="my_environments" title="我的環境"> + <layout_stack> + <layout_panel label="過濾器" name="filter_panel"> + <check_box label="日" name="chk_days"/> + <check_box label="天空" name="chk_skies"/> + <check_box label="水文" name="chk_water"/> + </layout_panel> + <layout_panel label="環境" name="list_panel"> + <check_box initial_value="false" label="顯示空資料夾" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="pnl_control"> + <panel label="bottom_panel" name="pnl_bottom"> + <menu_button name="btn_gear" tool_tip="更多選項"/> + <menu_button name="btn_newsettings" tool_tip="製作新的設定"/> + <button name="btn_del" tool_tip="刪除這個設定"/> + </panel> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/zh/floater_settings_picker.xml b/indra/newview/skins/default/xui/zh/floater_settings_picker.xml new file mode 100644 index 0000000000..dba6034b5a --- /dev/null +++ b/indra/newview/skins/default/xui/zh/floater_settings_picker.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater name="settings picker" title="選擇:設定"> + <floater.string name="choose_picture"> + 點按以挑選圖片 + </floater.string> + <floater.string name="pick title"> + 精選地點: + </floater.string> + <layout_stack name="test_stack"> + <layout_panel name="temp"> + <filter_editor label="材質過濾器" name="flt_inventory_search"/> + <check_box initial_value="false" label="顯示資料夾" name="chk_showfolders"/> + </layout_panel> + <layout_panel name="temp"> + <button label="確定" label_selected="確定" name="btn_select"/> + <button label="取消" label_selected="取消" name="btn_cancel"/> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/zh/menu_inventory.xml b/indra/newview/skins/default/xui/zh/menu_inventory.xml index 2ed078841e..4db6b4512d 100644 --- a/indra/newview/skins/default/xui/zh/menu_inventory.xml +++ b/indra/newview/skins/default/xui/zh/menu_inventory.xml @@ -10,7 +10,6 @@ <menu_item_call label="啟用" name="Marketplace Activate"/> <menu_item_call label="停用" name="Marketplace Deactivate"/> <menu_item_call label="分享" name="Share"/> - <menu_item_call label="購買" name="Task Buy"/> <menu_item_call label="打開" name="Task Open"/> <menu_item_call label="播放" name="Task Play"/> <menu_item_call label="屬性" name="Task Properties"/> @@ -42,6 +41,11 @@ <menu_item_call label="新頭髮" name="New Hair"/> <menu_item_call label="新眼睛" name="New Eyes"/> </menu> + <menu label="新的設定" name="New Settings"> + <menu_item_call label="新的天空" name="New Sky"/> + <menu_item_call label="新的水文" name="New Water"/> + <menu_item_call label="新的日循環" name="New Day Cycle"/> + </menu> <menu label="作這一用途的預設值:" name="upload_def"> <menu_item_call label="圖像上傳" name="Image uploads"/> <menu_item_call label="聲音上傳" name="Sound uploads"/> @@ -103,6 +107,9 @@ <menu_item_call label="編輯" name="Wearable Edit"/> <menu_item_call label="添加" name="Wearable Add"/> <menu_item_call label="脫下" name="Take Off"/> + <menu_item_call label="僅套用到我自己" name="Settings Apply Local"/> + <menu_item_call label="套用到地段" name="Settings Apply Parcel"/> + <menu_item_call label="套用到地區" name="Settings Apply Region"/> <menu_item_call label="複製到 Marketplace 刊登" name="Marketplace Copy"/> <menu_item_call label="移到 Marketplace 刊登" name="Marketplace Move"/> <menu_item_call label="-- 無選項 --" name="--no options--"/> diff --git a/indra/newview/skins/default/xui/zh/menu_inventory_add.xml b/indra/newview/skins/default/xui/zh/menu_inventory_add.xml index 30bf5a7e75..013ac094b4 100644 --- a/indra/newview/skins/default/xui/zh/menu_inventory_add.xml +++ b/indra/newview/skins/default/xui/zh/menu_inventory_add.xml @@ -5,9 +5,7 @@ <menu_item_call label="聲音(L$[COST])..." name="Upload Sound"/> <menu_item_call label="動作(L$[COST])..." name="Upload Animation"/> <menu_item_call label="模型…" name="Upload Model"/> - <menu_item_call label="模型精靈…" name="Upload Model Wizard"/> <menu_item_call label="批量(每檔案 L$[COST] )..." name="Bulk Upload"/> - <menu_item_call label="設定預設上傳權限" name="perm prefs"/> </menu> <menu_item_call label="新資料夾" name="New Folder"/> <menu_item_call label="新腳本" name="New Script"/> @@ -33,4 +31,9 @@ <menu_item_call label="新頭髮" name="New Hair"/> <menu_item_call label="新眼睛" name="New Eyes"/> </menu> + <menu label="新的設定" name="New Settings"> + <menu_item_call label="新的天空" name="New Sky"/> + <menu_item_call label="新的水文" name="New Water"/> + <menu_item_call label="新的日循環" name="New Day Cycle"/> + </menu> </menu> diff --git a/indra/newview/skins/default/xui/zh/menu_save_settings.xml b/indra/newview/skins/default/xui/zh/menu_save_settings.xml new file mode 100644 index 0000000000..9a70f38115 --- /dev/null +++ b/indra/newview/skins/default/xui/zh/menu_save_settings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="save_settings_menu"> + <menu_item_check label="儲存" name="save_settings"/> + <menu_item_check label="另存為" name="save_as_new_settings"/> + <menu_item_check label="確定套用" name="commit_changes"/> + <menu_item_check label="僅套用到我自己" name="apply_local"/> + <menu_item_check label="套用到地段" name="apply_parcel"/> + <menu_item_check label="套用到地區" name="apply_region"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/zh/menu_settings_add.xml b/indra/newview/skins/default/xui/zh/menu_settings_add.xml new file mode 100644 index 0000000000..4e11741241 --- /dev/null +++ b/indra/newview/skins/default/xui/zh/menu_settings_add.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_add"> + <menu_item_call label="新的天空" name="New Sky"/> + <menu_item_call label="新的水文" name="New Water"/> + <menu_item_call label="新的日循環" name="New Day Cycle"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/zh/menu_settings_gear.xml b/indra/newview/skins/default/xui/zh/menu_settings_gear.xml new file mode 100644 index 0000000000..342f9d50b4 --- /dev/null +++ b/indra/newview/skins/default/xui/zh/menu_settings_gear.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<toggleable_menu name="menu_settings_gear"> + <menu_item_call label="編輯" name="edit_settings"/> + <menu_item_call label="僅套用到我自己" name="Settings Apply Local"/> + <menu_item_call label="套用到地段" name="Settings Apply Parcel"/> + <menu_item_call label="套用到地區" name="Settings Apply Region"/> + <menu_item_call label="複製" name="copy_settings"/> + <menu_item_call label="貼上" name="paste_settings"/> + <menu_item_call label="覆製 UUID" name="copy_uuid"/> +</toggleable_menu> diff --git a/indra/newview/skins/default/xui/zh/menu_viewer.xml b/indra/newview/skins/default/xui/zh/menu_viewer.xml index a8ac7cbf0e..39d4a7c4f7 100644 --- a/indra/newview/skins/default/xui/zh/menu_viewer.xml +++ b/indra/newview/skins/default/xui/zh/menu_viewer.xml @@ -75,30 +75,14 @@ <menu_item_check label="地段屬性" name="Parcel Properties"/> <menu_item_check label="進階選單" name="Show Advanced Menu"/> </menu> - <menu label="太陽" name="Sun"> + <menu label="環境" name="Environment"> <menu_item_check label="日出" name="Sunrise"/> <menu_item_check label="中午" name="Noon"/> <menu_item_check label="日落" name="Sunset"/> <menu_item_check label="午夜" name="Midnight"/> - <menu_item_check label="使用地區設定" name="Use Region Settings"/> - </menu> - <menu label="環境編輯器" name="Environment Editor"> - <menu_item_call label="環境設定…" name="Environment Settings"/> - <menu label="水的自訂配置" name="Water Presets"> - <menu_item_call label="新的自訂配置…" name="new_water_preset"/> - <menu_item_call label="編輯自訂配置…" name="edit_water_preset"/> - <menu_item_call label="刪除自訂配置…" name="delete_water_preset"/> - </menu> - <menu label="天空自訂配置" name="Sky Presets"> - <menu_item_call label="新的自訂配置…" name="new_sky_preset"/> - <menu_item_call label="編輯自訂配置…" name="edit_sky_preset"/> - <menu_item_call label="刪除自訂配置…" name="delete_sky_preset"/> - </menu> - <menu label="日的自訂配置" name="Day Presets"> - <menu_item_call label="新的自訂配置…" name="new_day_preset"/> - <menu_item_call label="編輯自訂配置…" name="edit_day_preset"/> - <menu_item_call label="刪除自訂配置…" name="delete_day_preset"/> - </menu> + <menu_item_check label="使用共享環境" name="Use Shared Environment"/> + <menu_item_call label="我的環境…" name="my_environs"/> + <menu_item_check label="暫停雲彩" name="pause_clouds"/> </menu> </menu> <menu label="建造" name="BuildTools"> diff --git a/indra/newview/skins/default/xui/zh/notifications.xml b/indra/newview/skins/default/xui/zh/notifications.xml index 9fe7b5acae..186a850a15 100644 --- a/indra/newview/skins/default/xui/zh/notifications.xml +++ b/indra/newview/skins/default/xui/zh/notifications.xml @@ -1916,6 +1916,10 @@ SHA1 指紋:[MD5_DIGEST] 若不勾選這選項,可能會移除地段所有人為防止惡意騷擾及為維護隱私、保護幼未成年居民不接觸成年限制級內容的限制措施。 若有必要請與地段所有人溝通。 <usetemplate name="okbutton" yestext="確定"/> </notification> + <notification name="EstateParcelEnvironmentOverride"> + 取消勾選這選項,可能會移除地段所有人之前新增到地段的任何自定環境。 若有必要請與地段所有人溝通。 + <usetemplate name="okbutton" yestext="確定"/> + </notification> <notification name="RegionEntryAccessBlocked"> 你所欲前往的地區含有超過你目前偏好的分級的內容。 你可以到「我自己 > 偏好設定 > 一般設定」變更你的偏好設定。 <usetemplate name="okbutton" yestext="確定"/> @@ -4342,4 +4346,40 @@ SHA1 指紋:[MD5_DIGEST] [REASON] <usetemplate name="okbutton" yestext="確定"/> </notification> + <notification name="FailedToFindSettings"> + 無法從資料庫載入[NAME]的設定。 + </notification> + <notification name="FailedToLoadSettingsApply"> + 無法將設定套用到環境。 + </notification> + <notification name="FailedToBuildSettingsDay"> + 無法將設定套用到環境。 + </notification> + <notification name="NoEnvironmentSettings"> + 這區域不支援環境設定。 + </notification> + <notification name="WLImportFail"> + 無法從[FILE]匯入舊的風光(Windlight)設定。 + </notification> + <notification name="WLParcelApplyFail"> + 無法設定此地段的環境。 +請輸入或選擇一個你有權修改的地段。 + </notification> + <notification name="SettingsUnsuported"> + 這地區不支援設定。 +請移位到支援設定的地區,再試一次。 + </notification> + <notification name="SettingsConfirmLoss"> + 你即將針對名爲"[NAME]"的[TYPE]放棄變更。 +確定繼續? + <usetemplate ignoretext="確定放棄變更?" name="okcancelignore" notext="否" yestext="是"/> + </notification> + <notification name="SettingsMakeNoTrans"> + 你即將把無法轉移的設定匯入這個日循環。 如果繼續,將使得你正在編輯的設定也變成無法轉移。 + +這個改變無法取消復原。 + +確定繼續? + <usetemplate ignoretext="確定要把設定變成無法轉移?" name="okcancelignore" notext="否" yestext="是"/> + </notification> </notifications> diff --git a/indra/newview/skins/default/xui/zh/panel_region_environment.xml b/indra/newview/skins/default/xui/zh/panel_region_environment.xml index afea391dda..16f9dc83a0 100644 --- a/indra/newview/skins/default/xui/zh/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/zh/panel_region_environment.xml @@ -1,33 +1,77 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <panel label="環境" name="panel_env_info"> - <text name="water_settings_title"> - 選擇你希望到你地區的訪客所能看到的水和天空 / 日循環設定。 詳情 - </text> - <radio_group name="region_settings_radio_group"> - <radio_item label="使用第二人生預設值" name="use_sl_default_settings"/> - <radio_item label="使用以下設定" name="use_my_settings"/> - </radio_group> - <panel name="user_environment_settings"> - <text name="water_settings_title"> - 水的設定 - </text> - <combo_box name="water_settings_preset_combo"> - <combo_box.item label="-選擇一個自訂配置-" name="item0"/> - </combo_box> - <text name="sky_dayc_settings_title"> - 天空/日循環 - </text> - <radio_group name="sky_dayc_settings_radio_group"> - <radio_item label="固定天空" name="my_sky_settings"/> - <radio_item label="日循環" name="my_dayc_settings"/> - </radio_group> - <combo_box name="sky_settings_preset_combo"> - <combo_box.item label="-選擇一個自訂配置-" name="item0"/> - </combo_box> - <combo_box name="dayc_settings_preset_combo"> - <combo_box.item label="-選擇一個自訂配置-" name="item0"/> - </combo_box> - </panel> - <button label="套用" name="apply_btn"/> - <button label="取消" name="cancel_btn"/> + <string name="str_label_use_default"> + 使用預設設定 + </string> + <string name="str_label_use_region"> + 使用地區設定 + </string> + <string name="str_unknow_inventory"> + 未知 + </string> + <string name="str_altitude_desription"> + 天空 [INDEX]([ALTITUDE]m) + </string> + <string name="str_no_parcel"> + 未選擇地段。 環境設定已停用。 + </string> + <string name="str_cross_region"> + 跨越地區不提供環境設定。 + </string> + <string name="str_legacy"> + 這地區不提供環境設定。 + </string> + <layout_stack> + <layout_panel name="pnl_environment_disabled"> + <text name="txt_environment_disabled"> + ... + </text> + </layout_panel> + <layout_panel name="pnl_environment_config"> + <layout_stack> + <layout_panel name="pnl_environment_current"> + <radio_group name="rdg_environment_select"> + <radio_item label="[USEDEFAULT]" name="rdo_use_xxx_setting"/> + <radio_item label="來自收納區的設定" name="rdo_use_inv_setting"/> + <radio_item label="自定環境" name="rdo_use_custom_setting"/> + </radio_group> + <line_editor name="edt_inventory_name"> + 未知 + </line_editor> + <button label="編輯環境" name="btn_edit"/> + </layout_panel> + <layout_panel name="pnl_environment_length"> + <text name="lbl_apparent_time"> + [HH]:[MM][AP] ([PRC]%) + </text> + </layout_panel> + </layout_stack> + </layout_panel> + <layout_panel name="pnl_environment_altitudes"> + <panel name="cnt_panel"> + <multi_slider initial_value="100" name="sld_altitudes"> + <slider name="sld1" value="200"/> + <slider name="sld2" value="400"/> + <slider name="sld3" value="600"/> + </multi_slider> + <text name="ground"> + 地面 + </text> + <text name="alt1"> + 天空 [INDEX]([ALTITUDE]m) + </text> + <text name="alt2"> + 天空 [INDEX]([ALTITUDE]m) + </text> + <text name="alt3"> + 天空 [INDEX]([ALTITUDE]m) + </text> + </panel> + </layout_panel> + <layout_panel name="pnl_environment_buttons"> + <check_box label="地段所有人可強制設定環境" name="chk_allow_override"/> + <button label="套用" name="btn_apply"/> + <button label="重設" name="btn_cancel"/> + </layout_panel> + </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/zh/panel_region_estate.xml b/indra/newview/skins/default/xui/zh/panel_region_estate.xml index 3825e7ab23..4be4f0aac1 100644 --- a/indra/newview/skins/default/xui/zh/panel_region_estate.xml +++ b/indra/newview/skins/default/xui/zh/panel_region_estate.xml @@ -29,22 +29,22 @@ 領地管理員: </text> <text name="allow_resident_label"> - 永遠允許: + 永遠准許: </text> - <button label="添加..." name="add_estate_manager_btn"/> - <button label="移除..." name="remove_estate_manager_btn"/> - <button label="添加..." name="add_allowed_avatar_btn"/> - <button label="移除..." name="remove_allowed_avatar_btn"/> + <button label="新增…" name="add_estate_manager_btn"/> + <button label="移除…" name="remove_estate_manager_btn"/> + <button label="新增…" name="add_allowed_avatar_btn"/> + <button label="移除…" name="remove_allowed_avatar_btn"/> <text name="allow_group_label"> - 永遠允許的群組: + 永遠准許的群組: </text> <text name="ban_resident_label"> - 永遠封鎖: + 永遠禁入: </text> - <button label="添加..." name="add_allowed_group_btn"/> - <button label="移除..." name="remove_allowed_group_btn"/> - <button label="添加..." name="add_banned_avatar_btn"/> - <button label="移除..." name="remove_banned_avatar_btn"/> + <button label="新增…" name="add_allowed_group_btn"/> + <button label="移除…" name="remove_allowed_group_btn"/> + <button label="新增…" name="add_banned_avatar_btn"/> + <button label="移除…" name="remove_banned_avatar_btn"/> <button label="送出訊息到領地..." name="message_estate_btn"/> <button label="由領地將居民踢出..." name="kick_user_from_estate_btn"/> </panel> diff --git a/indra/newview/skins/default/xui/zh/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/zh/panel_settings_sky_atmos.xml new file mode 100644 index 0000000000..a352055d6d --- /dev/null +++ b/indra/newview/skins/default/xui/zh/panel_settings_sky_atmos.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="大氣與照明" name="panel_settings_sky_atmos"/> diff --git a/indra/newview/skins/default/xui/zh/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/zh/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..e27e2278df --- /dev/null +++ b/indra/newview/skins/default/xui/zh/panel_settings_sky_clouds.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="雲彩" name="panel_settings_sky_clouds"> + <layout_stack> + <layout_panel> + <slider label="X" name="cloud_density_x"/> + <slider label="Y" name="cloud_density_y"/> + <slider label="D" name="cloud_density_d"/> + <slider label="X" name="cloud_detail_x"/> + <slider label="Y" name="cloud_detail_y"/> + <slider label="D" name="cloud_detail_d"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/zh/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/zh/panel_settings_sky_density.xml new file mode 100644 index 0000000000..4b043ccaa2 --- /dev/null +++ b/indra/newview/skins/default/xui/zh/panel_settings_sky_density.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="密度" name="panel_settings_sky_density"> + <layout_stack> + <layout_panel> + <slider label="Rayleigh指數函數項:" name="rayleigh_exponential"/> + <slider label="Rayleigh指數函數比例:" name="rayleigh_exponential_scale"/> + <slider label="Rayleigh線性項:" name="rayleigh_linear"/> + <slider label="Rayleigh常數項:" name="rayleigh_constant"/> + <slider label="Rayleigh最大高度:" name="rayleigh_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="Mie指數函數項:" name="mie_exponential"/> + <slider label="Mie指數函數比例:" name="mie_exponential_scale"/> + <slider label="Mie線性項:" name="mie_linear"/> + <slider label="Mie常數項:" name="mie_constant"/> + <slider label="Mie異性因子:" name="mie_aniso_factor"/> + <slider label="Mie最大高度:" name="mie_max_altitude"/> + </layout_panel> + <layout_panel> + <slider label="吸收指數函數項:" name="absorption_exponential"/> + <slider label="吸收指數函數比例:" name="absorption_exponential_scale"/> + <slider label="吸收線性項:" name="absorption_linear"/> + <slider label="吸收常數項:" name="absorption_constant"/> + <slider label="吸收最大高度:" name="absorption_max_altitude"/> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/zh/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/zh/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..594f7e89d1 --- /dev/null +++ b/indra/newview/skins/default/xui/zh/panel_settings_sky_sunmoon.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="日與月" name="panel_settings_sky_hbodies"/> diff --git a/indra/newview/skins/default/xui/zh/panel_settings_water.xml b/indra/newview/skins/default/xui/zh/panel_settings_water.xml new file mode 100644 index 0000000000..59687c001b --- /dev/null +++ b/indra/newview/skins/default/xui/zh/panel_settings_water.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<panel label="水文" name="panel_settings_water"> + <layout_stack name="water_stack1"> + <layout_panel> + <text name="FresnelOffsetText"> + 菲涅耳偏距: + </text> + </layout_panel> + <layout_panel> + <layout_stack name="water_stack2"> + <layout_panel> + <slider label="X:" name="water_normal_scale_x"/> + <slider label="Y:" name="water_normal_scale_y"/> + <slider label="Z:" name="water_normal_scale_z"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> diff --git a/indra/newview/skins/default/xui/zh/strings.xml b/indra/newview/skins/default/xui/zh/strings.xml index 24d8dc60cb..57da57a82c 100644 --- a/indra/newview/skins/default/xui/zh/strings.xml +++ b/indra/newview/skins/default/xui/zh/strings.xml @@ -632,6 +632,15 @@ http://secondlife.com/viewer-access-faq <string name="BUTTON_HELP"> 顯示幫助 </string> + <string name="TooltipNotecardNotAllowedTypeDrop"> + 這類物項無法附著 +到本地區的記事卡。 + </string> + <string name="TooltipNotecardOwnerRestrictedDrop"> + 只有帶有不受限制的 +「下一個所有人」權限的物件 +才可附著到記事卡。 + </string> <string name="Searching"> 搜尋中... </string> @@ -780,6 +789,9 @@ http://secondlife.com/support 求助解決問題。 <string name="symbolic link"> 聯結 </string> + <string name="settings blob"> + 設定 + </string> <string name="symbolic folder link"> 資料夾聯結 </string> @@ -2483,6 +2495,9 @@ http://secondlife.com/support 求助解決問題。 <string name="RegionSettings"> 地區設定 </string> + <string name="NoEnvironmentSettings"> + 這區域不支援環境設定。 + </string> <string name="ClassifiedClicksTxt"> 點按:[TELEPORT] 瞬間傳送,[MAP] 地圖,[PROFILE] 檔案 </string> @@ -4825,6 +4840,15 @@ http://secondlife.com/support 求助解決問題。 <string name="Female - Wow"> 女性 - 哇塞 </string> + <string name="New Daycycle"> + 新的日循環 + </string> + <string name="New Water"> + 新的水文 + </string> + <string name="New Sky"> + 新的天空 + </string> <string name="/bow"> /彎腰點頭 </string> diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index bb28abead3..fe81fd63ea 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -258,7 +258,7 @@ namespace tut std::string("https://login.aditi.lindenlab.com/cgi-bin/login.cgi")); ensure_equals("Aditi helper uri", LLGridManager::getInstance()->getHelperURI("util.aditi.lindenlab.com"), - std::string("https://secondlife.aditi.lindenlab.com/helpers/")); + std::string("https://secondlife.aditi.lindenlab.com/helpers/")); ensure_equals("Aditi login page", LLGridManager::getInstance()->getLoginPage("util.aditi.lindenlab.com"), std::string("https://viewer-splash.secondlife.com/")); @@ -330,7 +330,7 @@ namespace tut std::string("https://login.aditi.lindenlab.com/cgi-bin/login.cgi")); ensure_equals("Aditi helper uri", LLGridManager::getInstance()->getHelperURI("util.aditi.lindenlab.com"), - std::string("https://secondlife.aditi.lindenlab.com/helpers/")); + std::string("https://secondlife.aditi.lindenlab.com/helpers/")); ensure_equals("Aditi login page", LLGridManager::getInstance()->getLoginPage("util.aditi.lindenlab.com"), std::string("https://viewer-splash.secondlife.com/")); diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index c0f642c852..fcb97ded8f 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -635,7 +635,7 @@ class WindowsManifest(ViewerManifest): self.path("dullahan_host.exe") self.path("natives_blob.bin") self.path("snapshot_blob.bin") - self.path("widevinecdmadapter.dll") + self.path("v8_context_snapshot.bin") # MSVC DLLs needed for CEF and have to be in same directory as plugin with self.prefix(src=os.path.join(self.args['build'], os.pardir, |