Results 1 to 4 of 4

Thread: Exporting UV and homogenous UVQ coordinates simultaneously

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    3

    Exporting UV and homogenous UVQ coordinates simultaneously

    Hi, I want to export UV and UVQ (homogenous) coordinates simultaneously and I am wondering what's the best way of doing this. I am thinking of using a <source> with a <float_array> and an accessor with 5 <param>'s like: (I intentionally left off the unimportant parts)
    Code :
    <source id="...">
       <float_array id="...">
       <technique_common>
          <accessor source="...">
             <param name="S" type="float"/>
             <param name="T" type="float"/>
             <param name="xxx_u" type="float"/>
             <param name="xxx_v" type="float"/>
             <param name="xxx_q" type="float"/>
          </accessor>
       </technique_common>
    </source>
    Or is this the better way:
    Code :
    <source id="...">
       <float_array id="...">
       <technique_common>
          <accessor source="...">
             <param name="S" type="float"/>
             <param name="T" type="float"/>
          </accessor>
       </technique_common>
       <technique profile="...">
          <accessor source="...">
             <param name="xxx_u" type="float"/>
             <param name="xxx_v" type="float"/>
             <param name="xxx_q" type="float"/>
          </accessor>
       </technique>
    </source>
    Which one is better? Are there better ways of doing this? Will this be transparent for other applications who don't know about "xxx_u", "xxx_v", "xxx_q" in the first case and how should those param's be named properly in both cases?
    Thanks.

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: Exporting UV and homogenous UVQ coordinates simultaneous

    Quote Originally Posted by rreichl
    Hi, I want to export UV and UVQ (homogenous) coordinates simultaneously and I am wondering what's the best way of doing this. I am thinking of using a <source> with a <float_array> and an accessor with 5 <param>'s
    You can export the values in one or more <float_array> as you like. Remember that source data does not have semantics yet. The values don't "become" texture coordinates until they are referenced by an <input semantic="TEXCOORD"> element.

    Also note that inputs are scalable according to the source's accessor, so that a TEXCOORD can sample 1D, 2D, 3D, or more texture coordinates. The common profile defines parameters for up to 4D (using S,T,P,Q as names). For example:
    Code :
    <source id="3d">
       <float_array id="stp">
       <technique_common>
          <accessor source="#stp">
             <param name="S" type="float"/>
             <param name="T" type="float"/>
             <param name="P" type="float"/>
          </accessor>
       </technique_common>
    </source>
     
    <source id="4d">
       <float_array id="stpq">
       <technique_common>
          <accessor source="#stpq">
             <param name="S" type="float"/>
             <param name="T" type="float"/>
             <param name="P" type="float"/>
             <param name="Q" type="float"/>
          </accessor>
       </technique_common>
    </source>
    ...
    <triangles ...>
       <input semantic="TEXCOORD" source="#3d" set="1"/>
       <input semantic="TEXCOORD" source="#4d" set="2"/>
    </triangles>

  3. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    3
    But real 3D texture coordinates are different from homogenous 2D texture coordinates using three values. Isn't STP used for real 3D texture coordinates or can it also be used for homogenous 2D texture coordinates with three values. But how can an application then decide if it is 3D or homogenous 2D?

    If i separate the 2D texture coordinates and the homogenous 2D texture coordinates like in your example and having two <input semantic> then I have to bind the texture name in a e.g. <diffuse> to two different <input semantic> elements simultanously which I can't. I'd like one application to choose the 2D texture coordinates and the other the homogenous 2D texture coordinates with one bind to one <input semantic>.

    You write that the values don't "become" texture coordinates until they are referenced properly. I agree, but if I name the first param "2" and the second param "1" and not "S", "T" or "T", "S" how does an importer know that the first param "2" is in fact the v coordinate and the second param "1" is in fact the u coordinate. I know this is probably a very basic COLLADA question but I saw exporters writing out S and T and other exporters writing out U and V for texture coordinates so I would like to know how this should be handled properly.

    Thanks.

  4. #4
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771
    For your case, you may need to provide <extra> data that describes what you're doing with the homogeneous coordinates.

    Certainly you can bind the different sets of texture coordinates to your material. Taken from the 1.4.1 2nd Edition spec:

    <instance_geometry url="#geometry_id">
    <bind_material>
    <technique_common>
    <instance_material symbol="material_symbol" target="#material_id">
    <bind_vertex_input semantic="myST" input_semantic="TEXCOORD" set="1" />
    <bind_vertex_input semantic="myUVW" input_semantic="TEXCOORD" set="2" />
    <extra profile="XXX">
    <homogeneous_texture set="2">true</homogeneous_texture>
    </extra>

    </instance_material>
    </technique_common>
    </bind_material>
    </instance_geometry>
    ... I've add the set attribute to the example (in green) showing that you can cleaning bind multiple inputs to from your geometry to your material. I've also added an <extra> that says the 2nd set is homogeneous. This is just a suggestion on for you to consider.

    The names of the <param> don't matter in fact. The order of values is defined by the semantic. In this case TEXCOORD means S, then T, then P, then Q, in that order if all are present. No gaps are allowed.

    Since your 2nd set of textures are not in keeping with that semantic, I suggest that you use the generic UV semantic instead, for proper U, V, W values. E.g.:

    Code :
       <bind_vertex_input semantic="myUVW" input_semantic="UV" set="2" />

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •