Rendering
Jump to navigation
Jump to search
This page covers general rendering concerns that are not specific to model formats.
Model Specific Rendering
More information about rendering specific model formats can be found at the following pages:
Screen Effects
EffectGlow
This fullscreen effect controls both the bloom-style glow effect used by the game, and player state driven blur effects like inebriation.
To apply the effect, the game creates 4 new render targets:
- RT 0: Already exists, and holds the output of rendering the given world scene
- RT 1: Created by passing RT 0 through the FFXBox4 shader (box blur)
- RT 2: Created by passing RT 1 through the FFXGauss4 shader (4-tap gaussian blur)
- RT 3: Created by passing RT 2 through the FFXGauss4 shader (second pass)
- RT 4: Created by passing RT 0 and RT 3 through the FFXGlow shader (both targets are sampled)
FFXBox4 Shaders (7.x)
TODO: Explain how FFXBox4 works
FFXGauss4 Shaders (7.x)
TODO: Explain how FFXGauss4 works
FFXGlow Shaders (7.x)
TODO: Possibly also 6.x? 5.x?
Vertex Shader
The vertex shader used for FFXGlow is a simple full screen vertex shader, and can be found in FullScreen.bls in the appropriate vertex shader directory.
Pixel Shader
- pc_blurAmount.z: controls how much of the final blur output (RT 3) is carried over in the final output; this is used to manage effects like blurring the screen due to inebriation
- pc_blurAmount.w: controls how much 'bloom' is applied to the screen; this typically is sourced from the LightParams client database: LightParamsRec->m_glow
#version 420
layout(location = 1) in vec2 in_screenCoord;
layout(location = 2) in vec2 in_blurCoord;
layout(location = 0) out vec4 out_result;
layout(std140) uniform ps_cb0
{
vec4 pc_blurAmount;
};
uniform sampler2D pt_screenTex;
uniform sampler2D pt_blurTex;
void main()
{
float blurFactor = pc_blurAmount.z;
float glowFactor = pc_blurAmount.w;
vec4 screenColor = texture(pt_screenTex, in_screenCoord);
vec3 blurColor = texture(pt_blurTex, in_blurCoord).rgb;
// Mix screen and blur color (to handle effects like inebriation)
vec4 finalColor = vec4(mix(screenColor.rgb, blurColor, vec3(blurFactor)), 0.0);
// Calculate the glow color
vec3 glowColor = (blurColor * blurColor) * glowFactor;
// Add the glow color
finalColor.rgb += glowColor;
out_result = vec4(finalColor.rgb, screenColor.a);
}