CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.04k stars 3.51k forks source link

Check matrix multiplication in shaders #4250

Open bagnell opened 8 years ago

bagnell commented 8 years ago

Prevent possible precision errors when transforming vertices be multiple matrices.

Go through all of the shaders and change things like:

vec4 positionWC = czm_inverseView * positionEC;
vec4 positionMC = czm_inverseModel * positionWC;

to vec4 positionMC = czm_inverseModelView * positionEC;

The only exception here is the projection matrix where we would want to do the opposite. Change gl_Position = czm_modelViewProjection * position; to

vec4 positionEC = czm_modelView * position;
gl_Position = czm_projection * positionEC;

For the first change see Creating Vast Game Worls by Emil Persson. For the second change see Tightening the Precision of Perspective Rendering by Paul Upchurch and Mathieu Desbrun and Depth Precision Visualized by Nathan Reed.

GGajanan1 commented 13 hours ago

Hi @bagnell Can You assign me this task I am ready to contribute to this