PDA

View Full Version : Dynamic 2D Shadows



Andru
04-12-2010, 03:41 PM
Here the third party module for ZenGL, that provide $subj :)

developed by: Vadim Burenkov aka Vad
Graphic API: OpenGL
Cross-platform: Yes
Required version of ZenGL: 0.2 RC6

Preview version can be downloaded here (http://zengl.googlecode.com/files/LightEngine2D.7z). Inside you can find LightEngine2D.pas, examples for FreePascal, Lazarus, Delphi 7 and Delphi 2010. Also there is an executable for Windows. For now required version of ZenGL can be found only in svn. Version with render based on Direct3D and direct lights added to TODO list :)

http://zengl.org/demos/lightengine2d_01.jpg
(so small FPS because of Radeon HD 4200...)

WILL
05-12-2010, 09:36 AM
Wow that's really cool. :)

User137
05-12-2010, 09:58 AM
Just 1 thing, are the circles and squares meant to be colored by the light too? As walls it looks a bit weird. But nice start.

Vad
05-12-2010, 05:41 PM
Wow that's really cool.Thanks:).

Just 1 thing, are the circles and squares meant to be colored by the light too?Yes. Its because of color blending. Objects in demo absolutely white, and they get light color.
For example color blending of a box and purpure light:
http://i030.radikal.ru/1012/26/8c51d74b03c3.jpg (http://www.radikal.ru)

virtual
05-12-2010, 05:46 PM
interesting , thats for sure a great addition to ZenGl

chronozphere
05-12-2010, 06:23 PM
This is really nice. But I have to agree with user137. Sometimes the shadows are rendered at the wrong place.

You say that this is a ZenGL extension. Does ZenGL have some kind of plugin architecture or is this just an addition to the engine codebase? :)

Andru
05-12-2010, 07:34 PM
Sometimes the shadows are rendered at the wrong place.
"Wrong place" because all walls placed in different layers and this is create quite a mess with shadows :)


Does ZenGL have some kind of plugin architecture or is this just an addition to the engine codebase?
this is something like "just an addition to the engine codebase" in separate unit :) For writing plugins, I think, there is no need in some special architecture. You can register new graphic and sound format through zgl_Reg, or get OpenGL context/Direct3D device through zgl_Get, and so on. Maybe later I will add some other specific functions.

User137
05-12-2010, 08:02 PM
Yes. Its because of color blending. Objects in demo absolutely white, and they get light color.

I can now understand what you mean. The lights themselves are the only way to make any objects come visible. It's pretty cool idea and looks to be working well.

Vad
11-12-2010, 05:57 PM
Last updates of LightEngine2D.

You can download source code and demos here (http://www.vad-code.narod.ru).

New in 1.1 version:
- Added 3 demos.
- You can create any shapes using le_GetNewGroup:
http://www.vad-code.narod.ru/scr/scr1.jpg
(it means that you can combine convex polygones and circles to create shape that you need:P)
- Chipmunk physics support (demo3).
- English comments.
- uObjectsManager.pas for saving objects in files (demo4).

Andru
16-02-2011, 08:58 PM
LightEngine2D was updated and placed on extras-page (http://zengl.org/extra.html) :)

New in version 1.30:
-Soft shadows added.
-Sector lights looks better now.
-Render optimizations:
Demo2 with 450 objects (150 circles and 300 boxes) on Radeon 4890HD
v1.20 - 965fps (render time - 0.91; update time - 0.48 )
v1.30 - 1148fps (render time - 0.72; update time - 0.49)
v1.30 (soft shadows) - 834fps (render time - 0.97; update time - 0.81)

What was new in version v1.20:
-Updated to ZenGL revision 1045 (camera fixed).
-Dynamic compilation fixed.
-Render and processing optimization:
Demo2 with 450 objects (150 circles and 300 boxes) on Radeon 4890HD
v1.10 - 425fps (render time - 2.17; update time - 0.70)
v1.15 - 965fps (render time - 0.91; update time - 0.48 )
-Direct lights added.
-Some changes in syntax of API.

http://zengl.org/extra/lightengine2d/screen01s.png (http://zengl.org/extra/lightengine2d/screen01.png)

arthurprs
16-02-2011, 11:37 PM
Thats the definition of awesome!

wagenheimer
17-02-2011, 12:39 AM
Very Awsome!

This may works with Direct3D and older video cards also? What is the requeriment?

Andru
17-02-2011, 04:25 AM
This may works with Direct3D and older video cards also? What is the requeriment?
For now there is only OpenGL render, but when I will get more free time, I will start work on Direct3D version :) But I don't know how it would work on old Intel's(or very low-end videocards), because every light source need it own render target, and this is little bit heavy.

Update: using internal ZenGL convertation from OpenGL to Direct3D(but it still little bit buggy with depth buffer...) I had have got only ~83 fps on Intel 965 Express in demo01(with 5 light sources), so I think this is definitely not for old Intel i865 and so on, where heavy fillrate will show slideshow :)

gintasdx
17-02-2011, 03:06 PM
Great update!
The scrolling screen and chipmunk physics code will come handy to me from those demos :)
With Intel GMA HD
GL_RENDERER: Mesa DRI Intel(R) Ironlake Mobile GEM 20100330 DEVELOPMENT x86/MMX/SSE2
GL_VERSION: 2.1 Mesa 7.9-devel
on Ubuntu 10.10 I get from 40 on a first demos and 60 on two last ones.

Andru
17-02-2011, 04:49 PM
With Intel GMA HD
Wow, it works on Linux! :) But under Windows with Intel 965 Express I have no luck to work it with FBO render targets(only black screen)... seems something wrong with this technique in Intel OpenGL drivers under Windows(remembering the first version of LightEngine 2D, I found ridiculous bug with enabling/disabling GL_DEPTH_TEST).

Andru
18-02-2011, 10:58 AM
In svn version of ZenGL I have improved zgl_direct3d_all.pas and now these shadows works correctly through Direct3D9 render :) So, in near future I will try to make LightEngine 2D with Direct3D9 rendering, which will work with ZenGL.dll, i.e. not only statically.

dazappa
18-02-2011, 06:18 PM
Very nice! For me the difference between soft and hard shadows was a mere 7 FPS. On demo 3, objects near the top seem to go invisible. Seems like it may be a result of you destroying physics objects but not shadows.