Alpha blending of point sprites ( making clouds )

Hello,

I’m trying to use sprites library from tralala
http://hub.jmonkeyengine.org/forum/topic/spritelibrary-efficient-render-of-sprites/
to make clouds for aircraft simulator

it uses a Mesh with point sprites to render sprites really fast. I works perfectly for tralala NPCs which are opaque. But when I’m trying to use it for transparent cloud “puffs” ( static particle system basically ) I get these problems - alpha blending does not work properly:

https://plus.google.com/u/0/photos/yourphotos?pid=5966321813642494210&oid=100958146796876347936

it is not really transparent

I was trying to play with these options withou sucess
[java]
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
mat.getAdditionalRenderState().setBlendMode(BlendMode.Additive);
mat.getAdditionalRenderState().setAlphaTest(false);
mat.getAdditionalRenderState().setAlphaFallOff(0.0000001f);
[/java]

the only think which helps is
[java]
mat.getAdditionalRenderState().setDepthTest( false );
[/java]
after disabling depth test I got quite nice clouds, the only problem is, that they are not occluding any other geometry properly (the red piramid on picture is for testing). If the geometry is rendered before cloud it is ocludded, if it is rendered after it is not occluded.

NOTE: I hope that you can view this images form picasa ( the new picasa album interface seems to be quite useless for sharing images on disscussion forum )

sorry, I put there wrong url

this is url of scrrenshot how it looks with depthTest ( normally, before switched it off)

mat.getAdditionalRenderState().setAlphaTest(false);

Set that to true, not false.

Thanks pspeed, but it is not working fine neither with

mat.getAdditionalRenderState().setAlphaTest(false);

[java] spriteGeometry = new Geometry(“SpriteMesh”, mesh);
Material mat = new Material(assetManager, “3d/shaders/Particle.j3md”);
mat.setTexture(“Texture”, texture);
spriteGeometry.setMaterial(mat);
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setAlphaFallOff(0.0000001f);
rootNode.attachChild(spriteGeometry);
[/java]

there are still some sharp borders of the sprites rather than nice smooth smoke … I wonder how particle systems in “Effects” are rendered, but they are probably independent meshes rather than one big mesh with point sprites, am I right ?

with .setAlphaTest(true); and .setDepthTest( true ); it look like this (if dropbox link works):

OK,
I tried modify TestPointSprite from examples render this smoke puffs, and it is working fine
so probably i is just something specific for tralalas sprite library.

OK, so now I would need to use jMonkey particle system… is it possible to put the particles to specific place one by one, instead of using emiter?

===================================

looks like it would be best make a derivate of import com.jme3.effect.ParticleEmitter; and a make a static cloud from that ( ? )

@asija said: OK, I tried modify TestPointSprite from examples render this smoke puffs, and it is working fine so probably i is just something specific for tralalas sprite library.

OK, so now I would need to use jMonkey particle system… is it possible to put the particles to specific place one by one, instead of using emiter?

The smoke puffs are rendered with AlphaAdd blend mode so it does not matter which order they are drawn.

Welcome to the world of transparency. It’s a teasing mistress.

no, I already changed it to AlphaBlend and put there test object… everything looks fine ( depthTest, blending … )

only problem is, that I need more control to place individual particles/sprites/puffs on specific place, but I think I can do it by copying and modification of ParticleEmitter source code.

… thanks for help

Note: many cards will limit the on-screen size of point sprites to as small as 64 pixels. If you expect to have sprites larger than 64 pixels on screen then you should use a mesh of quads instead… with some vertex shader billboarding if you need it.

Thank, I didn’t know that.
Does render speed depend much on size of sprites? first I used 512x512 than I downsampled it to 128x128 and I think it is faster. Would it be even faster if I downsample ti even more? … I should probably experiment what tradeoff between resolution of individual sprite and number of sprites gives mos realistic clouds.

Ultimativelly I would like clouds like this

I’m also thinking it may by possible to do some fake shading of these clouds ( for example lower part of cloud would be darker then upper part ). I think it would be possible If I make 2 meshes one with 2 different tones (colors) of the smoke puffs.
like this:
http://img98.rajce.idnes.cz/d9803/3/3089/3089927_0cc867af1fbe2d8deecb0dd7efb69672/images/Cervanky.jpg

but maybe Ray-Marching fragmetShader like this

would be better solution, but I don’t know if the speed would be feasible on fullscreen
I also don’t know how to deal with airplane (or other objects) inside the cloud If I would use fragmentShader to render the cloud