Merge branch 'release/2024.09-ExtraFPS' of https://github.com/secondlife/viewer

# Conflicts:
#	indra/llrender/llvertexbuffer.cpp
#	indra/newview/app_settings/settings.xml
#	indra/newview/lltexturefetch.cpp
#	indra/newview/viewer_manifest.py
master
Ansariel 2024-11-27 19:23:33 +01:00
commit 68d82c9793
79 changed files with 1129 additions and 381 deletions

View File

@ -656,7 +656,7 @@ class LLManifest(object, metaclass=LLManifestRegistry):
'vers':'_'.join(self.args['version'])}
print("Creating unpacked file:", unpacked_file_name)
# could add a gz here but that doubles the time it takes to do this step
tf = tarfile.open(self.src_path_of(unpacked_file_name), 'w:')
tf = tarfile.open(self.build_path_of(unpacked_file_name), 'w:')
# add the entire installation package, at the very top level
tf.add(self.get_dst_prefix(), "")
tf.close()

View File

@ -2429,9 +2429,15 @@ void LLKeyframeMotion::onLoadComplete(const LLUUID& asset_uuid,
LLCharacter* character = *char_iter;
// look for an existing instance of this motion
LLKeyframeMotion* motionp = static_cast<LLKeyframeMotion*> (character->findMotion(asset_uuid));
if (motionp)
if (LLMotion* asset = character->findMotion(asset_uuid))
{
LLKeyframeMotion* motionp = dynamic_cast<LLKeyframeMotion*>(asset);
if (!motionp)
{
// This motion is not LLKeyframeMotion (e.g., LLEmote)
return;
}
if (0 == status)
{
if (motionp->mAssetStatus == ASSET_LOADED)

View File

@ -605,7 +605,7 @@ void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf)
mSettingFlags |= other->mSettingFlags;
mCanAutoAdjust = false; // no point?
mCanAutoAdjust = other->mCanAutoAdjust;
mSunRotation = slerp((F32)blendf, mSunRotation, other->mSunRotation);
mMoonRotation = slerp((F32)blendf, mMoonRotation, other->mMoonRotation);
@ -1181,6 +1181,11 @@ void LLSettingsSky::loadValuesFromLLSD()
mReflectionProbeAmbiance = (F32)settings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal();
}
mHDRMax = 2.0f;
mHDRMin = 0.5f;
mHDROffset = 1.0f;
mTonemapMix = 1.0f;
mSunTextureId = settings[SETTING_SUN_TEXTUREID].asUUID();
mMoonTextureId = settings[SETTING_MOON_TEXTUREID].asUUID();
mCloudTextureId = settings[SETTING_CLOUD_TEXTUREID].asUUID();
@ -2031,6 +2036,38 @@ F32 LLSettingsSky::getGamma() const
return mGamma;
}
F32 LLSettingsSky::getHDRMin() const
{
if (mCanAutoAdjust)
return 0.f;
return mHDRMin;
}
F32 LLSettingsSky::getHDRMax() const
{
if (mCanAutoAdjust)
return 0.f;
return mHDRMax;
}
F32 LLSettingsSky::getHDROffset() const
{
if (mCanAutoAdjust)
return 1.0f;
return mHDROffset;
}
F32 LLSettingsSky::getTonemapMix() const
{
if (mCanAutoAdjust)
return 0.0f;
return mTonemapMix;
}
void LLSettingsSky::setGamma(F32 val)
{
mGamma = val;

View File

@ -209,6 +209,11 @@ public:
F32 getGamma() const;
F32 getHDRMin() const;
F32 getHDRMax() const;
F32 getHDROffset() const;
F32 getTonemapMix() const;
void setGamma(F32 val);
LLColor3 getGlow() const;
@ -380,6 +385,10 @@ protected:
F32 mCloudVariance;
F32 mCloudShadow;
F32 mCloudScale;
F32 mTonemapMix;
F32 mHDROffset;
F32 mHDRMax;
F32 mHDRMin;
LLVector2 mScrollRate;
LLColor3 mCloudPosDensity1;
LLColor3 mCloudPosDensity2;

View File

@ -1866,6 +1866,23 @@ void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLf
}
}
void LLGLSLShader::uniform4f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
const auto& iter = mValue.find(location);
LLVector4 vec(x, y, z, w);
if (iter == mValue.end() || shouldChange(iter->second, vec))
{
glUniform4f(location, x, y, z, w);
mValue[location] = vec;
}
}
}
void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;

View File

@ -52,6 +52,7 @@ public:
bool hasAmbientOcclusion = false;
bool hasSrgb = false;
bool isDeferred = false;
bool hasFullGBuffer = false;
bool hasScreenSpaceReflections = false;
bool hasAlphaMask = false;
bool hasReflectionProbes = false;
@ -221,6 +222,7 @@ public:
void uniform1f(const LLStaticHashedString& uniform, GLfloat v);
void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y);
void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z);
void uniform4f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);

View File

@ -259,8 +259,8 @@ void LLImageGL::initClass(LLWindow* window, S32 num_catagories, bool skip_analyz
if (thread_texture_loads || thread_media_updates)
{
LLImageGLThread::createInstance(window);
LLImageGLThread::sEnabledTextures = thread_texture_loads;
LLImageGLThread::sEnabledMedia = thread_media_updates;
LLImageGLThread::sEnabledTextures = gGLManager.mGLVersion > 3.95f ? thread_texture_loads : false;
LLImageGLThread::sEnabledMedia = gGLManager.mGLVersion > 3.95f ? thread_media_updates : false;
}
}
@ -332,6 +332,7 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
case GL_RGB8: return 24;
case GL_RGBA: return 32;
case GL_RGBA8: return 32;
case GL_RGB10_A2: return 32;
case GL_SRGB_ALPHA: return 32;
case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac
case GL_DEPTH_COMPONENT: return 24;

View File

@ -223,6 +223,14 @@ bool LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
}
}
if (features->hasFullGBuffer)
{
if (!shader->attachFragmentObject("deferred/gbufferUtil.glsl"))
{
return false;
}
}
if (features->hasScreenSpaceReflections || features->hasReflectionProbes)
{
if (!shader->attachFragmentObject("deferred/screenSpaceReflUtil.glsl"))
@ -612,7 +620,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev
extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 0.34\n"); // bit 0
extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_PBR 0.67\n"); // bit 1
extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_HDRI 1.0\n"); // bit 2
extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag) (abs(norm.w-flag)< 0.1)\n");
extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(data, flag) (abs(data-flag)< 0.1)\n");
if (defines)
{
@ -723,6 +731,9 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev
}
}
// Master definition can be found in deferredUtil.glsl
extra_code_text[extra_code_count++] = strdup("struct GBufferInfo { vec4 albedo; vec4 specular; vec3 normal; vec4 emissive; float gbufferFlag; float envIntensity; };\n");
//copy file into memory
enum {
flag_write_to_out_of_extra_block_area = 0x01
@ -1255,6 +1266,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("sky_hdr_scale");
mReservedUniforms.push_back("sky_sunlight_scale");
mReservedUniforms.push_back("sky_ambient_scale");
mReservedUniforms.push_back("classic_mode");
mReservedUniforms.push_back("blue_horizon");
mReservedUniforms.push_back("blue_density");
mReservedUniforms.push_back("haze_horizon");

View File

@ -121,6 +121,7 @@ public:
SKY_HDR_SCALE, // "sky_hdr_scale"
SKY_SUNLIGHT_SCALE, // "sky_sunlight_scale"
SKY_AMBIENT_SCALE, // "sky_ambient_scale"
CLASSIC_MODE, // "classic_mode"
BLUE_HORIZON, // "blue_horizon"
BLUE_DENSITY, // "blue_density"
HAZE_HORIZON, // "haze_horizon"

View File

@ -962,10 +962,6 @@ void LLVertexBuffer::initClass(LLWindow* window)
{
llassert(sVBOPool == nullptr);
// <FS:Ansariel> Fix memory leak
//LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL;
//sVBOPool = new LLAppleVBOPool();
if (gGLManager.mIsApple)
{
LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL;

View File

@ -2286,6 +2286,50 @@ if (WINDOWS)
add_dependencies(${VIEWER_BINARY_NAME} stage_third_party_libs llcommon llwebrtc copy_w_viewer_manifest)
# Useful for remote debugging or profiling if set to target a shared drive. for example, brad sets it to "dist/secondlife" to deploy under
# the build tree (and then I share that directory) or "f:/dist/secondlife" to deploy to a network mounted drive (although this can be slow).
# this will also create an "unpacked" tarball at build-<platform>/newview/unpacked_<platform>_7_1_11_<build num>.tar
set(LOCAL_DIST_DIR "" CACHE PATH "Path for 'local' unpacked copy of viewer distribution to be deployed to.")
set(product SecondLife-${ARCH}-${VIEWER_SHORT_VERSION}.${VIEWER_VERSION_REVISION})
if(IS_DIRECTORY ${LOCAL_DIST_DIR})
add_custom_command(
OUTPUT ${LOCAL_DIST_DIR}/.${product}.copy_touched
COMMAND ${PYTHON_EXECUTABLE}
ARGS
${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
"--actions=\"copy package unpacked\""
--arch=${ARCH}
--artwork=${ARTWORK_DIR}
"--bugsplat=${BUGSPLAT_DB}"
"--fmodstudio=${USE_FMODSTUDIO}"
"--openal=${USE_OPENAL}"
"--tracy=${USE_TRACY}"
"--avx2=${USE_AVX2_OPTIMIZATION}"
--build=${CMAKE_CURRENT_BINARY_DIR}
--buildtype=$<IF:$<BOOL:${LL_GENERATOR_IS_MULTI_CONFIG}>,$<CONFIG>,${CMAKE_BUILD_TYPE}>
"--channel=${VIEWER_CHANNEL}"
--configuration=$<CONFIG>
--dest=${LOCAL_DIST_DIR}
--grid=${GRID}
--source=${CMAKE_CURRENT_SOURCE_DIR}
--versionfile=${CMAKE_CURRENT_BINARY_DIR}/viewer_version.txt
--touch=${LOCAL_DIST_DIR}/.${product}.copy_touched
--viewer_flavor=${ND_VIEWER_FLAVOR}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
stage_third_party_libs
llwebrtc
${CMAKE_CURRENT_BINARY_DIR}/viewer_version.txt
${COPY_INPUT_DEPENDENCIES}
${VIEWER_BINARY_NAME}
COMMENT "Performing viewer_manifest local dist copy"
)
add_custom_target(copy_local_dist_viewer_manifest ALL DEPENDS ${LOCAL_DIST_DIR}/.${product}.copy_touched)
elseif (NOT LOCAL_DIST_DIR STREQUAL "")
message(FATAL_ERROR "LOCAL_DIST_DIR ${LOCAL_DIST_DIR} specified but is not valid target directory to copy viewer distribution into. Please create the directory and try again")
endif () # IS_DIRECTORY ${LOCAL_DIST_DIR}
if (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts)
add_dependencies(${VIEWER_BINARY_NAME} copy_win_scripts)
endif (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts)

View File

@ -99,6 +99,7 @@
<string>RenderUnloadedAvatar</string>
<string>RenderUseStreamVBO</string>
<string>RenderVBOEnable</string>
<string>RenderVintageMode</string>
<string>RenderVSyncEnable</string>
<string>RenderVolumeLODFactor</string>
<string>RenderWaterRefResolution</string>

View File

@ -11141,6 +11141,17 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>0</integer>
</map>
<key>RenderEnableEmissiveBuffer</key>
<map>
<key>Comment</key>
<string>Enable emissive buffer in gbuffer. Should only be disabled in GL3 mode.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>RenderHDRIExposure</key>
<map>
<key>Comment</key>
@ -11188,7 +11199,7 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>RenderMaxOpenGLVersion</key>
<map>
<key>Comment</key>
<string>Maximum OpenGL version to attempt use (minimum 3.2 maximum 4.6). Requires restart.</string>
<string>Maximum OpenGL version to attempt use (minimum 3.1 maximum 4.6). Requires restart.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@ -12780,14 +12791,25 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>RenderSkySunlightScale</key>
<map>
<key>Comment</key>
<string>Sunlight scale fudge factor for matching with pre-PBR viewer</string>
<string>Sunlight scale fudge factor for matching with pre-PBR viewer when HDR is disabled</string>
<key>Persist</key>
<integer>1</integer>
<integer>0</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>1.0</real>
</map>
<key>RenderHDRSkySunlightScale</key>
<map>
<key>Comment</key>
<string>Sunlight scale fudge factor for matching with pre-PBR viewer when HDR is enabled</string>
<key>Persist</key>
<integer>0</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>1.0</real>
</map>
<key>RenderSkyAmbientScale</key>
<map>
<key>Comment</key>
@ -12797,7 +12819,7 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.7</real>
<real>1.0</real>
</map>
<key>RenderReflectionProbeMaxLocalLightAmbiance</key>
@ -23197,6 +23219,17 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>1</integer>
</map>
<key>RenderVintageMode</key>
<map>
<key>Comment</key>
<string>Disable different rendering pipeline features to improve performance on older machines that makes the world look closer to how it used to prior to V7.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>FSNetMapPhantomOpacity</key>
<map>

View File

@ -36,7 +36,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -52,7 +52,10 @@ void main()
frag_data[0] = vec4(diff.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -40,7 +40,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -52,18 +52,21 @@ void main()
{
discard;
}
col *= vertex_color;
col *= vertex_color;
vec3 norm = texture(bumpMap, vary_texcoord0.xy).rgb * 2.0 - 1.0;
vec3 norm = texture(bumpMap, vary_texcoord0.xy).rgb * 2.0 - 1.0;
vec3 tnorm = vec3(dot(norm,vary_mat0),
dot(norm,vary_mat1),
dot(norm,vary_mat2));
vec3 tnorm = vec3(dot(norm,vary_mat0),
dot(norm,vary_mat1),
dot(norm,vary_mat2));
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(tnorm);
frag_data[2] = encodeNormal(nvn, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(tnorm);
frag_data[2] = encodeNormal(nvn, vertex_color.a, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0, 0, 0, 0);
#endif
}

View File

@ -114,9 +114,15 @@ void main()
color.rgb *= 2.0;
/// Gamma correct for WL (soft clip effect).
frag_data[0] = vec4(0);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0,0,0,GBUFFER_FLAG_SKIP_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[0] = vec4(0);
frag_data[3] = vec4(color.rgb, alpha1);
#else
frag_data[0] = vec4(color.rgb, alpha1);
#endif
}

View File

@ -48,8 +48,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
uniform sampler2D normalMap;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform sampler2D depthMap;
uniform sampler2D projectionMap; // rgba
uniform sampler2D brdfLut;
@ -62,6 +62,8 @@ 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_ambiance;
uniform int classic_mode;
// light params
uniform vec3 color; // light_color
uniform float size; // light_size
@ -73,11 +75,11 @@ const float M_PI = 3.14159265;
const float ONE_OVER_PI = 0.3183098861;
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cs);
vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
vec4 decodeNormal(vec4 norm);
float calcLegacyDistanceAttenuation(float distance, float falloff)
{
float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0);
@ -152,6 +154,12 @@ vec4 getNorm(vec2 screenpos)
return norm;
}
vec4 getNormRaw(vec2 screenpos)
{
vec4 norm = texture(normalMap, screenpos.xy);
return norm;
}
// get linear depth value given a depth buffer sample d and znear and zfar values
float linearDepth(float d, float znear, float zfar)
{
@ -352,13 +360,15 @@ vec2 BRDF(float NoV, float roughness)
}
// set colorDiffuse and colorSpec to the results of GLTF PBR style IBL
vec3 pbrIbl(vec3 diffuseColor,
void pbrIbl(vec3 diffuseColor,
vec3 specularColor,
vec3 radiance, // radiance map sample
vec3 irradiance, // irradiance map sample
float ao, // ambient occlusion factor
float nv, // normal dot view vector
float perceptualRough)
float perceptualRough,
out vec3 diffuseOut,
out vec3 specularOut)
{
// retrieve a scale and bias to F0. See [1], Figure 3
vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0-perceptualRough);
@ -368,7 +378,8 @@ vec3 pbrIbl(vec3 diffuseColor,
vec3 diffuse = diffuseLight * diffuseColor;
vec3 specular = specularLight * (specularColor * brdf.x + brdf.y);
return (diffuse + specular) * ao;
diffuseOut = diffuse * ao;
specularOut = specular * ao;
}
@ -431,12 +442,15 @@ float microfacetDistribution(PBRInfo pbrInputs)
return roughnessSq / (M_PI * f * f);
}
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l) //surface point to light
vec3 l,
out float nl,
out vec3 diff,
out vec3 spec) //surface point to light
{
// make sure specular highlights from punctual lights don't fall off of polished surfaces
perceptualRoughness = max(perceptualRoughness, 8.0/255.0);
@ -485,10 +499,11 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
// Calculation of analytical lighting contribution
vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
vec3 specContrib = F * G * D / (4.0 * NdotL * NdotV);
// Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
vec3 color = NdotL * (diffuseContrib + specContrib);
return clamp(color, vec3(0), vec3(10));
nl = NdotL;
diff = diffuseContrib;
spec = specContrib;
}
vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
@ -522,7 +537,12 @@ vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
vec3 intensity = spot_atten * dist_atten * lightColor * 3.0; //magic number to balance with legacy materials
color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
float nl = 0;
vec3 diffPunc = vec3(0);
vec3 specPunc = vec3(0);
pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, nl, diffPunc, specPunc);
color = intensity * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
return color;
@ -541,10 +561,44 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v,
vec3 color = vec3(0);
float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0);
vec3 iblDiff = vec3(0);
vec3 iblSpec = vec3(0);
pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness, iblDiff, iblSpec);
color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness);
color += iblDiff;
color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir)) * sunlit * 3.0 * scol; //magic number to balance with legacy materials
// For classic mode, we use a special version of pbrPunctual that basically gives us a deconstructed form of the lighting.
float nl = 0;
vec3 diffPunc = vec3(0);
vec3 specPunc = vec3(0);
pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), nl, diffPunc, specPunc);
// Depending on the sky, we combine these differently.
if (classic_mode > 0)
{
// Reconstruct the diffuse lighting that we do for blinn-phong materials here.
// A special note about why we do some really janky stuff for classic mode.
// Since adding classic mode, we've moved the lambertian diffuse multiply out from pbrPunctual and instead handle it in the different light type calcs.
// For classic mode, this baiscally introduces a double multiplication that we need to somehow avoid
// Using one of the old mobile gamma correction tricks (val * val to "linearize", sqrt(val) to bring back into sRGB), we can _mostly_ avert this
// This will never be 100% correct, but at the very least we can make it look mostly correct with legacy skies and classic mode.
float da = pow(sqrt(nl), 1.2);
vec3 sun_contrib = vec3(min(da, scol));
// Multiply by PI to account for lambertian diffuse colors. Otherwise things will be too dark when lit by the sun on legacy skies.
sun_contrib = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit * 0.7) * M_PI;
// Manually recombine everything here. We have to separate the shading to ensure that lighting is able to more closely match blinn-phong.
color.rgb = srgb_to_linear(iblDiff) + clamp(sun_contrib * (da * (diffPunc.rgb + specPunc.rgb) * scol), vec3(0), vec3(10));
}
else
{
color += clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10)) * sunlit * 3.0 * scol;
}
color.rgb += iblSpec.rgb;
color += colorEmissive;

