UV links between embedded mesh and material

General questions about Indigo, the scene format, rendering etc...
Post Reply
12 posts • Page 1 of 1
User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

UV links between embedded mesh and material

Post by rgigante » Sat Nov 18, 2006 3:11 am

Hi guys,

although there's a basic functionality into XSI2Indigo to export UV coords, i'm trying to provide a new functionality letting the user to specify different materials and different texture proj coords (color UV coords, bump UV coords...and so on) on different portion of the same mesh.

Based on my knowledge above indigo's XML scene description (for onesty i've to say that the ex-provided "xmlmeshtest.xml"...has never worked...and now has disappeared from distro), i've understood that into a standard material definition there the uv_set definition

Code: Select all

<material>
    <name>matAll</name>
    <phong>
        <diffuse>0.8 0.8 0.8</diffuse>
        <specular>0.04 0.04 0.04</specular>
        <exponent>1000</exponent>
        <albedo_texture>
            <gain>1</gain>
            <exponent>1</exponent>
            <uv_set>ColorUV</uv_set>
            <path>..\ref_txt.jpg</path>
        </albedo_texture>
        <bump_map>
           <gain>0.01</gain>
           <exponent>0.1</exponent>
           <uv_set>BumpUV</uv_set>
           <path>..\ref_txt.jpg</path>
        </bump_map>
    </phong>
</material>
that refers to the exposed_uv_set in the mesh description:

Code: Select all

<mesh>
	<name>sphere</name>
	<embedded>
   <expose_uv_set>
		<index>0</index>
		<name>ColorUV</name>
	</expose_uv_set>
   <expose_uv_set>
		<index>0</index>
		<name>BumpUV</name>
	</expose_uv_set>
   <vertex pos='0.0490948 -0.309973 -3.98767' normal='0.0122736 -0.0774924 -0.996917' uv0='0.2875 0.025'/>
	<vertex pos='0 -0.313836 -3.98767' normal='0 -0.0784583 -0.996917' uv0='0.2625 0.025'/>
	<vertex pos='0 0 -4' normal='-1.10098e-009 2.79614e-010 -1' uv0='0.3875 0'/>
....
....
....
In this case into matAll there are uv_set for color and bump named respectively ColorUV and BumpUV. This two sets found their reference into the exposed_uv_set but what's the meaning of the index? Does it explicitely refers to the position of the uv's values into the vertex-tag? for example index = 0 -> first uv coords, index = 1 -> second uv coords...?

And what happens if i have two materials one with bump one with color texture applied on the same object on different parts and with different uv_set? Does anyone have an idea how the XML scene should look like?


Thanks really in advance for your time spent on this discussion.


Regards, Riccardo.

zuegs
Posts: 380
Joined: Tue Jun 27, 2006 5:46 pm
Location: switzerland

Post by zuegs » Sat Nov 18, 2006 3:25 am

I think it work like this: :wink:

Code: Select all

<mesh> 
   <name>sphere</name> 
   <embedded> 
   <expose_uv_set> 
      <index>0</index> 
      <name>ColorUV</name> 
   </expose_uv_set> 
   <expose_uv_set> 
      <index>1</index> 
      <name>BumpUV</name> 
   </expose_uv_set> 
   <vertex pos='0.0490948 -0.309973 -3.98767' normal='0.0122736 -0.0774924 -0.996917' uv0='0.2875 0.025' uv1='-1.2875 -1.025' /> 
   <vertex pos='0 -0.313836 -3.98767' normal='0 -0.0784583 -0.996917' uv0='0.2625 0.025' uv1='-1.2625 -1.025' /> 
   <vertex pos='0 0 -4' normal='-1.10098e-009 2.79614e-010 -1' uv0='0.3875 0' uv1='-1.3875 0' /> 
.... 
.... 
.... 
"uv0" tag for index=0 uv's (ColorUV)
"uv1" tag for index=1 uv's (BumpUV) :wink:

User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

Post by rgigante » Sat Nov 18, 2006 5:12 am

