GPU/Fragment Lighting: Difference between revisions

Neobrain (talk | contribs)
Dropping the bomb. Still somewhat incomplete, but this should be good enough to get started.
 
Halcy (talk | contribs)
Fragment Lighting Equation: updated mathbin link
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:GPU]]
Fragment lighting is a DMP extension to the standard OpenGL pipeline with which applications can calculate object lighting for each rendered pixel instead of just per vertex. The fragment lighting algorithm furthermore supports the shading models Blinn-Phong, Cook-Terrance, Ward, and microfacet-based BRDF-models. While the lighting calculations take place in a very localized position of the pixel processing pipeline, the feature interacts with different other pipeline stages.
Fragment lighting is a DMP extension to the standard OpenGL pipeline with which applications can calculate object lighting for each rendered pixel instead of just per vertex. The fragment lighting algorithm furthermore supports the shading models Blinn-Phong, Cook-Terrance, Ward, and microfacet-based BRDF-models. While the lighting calculations take place in a very localized position of the pixel processing pipeline, the feature interacts with different other pipeline stages.


Line 32: Line 33:


== Fragment Lighting Equation ==
== Fragment Lighting Equation ==
There are two lighting equations: One for the primary color and one for the secondary color. Both of them are given in section 3.2.2 of the "Kazakov and Ohbuchi" source below.
There are two lighting equations: One for the primary color and one for the secondary color. Both of them are given in section 3.2.2 of the "Kazakov and Ohbuchi" source below. In addition, the fragment lighting can be set up to write to the alpha channel of the primary or secondary color depending on a selectable angle and a LUT. The equations used can be found here: http://mathb.in/26766
 
Some common setups include:
 
{| class="wikitable"
!Model
!LutD0
!LutD1
!ReflectionLuts
!Geometry factors
!SpotlightLut
|-
|Blinn-Phong
| Input: N dot H, Contents: x^s
| --
| --
| Disabled
| Spotlight setup or no-op
|-
|Cook-Torrance
| --
| Input: N dot H, D(x)
| Input: V dot H, Contents: F(x)
| Enabled
| Spotlight setup or no-op
|-
|Schlick-like
| --
| Input: N dot H, Contents: Schlick Z(x)
| Input: V dot H, Contents: F(x)
| Enabled
| Input: cos phi_i, Contents: Schlick A(x)
|-
|Subsurface scattering (not entirely sure)
| --
| Input: N dot V, Contents: Transmittance by angle
| Input: L dot N, Contents: Reflectance by angle
| Disabled
| Spotlight setup or no-op
|}
 
s is the specularity factor for Blinn-Phong.
 
Spotlight setup means input -L dot P and contents spotlight falloff.
 
F and D can be found in http://inst.cs.berkeley.edu/~cs294-13/fa09/lectures/cookpaper.pdf
 
Schlick Z and Schlick A are defined in http://www.cs.virginia.edu/~jdl/bib/appearance/analytic%20models/schlick94b.pdf .
 
The Fresnel LUT can be used to, for example, blend two colours according to how oblique the view angle is, or to simply additively blend white onto fragments with an exponential falloff, resulting in rim lighting.


== Fragment Lighting Output ==
== Fragment Lighting Output ==
Line 40: Line 90:
This wiki page can only give a short overview of the fragment lighting feature. Luckily, there is a plethora of public literature available which describes the feature in more detail:
This wiki page can only give a short overview of the fragment lighting feature. Luckily, there is a plethora of public literature available which describes the feature in more detail:
* Everitt - "Per-Pixel Lighting": A presentation given at the Game Developers Conference 2001 about per-pixel lighting. It doesn't have anything to do with the PICA200 algorithm, but explains the core ideas very well (especially the concepts of surface-local space and how it relates to other coordinate systems).
* Everitt - "Per-Pixel Lighting": A presentation given at the Game Developers Conference 2001 about per-pixel lighting. It doesn't have anything to do with the PICA200 algorithm, but explains the core ideas very well (especially the concepts of surface-local space and how it relates to other coordinate systems).
* Kazakov and Ohbuchi - "Primitive Processing and Advanced Shading Architecture for Embedded Space": Provides a general overview over the fragment lighting algorithm used by the PICA200 and provides explicit formulas for the primary and secondary lighting output.
* Kazakov and Ohbuchi - "Primitive Processing and Advanced Shading Architecture for Embedded Space": Provides a general overview over the fragment lighting algorithm used by the PICA200 and provides explicit formulas for the primary and secondary lighting output. NOTE: There exist both a scientific publication and a short presentation with this title. Both are useful, but the former goes into much greater detail.
* Ohbuchi and Unno - "A Real-Time Configurable Shader Based on Lookup Tables": Provides a very detailed explanantion of the fragment lighting implementation
* Ohbuchi and Unno - "A Real-Time Configurable Shader Based on Lookup Tables": Provides a very detailed explanantion of the fragment lighting implementation
* Kuijk and Blake - "Faster Phong Shading via Angular Interpolation": Explains in greater detail how quaternions can be used to encode information about normals and tangents (and how quaternions are easier to interpolate than vectors).
* Kuijk and Blake - "Faster Phong Shading via Angular Interpolation": Explains in greater detail how quaternions can be used to encode information about normals and tangents (and how quaternions are easier to interpolate than vectors).