View File

@ -39,7 +39,7 @@ in vec2 vary_texcoord0;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -55,7 +55,10 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -36,7 +36,7 @@ in vec4 vertex_color;
in vec2 vary_texcoord0;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -52,6 +52,9 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -33,7 +33,7 @@ uniform sampler2D diffuseMap;
in vec3 vary_normal;
in vec2 vary_texcoord0;
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -47,7 +47,10 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -35,7 +35,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -44,7 +44,10 @@ void main()
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
frag_data[2] = encodeNormal(nvn.xyz, vertex_color.a, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0, 0, 0, 0);
#endif
}

View File

@ -33,7 +33,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
vec3 linear_to_srgb(vec3 c);
@ -48,6 +48,9 @@ void main()
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vec4(spec, vertex_color.a); // spec
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
frag_data[2] = encodeNormal(nvn.xyz, vertex_color.a, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0, 0, 0, 0);
#endif
}

View File

@ -35,7 +35,8 @@ uniform sampler2D exposureMap;
uniform float dt;
uniform vec2 noiseVec;
uniform vec3 dynamic_exposure_params;
uniform vec4 dynamic_exposure_params;
uniform vec4 dynamic_exposure_params2;
float lum(vec3 col)
{
@ -53,11 +54,11 @@ void main()
L /= max_L;
L = pow(L, 2.0);
float s = mix(dynamic_exposure_params.z, dynamic_exposure_params.y, L);
#ifdef USE_LAST_EXPOSURE
float prev = texture(exposureMap, vec2(0.5,0.5)).r;
s = mix(prev, s, min(dt*2.0*abs(prev-s), 0.04));
float speed = -log(dynamic_exposure_params.w) / dynamic_exposure_params2.w;
s = mix(prev, s, 1 - exp(-speed * dt));
#endif
frag_color = max(vec4(s, s, s, dt), vec4(0.0));

View File

@ -0,0 +1,59 @@
/**
* @file class1/deferred/gbufferUtil.glsl
*
* $LicenseInfo:firstyear=2024&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 diffuseRect;
uniform sampler2D specularRect;
#if defined(HAS_EMISSIVE)
uniform sampler2D emissiveRect;
#endif
vec4 getNormRaw(vec2 screenpos);
vec4 decodeNormal(vec4 norm);
GBufferInfo getGBuffer(vec2 screenpos)
{
GBufferInfo ret;
vec4 diffInfo = vec4(0);
vec4 specInfo = vec4(0);
vec4 emissInfo = vec4(0);
diffInfo = texture(diffuseRect, screenpos.xy);
specInfo = texture(specularRect, screenpos.xy);
vec4 normInfo = getNormRaw(screenpos);
#if defined(HAS_EMISSIVE)
emissInfo = texture(emissiveRect, screenpos.xy);
#endif
ret.albedo = diffInfo;
ret.normal = decodeNormal(normInfo).xyz;
ret.specular = specInfo;
ret.envIntensity = normInfo.b;
ret.gbufferFlag = normInfo.w;
ret.emissive = emissInfo;
return ret;
}

View File

@ -43,15 +43,19 @@ void mirrorClip(vec3 pos)
}
}
vec4 encodeNormal(vec3 norm, float gbuffer_flag)
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag)
{
return vec4(norm * 0.5 + 0.5, gbuffer_flag);
float f = sqrt(8 * n.z + 8);
return vec4(n.xy / f + 0.5, env, gbuffer_flag);
}
vec4 decodeNormal(vec4 norm)
{
norm.xyz = norm.xyz * 2.0 - 1.0;
return norm;
vec2 fenc = norm.xy*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4);
vec4 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}

View File

@ -35,5 +35,8 @@ void main()
frag_data[0] = color*texture(diffuseMap, vary_texcoord0.xy);
frag_data[1] = vec4(0.0);
frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -38,7 +38,7 @@ in vec2 vary_texcoord0;
vec3 linear_to_srgb(vec3 c);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -55,5 +55,8 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = spec;
frag_data[2] = vec4(norm.xyz, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -51,8 +51,8 @@ void main()
vec4 norm = texture(normalMap, tc);
if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI) &&
!GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS))
if (!GET_GBUFFER_FLAG(norm.w, GBUFFER_FLAG_HAS_HDRI) &&
!GET_GBUFFER_FLAG(norm.w, GBUFFER_FLAG_SKIP_ATMOS))
{
// Apply the diffuse luminance scale to objects but not the sky
// Prevents underexposing when looking at bright environments

View File

@ -44,7 +44,9 @@ void main()
frag_data[0] = vec4(0.5, 0, 1, 0); // gbuffer is sRGB for legacy materials
frag_data[1] = vec4(0); // XYZ = Specular color. W = Specular exponent.
frag_data[2] = vec4(0); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
#endif
}

View File

@ -56,7 +56,13 @@ void main()
frag_data[0] = vec4(0);
frag_data[1] = vec4(0.0);
frag_data[2] = vec4(0.0, 0.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[0] = vec4(0);
frag_data[3] = vec4(c.rgb, c.a);
#else
frag_data[0] = vec4(c.rgb, c.a);
#endif
// Added and commented out for a ground truth. Do not uncomment - Geenz
//gl_FragDepth = 0.999985f;

View File

@ -61,7 +61,7 @@ uniform vec4 clipPlane;
uniform float clipSign;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
uniform mat3 normal_matrix;
@ -114,8 +114,11 @@ void main()
// See: C++: addDeferredAttachments(), GLSL: softenLightF
frag_data[0] = max(vec4(col, 0.0), vec4(0)); // Diffuse
frag_data[1] = max(vec4(spec.rgb,0.0), vec4(0)); // PBR linear packed Occlusion, Roughness, Metal.
frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags
frag_data[2] = encodeNormal(tnorm, 0, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags
#if defined(HAS_EMISSIVE)
frag_data[3] = max(vec4(emissive,0), vec4(0)); // PBR sRGB Emissive
#endif
}
#else

View File

@ -162,7 +162,7 @@ in vec4[2] vary_coords;
#endif
void mirrorClip(vec3 position);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
float terrain_mix(TerrainMix tm, vec4 tms4);
@ -430,7 +430,10 @@ void main()
#endif
frag_data[0] = max(vec4(pbr_mix.col.xyz, 0.0), vec4(0)); // Diffuse
frag_data[1] = max(vec4(mix_orm.rgb, base_color_factor_alpha), vec4(0)); // PBR linear packed Occlusion, Roughness, Metal.
frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, flags
frag_data[2] = encodeNormal(tnorm, 0, GBUFFER_FLAG_HAS_PBR); // normal, flags
#if defined(HAS_EMISSIVE)
frag_data[3] = max(vec4(mix_emissive,0), vec4(0)); // PBR sRGB Emissive
#endif
}

View File

@ -117,8 +117,13 @@ void main()
frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_SKIP_ATMOS);
}
frag_data[0] = vec4(0);
frag_data[1] = vec4(0);
#if defined(HAS_EMISSIVE)
frag_data[0] = vec4(0);
frag_data[3] = vec4(color.rgb, 1.0);
#else
frag_data[0] = vec4(color.rgb, 1.0);
#endif
}

View File

@ -58,9 +58,14 @@ void main()
col.a = (col.a * factor) * 32.0f;
col.a *= twinkle();
frag_data[0] = vec4(0);
frag_data[1] = vec4(0.0f);
frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[0] = vec4(0);
frag_data[3] = col;
#else
frag_data[0] = col;
#endif
}

View File

@ -48,6 +48,11 @@ void main()
frag_data[0] = vec4(0);
frag_data[1] = vec4(0.0f);
frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[0] = vec4(0);
frag_data[3] = c;
#else
frag_data[0] = c;
#endif
}

View File

@ -39,7 +39,7 @@ in vec4 vary_texcoord0;
in vec4 vary_texcoord1;
void mirrorClip(vec3 position);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -61,7 +61,10 @@ void main()
frag_data[0] = max(outColor, vec4(0));
frag_data[1] = vec4(0.0,0.0,0.0,-1.0);
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -37,7 +37,7 @@ in vec3 vary_position;
uniform float minimum_alpha;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@ -51,6 +51,9 @@ void main()
frag_data[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
}

View File

@ -64,7 +64,7 @@ in vec2 base_color_uv;
in vec2 emissive_uv;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
@ -243,8 +243,11 @@ void main()
#else
frag_data[0] = max(vec4(basecolor.rgb, 0.0), vec4(0));
frag_data[1] = max(vec4(orm.rgb,0.0), vec4(0));
frag_data[2] = encodeNormal(norm, GBUFFER_FLAG_HAS_PBR);
frag_data[2] = encodeNormal(norm, 0, GBUFFER_FLAG_HAS_PBR);
//#if defined(HAS_EMISSIVE)
frag_data[3] = max(vec4(emissive,0), vec4(0));
//#endif
#endif
#endif

View File

@ -197,7 +197,7 @@ out vec3 vary_fragcoord;
layout (std140) uniform GLTFJoints
{
mat3x4 gltf_joints[MAX_NODES_PER_GLTF_OBJECT];
vec4 gltf_joints[MAX_NODES_PER_GLTF_OBJECT];
};
@ -210,27 +210,22 @@ mat4 getGLTFTransform()
vec4 w = weight4;
uint i1 = joint.x;
uint i2 = joint.y;
uint i3 = joint.z;
uint i4 = joint.w;
uint i1 = joint.x*3u;
uint i2 = joint.y*3u;
uint i3 = joint.z*3u;
uint i4 = joint.w*3u;
mat3 mat = mat3(gltf_joints[i1])*w.x;
mat += mat3(gltf_joints[i2])*w.y;
mat += mat3(gltf_joints[i3])*w.z;
mat += mat3(gltf_joints[i4])*w.w;
vec3 trans = vec3(gltf_joints[i1][0].w,gltf_joints[i1][1].w,gltf_joints[i1][2].w)*w.x;
trans += vec3(gltf_joints[i2][0].w,gltf_joints[i2][1].w,gltf_joints[i2][2].w)*w.y;
trans += vec3(gltf_joints[i3][0].w,gltf_joints[i3][1].w,gltf_joints[i3][2].w)*w.z;
trans += vec3(gltf_joints[i4][0].w,gltf_joints[i4][1].w,gltf_joints[i4][2].w)*w.w;
// lerp the joints
vec4 v0 = gltf_joints[i1+0u] * w.x + gltf_joints[i2+0u] * w.y + gltf_joints[i3+0u] * w.z + gltf_joints[i4+0u] * w.w;
vec4 v1 = gltf_joints[i1+1u] * w.x + gltf_joints[i2+1u] * w.y + gltf_joints[i3+1u] * w.z + gltf_joints[i4+1u] * w.w;
vec4 v2 = gltf_joints[i1+2u] * w.x + gltf_joints[i2+2u] * w.y + gltf_joints[i3+2u] * w.z + gltf_joints[i4+2u] * w.w;
//unpack into return matrix
mat4 ret;
ret[0] = vec4(mat[0], 0);
ret[1] = vec4(mat[1], 0);
ret[2] = vec4(mat[2], 0);
ret[3] = vec4(trans, 1.0);
ret[0] = vec4(v0.xyz, 0);
ret[1] = vec4(v1.xyz, 0);
ret[2] = vec4(v2.xyz, 0);
ret[3] = vec4(v0.w, v1.w, v2.w, 1.0);
return ret;
}
@ -239,7 +234,7 @@ mat4 getGLTFTransform()
layout (std140) uniform GLTFNodes
{
mat3x4 gltf_nodes[MAX_NODES_PER_GLTF_OBJECT];
vec4 gltf_nodes[MAX_NODES_PER_GLTF_OBJECT];
};
uniform int gltf_node_id = 0;
@ -247,13 +242,17 @@ uniform int gltf_node_id = 0;
mat4 getGLTFTransform()
{
mat4 ret;
mat3x4 src = gltf_nodes[gltf_node_id];
int idx = gltf_node_id*3;
ret[0] = vec4(src[0].xyz, 0);
ret[1] = vec4(src[1].xyz, 0);
ret[2] = vec4(src[2].xyz, 0);
vec4 src0 = gltf_nodes[idx+0];
vec4 src1 = gltf_nodes[idx+1];
vec4 src2 = gltf_nodes[idx+2];
ret[3] = vec4(src[0].w, src[1].w, src[2].w, 1);
ret[0] = vec4(src0.xyz, 0);
ret[1] = vec4(src1.xyz, 0);
ret[2] = vec4(src2.xyz, 0);
ret[3] = vec4(src0.w, src1.w, src2.w, 1);
return ret;
}

View File

@ -31,5 +31,8 @@ void main()
frag_data[0] = vec4(0, 0, 0, 0);
frag_data[1] = vec4(0, 0, 0, 0);
frag_data[2] = vec4(1, 0, 0, GBUFFER_FLAG_HAS_PBR);
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(1, 0, 0, 0);
#endif
}

View File

@ -41,6 +41,7 @@ uniform float scene_light_strength;
uniform float sun_moon_glow_factor;
uniform float sky_sunlight_scale;
uniform float sky_ambient_scale;
uniform int classic_mode;
float getAmbientClamp() { return 1.0f; }
@ -121,7 +122,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
// brightness of surface both sunlight and ambient
sunlit = sunlight.rgb;
amblit = tmpAmbient;
amblit = pow(tmpAmbient.rgb, vec3(0.9)) * 0.57;
additive *= vec3(1.0 - combined_haze);
@ -142,18 +143,22 @@ float ambientLighting(vec3 norm, vec3 light_dir)
return ambient;
}
// return lit amblit in linear space, leave sunlit and additive in sRGB space
void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 additive,
out vec3 atten)
{
calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten);
amblit *= ambientLighting(norm, light_dir);
if (classic_mode < 1)
{
amblit = srgb_to_linear(amblit);
sunlit = srgb_to_linear(sunlit);
}
// multiply to get similar colors as when the "scaleSoftClip" implementation was doubling color values
// (allows for mixing of light sources other than sunlight e.g. reflection probes)
sunlit *= sky_sunlight_scale;
amblit *= sky_ambient_scale;
amblit = srgb_to_linear(amblit);
amblit *= ambientLighting(norm, light_dir);
}

View File

@ -36,6 +36,7 @@ out vec4 frag_color;
uniform mat3 env_mat;
uniform vec3 sun_dir;
uniform vec3 moon_dir;
uniform int classic_mode;
#ifdef USE_DIFFUSE_TEX
uniform sampler2D diffuseMap;
@ -241,10 +242,10 @@ void main()
calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten);
vec3 sunlit_linear = srgb_to_linear(sunlit);
vec3 sunlit_linear = sunlit;
vec3 amblit_linear = amblit;
vec3 irradiance;
vec3 irradiance = amblit;
vec3 glossenv;
vec3 legacyenv;
sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, frag, pos.xyz, norm.xyz, 0.0, 0.0, true, amblit_linear);
@ -260,11 +261,20 @@ void main()
color.a = final_alpha;
vec3 sun_contrib = min(final_da, shadow) * sunlit_linear;
color.rgb = irradiance;
if (classic_mode > 0)
{
final_da = pow(final_da,1.2);
vec3 sun_contrib = vec3(min(final_da, shadow));
color.rgb += sun_contrib;
color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7);
sunlit_linear = srgb_to_linear(sunlit_linear);
}
else
{
vec3 sun_contrib = min(final_da, shadow) * sunlit_linear;
color.rgb += sun_contrib;
}
color.rgb *= diffuse_linear.rgb;

View File

@ -111,13 +111,6 @@ vec3 pbrBaseLight(vec3 diffuseColor,
vec3 additive,
vec3 atten);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l); //surface point to light
vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
@ -168,7 +161,7 @@ void main()
vec3 atten;
calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten);
vec3 sunlit_linear = srgb_to_linear(sunlit);
vec3 sunlit_linear = sunlit;
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
@ -189,7 +182,7 @@ void main()
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
vec3 irradiance = vec3(0);
vec3 irradiance = amblit;
vec3 radiance = vec3(0);
sampleReflectionProbes(irradiance, radiance, vary_position.xy*0.5+0.5, pos.xyz, norm.xyz, gloss, true, amblit);

View File

@ -32,11 +32,12 @@ uniform samplerCube environmentMap;
uniform mat3 env_mat;
vec3 srgb_to_linear(vec3 c);
vec3 linear_to_srgb(vec3 c);
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear)
{
ambenv = vec3(reflection_probe_ambiance * 0.25);
ambenv = mix(ambenv, vec3(reflection_probe_ambiance * 0.25), reflection_probe_ambiance);
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
vec3 env_vec = env_mat * refnormpersp;
@ -58,12 +59,12 @@ vec4 sampleReflectionProbesDebug(vec3 pos)
void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear)
{
ambenv = vec3(reflection_probe_ambiance * 0.25);
ambenv = mix(ambenv, vec3(reflection_probe_ambiance * 0.25), reflection_probe_ambiance);
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
vec3 env_vec = env_mat * refnormpersp;
legacyenv = srgb_to_linear(texture(environmentMap, env_vec).rgb);
legacyenv = texture(environmentMap, env_vec).rgb;
glossenv = legacyenv;
}
@ -75,6 +76,6 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no
void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity)
{
color = mix(color.rgb, legacyenv*1.5, envIntensity);
color = srgb_to_linear(mix(linear_to_srgb(color.rgb), legacyenv*2.0, envIntensity));
}

View File

@ -64,8 +64,6 @@ void main()
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
vec3 sunlit_linear = srgb_to_linear(sunlit);
// mask off atmospherics below water (when camera is under water)
bool do_atmospherics = false;

View File

@ -36,6 +36,7 @@
uniform float emissive_brightness; // fullbright flag, 1.0 == fullbright, 0.0 otherwise
uniform int sun_up_factor;
uniform int classic_mode;
vec4 applySkyAndWaterFog(vec3 pos, vec3 additive, vec3 atten, vec4 color);
vec3 scaleSoftClipFragLinear(vec3 l);
@ -51,7 +52,7 @@ uniform mat3 normal_matrix;
in vec3 vary_position;
void mirrorClip(vec3 pos);
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
@ -329,10 +330,10 @@ void main()
vec3 atten;
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
vec3 sunlit_linear = srgb_to_linear(sunlit);
vec3 sunlit_linear = sunlit;
vec3 amblit_linear = amblit;
vec3 ambenv;
vec3 ambenv = amblit;
vec3 glossenv;
vec3 legacyenv;
sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xy*0.5+0.5, pos.xyz, norm.xyz, glossiness, env, true, amblit_linear);
@ -340,8 +341,20 @@ void main()
color = ambenv;
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
vec3 sun_contrib = min(da, shadow) * sunlit_linear;
color.rgb += sun_contrib;
if (classic_mode > 0)
{
da = pow(da,1.2);
vec3 sun_contrib = vec3(min(da, shadow));
color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7);
sunlit_linear = srgb_to_linear(sunlit_linear);
}
else
{
vec3 sun_contrib = min(da, shadow) * sunlit_linear;
color.rgb += sun_contrib;
}
color *= diffcol.rgb;
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
@ -415,8 +428,11 @@ void main()
frag_data[0] = max(vec4(diffcol.rgb, emissive), vec4(0)); // gbuffer is sRGB for legacy materials
frag_data[1] = max(vec4(spec.rgb, glossiness), vec4(0)); // XYZ = Specular color. W = Specular exponent.
frag_data[2] = encodeNormal(norm, flag); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
frag_data[3] = vec4(env, 0, 0, 0);
frag_data[2] = encodeNormal(norm, env, flag); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0, 0, 0, 0);
#endif
#endif
}

View File

@ -27,9 +27,6 @@
out vec4 frag_color;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D lightFunc;
uniform vec3 env_mat[3];
@ -55,13 +52,17 @@ vec3 srgb_to_linear(vec3 c);
// Util
vec3 hue_to_rgb(float hue);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l); //surface point to light
vec3 l, // surface point to light
out float nl,
out vec3 diff,
out vec3 spec);
GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
@ -73,18 +74,19 @@ void main()
discard;
}
vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG()
vec3 n = norm.xyz;
GBufferInfo gb = getGBuffer(tc);
vec4 spec = texture(specularRect, tc);
vec3 diffuse = texture(diffuseRect, tc).rgb;
vec3 n = gb.normal;
vec4 spec = gb.specular;
vec3 diffuse = gb.albedo.rgb;
vec3 h, l, v = -normalize(pos);
float nh, nv, vh, lightDist;
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 colorEmissive = texture(emissiveRect, tc).rgb;
vec3 colorEmissive = gb.emissive.rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
@ -113,8 +115,11 @@ void main()
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
vec3 intensity = dist_atten * lightColor * 3.25;
final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
float nl = 0;
vec3 diff = vec3(0);
vec3 specPunc = vec3(0);
pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, nl, diff, specPunc);
final_color += intensity * clamp(nl * (diff + specPunc), vec3(0), vec3(10));
}
}
}

View File

@ -27,9 +27,6 @@
out vec4 frag_color;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D lightFunc;
uniform vec3 env_mat[3];
@ -57,24 +54,29 @@ vec2 getScreenCoord(vec4 clip);
vec3 srgb_to_linear(vec3 c);
float getDepth(vec2 tc);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l); //surface point to light
vec3 l, // surface point to light
out float nl,
out vec3 diff,
out vec3 spec);
GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
vec3 final_color = vec3(0);
vec2 tc = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
GBufferInfo gb = getGBuffer(tc);
vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG()
vec3 n = norm.xyz;
vec3 n = gb.normal;
vec3 diffuse = texture(diffuseRect, tc).rgb;
vec4 spec = texture(specularRect, tc);
vec3 diffuse = gb.albedo.rgb;
vec4 spec = gb.specular;
// Common half vectors calcs
vec3 lv = trans_center.xyz-pos;
@ -89,9 +91,9 @@ void main()
float dist = lightDist / size;
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 colorEmissive = texture(emissiveRect, tc).rgb;
vec3 colorEmissive = gb.emissive.rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
@ -104,7 +106,14 @@ void main()
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
vec3 intensity = dist_atten * color * 3.25; // Legacy attenuation, magic number to balance with legacy materials
final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv));
float nl = 0;
vec3 diffPunc = vec3(0);
vec3 specPunc = vec3(0);
pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
final_color += intensity* clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
else
{

View File

@ -66,7 +66,7 @@ void main()
vec4 fcol = texture(diffuseMap, tc);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
if (GET_GBUFFER_FLAG(norm.w, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = specCol.rgb;
float perceptualRoughness = orm.g;

View File

@ -23,16 +23,12 @@
* $/LicenseInfo$
*/
/*[EXTRA_CODE_HERE]*/
#define FLT_MAX 3.402823466e+38
out vec4 frag_color;
vec4 decodeNormal(vec4 norm);
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
const float M_PI = 3.14159265;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
@ -56,6 +52,8 @@ uniform mat3 ssao_effect_mat;
uniform vec3 sun_dir;
uniform vec3 moon_dir;
uniform int sun_up_factor;
uniform int classic_mode;
in vec2 vary_fragcoord;
uniform mat4 inv_proj;
@ -105,13 +103,7 @@ vec3 pbrBaseLight(vec3 diffuseColor,
vec3 additive,
vec3 atten);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l); //surface point to light
GBufferInfo getGBuffer(vec2 screenpos);
void adjustIrradiance(inout vec3 irradiance, float ambocc)
{
@ -128,13 +120,15 @@ void main()
vec2 tc = vary_fragcoord.xy;
float depth = getDepth(tc.xy);
vec4 pos = getPositionWithDepth(tc, depth);
vec4 norm = getNorm(tc);
vec3 colorEmissive = texture(emissiveRect, tc).rgb;
float envIntensity = colorEmissive.r;
GBufferInfo gb = getGBuffer(tc);
vec3 colorEmissive = gb.emissive.rgb;
float envIntensity = gb.envIntensity;
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
vec4 baseColor = texture(diffuseRect, tc);
vec4 spec = texture(specularRect, tc); // NOTE: PBR linear Emissive
vec4 baseColor = gb.albedo;
vec4 spec = gb.specular; // NOTE: PBR linear Emissive
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
vec2 scol_ambocc = texture(lightMap, vary_fragcoord.xy).rg;
@ -159,26 +153,26 @@ void main()
vec3 additive;
vec3 atten;
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
calcAtmosphericVarsLinear(pos.xyz, gb.normal, light_dir, sunlit, amblit, additive, atten);
vec3 sunlit_linear = srgb_to_linear(sunlit);
vec3 sunlit_linear = sunlit;
vec3 amblit_linear = amblit;
vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
float ao = orm.r;
vec3 irradiance = amblit_linear;
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear);
sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, gb.normal, gloss, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
@ -187,17 +181,21 @@ void main()
calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor);
vec3 v = -normalize(pos.xyz);
color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
color = pbrBaseLight(diffuseColor, specularColor, metallic, v, gb.normal, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
}
else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI))
else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_HDRI))
{
// actual HDRI sky, just copy color value
color = colorEmissive.rgb;
}
else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS))
else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_SKIP_ATMOS))
{
//should only be true of WL sky, port over base color value and scale for fake HDR
#if defined(HAS_EMISSIVE)
color = colorEmissive.rgb;
#else
color = baseColor.rgb;
#endif
color = srgb_to_linear(color);
color *= sky_hdr_scale;
}
@ -208,31 +206,43 @@ void main()
spec.rgb = srgb_to_linear(spec.rgb);
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
float da = clamp(dot(gb.normal, light_dir.xyz), 0.0, 1.0);
vec3 irradiance = vec3(0);
vec3 irradiance = amblit;
vec3 glossenv = vec3(0);
vec3 legacyenv = vec3(0);
sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear);
sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, gb.normal, spec.a, envIntensity, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
// apply lambertian IBL only (see pbrIbl)
color.rgb = irradiance;
vec3 sun_contrib = min(da, scol) * sunlit_linear;
color.rgb += sun_contrib;
if (classic_mode > 0)
{
da = pow(da,1.2);
vec3 sun_contrib = vec3(min(da, scol));
color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7);
sunlit_linear = srgb_to_linear(sunlit_linear);
}
else
{
vec3 sun_contrib = min(da, scol) * sunlit_linear;
color.rgb += sun_contrib;
}
color.rgb *= baseColor.rgb;
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
vec3 refnormpersp = reflect(pos.xyz, gb.normal);
if (spec.a > 0.0)
{
vec3 lv = light_dir.xyz;
vec3 h, l, v = -normalize(pos.xyz);
float nh, nl, nv, vh, lightDist;
vec3 n = norm.xyz;
vec3 n = gb.normal;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
if (nl > 0.0 && nh > 0.0)
@ -249,7 +259,7 @@ void main()
}
// add radiance map
applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz);
applyGlossEnv(color, glossenv, spec, pos.xyz, gb.normal);
}
@ -257,10 +267,11 @@ void main()
if (envIntensity > 0.0)
{ // add environment map
applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
applyLegacyEnv(color, legacyenv, spec, pos.xyz, gb.normal, envIntensity);
}
}
//color.r = classic_mode > 0 ? 1.0 : 0.0;
frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results
frag_color.a = 0.0;
}

