Remove unused lighting model programs and shader source 25/36025/2
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 27 Feb 2015 12:08:21 +0000 (12:08 +0000)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 27 Feb 2015 12:10:13 +0000 (04:10 -0800)
Change-Id: I95a19e60f179ac8e07b5abd59e9231266879a305

dali/internal/event/effects/shader-factory.cpp
dali/internal/render/shader-source/textured-mesh.txt
dali/internal/render/shader-source/untextured-mesh.txt

index 0dec5d4..f706227 100644 (file)
 // the generated shader strings
 #include "dali-shaders.h"
 
-
 // Use pre-compiler constants in order to utilize string concatenation
 #define SHADER_DEF_USE_BONES    "#define USE_BONES\n"
-#define SHADER_DEF_USE_LIGHTING "#define USE_LIGHTING\n"
 #define SHADER_DEF_USE_COLOR    "#define USE_COLOR\n"
 #define SHADER_DEF_USE_GRADIENT "#define USE_GRADIENT\n"
 
@@ -130,21 +128,11 @@ void ShaderFactory::LoadDefaultShaders()
   mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE_GLOW, TextDistanceFieldOutlineGlowVertex, TextDistanceFieldOutlineGlowFragment, false );
 
   // Untextured meshes
-  mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_DEFAULT,
-                                      UntexturedMeshVertex,
-                                      std::string( SHADER_DEF_USE_LIGHTING ) + UntexturedMeshFragment,
-                                      false );
-
   mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_EVENLY_LIT,
                                       UntexturedMeshVertex,
                                       UntexturedMeshFragment,
                                       false );
 
-  mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_RIGGED_AND_LIT,
-                                      std::string( SHADER_DEF_USE_BONES ) + UntexturedMeshVertex,
-                                      std::string( SHADER_DEF_USE_LIGHTING ) + UntexturedMeshFragment,
-                                      true );
-
   mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_RIGGED_AND_EVENLY_LIT,
                                       std::string( SHADER_DEF_USE_BONES ) + UntexturedMeshVertex,
                                       UntexturedMeshFragment,
@@ -161,21 +149,11 @@ void ShaderFactory::LoadDefaultShaders()
                                       false );
 
   // Textured meshes
-  mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_DEFAULT,
-                                      TexturedMeshVertex,
-                                      std::string( SHADER_DEF_USE_LIGHTING ) + TexturedMeshFragment,
-                                      false );
-
   mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_EVENLY_LIT,
                                       TexturedMeshVertex,
                                       TexturedMeshFragment,
                                       false );
 
-  mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_RIGGED_AND_LIT,
-                                      std::string( SHADER_DEF_USE_BONES ) + TexturedMeshVertex,
-                                      std::string( SHADER_DEF_USE_LIGHTING ) + TexturedMeshFragment,
-                                      true );
-
   mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_RIGGED_AND_EVENLY_LIT,
                                       std::string( SHADER_DEF_USE_BONES ) + TexturedMeshVertex,
                                       TexturedMeshFragment,
