2D Dynamic Shadows

BlitzMax Forums/BlitzMax Programming/2D Dynamic Shadows

René(Posted 2005) [#1]
I wrote a module to create fully dynamic hard edged or soft shadows. You can create any convex geometry you want, since you are drawing the shadow casting vectors like in a vector painting software.

Thanks to Orangy Tang for his paper and Indiepath for his DirectX version of DrawTexturedPoly() and some tips on the forum code (still haven't found a manual :-)

Downloads and bigger screenshots are here:
http://www.pyropixel.de/bmax_shadows.html





These demos includes some basic editor functions to play around with.

Tip: always build the shadow vectors in anti-clockwise direction.

Have fun.


TartanTangerine (was Indiepath)(Posted 2005) [#2]
Most impressive. Is that my TExtured Poly command you use there?


René(Posted 2005) [#3]
Why aren't the forum manuals in manual section...I always forget how the bbcodes work...:-O


TartanTangerine (was Indiepath)(Posted 2005) [#4]
Just kill the [img] tags and it will show


tonyg(Posted 2005) [#5]
yep, where do I sign?
Is it DX and/or GL?


René(Posted 2005) [#6]
@Indiepath
Yes it's your TexturedPoly command.

@tonyg
It's both. You would need Indiepath's TexturedPoly command and my GL version of TexturedPoly command.

See this post for TexturedPoly:
http://www.blitzmax.com/Community/posts.php?topic=51059


tonyg(Posted 2005) [#7]
That's good and, the obvious question, when/where can I get it?


TartanTangerine (was Indiepath)(Posted 2005) [#8]
YEah where's the code man. I wanna play.


René(Posted 2005) [#9]
Um. I think I have to prepare a little manual and an example code for public use. I will come back later...


René(Posted 2005) [#10]
Ok, I updated my site (link see first post).
You will find a first release download there.

I hope it will work. Please let me know.


TartanTangerine (was Indiepath)(Posted 2005) [#11]
Ah you compiled it all, how can we learn from a compiled module.. 'cmon show us the real deal.


tonyg(Posted 2005) [#12]
Not sure what I'm doing wrong but it can't find pyropixel.vector2d.


René(Posted 2005) [#13]
Ah, so it does not work. I thought, when I send you the compiled ones, the dependencies to other modules would be avoided.

I'm heavily using vector functions of my own vector module. I believe nearly everyone has got a different vector module but all vector modules are of the same name. This is very anoying. Or is there a trick how to deal with different mods that use the same type declarations?

Anyway, updated to release v0.2. on my site (see first post for link). Full source code of shadow module and my vector module.

The source code is of course commented very poor :-)


tonyg(Posted 2005) [#14]
Thanks for that Rene.
I can't compile the modules. It's possible the framework/Imports are not correct although I used FrameWork Assistant.
It can't find DrawTexturedPoly (I *have* added the drawtexturedpoly stuff)


René(Posted 2005) [#15]
Hm, I remember the first time I tried to add Indiepath's DrawTexturedPoly hack, the Blitz IDE recognised DrawTexturedPoly() as a command (the command gets yellow in the code) but when I tried to compile it says something like "Identifier DrawTexturedPoly not found" or something else.

Do you have the same problem?


René(Posted 2005) [#16]
I tried to reproduce the problem. I found out, when I add the DrawTexturedPoly() function in the max2d.bmx file to the very bottom, I cannot compile.

But when I paste the function somewhat higher in the code for example after the DrawPoly() function, I can compile. Weird!


TartanTangerine (was Indiepath)(Posted 2005) [#17]
Perhaps I should build the textured poly function outside of the max2d.bmx file. I know how to do that know :D


René(Posted 2005) [#18]
Yes, maybe...I'm afraid of the next modsync update...


tonyg(Posted 2005) [#19]
Yep, moving the drawtexturedpoly in max2d.bmx means I can build modules.
For some reason demo3 can't find TLight while Demo4 doesn't have a problem.
<edit> Forget that, re-extracted the demo code, re-ran, got an error that debugmode not found, rem'ed the debug statement and it ran.
I get the feeling for Bmax modules to be compatible they need to have some sort of structure where they don't use the same function/method names.


klepto2(Posted 2005) [#20]
Great Stuff, I have tried it by myself, but give up after getting trouble with DX and OpenGL.

Will try it now. From the Screenies it looks great.


tonyg(Posted 2005) [#21]
I'm keeping an eye on this as the demos are fantastic. What would be nice is a seperate shadow editor where I can load a tileset and create the polygons, save them out and then load them into my program.
If it's already possible to do this I'd be interested to know how.


Robert Cummings(Posted 2005) [#22]
Can't get this working - error with build modules?

also

---------------------------
BlitzMax Application
---------------------------
Compile Error
Identifier 'DrawTexturedPoly' not found
---------------------------
OK
---------------------------


tonyg(Posted 2005) [#23]
"and Indiepath for his DirectX version of DrawTexturedPoly() "
and from the website...
"This module works only with the Drawtexturedpoly() command."


smilertoo(Posted 2005) [#24]
I did everything i read but bmax wouldnt compile for me either


Robert Cummings(Posted 2005) [#25]
Well why doesn't he include it? Just include it for gods sake.


puki(Posted 2005) [#26]
Heh - this is why I don't use BMax.


tonyg(Posted 2005) [#27]
Do any of the 'not compile' problems provide messages?


René(Posted 2005) [#28]
@tonyg:
did you know: you can press F12 to export all object code to console. Press Shift+F12 to export only selected objects.

You could write a background image loader and use this function. There is still a little bug: there must be at least one TShadowCasterObject or the shadow system will not run, sorry for that.


René(Posted 2005) [#29]
New version uploaded on my site (see first post).
No new features, but an only includes version. So no mod hacks are needed, everything is included. The restriction: the include version is OpenGL only since I do not know, how to write a DrawTexturedPoly() command for DirectX...


tonyg(Posted 2005) [#30]
I'll try that next week.
It'd be nice to have the shadow/light editor as part of a map editor.
Load your map, draw around your shadow casters, place your lights and then save the data.
With ability to add lights at runtime I can see some nice stuff being produced.
What further plans do you have for this mod and where can I track it's progress?
Sometimes I wonder whether there should be a BB.com uber-2d mod using the great stuff being produced on these forums.


René(Posted 2005) [#31]
There are some more features planned:
- rotating of TShadowCasterObjects
- maybe scaling of TShadowCasterObjects
- circle shadow geometries
- lense flares
- textured umbra shadows (for creating light through window fx, fake caustics, etc.)
- a standalone editor with export to file functions

I will post everything in this thread and/or update the project site.


daaan(Posted 2005) [#32]
Wow, this really is amazing. I've already easily implemented this in a project im working on. Thanks.


tonyg(Posted 2005) [#33]
I'm still keeping an eye on this so any news/progress is most welcome.


René(Posted 2005) [#34]
Right now im working on a feature rich editor that will use the shadow system with some new features.

Right now the progess is slow because of other projects without shadows :-)

Since there is no official DrawTexturedPoly command, I will only develop an OpenGL version. I don't want to do such mod hacks anymore...

There will be more news/updates in future, when my Website update is done.


GrahamK(Posted 2005) [#35]
Nice...