View File

@ -27,9 +27,6 @@
out vec4 frag_color;
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform samplerCube environmentMap;
uniform sampler2D lightMap;
uniform sampler2D lightFunc;
@ -80,12 +77,17 @@ vec4 getPosition(vec2 pos_screen);
const float M_PI = 3.14159265;
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l); //surface point to light
vec3 l, // surface point to light
out float nl,
out vec3 diff,
out vec3 spec);
GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
@ -118,8 +120,9 @@ void main()
shadow = clamp(shadow, 0.0, 1.0);
}
vec4 norm = getNorm(tc);
vec3 n = norm.xyz;
GBufferInfo gb = getGBuffer(tc);
vec3 n = gb.normal;
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
if (dist_atten <= 0.0)
@ -132,14 +135,14 @@ void main()
float nh, nl, nv, vh, lightDist;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
vec3 diffuse = texture(diffuseRect, tc).rgb;
vec4 spec = texture(specularRect, tc);
vec3 diffuse = gb.albedo.rgb;
vec4 spec = gb.specular;
vec3 dlit = vec3(0, 0, 0);
vec3 slit = vec3(0, 0, 0);
vec3 amb_rgb = vec3(0);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
@ -151,6 +154,8 @@ void main()
diffuseColor *= 1.0 - metallic;
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
vec3 diffPunc = vec3(0);
vec3 specPunc = vec3(0);
// We need this additional test inside a light's frustum since a spotlight's ambiance can be applied
if (proj_tc.x > 0.0 && proj_tc.x < 1.0
@ -168,16 +173,21 @@ void main()
dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
vec3 intensity = dist_atten * dlit * 3.25 * shadow; // Legacy attenuation, magic number to balance with legacy materials
final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
final_color += intensity * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy ) * 3.25; //magic number to balance with legacy ambiance
final_color += amb_rgb * pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, -lv);
pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
final_color += amb_rgb * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
}
else
{
float envIntensity = texture(emissiveRect, tc).r;
float envIntensity = gb.envIntensity;
diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb);

