Alpha texture: separate UV set?

For a RGBA textured GeometryIndexedArray’ed Shape3D I currently use one list of
TexCoord2f() objects to specify the (imported) UV coordinates.
Would it be possible to have two UV maps: one for the RGB texture and one for the Alpha texture?

Maybe this question is related to multi-texturing? I’ve read the Xith3d tutoral for multitexturing but it’s a bit short. I’ve not implemented multitexturing yet, however the same question arises: is it possible to have an own UV map (TexCoord2f() list) for each texture?

Many thanks.

[quote]Would it be possible to have two UV maps: one for the RGB texture and one for the Alpha texture?
[/quote]
For different textures - YES. For same texture - NO.

[quote]Maybe this question is related to multi-texturing?
[/quote]
Yes

[quote]is it possible to have an own UV map (TexCoord2f() list) for each texture?
[/quote]
Yes

Yuri

One solution is to multitexture using a grayshade texture to represent your alpha and an rgb texture. Use the MODULATE texture attribute to combine the two textures. Think of MODULATE as multiplying one texture texel by the other. Using a grayshade texture insures that the R and the G and the B are all multiplied by the same value.

I have a tutorial with source and a webstart example over at xith.org ;D. In the example I combine a black & white cross with a stained-glass texture leaving a pattern. I modify the black/white texture coords from to go from 50% to 600% (which tiles 6x6)

webstart example:

http://xith.org/jws/jws-org.xith3d.gsg.TextureFun1.jnlp

tutorial:

http://xith.org/tutes/GettingStarted/html/more_fun_with_textures.html

Thanks Yuri, thanks Hawkind.

[quote]One solution is to multitexture using a grayshade texture to represent your alpha and an rgb texture. Use the MODULATE texture attribute to combine the two textures. Think of MODULATE as multiplying one texture texel by the other. Using a grayshade texture insures that the R and the G and the B are all multiplied by the same value.
[/quote]
Fits well to: http://java.sun.com/products/java-media/3D/forDevelopers/J3D_1_3_API/j3dapi/javax/media/j3d/TextureAttributes.html#TextureAttributes()

By studying the Xith tutorial about Multitexturing again I learned now how to do different UV-sets for each multi texture. That’s very nice. So Lightmaps could be done this way I suppose. Then I’ll lightmap my scenery. :slight_smile:

Now to something even more complicated. For example three textures on a Shape3d: One gras texture, one sand texture and the third one acting as a kind of alpha saying how to blend the two picture textures: an alpha value of 0 means use just the gras, alpha value 255 means use just the sand, and anything between is used to blend the gras and sand textures.
However for such you probably have to do multi-pass rendering (with reading the two-texture blended texture from OpenGL back to a memory texture and using it as base for a second pass, and so on?

If your hardware supports more that 2 testure units, then you can render everything in one pass.

Yuri

[quote]If your hardware supports more that 2 testure units, then you can render everything in one pass.Yuri
[/quote]
I see. Nice!
If you now add three textures to a Xith3d multi texture surface/shap3d does OpenGL do it via software? Like if you use more than … 8 (?) light sources for example?

This is my next tutorial…in a week or so…

One approach is to use what david yazel calls a splat shape. Place two shapes in an ordered group, this group enforces rendering order.

On the first shape multitexture rocks and grass for example. On the second shape use a transparent texture containing some puddles. By this I mean alpha=0 except where there is water. If the second shape is offset very slightly in the Y direction (raising the second shape slightly above the first one) the ‘puddles’ will appear to be rendereded on top of the grass and rocks giving the appearence of 3 textures multitextured on each other.

If you plan to add a tutorial, I think (static) terrain is really a good topic. ;D

[quote]If you now add three textures to a Xith3d multi texture surface/shap3d does OpenGL do it via software?
[/quote]
Never tried that. Actually, this depends on driver, I think.

Yuri

[quote]This is my next tutorial…in a week or so…

One approach is to use what david yazel calls a splat shape. Place two shapes in an ordered group, this group enforces rendering order.
(…) If the second shape is offset very slightly in the Y direction (raising the second shape slightly above the first one) the ‘puddles’ will appear to be rendereded on top of the grass and rocks giving the appearence of 3 textures multitextured on each other.
[/quote]
That’s a good idea. However doesn’t it produce Z-Puffer “flickering” if the Y-distance (or Z, depends on the direction you want your splat shapes to direct) is too small when the objects are away…?
Also it means doubling the triangles for the two shape faking one shape? So it’s probably the hard way. :slight_smile:

Multitexturing is very nice - and can be confusing because it’s difficult to judge what output result the various modi will produce. Usually I get some kind of Predator-view-result. I should make my application to let alter these settings at runtime. :slight_smile:

The TextureMode COMBINE looks to be the one I need mostly for multi-texturing with two textures.

The following in the Java3d documentation does apply to Xith3d, too, I think. However I don’t understand the COMBINE_INTERPOLATE TextureMode. The docu at http://java.sun.com/products/java-media/3D/forDevelopers/J3D_1_3_API/j3dapi/javax/media/j3d/TextureAttributes.html reads:[quote]
"Combine Mode - defines the combine operation when texture mode specifies COMBINE. The combine mode includes the following:
(…)
COMBINE_INTERPOLATE
C’ = C0 C2 + C1 (1 - C2)
[/quote]
Does this mean you use 3 texture units with 3 textures (C0 … C2) ? But I thought most graphic cards would use “just” two texture units…
Also to which TextureMode’s do you set the other two texture units then, if, for example, you would like to have something like my earlier mentioned gras-rock-“water” trio?

Yes, you can use only 2 textures at given stage - but you can Cn to be texture color, texture alpha, object color, object alpha, constant color, constant alpha, with texture being current one or result of previous stage. This means 8 possibilities for each component.

In most cases you will set C2 to alpha of one of the components which will be a control parameter of interpolation between colors C0 and C1. Colors C0/C1 can be texture/object color/constant color depending on what you need for particular stage.

Think about it as a DECAL on steroids.

Just hawk flapping his own wings… ;D

Previously I posted to this thread describing how I would use multiple layers of textures to splat additional detail to a terrain texture (A SplatShape). A Decal node is used to organize the the rendering order.

An example of this has been added to the xith tutorials at


http://www.xith.org/tutes/GettingStarted/html/more_fun_with_textures.html#SECTION00073000000000000000

[OT]

By the way, well done hawk on your excellent set of advanced texturing tutes - they are quite impressive.

Will.