1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0027943: Visualization - fix broken shading by positional light for object with local transformation

OpenGl_ShaderManager, per-vertex shading and per-fragment shading
- do not apply model-world matrix on the light sources
which are expected to be defined in world-space.
This commit is contained in:
kgv
2016-10-09 20:48:16 +03:00
committed by apn
parent bd6a845441
commit 5f4bd4d4d2
6 changed files with 189 additions and 9 deletions

View File

@@ -31,7 +31,7 @@ void pointLight (in int theId,
vec3 aLight = occLight_Position (theId).xyz;
if (occLight_IsHeadlight (theId) == 0)
{
aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 1.0));
aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));
}
aLight -= thePoint;
@@ -67,8 +67,8 @@ void spotLight (in int theId,
vec3 aSpotDir = occLight_SpotDirection (theId).xyz;
if (occLight_IsHeadlight (theId) == 0)
{
aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 1.0));
aSpotDir = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aSpotDir, 0.0));
aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));
aSpotDir = vec3 (occWorldViewMatrix * vec4 (aSpotDir, 0.0));
}
aLight -= thePoint;
@@ -116,7 +116,7 @@ void directionalLight (in int theId,
vec3 aLight = normalize (occLight_Position (theId).xyz);
if (occLight_IsHeadlight (theId) == 0)
{
aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 0.0));
aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));
}
vec3 aHalf = normalize (aLight + theView);