View File

@ -42,20 +42,25 @@ vec2 BRDF(float NoV, float roughness);
void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor);
vec3 pbrIbl(vec3 diffuseColor,
void pbrIbl(vec3 diffuseColor,
vec3 specularColor,
vec3 radiance, // radiance map sample
vec3 irradiance, // irradiance map sample
float ao, // ambient occlusion factor
float nv, // normal dot view vector
float perceptualRoughness);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l); //surface point to light
out vec3 diffuse,
out vec3 specular);
void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
vec3 l, // surface point to light
out float nl,
out vec3 diff,
out vec3 spec);
vec3 pbrBaseLight(vec3 diffuseColor,
vec3 specularColor,
@ -257,13 +262,20 @@ void main()
float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0);
vec3 punctual = pbrPunctual(vec3(0), specularColor, 0.1, metallic, normalize(wavef+up*max(dist, 32.0)/32.0*(1.0-vdu)), v, normalize(light_dir));
float nl = 0;
vec3 diffPunc = vec3(0);
vec3 specPunc = vec3(0);
pbrPunctual(vec3(0), specularColor, 0.1, metallic, normalize(wavef+up*max(dist, 32.0)/32.0*(1.0-vdu)), v, normalize(light_dir), nl, diffPunc, specPunc);
vec3 punctual = clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
vec3 color = punctual * sunlit_linear * 2.75 * shadow;
vec3 iblDiff;
vec3 iblSpec;
pbrIbl(vec3(0), vec3(1), radiance, vec3(0), ao, NdotV, 0.0, iblDiff, iblSpec);
vec3 ibl = pbrIbl(vec3(0), vec3(1), radiance, vec3(0), ao, NdotV, 0.0);
color += ibl;
color += iblDiff + iblSpec;
float nv = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0);
vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0);

View File

@ -1,4 +1,4 @@
version 64
version 71
// 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
@ -84,6 +84,9 @@ RenderCASSharpness 1 1
RenderExposure 1 4
RenderTonemapType 1 1
RenderTonemapMix 1 1
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 1
//
// Low Graphics Settings
@ -100,7 +103,7 @@ RenderGlowResolutionPow 1 8
RenderLocalLightCount 1 8
RenderMaxPartCount 1 256
RenderTransparentWater 1 0
RenderReflectionsEnabled 1 1
RenderReflectionsEnabled 1 0
RenderReflectionProbeDetail 1 0
RenderTerrainDetail 1 0
RenderTerrainLODFactor 1 1
@ -124,6 +127,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 0
RenderHDREnabled 1 0
RenderVintageMode 1 1
//
// Medium Low Graphics Settings
@ -164,6 +170,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Medium Graphics Settings (standard)
@ -204,6 +213,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Medium High Graphics Settings
@ -244,6 +256,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// High Graphics Settings (SSAO + sun shadows)
@ -284,6 +299,9 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// High Ultra Graphics Settings (deferred + SSAO + all shadows)
@ -324,6 +342,9 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Ultra graphics (REALLY PURTY!)
@ -364,6 +385,9 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Class Unknown Hardware (unknown)
@ -372,6 +396,8 @@ list Unknown
RenderShadowDetail 1 0
RenderDeferredSSAO 1 0
RenderMirrors 1 0
RenderEnableEmissiveBuffer 1 0
RenderVintageMode 1 1
//
// VRAM > 512MB
@ -394,6 +420,7 @@ RenderDeferredSSAO 0 0
RenderShadowDetail 0 0
RenderReflectionProbeDetail 0 -1
RenderMirrors 0 0
RenderVintageMode 1 1
list Intel
RenderAnisotropic 1 0
@ -412,6 +439,11 @@ RenderFSAASamples 0 0
RenderReflectionsEnabled 0 0
RenderReflectionProbeDetail 0 0
RenderMirrors 0 0
RenderEnableEmissiveBuffer 1 0
RenderGLMultiThreadedTextures 0 0
RenderGLMultiThreadedMedia 0 0
RenderHDREnabled 1 0
RenderVintageMode 1 1
list TexUnit16orLess
RenderTerrainPBRDetail 1 -1

View File

@ -1,4 +1,4 @@
version 50
version 51
// 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
@ -84,6 +84,9 @@ RenderCASSharpness 1 1
RenderExposure 1 4
RenderTonemapType 1 1
RenderTonemapMix 1 1
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 1
//
// Low Graphics Settings
@ -100,7 +103,7 @@ RenderGlowResolutionPow 1 8
RenderLocalLightCount 1 8
RenderMaxPartCount 1 256
RenderTransparentWater 1 0
RenderReflectionsEnabled 1 1
RenderReflectionsEnabled 1 0
RenderReflectionProbeDetail 1 0
RenderTerrainDetail 1 0
RenderTerrainLODFactor 1 1
@ -124,6 +127,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 0
RenderHDREnabled 1 0
RenderVintageMode 1 1
//
// Medium Low Graphics Settings
@ -164,6 +170,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Medium Graphics Settings (standard)
@ -204,6 +213,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Medium High Graphics Settings
@ -244,6 +256,9 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// High Graphics Settings (SSAO + sun shadows)
@ -284,6 +299,9 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// High Ultra Graphics Settings (deferred + SSAO + all shadows)
@ -324,6 +342,9 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Ultra graphics (REALLY PURTY!)
@ -364,6 +385,9 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderEnableEmissiveBuffer 1 1
RenderHDREnabled 1 1
RenderVintageMode 1 0
//
// Class Unknown Hardware (unknown)
@ -372,6 +396,8 @@ list Unknown
RenderShadowDetail 1 0
RenderDeferredSSAO 1 0
RenderMirrors 1 0
RenderEnableEmissiveBuffer 1 0
RenderVintageMode 1 1
//
// VRAM > 512MB
@ -394,6 +420,7 @@ RenderDeferredSSAO 0 0
RenderShadowDetail 0 0
RenderReflectionProbeDetail 0 -1
RenderMirrors 0 0
RenderVintageMode 1 1
list Intel
RenderAnisotropic 1 0
@ -416,7 +443,11 @@ RenderFSAASamples 0 0
RenderReflectionsEnabled 0 0
RenderReflectionProbeDetail 0 0
RenderMirrors 0 0
RenderGLMultiThreadedTextures 0 0
RenderEnableEmissiveBuffer 1 0
RenderGLMultiThreadedTextures 0 0
RenderGLMultiThreadedMedia 0 0
RenderHDREnabled 1 0
RenderVintageMode 1 1
list TexUnit16orLess
RenderTerrainPBRDetail 1 -1

View File

@ -1,4 +1,4 @@
version 63
version 65
// 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
@ -83,6 +83,7 @@ RenderCASSharpness 1 1
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 1
RenderVintageMode 1 1
//
// Low Graphics Settings
@ -123,6 +124,7 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderVintageMode 1 1
//
// Medium Low Graphics Settings
@ -163,6 +165,7 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderVintageMode 1 0
//
// Medium Graphics Settings (standard)
@ -203,6 +206,7 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderVintageMode 1 0
//
// Medium High Graphics Settings
@ -243,6 +247,7 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderVintageMode 1 0
//
// High Graphics Settings (SSAO + sun shadows)
@ -283,6 +288,7 @@ RenderCASSharpness 1 0
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderVintageMode 1 0
//
// High Ultra Graphics Settings (SSAO + all shadows)
@ -323,6 +329,7 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderVintageMode 1 0
//
// Ultra graphics (REALLY PURTY!)
@ -363,6 +370,7 @@ RenderCASSharpness 1 0.4
RenderExposure 1 1
RenderTonemapType 1 1
RenderTonemapMix 1 0.7
RenderVintageMode 1 0
//
// Class Unknown Hardware (unknown)
@ -371,6 +379,7 @@ list Unknown
RenderShadowDetail 1 0
RenderDeferredSSAO 1 0
RenderMirrors 1 0
RenderVintageMode 1 1
//
@ -392,6 +401,7 @@ RenderTerrainDetail 1 0
RenderDeferredSSAO 0 0
RenderShadowDetail 0 0
RenderMirrors 0 0
RenderVintageMode 1 1
list TexUnit8orLess
RenderDeferredSSAO 0 0
@ -420,3 +430,4 @@ RenderFSAASamples 0 0
RenderReflectionProbeDetail 0 0
RenderReflectionsEnabled 0 0
RenderMirrors 0 0
RenderVintageMode 1 1

View File

@ -823,7 +823,7 @@ const F64Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f);
const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("01e41537-ff51-2f1f-8ef7-17e4df760bfb");
const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("c46226b4-0e43-5a56-9708-d27ca1df3292");
const LLUUID LLEnvironment::KNOWN_SKY_LEGACY_MIDDAY("cef49723-0292-af49-9b14-9598a616b8a3");
const LLUUID LLEnvironment::KNOWN_SKY_LEGACY_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");

