Ortho shading fixes (#6453)
This commit is contained in:
@@ -54,6 +54,10 @@ vec3 getWorldViewVector() {
|
||||
return shading_view;
|
||||
}
|
||||
|
||||
bool isPerspectiveProjection() {
|
||||
return frameUniforms.clipFromViewMatrix[2].w != 0.0;
|
||||
}
|
||||
|
||||
/** @public-api */
|
||||
vec3 getWorldNormalVector() {
|
||||
return shading_normal;
|
||||
|
||||
@@ -33,7 +33,13 @@ void computeShadingParams() {
|
||||
#endif
|
||||
|
||||
shading_position = vertex_worldPosition.xyz;
|
||||
shading_view = normalize(frameUniforms.cameraPosition - shading_position);
|
||||
|
||||
// With perspective camera, the view vector is cast from the fragment pos to the eye position,
|
||||
// With ortho camera, however, the view vector is the same for all fragments:
|
||||
shading_view = isPerspectiveProjection() ?
|
||||
(frameUniforms.cameraPosition - shading_position) :
|
||||
frameUniforms.worldFromViewMatrix[2].xyz; // ortho camera backward dir
|
||||
shading_view = normalize(shading_view);
|
||||
|
||||
// we do this so we avoid doing (matrix multiply), but we burn 4 varyings:
|
||||
// p = clipFromWorldMatrix * shading_position;
|
||||
|
||||
Reference in New Issue
Block a user