ColladaFX shared parameter refencing

I’ve been looking around try to find an example of how to share parameters between the profile_CG and profile_COMMON. I haven’t found any examples of what this would look like, but from reading the specification, I created this Collada document below. This validates against the schema, but neither FCollada nor COLLADA_DOM are capable of handling an effect like this.

Is there a collada library that supports shared parameters yet that can be used to verify this document against?

Are there any examples of effects that share parameters between profiles in the wild yet?

Are there any other expected problems with defining an effects like this?


<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema"
version="1.4.1">
  <asset>
    <created>2000-01-01T00:00:00Z</created>
    <modified>2000-01-01T00:00:00Z</modified>
  </asset>
  <library_effects>
    <effect id="e">
      <newparam sid="diffuseSurface">
        <surface type="2D">
          <format>RGB</format>
          <init_as_null/>
        </surface>
      </newparam>
      <newparam sid="diffuseSampler">
        <semantic>DIFFUSE</semantic>
        <sampler2D><source>diffuseSurface</source></sampler2D>
      </newparam>
      <newparam sid="ambientColor">
        <semantic>AMBIENT</semantic>
        <float4>0 0 0 1</float4>
      </newparam>
      <profile_CG>
        <technique>
          <pass sid="p">
            <shader stage="VERTEX">
              <name source="vs">main</name>
            </shader>
            <shader stage="FRAGMENT">
              <name source="fs">main</name>
              <bind symbol="g_diffuse"><param ref="diffuseSampler"/></bind>
              <bind symbol="g_ambient"><param ref="ambientColor"/></bind>
            </shader>
          </pass>
        </technique>
      </profile_CG>
      <profile_COMMON>
        <technique sid="Blinn">
          <blinn>
            <ambient><param ref="ambientColor"/></ambient>
            <diffuse><texture texture="diffuseSampler" texcoord="TEX0"/></diffuse>
          </blinn>
        </technique>
      </profile_COMMON>
    </effect>
  </library_effects>
</COLLADA>

Your example looks right to me. What do you mean when you say that the DOM doesn’t handle an effect like that? It’s up to the client to resolve SID values, so as long as the DOM reads in all the data correctly I would think that it succeeded.

I’m not sure of what apps (if any) support shared parameters properly. Did you try Feeling Viewer?

To be me more accurate, Collada_DOM parses it okay.

The fact that you cannot cast between domCommon_newparam_type and domFx_newparam_common make it non-trivial to add support to Collada_FX / Collada_RT (or at least, I could not find a way to easily cast between them).

Yeah, since those are completely distinct types in the schema, the DOM code generator creates distinct classes for each. You can’t cast between them. You have to write two paths unfortunately.

If you use the daeSIDResolver class to resolve the sid to an element, you can figure out which type of <newparam> it is as follows:

if (domFx_newparam_common* param = daeSafeCast<domFx_newparam_common>(element)) {
    // do stuff
}
else if (domCommon_newparam_type* param = daeSafeCast<domCommon_newparam_type>(element)) {
    // do stuff
}

So the DOM shouldn’t be a limiting factor in RT’s ability to support shared parameters.