View File

@ -2349,9 +2349,11 @@ bool LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius)
if (rigInfo.needsUpdate())
{
LLVOVolume* vo_volume = (LLVOVolume*)mVObjp.get();
LLVOAvatar* avatar = mVObjp->getAvatar();
const LLMeshSkinInfo* skin = vo_volume->getSkinInfo();
LLSkinningUtil::updateRiggingInfo(skin, avatar, face);
if (skin)
{
LLSkinningUtil::updateRiggingInfo(skin, avatar, face);
}
}
// calculate the world space bounding box of the face by combining the bounding boxes of all the joints

View File

@ -665,7 +665,16 @@ void LLFeatureManager::applyBaseMasks()
if (gGLManager.mIsIntel)
{
maskFeatures("Intel");
if (gGLManager.mGLVersion < 4.59f)
static constexpr F32 TARGET_GL_VERSION =
#if LL_DARWIN
4.09f;
#else
4.59f;
#endif
// check against 3.33 to avoid applying this fallback twice
if (gGLManager.mGLVersion < TARGET_GL_VERSION && gGLManager.mGLVersion > 3.33f)
{
// if we don't have OpenGL 4.6 on intel, set it to OpenGL 3.3
// we also want to trigger the GL3 fallbacks on these chipsets
@ -675,10 +684,12 @@ void LLFeatureManager::applyBaseMasks()
// https://docs.blender.org/manual/en/latest/troubleshooting/gpu/windows/intel.html#legacy-intel-hd-4000-5000
// https://www.intel.com/content/www/us/en/support/articles/000005524/graphics.html
// this will disable things like reflection probes, HDR, FXAA and SMAA
LL_INFOS("RenderInit") << "Applying Intel integrated pre-Haswell fallback. Downgrading feature usage to OpenGL 3.3" << LL_ENDL;
gGLManager.mGLVersion = llmin(gGLManager.mGLVersion, 3.33f);
// and select GLSL version for OpenGL 3.3
gGLManager.mGLVersionString += " 3.3 fallback"; // for ViewerStats reporting
// and select GLSL version for OpenGL 3.2
gGLManager.mGLSLVersionMajor = 3;
gGLManager.mGLSLVersionMinor = 30;
gGLManager.mGLSLVersionMinor = 20;
}
}
if (gGLManager.mIsApple)
@ -712,6 +723,10 @@ void LLFeatureManager::applyBaseMasks()
if (gGLManager.mGLVersion < 3.99f)
{
maskFeatures("GL3");
// make sure to disable background context activity in GL3 mode
LLImageGLThread::sEnabledMedia = false;
LLImageGLThread::sEnabledTextures = false;
}
// now mask by gpu string

View File

@ -31,10 +31,14 @@
#include "llviewertexture.h"
class LLGLSLShader;
class LLGLTFMaterialList;
class LLTerrainMaterials;
class LLFetchedGLTFMaterial: public LLGLTFMaterial
{
friend class LLGLTFMaterialList; // for lifetime management
// for lifetime management
friend class LLGLTFMaterialList;
friend class LLTerrainMaterials;
public:
LLFetchedGLTFMaterial();
virtual ~LLFetchedGLTFMaterial();

View File

@ -319,6 +319,18 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings()
ctrl_shadows->setValue(0);
shadows_text->setEnabled(false);
}
// Vintage mode
LLCachedControl<bool> is_vintage(gSavedSettings, "RenderVintageMode");
LLSliderCtrl* tonemapMix = getChild<LLSliderCtrl>("TonemapMix");
LLComboBox* tonemapSelect = getChild<LLComboBox>("TonemapType");
LLTextBox* tonemapLabel = getChild<LLTextBox>("TonemapTypeText");
LLSliderCtrl* exposureSlider = getChild<LLSliderCtrl>("RenderExposure");
tonemapSelect->setEnabled(!is_vintage);
tonemapLabel->setEnabled(!is_vintage);
tonemapMix->setEnabled(!is_vintage);
exposureSlider->setEnabled(!is_vintage);
}
void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState()

View File

@ -289,6 +289,8 @@ LLModelPreview::~LLModelPreview()
}
mBaseModel.clear();
mBaseScene.clear();
LLLoadedCallbackEntry::cleanUpCallbackList(&mCallbackTextureList);
}
void LLModelPreview::updateDimentionsAndOffsets()
@ -774,7 +776,7 @@ void LLModelPreview::rebuildUploadData()
{
// in case user provided a missing file later
texture->setIsMissingAsset(false);
texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, this, NULL, false);
texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, this, &mCallbackTextureList, false);
texture->forceToSaveRawImage(0, F32_MAX);
texture->updateFetch();
if (mModelLoader)
@ -4189,8 +4191,6 @@ LLJoint* LLModelPreview::lookupJointByName(const std::string& str, void* opaque)
U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque)
{
(void)opaque;
if (material.mDiffuseMapFilename.size())
{
material.mOpaqueData = new LLPointer< LLViewerFetchedTexture >;
@ -4204,7 +4204,8 @@ U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque)
}
// Todo: might cause a crash if preview gets closed before we get the callback.
// Use a callback list or guard callback in some way
tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, opaque, NULL, false);
LLModelPreview* preview = (LLModelPreview*)opaque;
tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, opaque, &preview->mCallbackTextureList, false);
tex->forceToSaveRawImage(0, F32_MAX);
material.setDiffuseMap(tex->getID()); // record tex ID
return 1;

View File

@ -334,6 +334,7 @@ protected:
LLMeshUploadThread::instance_list mUploadData;
std::set<LLViewerFetchedTexture * > mTextureSet;
LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList;
//map of vertex buffers to models (one vertex buffer in vector per face in model
std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mVertexBuffer[LLModel::NUM_LODS + 1];

View File

@ -55,8 +55,15 @@
static LLPanelInjector<LLOutfitGallery> t_outfit_gallery("outfit_gallery");
#define MAX_OUTFIT_PHOTO_WIDTH 256
#define MAX_OUTFIT_PHOTO_HEIGHT 256
// The maximum resolution at which to load the outfit photo. If the given
// texture has a higher resolution, tell the texture streaming system to
// only load the resolution needed. An in-world object may request to load
// the texture at a higher resolution, but that won't affect textures
// loaded with LLViewerTexture::FETCHED_TEXTURE. (see
// LLOutfitGalleryItem::setImageAssetId and also
// LLViewerTexture::LOD_TEXTURE)
#define MAX_OUTFIT_PHOTO_LOAD_WIDTH 256
#define MAX_OUTFIT_PHOTO_LOAD_HEIGHT 256
const S32 GALLERY_ITEMS_PER_ROW_MIN = 2;
@ -979,28 +986,18 @@ void LLOutfitGalleryItem::draw()
border.mRight = border.mRight + 1;
gl_rect_2d(border, border_color, false);
// If the floater is focused, don't apply its alpha to the texture (STORM-677).
const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
if (mTexturep)
{
if (mImageUpdatePending && mTexturep->getDiscardLevel() >= 0)
{
mImageUpdatePending = false;
if (mTexturep->getOriginalWidth() > MAX_OUTFIT_PHOTO_WIDTH || mTexturep->getOriginalHeight() > MAX_OUTFIT_PHOTO_HEIGHT)
{
setDefaultImage();
}
}
else
{
LLRect interior = border;
interior.stretch(-1);
LLRect interior = border;
interior.stretch(-1);
gl_draw_scaled_image(interior.mLeft - 1, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha);
// Pump the priority
const F32 stats = (F32)llmin(interior.getWidth() * interior.getHeight(), MAX_OUTFIT_PHOTO_LOAD_WIDTH * MAX_OUTFIT_PHOTO_LOAD_HEIGHT);
mTexturep->addTextureStats(stats);
// Pump the priority
mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight()));
}
// If the floater is focused, don't apply its alpha to the texture (STORM-677).
const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
gl_draw_scaled_image(interior.mLeft - 1, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha);
}
}
@ -1128,14 +1125,18 @@ bool LLOutfitGalleryItem::openOutfitsContent()
bool LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id)
{
LLPointer<LLViewerFetchedTexture> texture = LLViewerTextureManager::getFetchedTexture(image_asset_id, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
if (texture && texture->getOriginalWidth() <= MAX_OUTFIT_PHOTO_WIDTH && texture->getOriginalHeight() <= MAX_OUTFIT_PHOTO_HEIGHT)
LLPointer<LLViewerFetchedTexture> texture = LLViewerTextureManager::getFetchedTexture(image_asset_id, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::FETCHED_TEXTURE);
if (texture)
{
mImageAssetId = image_asset_id;
mTexturep = texture;
// *TODO: There was previously logic which attempted to toggle
// visibility of the preview icon based on certain conditions,
// however these conditions either did not make sense or were not
// applicable due to texture streaming. Maybe we should only hide
// the preview icon if the texture has at least one mip loaded.
mPreviewIcon->setVisible(false);
mDefaultImage = false;
mImageUpdatePending = (texture->getDiscardLevel() == -1);
return true;
}
return false;
@ -1152,7 +1153,6 @@ void LLOutfitGalleryItem::setDefaultImage()
mImageAssetId.setNull();
mPreviewIcon->setVisible(true);
mDefaultImage = true;
mImageUpdatePending = false;
}
LLContextMenu* LLOutfitGalleryContextMenu::createMenu()

View File

@ -266,7 +266,6 @@ private:
bool mSelected;
bool mWorn;
bool mDefaultImage;
bool mImageUpdatePending;
bool mHidden;
std::string mOutfitName;
};

View File

