How to Graphics FX with OpenGL ?

Started by broumbroum, February 18, 2009, 17:14:32

Previous topic - Next topic

broumbroum

HI! I want to make custom graphics effects not using textures, like flames, water-style projections, motion-blur or lens-flare etc. (something like seen in M.u.g.e.n plz)
anywhere I can find short examples ?

Ciardhubh

You want real-time rendered effects? Sounds like GLSL shaders are an option. Unfortunately there are no short examples, as these effects can be quite complex if you haven't dealt with shaders before; especially since the documentation on most of them is ... horrible.

This site has a few interesting shaders including fire, glass (probably usable as water too) and environment mapping:
http://3dshaders.com/home/index.php?option=com_weblinks&catid=14&Itemid=34

Check the executables. They demonstrate how the shaders look like. Source code is included but again, it's not easy to get into.

bobjob

mugen just uses simple particle effects, did you want them 2D or 3D.
if 2D im sure slick should have some good examples

here is some example code that creates particles in lwjgl:
http://bloody-blades.de/?page_id=3
goto lesson: 19 particle engine

broumbroum

Is that true that gl_Triangle_strip is faster than gl_polygon to draw unregular shapes like custom polygons ? For example if I want a custom "flame" shape around my player using gl_triangle_strip would be faster ?
I know how to compute Béziers curves, as of the Java VectorGlyph javadoc gives a clue about them, so that I'd draw a custom blended shape around my player to simulate "aura" or "power" or "dragon balls". Where I'm not sure about using particles.
See the original bitmap (2.png) and instead I try a direct rendering of a shape like that (explosion_blend,png).
Again, I see that GLSL seems to be the better rendering ever but I don't know enough about how to use them, unfortunately.
Also, lens flares short samples I found here are interesting, since it's not as hard as parametric particle engine : http://www.opengl.org/resources/features/KilgardTechniques/LensFlare/ .
Thank you for the particle engine demo !

Kai

QuoteIs that true that gl_Triangle_strip is faster than gl_polygon [...]
Yes, it is.
In fact, the polygon primitive type can be considered harmful :-), and is marked deprecated in the OpenGL 3.0 specification.
The main reason for that is, because the graphics card can only render (clip and fill) triangles, points and lines. The polygon primitive is a way that the OpenGL API gives us developers to specify an arbitrary polygon that, when sent to the GL driver, has to be triangulated before sending it to the graphics card. For a polygon with many vertices there are pretty many possibilities to triangulate it, which is not a trivial operation. Consider even a polygon with 4 vertices, for which there are always exactly 2 possibilities to triangulate it (and most of the times the wrong triangulation (not wanted by the developer) is being selected :-) ).

So, if you want ultimate frame rates, you should use the triangle (or triangle strip) primitive right from the start.