Yes perfectly...it works if u have the whole geometry referenced by a single material containing both Color and Bump map. But if u have a portion of your geometry to which are assigned two different materials (one with bump and one with color texture) u should define different exposed_uv_set in the vertex definition correctly related to the different uv_set present in the two material definition... (i'm having a little idea...)

Code: Select all

<triangle_set>
<material>matColorOnly</material>
<tri>..........</tri>
<tri>..........</tri>
<tri>..........</tri>
</triangle_set>
<triangle_set>
<material>matBumpOnly</material>
<tri>..........</tri>
<tri>..........</tri>
<tri>..........</tri>
</triangle_set>

The solution could be to integrate all the UV values stiched on the geometry (if exist 5 texture proj on the object it possible to generate the five uv coord sets related).
Anyway the discussion is still opened inspite to optimize and reduce the total size of XML scene...

Thanks in advance Zuegs

User avatar
scaron
Posts: 15
Joined: Tue Jun 27, 2006 11:38 am
Location: Venice, CA
Contact:

Post by scaron » Sat Nov 18, 2006 8:34 am

i think you have the right idea, you can continue to send me emails about this subject. i will do my best to help out but i am working on a production right now. late nights, you know
doer of things somewhat technical

zuegs
Posts: 380
Joined: Tue Jun 27, 2006 5:46 pm
Location: switzerland

Post by zuegs » Sat Nov 18, 2006 8:42 am

Yes, i assume you can define as much uv-sets you like. You can define for each material a own uv_set name as "mat1_ColorUV" then when exporting a mesh you have to ennumerate all used UV-sets for all used materials in the mesh with <expose_uv_set> and so on ....... :wink:

Code: Select all

<material> 
  <name>mat1</name> 
  <phong> 
    <diffuse>0.8 0.8 0.8</diffuse> 
    <specular>0.04 0.04 0.04</specular> 
    <exponent>1000</exponent> 
    <albedo_texture> 
      <gain>1</gain> 
      <exponent>1</exponent> 
      <uv_set>mat1_ColorUV</uv_set> 
      <path>..\ref_txt1.jpg</path> 
    </albedo_texture> 
  </phong> 
</material>
<material> 
  <name>mat2</name> 
  <phong> 
    <diffuse>0.8 0.8 0.8</diffuse> 
    <specular>0.04 0.04 0.04</specular> 
    <exponent>10</exponent> 
    <albedo_texture> 
      <gain>1</gain> 
      <exponent>1</exponent> 
      <uv_set>mat2_ColorUV</uv_set> 
      <path>..\ref_txt2.jpg</path> 
    </albedo_texture> 
    <bump_map> 
      <gain>0.01</gain> 
      <exponent>0.1</exponent> 
      <uv_set>mat2_BumpUV</uv_set> 
      <path>..\ref_txt3.jpg</path> 
    </bump_map> 
  </phong> 
</material>

<mesh> 
  <name>sphere</name> 
  <embedded> 
    <expose_uv_set> 
      <index>0</index> 
      <name>mat1_ColorUV</name> 
    </expose_uv_set> 
    <expose_uv_set> 
       <index>1</index> 
       <name>mat2_ColorUV</name> 
    </expose_uv_set>
    <expose_uv_set> 
       <index>2</index> 
       <name>mat2_BumpUV</name> 
    </expose_uv_set>
    <vertex pos='0 0 0' normal='0 0 1' uv0='0 0' uv1='1 1' uv2='0 2'/> 
    <vertex pos='0 1 0' normal='0 0 1' uv0='0 1' uv1='1 0' uv2='0 0' /> 
    <vertex pos='1 1 0' normal='0 0 1' uv0='1 1' uv1='0 0' uv2='2 0' /> 
    <vertex pos='1 0 0' normal='0 0 1' uv0='1 0' uv1='0 1' uv2='2 2' /> 
    <triangle_set>
      <material>mat1</material> 
      <tri>..........</tri> 
      <tri>..........</tri> 
    </triangle_set> 
    <triangle_set>
      <material>mat2</material> 
      <tri>..........</tri> 
      <tri>..........</tri> 
    </triangle_set> 
  </embedded>
</mesh>
I think if you know in advance that a vertex may not make part of a specific material and so will not need to export this UVs :

Code: Select all

<vertex pos='0 0 0' normal='0 0 1' uv2='0 2'/> 

User avatar
u3dreal
Posts: 346
Joined: Sun Jul 02, 2006 10:36 am

Post by u3dreal » Sat Nov 18, 2006 12:22 pm

Yes i can second that .. sorry for the late answer as i have all
this in my exporter since 6 months.

I can only offer that you can pm me for futher upcoming questions..
so i don't miss it.. ;)

cheers

u3dreal ;)