@ -463,7 +463,7 @@ void LLReflectionMapManager::update()
LLReflectionMap* LLReflectionMapManager::addProbe(LLSpatialGroup* group)
{
if (gGLManager.mGLVersion < 4.05f)
if (gGLManager.mGLVersion < 4.05f || !LLPipeline::sReflectionProbesEnabled)
{
return nullptr;
}
@ -579,6 +579,11 @@ LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* gr
LLReflectionMap* LLReflectionMapManager::registerViewerObject(LLViewerObject* vobj)
{
if (!LLPipeline::sReflectionProbesEnabled)
{
return nullptr;
}
llassert(vobj != nullptr);
LLReflectionMap* probe = new LLReflectionMap();

View File

@ -794,6 +794,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
F32 g = getGamma();
static LLCachedControl<bool> hdr(gSavedSettings, "RenderHDREnabled");
static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true);
static LLCachedControl<F32> auto_adjust_ambient_scale(gSavedSettings, "RenderSkyAutoAdjustAmbientScale", 0.75f);
static LLCachedControl<F32> auto_adjust_hdr_scale(gSavedSettings, "RenderSkyAutoAdjustHDRScale", 2.f);
@ -801,10 +802,15 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
static LLCachedControl<F32> auto_adjust_blue_density_scale(gSavedSettings, "RenderSkyAutoAdjustBlueDensityScale", 1.f);
static LLCachedControl<F32> auto_adjust_sun_color_scale(gSavedSettings, "RenderSkyAutoAdjustSunColorScale", 1.f);
static LLCachedControl<F32> sunlight_scale(gSavedSettings, "RenderSkySunlightScale", 1.5f);
static LLCachedControl<F32> sunlight_hdr_scale(gSavedSettings, "RenderHDRSkySunlightScale", 1.5f);
static LLCachedControl<F32> ambient_scale(gSavedSettings, "RenderSkyAmbientScale", 1.5f);
shader->uniform1f(LLShaderMgr::SKY_SUNLIGHT_SCALE, sunlight_scale);
// sky is a "classic" sky following pre SL 7.0 shading
bool classic_mode = psky->canAutoAdjust();
shader->uniform1f(LLShaderMgr::SKY_SUNLIGHT_SCALE, hdr ? sunlight_hdr_scale : sunlight_scale);
shader->uniform1f(LLShaderMgr::SKY_AMBIENT_SCALE, ambient_scale);
shader->uniform1i(LLShaderMgr::CLASSIC_MODE, classic_mode);
F32 probe_ambiance = getReflectionProbeAmbiance();

View File

@ -1696,18 +1696,13 @@ bool LLTextureFetchWorker::doWork(S32 param)
{
if (http_not_found == mGetStatus)
{
if (mFTType != FTT_MAP_TILE)
{
LL_WARNS(LOG_TXT) << "Texture missing from server (404): " << mUrl << LL_ENDL;
}
if(mWriteToCacheState == NOT_WRITE) //map tiles or server bakes
{
setState(DONE);
releaseHttpSemaphore();
if (mFTType != FTT_MAP_TILE)
{
LL_WARNS(LOG_TXT) << mID << " abort: WAIT_HTTP_REQ not found" << LL_ENDL;
LL_WARNS(LOG_TXT) << mID << "NOT_WRITE texture missing from server (404), abort: " << mUrl << LL_ENDL;
}
return true;
}
@ -1717,6 +1712,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
LLViewerRegion* region = getRegion();
if (!region || mLastRegionId != region->getRegionID())
{
if (mFTType != FTT_MAP_TILE)
{
LL_INFOS(LOG_TXT) << "Texture missing from server (404), retrying: " << mUrl << " mRetryAttempt " << mRetryAttempt << LL_ENDL;
}
// cap failure? try on new region.
mUrl.clear();
++mRetryAttempt;
@ -1737,6 +1736,11 @@ bool LLTextureFetchWorker::doWork(S32 param)
return doWork(param);
}
// </FS:Ansariel>
if (mFTType != FTT_MAP_TILE)
{
LL_WARNS(LOG_TXT) << "Texture missing from server (404): " << mUrl << LL_ENDL;
}
}
else if (http_service_unavail == mGetStatus)
{
@ -3047,7 +3051,7 @@ LLTextureFetchWorker* LLTextureFetch::getWorker(const LLUUID& id)
// Threads: T*
bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, S32& worker_state,
LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux,
LLCore::HttpStatus& last_http_get_status)
{
@ -3056,6 +3060,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
LLTextureFetchWorker* worker = getWorker(id);
if (worker)
{
worker_state = worker->mState;
if (worker->wasAborted())
{
res = true;
@ -3134,6 +3139,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
}
else
{
worker_state = 0;
res = true;
}
return res;

View File

@ -95,7 +95,7 @@ public:
// Threads: T*
// keep in mind that if fetcher isn't done, it still might need original raw image
bool getRequestFinished(const LLUUID& id, S32& discard_level,
bool getRequestFinished(const LLUUID& id, S32& discard_level, S32& worker_state,
LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux,
LLCore::HttpStatus& last_http_get_status);

View File

@ -326,6 +326,23 @@ static bool handleReleaseGLBufferChanged(const LLSD& newvalue)
return true;
}
static bool handleEnableEmissiveChanged(const LLSD& newvalue)
{
return handleReleaseGLBufferChanged(newvalue) && handleSetShaderChanged(newvalue);
}
static bool handleEnableClassicMode(const LLSD& newvalue)
{
gSavedSettings.setBOOL("RenderEnableEmissiveBuffer", !newvalue.asBoolean());
gSavedSettings.setBOOL("RenderHDREnabled", !newvalue.asBoolean());
return true;
}
static bool handleEnableHDR(const LLSD& newvalue)
{
return handleReleaseGLBufferChanged(newvalue) && handleSetShaderChanged(newvalue);
}
static bool handleLUTBufferChanged(const LLSD& newvalue)
{
if (gPipeline.isInit())
@ -1257,6 +1274,9 @@ void settings_setup_listeners()
setting_setup_signal_listener(gSavedSettings, "RenderGlow", handleSetShaderChanged);
setting_setup_signal_listener(gSavedSettings, "RenderGlowResolutionPow", handleReleaseGLBufferChanged);
setting_setup_signal_listener(gSavedSettings, "RenderGlowHDR", handleReleaseGLBufferChanged);
setting_setup_signal_listener(gSavedSettings, "RenderEnableEmissiveBuffer", handleEnableEmissiveChanged);
setting_setup_signal_listener(gSavedSettings, "RenderVintageMode", handleEnableClassicMode);
setting_setup_signal_listener(gSavedSettings, "RenderHDREnabled", handleEnableHDR);
setting_setup_signal_listener(gSavedSettings, "RenderGlowNoise", handleSetShaderChanged);
setting_setup_signal_listener(gSavedSettings, "RenderGammaFull", handleSetShaderChanged);
setting_setup_signal_listener(gSavedSettings, "FSOverrideVRAMDetection", handleOverrideVRAMDetectionChanged); // <FS:Beq/> Override VRAM detection support

View File

@ -1070,30 +1070,17 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)
gGL.setColorMask(true, true);
if (LLPipeline::sRenderDeferred)
gPipeline.mRT->deferredScreen.bindTarget();
if (gUseWireframe)
{
gPipeline.mRT->deferredScreen.bindTarget();
if (gUseWireframe)
{
F32 g = 0.5f;
glClearColor(g, g, g, 1.f);
}
else
{
glClearColor(1, 0, 1, 1);
}
gPipeline.mRT->deferredScreen.clear();
F32 g = 0.5f;
glClearColor(g, g, g, 1.f);
}
else
{
gPipeline.mRT->screen.bindTarget();
if (LLPipeline::sUnderWaterRender && !gPipeline.canUseWindLightShaders())
{
const LLColor4 &col = LLEnvironment::instance().getCurrentWater()->getWaterFogColor();
glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f);
}
gPipeline.mRT->screen.clear();
glClearColor(1, 0, 1, 1);
}
gPipeline.mRT->deferredScreen.clear();
gGL.setColorMask(true, false);

View File

@ -260,6 +260,16 @@ static bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader
return riggedShader.createShader();
}
static void add_common_permutations(LLGLSLShader* shader)
{
LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
if (emissive)
{
shader->addPermutation("HAS_EMISSIVE", "1");
}
}
static bool make_gltf_variant(LLGLSLShader& shader, LLGLSLShader& variant, bool alpha_blend, bool rigged, bool unlit, bool multi_uv, bool use_sun_shadow)
{
@ -776,6 +786,13 @@ std::string LLViewerShaderMgr::loadBasicShaders()
attribs["MAX_JOINTS_PER_MESH_OBJECT"] =
std::to_string(LLSkinningUtil::getMaxJointCount());
LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
if (emissive)
{
attribs["HAS_EMISSIVE"] = "1";
}
bool ssr = gSavedSettings.getBOOL("RenderScreenSpaceReflections");
bool mirrors = gSavedSettings.getBOOL("RenderMirrors");
@ -856,6 +873,7 @@ std::string LLViewerShaderMgr::loadBasicShaders()
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/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/gbufferUtil.glsl", 1) );
index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/globalF.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) );
@ -1195,6 +1213,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredHighlightProgram.mShaderFiles.push_back(make_pair("interface/highlightV.glsl", GL_VERTEX_SHADER));
gDeferredHighlightProgram.mShaderFiles.push_back(make_pair("deferred/highlightF.glsl", GL_FRAGMENT_SHADER));
gDeferredHighlightProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE];
add_common_permutations(&gDeferredHighlightProgram);
success = gDeferredHighlightProgram.createShader();
}
@ -1207,6 +1226,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseIndexedF.glsl", GL_FRAGMENT_SHADER));
gDeferredDiffuseProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredDiffuseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredDiffuseProgram);
success = make_rigged_variant(gDeferredDiffuseProgram, gDeferredSkinnedDiffuseProgram);
success = success && gDeferredDiffuseProgram.createShader();
}
@ -1219,6 +1239,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskIndexedF.glsl", GL_FRAGMENT_SHADER));
gDeferredDiffuseAlphaMaskProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
gDeferredDiffuseAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredDiffuseAlphaMaskProgram);
success = make_rigged_variant(gDeferredDiffuseAlphaMaskProgram, gDeferredSkinnedDiffuseAlphaMaskProgram);
success = success && gDeferredDiffuseAlphaMaskProgram.createShader();
}
@ -1230,6 +1251,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER));
gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskF.glsl", GL_FRAGMENT_SHADER));
gDeferredNonIndexedDiffuseAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredNonIndexedDiffuseAlphaMaskProgram);
success = gDeferredNonIndexedDiffuseAlphaMaskProgram.createShader();
llassert(success);
}
@ -1241,6 +1263,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("deferred/diffuseNoColorV.glsl", GL_VERTEX_SHADER));
gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderFiles.push_back(make_pair("deferred/diffuseAlphaMaskNoColorF.glsl", GL_FRAGMENT_SHADER));
gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram);
success = gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram.createShader();
llassert(success);
}
@ -1252,6 +1275,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpV.glsl", GL_VERTEX_SHADER));
gDeferredBumpProgram.mShaderFiles.push_back(make_pair("deferred/bumpF.glsl", GL_FRAGMENT_SHADER));
gDeferredBumpProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredBumpProgram);
success = make_rigged_variant(gDeferredBumpProgram, gDeferredSkinnedBumpProgram);
success = success && gDeferredBumpProgram.createShader();
llassert(success);
@ -1317,6 +1341,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredMaterialProgram[i].addPermutation("HAS_SUN_SHADOW", "1");
}
add_common_permutations(&gDeferredMaterialProgram[i]);
gDeferredMaterialProgram[i].mFeatures.hasSrgb = true;
gDeferredMaterialProgram[i].mFeatures.calculatesAtmospherics = true;
@ -1360,6 +1385,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredPBROpaqueProgram.clearPermutations();
add_common_permutations(&gDeferredPBROpaqueProgram);
success = make_rigged_variant(gDeferredPBROpaqueProgram, gDeferredSkinnedPBROpaqueProgram);
if (success)
{
@ -1381,6 +1408,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gGLTFPBRMetallicRoughnessProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gGLTFPBRMetallicRoughnessProgram.clearPermutations();
add_common_permutations(&gGLTFPBRMetallicRoughnessProgram);
success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow);
//llassert(success);
@ -1403,6 +1432,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gPBRGlowProgram.mShaderFiles.push_back(make_pair("deferred/pbrglowF.glsl", GL_FRAGMENT_SHADER));
gPBRGlowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gPBRGlowProgram);
success = make_rigged_variant(gPBRGlowProgram, gPBRGlowSkinnedProgram);
if (success)
{
@ -1422,13 +1453,13 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gHUDPBROpaqueProgram.clearPermutations();
gHUDPBROpaqueProgram.addPermutation("IS_HUD", "1");
add_common_permutations(&gHUDPBROpaqueProgram);
success = gHUDPBROpaqueProgram.createShader();
llassert(success);
}
if (success)
{
LLGLSLShader* shader = &gDeferredPBRAlphaProgram;
@ -1458,6 +1489,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
shader->addPermutation("HAS_EMISSIVE_MAP", "1");
shader->addPermutation("USE_VERTEX_COLOR", "1");
add_common_permutations(shader);
if (use_sun_shadow)
{
shader->addPermutation("HAS_SUN_SHADOW", "1");
@ -1495,6 +1528,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
shader->addPermutation("IS_HUD", "1");
add_common_permutations(shader);
shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = shader->createShader();
llassert(success);
@ -1527,6 +1562,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
shader->addPermutation("TERRAIN_PBR_DETAIL", llformat("%d", detail));
shader->addPermutation("TERRAIN_PAINT_TYPE", llformat("%d", paint_type));
shader->addPermutation("TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT", llformat("%d", mapping));
add_common_permutations(shader);
success = success && shader->createShader();
llassert(success);
}
@ -1539,6 +1577,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredTreeProgram.mShaderFiles.push_back(make_pair("deferred/treeV.glsl", GL_VERTEX_SHADER));
gDeferredTreeProgram.mShaderFiles.push_back(make_pair("deferred/treeF.glsl", GL_FRAGMENT_SHADER));
gDeferredTreeProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredTreeProgram);
success = gDeferredTreeProgram.createShader();
}
@ -1574,6 +1615,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredImpostorProgram.mShaderFiles.push_back(make_pair("deferred/impostorV.glsl", GL_VERTEX_SHADER));
gDeferredImpostorProgram.mShaderFiles.push_back(make_pair("deferred/impostorF.glsl", GL_FRAGMENT_SHADER));
gDeferredImpostorProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredImpostorProgram);
success = gDeferredImpostorProgram.createShader();
llassert(success);
}
@ -1582,6 +1626,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredLightProgram.mName = "Deferred Light Shader";
gDeferredLightProgram.mFeatures.isDeferred = true;
gDeferredLightProgram.mFeatures.hasFullGBuffer = true;
gDeferredLightProgram.mFeatures.hasShadows = true;
gDeferredLightProgram.mFeatures.hasSrgb = true;
@ -1592,6 +1637,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredLightProgram.clearPermutations();
add_common_permutations(&gDeferredLightProgram);
success = gDeferredLightProgram.createShader();
llassert(success);
}
@ -1602,6 +1649,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
{
gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i);
gDeferredMultiLightProgram[i].mFeatures.isDeferred = true;
gDeferredMultiLightProgram[i].mFeatures.hasFullGBuffer = true;
gDeferredMultiLightProgram[i].mFeatures.hasShadows = true;
gDeferredMultiLightProgram[i].mFeatures.hasSrgb = true;
@ -1612,6 +1660,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredMultiLightProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredMultiLightProgram[i].addPermutation("LIGHT_COUNT", llformat("%d", i+1));
add_common_permutations(&gDeferredMultiLightProgram[i]);
success = gDeferredMultiLightProgram[i].createShader();
llassert(success);
}
@ -1623,6 +1673,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredSpotLightProgram.mShaderFiles.clear();
gDeferredSpotLightProgram.mFeatures.hasSrgb = true;
gDeferredSpotLightProgram.mFeatures.isDeferred = true;
gDeferredSpotLightProgram.mFeatures.hasFullGBuffer = true;
gDeferredSpotLightProgram.mFeatures.hasShadows = true;
gDeferredSpotLightProgram.clearPermutations();
@ -1630,6 +1681,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER));
gDeferredSpotLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredSpotLightProgram);
success = gDeferredSpotLightProgram.createShader();
llassert(success);
}
@ -1639,6 +1692,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredMultiSpotLightProgram.mName = "Deferred MultiSpotLight Shader";
gDeferredMultiSpotLightProgram.mFeatures.hasSrgb = true;
gDeferredMultiSpotLightProgram.mFeatures.isDeferred = true;
gDeferredMultiSpotLightProgram.mFeatures.hasFullGBuffer = true;
gDeferredMultiSpotLightProgram.mFeatures.hasShadows = true;
gDeferredMultiSpotLightProgram.clearPermutations();
@ -1648,6 +1702,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredMultiSpotLightProgram.mShaderFiles.push_back(make_pair("deferred/spotLightF.glsl", GL_FRAGMENT_SHADER));
gDeferredMultiSpotLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredMultiSpotLightProgram);
success = gDeferredMultiSpotLightProgram.createShader();
llassert(success);
}
@ -1675,6 +1731,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER));
gDeferredSunProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredSunProgram);
success = gDeferredSunProgram.createShader();
llassert(success);
}
@ -1690,6 +1748,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredSunProbeProgram.mShaderFiles.push_back(make_pair("deferred/sunLightF.glsl", GL_FRAGMENT_SHADER));
gDeferredSunProbeProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredSunProbeProgram);
success = gDeferredSunProbeProgram.createShader();
llassert(success);
}
@ -1704,6 +1764,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredBlurLightProgram.mShaderFiles.push_back(make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER));
gDeferredBlurLightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredBlurLightProgram);
success = gDeferredBlurLightProgram.createShader();
llassert(success);
}
@ -1758,6 +1820,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
shader->addPermutation("HAS_SUN_SHADOW", "1");
}
add_common_permutations(shader);
if (rigged)
{
shader->addPermutation("HAS_SKIN", "1");
@ -1823,6 +1887,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
shader->addPermutation("HAS_SUN_SHADOW", "1");
}
add_common_permutations(shader);
shader->mRiggedVariant = &gDeferredSkinnedAlphaImpostorProgram;
shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED];
if (!rigged)
@ -1851,6 +1917,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarEyesProgram.mShaderFiles.push_back(make_pair("deferred/avatarEyesV.glsl", GL_VERTEX_SHADER));
gDeferredAvatarEyesProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER));
gDeferredAvatarEyesProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredAvatarEyesProgram);
success = gDeferredAvatarEyesProgram.createShader();
llassert(success);
}
@ -1867,6 +1936,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER));
gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightF.glsl", GL_FRAGMENT_SHADER));
gDeferredFullbrightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredFullbrightProgram);
success = make_rigged_variant(gDeferredFullbrightProgram, gDeferredSkinnedFullbrightProgram);
success = gDeferredFullbrightProgram.createShader();
llassert(success);
@ -1886,6 +1958,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gHUDFullbrightProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gHUDFullbrightProgram.clearPermutations();
gHUDFullbrightProgram.addPermutation("IS_HUD", "1");
add_common_permutations(&gHUDFullbrightProgram);
success = gHUDFullbrightProgram.createShader();
llassert(success);
}
@ -1904,6 +1979,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightAlphaMaskProgram.clearPermutations();
gDeferredFullbrightAlphaMaskProgram.addPermutation("HAS_ALPHA_MASK","1");
gDeferredFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredFullbrightAlphaMaskProgram);
success = make_rigged_variant(gDeferredFullbrightAlphaMaskProgram, gDeferredSkinnedFullbrightAlphaMaskProgram);
success = success && gDeferredFullbrightAlphaMaskProgram.createShader();
llassert(success);
@ -1923,6 +2001,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gHUDFullbrightAlphaMaskProgram.clearPermutations();
gHUDFullbrightAlphaMaskProgram.addPermutation("HAS_ALPHA_MASK", "1");
gHUDFullbrightAlphaMaskProgram.addPermutation("IS_HUD", "1");
add_common_permutations(&gHUDFullbrightAlphaMaskProgram);
gHUDFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = gHUDFullbrightAlphaMaskProgram.createShader();
llassert(success);
@ -1943,6 +2024,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightAlphaMaskAlphaProgram.clearPermutations();
gDeferredFullbrightAlphaMaskAlphaProgram.addPermutation("HAS_ALPHA_MASK", "1");
gDeferredFullbrightAlphaMaskAlphaProgram.addPermutation("IS_ALPHA", "1");
add_common_permutations(&gDeferredFullbrightAlphaMaskAlphaProgram);
gDeferredFullbrightAlphaMaskAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = make_rigged_variant(gDeferredFullbrightAlphaMaskAlphaProgram, gDeferredSkinnedFullbrightAlphaMaskAlphaProgram);
success = success && gDeferredFullbrightAlphaMaskAlphaProgram.createShader();
@ -1965,6 +2049,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gHUDFullbrightAlphaMaskAlphaProgram.addPermutation("HAS_ALPHA_MASK", "1");
gHUDFullbrightAlphaMaskAlphaProgram.addPermutation("IS_ALPHA", "1");
gHUDFullbrightAlphaMaskAlphaProgram.addPermutation("IS_HUD", "1");
add_common_permutations(&gHUDFullbrightAlphaMaskAlphaProgram);
gHUDFullbrightAlphaMaskAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = success && gHUDFullbrightAlphaMaskAlphaProgram.createShader();
llassert(success);
@ -1983,6 +2070,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER));
gDeferredFullbrightShinyProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredFullbrightShinyProgram.mFeatures.hasReflectionProbes = true;
add_common_permutations(&gDeferredFullbrightShinyProgram);
success = make_rigged_variant(gDeferredFullbrightShinyProgram, gDeferredSkinnedFullbrightShinyProgram);
success = success && gDeferredFullbrightShinyProgram.createShader();
llassert(success);
@ -2003,6 +2093,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gHUDFullbrightShinyProgram.mFeatures.hasReflectionProbes = true;
gHUDFullbrightShinyProgram.clearPermutations();
gHUDFullbrightShinyProgram.addPermutation("IS_HUD", "1");
add_common_permutations(&gHUDFullbrightShinyProgram);
success = gHUDFullbrightShinyProgram.createShader();
llassert(success);
}
@ -2018,6 +2111,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveV.glsl", GL_VERTEX_SHADER));
gDeferredEmissiveProgram.mShaderFiles.push_back(make_pair("deferred/emissiveF.glsl", GL_FRAGMENT_SHADER));
gDeferredEmissiveProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredEmissiveProgram);
success = make_rigged_variant(gDeferredEmissiveProgram, gDeferredSkinnedEmissiveProgram);
success = success && gDeferredEmissiveProgram.createShader();
llassert(success);
@ -2032,10 +2128,12 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredSoftenProgram.mFeatures.hasAtmospherics = true;
gDeferredSoftenProgram.mFeatures.hasGamma = true;
gDeferredSoftenProgram.mFeatures.isDeferred = true;
gDeferredSoftenProgram.mFeatures.hasFullGBuffer = true;
gDeferredSoftenProgram.mFeatures.hasShadows = use_sun_shadow;
gDeferredSoftenProgram.mFeatures.hasReflectionProbes = mShaderLevel[SHADER_DEFERRED] > 2;
gDeferredSoftenProgram.clearPermutations();
add_common_permutations(&gDeferredSoftenProgram);
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER));
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER));
@ -2072,6 +2170,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gHazeProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER));
gHazeProgram.mShaderFiles.push_back(make_pair("deferred/hazeF.glsl", GL_FRAGMENT_SHADER));
add_common_permutations(&gHazeProgram);
gHazeProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = gHazeProgram.createShader();
@ -2096,6 +2196,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gHazeWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterHazeV.glsl", GL_VERTEX_SHADER));
gHazeWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterHazeF.glsl", GL_FRAGMENT_SHADER));
add_common_permutations(&gHazeWaterProgram);
gHazeWaterProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = gHazeWaterProgram.createShader();
@ -2125,6 +2227,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowSkinnedV.glsl", GL_VERTEX_SHADER));
gDeferredSkinnedShadowProgram.mShaderFiles.push_back(make_pair("deferred/shadowF.glsl", GL_FRAGMENT_SHADER));
gDeferredSkinnedShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredSkinnedShadowProgram);
// gDeferredSkinnedShadowProgram.addPermutation("DEPTH_CLAMP", "1"); // disable depth clamp for now
success = gDeferredSkinnedShadowProgram.createShader();
llassert(success);
@ -2156,6 +2261,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredShadowFullbrightAlphaMaskProgram.clearPermutations();
gDeferredShadowFullbrightAlphaMaskProgram.addPermutation("DEPTH_CLAMP", "1");
gDeferredShadowFullbrightAlphaMaskProgram.addPermutation("IS_FULLBRIGHT", "1");
add_common_permutations(&gDeferredShadowFullbrightAlphaMaskProgram);
gDeferredShadowFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = make_rigged_variant(gDeferredShadowFullbrightAlphaMaskProgram, gDeferredSkinnedShadowFullbrightAlphaMaskProgram);
success = success && gDeferredShadowFullbrightAlphaMaskProgram.createShader();
@ -2185,6 +2293,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredShadowGLTFAlphaMaskProgram.mShaderFiles.push_back(make_pair("deferred/pbrShadowAlphaMaskF.glsl", GL_FRAGMENT_SHADER));
gDeferredShadowGLTFAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredShadowGLTFAlphaMaskProgram.clearPermutations();
add_common_permutations(&gDeferredShadowGLTFAlphaMaskProgram);
success = make_rigged_variant(gDeferredShadowGLTFAlphaMaskProgram, gDeferredSkinnedShadowGLTFAlphaMaskProgram);
success = success && gDeferredShadowGLTFAlphaMaskProgram.createShader();
llassert(success);
@ -2198,6 +2309,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredShadowGLTFAlphaBlendProgram.mShaderFiles.push_back(make_pair("deferred/pbrShadowAlphaBlendF.glsl", GL_FRAGMENT_SHADER));
gDeferredShadowGLTFAlphaBlendProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredShadowGLTFAlphaBlendProgram.clearPermutations();
add_common_permutations(&gDeferredShadowGLTFAlphaBlendProgram);
success = make_rigged_variant(gDeferredShadowGLTFAlphaBlendProgram, gDeferredSkinnedShadowGLTFAlphaBlendProgram);
success = success && gDeferredShadowGLTFAlphaBlendProgram.createShader();
llassert(success);
@ -2251,6 +2365,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredTerrainProgram.mShaderFiles.clear();
gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainV.glsl", GL_VERTEX_SHADER));
gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainF.glsl", GL_FRAGMENT_SHADER));
add_common_permutations(&gDeferredTerrainProgram);
gDeferredTerrainProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
success = gDeferredTerrainProgram.createShader();
llassert(success);
@ -2264,6 +2381,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarV.glsl", GL_VERTEX_SHADER));
gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarF.glsl", GL_FRAGMENT_SHADER));
gDeferredAvatarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredAvatarProgram);
success = gDeferredAvatarProgram.createShader();
llassert(success);
}
@ -2297,6 +2417,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarAlphaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredAvatarAlphaProgram);
success = gDeferredAvatarAlphaProgram.createShader();
llassert(success);
@ -2439,7 +2561,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
}
}
if (success)
if (gGLManager.mGLVersion > 3.15f && success)
{
std::vector<std::pair<std::string, std::string>> quality_levels = { {"SMAA_PRESET_LOW", "Low"},
{"SMAA_PRESET_MEDIUM", "Medium"},
@ -2606,6 +2728,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gEnvironmentMapProgram.clearPermutations();
gEnvironmentMapProgram.addPermutation("HAS_HDRI", "1");
add_common_permutations(&gEnvironmentMapProgram);
gEnvironmentMapProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER));
gEnvironmentMapProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER));
gEnvironmentMapProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
@ -2629,6 +2752,8 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY;
add_common_permutations(&gDeferredWLSkyProgram);
success = gDeferredWLSkyProgram.createShader();
llassert(success);
}
@ -2647,6 +2772,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY;
gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113
add_common_permutations(&gDeferredWLCloudProgram);
success = gDeferredWLCloudProgram.createShader();
llassert(success);
}
@ -2664,6 +2792,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscF.glsl", GL_FRAGMENT_SHADER));
gDeferredWLSunProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLSunProgram.mShaderGroup = LLGLSLShader::SG_SKY;
add_common_permutations(&gDeferredWLSunProgram);
success = gDeferredWLSunProgram.createShader();
llassert(success);
}
@ -2683,6 +2814,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY;
gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113
add_common_permutations(&gDeferredWLMoonProgram);
success = gDeferredWLMoonProgram.createShader();
llassert(success);
}
@ -2696,6 +2830,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredStarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY;
gDeferredStarProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113
add_common_permutations(&gDeferredWLSkyProgram);
success = gDeferredStarProgram.createShader();
llassert(success);
}
@ -2738,6 +2875,9 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gDeferredBufferVisualProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
gDeferredBufferVisualProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredVisualizeBuffers.glsl", GL_FRAGMENT_SHADER));
gDeferredBufferVisualProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
add_common_permutations(&gDeferredBufferVisualProgram);
success = gDeferredBufferVisualProgram.createShader();
}
// [RLVa:KB] - @setsphere

