1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +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

@@ -83,7 +83,7 @@ const char THE_FUNC_pointLight[] =
EOL" vec3 aLight = occLight_Position (theId).xyz;"
EOL" if (occLight_IsHeadlight (theId) == 0)"
EOL" {"
EOL" aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 1.0));"
EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));"
EOL" }"
EOL" aLight -= thePoint;"
EOL
@@ -121,8 +121,8 @@ const char THE_FUNC_spotLight[] =
EOL" vec3 aSpotDir = occLight_SpotDirection (theId).xyz;"
EOL" if (occLight_IsHeadlight (theId) == 0)"
EOL" {"
EOL" aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 1.0));"
EOL" aSpotDir = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aSpotDir, 0.0));"
EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));"
EOL" aSpotDir = vec3 (occWorldViewMatrix * vec4 (aSpotDir, 0.0));"
EOL" }"
EOL" aLight -= thePoint;"
EOL
@@ -171,7 +171,7 @@ const char THE_FUNC_directionalLight[] =
EOL" vec3 aLight = normalize (occLight_Position (theId).xyz);"
EOL" if (occLight_IsHeadlight (theId) == 0)"
EOL" {"
EOL" aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 0.0));"
EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));"
EOL" }"
EOL
EOL" vec3 aHalf = normalize (aLight + theView);"
@@ -200,7 +200,7 @@ const char THE_FUNC_directionalLightFirst[] =
EOL" vec3 aLight = normalize (occLightSources[1].xyz);"
EOL" if (occLight_IsHeadlight (0) == 0)"
EOL" {"
EOL" aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 0.0));"
EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));"
EOL" }"
EOL
EOL" vec3 aHalf = normalize (aLight + theView);"

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);