Previous Thread  Next Thread

chat icon Collada material export with texture

Zoijar

Posted: Thu Jan 24, 2013 3:05 pm
Joined: 24 Jan 2013
Posts: 2
I'm trying to export a simple object with a material to collada. I created a material with a diffuse texture, and assigned it to the cube. It renders as expected in Blender itself. Export options have all the texture options on. The generated collada file looks as follows:

Code:

  <library_images>
    <image id="cobblestone_jpg" name="cobblestone_jpg">
      <init_from>cobblestone.jpg</init_from>
    </image>

...

<library_effects>
    <effect id="Cobblestone-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>

...

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


The material is there, properly linked to the object, and references the right effect. The images are there, but the problem is that the effect does not link the images as surfaces (so they won't be used; how could you find them?)

In contrast, 3ds max exports like this in the effect section:

Code:

<effect id="Material__121">
      <profile_COMMON>
        <newparam sid="pedestal_jpg-surface">
          <surface type="2D">
            <init_from>pedestal_jpg</init_from>
          </surface>
        </newparam>
        <newparam sid="pedestal_jpg-sampler">
          <sampler2D>
            <source>pedestal_jpg-surface</source>
          </sampler2D>
        </newparam>
        <technique sid="common">
          <blinn>
            <emission>
              <color>0 0 0 1</color>
            </emission>
            <ambient>
              <color>0 0.2941177 0.01960784 1</color>
            </ambient>
            <diffuse>
              <texture texture="pedestal_jpg-sampler" texcoord="CHANNEL1"/>
            </diffuse>
            <specular>
              <color>0.9 0.9 0.9 1</color>
            </specular>
            <shininess>
              <float>10</float>
            </shininess>
            <reflective>
              <color>0 0 0 1</color>
            </reflective>
            <transparent opaque="A_ONE">
              <color>1 1 1 1</color>
            </transparent>
            <transparency>
              <float>1</float>
            </transparency>
          </blinn>
        </technique>
      </profile_COMMON>
      <extra>


Which I believe to be the proper way; i.e., it first defines a 'surface' that references an image, it then defines a 'sampler' that references this surface, and finally it sets the diffuse material property to a texture, which references the sampler. My code then parses: texture -> sampler -> surface -> image.

Is it possible to enable this behaviour in Blender, or is it simply not (yet) supported? Is there another way to get textures to be referenced in the materials?
Reply with quote


Zoijar

Posted: Sat Jan 26, 2013 2:50 pm
Joined: 24 Jan 2013
Posts: 2
I'm sorry; I've solved it... turns out that if your texture mapping is set to generated it won't export the textures into the effect. You have to use uv mapping coordinates (for future reference if someone finds this), then it works as expected, similar to 3ds.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group