Updated shaders, shader script and geometry types. 91/29991/3
authorDavid Steele <david.steele@partner.samsung.com>
Thu, 6 Nov 2014 15:55:03 +0000 (15:55 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 7 Nov 2014 14:25:15 +0000 (06:25 -0800)
Updated shader generation script to automatically generate custom
prefix and postfix strings from the main shaders. Deleted prefix/postfix
shaders.
Renamed shader sources to be meaningful.
Renamed shader geometry types to be consistent and meaningful

Change-Id: I8e3a09ba43b450d1bc9eb34d8a559c05a55bb4a4
Signed-off-by: David Steele <david.steele@partner.samsung.com>
29 files changed:
build/scripts/generate-shader-strings.pl
build/tizen/dali-core/Makefile.am
dali/internal/event/effects/shader-effect-impl.cpp
dali/internal/event/effects/shader-factory.cpp
dali/internal/render/renderers/scene-graph-mesh-renderer.cpp
dali/internal/render/shader-source/custom-font-postfix.txt [deleted file]
dali/internal/render/shader-source/custom-font-prefix.txt [deleted file]
dali/internal/render/shader-source/custom-image-postfix.txt [deleted file]
dali/internal/render/shader-source/custom-image-prefix.txt [deleted file]
dali/internal/render/shader-source/custom-mesh-postfix.txt [deleted file]
dali/internal/render/shader-source/custom-mesh-prefix.txt [deleted file]
dali/internal/render/shader-source/distance-field-font-glow.txt [deleted file]
dali/internal/render/shader-source/distance-field-font-outline-glow.txt [deleted file]
dali/internal/render/shader-source/distance-field-font-outline.txt [deleted file]
dali/internal/render/shader-source/distance-field-font-shadow.txt [deleted file]
dali/internal/render/shader-source/distance-field-font.txt [deleted file]
dali/internal/render/shader-source/flat-color-texture.txt [deleted file]
dali/internal/render/shader-source/image.txt [new file with mode: 0644]
dali/internal/render/shader-source/mesh-color-no-texture.txt [deleted file]
dali/internal/render/shader-source/mesh.txt [deleted file]
dali/internal/render/shader-source/text-distance-field-glow.txt [new file with mode: 0644]
dali/internal/render/shader-source/text-distance-field-outline-glow.txt [new file with mode: 0644]
dali/internal/render/shader-source/text-distance-field-outline.txt [new file with mode: 0644]
dali/internal/render/shader-source/text-distance-field-shadow.txt [new file with mode: 0644]
dali/internal/render/shader-source/text-distance-field.txt [new file with mode: 0644]
dali/internal/render/shader-source/textured-mesh.txt [new file with mode: 0644]
dali/internal/render/shader-source/untextured-mesh.txt [new file with mode: 0644]
dali/internal/render/shaders/shader.cpp
dali/public-api/shader-effects/shader-effect.h

index 29b3af6..cafaa23 100755 (executable)
@@ -97,12 +97,12 @@ CPP_FOOTER_END
 
 ###############################################################################
 
+my %shaders=();
+
 sub GenerateStringsFromFile
 {
   my($file) = shift;
   my($dir) = shift;
-  my($headerFile) = shift;
-  my($sourceFile) = shift;
 
   my $shadername = $file;
   $shadername =~ s/-([a-z])/uc($1)/eg;
@@ -111,6 +111,7 @@ sub GenerateStringsFromFile
 
   my $state = 0;
 
+  my $shader="";
   open MEM, "$dir/$file" || die "Can't open $file for reading: $!\n";
   while(<MEM>)
   {
@@ -120,28 +121,31 @@ sub GenerateStringsFromFile
       if (/<VertexShader>/)
       {
         $state = 1;
-        print $headerFile "extern const char* const ${shadername}Vertex;\n";
-        print $sourceFile "extern const char* const ${shadername}Vertex;\n";
-        print $sourceFile "const char* const ${shadername}Vertex(\n";
+        $shader = "";
       }
       elsif (/<FragmentShader>/)
       {
         $state = 1;
-        print $headerFile "extern const char* const ${shadername}Fragment;\n";
-        print $sourceFile "extern const char* const ${shadername}Fragment;\n";
-        print $sourceFile "const char* const ${shadername}Fragment(\n";
+        $shader = "";
       }
     }
     elsif ($state == 1)
     {
-      if (m!</VertexShader>! || m!</FragmentShader>!)
+      if (m!</VertexShader>!)
       {
         $state = 0;
-        print $sourceFile ");\n\n";
+        $shaders{$shadername}->{"vertex"} = $shader;
+      }
+      elsif( m!</FragmentShader>!)
+      {
+        $state = 0;
+        $shaders{$shadername}->{"fragment"} = $shader;
       }
       else
       {
-        print $sourceFile "\"$_\\n\"\n";
+        ## Accumulate
+        $shader .= "$_\n";
+#       print $sourceFile "\"$_\\n\"\n";
       }
     }
   }
@@ -161,22 +165,167 @@ sub GetShaderFiles
 
 ###############################################################################
 
+sub PrintSourceLine
+{
+    my $sourceFile=shift;
+    my $line=shift;
+    chomp $line;
+    $line =~ s!//.*$!!; # Strip out comments
+    $line =~ s!\s*$!!; # Strip out trailing space
+    if( $line !~ m!^\s*$! )
+    {
+        print $sourceFile "\"$line\\n\"\n";
+    }
+}
+
+sub PrintMacroLine
+{
+    my $sourceFile=shift;
+    my $line=shift;
+    chomp $line;
+    $line =~ s!//.*$!!; # Strip out comments
+    $line =~ s!\s*$!!; # Strip out trailing space
+    if( $line !~ m!^\s*$! )
+    {
+        print $sourceFile "\"$line\\n\" \\\n";
+    }
+}
+
+
+sub PrintShaderProgramWithMacros
+{
+    my $sourceFile=shift;
+    my $shadername=shift;
+    my $SHADERNAME=$shadername;
+    $SHADERNAME =~ s/([A-Z])/_$1/g;
+    substr($SHADERNAME,0,1)="";
+    $SHADERNAME = uc($SHADERNAME);
+
+    my $program_type=shift;
+    my $ProgramType=ucfirst($program_type);
+    my $PROGRAM_TYPE=uc($program_type);
+    my $custom=shift;
+
+    my @lines=split(/\n/, $shaders{$shadername}->{$program_type} );
+
+    print $sourceFile "#define ${SHADERNAME}_PREFIX_${PROGRAM_TYPE} \\\n";
+    LINE: while( scalar(@lines) )
+    {
+        last LINE if $lines[0] =~ /main()/;
+        PrintMacroLine($sourceFile, shift(@lines));
+    }
+    print $sourceFile "\n\n";
+
+    print $sourceFile "#define ${SHADERNAME}_POSTFIX_${PROGRAM_TYPE} \\\n";
+    LINE: while( scalar(@lines) )
+    {
+        PrintMacroLine($sourceFile, shift(@lines));
+    }
+    print $sourceFile "\n\n";
+
+    if($custom)
+    {
+        print $sourceFile "extern const char* const Custom${shadername}Prefix${ProgramType};\n";
+        print $sourceFile "const char* const Custom${shadername}Prefix${ProgramType}(\n";
+        print $sourceFile "  ${SHADERNAME}_PREFIX_${PROGRAM_TYPE}\n";
+        print $sourceFile ");\n\n";
+
+        print $sourceFile "extern const char* const Custom${shadername}Postfix${ProgramType};\n";
+        print $sourceFile "const char* const Custom${shadername}Postfix${ProgramType}(\n";
+        print $sourceFile "  ${SHADERNAME}_POSTFIX_${PROGRAM_TYPE}\n";
+        print $sourceFile ");\n\n";
+    }
+    print $sourceFile "extern const char* const ${shadername}${ProgramType};\n";
+    print $sourceFile "const char* const ${shadername}${ProgramType}(\n";
+    print $sourceFile "  ${SHADERNAME}_PREFIX_${PROGRAM_TYPE}\n";
+    print $sourceFile "  ${SHADERNAME}_POSTFIX_${PROGRAM_TYPE}\n";
+    print $sourceFile ");\n\n";
+
+}
+
+sub PrintShaderProgram
+{
+    my $sourceFile=shift;
+    my $shadername=shift;
+    my $program_type=shift;
+    my $custom=shift;
+    my $ProgramType=ucfirst($program_type);
+
+    my @lines=split(/\n/, $shaders{$shadername}->{$program_type} );
+
+    print $sourceFile "const char* const ${shadername}${ProgramType}(\n";
+    for my $i (0..scalar(@lines)-1)
+    {
+        PrintSourceLine($sourceFile, $lines[$i]);
+    }
+    print $sourceFile ");\n\n";
+
+    if( $custom )
+    {
+        print $sourceFile "const char* const Custom${shadername}Prefix${ProgramType}(\n";
+      LINE:
+        while( scalar(@lines) )
+        {
+            last LINE if $lines[0] =~ /main()/;
+            PrintSourceLine($sourceFile, shift(@lines));
+        }
+        print $sourceFile ");\n\n";
+
+        print $sourceFile "const char* const Custom${shadername}Postfix${ProgramType}(\n";
+
+        while( scalar(@lines) )
+        {
+            PrintSourceLine($sourceFile, shift(@lines));
+        }
+        print $sourceFile ");\n\n";
+    }
+}
+
+
+sub PrintShaderSources
+{
+  my($headerFile) = shift;
+  my($sourceFile) = shift;
+  my $shadername;
+
+  # Strings are now in memory. Dump them back out again:
+  foreach $shadername (sort(keys(%shaders)))
+  {
+    print $headerFile "extern const char* const ${shadername}Vertex;\n";
+    print $headerFile "extern const char* const ${shadername}Fragment;\n";
+
+    my $custom = 0;
+    if( $shadername !~ /TextDistanceField/ || $shadername eq "TextDistanceField" )
+    {
+        print $headerFile "extern const char* const Custom${shadername}PrefixVertex;\n";
+        print $headerFile "extern const char* const Custom${shadername}PostfixVertex;\n";
+        print $headerFile "extern const char* const Custom${shadername}PrefixFragment;\n";
+        print $headerFile "extern const char* const Custom${shadername}PostfixFragment;\n";
+        $custom = 1;
+    }
+    PrintShaderProgramWithMacros($sourceFile, $shadername, "vertex", $custom);
+    PrintShaderProgramWithMacros($sourceFile, $shadername, "fragment", $custom);
+  }
+}
+
+###############################################################################
+
 my($optHelp);
 my($optMan);
 my($shaderDir) = "";
-my($filePrefix) = "";
+my($fileName) = "";
 
 GetOptions(
   "help"           => \$optHelp,
   "man"            => \$optMan,
   "shader-dir=s"   => \$shaderDir,
-  "file-prefix=s"  => \$filePrefix
+  "file-name=s"  => \$fileName
 ) or pod2usage(2);
 
 pod2usage(1) if $optHelp;
 pod2usage(-exitstatus => 0, -verbose => 2) if $optMan;
 
-if ($shaderDir eq "" || $filePrefix eq "")
+if ($shaderDir eq "" || $fileName eq "")
 {
   pod2usage(1);
 }
@@ -185,8 +334,8 @@ else
   my $dir = $shaderDir;
   my @shaderFiles = GetShaderFiles($dir);
 
-  my $headerFile = OpenFileForWriting("$filePrefix.h");
-  my $sourceFile = OpenFileForWriting("$filePrefix.cpp");
+  my $headerFile = OpenFileForWriting("$fileName.h");
+  my $sourceFile = OpenFileForWriting("$fileName.cpp");
 
   GenerateHeaderFileHeader($headerFile);
   GenerateSourceFileHeader($sourceFile);
@@ -194,9 +343,11 @@ else
   my $file;
   foreach $file (@shaderFiles)
   {
-    GenerateStringsFromFile($file, $dir, $headerFile, $sourceFile);
+    GenerateStringsFromFile($file, $dir);
   }
 
+  PrintShaderSources($headerFile, $sourceFile);
+
   GenerateHeaderFileFooter($headerFile);
   GenerateSourceFileFooter($sourceFile);
 
@@ -210,21 +361,21 @@ __END__
 
 =head1 NAME
 
-generate-shader-strings.pl - Given a shader directory and a file prefix, this script generates a header and source file where all the shaders in the directory are stored as vertex and fragment shader std::string(s).
+generate-shader-strings.pl - Given a shader directory and a file name, this script generates a header and source file where all the shaders in the directory are stored as vertex and fragment shader const char arrays.
 
 =head1 SYNOPSIS
 
-generate-shader-strings.pl -s=<shader-dir> -f=<file-prefix>
+generate-shader-strings.pl -s=<shader-dir> -f=<file-name>
 
-generate-shader-strings.pl --shader-dir=<shader-dir> -file-prefix=<file-prefix>
+generate-shader-strings.pl -shader-dir=<shader-dir> -file-name=<file-name>
 
 =head1 DESCRIPTION
 
-Given a shader directory and a file prefix, this script generates a header and source file where all the shaders in the directory are stored as vertex and fragment shader std::string(s).
+Given a shader directory and a file name, this script generates a header and source file where all the shaders in the directory are stored as vertex and fragment shader const char arrays.
 
 The shader files in the specified directory should have the suffix ".txt" and the vertex and fragment shaders should be encapsulated within <VertexShader>*</VertexShader> and <FragmentShader>*</FragmentShader> respectively in this text file.
 
-The generated source files will be called <file-prefix>.h and <file-prefix>.cpp.
+The generated source files will be called <file-name>.h and <file-name>.cpp.
 
 =head1 OPTIONS
 
@@ -234,7 +385,6 @@ The generated source files will be called <file-prefix>.h and <file-prefix>.cpp.
 
 The directory the shader files should be loaded from.
 
-=item B<-f|--file-prefix>
-
-The prefix of the output files.
+=item B<-f|--file-name>
 
+The name of the output files.
index bb7bc39..f24571b 100644 (file)
@@ -53,7 +53,7 @@ $(nodist_libdali_core_la_OBJECTS): $(dali_shaders_src_file)
 dali_shaders_src_file = dali-shaders.cpp
 
 dali-shaders.cpp: $(dali_shaders_script) $(dali_shaders_dir)/*.txt
-       $< --shader-dir=$(dali_shaders_dir) --file-prefix=dali-shaders
+       $< --shader-dir=$(dali_shaders_dir) --file-name=dali-shaders
 
 dali_core_includes = \
         -I../../..
index 5f67fe7..cb802e4 100644 (file)
@@ -80,12 +80,16 @@ WrapperStrings customShaderWrappers [] =
     CustomImagePostfixVertex, CustomImagePostfixFragment
   },
   {
-    CustomFontPrefixVertex, CustomFontPrefixFragment,
-    CustomFontPostfixVertex, CustomFontPostfixFragment
+    CustomTextDistanceFieldPrefixVertex, CustomTextDistanceFieldPrefixFragment,
+    CustomTextDistanceFieldPostfixVertex, CustomTextDistanceFieldPostfixFragment
   },
   {
-    CustomMeshPrefixVertex, CustomMeshPrefixFragment,
-    CustomMeshPostfixVertex, CustomMeshPostfixFragment
+    CustomUntexturedMeshPrefixVertex, CustomUntexturedMeshPrefixFragment,
+    CustomUntexturedMeshPostfixVertex, CustomUntexturedMeshPostfixFragment
+  },
+  {
+    CustomTexturedMeshPrefixVertex, CustomTexturedMeshPrefixFragment,
+    CustomTexturedMeshPostfixVertex, CustomTexturedMeshPostfixFragment
   }
 };
 
@@ -176,8 +180,8 @@ ShaderEffectPtr ShaderEffect::New( const string& imageVertexShader,
                                    const string& textFragmentShader,
                                    const string& texturedMeshVertexShader,
                                    const string& texturedMeshFragmentShader,
-                                   const string& meshVertexShader,
-                                   const string& meshFragmentShader,
+                                   const string& untexturedMeshVertexShader,
+                                   const string& untexturedMeshFragmentShader,
                                    Dali::ShaderEffect::GeometryHints hints )
 {
   ShaderEffectPtr shaderEffect( New(hints) );
@@ -185,7 +189,7 @@ ShaderEffectPtr ShaderEffect::New( const string& imageVertexShader,
   shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_IMAGE, SHADER_SUBTYPE_ALL, "", "", imageVertexShader, imageFragmentShader );
   shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, "", "", textVertexShader, textFragmentShader );
   shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_SUBTYPE_ALL, "", "", texturedMeshVertexShader, texturedMeshFragmentShader );
-  shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_MESH, SHADER_SUBTYPE_ALL, "", "", meshVertexShader, meshFragmentShader );
+  shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_SUBTYPE_ALL, "", "", untexturedMeshVertexShader, untexturedMeshFragmentShader );
 
   return shaderEffect;
 }
@@ -469,9 +473,9 @@ void ShaderEffect::SetDefaultProperty( Property::Index index, const Property::Va
         {
           geometryType  = GEOMETRY_TYPE_TEXT;
         }
-        else if( s == "GEOMETRY_TYPE_MESH")
+        else if( s == "GEOMETRY_TYPE_UNTEXTURED_MESH")
         {
-          geometryType  = GEOMETRY_TYPE_MESH;
+          geometryType  = GEOMETRY_TYPE_UNTEXTURED_MESH;
         }
         else if( s == "GEOMETRY_TYPE_TEXTURED_MESH")
         {
@@ -611,9 +615,9 @@ void ShaderEffect::SetPrograms( GeometryType  geometryTypes,
     SetWrappedProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
   }
 
-  if( geometryTypes & GEOMETRY_TYPE_MESH )
+  if( geometryTypes & GEOMETRY_TYPE_UNTEXTURED_MESH )
   {
-    SetWrappedProgram( GEOMETRY_TYPE_MESH, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
+    SetWrappedProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
   }
 }
 
@@ -635,12 +639,16 @@ void ShaderEffect::SetWrappedProgram( GeometryType geometryType, ShaderSubTypes
       index = 1;
       break;
     }
-    case GEOMETRY_TYPE_MESH:
-    case GEOMETRY_TYPE_TEXTURED_MESH:
+    case GEOMETRY_TYPE_UNTEXTURED_MESH:
     {
       index = 2;
       break;
     }
+    case GEOMETRY_TYPE_TEXTURED_MESH:
+    {
+      index = 3;
+      break;
+    }
     case GEOMETRY_TYPE_LAST:
     {
       DALI_ASSERT_DEBUG(0 && "Wrong geometry type");
index 0a34ca9..aa2b98e 100644 (file)
@@ -113,91 +113,91 @@ void ShaderFactory::LoadDefaultShaders()
 {
   mDefaultShader = ShaderEffect::New();
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_IMAGE, SHADER_DEFAULT, FlatColorTextureVertex, FlatColorTextureFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_IMAGE, SHADER_DEFAULT, ImageVertex, ImageFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, DistanceFieldFontVertex, DistanceFieldFontFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, TextDistanceFieldVertex, TextDistanceFieldFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT, SHADER_DEF_USE_GRADIENT, SHADER_DEF_USE_GRADIENT, DistanceFieldFontVertex, DistanceFieldFontFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT, SHADER_DEF_USE_GRADIENT, SHADER_DEF_USE_GRADIENT, TextDistanceFieldVertex, TextDistanceFieldFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_GLOW, DistanceFieldFontGlowVertex, DistanceFieldFontGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_GLOW, TextDistanceFieldGlowVertex, TextDistanceFieldGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_SHADOW, DistanceFieldFontShadowVertex, DistanceFieldFontShadowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_SHADOW, TextDistanceFieldShadowVertex, TextDistanceFieldShadowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE, DistanceFieldFontOutlineVertex, DistanceFieldFontOutlineFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE, TextDistanceFieldOutlineVertex, TextDistanceFieldOutlineFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE_GLOW, DistanceFieldFontOutlineGlowVertex, DistanceFieldFontOutlineGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE_GLOW, TextDistanceFieldOutlineGlowVertex, TextDistanceFieldOutlineGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
   // Untextured meshes
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_MESH, SHADER_DEFAULT,
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_DEFAULT,
                               "", // Vertex shader defs
                               SHADER_DEF_USE_LIGHTING, // fragment shader defs
-                              MeshColorNoTextureVertex,
-                              MeshColorNoTextureFragment,
+                              UntexturedMeshVertex,
+                              UntexturedMeshFragment,
                               ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_MESH, SHADER_EVENLY_LIT,
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_EVENLY_LIT,
                               "", // Vertex shader defs
                               "", // fragment shader defs
-                              MeshColorNoTextureVertex,
-                              MeshColorNoTextureFragment,
+                              UntexturedMeshVertex,
+                              UntexturedMeshFragment,
                               ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_MESH, SHADER_RIGGED_AND_LIT,
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_RIGGED_AND_LIT,
                               SHADER_DEF_USE_BONES,    // vertex shader defs
                               SHADER_DEF_USE_LIGHTING, // fragment shader defs
-                              MeshColorNoTextureVertex,
-                              MeshColorNoTextureFragment,
+                              UntexturedMeshVertex,
+                              UntexturedMeshFragment,
                               ShaderEffect::MODIFIES_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_MESH, SHADER_RIGGED_AND_EVENLY_LIT,
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_RIGGED_AND_EVENLY_LIT,
                               SHADER_DEF_USE_BONES, // Vertex shader defs
                               "",                   // Fragment shader defs
-                              MeshColorNoTextureVertex,
-                              MeshColorNoTextureFragment,
+                              UntexturedMeshVertex,
+                              UntexturedMeshFragment,
                               ShaderEffect::MODIFIES_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_MESH, SHADER_RIGGED_AND_VERTEX_COLOR,
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_RIGGED_AND_VERTEX_COLOR,
                               (SHADER_DEF_USE_BONES SHADER_DEF_USE_COLOR), // Vertex shader defs
                               SHADER_DEF_USE_COLOR,                        // Fragment shader defs
-                              MeshColorNoTextureVertex,
-                              MeshColorNoTextureFragment,
+                              UntexturedMeshVertex,
+                              UntexturedMeshFragment,
                               ShaderEffect::MODIFIES_GEOMETRY );
 
-  mDefaultShader->SetProgram( GEOMETRY_TYPE_MESH, SHADER_VERTEX_COLOR,
+  mDefaultShader->SetProgram( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_VERTEX_COLOR,
                               SHADER_DEF_USE_COLOR,  // Vertex shader defs
                               SHADER_DEF_USE_COLOR,  // Fragment shader defs
-                              MeshColorNoTextureVertex,
-                              MeshColorNoTextureFragment,
+                              UntexturedMeshVertex,
+                              UntexturedMeshFragment,
                               ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
   // Textured meshes
   mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_DEFAULT,
                               "",                      // Vertex shader defs
                               SHADER_DEF_USE_LIGHTING, // fragment shader defs
-                              MeshVertex,
-                              MeshFragment,
+                              TexturedMeshVertex,
+                              TexturedMeshFragment,
                               ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
 
   mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_EVENLY_LIT,
                               "",                      // Vertex shader defs
                               "",                      // Fragment shader defs
-                              MeshVertex,
-                              MeshFragment,
+                              TexturedMeshVertex,
+                              TexturedMeshFragment,
                               ShaderEffect::DOESNT_MODIFY_GEOMETRY );
 
   mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_RIGGED_AND_LIT,
                               SHADER_DEF_USE_BONES,    // Vertex shader defs
                               SHADER_DEF_USE_LIGHTING, // Fragment shader defs
-                              MeshVertex,
-                              MeshFragment,
+                              TexturedMeshVertex,
+                              TexturedMeshFragment,
                               ShaderEffect::MODIFIES_GEOMETRY );
 
   mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_RIGGED_AND_EVENLY_LIT,
                               SHADER_DEF_USE_BONES, // Vertex shader defs
                               "",                   // Fragment shader defs
-                              MeshVertex,
-                              MeshFragment,
+                              TexturedMeshVertex,
+                              TexturedMeshFragment,
                               ShaderEffect::MODIFIES_GEOMETRY );
 }
 
index f97a847..3d30d82 100644 (file)
@@ -129,7 +129,7 @@ void MeshRenderer::ResolveGeometryTypes( BufferIndex bufferIndex, GeometryType&
   outType = GEOMETRY_TYPE_TEXTURED_MESH;
   if( ! material.HasTexture() )
   {
-    outType = GEOMETRY_TYPE_MESH;
+    outType = GEOMETRY_TYPE_UNTEXTURED_MESH;
   }
   outSubType = SHADER_DEFAULT;
 
diff --git a/dali/internal/render/shader-source/custom-font-postfix.txt b/dali/internal/render/shader-source/custom-font-postfix.txt
deleted file mode 100644 (file)
index 95244f6..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<VertexShader>
-
-  void main()
-  {
-    gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-    vTexCoord = aTexCoord;
-
-#ifdef USE_GRADIENT
-    lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
-    vColor = mix(uTextColor, uGradientColor, f);
-#endif
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-  void main()
-  {
-    // sample distance field
-    highp float distance = texture2D(sTexture, vTexCoord).a;
-
-#ifdef USE_GRADIENT
-    lowp vec4 color = clamp(vColor, 0., 1.); // gradiant calculation can overflow.
-#else
-    lowp vec4 color = uTextColor;
-#endif
-
-    // adjust fragment alpha by sampled distance
-    color.a *= smoothstep(uSmoothing[0], uSmoothing[1], distance );
-
-    // final color multiplied by Actor color
-    gl_FragColor = uColor * color;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/custom-font-prefix.txt b/dali/internal/render/shader-source/custom-font-prefix.txt
deleted file mode 100644 (file)
index 6bf642d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<VertexShader>
-
-  attribute mediump vec3  aPosition;
-  attribute mediump vec2  aTexCoord;
-
-  uniform   mediump mat4  uModelView;
-  uniform   mediump mat4  uProjection;
-  uniform   mediump mat4  uMvpMatrix;
-  uniform   mediump mat3  uNormalMatrix;
-  uniform   lowp    vec4  uColor;
-  uniform   lowp    vec4  uTextColor;
-
-  varying   mediump vec2  vTexCoord;
-
-#ifdef USE_GRADIENT
-  uniform   lowp    vec4  uGradientColor;
-  uniform   mediump vec4  uGradientLine;
-  uniform   mediump vec2  uInvTextSize;
-
-  varying   lowp    vec4  vColor;
-#endif
-
-</VertexShader>
-
-<FragmentShader>
-  uniform mediump sampler2D sTexture;
-  uniform highp   vec4      sTextureRect;
-  uniform lowp    vec4      uColor;
-  uniform highp   vec2      uSmoothing;
-
-  varying highp vec2      vTexCoord;
-
-#ifdef USE_GRADIENT
-  varying lowp    vec4      vColor;
-#else
-  uniform lowp    vec4      uTextColor;
-#endif
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/custom-image-postfix.txt b/dali/internal/render/shader-source/custom-image-postfix.txt
deleted file mode 100644 (file)
index 0b54e28..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<VertexShader>
-
-  void main()
-  {
-    gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);
-    vTexCoord = aTexCoord;
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-  void main()
-  {
-    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/custom-image-prefix.txt b/dali/internal/render/shader-source/custom-image-prefix.txt
deleted file mode 100644 (file)
index 595e92c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<VertexShader>
-  precision mediump float;
-
-  attribute vec3  aPosition;
-  attribute vec2  aTexCoord;
-
-  uniform   mat4  uModelView;
-  uniform   mat4  uProjection;
-  uniform   mat4  uMvpMatrix;
-  uniform   mat3  uNormalMatrix;
-  uniform   mat4  uModelMatrix;
-  uniform   mat4  uViewMatrix;
-
-  uniform   vec4  uColor;
-
-  varying   vec2  vTexCoord;
-
-  uniform   vec4  sTextureRect;
-  uniform   vec4  sEffectRect;
-
-</VertexShader>
-
-<FragmentShader>
-  precision mediump float;
-
-  uniform sampler2D sTexture;
-  uniform sampler2D sEffect;
-
-  uniform vec4      sTextureRect;
-  uniform vec4      sEffectRect;
-
-  uniform vec4      uColor;
-
-  varying vec2      vTexCoord;
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/custom-mesh-postfix.txt b/dali/internal/render/shader-source/custom-mesh-postfix.txt
deleted file mode 100644 (file)
index e455ebf..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-<VertexShader>
-#define USE_TEXTURES
-#define USE_NORMALS
-#define MAX_BONES_PER_MESH  12
-
-#ifdef USE_BONES
-  uniform   int             uBoneCount;
-  uniform   mediump mat4    uBoneMatrices[MAX_BONES_PER_MESH];
-  uniform   mediump mat3    uBoneMatricesIT[MAX_BONES_PER_MESH];
-  attribute mediump vec4    aBoneWeights;
-  attribute mediump vec4    aBoneIndices;
-#endif
-
-  void main()
-  {
-    mediump vec4 vertexPosition = vec4(aPosition, 1.0);
-    mediump float lightIntensity;
-
-#ifdef USE_BONES
-    if(uBoneCount > 0)
-    {
-      mediump vec4 boneWeights = aBoneWeights;
-      mediump ivec4 boneIndices = ivec4(aBoneIndices);
-      mediump vec3 vertexNormal;
-
-      // re-calculate the final weight
-      boneWeights.w = 1.0 - dot(boneWeights.xyz, vec3(1.0, 1.0, 1.0));
-
-      vec4 bonePos = (uBoneMatrices[boneIndices.x] * vertexPosition) * boneWeights.x;
-      bonePos     += (uBoneMatrices[boneIndices.y] * vertexPosition) * boneWeights.y;
-      bonePos     += (uBoneMatrices[boneIndices.z] * vertexPosition) * boneWeights.z;
-      bonePos     += (uBoneMatrices[boneIndices.w] * vertexPosition) * boneWeights.w;
-
-      vertexNormal  = (uBoneMatricesIT[boneIndices.x] * aNormal) * boneWeights.x;
-      vertexNormal += (uBoneMatricesIT[boneIndices.y] * aNormal) * boneWeights.y;
-      vertexNormal += (uBoneMatricesIT[boneIndices.z] * aNormal) * boneWeights.z;
-      vertexNormal += (uBoneMatricesIT[boneIndices.w] * aNormal) * boneWeights.w;
-      vertexNormal =  normalize(vertexNormal);
-
-      vertexPosition = uProjection * bonePos;
-      vVertex = bonePos;
-      vNormal = vertexNormal;
-    }
-    else
-    {
-#endif
-      vertexPosition = uMvpMatrix * vec4(aPosition, 1.0);
-      vVertex = uModelView * vec4(aPosition, 1.0);
-      vNormal = uModelViewIT * aNormal;
-#ifdef USE_BONES
-    }
-#endif
-    gl_Position = vertexPosition;
-
-    mediump vec2 start = uCustomTextureCoords.xy;
-    mediump vec2 scale = uCustomTextureCoords.zw;
-    vTexCoord = vec2(start.x + aTexCoord.x * scale.x, start.y + aTexCoord.y * scale.y);
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-#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;
-    vec3 N = normalize(vNormal);
-    vec3 L = normalize(lightVector);
-    // TODO: for directional light, should use mLightDir for light direction not lightVector
-    float NdotL = dot(N, L);
-
-    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
-      vec3 E = normalize(vVertex.xyz);
-      vec3 R = reflect(L, N);
-      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
-    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;
-
-    // and finally, apply Actor color
-    fragColor *= uColor;
-
-// Next line useful for visualizing the normals
-//    fragColor = vec4(normalize(vNormal), 1.0);
-    gl_FragColor = fragColor;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/custom-mesh-prefix.txt b/dali/internal/render/shader-source/custom-mesh-prefix.txt
deleted file mode 100644 (file)
index a6c2aa7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<VertexShader>
-  precision mediump float;
-
-  uniform   mediump mat4    uProjection;
-  uniform   mediump mat4    uModelView;
-  uniform   mediump mat4    uMvpMatrix;
-
-  uniform           bool    uTextureMapped;
-  uniform   mediump vec4    uCustomTextureCoords;
-  attribute mediump vec2    aTexCoord;
-  varying   mediump vec2    vTexCoord;
-
-  uniform   mat3    uModelViewIT;
-  attribute mediump vec3    aNormal;
-  varying   mediump vec3    vNormal;
-
-  attribute mediump vec3    aPosition;
-  varying   mediump vec4    vVertex;
-
-</VertexShader>
-
-<FragmentShader>
-  precision mediump float;
-
-  struct Material
-  {
-    mediump float mOpacity;
-    mediump float mShininess;
-    lowp    vec4  mAmbient;
-    lowp    vec4  mDiffuse;
-    lowp    vec4  mSpecular;
-    lowp    vec4  mEmissive;
-  };
-
-  uniform sampler2D     sTexture;
-  uniform sampler2D     sOpacityTexture;
-  uniform sampler2D     sNormalMapTexture;
-  uniform sampler2D     sEffect;
-  varying vec2          vTexCoord;
-
-  uniform Material      uMaterial;
-
-  uniform lowp  vec4    uColor;
-  varying highp vec4    vVertex;
-  varying highp vec3    vNormal;
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/distance-field-font-glow.txt b/dali/internal/render/shader-source/distance-field-font-glow.txt
deleted file mode 100644 (file)
index 8d29264..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<VertexShader>
-
-  attribute mediump vec3  aPosition;
-  attribute mediump vec2  aTexCoord;
-
-  uniform   mediump mat4  uMvpMatrix;
-  uniform   lowp    vec4  uColor;
-  uniform   lowp    vec4  uTextColor;
-  uniform   lowp    vec4  uGradientColor;
-  uniform   mediump vec4  uGradientLine;
-  uniform   mediump vec2  uInvTextSize;
-
-  varying   mediump vec2  vTexCoord;
-  varying   lowp    vec4  vColor;
-
-  void main()
-  {
-    gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-    vTexCoord = aTexCoord;
-
-    lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
-
-    vColor = mix(uTextColor, uGradientColor, f);
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-  uniform mediump sampler2D sTexture;
-  uniform lowp    vec4      uColor;
-  uniform highp   vec2      uSmoothing;
-  uniform highp   float     uGlow;
-  uniform lowp    vec4      uGlowColor;
-
-  varying mediump vec2      vTexCoord;
-  varying lowp vec4         vColor;
-
-  void main()
-  {
-    // sample distance field
-    mediump float distance = texture2D(sTexture, vTexCoord).a;
-
-    mediump float glowBlend = smoothstep(uSmoothing[0], uSmoothing[1], distance);
-
-    // blend fragment color between glow color and text color
-    lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
-    lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );
-    lowp vec4 color = mix(glowColor, clampedColor, glowBlend);
-
-    // fade out glow between uSmoothing and uGlow
-    color.a *= smoothstep(uGlow, uSmoothing[0], distance);
-
-    // final color multiplied by Actor color
-    gl_FragColor = uColor * color;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/distance-field-font-outline-glow.txt b/dali/internal/render/shader-source/distance-field-font-outline-glow.txt
deleted file mode 100644 (file)
index a9088f9..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<VertexShader>
-
-  attribute mediump vec3  aPosition;
-  attribute mediump vec2  aTexCoord;
-
-  uniform   mediump mat4  uMvpMatrix;
-  uniform   lowp    vec4  uColor;
-  uniform   lowp    vec4  uTextColor;
-  uniform   lowp    vec4  uGradientColor;
-  uniform   mediump vec4  uGradientLine;
-  uniform   mediump vec2  uInvTextSize;
-
-  varying   mediump vec2  vTexCoord;
-  varying   lowp    vec4  vColor;
-
-  void main()
-  {
-    gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-    vTexCoord = aTexCoord;
-
-    lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
-
-    vColor = mix(uTextColor, uGradientColor, f);
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-  uniform mediump sampler2D sTexture;
-  uniform lowp    vec4      uColor;
-  uniform highp   vec2      uSmoothing;
-  uniform highp   vec2      uOutline;
-  uniform lowp    vec4      uOutlineColor;
-  uniform highp   float     uGlow;
-  uniform lowp    vec4      uGlowColor;
-
-  varying mediump vec2      vTexCoord;
-  varying lowp vec4         vColor;
-
-  void main()
-  {
-    // sample distance field
-    mediump float distance = texture2D(sTexture, vTexCoord).a;
-
-    // blend fragment color between outline color and text color
-    mediump float outlineBlend = smoothstep(uOutline[0], uOutline[1], distance);
-
-    lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
-
-    // create blend between text color and outline color using outlineBlend
-    lowp vec4 outlineColor = vec4( uOutlineColor.rgb, uOutlineColor.a * clampedColor.a );
-    lowp vec4 color = mix(outlineColor, clampedColor, outlineBlend);
-
-    mediump float glowBlend = smoothstep(uSmoothing[0], uSmoothing[1], distance);
-
-    // blend fragment color between glow color and text color
-    lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );
-    color = mix(glowColor, color, glowBlend);
-
-    // fade out glow between uSmoothing and uGlow
-    color.a *= smoothstep(uGlow, uSmoothing[0], distance);
-
-    // final color multiplied by Actor color
-    gl_FragColor = uColor * color;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/distance-field-font-outline.txt b/dali/internal/render/shader-source/distance-field-font-outline.txt
deleted file mode 100644 (file)
index 118cbe3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<VertexShader>
-
-  attribute mediump vec3  aPosition;
-  attribute mediump vec2  aTexCoord;
-
-  uniform   mediump mat4  uMvpMatrix;
-  uniform   lowp    vec4  uColor;
-  uniform   lowp    vec4  uTextColor;
-  uniform   lowp    vec4  uGradientColor;
-  uniform   mediump vec4  uGradientLine;
-  uniform   mediump vec2  uInvTextSize;
-
-  varying   mediump vec2  vTexCoord;
-  varying   lowp    vec4  vColor;
-
-  void main()
-  {
-    gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-    vTexCoord = aTexCoord;
-
-    lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
-
-    vColor = mix(uTextColor, uGradientColor, f);
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-  uniform mediump sampler2D sTexture;
-  uniform lowp    vec4      uColor;
-  uniform highp   vec2      uSmoothing;
-  uniform mediump vec2      uOutline;
-  uniform lowp    vec4      uOutlineColor;
-
-  varying highp   vec2      vTexCoord;
-  varying lowp    vec4      vColor;
-
-  void main()
-  {
-    // sample distance field
-    highp float distance = texture2D(sTexture, vTexCoord).a;
-
-    // blend fragment color between outline color and text color
-    highp float outlineBlend = smoothstep(uOutline[0], uOutline[1], distance);
-    lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
-    lowp vec4 outlineColor = vec4( uOutlineColor.rgb, uOutlineColor.a * clampedColor.a );
-    lowp vec4 color = mix(outlineColor, clampedColor, outlineBlend);
-
-    // adjust fragment alpha by sampled distance
-    color.a *= smoothstep(uSmoothing[0], uSmoothing[1], distance);
-
-    // final color multiplied by Actor color
-    gl_FragColor = uColor * color;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/distance-field-font-shadow.txt b/dali/internal/render/shader-source/distance-field-font-shadow.txt
deleted file mode 100644 (file)
index 69cbb9d..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<VertexShader>
-
-  attribute mediump vec3  aPosition;
-  attribute highp vec4  aTexCoord;
-
-  uniform   mediump mat4  uMvpMatrix;
-  uniform   lowp    vec4  uColor;
-  uniform   lowp    vec4  uTextColor;
-  uniform   highp   vec2  uShadow;
-  uniform   lowp    vec4  uGradientColor;
-  uniform   mediump vec4  uGradientLine;
-  uniform   mediump vec2  uInvTextSize;
-
-  varying   highp   vec2  vTexCoord;
-  varying   highp   vec2  vShadowCoord;
-  varying   lowp    vec4  vColor;
-
-  void main()
-  {
-    gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-    vTexCoord = aTexCoord.xy;
-    vShadowCoord = vTexCoord - (uShadow * aTexCoord.zw);
-
-    lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
-    vColor = mix(uTextColor, uGradientColor, f);
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-  uniform mediump sampler2D sTexture;
-  uniform lowp    vec4      uColor;
-  uniform highp   vec2      uSmoothing;
-  uniform highp   vec2      uShadowSmoothing;
-  uniform lowp    vec4      uShadowColor;
-
-  varying highp   vec2      vTexCoord;
-  varying highp   vec2      vShadowCoord;
-  varying lowp    vec4      vColor;
-
-  void main()
-  {
-    // sample distance field
-    mediump float distance = texture2D(sTexture, vTexCoord).a;
-    mediump float shadow_distance = texture2D(sTexture, vShadowCoord).a;
-
-    mediump float inText = smoothstep(uSmoothing[0], uSmoothing[1], distance);
-    mediump float inShadow = smoothstep(uShadowSmoothing[0], uShadowSmoothing[1], shadow_distance);
-
-    lowp vec4 color;
-
-    mediump float oneMinusSrcAlpha = (1.0 - inText) * inShadow;
-
-    lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
-    lowp vec4 cText = vec4( clampedColor.rgb, clampedColor.a * inText );
-    lowp vec4 cShadow = vec4(uShadowColor.rgb, uShadowColor.a * clampedColor.a * inShadow);
-
-    // completely outside shadow, maybe inside text
-    if( inShadow <= 0.0 )
-    {
-      color = cText;
-    }
-    // completely outside text, definitely inside shadow
-    else if( inText <= 0.0 )
-    {
-      color = cShadow;
-    }
-    // inside text and/or shadow border(s)
-    else
-    {
-      color.rgb = mix( cText.rgb, cShadow.rgb, oneMinusSrcAlpha );
-      color.a = max(cText.a, cShadow.a);
-    }
-
-    // final color multiplied by Actor color
-    gl_FragColor = uColor * color;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/distance-field-font.txt b/dali/internal/render/shader-source/distance-field-font.txt
deleted file mode 100644 (file)
index 267852b..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<VertexShader>
-
-  attribute mediump vec3  aPosition;
-  attribute mediump vec2  aTexCoord;
-
-  uniform   mediump mat4  uModelView;
-  uniform   mediump mat4  uProjection;
-  uniform   mediump mat4  uMvpMatrix;
-  uniform   mediump mat3  uNormalMatrix;
-  uniform   lowp    vec4  uColor;
-  uniform   lowp    vec4  uTextColor;
-
-  varying   mediump vec2  vTexCoord;
-
-#ifdef USE_GRADIENT
-  uniform   lowp    vec4  uGradientColor;
-  uniform   mediump vec4  uGradientLine;
-  uniform   mediump vec2  uInvTextSize;
-
-  varying   lowp    vec4  vColor;
-#endif
-
-  void main()
-  {
-    gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-    vTexCoord = aTexCoord;
-
-#ifdef USE_GRADIENT
-    lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
-    vColor = mix(uTextColor, uGradientColor, f);
-#endif
-  }
-
-</VertexShader>
-
-<FragmentShader>
-
-  uniform mediump sampler2D sTexture;
-  uniform highp   vec4      sTextureRect;
-  uniform lowp    vec4      uColor;
-  uniform highp   vec2      uSmoothing;
-
-  varying highp vec2      vTexCoord;
-
-#ifdef USE_GRADIENT
-  varying lowp    vec4      vColor;
-#else
-  uniform lowp    vec4      uTextColor;
-#endif
-
-  void main()
-  {
-    // sample distance field
-    highp float distance = texture2D(sTexture, vTexCoord).a;
-
-#ifdef USE_GRADIENT
-    lowp vec4 color = clamp(vColor, 0., 1.); // gradiant calculation can overflow.
-#else
-    lowp vec4 color = uTextColor;
-#endif
-
-    // adjust fragment alpha by sampled distance
-    color.a *= smoothstep(uSmoothing[0], uSmoothing[1], distance );
-
-    // final color multiplied by Actor color
-    gl_FragColor = uColor * color;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/flat-color-texture.txt b/dali/internal/render/shader-source/flat-color-texture.txt
deleted file mode 100644 (file)
index a3f7716..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<VertexShader>
-
-    attribute mediump vec3  aPosition;
-    attribute mediump vec2  aTexCoord;
-
-    uniform   mediump mat4  uMvpMatrix;
-    uniform   lowp    vec4  uColor;
-
-    varying   mediump vec2  vTexCoord;
-
-    void main()
-    {
-      gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-      vTexCoord = aTexCoord;
-    }
-
-</VertexShader>
-
-<FragmentShader>
-
-    uniform         sampler2D sTexture;
-    uniform lowp    vec4      uColor;
-
-    varying mediump vec2      vTexCoord;
-
-    void main()
-    {
-      gl_FragColor = texture2D(sTexture, vTexCoord) * uColor;
-    }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/image.txt b/dali/internal/render/shader-source/image.txt
new file mode 100644 (file)
index 0000000..7851fa7
--- /dev/null
@@ -0,0 +1,44 @@
+<VertexShader>
+
+attribute mediump vec3  aPosition;
+attribute mediump vec2  aTexCoord;
+
+uniform   mediump mat4  uModelView;
+uniform   mediump mat4  uProjection;
+uniform   mediump mat4  uMvpMatrix;
+uniform   mediump mat3  uNormalMatrix;
+uniform   mediump mat4  uModelMatrix;
+uniform   mediump mat4  uViewMatrix;
+
+uniform   mediump vec4  uColor;
+
+varying   mediump vec2  vTexCoord;
+
+uniform   mediump vec4  sTextureRect;
+uniform   mediump vec4  sEffectRect;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+  vTexCoord = aTexCoord;
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+uniform sampler2D sTexture;
+uniform sampler2D sEffect;
+
+uniform mediump vec4 sTextureRect;
+uniform mediump vec4 sEffectRect;
+
+uniform mediump vec4 uColor;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+  gl_FragColor = texture2D(sTexture, vTexCoord) * uColor;
+}
+
+</FragmentShader>
diff --git a/dali/internal/render/shader-source/mesh-color-no-texture.txt b/dali/internal/render/shader-source/mesh-color-no-texture.txt
deleted file mode 100644 (file)
index b8898ef..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-<VertexShader>
-  precision mediump float;
-
-  uniform   mediump mat4    uProjection;
-  uniform   mediump mat4    uModelView;
-  uniform   mediump mat4    uMvpMatrix;
-
-  uniform           bool    uTextureMapped;
-  uniform   mediump vec4    uCustomTextureCoords;
-  attribute mediump vec2    aTexCoord;
-  varying   mediump vec2    vTexCoord;
-
-  uniform   mat3    uModelViewIT;
-  attribute mediump vec3    aNormal;
-  varying   mediump vec3    vNormal;
-
-  attribute mediump vec3    aPosition;
-  varying   mediump vec4    vVertex;
-#define USE_NORMALS
-#define MAX_BONES_PER_MESH  12
-
-#ifdef USE_BONES
-  uniform   int             uBoneCount;
-  uniform   mediump mat4    uBoneMatrices[MAX_BONES_PER_MESH];
-  uniform   mediump mat3    uBoneMatricesIT[MAX_BONES_PER_MESH];
-  attribute mediump vec4    aBoneWeights;
-  attribute mediump vec4    aBoneIndices;
-#endif
-
-#ifdef USE_COLOR
-  attribute lowp vec3       aColor;
-  varying   mediump vec3    vColor;
-#endif
-
-  void main()
-  {
-    mediump vec4 vertexPosition = vec4(aPosition, 1.0);
-
-#ifdef USE_BONES
-    if(uBoneCount > 0)
-    {
-      mediump vec4 boneWeights = aBoneWeights;
-      mediump ivec4 boneIndices = ivec4(aBoneIndices);
-      mediump vec3 vertexNormal;
-
-      // re-calculate the final weight
-      boneWeights.w = 1.0 - dot(boneWeights.xyz, vec3(1.0, 1.0, 1.0));
-
-      vec4 bonePos = (uBoneMatrices[boneIndices.x] * vertexPosition) * boneWeights.x;
-      bonePos     += (uBoneMatrices[boneIndices.y] * vertexPosition) * boneWeights.y;
-      bonePos     += (uBoneMatrices[boneIndices.z] * vertexPosition) * boneWeights.z;
-      bonePos     += (uBoneMatrices[boneIndices.w] * vertexPosition) * boneWeights.w;
-
-      vertexNormal  = (uBoneMatricesIT[boneIndices.x] * aNormal) * boneWeights.x;
-      vertexNormal += (uBoneMatricesIT[boneIndices.y] * aNormal) * boneWeights.y;
-      vertexNormal += (uBoneMatricesIT[boneIndices.z] * aNormal) * boneWeights.z;
-      vertexNormal += (uBoneMatricesIT[boneIndices.w] * aNormal) * boneWeights.w;
-      vertexNormal =  normalize(vertexNormal);
-
-      vertexPosition = uProjection * bonePos;
-      vVertex = bonePos;
-      vNormal = vertexNormal;
-    }
-    else
-    {
-#endif
-      vertexPosition = uMvpMatrix * vec4(aPosition, 1.0);
-      vVertex = uModelView * vec4(aPosition, 1.0);
-      vNormal = uModelViewIT * aNormal;
-#ifdef USE_BONES
-    }
-#endif
-    gl_Position = vertexPosition;
-
-#ifdef USE_COLOR
-    vColor = aColor;
-#endif
-  }
-
-</VertexShader>
-
-<FragmentShader>
-  precision mediump float;
-
-  struct Material
-  {
-    mediump float mOpacity;
-    mediump float mShininess;
-    lowp    vec4  mAmbient;
-    lowp    vec4  mDiffuse;
-    lowp    vec4  mSpecular;
-    lowp    vec4  mEmissive;
-  };
-
-  uniform sampler2D     sTexture;
-  uniform sampler2D     sOpacityTexture;
-  uniform sampler2D     sNormalMapTexture;
-  uniform sampler2D     sEffect;
-  varying vec2          vTexCoord;
-
-  uniform Material      uMaterial;
-
-  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;
-    vec3 N = normalize(vNormal);
-    vec3 L = normalize(lightVector);
-    // TODO: for directional light, should use mLightDir for light direction not lightVector
-    float NdotL = dot(N, L);
-
-    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
-      vec3 E = normalize(vVertex.xyz);
-      vec3 R = reflect(L, N);
-      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
-
-    // set initial color to vertex color
-    vec4 fragColor = vec4(vColor, 1.0);
-
-#else
-
-    // set initial color to material color
-    vec4 fragColor = uMaterial.mAmbient + uMaterial.mDiffuse;
-
-#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;
-
-    // and finally, apply Actor color
-    fragColor *= uColor;
-
-// Next line useful for visualizing the normals
-//    vertexColor = vec4(normalize(vNormal), 1.0);
-    gl_FragColor = fragColor;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/mesh.txt b/dali/internal/render/shader-source/mesh.txt
deleted file mode 100644 (file)
index 2eb5b70..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-<VertexShader>
-  precision mediump float;
-
-  uniform   mediump mat4    uProjection;
-  uniform   mediump mat4    uModelView;
-  uniform   mediump mat4    uMvpMatrix;
-
-  uniform           bool    uTextureMapped;
-  uniform   mediump vec4    uCustomTextureCoords;
-  attribute mediump vec2    aTexCoord;
-  varying   mediump vec2    vTexCoord;
-
-  uniform   mat3            uModelViewIT;
-  attribute mediump vec3    aNormal;
-  varying   mediump vec3    vNormal;
-
-  attribute mediump vec3    aPosition;
-  varying   mediump vec4    vVertex;
-
-#define MAX_BONES_PER_MESH  12
-
-#ifdef USE_BONES
-  uniform   int             uBoneCount;
-  uniform   mediump mat4    uBoneMatrices[MAX_BONES_PER_MESH];
-  uniform   mediump mat3    uBoneMatricesIT[MAX_BONES_PER_MESH];
-  attribute mediump vec4    aBoneWeights;
-  attribute mediump vec4    aBoneIndices;
-#endif
-
-  void main()
-  {
-    mediump vec4 vertexPosition = vec4(aPosition, 1.0);
-    mediump float lightIntensity;
-
-#ifdef USE_BONES
-    if(uBoneCount > 0)
-    {
-      mediump vec4 boneWeights = aBoneWeights;
-      mediump ivec4 boneIndices = ivec4(aBoneIndices);
-      mediump vec3 vertexNormal;
-
-      // re-calculate the final weight
-      boneWeights.w = 1.0 - dot(boneWeights.xyz, vec3(1.0, 1.0, 1.0));
-
-      vec4 bonePos = (uBoneMatrices[boneIndices.x] * vertexPosition) * boneWeights.x;
-      bonePos     += (uBoneMatrices[boneIndices.y] * vertexPosition) * boneWeights.y;
-      bonePos     += (uBoneMatrices[boneIndices.z] * vertexPosition) * boneWeights.z;
-      bonePos     += (uBoneMatrices[boneIndices.w] * vertexPosition) * boneWeights.w;
-
-      vertexNormal  = (uBoneMatricesIT[boneIndices.x] * aNormal) * boneWeights.x;
-      vertexNormal += (uBoneMatricesIT[boneIndices.y] * aNormal) * boneWeights.y;
-      vertexNormal += (uBoneMatricesIT[boneIndices.z] * aNormal) * boneWeights.z;
-      vertexNormal += (uBoneMatricesIT[boneIndices.w] * aNormal) * boneWeights.w;
-      vertexNormal =  normalize(vertexNormal);
-
-      vertexPosition = uProjection * bonePos;
-      vVertex = bonePos;
-      vNormal = vertexNormal;
-    }
-    else
-    {
-#endif
-      vertexPosition = uMvpMatrix * vec4(aPosition, 1.0);
-      vVertex = uModelView * vec4(aPosition, 1.0);
-      vNormal = uModelViewIT * aNormal;
-#ifdef USE_BONES
-    }
-#endif
-    gl_Position = vertexPosition;
-
-    mediump vec2 start = uCustomTextureCoords.xy;
-    mediump vec2 scale = uCustomTextureCoords.zw;
-    vTexCoord = vec2(start.x + aTexCoord.x * scale.x, start.y + aTexCoord.y * scale.y);
-  }
-
-</VertexShader>
-
-<FragmentShader>
-  precision mediump float;
-
-  struct Material
-  {
-    mediump float mOpacity;
-    mediump float mShininess;
-    lowp    vec4  mAmbient;
-    lowp    vec4  mDiffuse;
-    lowp    vec4  mSpecular;
-    lowp    vec4  mEmissive;
-  };
-
-  uniform sampler2D     sTexture;
-  uniform sampler2D     sOpacityTexture;
-  uniform sampler2D     sNormalMapTexture;
-  uniform sampler2D     sEffect;
-  varying vec2          vTexCoord;
-
-  uniform Material      uMaterial;
-
-  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;
-    vec3 N = normalize(vNormal);
-    vec3 L = normalize(lightVector);
-    // TODO: for directional light, should use mLightDir for light direction not lightVector
-    float NdotL = dot(N, L);
-
-    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
-      vec3 E = normalize(vVertex.xyz);
-      vec3 R = reflect(L, N);
-      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
-    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;
-
-    // and finally, apply Actor color
-    fragColor *= uColor;
-
-// Next line useful for visualizing the normals
-//    fragColor = vec4(normalize(vNormal), 1.0);
-    gl_FragColor = fragColor;
-  }
-
-</FragmentShader>
diff --git a/dali/internal/render/shader-source/text-distance-field-glow.txt b/dali/internal/render/shader-source/text-distance-field-glow.txt
new file mode 100644 (file)
index 0000000..bc18e0e
--- /dev/null
@@ -0,0 +1,58 @@
+<VertexShader>
+
+attribute mediump vec3  aPosition;
+attribute mediump vec2  aTexCoord;
+
+uniform   mediump mat4  uMvpMatrix;
+uniform   lowp    vec4  uColor;
+uniform   lowp    vec4  uTextColor;
+uniform   lowp    vec4  uGradientColor;
+uniform   mediump vec4  uGradientLine;
+uniform   mediump vec2  uInvTextSize;
+
+varying   mediump vec2  vTexCoord;
+varying   lowp    vec4  vColor;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+  vTexCoord = aTexCoord;
+
+  lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
+
+  vColor = mix(uTextColor, uGradientColor, f);
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+uniform mediump sampler2D sTexture;
+uniform lowp    vec4      uColor;
+uniform highp   vec2      uSmoothing;
+uniform highp   float     uGlow;
+uniform lowp    vec4      uGlowColor;
+
+varying mediump vec2      vTexCoord;
+varying lowp vec4         vColor;
+
+void main()
+{
+  // sample distance field
+  mediump float distance = texture2D(sTexture, vTexCoord).a;
+
+  mediump float glowBlend = smoothstep(uSmoothing[0], uSmoothing[1], distance);
+
+  // blend fragment color between glow color and text color
+  lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
+  lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );
+  lowp vec4 color = mix(glowColor, clampedColor, glowBlend);
+
+  // fade out glow between uSmoothing and uGlow
+  color.a *= smoothstep(uGlow, uSmoothing[0], distance);
+
+  // final color multiplied by Actor color
+  gl_FragColor = uColor * color;
+}
+
+</FragmentShader>
diff --git a/dali/internal/render/shader-source/text-distance-field-outline-glow.txt b/dali/internal/render/shader-source/text-distance-field-outline-glow.txt
new file mode 100644 (file)
index 0000000..6196349
--- /dev/null
@@ -0,0 +1,68 @@
+<VertexShader>
+
+attribute mediump vec3  aPosition;
+attribute mediump vec2  aTexCoord;
+
+uniform   mediump mat4  uMvpMatrix;
+uniform   lowp    vec4  uColor;
+uniform   lowp    vec4  uTextColor;
+uniform   lowp    vec4  uGradientColor;
+uniform   mediump vec4  uGradientLine;
+uniform   mediump vec2  uInvTextSize;
+
+varying   mediump vec2  vTexCoord;
+varying   lowp    vec4  vColor;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+  vTexCoord = aTexCoord;
+
+  lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
+
+  vColor = mix(uTextColor, uGradientColor, f);
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+uniform mediump sampler2D sTexture;
+uniform lowp    vec4      uColor;
+uniform highp   vec2      uSmoothing;
+uniform highp   vec2      uOutline;
+uniform lowp    vec4      uOutlineColor;
+uniform highp   float     uGlow;
+uniform lowp    vec4      uGlowColor;
+
+varying mediump vec2      vTexCoord;
+varying lowp vec4         vColor;
+
+void main()
+{
+  // sample distance field
+  mediump float distance = texture2D(sTexture, vTexCoord).a;
+
+  // blend fragment color between outline color and text color
+  mediump float outlineBlend = smoothstep(uOutline[0], uOutline[1], distance);
+
+  lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
+
+  // create blend between text color and outline color using outlineBlend
+  lowp vec4 outlineColor = vec4( uOutlineColor.rgb, uOutlineColor.a * clampedColor.a );
+  lowp vec4 color = mix(outlineColor, clampedColor, outlineBlend);
+
+  mediump float glowBlend = smoothstep(uSmoothing[0], uSmoothing[1], distance);
+
+  // blend fragment color between glow color and text color
+  lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );
+  color = mix(glowColor, color, glowBlend);
+
+  // fade out glow between uSmoothing and uGlow
+  color.a *= smoothstep(uGlow, uSmoothing[0], distance);
+
+  // final color multiplied by Actor color
+  gl_FragColor = uColor * color;
+}
+
+</FragmentShader>
diff --git a/dali/internal/render/shader-source/text-distance-field-outline.txt b/dali/internal/render/shader-source/text-distance-field-outline.txt
new file mode 100644 (file)
index 0000000..2e786d5
--- /dev/null
@@ -0,0 +1,57 @@
+<VertexShader>
+
+attribute mediump vec3  aPosition;
+attribute mediump vec2  aTexCoord;
+
+uniform   mediump mat4  uMvpMatrix;
+uniform   lowp    vec4  uColor;
+uniform   lowp    vec4  uTextColor;
+uniform   lowp    vec4  uGradientColor;
+uniform   mediump vec4  uGradientLine;
+uniform   mediump vec2  uInvTextSize;
+
+varying   mediump vec2  vTexCoord;
+varying   lowp    vec4  vColor;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+  vTexCoord = aTexCoord;
+
+  lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
+
+  vColor = mix(uTextColor, uGradientColor, f);
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+uniform mediump sampler2D sTexture;
+uniform lowp    vec4      uColor;
+uniform highp   vec2      uSmoothing;
+uniform mediump vec2      uOutline;
+uniform lowp    vec4      uOutlineColor;
+
+varying highp   vec2      vTexCoord;
+varying lowp    vec4      vColor;
+
+void main()
+{
+  // sample distance field
+  highp float distance = texture2D(sTexture, vTexCoord).a;
+
+  // blend fragment color between outline color and text color
+  highp float outlineBlend = smoothstep(uOutline[0], uOutline[1], distance);
+  lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
+  lowp vec4 outlineColor = vec4( uOutlineColor.rgb, uOutlineColor.a * clampedColor.a );
+  lowp vec4 color = mix(outlineColor, clampedColor, outlineBlend);
+
+  // adjust fragment alpha by sampled distance
+  color.a *= smoothstep(uSmoothing[0], uSmoothing[1], distance);
+
+  // final color multiplied by Actor color
+  gl_FragColor = uColor * color;
+}
+
+</FragmentShader>
diff --git a/dali/internal/render/shader-source/text-distance-field-shadow.txt b/dali/internal/render/shader-source/text-distance-field-shadow.txt
new file mode 100644 (file)
index 0000000..a7c99ee
--- /dev/null
@@ -0,0 +1,80 @@
+<VertexShader>
+
+attribute mediump vec3  aPosition;
+attribute highp vec4  aTexCoord;
+
+uniform   mediump mat4  uMvpMatrix;
+uniform   lowp    vec4  uColor;
+uniform   lowp    vec4  uTextColor;
+uniform   highp   vec2  uShadow;
+uniform   lowp    vec4  uGradientColor;
+uniform   mediump vec4  uGradientLine;
+uniform   mediump vec2  uInvTextSize;
+
+varying   highp   vec2  vTexCoord;
+varying   highp   vec2  vShadowCoord;
+varying   lowp    vec4  vColor;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+  vTexCoord = aTexCoord.xy;
+  vShadowCoord = vTexCoord - (uShadow * aTexCoord.zw);
+
+  lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
+  vColor = mix(uTextColor, uGradientColor, f);
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+uniform mediump sampler2D sTexture;
+uniform lowp    vec4      uColor;
+uniform highp   vec2      uSmoothing;
+uniform highp   vec2      uShadowSmoothing;
+uniform lowp    vec4      uShadowColor;
+
+varying highp   vec2      vTexCoord;
+varying highp   vec2      vShadowCoord;
+varying lowp    vec4      vColor;
+
+void main()
+{
+  // sample distance field
+  mediump float distance = texture2D(sTexture, vTexCoord).a;
+  mediump float shadow_distance = texture2D(sTexture, vShadowCoord).a;
+
+  mediump float inText = smoothstep(uSmoothing[0], uSmoothing[1], distance);
+  mediump float inShadow = smoothstep(uShadowSmoothing[0], uShadowSmoothing[1], shadow_distance);
+
+  lowp vec4 color;
+
+  mediump float oneMinusSrcAlpha = (1.0 - inText) * inShadow;
+
+  lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 );
+  lowp vec4 cText = vec4( clampedColor.rgb, clampedColor.a * inText );
+  lowp vec4 cShadow = vec4(uShadowColor.rgb, uShadowColor.a * clampedColor.a * inShadow);
+
+  // completely outside shadow, maybe inside text
+  if( inShadow <= 0.0 )
+  {
+    color = cText;
+  }
+  // completely outside text, definitely inside shadow
+  else if( inText <= 0.0 )
+  {
+    color = cShadow;
+  }
+  // inside text and/or shadow border(s)
+  else
+  {
+    color.rgb = mix( cText.rgb, cShadow.rgb, oneMinusSrcAlpha );
+    color.a = max(cText.a, cShadow.a);
+  }
+
+  // final color multiplied by Actor color
+  gl_FragColor = uColor * color;
+}
+
+</FragmentShader>
diff --git a/dali/internal/render/shader-source/text-distance-field.txt b/dali/internal/render/shader-source/text-distance-field.txt
new file mode 100644 (file)
index 0000000..a02a980
--- /dev/null
@@ -0,0 +1,69 @@
+<VertexShader>
+
+attribute mediump vec3  aPosition;
+attribute mediump vec2  aTexCoord;
+
+uniform   mediump mat4  uModelView;
+uniform   mediump mat4  uProjection;
+uniform   mediump mat4  uMvpMatrix;
+uniform   mediump mat3  uNormalMatrix;
+uniform   lowp    vec4  uColor;
+uniform   lowp    vec4  uTextColor;
+
+varying   mediump vec2  vTexCoord;
+
+#ifdef USE_GRADIENT
+uniform   lowp    vec4  uGradientColor;
+uniform   mediump vec4  uGradientLine;
+uniform   mediump vec2  uInvTextSize;
+
+varying   lowp    vec4  vColor;
+#endif
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+  vTexCoord = aTexCoord;
+
+#ifdef USE_GRADIENT
+  lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw );
+  vColor = mix(uTextColor, uGradientColor, f);
+#endif
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+uniform mediump sampler2D sTexture;
+uniform highp   vec4      sTextureRect;
+uniform lowp    vec4      uColor;
+uniform highp   vec2      uSmoothing;
+
+varying highp vec2      vTexCoord;
+
+#ifdef USE_GRADIENT
+varying lowp    vec4      vColor;
+#else
+uniform lowp    vec4      uTextColor;
+#endif
+
+void main()
+{
+  // sample distance field
+  highp float distance = texture2D(sTexture, vTexCoord).a;
+
+#ifdef USE_GRADIENT
+  lowp vec4 color = clamp(vColor, 0., 1.); // gradiant calculation can overflow.
+#else
+  lowp vec4 color = uTextColor;
+#endif
+
+  // adjust fragment alpha by sampled distance
+  color.a *= smoothstep(uSmoothing[0], uSmoothing[1], distance );
+
+  // final color multiplied by Actor color
+  gl_FragColor = uColor * color;
+}
+
+</FragmentShader>
diff --git a/dali/internal/render/shader-source/textured-mesh.txt b/dali/internal/render/shader-source/textured-mesh.txt
new file mode 100644 (file)
index 0000000..c155725
--- /dev/null
@@ -0,0 +1,191 @@
+<VertexShader>
+
+uniform   mediump mat4    uProjection;
+uniform   mediump mat4    uModelView;
+uniform   mediump mat4    uMvpMatrix;
+
+uniform           bool    uTextureMapped;
+uniform   mediump vec4    uCustomTextureCoords;
+attribute mediump vec2    aTexCoord;
+varying   mediump vec2    vTexCoord;
+
+uniform   mat3            uModelViewIT;
+attribute mediump vec3    aNormal;
+varying   mediump vec3    vNormal;
+
+attribute mediump vec3    aPosition;
+varying   mediump vec4    vVertex;
+
+#define MAX_BONES_PER_MESH  12
+
+#ifdef USE_BONES
+uniform   int             uBoneCount;
+uniform   mediump mat4    uBoneMatrices[MAX_BONES_PER_MESH];
+uniform   mediump mat3    uBoneMatricesIT[MAX_BONES_PER_MESH];
+attribute mediump vec4    aBoneWeights;
+attribute mediump vec4    aBoneIndices;
+#endif
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 1.0);
+  mediump float lightIntensity;
+
+#ifdef USE_BONES
+  if(uBoneCount > 0)
+  {
+    mediump vec4 boneWeights = aBoneWeights;
+    mediump ivec4 boneIndices = ivec4(aBoneIndices);
+    mediump vec3 vertexNormal;
+
+    // re-calculate the final weight
+    boneWeights.w = 1.0 - dot(boneWeights.xyz, vec3(1.0, 1.0, 1.0));
+
+    mediump vec4 bonePos = (uBoneMatrices[boneIndices.x] * vertexPosition) * boneWeights.x;
+    bonePos     += (uBoneMatrices[boneIndices.y] * vertexPosition) * boneWeights.y;
+    bonePos     += (uBoneMatrices[boneIndices.z] * vertexPosition) * boneWeights.z;
+    bonePos     += (uBoneMatrices[boneIndices.w] * vertexPosition) * boneWeights.w;
+
+    vertexNormal  = (uBoneMatricesIT[boneIndices.x] * aNormal) * boneWeights.x;
+    vertexNormal += (uBoneMatricesIT[boneIndices.y] * aNormal) * boneWeights.y;
+    vertexNormal += (uBoneMatricesIT[boneIndices.z] * aNormal) * boneWeights.z;
+    vertexNormal += (uBoneMatricesIT[boneIndices.w] * aNormal) * boneWeights.w;
+    vertexNormal =  normalize(vertexNormal);
+
+    vertexPosition = uProjection * bonePos;
+    vVertex = bonePos;
+    vNormal = vertexNormal;
+  }
+  else
+  {
+#endif
+    vertexPosition = uMvpMatrix * mediump vec4(aPosition, 1.0);
+    vVertex = uModelView * mediump vec4(aPosition, 1.0);
+    vNormal = uModelViewIT * aNormal;
+#ifdef USE_BONES
+  }
+#endif
+  gl_Position = vertexPosition;
+
+  mediump vec2 start = uCustomTextureCoords.xy;
+  mediump vec2 scale = uCustomTextureCoords.zw;
+  vTexCoord = mediump vec2(start.x + aTexCoord.x * scale.x, start.y + aTexCoord.y * scale.y);
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+struct Material
+{
+  mediump float mOpacity;
+  mediump float mShininess;
+  lowp    vec4  mAmbient;
+  lowp    vec4  mDiffuse;
+  lowp    vec4  mSpecular;
+  lowp    vec4  mEmissive;
+};
+
+uniform sampler2D     sTexture;
+uniform sampler2D     sOpacityTexture;
+uniform sampler2D     sNormalMapTexture;
+uniform sampler2D     sEffect;
+varying mediump vec2 vTexCoord;
+
+uniform Material      uMaterial;
+
+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;
+
+  // and finally, apply Actor color
+  fragColor *= uColor;
+
+  gl_FragColor = fragColor;
+}
+
+</FragmentShader>
diff --git a/dali/internal/render/shader-source/untextured-mesh.txt b/dali/internal/render/shader-source/untextured-mesh.txt
new file mode 100644 (file)
index 0000000..9ba5af9
--- /dev/null
@@ -0,0 +1,206 @@
+<VertexShader>
+uniform   mediump mat4    uProjection;
+uniform   mediump mat4    uModelView;
+uniform   mediump mat4    uMvpMatrix;
+
+uniform           bool    uTextureMapped;
+uniform   mediump vec4    uCustomTextureCoords;
+attribute mediump vec2    aTexCoord;
+varying   mediump vec2    vTexCoord;
+
+uniform   mat3    uModelViewIT;
+attribute mediump vec3    aNormal;
+varying   mediump vec3    vNormal;
+
+attribute mediump vec3    aPosition;
+varying   mediump vec4    vVertex;
+#define USE_NORMALS
+#define MAX_BONES_PER_MESH  12
+
+#ifdef USE_BONES
+uniform   int             uBoneCount;
+uniform   mediump mat4    uBoneMatrices[MAX_BONES_PER_MESH];
+uniform   mediump mat3    uBoneMatricesIT[MAX_BONES_PER_MESH];
+attribute mediump vec4    aBoneWeights;
+attribute mediump vec4    aBoneIndices;
+#endif
+
+#ifdef USE_COLOR
+attribute lowp vec3       aColor;
+varying   mediump vec3    vColor;
+#endif
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 1.0);
+
+#ifdef USE_BONES
+  if(uBoneCount > 0)
+  {
+    mediump vec4 boneWeights = aBoneWeights;
+    mediump ivec4 boneIndices = ivec4(aBoneIndices);
+    mediump vec3 vertexNormal;
+
+    // re-calculate the final weight
+    boneWeights.w = 1.0 - dot(boneWeights.xyz, vec3(1.0, 1.0, 1.0));
+
+    vec4 bonePos = (uBoneMatrices[boneIndices.x] * vertexPosition) * boneWeights.x;
+    bonePos     += (uBoneMatrices[boneIndices.y] * vertexPosition) * boneWeights.y;
+    bonePos     += (uBoneMatrices[boneIndices.z] * vertexPosition) * boneWeights.z;
+    bonePos     += (uBoneMatrices[boneIndices.w] * vertexPosition) * boneWeights.w;
+
+    vertexNormal  = (uBoneMatricesIT[boneIndices.x] * aNormal) * boneWeights.x;
+    vertexNormal += (uBoneMatricesIT[boneIndices.y] * aNormal) * boneWeights.y;
+    vertexNormal += (uBoneMatricesIT[boneIndices.z] * aNormal) * boneWeights.z;
+    vertexNormal += (uBoneMatricesIT[boneIndices.w] * aNormal) * boneWeights.w;
+    vertexNormal =  normalize(vertexNormal);
+
+    vertexPosition = uProjection * bonePos;
+    vVertex = bonePos;
+    vNormal = vertexNormal;
+  }
+  else
+  {
+#endif
+    vertexPosition = uMvpMatrix * vec4(aPosition, 1.0);
+    vVertex = uModelView * vec4(aPosition, 1.0);
+    vNormal = uModelViewIT * aNormal;
+#ifdef USE_BONES
+  }
+#endif
+  gl_Position = vertexPosition;
+
+#ifdef USE_COLOR
+  vColor = aColor;
+#endif
+}
+
+</VertexShader>
+
+<FragmentShader>
+
+struct Material
+{
+  mediump float mOpacity;
+  mediump float mShininess;
+  lowp    vec4  mAmbient;
+  lowp    vec4  mDiffuse;
+  lowp    vec4  mSpecular;
+  lowp    vec4  mEmissive;
+};
+
+uniform sampler2D     sTexture;
+uniform sampler2D     sOpacityTexture;
+uniform sampler2D     sNormalMapTexture;
+uniform sampler2D     sEffect;
+varying mediump vec2  vTexCoord;
+
+uniform Material      uMaterial;
+
+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;
+  vec3 N = normalize(vNormal);
+  vec3 L = normalize(lightVector);
+  // TODO: for directional light, should use mLightDir for light direction not lightVector
+  float NdotL = dot(N, L);
+
+  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
+    vec3 E = normalize(vVertex.xyz);
+    vec3 R = reflect(L, N);
+    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
+
+  // set initial color to vertex color
+  mediump vec4 fragColor = vec4(vColor, 1.0);
+
+#else
+
+  // set initial color to material color
+  mediump vec4 fragColor = uMaterial.mAmbient + uMaterial.mDiffuse;
+
+#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;
+
+  // and finally, apply Actor color
+  fragColor *= uColor;
+
+  gl_FragColor = fragColor;
+}
+
+</FragmentShader>
index fe9623f..a5af5b9 100644 (file)
@@ -90,9 +90,9 @@ inline unsigned int GetGeometryTypeIndex(GeometryType type)
   {
     index = Log<GEOMETRY_TYPE_TEXT>::value;
   }
-  else if ( type & GEOMETRY_TYPE_MESH )
+  else if ( type & GEOMETRY_TYPE_UNTEXTURED_MESH )
   {
-    index = Log<GEOMETRY_TYPE_MESH>::value;
+    index = Log<GEOMETRY_TYPE_UNTEXTURED_MESH>::value;
   }
   else if ( type & GEOMETRY_TYPE_TEXTURED_MESH )
   {
index ca8b854..a9fe2c8 100644 (file)
@@ -68,7 +68,7 @@ enum GeometryType
 {
   GEOMETRY_TYPE_IMAGE = 0x01,         ///< image, with flat color or texture
   GEOMETRY_TYPE_TEXT = 0x02,          ///< text, with flat color or texture
-  GEOMETRY_TYPE_MESH = 0x04,          ///< Complex meshes, with flat color
+  GEOMETRY_TYPE_UNTEXTURED_MESH = 0x04,///< Complex meshes, with flat color
   GEOMETRY_TYPE_TEXTURED_MESH = 0x08, ///< Complex meshes, with texture
   GEOMETRY_TYPE_LAST = 0x10
 };