Skip to content
Snippets Groups Projects

Improve pipeline Light input

Merged Jonathan Kunstwald requested to merge feature/jk-dev into master
1 unresolved thread
10 files
+ 81
197
Compare changes
  • Side-by-side
  • Inline
Files
10
+ 20
7
@@ -62,7 +62,7 @@ Get the shadow amount at the fragment, in a range of 0 to 1. Usually applied to
By the nature of a clustered renderer, each fragment is assigned a set of light sources that affect it. These can be accessed with a special macro in the shader, like this:
```GLSL
FOREACH_LIGHT(viewSpaceZ, i)
FOREACH_LIGHT(i)
{
LightData light = getLight(i);
}
@@ -74,8 +74,10 @@ LightData light = getLight(i);
vec3 L;
vec3 radiance;
getTubeLightInfo(light, worldPos, V, N, roughness, L, radiance);
// Use L and radiance...
```
These values can then be used with any point light shading model. A good fit is the GGX implementation in `glow-extras-material`, as can be seen in the RenderingPipeline sample.
These values can then be used with any point light shading model. A good fit is the GGX implementation in `glow-extras-material`, as can be seen in the RenderingPipeline sample. Note that `roughness` is a required argument for the area normalization for sphere- and tube lights, matched for a GGX-like interpretation of roughness (from UE4's shading model).
### Transparent pass
@@ -155,7 +157,7 @@ A fragment shader is optional, but can be added to discard fragments.
### RenderScene
All of the possible runtime pipeline configuration is encompassed by the `RenderScene` struct. It contains various parameters:
All of the possible runtime pipeline configuration is encompassed by the `RenderScene` struct. It contains various parameters, some of them are:
- Clear color
- Atmospheric scattering config
- Sun direction and color
@@ -164,17 +166,28 @@ All of the possible runtime pipeline configuration is encompassed by the `Render
- Postprocessing settings
- Color grading LUT
It also contains the lights that are currently in the scene.
### Lights
Since the pipeline uses a clustered forward renderer, a rather large number of lights can be evaluated at reasonable performance. All lights in the `RenderScene` are assigned to the clusters of the camera frustum and made accessible to the fragment shaders of the opaque pass. The pipeline exclusively supports tube lights, which degenerate to sphere- and point lights whenever needed. The `Light` struct provides constructors for all three types accordingly.
Since the pipeline uses a clustered forward renderer, a rather large number of lights can be evaluated at reasonable performance. All lights are assigned to the clusters of the camera frustum and made accessible to the fragment shaders of the opaque pass. The pipeline internally only uses tube lights, which degenerate to sphere- and point lights whenever needed.
To register lights, override this `RenderCallback` method:
```C++
void onGatherLights(LightCallback&) override;
```
It supplies a `LightCallback`, which is used to register any sort of light visible in the scene:
```C++
void onGatherLights(LightCallback& lc) {
lc.addLight(position, color, radius); // Point Light
lc.addLight(position, color, size, radius); // Sphere Light
lc.addLight(positionA, positionB, color, size, radius); // Tube Light
}
```
## Miscellaneous
### 3D position query
Receive the 3D position of geometry located at a given pixel.
Receive the 3D position of geometry (that is present in the depth buffer) located at a given pixel.
```C++
optional<glm::vec3> RenderPipeline::queryPosition3D(glm::uvec2 const &pixel) const
```
Loading