RenderEnableEmissiveBuffer - ApertureViewer/Aperture-Viewer GitHub Wiki
-
Setting Name:
RenderEnableEmissiveBuffer
-
Controlled By: This setting is typically controlled indirectly via the master setting
RenderDisableVintageMode
. WhenRenderDisableVintageMode
istrue
(default),RenderEnableEmissiveBuffer
is set totrue
. WhenRenderDisableVintageMode
isfalse
,RenderEnableEmissiveBuffer
is set tofalse
. -
Assumed XML Definition (if directly controlled):
<key>RenderEnableEmissiveBuffer</key> <map> <key>Comment</key> <string>Enables a dedicated buffer for PBR emissive material properties, affecting probe lighting and glow.</string> <key>Persist</key> <integer>1</integer> <!-- Likely persistent if controlled directly --> <key>Type</key> <string>Boolean</string> <key>Value</key> <integer>1</integer> <!-- Default Value (true) when modern pipeline is active --> </map>
-
Data Type:
Boolean
(Stored as integer 0/1, used asbool
in C++) -
Default Value:
true
(whenRenderDisableVintageMode
is true).
The primary function of RenderEnableEmissiveBuffer
is to control the allocation and use of a dedicated render target (G-Buffer attachment) specifically for storing information about Physically Based Rendering (PBR) emissive materials.
This setting acts as a crucial enabler for two distinct PBR-specific effects:
- PBR Indirect Lighting via Reflection Probes: When enabled, it allows PBR materials with an emissive component (texture or color tint with Luminance > 0) to contribute accurately colored indirect light within the bounds of Reflection Probes. This light affects the appearance of nearby non-emissive surfaces captured by the probe.
-
Accurate PBR Glow Effect: When enabled (and
RenderGlow
is also active), it allows the Glow post-processing effect to correctly read the intended color and intensity from PBR emissive materials, resulting in a visually correct and often significantly brighter glow contribution compared to when the buffer is disabled.
Critically, this setting has NO direct effect on traditional Blinn-Phong (BP) materials. BP materials use the "Fullbright" flag and their tint color for probe lighting contributions, and their Glow (f32) value and the RenderGlowNoise
setting primarily influence their glow appearance.
-
File:
llcommon/llviewercontrol.cpp
-
Function:
handleDisableVintageMode(const LLSD& newvalue)
-
Logic: Directly sets
RenderEnableEmissiveBuffer
based on theRenderDisableVintageMode
value.gSavedSettings.setBOOL("RenderEnableEmissiveBuffer", newvalue.asBoolean());
-
Logic: Directly sets
-
Function:
-
File:
llcommon/pipeline.cpp
-
Function:
LLPipeline::addDeferredAttachments(...)
-
Logic: Checks this setting (via cached
has_emissive
). If true, allocates the 3rd color attachment for the main G-Buffer (mRT->deferredScreen
, attachment index 3). The format (GL_RGB16F
orGL_RGB
) depends onRenderHDREnabled
. This is where the buffer itself is created.
static LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false); // ... (check RenderHDREnabled for format) ... if (has_emissive) { valid = valid && target.addColorAttachment(emissive); // frag_data[3] PBR emissive }
-
Logic: Checks this setting (via cached
-
Function:
LLPipeline::generateLuminance(...)
-
Logic: The
gLuminanceProgram
shader reads from the emissive buffer (texture unit bound toLLShaderMgr::DEFERRED_EMISSIVE
, sampling attachment index 3 ofdeferredScreen
) if available. This contribution is added to the luminance calculated from diffuse surfaces, affecting the input to the auto-exposure system.
(Note: The code snippet bindingchannel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); if (channel > -1) { // mGlow[1] is bound here in the provided code snippet, which seems potentially incorrect // if it's meant to read the main emissive G-buffer. // Assumed intent/correct implementation: Read from mRT->deferredScreen attachment 3. mRT->deferredScreen.bindTexture(3, channel, LLTexUnit::TFO_POINT); // Hypothetical correct binding // mGlow[1].bindTexture(0, channel); // Actual code - reads intermediate glow buffer? Needs verification. }
mGlow[1]
here is suspicious and might be an error or relate to a later stage. The logical place to read the main emissive G-Buffer ismRT->deferredScreen
attachment 3). -
Logic: The
-
Function:
LLPipeline::generateGlow(...)
-
Logic: The
gGlowExtractProgram
likely implicitly or explicitly uses the emissive buffer data when extracting initial glow information from the scene, contributing to the final bloom effect if the buffer is enabled.
-
Logic: The
-
Function:
-
File:
llcommon/llviewershadermgr.cpp
-
Function:
add_common_permutations(LLGLSLShader* shader)
-
Logic: If
RenderEnableEmissiveBuffer
is true, adds the preprocessor definition#define HAS_EMISSIVE 1
when compiling many shaders. Shaders using PBR materials rely on this define to include code paths that write to or read from the emissive buffer.
-
Logic: If
-
Function:
-
Enabling (
true
):-
Memory: Increases GPU VRAM usage by adding another full-screen render target to the G-Buffer. The size increase depends on screen resolution and whether HDR is enabled (e.g.,
GL_RGB16F
uses more VRAM thanGL_RGB8
). -
GPU Load:
- Adds a minor cost during the G-Buffer pass for shaders (PBR opaque, PBR alpha mask) writing to the emissive buffer.
- Adds a minor cost for shaders reading from the buffer (e.g.,
generateLuminance
, potentiallygGlowExtractProgram
, reflection probe rendering).
- Overall: A moderate increase in VRAM usage and a small increase in GPU processing load. Usually negligible on modern GPUs unless severely VRAM limited.
-
Memory: Increases GPU VRAM usage by adding another full-screen render target to the G-Buffer. The size increase depends on screen resolution and whether HDR is enabled (e.g.,
-
Disabling (
false
):- Memory: Saves the VRAM required for the emissive G-Buffer attachment.
- GPU Load: Reduces GPU load slightly by eliminating writes/reads associated with the emissive buffer.
- Overall: Provides a small performance optimization, primarily in VRAM savings.
Conclusion: Enabling the emissive buffer has a performance cost, mainly in VRAM. Disabling it saves resources but breaks PBR emissive functionality.
The visual impact depends heavily on whether PBR or Blinn-Phong materials are used.
-
PBR Materials:
-
Reflection Probe Lighting:
-
Enabled (
true
): PBR materials with Emissive Tint (L>0) correctly contribute colored indirect light within reflection probes. This adds realism to reflections on nearby surfaces. -
Disabled (
false
): PBR materials do not contribute any light to reflection probes based on their emissive properties.
-
Enabled (
-
Glow Effect (Requires
RenderGlow=true
):-
Enabled (
true
): PBR materials with Emissive Tint (L>0) contribute their intended color and intensity to the glow effect. The glow appears correct, often bright, and accurately colored. IfRenderGlowNoise=true
, this combines with the noise effect. -
Disabled (
false
): The PBR material's specific emissive contribution to glow is lost. IfRenderGlowNoise=true
and Emissive Tint (L>0), a glow effect may still appear but seems driven primarily by the noise map (potentially desaturated, speckled, weaker). IfRenderGlowNoise=false
, PBR glow is likely absent or minimal.
-
Enabled (
-
Reflection Probe Lighting:
-
Blinn-Phong (BP) Materials:
-
Reflection Probe Lighting:
-
Enabled/Disabled (
true
/false
): NO EFFECT. BP materials contribute light to probes based on theFullbright
flag and Tint color (L>0), independent of this setting.
-
Enabled/Disabled (
-
Glow Effect (Requires
RenderGlow=true
):-
Enabled/Disabled (
true
/false
): NO EFFECT. BP glow depends on the material's Glow value (f32), theFullbright
flag, andRenderGlowNoise
. IfFullbright
is OFF andRenderGlowNoise
is ON, glow seems driven by the noise map. IfFullbright
is ON andRenderGlowNoise
is ON, the fullbright appearance enhances/combines with the noise-driven glow. IfRenderGlowNoise
is OFF andFullbright
is OFF, BP materials typically show no glow regardless of their Glow value or this setting.
-
Enabled/Disabled (
-
Reflection Probe Lighting:
Summary of Visual Impact: Enabling is essential for correct PBR emissive lighting in probes and visually correct PBR glow. Disabling breaks these PBR features but saves minor resources and has no impact on Blinn-Phong materials.
-
Defined Default:
true
(implicitly set byRenderDisableVintageMode
being true).
This is the correct and intended default for the modern PBR rendering pipeline. Disabling it fundamentally breaks key visual features of PBR emissive materials.
-
For Correct PBR Rendering:
true
(Enabled). This is mandatory for PBR emissive materials to function as intended, both for probe lighting and for glow effects. The minor performance cost is generally worth the visual fidelity on capable hardware. -
When to Disable: Only if deliberately using the "Vintage" rendering mode (via
RenderDisableVintageMode
), or possibly in extreme VRAM-limited scenarios where every buffer counts (though disabling HDR viaRenderHDREnabled
is usually far more impactful). Disabling this breaks PBR emissive rendering.
Objective: To observe the conditional effects on PBR probe lighting and PBR/BP glow.
Prerequisites: Access to toggle RenderDisableVintageMode
(or directly RenderEnableEmissiveBuffer
if decoupled). Access to PBR and BP materials with emissive/fullbright/glow properties. A scene with reflection probes active (RenderReflectionProbeLevel
> 0) and optionally Glow enabled (RenderGlow
).
Procedure:
-
PBR Probe Lighting Test:
- Place a PBR object with a bright emissive color (Tint L>0) near a non-emissive, reflective surface, ensuring both are within a probe's influence.
- Enable HDR (
RenderDisableVintageMode=true
). - Set
RenderEnableEmissiveBuffer
totrue
(default). Observe the reflection: colored light from the PBR object should illuminate the reflective surface within the probe's capture. - Set
RenderEnableEmissiveBuffer
tofalse
(by settingRenderDisableVintageMode=false
and back totrue
, or directly if possible). Observe the reflection again. - Expected Observation: The colored indirect light from the PBR object on the reflective surface should disappear when the buffer is disabled.
-
PBR Glow Test:
- View a PBR object with Emissive Tint (L>0).
- Enable
RenderGlow
andRenderHDREnabled
. Optionally toggleRenderGlowNoise
. - Set
RenderEnableEmissiveBuffer
totrue
. Observe glow intensity and color. - Set
RenderEnableEmissiveBuffer
tofalse
. Observe glow again. - Expected Observation: Glow should be significantly brighter and/or more accurately colored when the buffer is enabled. When disabled (especially if Noise is ON), glow might appear weaker, desaturated, or dominated by noise speckle.
-
BP Control Test:
- Repeat steps 1 & 2 using a BP object with
Fullbright=true
and/or a non-zero Glow value. - Toggle
RenderEnableEmissiveBuffer
ON and OFF. -
Expected Observation: Toggling
RenderEnableEmissiveBuffer
should have no noticeable effect on the BP object's probe lighting contribution or its glow appearance.
- Repeat steps 1 & 2 using a BP object with
Objective: To verify conditional buffer allocation, shader compilation defines, and buffer usage.
Prerequisites: Debug build, graphics debugger, ability to modify settings (likely via RenderDisableVintageMode
).
Procedure:
-
Verify Buffer Allocation:
- Use the graphics debugger. Enable HDR and Emissive Buffer (
RenderDisableVintageMode=true
). Capture frame. Inspect G-Buffer attachments (mRT->deferredScreen
). Verify attachment 3 exists and has an appropriate format (e.g.,GL_RGB16F
). - Disable Emissive Buffer (
RenderDisableVintageMode=false
). Reload/restart. Capture frame. Verify G-Buffer attachment 3 is absent or unused.
- Use the graphics debugger. Enable HDR and Emissive Buffer (
-
Verify Shader Defines:
- Enable Emissive Buffer. Capture frame. Select a draw call using a PBR shader (e.g.,
gDeferredPBROpaqueProgram
). Inspect the compiled shader source or definition. Verify#define HAS_EMISSIVE 1
is present. - Disable Emissive Buffer. Capture frame. Inspect the same shader. Verify
#define HAS_EMISSIVE 1
is absent.
- Enable Emissive Buffer. Capture frame. Select a draw call using a PBR shader (e.g.,
-
Verify Buffer Reads:
- Enable Emissive Buffer. Capture frame. Step into
LLPipeline::generateLuminance
. Verify that the code path attempting to bind/readLLShaderMgr::DEFERRED_EMISSIVE
is active and binds the correct texture/attachment (likely G-Buffer attachment 3). - Disable Emissive Buffer. Capture frame. Verify the same code path is inactive or the texture binding for emissive is skipped/uses a dummy texture.
- Enable Emissive Buffer. Capture frame. Step into
Feature | Detail |
---|---|
Setting Name | RenderEnableEmissiveBuffer |
Controlled Via | RenderDisableVintageMode |
Purpose | Enables dedicated render target for PBR Emissive data. |
PBR Effect (Lighting) | Enables PBR emissive materials to contribute colored indirect light within Reflection Probes. |
PBR Effect (Glow) | Enables correct color/intensity contribution of PBR emissive materials to the Glow effect. |
Blinn-Phong Effect | None. BP uses Fullbright/Glow value/Noise for its lighting/glow. |
Default Value |
true (when modern pipeline active) |
Code Locations |
pipeline (allocation, usage), llviewershadermgr (compilation define), llviewercontrol (setter) |
Performance | Moderate VRAM increase, minor GPU load increase when enabled. |
Visual Impact | Essential for correct PBR emissive visuals (probe lighting & glow). No impact on BP. |
Recommended |
true for PBR pipeline. Disabling breaks PBR emissive. |