Hacking COLLADA to add reflectivity

Model with shininess (Phong shader)

If you export a COLLADA DAE model from SketchUp (using either the 3D Model Export feature in SketchUp or my Sketchfab plugin), then you will notice that any materials in the model (colors or textures) look flat (like you can see in the model shown in the web viewer below). Although shininess is not always appropriate, a slight amount of reflectivity can “dress up” such a model significantly.

Default model

The flat textures appear because SketchUp exports COLLADA files in a way that assigns a “Lambert” shader to all materials. This provides accurate texturing, color and transparency but no reflections. A better shading approach is actually written into the COLLADA specification (p. 8-84) and is readily available in many COLLADA viewers (including WebGL viewers like Sketchfab) – it’s a Phong shader. If we want any glossiness, that’s the one we want.

To add glossiness to an already exported COLLADA file, open it in a text editor and use find/replace or any other method you like to replace lines like these:

  <diffuse><color>1.0 0.0 0.0 1.0</color></diffuse>


  <ambient><color>0.0 0.0 0.0 1.0</color></ambient>
  <specular><color>1.0 1.0 1.0 1.0</color></specular>
  <reflective><color>1.0 1.0 1.0 1.0</color></reflective>
  <diffuse><color>1.0 0.0 0.0 1.0</color></diffuse>

Do this for every material that is defined in the file. Just change “lambert” to “phong” but leave the “diffuse” line alone. Then add the other lines. Feel free to modify the parameters to your liking.

Links & Ads: