#975 Add RenderHDRISplitScreen debug setting (#976)

* #975 Add RenderHDRISplitScreen debug setting

* Create hdri_local_preview.md
master
RunitaiLinden 2024-03-13 12:27:33 -05:00 committed by GitHub
parent ef75523555
commit d909e72438
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 73 additions and 28 deletions

View File

@ -0,0 +1,21 @@
A resident may swap out their sky for an EXR format HDRI for the purposes of previewing how their object would render in Second Life in an environment that matches the supplied HDRI. This should aid in matching inworld lighting with external tools so artists can know if their content has imported properly.
To load an HDRI, click Develop->Render Tests->HDRI Preview:
![image](https://github.com/secondlife/viewer/assets/23218274/fbdeab5f-dc1f-4406-be19-0c9ee7437b3f)
Choose an EXR image. A library of publicly available HDRIs can be found here: https://polyhaven.com/hdris
The Personal Lighting floater will open, and the sky will be replaced with the HDRI you chose. Reflection Probes will reset, and the scene will be illuminated by the HDRI.
Three debug settings affect how the HDRI is displayed:
RenderHDRIExposure - Exposure adjustment of HDRI when previewing an HDRI. Units are EV. Sane values would be -10 to 10.
RenderHDRIRotation - Rotation (in degrees) of environment when previewing an HDRI.
RenderHDRISplitScreen - What percentage of screen to render using HDRI vs EEP sky.
Exposure and Rotation should behave similarly to the rotation and exposure controls in Substance Painter.
Split Screen can be used to display an EEP sky side-by-side with an HDRI sky to aid in authoring an EEP sky that matches an HDRI sky. It is currently expected that EEP sun disc, moon, clouds, and stars do not render when previewing an HDRI, but that may change in the future.

View File

@ -9373,6 +9373,17 @@
<key>Value</key>
<real>0.0</real>
</map>
<key>RenderHDRISplitScreen</key>
<map>
<key>Comment</key>
<string>What percentage of screen to render using HDRI vs EEP sky.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>1.0</real>
</map>
<key>RenderMaxOpenGLVersion</key>
<map>
<key>Comment</key>

View File

@ -28,8 +28,10 @@ in vec3 vary_HazeColor;
in float vary_LightNormPosDot;
#ifdef HAS_HDRI
in vec3 vary_position;
in vec4 vary_position;
in vec3 vary_rel_pos;
uniform float sky_hdr_scale;
uniform float hdri_split_screen;
uniform mat3 env_mat;
uniform sampler2D environmentMap;
#endif
@ -81,33 +83,39 @@ vec3 halo22(float d)
void main()
{
vec3 color;
#ifdef HAS_HDRI
vec3 pos = normalize(vary_position);
pos = env_mat * pos;
vec2 texCoord = vec2(atan(pos.z, pos.x) + PI, acos(pos.y)) / vec2(2.0 * PI, PI);
vec3 color = textureLod(environmentMap, texCoord.xy, 0).rgb * sky_hdr_scale;
color = min(color, vec3(8192*8192*16)); // stupidly large value arrived at by binary search -- avoids framebuffer corruption from some HDRIs
vec3 frag_coord = vary_position.xyz/vary_position.w;
if (-frag_coord.x > ((1.0-hdri_split_screen)*2.0-1.0))
{
vec3 pos = normalize(vary_rel_pos);
pos = env_mat * pos;
vec2 texCoord = vec2(atan(pos.z, pos.x) + PI, acos(pos.y)) / vec2(2.0 * PI, PI);
color = textureLod(environmentMap, texCoord.xy, 0).rgb * sky_hdr_scale;
color = min(color, vec3(8192*8192*16)); // stupidly large value arrived at by binary search -- avoids framebuffer corruption from some HDRIs
frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_HAS_HDRI);
#else
// Potential Fill-rate optimization. Add cloud calculation
// back in and output alpha of 0 (so that alpha culling kills
// the fragment) if the sky wouldn't show up because the clouds
// are fully opaque.
vec3 color = vary_HazeColor;
float rel_pos_lightnorm = vary_LightNormPosDot;
float optic_d = rel_pos_lightnorm;
vec3 halo_22 = halo22(optic_d);
color.rgb += rainbow(optic_d);
color.rgb += halo_22;
color.rgb *= 2.;
color.rgb = clamp(color.rgb, vec3(0), vec3(5));
frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_SKIP_ATMOS);
frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_HAS_HDRI);
}
else
#endif
{
// Potential Fill-rate optimization. Add cloud calculation
// back in and output alpha of 0 (so that alpha culling kills
// the fragment) if the sky wouldn't show up because the clouds
// are fully opaque.
color = vary_HazeColor;
float rel_pos_lightnorm = vary_LightNormPosDot;
float optic_d = rel_pos_lightnorm;
vec3 halo_22 = halo22(optic_d);
color.rgb += rainbow(optic_d);
color.rgb += halo_22;
color.rgb *= 2.;
color.rgb = clamp(color.rgb, vec3(0), vec3(5));
frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_SKIP_ATMOS);
}
frag_data[0] = vec4(0);
frag_data[1] = vec4(0);

View File

@ -36,7 +36,8 @@ out vec3 vary_HazeColor;
out float vary_LightNormPosDot;
#ifdef HAS_HDRI
out vec3 vary_position;
out vec4 vary_position;
out vec3 vary_rel_pos;
#endif
// Inputs
@ -77,7 +78,8 @@ void main()
vec3 rel_pos = position.xyz - camPosLocal.xyz + vec3(0, 50, 0);
#ifdef HAS_HDRI
vary_position = rel_pos;
vary_rel_pos = rel_pos;
vary_position = pos;
#endif
// Adj position vector to clamp altitude

View File

@ -153,12 +153,15 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca
static LLCachedControl<F32> hdri_exposure(gSavedSettings, "RenderHDRIExposure", 0.0f);
static LLCachedControl<F32> hdri_rotation(gSavedSettings, "RenderHDRIRotation", 0.f);
static LLCachedControl<F32> hdri_split(gSavedSettings, "RenderHDRISplitScreen", 1.f);
static LLStaticHashedString hdri_split_screen("hdri_split_screen");
LLMatrix3 rot;
rot.setRot(0.f, hdri_rotation*DEG_TO_RAD, 0.f);
sky_shader->uniform1f(LLShaderMgr::SKY_HDR_SCALE, powf(2.f, hdri_exposure));
sky_shader->uniformMatrix3fv(LLShaderMgr::DEFERRED_ENV_MAT, 1, GL_FALSE, (F32*) rot.mMatrix);
sky_shader->uniform1f(hdri_split_screen, hdri_split);
}
else
{