Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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  
  Shadows  (Read 2687 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Posted 2005-12-14 08:32:35 »

Going through a loop with shadows at the moment. I wonder if theres some method I've missed:

Planar Projection Shadows - not worth the time since it makes it extemely intensive to shadow a many faced object (like say an MD2 model).

Shadow Volumes - great if you can caculate the silloutte geometry and hence shadow volume quickly enough. However, this seems pretty heavyweight and I don't think it will be quick enough on the systems I'm aiming at.

Shadow Mapping - brilliant method, unfortunately requires the GL_ARB_depth_texture extension which low end cards don't support.

So.. I'm a bit scuppered for realistic shadows?

I've been thinking about a method where I generate a shadow volume based on the bounding box of the object then draw slices through the volume textured with a render of the shadow caster from the lights perspective. Render these slices with depth test = equal and blended onto the surround geometry.

Any thoughts on this rambling?

Kev

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2005-12-14 09:22:19 »

Well if shadow volumes and shadow mapping are out you'll pretty much out of options for a general case stuff, so I guess it's back to the old-school methods of cheating. Smiley Projected textures (even just with generated greyscale textures) can still look pretty nice, so that might be an option. And Realtime Rendering has a good section on shadows and includes lots of the more simpler methods.

What kind of environment are we talking about here?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #2 - Posted 2005-12-14 10:08:20 »

Isometric rendered in OpenGL. Simple rooms with dynamic boxes and models in all modelled as axis oriented bounding boxes. Fixed viewport (might help?). Fixed Lighting (probably).

At the moment shadowing boxes seems pretty damn easy Smiley However, the non-animating ornaments (think vases, statues, chests) are slightly more worrying. More so the actual characters wandering arond seems really difficult to achieve in any nice looking way. My central character is an MD2 with ~600 polys. He can face and direction and may have up to 100 frames of animation.

I was wondering if I could maybe use two shadow methods (say planar projection for the MD2 and shadow volumes for the non-animating stuff)? Anyone tried anything like that before?

Kev

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2005-12-14 12:56:13 »

If your target doesn't support the shadow mapping extensions then shadow volumes are probably not going to be practical. Even if you simplified the geometry so generating the volumes was quick, the real killer on older cards is the fillrate it needs. Even GF2 can do simple shadow mapping, but they don't have nearly enough fillrate for anything other than the crudest shadow volumes.

I think your best bet is probably projective shadow textures - should mean objects shadow their environment correctly without too much fuss. If you really want self shadowing and shadows between objects then one of the Game Programming Gems books has a nice article on shadow textures with per-object ids. Can't remember the details at the moment though. Embarrassed

Edit: "Practical Priority Buffer Shadows" is in GPG2 if you can lay your hands on it.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline princec

JGO Kernel


Medals: 379
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2005-12-14 13:42:55 »

Mehhh, Kev you're always making life difficult for yourself. The solution is simple! Disable shadows if your fancy extension isn't present! Who's going to be any the wiser?

Cas Smiley

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #5 - Posted 2005-12-14 14:06:35 »

>Disable shadows if your fancy extension isn't present!

Well, its sorta difficult to write stuff which your own card doesnt support Smiley

My card (ati 9100 [8500 basically]) also doesnt support it, but you can play doom3 with it.

弾幕 ☆ @mahonnaiseblog
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2005-12-14 14:07:04 »

Unfortunately my card doesn't support the required extension for shadows, so I can't even test against it. Not to mention I was intending to use shadowing as part of some of the puzzles (maybe).

Fraid I don't own Gems and I'm not in a position to buying books at the moment (given I'm leaving for the states in 3 weeks). I'll try googling for the term see if I can get the idea. Thanks.

Kev

Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #7 - Posted 2005-12-14 14:22:59 »

Quote
Practical Priority Buffer Shadows
Those are mostly like shadow mapping, but give an ID to the object when rendered, this gives an inifinite precision, but because two pixels share the same id (same object), self shadowing doesn't occur because of the ID's.

If you really really want to do shadow mapping, then a view-dependant, progressive refinment of the shadow map using a heirarchial grid (i think thats called adaptive shadow mapping) should help as that minimises the area on which you need to read back from the frame buffer if you keep the memory bound of the textures quite low (glReadPixel is necessary in your case kevglass). You wont get as nice shadows as shadow volumes, or a high-res shadow mapping technique, but it works on old cards and has self-shadowing.

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #8 - Posted 2005-12-14 14:38:39 »

Seems like OT is right really. Projective shadows should be fine for me I think.

Kev

Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #9 - Posted 2005-12-15 08:56:02 »

So I implemented some shadows last night. Not sure what the right term is (projective shadow textures?) but I render the shadow caster from the light source using black on white. Copy that image into a texture then use project texture coordinate generation to map this over everything that is further away from the light source that the shadow caster. It does look nice and is pretty much what I was looking for.

However...

1) The black on white texture when blending across the scene causes all the colours to get washed out where the white blends onto the scene. I tried alpha masking and blending on alpha but with no success. I wondered if multitexturing might help this morning but I'm pretty sure I'll get the same effect. What I really need to do is fill the background of the shadow texture with a non-colour, i.e. not specified so that the blending ignores the white but I can't seem to figure this out? I assumed it'll be alpha=0 but that doesn't want to work out.

2) This method seems to need me to generate one shadow map per shadow caster or inversely one shadow map per shadow reciever. One map per caster is fine accept it means rerendering some part of the scene lots of times to place lots of shadows over it. One map per reciever seems fine accept that means tracking changes in things that might cast shadows on the reciever to work out when to recalculate the shadow map. I assume, I'm missing something?

