Implorer / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

Point sprite based particle emitters don't work on Android #546

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a ParticleEmitter, set it to use a point mesh, set the material 
parameter "PointSprite" to true and the additionalRenderState "PointSprite" to 
true. Use a texture for the material
2.run it on desktop -> it works as expected
3.run it on android -> nothing is rendered

What is the expected output? What do you see instead?
the same visual output on desktop and on android.

There are some differences between OpenGL 2.0 and OpenGL ES 2.0 regarding point 
sprites : 
from OpenGL ES 2.0 specs :
"OpenGL ES 2.0 supports aliased point sprites only. The POINT SPRITE default 
state is always TRUE.
-----------------------------------------------------
OpenGL 2.0 Common
void PointSize(float size) –
void PointParameterfifg[v](enum pname, T param) –
void Enable/Disable(POINT SMOOTH) –
void Enable/Disable(POINT SPRITE) –
void Enable/Disable(VERTEX PROGRAM POINT SIZE) –
-----------------------------------------------------
1516 Rasterization
3.3.1 Point Sprite Rasterization
Point sprite rasterization produces a fragment for each framebuffer pixel whose 
center lies inside a square
centered at the points (xw, yw), with side length equal to the current point 
sprite. The rasterization rules are
the same as that defined in the OpenGL 2.0 specification with the following 
differences:

 The point sprite coordinate origin is UPPER LEFT and cannot be changed.

 The point size is computed by the vertex shader, so the fixed function to 
multiply the point size with
a distance attenuation factor and clamping it to a specified point size range 
is no longer supported.

 The point size must be output by a vertex shader when rendering a point 
primitive. If the point size is
not output by the vertex shader, the value of point size is undefined

 Multisample point fade is not supported.

 The COORD REPLACE feature where s texture coordinate for a point sprite goes 
from 0 to 1 across the
point horizontally left-to-right and t texture coordinate goes from 0 to 1 
vertically top-to-bottom is
replaced by the gl PointCoord variable defined in the OpenGL ES shading 
language specification.
gl PointCoord becomes available in the fragment shader when rasterizing points 
and is not related
to any texture unit.

 Point sprites are used for rendering particle effects efficiently by drawing them as a point instead of
a quad. Traditional points (aliased and anti-aliased) have seen very limited 
use and are therefore no
longer supported. "

From what I gathered from OPENGL ES 2.0 specs, the code in applyRenderState for 
point sprite is no longer necessary in the oglesShaderRenderer.
I managed to have something render by removing the texture on the material.
Doing this i can see the particles, but each one is rendered as a single pixel.
It seems the gl_PointSize is not taken into account in the vertex shader.
I'm gonna investigate further.

Original issue reported on code.google.com by remy.bou...@gmail.com on 15 Oct 2012 at 3:07

GoogleCodeExporter commented 9 years ago
I looked at several tutorials and found that they are using:
glEnable(GL_TEXTURE_2D);
Prior to using point sprites, whereas we don't. Perhaps that is the issue.

Original comment by ShadowIs...@gmail.com on 15 Oct 2012 at 3:30

GoogleCodeExporter commented 9 years ago
It seems the issue is due to hardware dependent limits on the acceptable sizes 
of point sprites. Some platforms report that they only support point sprites of 
size 1x1 for example - in that case point sprites cannot be used normally. 

jME3 particles should be able to detect if point sprites are supported properly 
and if so, use them, otherwise they should fallback to triangle-based particles.

Original comment by ShadowIs...@gmail.com on 19 Nov 2012 at 3:53