[SOLVED] ~NEWBIE~ Multi-UV channel

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
gattu_marrudu
Gnoblar
Posts: 16
Joined: Tue Jul 19, 2005 7:27 am
Location: Sardinia, Italy

[SOLVED] ~NEWBIE~ Multi-UV channel

Post by gattu_marrudu »

I'm working on an architectural model, which I have modeled and completely prelighted in Maya.

As some geometries are a bit complex, I had to assign at least two UV sets to some objects - one to the diffuse texture, another one to the lightmap, which I connected to the ambient channel of each shader.

I tried to export the model to OGRE, but the OGRE exporter ofr Maya exports only one texture map, the diffuse one.

I looked around in the forums and I found that you have to manually specify more texture_unit statements in a shader in order to get multitextured materials:

Code: Select all

material generator/grass
{
technique
{
pass
{
ambient 0.588 0.588 0.588 1
diffuse 0.588 0.588 0.588 1
specular 0.9 0.9 0.9 1 0

texture_unit
{
texture grass_1.tga
filtering point point point
scale 0.1 0.1
}

texture_unit
{
texture default_lightmap.png
filtering point point point
}

}
}
}
BUT: how do I specify which texture connects to ambient and which to diffuse, and most important, which UV set they use?

Your help would be greatly appreciated.
gm
Last edited by gattu_marrudu on Tue Aug 09, 2005 11:57 am, edited 1 time in total.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

Read the manual. You use the tex_coord_set attribute for that.
http://www.ogre3d.org/docs/manual/manual_19.html#SEC61

Edit: colour_op_ex and alpha_op_ex are the commands that determine how the texture unit contributes to the materials overall colour/alpha
team-pantheon programmer
creators of Rastullahs Lockenpracht
gattu_marrudu
Gnoblar
Posts: 16
Joined: Tue Jul 19, 2005 7:27 am
Location: Sardinia, Italy

Post by gattu_marrudu »

You mean that diffuse, ambient, specular and other channels have only sense with flat colors, and I should use compositing techniques (adding, subtracting etc.) with textures?
Anyway, I tried setting the diffuse value to 0 0 0 0, then added the "diffuse" texture with colour_op add and the lightmap with colour_op add as well. The surface looks all white. Notice that there is no light in the scene, as the scene is entirely prelighted. I'm using a lambert material in Maya, but it doesn't seem to make difference in OGRE.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

I don't know what Maya does or can do, but it doesn'T matter for Ogre, as it is only interested in what you define in the material script. So if you want to discuss it, you need to provide the current material file (the one you provided probably isn't current anymore) and descibe what you want to get, and what you have right now in Ogre (with all white you have some serious error in it).

I have no idea what this lambert material is/does. In what way does your lightmap change the texture colour (additive/substrative/modulative)?
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
x 15
Contact:

Post by metaldev »

@gattu

dont know if this will help but generally speaking:

you want to draw your lightmap first (i usually use UV set 1)

then modulate your detail map over it (i usually use UV set 0)
(the detail map is usually a grayscale indexed image)

then modulate your diffuse (vertex coloring) over that.



the equivalent inside maya is doing this:
  • -create a layered texture (not to be confused with layered shader)

    -connect the output of the layered texture into the input color of your material

    -set your first pass in the layered shader to be the detail map and set it to 'multiply' (another word for modulate)

    -the second pass should be the lightmap... set it to 'over'

    -make sure your object has 2 UV sets

    -then do window > relationship editors > UV linking > texture-centric

    -select your object

    -connect the appropriate texture pass to the correct UV
gattu_marrudu
Gnoblar
Posts: 16
Joined: Tue Jul 19, 2005 7:27 am
Location: Sardinia, Italy

Post by gattu_marrudu »

Thanks for the clear example! I hadn't got a "compositing" concept of the maps in OGRE, just knew about the Maya way.
User avatar
maxxoros
Greenskin
Posts: 130
Joined: Tue Feb 22, 2005 7:18 pm

Post by maxxoros »

How you guys create lightmap in maya :o ...I wonder...
Could anyone tell me...I just only render to texture with maya :(..nbt create a texture with black and white for lightmap data
gattu_marrudu
Gnoblar
Posts: 16
Joined: Tue Jul 19, 2005 7:27 am
Location: Sardinia, Italy

Post by gattu_marrudu »

Baking in Maya needs some work, but it can be very efficiently tweaked.

First, if you have Maya 5.0 or later (or if you installed mr separately) you can take advantage of mental ray lightmaps, which include all mr's light effects (global illumination, raytraced soft shadows etc.). BTW, I just noticed that it doesn't bake bump maps!

Before baking lights and shadows you have to prepare your objects. All the object's UV points MUST lay within the 0-1 map space (the upper right quarter of the grid in the UV Texture Editor), and they SHALL NOT overlap. This can be "easily" achieved with Maya's mapping tools, like Automatic Mapping, Layout UVs and Normalize UVs.

If you have a textured material, it could be necessary to create a separate UV set only for baking, so the diffuse/opacity/etc. textures have their own mapping, and lightmap has its own one. You should get a bit familiar with the UV texture Editor if you want to make good lightmaps without using huge resolutions.

Then you should assign your objects to a baking set, which can allow you to apply different settings on different groups of objects. Note that mr bakes the lightmaps using the active UV set, unless you specify the UV set name in the bake set options.

Then you have to go in the Rendering menu section, and select Lighting/Shading->Batch Bake (mental ray) []. You can choose to create a lightmap which is the result of a full rendering, or only the lighting, or only occlusion, and so on. You can then composite the different texture layers from the OGRE material script, as we were discussing above.

Hope it helped. Anyway you can find dtailed info in the Maya docs, searching for "baking lights" or such.
Post Reply