View File

@ -1624,8 +1624,8 @@ void LLViewerFetchedTexture::postCreateTexture()
if (!needsToSaveRawImage())
{
mNeedsAux = false;
destroyRawImage();
}
destroyRawImage(); // will save raw image if needed
mNeedsCreateTexture = false;
}
@ -1945,7 +1945,7 @@ bool LLViewerFetchedTexture::updateFetch()
if (mRawImage.notNull()) sRawCount--;
if (mAuxRawImage.notNull()) sAuxCount--;
// keep in mind that fetcher still might need raw image, don't modify original
bool finished = LLAppViewer::getTextureFetch()->getRequestFinished(getID(), fetch_discard, mRawImage, mAuxRawImage,
bool finished = LLAppViewer::getTextureFetch()->getRequestFinished(getID(), fetch_discard, mFetchState, mRawImage, mAuxRawImage,
mLastHttpGetStatus);
if (mRawImage.notNull()) sRawCount++;
if (mAuxRawImage.notNull())
@ -2041,7 +2041,9 @@ bool LLViewerFetchedTexture::updateFetch()
if (!mIsFetching)
{
if ((decode_priority > 0) && (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL))
if ((decode_priority > 0)
&& (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL)
&& mFetchState > 1) // 1 - initial, make sure fetcher did at least something
{
// We finished but received no data
if (getDiscardLevel() < 0)
@ -2053,6 +2055,7 @@ bool LLViewerFetchedTexture::updateFetch()
<< " mRawDiscardLevel " << mRawDiscardLevel
<< " current_discard " << current_discard
<< " stats " << mLastHttpGetStatus.toHex()
<< " worker state " << mFetchState
<< LL_ENDL;
}
setIsMissingAsset();
@ -2079,6 +2082,9 @@ bool LLViewerFetchedTexture::updateFetch()
{
// We have data, but our fetch failed to return raw data
// *TODO: FIgure out why this is happening and fix it
// Potentially can happen when TEX_LIST_SCALE and TEX_LIST_STANDARD
// get requested for the same texture id at the same time
// (two textures, one fetcher)
destroyRawImage();
}
}

View File

@ -102,14 +102,6 @@ namespace
}
};
LLTerrainMaterials::LLTerrainMaterials()
{
for (S32 i = 0; i < ASSET_COUNT; ++i)
{
mMaterialTexturesSet[i] = false;
}
}
LLTerrainMaterials::~LLTerrainMaterials()
{
unboost();
@ -199,7 +191,6 @@ void LLTerrainMaterials::setDetailAssetID(S32 asset, const LLUUID& id)
LLPointer<LLFetchedGLTFMaterial>& mat = mDetailMaterials[asset];
mat = id.isNull() ? nullptr : gGLTFMaterialList.getMaterial(id);
mDetailRenderMaterials[asset] = nullptr;
mMaterialTexturesSet[asset] = false;
}
const LLGLTFMaterial* LLTerrainMaterials::getMaterialOverride(S32 asset) const
@ -262,11 +253,17 @@ bool LLTerrainMaterials::makeMaterialsReady(bool boost, bool strict)
if (!material_asset_ready(mat)) { continue; }
LLPointer<LLFetchedGLTFMaterial>& render_mat = mDetailRenderMaterials[i];
// This will be mutated by materialTexturesReady, due to the way that
// function is implemented.
bool render_material_textures_set = bool(render_mat);
if (!render_mat)
{
render_mat = new LLFetchedGLTFMaterial();
*render_mat = *mat;
// This render_mat is effectively already loaded, because it gets its data from mat.
// However, its textures may not be loaded yet.
render_mat->materialBegin();
render_mat->materialComplete(true);
LLPointer<LLGLTFMaterial>& override_mat = mDetailMaterialOverrides[i];
if (override_mat)
@ -275,7 +272,8 @@ bool LLTerrainMaterials::makeMaterialsReady(bool boost, bool strict)
}
}
ready[i] = materialTexturesReady(render_mat, mMaterialTexturesSet[i], boost, strict);
ready[i] = materialTexturesReady(render_mat, render_material_textures_set, boost, strict);
llassert(render_material_textures_set);
}
#if 1
@ -414,16 +412,6 @@ bool LLTerrainMaterials::materialTexturesReady(LLPointer<LLFetchedGLTFMaterial>&
return true;
}
// Boost the loading priority of every known texture in the material
// Return true when ready to use
// static
bool LLTerrainMaterials::makeMaterialReady(LLPointer<LLFetchedGLTFMaterial> &mat, bool &textures_set, bool boost, bool strict)
{
if (!material_asset_ready(mat)) { return false; }
return materialTexturesReady(mat, textures_set, boost, strict);
}
// static
const LLUUID (&LLVLComposition::getDefaultTextures())[ASSET_COUNT]
{

View File

@ -27,18 +27,17 @@
#ifndef LL_LLVLCOMPOSITION_H
#define LL_LLVLCOMPOSITION_H
#include "llfetchedgltfmaterial.h"
#include "llimage.h"
#include "llpointer.h"
#include "llterrainpaintmap.h"
#include "llviewerlayer.h"
#include "llviewershadermgr.h"
#include "llviewertexture.h"
#include "llpointer.h"
#include "llimage.h"
class LLSurface;
class LLViewerFetchedTexture;
class LLGLTFMaterial;
class LLFetchedGLTFMaterial;
class LLModifyRegion
{
@ -52,7 +51,7 @@ class LLTerrainMaterials : public LLModifyRegion
public:
friend class LLDrawPoolTerrain;
LLTerrainMaterials();
LLTerrainMaterials() {}
virtual ~LLTerrainMaterials();
void apply(const LLModifyRegion& other);
@ -93,15 +92,15 @@ protected:
static bool makeTextureReady(LLPointer<LLViewerFetchedTexture>& tex, bool boost);
// strict = true -> all materials must be sufficiently loaded
// strict = false -> at least one material must be loaded
static bool makeMaterialReady(LLPointer<LLFetchedGLTFMaterial>& mat, bool& textures_set, bool boost, bool strict);
// *NOTE: Prefer calling makeMaterialReady if mat is known to be LLFetchedGLTFMaterial
static bool materialTexturesReady(LLPointer<LLFetchedGLTFMaterial>& mat, bool& textures_set, bool boost, bool strict);
LLPointer<LLViewerFetchedTexture> mDetailTextures[ASSET_COUNT];
// *NOTE: Unlike mDetailRenderMaterials, the textures in this are not
// guaranteed to be set or loaded after a true return from
// makeMaterialsReady.
LLPointer<LLFetchedGLTFMaterial> mDetailMaterials[ASSET_COUNT];
LLPointer<LLGLTFMaterial> mDetailMaterialOverrides[ASSET_COUNT];
LLPointer<LLFetchedGLTFMaterial> mDetailRenderMaterials[ASSET_COUNT];
bool mMaterialTexturesSet[ASSET_COUNT];
U32 mPaintType = TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE;
LLPointer<LLViewerTexture> mPaintMap;

View File

@ -767,6 +767,15 @@ void LLVOVolume::animateTextures()
if (!facep->mTextureMatrix)
{
facep->mTextureMatrix = new LLMatrix4();
if (facep->getVirtualSize() > MIN_TEX_ANIM_SIZE)
{
// Fix the one edge case missed in
// LLVOVolume::updateTextureVirtualSize when the
// mTextureMatrix is not yet present
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
mDrawable->getSpatialGroup()->dirtyGeom();
gPipeline.markRebuild(mDrawable->getSpatialGroup());
}
}
LLMatrix4& tex_mat = *facep->mTextureMatrix;
@ -912,7 +921,24 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
LLFace* face = mDrawable->getFace(i);
if (!face) continue;
const LLTextureEntry *te = face->getTextureEntry();
LLViewerTexture *imagep = face->getTexture();
LLViewerTexture *imagep = nullptr;
U32 ch_min;
U32 ch_max;
if (!te->getGLTFRenderMaterial())
{
ch_min = LLRender::DIFFUSE_MAP;
ch_max = LLRender::SPECULAR_MAP;
}
else
{
ch_min = LLRender::BASECOLOR_MAP;
ch_max = LLRender::EMISSIVE_MAP;
}
for (U32 ch = ch_min; (!imagep && ch <= ch_max); ++ch)
{
// Get _a_ non-null texture if possible (usually diffuse/basecolor, but could be something else)
imagep = face->getTexture(ch);
}
if (!imagep || !te ||
face->mExtents[0].equals3(face->mExtents[1]))
{
@ -940,12 +966,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
// if the face has gotten small enough to turn off texture animation and texture
// animation is running, rebuild the render batch for this face to turn off
// texture animation
// Do the opposite when the face gets big enough.
// If a face is animatable, it will always have non-null mTextureMatrix
// pointer defined after the first call to LLVOVolume::animateTextures,
// although the animation is not always turned on.
if (face->mTextureMatrix != NULL)
{
if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
(vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
if ((vsize > MIN_TEX_ANIM_SIZE) != (old_size > MIN_TEX_ANIM_SIZE))
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
// dirtyGeom+markRebuild tells the engine to call
// LLVolumeGeometryManager::rebuildGeom, which rebuilds the
// LLDrawInfo for the spatial group containing this LLFace,
// safely copying the mTextureMatrix from the LLFace the the
// LLDrawInfo. While it's not ideal to call it here, prims with
// animated faces get moved to a smaller partition to reduce
// side-effects of their updates (see shrinkWrap in
// LLVOVolume::animateTextures).
mDrawable->getSpatialGroup()->dirtyGeom();
gPipeline.markRebuild(mDrawable->getSpatialGroup());
}
}

View File

@ -372,17 +372,22 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false)
U32 emissive = GL_RGB16F;
bool hdr = gSavedSettings.getBOOL("RenderHDREnabled") && gGLManager.mGLVersion > 4.05f;
LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);
if (!hdr)
{
norm = GL_RGBA;
norm = GL_RGB10_A2;
emissive = GL_RGB;
}
bool valid = true
&& target.addColorAttachment(orm) // frag-data[1] specular OR PBR ORM
&& target.addColorAttachment(norm) // frag_data[2] normal+fogmask, See: class1\deferred\materialF.glsl & softenlight
&& target.addColorAttachment(emissive); // frag_data[3] PBR emissive OR material env intensity
bool valid = true;
valid = valid && target.addColorAttachment(orm); // frag-data[1] specular OR PBR ORM
valid = valid && target.addColorAttachment(norm);
if (has_emissive)
{
valid = valid && target.addColorAttachment(emissive); // frag_data[3] PBR emissive OR material env intensity
}
return valid;
}
@ -932,7 +937,7 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)
GLuint screenFormat = hdr ? GL_RGBA16F : GL_RGBA;
if (!mRT->screen.allocate(resX, resY, screenFormat)) return false;
if (!mRT->screen.allocate(resX, resY, GL_RGBA16F)) return false;
mRT->deferredScreen.shareDepthBuffer(mRT->screen);
@ -7201,28 +7206,35 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool
static LLStaticHashedString dt("dt");
static LLStaticHashedString noiseVec("noiseVec");
static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params");
static LLStaticHashedString dynamic_exposure_params2("dynamic_exposure_params2");
static LLStaticHashedString dynamic_exposure_e("dynamic_exposure_enabled");
static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", false);
static LLCachedControl<bool> dynamic_exposure_enabled(gSavedSettings, "RenderDynamicExposureEnabled", true);
static LLCachedControl<F32> dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f);
static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true);
static LLCachedControl<F32> dynamic_exposure_speed_error(gSavedSettings, "RenderDynamicExposureSpeedError", 0.1f);
static LLCachedControl<F32> dynamic_exposure_speed_target(gSavedSettings, "RenderDynamicExposureSpeedTarget", 2.f);
LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky();
F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust);
F32 exp_min = 1.f;
F32 exp_max = 1.f;
F32 exp_min = sky->getHDRMin();
F32 exp_max = sky->getHDRMax();
if (probe_ambiance > 0.f)
if (dynamic_exposure_enabled)
{
F32 hdr_scale = sqrtf(LLEnvironment::instance().getCurrentSky()->getGamma()) * 2.f;
if (hdr_scale > 1.f)
{
exp_min = 1.f / hdr_scale;
exp_max = hdr_scale;
}
exp_min = sky->getHDROffset() - exp_min;
exp_max = sky->getHDROffset() + exp_max;
}
else
{
exp_min = sky->getHDROffset();
exp_max = sky->getHDROffset();
}
shader->uniform1f(dt, gFrameIntervalSeconds);
shader->uniform2f(noiseVec, ll_frand() * 2.0f - 1.0f, ll_frand() * 2.0f - 1.0f);
shader->uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max);
shader->uniform4f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max, dynamic_exposure_speed_error);
shader->uniform4f(dynamic_exposure_params2, sky->getHDROffset(), exp_min, exp_max, dynamic_exposure_speed_target);
mScreenTriangleVB->setBuffer();
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
@ -7282,7 +7294,7 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst)
shader.uniform1i(tonemap_type, tonemap_type_setting);
static LLCachedControl<F32> tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f);
shader.uniform1f(tonemap_mix, tonemap_mix_setting);
shader.uniform1f(tonemap_mix, psky->getTonemapMix());
mScreenTriangleVB->setBuffer();
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
@ -8698,6 +8710,7 @@ void LLPipeline::renderDeferredLighting()
soften_shader.uniform1f(ssao_max_str, ssao_max);
LLEnvironment &environment = LLEnvironment::instance();
soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0);
soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV);

