In this case you can use OrderedGroup to do the sorting. Render the terrain before everyting else. You can also use OrderedGroup to render the terrain layers in a particular order. The first terrain layer (rock maybe?) must enable depth write and process all pixels even the transparent ones. The idee is to fill the depth buffer on the first layer. The next layers must be rendered with the exact same vertices as the first layer(very important), but only process pixels with equal depth. Offsetting the layers like you described is not the way to go.
Do you really need to do this by putting one poly omtop of another? Cant you just multi-texture a single poly.
[quote]Do you really need to do this by putting one poly omtop of another? Cant you just multi-texture a single poly.
[/quote]
After a little research and experimentation, it seems that multi-texturing averages out the texel values (which simply resulted in ~97% transparent tiles,) whereas what I’m looking for is proper alpha-compositing. If you know how to do this, I’d be most indebted.
[quote]In this case you can use OrderedGroup to do the sorting.
[/quote]
Why so I can. Had I but known.
[quote]Render the terrain before everyting else. You can also use OrderedGroup to render the terrain layers in a particular order. The first terrain layer (rock maybe?) must enable depth write and process all pixels even the transparent ones. The idee is to fill the depth buffer on the first layer. The next layers must be rendered with the exact same vertices as the first layer(very important), but only process pixels with equal depth. Offsetting the layers like you described is not the way to go.
[/quote]
I think that can be arranged. One question. “But only process pixels with equal depth.” As far as I can gather the RenderAttributes works on the basic of alpha values, not a z-buffer. Where would I find the method for this?
Meanwhile, I’ll tinker around and see what results I get.
Ah, it’s functioning perfectly now. BTW, there seems to be a specific class for this purpose- DecalGroup. Many thanks.
Caveat: I haven’t done anything with multi-texturing myself.
Belief: I believe the OP used for multi-texturing is actually settable and that all the standard OGL OPs are supported…
The MultiTexture Combine mode for blending 2 textures should be useful here I’d think - may be that’s what Jeff has been suggesting. You might want to look at TextureAttributes.COMBINE and specifically TextureAttributes.COMBINE_INTERPOLATE modes or may be some variants of it.
As a simple case, if you’ve 2 opaque textures and want to blend them in using a uniform blending factor then you could use the combine mode and set a TextureBlendColor of ( 0, 0, 0, blendFactor ).
This is a snapshot (from Java 3D) showing 2 textures - colormap + advection - with a blend factor of 0.7:
http://img236.imageshack.us/img236/9985/blendfacp75lc.th.gif
And this with a blend factor of 0.92:
http://img236.imageshack.us/img236/4568/blendfacp928ut.th.gif
It runs at about 12 FPS on a 6600GT with a 2048^2 texture + continuous offscreen rendering + noise texture cycling.
[quote]The MultiTexture Combine mode for blending 2 textures should be useful here I’d think - may be that’s what Jeff has been suggesting. You might want to look at TextureAttributes.COMBINE and specifically TextureAttributes.COMBINE_INTERPOLATE modes or may be some variants of it.
[/quote]
COMBINE_PREVIOUS_TEXTURE_UNIT_STATE and COMBINE_ONE_MINUS_SRC_ALPHA seem to be the most promising, but I haven’t tested that out yet, and there seem to be quite a few combinations of plausible options. I wish there were more thorough documentation on this point. I should probably look over the OpenGL api.
One other problem- I never seemed to be able to add more than 4 layers of texture to a single Appearance object, it always spat out an ArrayIndexOutOfBoundsException if I introduced another TextureUnitState beyond that. Is there some way I can increase this limit, or is it enforced by the hardware?
The number of texture unit states is based on your video card. The number can be found by querying the textureUnitStateMax property on the Canvas3D.
Mike
[quote]The number of texture unit states is based on your video card. The number can be found by querying the textureUnitStateMax property on the Canvas3D.
[/quote]
I see. No, I’ll have to go with the DecalGroup approach then, doing the fringe overlays correctly alone could require up to 9 texture layers, though that would be a fairly pathological case. Building splats, SFX and footrpints, etc, on top of that could require more. I’ll just fake it by introducing a few extra polys at runtime as neccesary. Thanks anyway.