User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

Post by rgigante » Tue Nov 21, 2006 7:27 pm

Thanks guys

Hmmm... other two questions:

-(first) for example the value 2 for <index> in the exposed_uv_set should correspond to the second couple of UV coords in the vertex definition?

-(second) could i've in the vertex definition "uv2" but not "uv1" neither "uv0" (cause i've tried but it doesn't works properly when rendering)?


Last, Nick could u please provide clear info about texturing and geometry creation in the Indigo Scene format?


Thanks everybody in advance.


Best regards, Riccardo.

User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

Post by rgigante » Tue Nov 21, 2006 10:08 pm

For better understand the role of <index> i've done two tests:

The material definition is

Code: Select all

<! DEFAULT MATERIAL SETTINGS >
	<material>
		<name>DummyMat</name>
		<diffuse>
			<colour>0.9 0.9 0.9</colour>
		</diffuse>
	</material>

	<material>
		<name>TexturedMat</name>
		<diffuse>
			<colour>0.9 0.9 0.9</colour>
			<albedo_texture>
            <gain>1</gain>
            <exponent>1</exponent>
				<uv_set>ColorUVs</uv_set>
				<path>ref_txt.jpg</path>
			</albedo_texture>
		</diffuse>
	</material>
In the first image
Image
http://img205.imageshack.us/img205/935/uv0idx0okxf2.jpg
has the following scene description for the plane:

Code: Select all

		<embedded>
			<expose_uv_set>
				<index>0</index>
				<name>ColorUVs</name>
			</expose_uv_set>
			<vertex pos='-4 4 0' normal='0 0 1' uv0='0 1'/>
			<vertex pos='-4 3 0' normal='0 0 1' uv0='0 0.875'/>
...
...
...
The second image
Image
http://img205.imageshack.us/img205/6518 ... 5kodz7.jpg
has the following scene description for the plane:

Code: Select all

	<mesh>
		<name>grid</name>
		<embedded>
			<expose_uv_set>
				<index>5</index>
				<name>ColorUVs</name>
			</expose_uv_set>
			<vertex pos='-4 4 0' normal='0 0 1' uv5='0 1'/>
			<vertex pos='-4 3 0' normal='0 0 1' uv5='0 0.875'/>
...
...
...
Why do u think it happens??? Shouldn't the images look the same?
Why instead of getting a non-textured plane in the second image i get such a strange texture-pattern?

obviously the uv-coords for the plane are identical in the first and in the second...


How should <index> correctly work???


Thanks in advance, Riccardo

User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

Post by rgigante » Fri Nov 24, 2006 11:22 am

Hi guys,

none to share ideas or suggestions? I'm stuck on this question and can't figure how to get out.
Hey u3dreal, any help really appreciated :)

Thanks in advance.
Riccardo

User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

Post by rgigante » Sat Nov 25, 2006 3:29 am

Just a lil update...as confirmed by OnoSendai at the moment Indigo handles no more than three (3) UV sets in each mesh.

This is the reason that led to the wrong appearence in the test i did with uv index = 5.

That's all.. Riccardo

User avatar
OnoSendai
Developer
Posts: 6243
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Post by OnoSendai » Sat Nov 25, 2006 3:37 am

4 uv sets actually... uv0 to uv3.

User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

Post by rgigante » Sat Nov 25, 2006 5:13 am

Are u sure Nick?

with

Code: Select all

	<mesh>
		<name>grid</name>
		<embedded>
			<expose_uv_set>
				<index>3</index>
				<name>ColorUVs</name>
			</expose_uv_set>
			<vertex pos='-4 4 0' normal='0 0 1' uv3='0 1'/>
			<vertex pos='-4 3 0' normal='0 0 1' uv3='0 0.875'/>
i got a non-textured grid... :?

Post Reply
12 posts • Page 1 of 1

Who is online

Users browsing this forum: No registered users and 17 guests