View File

@ -220,13 +220,11 @@
<combo_box.item label="Geringe (4) Qualität" name="4"/>
<combo_box.item label="Keine (5) Texturen" name="5"/>
</combo_box>
<text name="Alpha Mask Rendering">
Darstellung von Alpha-Masken:
</text>
<check_box label="Alpha-Masken verwenden" tool_tip="Falls aktiviert werden Alpha-Masken korrekt dargestellt." name="RenderAutoMaskAlphaDeferred"/>
<text name="Miscellaneous Rendering">
Sonstige Darstellungsoptionen:
</text>
<check_box label="Vintage-Modus" tool_tip="Deaktiviert diverse Features der Rendering-Pipeline um die Leistung auf älteren Maschinen zu verbessern und nähert das Aussehen der Welt näher an das Aussehen vor Version 7 an." name="RenderVintageMode"/>
<check_box label="Alpha-Masken verwenden" tool_tip="Falls aktiviert werden Alpha-Masken korrekt dargestellt." name="RenderAutoMaskAlphaDeferred"/>
<check_box label="Leuchten anzeigen" tool_tip="Stellt Leuchteffekte dar. Stärke muss auf 0 gesetzt werden, um Leuchteffekte zu deaktiveren, falls Schatten aktiviert sind." name="RenderGlow"/>
<slider label="Stärke:" tool_tip="Leuchtstärke. Größer = Breitere und weichere Darstellung (Standardwert: 2)" name="glow_strength"/>
<check_box label="Avatare anzeigen, die nicht vollständig geladen sind" name="RenderUnloadedAvatars"/>

View File

@ -684,6 +684,20 @@
function="Pref.RenderOptionUpdate" />
</check_box>
<check_box
control_name="RenderVintageMode"
height="16"
initial_value="false"
label="Vintage Mode"
layout="topleft"
left="420"
name="VintageMode"
top_delta="20"
width="240">
<check_box.commit_callback
function="Pref.RenderOptionUpdate" />
</check_box>
<text
type="string"
length="1"

View File

@ -1245,7 +1245,7 @@ If you do not understand the distinction then leave this control alone."
layout="topleft"
left="10"
name="World Updating"
top_pad="10"
top_pad="5"
width="308">
World Updating:
</text>
@ -1310,7 +1310,7 @@ If you do not understand the distinction then leave this control alone."
layout="topleft"
left="10"
name="Texture Rendering"
top_pad="7"
top_pad="4"
width="308">
Texture Rendering:
</text>
@ -1369,13 +1369,13 @@ If you do not understand the distinction then leave this control alone."
<text
type="string"
length="1"
top_pad="15"
top_pad="10"
follows="top|left"
height="18"
width="150"
word_wrap="true"
layout="topleft"
left="10"
left="22"
name="TextureDetailLabel">
Max Texture Quality Level:
</text>
@ -1414,12 +1414,25 @@ If you do not understand the distinction then leave this control alone."
height="12"
layout="topleft"
left="10"
name="Alpha Mask Rendering"
top_pad="5"
name="Miscellaneous Rendering"
top_pad="4"
width="308">
Alpha Mask Rendering:
Miscellaneous Rendering:
</text>
<check_box
control_name="RenderVintageMode"
height="16"
initial_value="false"
label="Vintage Mode"
tool_tip="Disable different rendering pipeline features to improve performance on older machines that makes the world look closer to how it used to prior to V7."
layout="topleft"
left_delta="10"
name="RenderVintageMode"
top_pad="6"
width="256">
<check_box.commit_callback
function="Pref.RenderOptionUpdate" />
</check_box>
<check_box
control_name="RenderAutoMaskAlphaDeferred"
height="16"
@ -1427,24 +1440,10 @@ If you do not understand the distinction then leave this control alone."
label="Render alpha masks"
tool_tip="When ticked this makes the Alpha masks (see-thru bits) render correctly"
layout="topleft"
left_delta="10"
left_delta="0"
name="RenderAutoMaskAlphaDeferred"
top_pad="6"
top_pad="2"
width="256"/>
<text
type="string"
length="1"
follows="left|top"
height="12"
layout="topleft"
left="10"
name="Miscellaneous Rendering"
top_pad="7"
width="308">
Miscellaneous Rendering:
</text>
<check_box
control_name="RenderGlow"
height="16"
@ -1452,9 +1451,9 @@ If you do not understand the distinction then leave this control alone."
label="Render glow"
tool_tip="Render glow. Note that strength needs to be set to zero to disable glow when shadows are enabled."
layout="topleft"
left_delta="10"
left_delta="0"
name="RenderGlow"
top_pad="6"
top_pad="2"
width="256"/>
<slider
enabled_control="RenderGlow"