Compositor: Difference between revisions

Jump to navigation Jump to search
no 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/Shaders ==
== Effects and Shaders ==


Effects can now have different implementations depending on the Compositor pipeline being used. For example, a grass Effect implemented for a high quality pipeline might have much more detail than one that targets low specification machines. Still, they both implement the "look" of grass, so they share the same Effect file (grass.eff).
=== Schemes ===
 
Effects can have different implementations depending on the Compositor pipeline being used. For example, a grass Effect implemented for a high quality pipeline might have much more detail than one that targets low specification machines. Still, they both implement the "look" of grass, so they share the same Effect file (grass.eff).


The Compositor chooses which implementation of an Effect to render based on the <tt><scheme></tt> of the techniques.
The Compositor chooses which implementation of an Effect to render based on the <tt><scheme></tt> of the techniques.
Line 197: Line 199:
</syntaxhighlight>
</syntaxhighlight>


In this case the technique will be chosen if the Compositor pipeline <tt><scene></tt> pass uses the <tt>test-scheme</tt> Effect scheme. Consequently, porting an Effect to a pipeline will require knowing which Effect schemes it uses and writing a technique for each one. The only exception to this is the Classic pipeline, which uses techniques with no scheme.
In this case the technique will be chosen if the Compositor pipeline <tt><scene></tt> pass uses the <tt>test-scheme</tt> Effect scheme. Consequently, porting an Effect to a Compositor pipeline will require knowing which Effect schemes it uses and writing a technique for each one. The only exception to this is the Classic/default pipeline, which uses techniques with no scheme.
 
=== Built-in uniforms ===
 
The Compositor provides a set of built-in uniforms that are passed along to every shader. These uniforms must '''not''' be defined in the Effect file, as they are defined and updated in C++.
 
{| class="wikitable"
!Name
!Type
!Purpose
|-
|<tt>fg_TextureMatrix</tt>
|<tt>mat4</tt>
|Texture matrix that replaces the old fixed-function behaviour. If no texture animations are present it corresponds to the identity matrix.
|-
|<tt>fg_Viewport</tt>
|<tt>vec4</tt>
|Viewport geometry for the current pass (x, y, width, height).
|-
|<tt>fg_PixelSize</tt>
|<tt>vec2</tt>
|Inverse of the width and height of the viewport.
|-
|<tt>fg_ViewMatrix</tt>
|<tt>mat4</tt>
|View matrix given by CameraGroup for this Compositor.
|-
|<tt>fg_ViewMatrixInverse</tt>
|<tt>mat4</tt>
|Inverse of the view matrix given by CameraGroup for this Compositor.
|-
|<tt>fg_ProjectionMatrix</tt>
|<tt>mat4</tt>
|Projection matrix given by CameraGroup for this Compositor.
|-
|<tt>fg_ProjectionMatrixInverse</tt>
|<tt>mat4</tt>
|Inverse of the projection matrix given by CameraGroup for this Compositor.
|-
|<tt>fg_CameraPositionCart</tt>
|<tt>vec3</tt>
|Position of the camera in world space, expressed in cartesian coordinates.
|-
|<tt>fg_CameraPositionGeod</tt>
|<tt>vec3</tt>
|Position of the camera in world space, expressed in geodesic coordinates (longitude in radians, latitude in radians, elevation in meters).
|-
|<tt>fg_CameraDistanceToEarthCenter</tt>
|<tt>float</tt>
|Distance from the camera to the center of the Earth in meters.
|-
|<tt>fg_CameraWorldUp</tt>
|<tt>vec3</tt>
|Camera up vector in world space.
|-
|<tt>fg_CameraViewUp</tt>
|<tt>vec3</tt>
|Camera up vector in view space.
|-
|<tt>fg_EarthRadius</tt>
|<tt>float</tt>
|Earth radius right below the camera position in meters.
|-
|<tt>fg_NearFar</tt>
|<tt>vec2</tt>
|Near and far clipping planes in meters). x component is the near plane, y component is the far plane.
|-
|<tt>fg_Fcoef</tt>
|<tt>float</tt>
|Used by logarithmic depth.
|-
|<tt>fg_FOVScale</tt>
|<tt>vec2</tt>
|Used by logarithmic depth.
|-
|<tt>fg_SunDirection</tt>
|<tt>vec3</tt>
|Normalized Sun (directional light) direction in view space.
|-
|<tt>fg_SunDirectionWorld</tt>
|<tt>vec3</tt>
|Normalized Sun (directional light) direction in world space.
|-
|<tt>fg_SunZenithCosTheta</tt>
|<tt>float</tt>
|Dot product between the Sun direction and the up vector at the camera position.
|-
|<tt>fg_MoonDirection</tt>
|<tt>vec3</tt>
|Normalized Moon (directional light) direction in view space.
|-
|<tt>fg_MoonDirectionWorld</tt>
|<tt>vec3</tt>
|Normalized Moon (directional light) direction in world space.
|-
|<tt>fg_MoonZenithCosTheta</tt>
|<tt>float</tt>
|Dot product between the Moon direction and the up vector at the camera position.
|}


== Creating a custom rendering pipeline ==
== Creating a custom rendering pipeline ==
343

edits

Navigation menu