11
$\begingroup$

I've been having trouble exporting collada objects from blender, so I stripped everything back and textured a single cube, and exported it.

This is a completely trivial model, one cube, with one material assigned to it, the material has a single 'g.png' texture assigned to it.

The exported collada data looks like this:

  <library_materials>
    <material id="Material-material" name="Material">
      <instance_effect url="#Material-effect"/>
    </material>
  </library_materials>

Where:

  <library_effects>
    <effect id="Material-effect">
      <profile_COMMON>
        <technique sid="common">
          <phong>
            <emission>
              <color sid="emission">0.2879998 0.2879998 0.2879998 1</color>
            </emission>
            <ambient>
              <color sid="ambient">0 0 0 1</color>
            </ambient>
            <diffuse>
              <color sid="diffuse">0.2163267 0.1845119 0.2121569 1</color>
            </diffuse>
            <specular>
              <color sid="specular">0.5 0.5 0.5 1</color>
            </specular>
            <shininess>
              <float sid="shininess">50</float>
            </shininess>
            <index_of_refraction>
              <float sid="index_of_refraction">1</float>
            </index_of_refraction>
          </phong>
        </technique>
        <extra>
          <technique profile="GOOGLEEARTH">
            <double_sided>1</double_sided>
          </technique>
        </extra>
      </profile_COMMON>
      <extra><technique profile="MAX3D"><double_sided>1</double_sided></technique></extra>
    </effect>
  </library_effects>

This seems to be missing the texture data associated with the object.

By comparsion, exporting a wavefront object generates this .mtl file:

# Blender MTL File: 'basic.blend'
# Material Count: 1

newmtl Material
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.790000 0.790000 0.790000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 0
map_Kd g.png   <----- ie. Blender is aware of this texture

So... is the collada exporter for blender just broken, or does it require some kind of special config in order to function correctly?

If the latter, how/what is required to make this work?

