Use terrain normal map in lightning

Registered by Erik Ogenvik

In order for us to better support lights on entities we must first improve the terrain lightning. This means that we must provide normals for the terrain so we properly can do normal mapping and shading through shaders.
The PLSM has support for providing vertex normals, but using these aren't a good idea due to the LOD system. As terrain geometry is moved between LOD levels the normals will shift, which won't look good. Instead we should provide the normals in a texture, very much like we now do with the terrain shadow. In fact, I think we could actually reuse the shadow texture, using the "rgb" channels for the normal and the alpha channel for the shadow.

In Ember this would mean some changes to the classes in src/components/ogre/terrain, and then additional changes to the Splat.cg shader.

Note that Mercator has a method Mercator::Terrain::getHeightAndNormal which is used now. This method will however recalculate the normal each time it's called. Instead there's already normal information provided for each Mercator::Segment (updated when Mercator::Segment::populateNormals is called). It can only be accessed on Segment basis though through the Mercator::Segment::getNormals() method. Updating the TerrainShadow code to use this would probably bring quite a speed increase in the shadow generation.

Blueprint information

Status:
Complete
Approver:
Erik Ogenvik
Priority:
Medium
Drafter:
Erik Ogenvik
Direction:
Needs approval
Assignee:
Alexey Torkhov
Definition:
Approved
Series goal:
None
Implementation:
Implemented
Milestone target:
milestone icon 0.5.6
Started by
Erik Ogenvik
Completed by
Erik Ogenvik

Related branches

Sprints

Whiteboard

There are three issues that needs to be fixed for this to be considered complete:
* The shadow setup needs to be put into more suitable classes.
* We need to have shadow fallbacks that guarantee that everything still looks good on machines without newer GPUs
* We need to implement support for alpha channels, so that for example the shadows of the trees properly show the foliage.

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.