343
edits
mNo edit summary |
No edit summary |
||
Line 185: | Line 185: | ||
* Unlike in Rembrandt, polygons facing the Sun are the ones used to generate the shadow map, so single sided surfaces and non-closed objects should be rendered correctly. | * Unlike in Rembrandt, polygons facing the Sun are the ones used to generate the shadow map, so single sided surfaces and non-closed objects should be rendered correctly. | ||
== Porting and developing Effects == | == Porting and developing Effects/Shaders == | ||
Effects can now have different implementations depending on the Compositor pipeline being used. For example, a grass Effect implemented in the ALS pipeline might have much more detail than the one in the low-spec pipeline. Still, they both implement the "look" of grass, so they share the same Effect file (grass.eff). | Effects can now have different implementations depending on the Compositor pipeline being used. For example, a grass Effect implemented in the ALS pipeline might have much more detail than the one in the low-spec pipeline. Still, they both implement the "look" of grass, so they share the same Effect file (grass.eff). | ||
Line 207: | Line 207: | ||
To add features specific to a particular pipeline (like shadows in the ALS pipeline), see each pipeline's documentation below. | To add features specific to a particular pipeline (like shadows in the ALS pipeline), see each pipeline's documentation below. | ||
== | === ALS === | ||
=== Low-Spec | ==== Adding shadows ==== | ||
==== Rendering correct depth ==== | |||
The ALS pipeline uses a logarithmic depth buffer. This is accomplished by writing to <tt>gl_FragDepth</tt> in the fragment shader or by modifying <tt>gl_Position.z</tt> in the vertex shader. The 2nd option is faster but doesn't work for very large polygons (like the terrain), so you should use it by default unless visual bugs appear. | |||
* '''1st option'''. | |||
Add the following to the vertex shader: | |||
<syntaxhighlight lang="cplusplus"> | |||
uniform float fg_Fcoef; | |||
[...] | |||
gl_Position = ... | |||
gl_Position.z = (log2(max(1e-6, 1.0 + gl_Position.w)) * fg_Fcoef - 1.0) * gl_Position.w; | |||
</syntaxhighlight> | |||
* '''2nd option'''. | |||
Add the following to the vertex shader: | |||
<syntaxhighlight lang="cplusplus"> | |||
varying float flogz; | |||
[...] | |||
gl_Position = ... | |||
flogz = 1.0 + gl_Position.w; | |||
</syntaxhighlight> | |||
And the following to the fragment shader: | |||
<syntaxhighlight lang="cplusplus"> | |||
uniform float fg_Fcoef; | |||
varying float flogz; | |||
[...] | |||
gl_FragColor = ... | |||
gl_FragDepth = log2(flogz) * fg_Fcoef * 0.5; | |||
</syntaxhighlight> | |||
== Technical notes of each pipeline == | |||
=== Default (Low-Spec) === | |||
A fixed function forward rendering pipeline mainly targeted to low spec systems. It imitates the classic forward pipeline used before multi-pass rendering was introduced by using two near/far cameras rendering directly to the screen. | A fixed function forward rendering pipeline mainly targeted to low spec systems. It imitates the classic forward pipeline used before multi-pass rendering was introduced by using two near/far cameras rendering directly to the screen. |
edits