render_trav_vp - ryzom/ryzomcore GitHub Wiki


title: render_trav.cpp vertex program description: published: true date: 2023-03-01T05:19:21.131Z tags: editor: markdown dateCreated: 2022-03-08T22:39:02.478Z

Lighting setup for meshvp vertex programs that cannot use the fixed function lighting. This works independent from the fixed function lighting, and thus independent from vertex programs generated for the fixed function lighting.

Used by meshvp_wind_tree and meshvp_per_pixel_lighting.

The programs generated by this class are limited to support ambient, 1 directional light and 3 point omni lights.

beginVPLightSetup

  • Caches some values to set in uniforms and blanks unused uniforms.
  • Indices start at _VPCurrentCtStart (currently always 24)
  • Sets the position, direction and constant uniforms

changeVPLightSetupMaterial

  • Actually sets the rgba uniforms, modified by the material parameters, if not already set

0 ambient [rgba] (summation of ambient of 4 vp lights 0 to 3)

1..4 diffuse [rgba] (4 lights)

if specular

5..8 specular [rgba] (4 lights)

9 light direction of the sun (light 0) normalized (*)

10 alpha const [alpha] (**)

11 eye in object space

else

5 light direction of the sun (light 0) normalized (*)

9 alpha const [alpha] (**)

point light indices (lights 1 to 3) start at 6 without spec or 12 if specular

6/12 light pos 1

7/13 light pos 2

8/14 light pos 3

* if !supportSpecular:
* - 0: AmbientColor.
* - 1..4: DiffuseColor of 4 lights.
* - 5: - (directional Light direction) in objectSpace
* - 6..8: light position (3 pointLihgts) in objectSpace
* - 9: material Diffuse Alpha copied to output. cte is: {0,0, 1, alphaMat}
* TOTAL: 10 constants used.
* if supportSpecular:
* - 0: AmbientColor.
* - 1..4: DiffuseColor of 4 lights.
* - 5..8: SpecularColor of 4 lights. NB: SpecularColor[5].w get the specular exponent of the material
* - 9: - (directional Light direction) in objectSpace
* - 10: material Diffuse Alpha copied to output. cte is: {0,0, 1, alphaMat}
* - 11: eye position in objectSpace
* - 12..14: light position (3 pointLihgts) in objectSpace
* TOTAL: 15 constants used.

See also: CVertexProgramLighted::buildInfo()

In changeVPLightSetupMaterial the excludeStrongest flag is used to exclude the strongest light from vertex lighting. This is used so that just the strongest light can be used for per pixel lighting.

⚠️ **GitHub.com Fallback** ⚠️