Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Drawing Order for correct Transparency - Alternatives? (and related stuff)  (Read 1055 times)
0 Members and 1 Guest are viewing this topic.
Offline RongoMatane

Junior Newbie





« Posted 2012-10-03 10:16:31 »

Hi,
i am programming an isometric game with a 3D map and objects on it that are 2D Sprites. These sprites also contain the shadow of the object, als partly transparent black area. I finally stumbled upon the problem of transparent regions blocking the view to objects behind them. I guess you are familiar with the problem, but i can give some screenshots if needed.
As i read one can solve this problem by drawing the objects in the right order. I don't really like this idea because avoiding this was half the reason to use 3D maps instead of pure 2D. So i wonder if there are alternatives to this. I enumerate some things i thought about and would really appreciate some feedback on this.

1. One thing i thought about was drawing the objects without any shadowing and after that draw all the shadows. For this i'd need seperate Shadow Textures and would basically need to draw twice as many sprites. Is this in general a bad idea?

2. One issue that comes with the 2D sprites is that i can't really create shadows and correct lighting on the object, for example in a days cycle. If i'd seperate the shadows, i could for example create 24 different shadowmaps for each hour, for each object, what sounds like a lot of effort. Does anyone have expereince with this, or knows any other methods to cast (good) shadows from 2D objects?

3. The lighting on the sprite itself should also change - a wall could be directly hit by light in the morning and be bright, and could be hidden from the sun in the noon and be dark. I thought about using another texture that basically encodes the normals of the surface of the object in color. With this i could directly calculate the brightness of the different parts of the object with a shader and render it correctly. Did anyone try this? Would this even work? Cheesy

These questions aim at unanimated objects, like buildings. I also have animated objects, but i think i could live with worse lighting there, also because it sounds like a ton of work to create all shadows for all hours for all animations (or "normalmaps").

It would be awesome to get some feedback and opinions, hints or links.

Greetings

Rongo
Offline theagentd

« JGO Bitwise Duke »


Medals: 366
Projects: 2
Exp: 8 years



« Reply #1 - Posted 2012-10-04 00:24:26 »

1. That's a good idea. How would you do it otherwise anyway? Look at this: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/dynamic-2d-soft-shadows-r2032

2. I did this once. I basically rendered a normal sprite colored black on the ground away from the shadow caster. I just picked from the 4 directions available, which did indeed cause a rather ugly change pop when at all four 45 degree angles when I changed the direction, but overall it looked great and was relatively easy to implement. With only 8 directions of shadow sprites and some smart blending between them it'll look great. 3D textures can be used to easily achieve that.

3. This is the trickiest part. Normal mapping is awesome and gives an incredible amount of depth, but I never had the skills/resources to try it out myself, but it'll surely look incredible. Note that normal maps have nothing to do with shadows, it's just how lighting interacts with the sprite surface. For static objects and static lights you can precompute shadows using some slow ray casting or so. For dynamic objects/lights you could either do some ray casts, which is pretty cheap since you only have to do it for the x axis since it's 2D meaning that it's only 8 or so per sprite. It's hard to make sprites cast shadows on other sprites though for the same reason, since the actual 3D information isn't there...


Myomyomyo.
Offline RongoMatane

Junior Newbie





« Reply #2 - Posted 2012-10-04 08:11:42 »

Awesome, thanks for your answer.
Then i think i'll go for seperate shadows with the option to expand it later into a 3D Texture and simulating the day cycle. The other option would have been to put the shadow and the image into one texture, not being able to simulate lighting and needing to draw in the correct order.

The ray casting won't wirk this way because i'm not really 2D. At the moment i don't have sprites for all 4 directions if you can rotate with 90° (which i can't right now) and i'm not sure if i'll even implement this. Otherwise i maybe could use the different rotated sprites to cast shadows.

I post some screenshots to make it more clear:
Normal look:
http://imagebin.org/230854

If i fly around in 3D, it's visible that the objects are only 2D:
http://imagebin.org/230855

And there can be heights:
http://imagebin.org/230856
The heights further complicate the problem, if i'd want to make really good shadows. I guess i couldn't avoid shadow volumes or shadow mapping then.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (10 views)
2014-12-23 03:34:11

rwatson462 (38 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!