Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 2D/CV lighting issue #2515

Merged
merged 1 commit into from
Feb 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Source/Shaders/Appearances/AllMaterialAppearanceFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ void main()
vec3 positionToEyeEC = -v_positionEC;
mat3 tangentToEyeMatrix = czm_tangentToEyeSpaceMatrix(v_normalEC, v_tangentEC, v_binormalEC);

vec3 normalEC;
vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
normalEC = normalize(faceforward(v_normalEC, vec3(0.0, 0.0, 1.0), -v_normalEC));
#else
normalEC = normalize(v_normalEC);
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif

czm_materialInput materialInput;
Expand Down
6 changes: 2 additions & 4 deletions Source/Shaders/Appearances/BasicMaterialAppearanceFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ void main()
{
vec3 positionToEyeEC = -v_positionEC;

vec3 normalEC;
vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
normalEC = normalize(faceforward(v_normalEC, vec3(0.0, 0.0, 1.0), -v_normalEC));
#else
normalEC = normalize(v_normalEC);
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif

czm_materialInput materialInput;
Expand Down
6 changes: 2 additions & 4 deletions Source/Shaders/Appearances/EllipsoidSurfaceAppearanceFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ void main()
{
czm_materialInput materialInput;

vec3 normalEC = czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0));
vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));
#ifdef FACE_FORWARD
normalEC = normalize(faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC));
#else
normalEC = normalize(normalEC);
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif

materialInput.s = v_st.s;
Expand Down
6 changes: 2 additions & 4 deletions Source/Shaders/Appearances/PerInstanceColorAppearanceFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ void main()
{
vec3 positionToEyeEC = -v_positionEC;

vec3 normalEC;
vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
normalEC = normalize(faceforward(v_normalEC, vec3(0.0, 0.0, 1.0), -v_normalEC));
#else
normalEC = normalize(v_normalEC);
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif

czm_materialInput materialInput;
Expand Down
6 changes: 2 additions & 4 deletions Source/Shaders/Appearances/TexturedMaterialAppearanceFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ void main()
{
vec3 positionToEyeEC = -v_positionEC;

vec3 normalEC;
vec3 normalEC = normalize(v_normalEC);;
#ifdef FACE_FORWARD
normalEC = normalize(faceforward(v_normalEC, vec3(0.0, 0.0, 1.0), -v_normalEC));
#else
normalEC = normalize(v_normalEC);
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif

czm_materialInput materialInput;
Expand Down
8 changes: 6 additions & 2 deletions Source/Shaders/Builtin/Functions/phong.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ float czm_private_getSpecularOfMaterial(vec3 lightDirectionEC, vec3 toEyeEC, czm
*/
vec4 czm_phong(vec3 toEye, czm_material material)
{
// Diffuse from directional light sources at eye (for top-down and horizon views)
float diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material) + czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material);
// Diffuse from directional light sources at eye (for top-down)
float diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material);
if (czm_sceneMode == czm_sceneMode3D) {
// (and horizon views in 3D)
diffuse += czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material);
}

// Specular from sun and pseudo-moon
float specular = czm_private_getSpecularOfMaterial(czm_sunDirectionEC, toEye, material) + czm_private_getSpecularOfMaterial(czm_moonDirectionEC, toEye, material);
Expand Down