diff options
Diffstat (limited to 'indra')
24 files changed, 335 insertions, 438 deletions
diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py index 778de90962..185e8e25c6 100755 --- a/indra/llcorehttp/tests/test_llcorehttp_peer.py +++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py @@ -38,7 +38,6 @@ from io import StringIO from http.server import HTTPServer, BaseHTTPRequestHandler -from llbase.fastest_elementtree import parse as xml_parse from llbase import llsd # we're in llcorehttp/tests ; testrunner.py is found in llmessage/tests diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp index 9034182072..18d704dd0f 100644 --- a/indra/llmath/llcamera.cpp +++ b/indra/llmath/llcamera.cpp @@ -311,104 +311,6 @@ int LLCamera::sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 rad return 0; } -// HACK: This version is still around because the version below doesn't work -// unless the agent planes are initialized. -// Return 1 if sphere is in frustum, 2 if fully in frustum, otherwise 0. -// NOTE: 'center' is in absolute frame. -int LLCamera::sphereInFrustumOld(const LLVector3 &sphere_center, const F32 radius) const -{ - // Returns 1 if sphere is in frustum, 0 if not. - // modified so that default view frust is along X with Z vertical - F32 x, y, z, rightDist, leftDist, topDist, bottomDist; - - // Subtract the view position - //LLVector3 relative_center; - //relative_center = sphere_center - getOrigin(); - LLVector3 rel_center(sphere_center); - rel_center -= mOrigin; - - bool all_in = TRUE; - - // Transform relative_center.x to camera frame - x = mXAxis * rel_center; - if (x < MIN_NEAR_PLANE - radius) - { - return 0; - } - else if (x < MIN_NEAR_PLANE + radius) - { - all_in = FALSE; - } - - if (x > mFarPlane + radius) - { - return 0; - } - else if (x > mFarPlane - radius) - { - all_in = FALSE; - } - - // Transform relative_center.y to camera frame - y = mYAxis * rel_center; - - // distance to plane is the dot product of (x, y, 0) * plane_normal - rightDist = x * mLocalPlanes[PLANE_RIGHT][VX] + y * mLocalPlanes[PLANE_RIGHT][VY]; - if (rightDist < -radius) - { - return 0; - } - else if (rightDist < radius) - { - all_in = FALSE; - } - - leftDist = x * mLocalPlanes[PLANE_LEFT][VX] + y * mLocalPlanes[PLANE_LEFT][VY]; - if (leftDist < -radius) - { - return 0; - } - else if (leftDist < radius) - { - all_in = FALSE; - } - - // Transform relative_center.y to camera frame - z = mZAxis * rel_center; - - topDist = x * mLocalPlanes[PLANE_TOP][VX] + z * mLocalPlanes[PLANE_TOP][VZ]; - if (topDist < -radius) - { - return 0; - } - else if (topDist < radius) - { - all_in = FALSE; - } - - bottomDist = x * mLocalPlanes[PLANE_BOTTOM][VX] + z * mLocalPlanes[PLANE_BOTTOM][VZ]; - if (bottomDist < -radius) - { - return 0; - } - else if (bottomDist < radius) - { - all_in = FALSE; - } - - if (all_in) - { - return 2; - } - - return 1; -} - - -// HACK: This (presumably faster) version only currently works if you set up the -// frustum planes using GL. At some point we should get those planes through another -// mechanism, and then we can get rid of the "old" version above. - // Return 1 if sphere is in frustum, 2 if fully in frustum, otherwise 0. // NOTE: 'center' is in absolute frame. int LLCamera::sphereInFrustum(const LLVector3 &sphere_center, const F32 radius) const @@ -463,65 +365,6 @@ F32 LLCamera::heightInPixels(const LLVector3 ¢er, F32 radius ) const } } -// If pos is visible, return the distance from pos to the camera. -// Use fudge distance to scale rad against top/bot/left/right planes -// Otherwise, return -distance -F32 LLCamera::visibleDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const -{ - if (mFixedDistance > 0) - { - return mFixedDistance; - } - LLVector3 dvec = pos - mOrigin; - // Check visibility - F32 dist = dvec.magVec(); - if (dist > rad) - { - F32 dp,tdist; - dp = dvec * mXAxis; - if (dp < -rad) - return -dist; - - rad *= fudgedist; - LLVector3 tvec(pos); - for (int p=0; p<PLANE_NUM; p++) - { - if (!(planemask & (1<<p))) - continue; - tdist = -(mWorldPlanes[p].dist(tvec)); - if (tdist > rad) - return -dist; - } - } - return dist; -} - -// Like visibleDistance, except uses mHorizPlanes[], which are left and right -// planes perpindicular to (0,0,1) in world space -F32 LLCamera::visibleHorizDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const -{ - if (mFixedDistance > 0) - { - return mFixedDistance; - } - LLVector3 dvec = pos - mOrigin; - // Check visibility - F32 dist = dvec.magVec(); - if (dist > rad) - { - rad *= fudgedist; - LLVector3 tvec(pos); - for (int p=0; p<HORIZ_PLANE_NUM; p++) - { - if (!(planemask & (1<<p))) - continue; - F32 tdist = -(mHorizPlanes[p].dist(tvec)); - if (tdist > rad) - return -dist; - } - } - return dist; -} // ---------------- friends and operators ---------------- @@ -536,18 +379,6 @@ std::ostream& operator<<(std::ostream &s, const LLCamera &C) s << " Aspect = " << C.getAspect() << "\n"; s << " NearPlane = " << C.mNearPlane << "\n"; s << " FarPlane = " << C.mFarPlane << "\n"; - s << " TopPlane = " << C.mLocalPlanes[LLCamera::PLANE_TOP][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_TOP][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_TOP][VZ] << "\n"; - s << " BottomPlane = " << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VZ] << "\n"; - s << " LeftPlane = " << C.mLocalPlanes[LLCamera::PLANE_LEFT][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_LEFT][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_LEFT][VZ] << "\n"; - s << " RightPlane = " << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VZ] << "\n"; s << "}"; return s; } @@ -675,26 +506,6 @@ void LLCamera::calcRegionFrustumPlanes(const LLVector3& shift, F32 far_clip_dist void LLCamera::calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom) { - LLVector3 a, b, c; - - // For each plane we need to define 3 points (LLVector3's) in camera view space. - // The order in which we pass the points to planeFromPoints() matters, because the - // plane normal has a degeneracy of 2; we want it pointing _into_ the frustum. - - a.setVec(0.0f, 0.0f, 0.0f); - b.setVec(mFarPlane, right, top); - c.setVec(mFarPlane, right, bottom); - mLocalPlanes[PLANE_RIGHT].setVec(a, b, c); - - c.setVec(mFarPlane, left, top); - mLocalPlanes[PLANE_TOP].setVec(a, c, b); - - b.setVec(mFarPlane, left, bottom); - mLocalPlanes[PLANE_LEFT].setVec(a, b, c); - - c.setVec(mFarPlane, right, bottom); - mLocalPlanes[PLANE_BOTTOM].setVec( a, c, b); - //calculate center and radius squared of frustum in world absolute coordinates static LLVector3 const X_AXIS(1.f, 0.f, 0.f); mFrustCenter = X_AXIS*mFarPlane*0.5f; @@ -718,39 +529,6 @@ void LLCamera::calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2) calculateFrustumPlanes(left, right, top, bottom); } -void LLCamera::calculateWorldFrustumPlanes() -{ - F32 d; - LLVector3 center = mOrigin - mXAxis*mNearPlane; - mWorldPlanePos = center; - LLVector3 pnorm; - for (int p = 0; p < PLANE_NUM; p++) - { - mLocalPlanes[p].getVector3(pnorm); - LLVector3 norm = rotateToAbsolute(pnorm); - norm.normVec(); - d = -(center * norm); - mWorldPlanes[p] = LLPlane(norm, d); - } - // horizontal planes, perpindicular to (0,0,1); - LLVector3 zaxis(0, 0, 1.0f); - F32 yaw = getYaw(); - { - LLVector3 tnorm; - mLocalPlanes[PLANE_LEFT].getVector3(tnorm); - tnorm.rotVec(yaw, zaxis); - d = -(mOrigin * tnorm); - mHorizPlanes[HORIZ_PLANE_LEFT] = LLPlane(tnorm, d); - } - { - LLVector3 tnorm; - mLocalPlanes[PLANE_RIGHT].getVector3(tnorm); - tnorm.rotVec(yaw, zaxis); - d = -(mOrigin * tnorm); - mHorizPlanes[HORIZ_PLANE_RIGHT] = LLPlane(tnorm, d); - } -} - // NOTE: this is the OpenGL matrix that will transform the default OpenGL view // (-Z=at, Y=up) to the default view of the LLCamera class (X=at, Z=up): // diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h index d0afa0e88f..27eaa614c9 100644 --- a/indra/llmath/llcamera.h +++ b/indra/llmath/llcamera.h @@ -131,14 +131,10 @@ private: S32 mViewHeightInPixels; // for ViewHeightInPixels() only F32 mNearPlane; F32 mFarPlane; - LL_ALIGN_16(LLPlane mLocalPlanes[PLANE_NUM]); F32 mFixedDistance; // Always return this distance, unless < 0 LLVector3 mFrustCenter; // center of frustum and radius squared for ultra-quick exclusion test F32 mFrustRadiusSquared; - LL_ALIGN_16(LLPlane mWorldPlanes[PLANE_NUM]); - LL_ALIGN_16(LLPlane mHorizPlanes[HORIZ_PLANE_NUM]); - U32 mPlaneCount; //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in LLVector3 mWorldPlanePos; // Position of World Planes (may be offset from camera) @@ -184,7 +180,6 @@ public: return atan2f(mXAxis[VZ], xylen); } - const LLPlane& getWorldPlane(S32 index) const { return mWorldPlanes[index]; } const LLVector3& getWorldPlanePos() const { return mWorldPlanePos; } // Copy mView, mAspect, mNearPlane, and mFarPlane to buffer. @@ -200,7 +195,6 @@ public: // Returns 1 if partly in, 2 if fully in. // NOTE: 'center' is in absolute frame. - S32 sphereInFrustumOld(const LLVector3 ¢er, const F32 radius) const; S32 sphereInFrustum(const LLVector3 ¢er, const F32 radius) const; S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); } S32 sphereInFrustumFull(const LLVector3 ¢er, const F32 radius) const { return sphereInFrustum(center, radius); } @@ -217,8 +211,6 @@ public: F32 heightInPixels(const LLVector3 ¢er, F32 radius ) const; // return the distance from pos to camera if visible (-distance if not visible) - F32 visibleDistance(const LLVector3 &pos, F32 rad, F32 fudgescale = 1.0f, U32 planemask = PLANE_ALL_MASK) const; - F32 visibleHorizDistance(const LLVector3 &pos, F32 rad, F32 fudgescale = 1.0f, U32 planemask = HORIZ_PLANE_ALL_MASK) const; void setFixedDistance(F32 distance) { mFixedDistance = distance; } friend std::ostream& operator<<(std::ostream &s, const LLCamera &C); @@ -227,7 +219,6 @@ protected: void calculateFrustumPlanes(); void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom); void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2); - void calculateWorldFrustumPlanes(); } LL_ALIGN_POSTFIX(16); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 08a2e6779e..016cbe6e75 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1238,6 +1238,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("diffuseRect"); mReservedUniforms.push_back("specularRect"); mReservedUniforms.push_back("emissiveRect"); + mReservedUniforms.push_back("exposureMap"); mReservedUniforms.push_back("brdfLut"); mReservedUniforms.push_back("noiseMap"); mReservedUniforms.push_back("lightFunc"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 93ea49d16a..ec3455952b 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -192,6 +192,7 @@ public: DEFERRED_DIFFUSE, // "diffuseRect" DEFERRED_SPECULAR, // "specularRect" DEFERRED_EMISSIVE, // "emissiveRect" + EXPOSURE_MAP, // "exposureMap" DEFERRED_BRDF_LUT, // "brdfLut" DEFERRED_NOISE, // "noiseMap" DEFERRED_LIGHTFUNC, // "lightFunc" diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 5ade88e32b..5ffd610fba 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9002,37 +9002,6 @@ <key>Value</key> <integer>1</integer> </map> - - <key>RenderShadowNearDist</key> - <map> - <key>Comment</key> - <string>Near clip plane of shadow camera (affects precision of depth shadows).</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Vector3</string> - <key>Value</key> - <array> - <real>256</real> - <real>256</real> - <real>256</real> - </array> - </map> - <key>RenderShadowClipPlanes</key> - <map> - <key>Comment</key> - <string>Near clip plane split distances for shadow map frusta.</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Vector3</string> - <key>Value</key> - <array> - <real>1.0</real> - <real>12.0</real> - <real>32.0</real> - </array> - </map> <key>RenderShadowSplitExponent</key> <map> <key>Comment</key> @@ -9048,21 +9017,6 @@ <real>2.0</real> </array> </map> - <key>RenderShadowOrthoClipPlanes</key> - <map> - <key>Comment</key> - <string>Near clip plane split distances for orthographic shadow map frusta.</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Vector3</string> - <key>Value</key> - <array> - <real>4.0</real> - <real>8.0</real> - <real>24.0</real> - </array> - </map> <key>RenderShadowProjOffset</key> <map> <key>Comment</key> @@ -10402,7 +10356,7 @@ <key>Type</key> <string>F32</string> <key>Value</key> - <real>16</real> + <real>8</real> </map> <key>RenderTonemapper</key> <map> @@ -10413,7 +10367,7 @@ <key>Type</key> <string>U32</string> <key>Value</key> - <real>1</real> + <real>2</real> </map> <key>RenderExposure</key> <map> @@ -10449,18 +10403,17 @@ <key>Value</key> <real>0</real> </map> - <key>RenderReflectionProbeTextureHackID</key> + <key>RenderAutomaticReflectionProbes</key> <map> <key>Comment</key> - <string>HACK -- Any object with a diffuse texture with this ID will be treated as a user override reflection probe. (default is "Violet Info Hub" photo from Library)</string> + <string>Automatic reflection probes control. 0 - disable, 1 - Terrain/water only, 2- Terrain/water + objects. Requires restart.</string> <key>Persist</key> <integer>1</integer> <key>Type</key> - <string>String</string> + <string>S32</string> <key>Value</key> - <string>6b186931-05da-eafa-a3ed-a012a33bbfb6</string> + <integer>2</integer> </map> - <key>RenderReflectionRes</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 5ca210863e..3a7552d23e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -114,7 +114,7 @@ void main() float rel_pos_len = length(rel_pos); // Initialize temp variables - vec3 sunlight = sunlight_color; + vec3 sunlight = sunlight_color*2.0; vec3 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl new file mode 100644 index 0000000000..b325f55576 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -0,0 +1,92 @@ +/** + * @file exposureF.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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]*/ + +out vec4 frag_color; + +uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect; +uniform sampler2D exposureMap; + +uniform float dt; +uniform vec2 noiseVec; + +// calculate luminance the same way LLColor4::calcHSL does +float lum(vec3 col) +{ + float mx = max(max(col.r, col.g), col.b); + float mn = min(min(col.r, col.g), col.b); + return (mx + mn) * 0.5; +} + +void main() +{ + float step = 1.0/16.0; + + float start = step; + float end = 1.0-step; + + float w = 0.0; + + vec3 col; + + vec2 nz = noiseVec * step * 0.5; + + for (float x = start; x <= end; x += step) + { + for (float y = start; y <= end; y += step) + { + vec2 tc = vec2(x,y) + nz; + vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; + float L = max(lum(c), 0.25); + + float d = length(vec2(0.5)-tc); + d = 1.0-d; + d *= d; + d *= d; + d *= d; + L *= d; + + w += L; + + col += c * L; + } + } + + col /= w; + + float L = lum(col); + + float s = clamp(0.1/L, 0.5, 2.5); + + float prev = texture(exposureMap, vec2(0.5,0.5)).r; + s = mix(prev, s, min(dt*2.0, 0.04)); + + frag_color = vec4(s, s, s, dt); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 87324bca7f..221de0b095 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -35,6 +35,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform sampler2D emissiveRect; +uniform sampler2D exposureMap; uniform vec2 screen_res; VARYING vec2 vary_fragcoord; @@ -107,7 +108,9 @@ uniform float gamma; vec3 toneMap(vec3 color) { - color *= exposure; + float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r; + + color *= exposure * exp_scale; #ifdef TONEMAP_ACES_NARKOWICZ color = toneMapACES_Narkowicz(color); @@ -122,7 +125,6 @@ vec3 toneMap(vec3 color) // this factor is based on the exposure correction of Krzysztof Narkowicz in his // implemetation of ACES tone mapping color *= 1.0/0.6; - //color /= 0.6; color = toneMapACES_Hill(color); #endif @@ -190,6 +192,9 @@ void main() vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb)); diff.rgb += nz*0.003; //diff.rgb = nz; + + //float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r; + //diff.g = exp_sample; frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl index 4d24b4de9a..8b4cac3e64 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl @@ -33,6 +33,6 @@ void main() { //transform vertex vec4 pos = vec4(position.xyz, 1.0); - gl_Position = pos; + gl_Position = pos; vary_fragcoord = (pos.xy*0.5+0.5); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 1424b57d6f..fc6291d438 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -32,8 +32,8 @@ ATTRIBUTE vec3 position; /////////////////////////////////////////////////////////////////////////////// // Output parameters -VARYING vec3 vary_HazeColor; -VARYING float vary_LightNormPosDot; +out vec3 vary_HazeColor; +out float vary_LightNormPosDot; // Inputs uniform vec3 camPosLocal; @@ -56,6 +56,8 @@ uniform float max_y; uniform vec3 glow; uniform float sun_moon_glow_factor; +uniform int cube_snapshot; + // NOTE: Keep these in sync! // indra\newview\app_settings\shaders\class1\deferred\skyV.glsl // indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl @@ -89,8 +91,8 @@ void main() vary_LightNormPosDot = rel_pos_lightnorm_dot; // Initialize temp variables - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color*0.75; + // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index ef35bf3fd7..e7322c14fb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -79,7 +79,6 @@ vec3 srgb_to_linear(vec3 c); vec3 linear_to_srgb(vec3 c); vec2 encode_normal (vec3 n); -vec3 scaleSoftClipFragLinear(vec3 l); vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); @@ -279,7 +278,6 @@ void main() color.rgb = linear_to_srgb(color.rgb); color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); - color.rgb = scaleSoftClipFragLinear(color.rgb); color.rgb = srgb_to_linear(color.rgb); vec4 light = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 55e1411be2..0d3dbf85e2 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -62,7 +62,8 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + float scale = 2.0; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color * scale: moonlight_color*0.75; // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -140,7 +141,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou // fudge sunlit and amblit to get consistent lighting compared to legacy // midday before PBR was a thing - sunlit = sunlight.rgb * 0.7; + sunlit = sunlight.rgb / scale; amblit = tmpAmbient.rgb * 0.25; additive *= vec3(1.0 - combined_haze); diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index bd06a680f5..7a5676e0ab 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -29,9 +29,6 @@ float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source); #endif -#define REFMAP_COUNT 256 -#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider - uniform samplerCubeArray reflectionProbes; uniform samplerCubeArray irradianceProbes; uniform sampler2D sceneMap; @@ -95,6 +92,7 @@ bool shouldSampleProbe(int i, vec3 pos) return false; } + // never allow automatic probes to encroach on box probes sample_automatic = false; } else @@ -429,25 +427,19 @@ void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col) // dir - normal to be weighted // origin - center of sphere probe // r - radius of probe influence volume -// min_da - minimum angular attenuation coefficient // i - index of probe in refSphere // dw - distance weight -float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, float min_da, int i, out float dw) +float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, int i, out float dw) { float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz - origin; float d2 = max(length(delta), 0.001); - float r2 = r1; //r1 * r1; - - //float atten = 1.0 - max(d2 - r2, 0.0) / max((rr - r2), 0.001); - float atten = 1.0 - max(d2 - r2, 0.0) / max((r - r2), 0.001); + float atten = 1.0 - max(d2 - r1, 0.0) / max((r - r1), 0.001); float w = 1.0 / d2; dw = w * atten * max(r, 1.0)*4; - atten *= max(dot(normalize(-delta), dir), min_da); - w *= atten; return w; @@ -484,7 +476,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres rr); - w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.25, i, dw); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw); } v -= c; @@ -524,7 +516,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres rr); - w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.001, i, dw); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw); } v -= c; @@ -562,7 +554,6 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float dw = 0; vec3 refcol; - { refcol = tapRefMap(pos, dir, w, dw, lod, refSphere[i].xyz, i); @@ -735,7 +726,7 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 refnormpersp = reflect(pos.xyz, norm.xyz); ambenv = sampleProbeAmbient(pos, norm); - + if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 020c7bbc74..3d634c7484 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 51 +version 53 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -102,6 +102,7 @@ RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 8 // // Medium Low Graphics Settings @@ -109,6 +110,7 @@ RenderScreenSpaceReflections 1 0 list LowMid RenderAnisotropic 1 0 RenderAvatarLODFactor 1 0.5 +RenderAvatarMaxNonImpostors 1 5 RenderAvatarMaxComplexity 1 100000 RenderAvatarPhysicsLODFactor 1 0.75 RenderFarClip 1 96 @@ -129,6 +131,7 @@ RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 16 // // Medium Graphics Settings (standard) @@ -136,6 +139,7 @@ RenderScreenSpaceReflections 1 0 list Mid RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 7 RenderAvatarMaxComplexity 1 200000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -147,7 +151,7 @@ RenderTransparentWater 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.25 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -156,6 +160,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 32 // // Medium High Graphics Settings (deferred enabled) @@ -163,6 +168,7 @@ RenderScreenSpaceReflections 1 0 list MidHigh RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 9 RenderAvatarMaxComplexity 1 250000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -174,7 +180,7 @@ RenderTransparentWater 1 1 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.375 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -183,6 +189,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 64 // // High Graphics Settings (deferred + SSAO) @@ -190,6 +197,7 @@ RenderScreenSpaceReflections 1 0 list High RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 11 RenderAvatarMaxComplexity 1 300000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -201,7 +209,7 @@ RenderTransparentWater 1 1 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.5 RenderDeferredSSAO 1 1 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -210,6 +218,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 128 // // High Ultra Graphics Settings (deferred + SSAO + shadows) @@ -217,6 +226,7 @@ RenderScreenSpaceReflections 1 0 list HighUltra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarMaxComplexity 1 350000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -228,7 +238,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.75 RenderDeferredSSAO 1 1 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 @@ -237,6 +247,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 256 // // Ultra graphics (REALLY PURTY!) @@ -244,6 +255,7 @@ RenderScreenSpaceReflections 1 0 list Ultra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 @@ -264,6 +276,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 1 +RenderReflectionProbeCount 1 256 // // Class Unknown Hardware (unknown) diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index dbb33b3997..eed790ddac 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 46 +version 48 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -71,7 +71,7 @@ RenderGLMultiThreaded 1 0 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 2 RenderScreenSpaceReflections 1 1 -RenderReflectionProbeCount 1 8 +RenderReflectionProbeCount 1 256 // // Low Graphics Settings @@ -100,6 +100,7 @@ RenderFSAASamples 1 0 RenderReflectionsEnabled 1 0 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 8 // // Medium Low Graphics Settings @@ -107,6 +108,7 @@ RenderScreenSpaceReflections 1 0 list LowMid RenderAnisotropic 1 0 RenderAvatarLODFactor 1 0.5 +RenderAvatarMaxNonImpostors 1 5 RenderAvatarMaxComplexity 1 100000 RenderAvatarPhysicsLODFactor 1 0.75 RenderFarClip 1 96 @@ -127,6 +129,7 @@ RenderFSAASamples 1 0 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 16 // // Medium Graphics Settings (standard) @@ -134,6 +137,7 @@ RenderScreenSpaceReflections 1 0 list Mid RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 7 RenderAvatarMaxComplexity 1 200000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -145,7 +149,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.25 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -154,6 +158,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 32 // // Medium High Graphics Settings (deferred enabled) @@ -161,6 +166,7 @@ RenderScreenSpaceReflections 1 0 list MidHigh RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 9 RenderAvatarMaxComplexity 1 250000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -172,7 +178,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.375 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -181,6 +187,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 64 // // High Graphics Settings (deferred + SSAO) @@ -188,6 +195,7 @@ RenderScreenSpaceReflections 1 0 list High RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 11 RenderAvatarMaxComplexity 1 300000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -199,7 +207,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.5 RenderDeferredSSAO 1 1 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -208,6 +216,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 128 // // High Ultra Graphics Settings (deferred + SSAO + shadows) @@ -215,6 +224,7 @@ RenderScreenSpaceReflections 1 0 list HighUltra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarMaxComplexity 1 350000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -226,7 +236,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.75 RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 RenderUseAdvancedAtmospherics 1 0 @@ -235,6 +245,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 256 // // Ultra graphics (REALLY PURTY!) @@ -242,6 +253,7 @@ RenderScreenSpaceReflections 1 0 list Ultra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 @@ -262,6 +274,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 1 +RenderReflectionProbeCount 1 256 // // Class Unknown Hardware (unknown) diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index acbc349567..b49fe35851 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -139,6 +139,8 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->bind(); + sky_shader->uniform1i(LLShaderMgr::CUBE_SNAPSHOT, gCubeSnapshot ? 1 : 0); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); LLViewerTexture* rainbow_tex = gSky.mVOSkyp->getRainbowTex(); diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 81a7aa47c8..0974ae0742 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -434,19 +434,19 @@ bool LLFeatureManager::loadGPUClass() mGPUClass = GPU_CLASS_0; #endif } - else if (gbps <= 8.f) + else if (gbps <= 32.0f) { mGPUClass = GPU_CLASS_1; } - else if (gbps <= 16.f) + else if (gbps <= 64.0f) { mGPUClass = GPU_CLASS_2; } - else if (gbps <= 40.f) + else if (gbps <= 128.0f) { mGPUClass = GPU_CLASS_3; } - else if (gbps <= 80.f) + else if (gbps <= 256.0f) { mGPUClass = GPU_CLASS_4; } diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 58ce571505..6828078f4f 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -328,29 +328,20 @@ void LLReflectionMapManager::getReflectionMaps(std::vector<LLReflectionMap*>& ma LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* group) { -#if 1 - if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) + static LLCachedControl<S32> automatic_probes(gSavedSettings, "RenderAutomaticReflectionProbes", 2); + if (automatic_probes > 1) { - OctreeNode* node = group->getOctreeNode(); - F32 size = node->getSize().getF32ptr()[0]; - if (size >= 15.f && size <= 17.f) + if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) { - return addProbe(group); + OctreeNode* node = group->getOctreeNode(); + F32 size = node->getSize().getF32ptr()[0]; + if (size >= 15.f && size <= 17.f) + { + return addProbe(group); + } } } -#endif -#if 0 - if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN) - { - OctreeNode* node = group->getOctreeNode(); - F32 size = node->getSize().getF32ptr()[0]; - if (size >= 15.f && size <= 17.f) - { - return addProbe(group); - } - } -#endif return nullptr; } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index dd4ff50259..192a96a408 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1255,43 +1255,45 @@ U32 LLViewerRegion::getNumOfVisibleGroups() const void LLViewerRegion::updateReflectionProbes() { -#if 1 - const F32 probe_spacing = 32.f; - const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); - const F32 hover_height = 2.f; + static LLCachedControl<S32> automatic_probes(gSavedSettings, "RenderAutomaticReflectionProbes", 2); + if (automatic_probes > 0) + { + const F32 probe_spacing = 32.f; + const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); + const F32 hover_height = 2.f; - F32 start = probe_spacing * 0.5f; + F32 start = probe_spacing * 0.5f; - U32 grid_width = REGION_WIDTH_METERS / probe_spacing; + U32 grid_width = REGION_WIDTH_METERS / probe_spacing; - mReflectionMaps.resize(grid_width * grid_width); + mReflectionMaps.resize(grid_width * grid_width); - F32 water_height = getWaterHeight(); - LLVector3 origin = getOriginAgent(); + F32 water_height = getWaterHeight(); + LLVector3 origin = getOriginAgent(); - for (U32 i = 0; i < grid_width; ++i) - { - F32 x = i * probe_spacing + start; - for (U32 j = 0; j < grid_width; ++j) + for (U32 i = 0; i < grid_width; ++i) { - F32 y = j * probe_spacing + start; + F32 x = i * probe_spacing + start; + for (U32 j = 0; j < grid_width; ++j) + { + F32 y = j * probe_spacing + start; - U32 idx = i * grid_width + j; + U32 idx = i * grid_width + j; - if (mReflectionMaps[idx].isNull()) - { - mReflectionMaps[idx] = gPipeline.mReflectionMapManager.addProbe(); - } + if (mReflectionMaps[idx].isNull()) + { + mReflectionMaps[idx] = gPipeline.mReflectionMapManager.addProbe(); + } - LLVector3 probe_origin = LLVector3(x,y, llmax(water_height, mImpl->mLandp->resolveHeightRegion(x,y))); - probe_origin.mV[2] += hover_height; - probe_origin += origin; + LLVector3 probe_origin = LLVector3(x, y, llmax(water_height, mImpl->mLandp->resolveHeightRegion(x, y))); + probe_origin.mV[2] += hover_height; + probe_origin += origin; - mReflectionMaps[idx]->mOrigin.load3(probe_origin.mV); - mReflectionMaps[idx]->mRadius = probe_radius; + mReflectionMaps[idx]->mOrigin.load3(probe_origin.mV); + mReflectionMaps[idx]->mRadius = probe_radius; + } } } -#endif } void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 31c71aac2a..93f4d22ff8 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -187,6 +187,7 @@ LLGLSLShader gDeferredPostProgram; LLGLSLShader gDeferredCoFProgram; LLGLSLShader gDeferredDoFCombineProgram; LLGLSLShader gDeferredPostGammaCorrectProgram; +LLGLSLShader gExposureProgram; LLGLSLShader gFXAAProgram; LLGLSLShader gDeferredPostNoDoFProgram; LLGLSLShader gDeferredWLSkyProgram; @@ -667,6 +668,10 @@ std::string LLViewerShaderMgr::loadBasicShaders() BOOL local_light_kill = gSavedSettings.getBOOL("LocalLightDisable"); BOOL ssr = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); + bool has_reflection_probes = gSavedSettings.getBOOL("RenderReflectionsEnabled") && gGLManager.mGLVersion > 3.99f; + + S32 probe_count = gSavedSettings.getS32("RenderReflectionProbeCount"); + if (ambient_kill) { attribs["AMBIENT_KILL"] = "1"; @@ -699,6 +704,12 @@ std::string LLViewerShaderMgr::loadBasicShaders() attribs["SSR"] = "1"; } + if (has_reflection_probes) + { + attribs["REFMAP_COUNT"] = std::to_string(probe_count); + attribs["REF_SAMPLE_COUNT"] = "32"; + } + // We no longer have to bind the shaders to global glhandles, they are automatically added to a map now. for (U32 i = 0; i < shaders.size(); i++) { @@ -721,7 +732,6 @@ std::string LLViewerShaderMgr::loadBasicShaders() ch = llmax(LLGLSLShader::sIndexedTextureChannels, 1); } - bool has_reflection_probes = gSavedSettings.getBOOL("RenderReflectionsEnabled") && gGLManager.mGLVersion > 3.99f; std::vector<S32> index_channels; index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); @@ -991,6 +1001,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPostProgram.unload(); gDeferredCoFProgram.unload(); gDeferredDoFCombineProgram.unload(); + gExposureProgram.unload(); gDeferredPostGammaCorrectProgram.unload(); gFXAAProgram.unload(); gDeferredWLSkyProgram.unload(); @@ -2509,6 +2520,20 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true; } + if (success) + { + gExposureProgram.mName = "Exposure"; + gExposureProgram.mFeatures.hasSrgb = true; + gExposureProgram.mFeatures.isDeferred = true; + gExposureProgram.mShaderFiles.clear(); + gExposureProgram.clearPermutations(); + gExposureProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); + gExposureProgram.mShaderFiles.push_back(make_pair("deferred/exposureF.glsl", GL_FRAGMENT_SHADER)); + gExposureProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gExposureProgram.createShader(NULL, NULL); + llassert(success); + } + if (success) { gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 867413b6c9..6fb2bc3fec 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -235,6 +235,7 @@ extern LLGLSLShader gDeferredDoFCombineProgram; extern LLGLSLShader gFXAAProgram; extern LLGLSLShader gDeferredPostNoDoFProgram; extern LLGLSLShader gDeferredPostGammaCorrectProgram; +extern LLGLSLShader gExposureProgram; extern LLGLSLShader gDeferredAvatarShadowProgram; extern LLGLSLShader gDeferredAvatarAlphaShadowProgram; extern LLGLSLShader gDeferredAvatarAlphaMaskShadowProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f059c87c91..eaec698f84 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -116,27 +116,7 @@ #include "llenvironment.h" #include "llsettingsvo.h" -#ifdef _DEBUG -// Debug indices is disabled for now for debug performance - djs 4/24/02 -//#define DEBUG_INDICES -#else -//#define DEBUG_INDICES -#endif - -// Expensive and currently broken -// -#define MATERIALS_IN_REFLECTIONS 0 - -// NOTE: Keep in sync with indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml -// NOTE: Unused consts are commented out since some compilers (on macOS) may complain about unused variables. -// const S32 WATER_REFLECT_NONE_WATER_OPAQUE = -2; - //const S32 WATER_REFLECT_NONE_WATER_TRANSPARENT = -1; - //const S32 WATER_REFLECT_MINIMAL = 0; -// const S32 WATER_REFLECT_TERRAIN = 1; - //const S32 WATER_REFLECT_STATIC_OBJECTS = 2; - //const S32 WATER_REFLECT_AVATARS = 3; - //const S32 WATER_REFLECT_EVERYTHING = 4; - +extern BOOL gSnapshot; bool gShiftFrame = false; //cached settings @@ -202,9 +182,6 @@ LLVector3 LLPipeline::RenderShadowGaussian; F32 LLPipeline::RenderShadowBlurDistFactor; bool LLPipeline::RenderDeferredAtmospheric; F32 LLPipeline::RenderHighlightFadeTime; -LLVector3 LLPipeline::RenderShadowClipPlanes; -LLVector3 LLPipeline::RenderShadowOrthoClipPlanes; -LLVector3 LLPipeline::RenderShadowNearDist; F32 LLPipeline::RenderFarClip; LLVector3 LLPipeline::RenderShadowSplitExponent; F32 LLPipeline::RenderShadowErrorCutoff; @@ -341,7 +318,7 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) bool valid = true && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM && target.addColorAttachment(GL_RGBA16F) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight - && target.addColorAttachment(GL_RGB16); // frag_data[3] PBR emissive + && target.addColorAttachment(GL_RGB16F); // frag_data[3] PBR emissive return valid; } @@ -558,9 +535,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderShadowBlurDistFactor"); connectRefreshCachedSettingsSafe("RenderDeferredAtmospheric"); connectRefreshCachedSettingsSafe("RenderHighlightFadeTime"); - connectRefreshCachedSettingsSafe("RenderShadowClipPlanes"); - connectRefreshCachedSettingsSafe("RenderShadowOrthoClipPlanes"); - connectRefreshCachedSettingsSafe("RenderShadowNearDist"); connectRefreshCachedSettingsSafe("RenderFarClip"); connectRefreshCachedSettingsSafe("RenderShadowSplitExponent"); connectRefreshCachedSettingsSafe("RenderShadowErrorCutoff"); @@ -855,6 +829,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mSceneMap.allocate(resX, resY, GL_RGB, true); } + mPostMap.allocate(resX, resY, GL_RGBA); + //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -1043,9 +1019,6 @@ void LLPipeline::refreshCachedSettings() RenderShadowBlurDistFactor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); RenderDeferredAtmospheric = gSavedSettings.getBOOL("RenderDeferredAtmospheric"); RenderHighlightFadeTime = gSavedSettings.getF32("RenderHighlightFadeTime"); - RenderShadowClipPlanes = gSavedSettings.getVector3("RenderShadowClipPlanes"); - RenderShadowOrthoClipPlanes = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); - RenderShadowNearDist = gSavedSettings.getVector3("RenderShadowNearDist"); RenderFarClip = gSavedSettings.getF32("RenderFarClip"); RenderShadowSplitExponent = gSavedSettings.getVector3("RenderShadowSplitExponent"); RenderShadowErrorCutoff = gSavedSettings.getF32("RenderShadowErrorCutoff"); @@ -1088,6 +1061,8 @@ void LLPipeline::releaseGLBuffers() mSceneMap.release(); + mPostMap.release(); + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -1108,6 +1083,10 @@ void LLPipeline::releaseLUTBuffers() } mPbrBrdfLut.release(); + + mExposureMap.release(); + mLastExposure.release(); + } void LLPipeline::releaseShadowBuffers() @@ -1284,6 +1263,13 @@ void LLPipeline::createLUTBuffers() gDeferredGenBrdfLutProgram.unbind(); mPbrBrdfLut.flush(); + + mExposureMap.allocate(1, 1, GL_R16F); + mExposureMap.bindTarget(); + mExposureMap.clear(); + mExposureMap.flush(); + + mLastExposure.allocate(1, 1, GL_R16F); } @@ -7402,7 +7388,62 @@ void LLPipeline::renderFinalize() dst.flush(); } - screenTarget()->bindTarget(); + // exposure sample + { + LL_PROFILE_GPU_ZONE("exposure sample"); + + { + // copy last frame's exposure into mLastExposure + mLastExposure.bindTarget(); + gCopyProgram.bind(); + gGL.getTexUnit(0)->bind(&mExposureMap); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + mLastExposure.flush(); + } + + + mExposureMap.bindTarget(); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + gExposureProgram.bind(); + + S32 channel = 0; + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); + if (channel > -1) + { + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel); + } + + channel = gExposureProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP); + if (channel > -1) + { + mLastExposure.bindTexture(0, channel); + } + + static LLStaticHashedString dt("dt"); + static LLStaticHashedString noiseVec("noiseVec"); + gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); + gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); + gExposureProgram.unbind(); + mExposureMap.flush(); + } + + mPostMap.bindTarget(); // gamma correct lighting { @@ -7429,6 +7470,12 @@ void LLPipeline::renderFinalize() mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP, mExposureMap.getUsage()); + if (channel > -1) + { + mExposureMap.bindTexture(0, channel); + } + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); static LLCachedControl<F32> exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7446,7 +7493,7 @@ void LLPipeline::renderFinalize() gDeferredPostGammaCorrectProgram.unbind(); } - screenTarget()->flush(); + mPostMap.flush(); LLVertexBuffer::unbind(); } @@ -7475,10 +7522,10 @@ void LLPipeline::renderFinalize() shader->bind(); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); if (channel > -1) { - screenTarget()->bindTexture(0, channel); + mPostMap.bindTexture(0, channel); } { @@ -7489,7 +7536,7 @@ void LLPipeline::renderFinalize() gGL.flush(); - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); shader->unbind(); mRT->fxaaBuffer.flush(); @@ -7519,9 +7566,8 @@ void LLPipeline::renderFinalize() 2.f / width * scale_x, 2.f / height * scale_y); { - // at this point we should pointed at the backbuffer - llassert(LLRenderTarget::sCurFBO == 0); - + // at this point we should pointed at the backbuffer (or a snapshot render target) + llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); @@ -7534,8 +7580,8 @@ void LLPipeline::renderFinalize() } else { - // at this point we should pointed at the backbuffer - llassert(LLRenderTarget::sCurFBO == 0); + // at this point we should pointed at the backbuffer (or a snapshot render target) + llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); @@ -7544,7 +7590,7 @@ void LLPipeline::renderFinalize() S32 screen_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DIFFUSE); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - gGL.getTexUnit(screen_channel)->bind(screenTarget()); + gGL.getTexUnit(screen_channel)->bind(&mPostMap); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; @@ -9277,27 +9323,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) glh::matrix4f view[6]; glh::matrix4f proj[6]; - //clip contains parallel split distances for 3 splits - LLVector3 clip = RenderShadowClipPlanes; - LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir); - //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(); + LLVector3 p = camera.getOrigin(); // gAgent.getPositionAgent(); p += caster_dir * RenderFarClip*2.f; shadow_near_clip.setVec(p, caster_dir); } @@ -9318,9 +9349,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) up = camera.getUpAxis(); } - /*LLVector3 left = up%at; - up = at%left;*/ - up.normVec(); at.normVec(); @@ -9403,6 +9431,14 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding } + if (gCubeSnapshot) + { // stretch clip planes for reflection probe renders to reduce number of shadow passes + mSunClipPlanes.mV[1] = mSunClipPlanes.mV[2]; + mSunClipPlanes.mV[2] = mSunClipPlanes.mV[3]; + mSunClipPlanes.mV[3] *= 1.5f; + } + + // convenience array of 4 near clip plane distances F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; @@ -9419,7 +9455,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < (gCubeSnapshot ? 3 : 4); j++) + for (S32 j = 0; j < (gCubeSnapshot ? 2 : 4); j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 0faa0c3f20..eb30c85993 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -300,8 +300,6 @@ public: void bindReflectionProbes(LLGLSLShader& shader); void unbindReflectionProbes(LLGLSLShader& shader); - - void renderDeferredLighting(); void postDeferredGammaCorrect(LLRenderTarget* screen_target); @@ -679,6 +677,13 @@ public: // for use by SSR LLRenderTarget mSceneMap; + // exposure map for getting average color in scene + LLRenderTarget mExposureMap; + LLRenderTarget mLastExposure; + + // tonemapped and gamma corrected render ready for post + LLRenderTarget mPostMap; + LLCullResult mSky; LLCullResult mReflectedObjects; LLCullResult mRefractedObjects; @@ -999,9 +1004,6 @@ public: static F32 RenderShadowBlurDistFactor; static bool RenderDeferredAtmospheric; static F32 RenderHighlightFadeTime; - static LLVector3 RenderShadowClipPlanes; - static LLVector3 RenderShadowOrthoClipPlanes; - static LLVector3 RenderShadowNearDist; static F32 RenderFarClip; static LLVector3 RenderShadowSplitExponent; static F32 RenderShadowErrorCutoff; |