index 4f7cbfa..5051e39 100644 (file)
@@ -29,7 +29,6 @@ attribute mediump vec4    aBoneIndices;
 void main()
 {
   mediump vec4 vertexPosition = vec4(aPosition, 1.0);
-  mediump float lightIntensity;
 
 #ifdef USE_BONES
   if(uBoneCount > 0)
@@ -98,87 +97,14 @@ uniform lowp  vec4    uColor;
 varying highp vec4    vVertex;
 varying highp vec3    vNormal;
 
-#ifdef USE_LIGHTING
-struct Light
-{
-  int           mType;                      // 0=AMBIENT,1=DIRECTIONAL,2=SPOT,3=POINT
-  highp   vec2  mFallOff;                   // x,y = falloff start, falloff end
-  mediump vec2  mSpotAngle;                 // x,y   = inner cone and outer cone
-  mediump vec3  mLightPos;                  // position
-  mediump vec3  mLightDir;                  // directional (for direction/spot lights)
-  lowp    vec3  mAmbient;                   // ambient component of the light's color
-  lowp    vec3  mDiffuse;                   // diffuse component of the light's color
-  lowp    vec3  mSpecular;                  // specular component of the light's color
-};
-
-uniform         int   uNumberOfLights;
-uniform Light         uLight0;
-
-lowp vec3 lightColor;
-lowp vec3 specularColor;
-
-void calculateLight(Light light)
-{
-  // Ensure that the varying vertex position doesn't lose precision
-  highp vec3 lightVector = light.mLightPos - vVertex.xyz;
-  mediump vec3 N = normalize(vNormal);
-  mediump vec3 L = normalize(lightVector);
-  // TODO: for directional light, should use mLightDir for light direction not lightVector
-  mediump float NdotL = dot(N, L);
-
-  mediump vec3 color = light.mAmbient * uMaterial.mAmbient.rgb;
-  color += light.mDiffuse * uMaterial.mDiffuse.rgb * abs(NdotL);
-
-  // Attenuation
-  highp float attenuation = 1.0;      // requires highp
-  if (light.mType >= 2)
-  {
-    attenuation -= smoothstep(light.mFallOff.x, light.mFallOff.y, length(lightVector));
-  }
-
-  // TODO spotlights
-
-  // add color to cumulative light total. TODO: don't attenuate directional light
-  lightColor += color * attenuation;
-
-  if (light.mType != 0 && NdotL > 0.0 && light.mType != 0)
-  {
-    // Specular highlight
-    highp vec3 E = normalize(vVertex.xyz);
-    highp vec3 R = reflect(L, N);
-    highp float specular = pow(max(dot(R, E), 0.0), uMaterial.mShininess);
-    specularColor += uMaterial.mSpecular.rgb * light.mSpecular * specular * attenuation;
-  }
-}
-#endif
-
 void main()
 {
   // sample the texture for the initial color
   mediump vec4 fragColor = texture2D(sTexture, vTexCoord);
 
-#ifdef USE_LIGHTING
-
-  // apply lighting and material properties
-  specularColor = vec3(0.0);
-  lightColor = vec3(0.0);
-
-  // @TODO conditionally compile different shaders for different number of lights
-  if( uNumberOfLights > 0 )
-  {
-    calculateLight(uLight0);
-  }
-
-  fragColor.rgb *= lightColor;
-  fragColor.rgb += specularColor;
-
-#else
-
   // apply material properties
   fragColor.rgb *= (uMaterial.mAmbient + uMaterial.mDiffuse).rgb;
 
-#endif
-
   // apply material alpha/opacity to alpha channel
   fragColor.a *= uMaterial.mOpacity * uMaterial.mDiffuse.a;
 
index db6f7ba..a2cd5b9 100644 (file)
@@ -101,69 +101,10 @@ uniform lowp  vec4    uColor;
 varying highp vec4    vVertex;
 varying highp vec3    vNormal;
 
-#ifdef USE_LIGHTING
-struct Light
-{
-  int           mType;                      // 0=AMBIENT,1=DIRECTIONAL,2=SPOT,3=POINT
-  highp   vec2  mFallOff;                   // x,y = falloff start, falloff end
-  mediump vec2  mSpotAngle;                 // x,y   = inner cone and outer cone
-  mediump vec3  mLightPos;                  // position
-  mediump vec3  mLightDir;                  // directional (for direction/spot lights)
-  lowp    vec3  mAmbient;                   // ambient component of the light's color
-  lowp    vec3  mDiffuse;                   // diffuse component of the light's color
-  lowp    vec3  mSpecular;                  // specular component of the light's color
-};
-#endif
-
-#ifdef USE_LIGHTING
-uniform         int   uNumberOfLights;
-uniform Light         uLight0;
-uniform Light         uLight1;
-uniform Light         uLight2;
-#endif
-
 #ifdef USE_COLOR
 varying mediump vec3  vColor;
 #endif
 
-#ifdef USE_LIGHTING
-lowp vec3 lightColor;
-lowp vec3 specularColor;
-
-void calculateLight(Light light)
-{
-  highp vec3 lightVector = light.mLightPos - vVertex.xyz;
-  mediump vec3 N = normalize(vNormal);
-  mediump vec3 L = normalize(lightVector);
-  // TODO: for directional light, should use mLightDir for light direction not lightVector
-  mediump float NdotL = dot(N, L);
-
-  mediump vec3 color = light.mAmbient * uMaterial.mAmbient.rgb;
-  color += light.mDiffuse * uMaterial.mDiffuse.rgb * abs(NdotL);
-
-  // Attenuation
-  highp float attenuation = 1.0;      // requires highp
-  if (light.mType >= 2)
-  {
-    attenuation -= smoothstep(light.mFallOff.x, light.mFallOff.y, length(lightVector));
-  }
-
-  // TODO spotlights
-
-  // add color to cumulative light total. TODO: don't attenuate directional light
-  lightColor += color * attenuation;
-
-  if (light.mType > 1 && NdotL > 0.0 && uMaterial.mShininess > 0.0)
-  {
-    // Specular highlight
-    highp vec3 E = normalize(vVertex.xyz);
-    highp vec3 R = reflect(L, N);
-    highp float specular = pow(max(dot(R, E), 0.0), uMaterial.mShininess);
-    specularColor += uMaterial.mSpecular.rgb * light.mSpecular * specular * attenuation;
-  }
-}
-#endif
-
 void main()
 {
 #ifdef USE_COLOR
@@ -178,22 +119,6 @@ void main()
 
 #endif
 
-#ifdef USE_LIGHTING
-  // apply lighting and material properties
-  specularColor = vec3(0.0);
-  lightColor = vec3(0.0);
-
-  // @TODO conditionally compile different shaders for different number of lights
-  if (uNumberOfLights > 0)
-  {
-    calculateLight(uLight0);
-  }
-
-  fragColor.rgb *= lightColor;
-  fragColor.rgb += specularColor;
-
-#endif
-
   // apply material alpha/opacity to alpha channel
   fragColor.a *= uMaterial.mOpacity * uMaterial.mDiffuse.a;