Even so, the results were very nice (though I haven't screenshoted yet - soon). Thanks for the initial points guys.

Kev

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #10 - Posted 2005-12-17 02:15:07 »

Im supposing your just using gluLookAt, modifying the frustum a bit and rendering the scene, copy to texture and use that as the texture ?

If your doing that, you can use glClearColor to specify the alpha value of the colour. Although from my experience, that never works for the display, maybe it works for textures....If that doesn't work, maybe you can try rendering a full screen quad before doing the black and white rendering to specify the alpha (worked for me in VEpi). Its a hack, but it might be worth trying it out...

And now I shall just sit here, on this exact chair until I get that screenie! Tongue

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #11 - Posted 2005-12-17 21:53:30 »

Ok, this is where I'm at right now:

http://www.cokeandcode.com/mm2/mm2-shadows.png

Kev

Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #12 - Posted 2005-12-17 22:14:48 »

Wow - Looking good Kev!

Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #13 - Posted 2005-12-19 11:45:30 »

Got a little bit further along, the screenshot above has been updated. I'm now using 512x512 shadow maps (one per shadow caster). With a bunch of clip planes defined to get some of the performance back and getting around 100 fps for a reasonbly simple scene (see screenshot) on my terrible hardware (ATI Mobility 7000 IGP).

Still tweening out performance a bit but its starting to come together.

Kev

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2005-12-19 13:38:00 »

If you have ~50% alpha, the shadows will be more realistic.

If you can't find a way to do that without shaders, you can render a quad with glColor(1,1,1, 0.5) on top of your texture.

The only side-effect would be that when 2 shadows overlap, the overlap will be darker (even for 1 light-source) which is unrealistic.

That is very almost impossible to correct, unless you write all shadows to a seperate texture and render that on top of the entire scene. But well, that would be just wasting gpu-cycles by blocking the pipelines several times per frame.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #15 - Posted 2005-12-19 14:02:57 »

Funny you should say that....

Currently I render the shadow textures to the back buffer (one texture per shadow caster). The shadows are rendered pure black on a white background. Since I have no alpha channel on my display I have to mask the shadows onto the scene using GL_DST_COLOR,GL_ZERO blending and hence can't get a 50% alpha (at least I don't think so).

At the moment, I can't see anyway of using a single texture for all casters without using the ARB_depth_texture extension (which I don't have). I can't see any way of using any other blending since I don't have alpha support on my display (16 bit mode).

I'm aiming at rubbish cards like mine so I guess the restrictions are what they are.

As a side note, I kinda prefer the black shadows since the whole thing is meant to look cartoony.. but I'd appreciate any pointers where I might get peformance increase (it drops a fair bit with additional alien models) or where I might get smoother graphical effects.

Kev

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #16 - Posted 2005-12-19 14:43:14 »

Perhaps you didn't understand me correctly: I meant rendering all shadow-textures to YetAnotherTexture and alpha-fading that one.
Anyway, that doesn't really help you much, as it's even slower than your current approach.

In my current project I render very simple shadows that are only projected on the ground, using only 1 texture. I agree that it's not as fancy as projecting shadows at other objects, but you might wonder whether that's realistisch for the hardware you aim for.

The basic idea is to render all objects to the ground-plane texture (black on white) - I did that with a custom projection matrix - and render the texture as a quad to the floor, with a certain faded alpha. Add some jittering over some passes and you'll have truly high-res soft-shadows. It requires only 1 additional pass, so you can let many objects cast the shadow.

It might not be what you need at all, but if shadows on the floor are enough for you, it does the job.

..

Hmm... if you want to get really fancy, do your own ray-tracing in a 64^3 grid, put the data in a 3d-texture and project it in world-coordinates at your scene... hehe. That only really works for static scenes Smiley

When I find something more usefull, I'll tell you Roll Eyes

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #17 - Posted 2005-12-19 14:50:18 »

Currently my thinking is I'll either

a) Just remove shadows, too costly.
b) Replace proper shadows with simple faded circlular shadows beneath every object projected onto the surface below them (though this could quite costly since I still end up with needing a depth factor.
c) Leave it with what I've got, try to get the speed up a little bit and stick to about two enemies in a room (which is probably enough anyway)

Quote
When I find something more usefull, I'll tell you Roll Eyes

Thanks. Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #18 - Posted 2005-12-19 15:27:04 »

If it would be option B, then just layer 1 quad per object on top of the surface. Nothing fancy, no depth-factor required. The algorithm described in my previous post would be much nicer and only a bit heavier.


Now you're using a isometric-projection, shouldn't you search for algorithms for isometric shadows? It's fairly easy to create a isometric-shadow-projection-to-a-plane projection-matrix thingy.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
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.

radar3301 (10 views)
2014-09-21 23:33:17

BurntPizza (28 views)
2014-09-21 02:42:18

BurntPizza (18 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (46 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!