Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Alpha texture: separate UV set?  (Read 2247 times)
0 Members and 1 Guest are viewing this topic.
Offline Preston

Senior Member


Medals: 4



« Posted 2003-12-05 06:53:41 »

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.
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #1 - Posted 2003-12-05 12:00:19 »

Quote
Would it be possible to have two UV maps: one for the RGB texture and one for the Alpha texture?


For different textures - YES. For same texture - NO.

Quote
Maybe this question is related to multi-texturing?


Yes

Quote
is it possible to have an own UV map (TexCoord2f() list) for each texture?


Yes

Yuri

Yuri Vl. Gushchin
JProof Group
Offline hawkwind

Junior Member




Java games rock!


« Reply #2 - Posted 2003-12-05 22:18:15 »

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 Grin.  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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Preston

Senior Member


Medals: 4



« Reply #3 - Posted 2003-12-06 07:35:46 »

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.

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. :-)

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?
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #4 - Posted 2003-12-06 11:56:45 »

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

Yuri

Yuri Vl. Gushchin
JProof Group
Offline Preston

Senior Member


Medals: 4



« Reply #5 - Posted 2003-12-06 12:18:36 »

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

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?
Offline hawkwind

Junior Member




Java games rock!


« Reply #6 - Posted 2003-12-06 14:00:19 »

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.

Offline Jens

Senior Member




Java for games!


« Reply #7 - Posted 2003-12-06 14:19:42 »

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

Xith3D Getting Started Guide (PDF,HTML,Source)
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #8 - Posted 2003-12-06 15:39:28 »

Quote
If you now add three textures to a Xith3d multi texture surface/shap3d does OpenGL do it via software?


Never tried that. Actually, this depends on driver, I think.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline Preston

Senior Member


Medals: 4



« Reply #9 - Posted 2003-12-09 06:40:42 »

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.

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. :-)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Preston

Senior Member


Medals: 4



« Reply #10 - Posted 2003-12-09 06:41:17 »

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. :-)

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)

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?
Offline abies

Senior Member





« Reply #11 - Posted 2003-12-09 07:04:02 »

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...


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.

Artur Biesiadowski
Offline hawkwind

Junior Member




Java games rock!


« Reply #12 - Posted 2004-02-02 22:51:40 »

Just hawk flapping his own wings.... Grin

  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://
http://www.xith.org/tutes/GettingStarted/html/more_fun_with_textures.html#SECTION00073000000000000000




Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #13 - Posted 2004-02-03 22:52:37 »

[OT]

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

Will.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (24 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!