(NB for what it's worth, the UV coordinates are exported in the .dae, abit they obviously are completely useless without a texture assigned to them; I've also tried adding two different textures to see if the exporter needs that because it naively assumes 'one texture = don't bother, it's one texture for the whole model'. That didn't work either)

$\endgroup$

3 Answers 3

7
$\begingroup$

Start with the default cube. Ensure you've created a material or use the default material already created. Assign a texture to it as a diffuse image, say "lava.png". The important point here is to assign your object texture via a material. There is another way to directly texture mesh faces without a material but you still need a default material to get the Collada export to recognise textures, so I suggest going with this approach. If you export as Collada format now, ensure you select "Include material textures" checkbox in the export options. This will produce something along the lines of following XML element in the export file:

<library_images>
    <image id="lava_png" name="lava_png">
        <init_from>lava.png</init_from>
    </image>
</library_images>

But the library effect element will look something like:

<library_effects>
    <effect id="Material-effect">
        <profile_COMMON>
            <technique sid="common">
                <phong>
                    <emission>
                        <color sid="emission">0 0 0 1</color>
                    </emission>
                    <ambient>
                        <color sid="ambient">0 0 0 1</color>
                        </ambient>
                    <diffuse>
                        <color sid="diffuse">0.64 0.64 0.64 1</color>
                    </diffuse>
                    <specular>
                        <color sid="specular">0.5 0.5 0.5 1</color>
                    </specular>
                    <shininess>
                        <float sid="shininess">50</float>
                    </shininess>
                    <index_of_refraction>
                        <float sid="index_of_refraction">1</float>
                    </index_of_refraction>
                </phong>
            </technique>
        <extra>
            <technique profile="GOOGLEEARTH">
                <double_sided>1</double_sided>
            </technique>
        </extra>
        </profile_COMMON>
        <extra>
            <technique profile="MAX3D"><double_sided>1</double_sided>
            </technique>
        </extra>
    </effect>
</library_effects>

Note that the diffuse element defines a colour rather than an image reference. This means there's no 'link' in the Collada file between the lava.png and the diffuse component of the material associated with the mesh.

The missing step relates to the coordinate mapping technique used. Go to the texture panel for the lava.png and find the "Mapping" section. The coordinates entry is likely set to "generated". Change this to UV and export again with "Include material textures" and the diffuse entry will now reference "lava_png-sampler". Something like:

<library_effects>
    <effect id="Material-effect">
        <profile_COMMON>
            <newparam sid="lava_png-surface">
                <surface type="2D">
                    <init_from>lava_png</init_from>
                </surface>
            </newparam>
            <newparam sid="lava_png-sampler">
                <sampler2D>
                    <source>lava_png-surface</source>
                </sampler2D>
            </newparam>
            <technique sid="common">
                <phong>
                    <emission>
                        <color sid="emission">0 0 0 1</color>
                    </emission>
                    <ambient>
                         <color sid="ambient">0 0 0 1</color>
                    </ambient>
                    <diffuse>
                        <texture texture="lava_png-sampler"/>
                    </diffuse>
                    <specular>
                        <color sid="specular">0.5 0.5 0.5 1</color>
                    </specular>
                    <shininess>
                        <float sid="shininess">50</float>
                    </shininess>
                    <index_of_refraction>
                        <float sid="index_of_refraction">1</float>
                    </index_of_refraction>
                </phong>
            </technique>
            <extra>
                <technique profile="GOOGLEEARTH">
                    <double_sided>1</double_sided>
                </technique>
            </extra>
        </profile_COMMON>
        <extra>
            <technique profile="MAX3D"><double_sided>1</double_sided>
            </technique> 
        </extra>
    </effect>
</library_effects>

This should then import, with the texture intact, into whatever you're using, e.g. Assimp or a modelling package/viewer.

Hope this helps.

$\endgroup$
3
  • $\begingroup$ Just for anyone else who finds this, the key here was: Go to the texture panel for the lava.png and find the "Mapping" section. The coordinates entry is likely set to "generated". Change this to UV and export again. (btw: I'm pretty sure this means the collada exporter is actually broken. Changing the UV coordinate type shouldn't have any impact on this) $\endgroup$
    – Doug
    Commented Nov 16, 2013 at 0:04
  • $\begingroup$ I can't find the "Include material textures" option in Blender 2.80, has this been changed? $\endgroup$
    – user79374
    Commented Sep 1, 2019 at 11:20
  • $\begingroup$ I have exactly this problem, but in Blender v3.6 there is no checkbox option for "Include material textures" - what now??? $\endgroup$
    – fafa
    Commented Oct 13, 2023 at 12:27
5
$\begingroup$

I was having an issue when exporting DAE's to use in Aurasma. After hours of messing around and re-exporting I realised that the problem was that I'd set Blender to default to the 'Cycles' renderer (and therefore associated materials) and exporting DAE's with textures only works with materials created in 'Blender Render' mode. I'm not sure that this solves the exact issue above but it's worth checking out and/or it may help someone else who is trawling the internet looking for a solution to the same issue as me.

$\endgroup$
1
  • $\begingroup$ I'm guessing "Blender Render" mode is "EEVEE"? because then it makes no difference in my case $\endgroup$
    – Daniel
    Commented Nov 23, 2023 at 20:01
2
$\begingroup$

I found out that to export texture you need to have Principled BSDF Shader connected to the texture - this is the only way.

Links to blender source code:

https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/io/collada/Materials.cpp#L236

https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/io/collada/EffectExporter.cpp#L113 https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/io/collada/collada_utils.cpp#L1319 https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/io/collada/collada_utils.cpp#L1448

Principled BSDF

$\endgroup$
3
  • $\begingroup$ This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review $\endgroup$
    – sybog64
    Commented Nov 12, 2021 at 19:24
  • 1
    $\begingroup$ It will help other peoples... come on... People here are so rude... WTF $\endgroup$ Commented Nov 12, 2021 at 21:24
  • $\begingroup$ No, this is not solution at all at least with Blender v3.6 as I have Principled BSFD node there yet it exports Collada .dae file without any image refference in it - images node in the file is empty like this <library_images/> $\endgroup$
    – fafa
    Commented Oct 13, 2023 at 13:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .