• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
larspensjo

Shadows effect depending on distance

4 posts in this topic

The question is how to get an decreasing shadow effect with distance from sun?

Some background:[list]
[*]I am using shadow maps, a separate render pass with the camera up in the sky in using orthogonal projection with the depth buffer saved in a bitmap for the final render phase.
[*]My world is infinite in all dimensions. There will be objects above ground, unlimited. In theory, that means that there should always be shadows from the sun. But in practice, I want nice views instead of totally realistic views.
[*]The idea is to let the effect of the shadow decrease with distance between the object doing the shadow and the surface that is shadowed. Beyond a certain limit, there would be no shadow at all.
[*]It is easy to get a value for the distance, from the object casting a shadow to the surface, in the fragment shader.
[/list]
This is where the problems start. The shadow map records the distances to the objects closest to the sun. If there are two objects casting a shadow on the same surface, the distance computation algorithm would be based on the object closest to the sun. This is not the result I want. I want the near distance object to cast a dark shadow, and the far distance object to cast a weaker shadow, outside of the shadow of the near distance object.

Edit: Of course I want decreasing shadow effects with distance from the sun, not increasing. Edited by larspensjo
0

Share this post


Link to post
Share on other sites
You can render two shadow maps (min/max), one standard and one reverted (revert culling and z-tests). The latter one can be used for calculating the distance to the closest surface. You can't use only the second one.

Though you could try to write it in a single pass (render the second value to a standard render target), but this could be slower than a two pass solution, because of turning down all the hardware z-buffer optimsation stuff. On the other hand the fragment shader would be pretty fast, at least I would test out both solution.
2

Share this post


Link to post
Share on other sites
Ashaman, thanks for the suggestion. But I am starting to believe it is simply not possible with a technique based on shadow maps.

In the creation of the shadow map, the camera is moved "near" the sun, looking in the same direction as the sun light is going. For every point in the shadow map, there can now be many objects that are hit by the same ray of light. In principle, I think one depth value is needed for every possible object in that direction. But one depth buffer can only hold one depth value for a point.
0

Share this post


Link to post
Share on other sites
The "decreasing with distance" behaviour of real shadows is due to the penumbra. Standard shadow mapping techniques are only good for drawing the umbra, and soft-shadow extensions are usually hacks to generate a visually-plausible (not physically correct) penumbra. e.g. a common approach is to use a larger "softening" filter for depth-samples that are a long distance from the shadow-receiver.
[img]http://www.billcasselman.com/index_clip_image001.gif[/img][img]http://van.physics.illinois.edu/qa/pictures/2068/20020123163918__umbra.jpg[/img]

The basic shadow mapping technique [i]can[/i] be extended to allow for real penumbras, but a general solution will be extremely slow/expensive.

Ashaman's suggestion to use 2 shadow maps is a trade-off -- instead of the up-to-infinite depths required, it's limited to 2, which is still more information than 1 ;)

There's a general rendering technique known as "Depth Peeling", which allows you to store many layers of information per pixel, which can be applied to shadow mapping, but of course the memory and processing requires go up as you increase the amount of layers that are required.
For an example, look up "deep shadow maps", but be aware that solving this problem in general isn't easy and will involve quite a bit of research.

[quote name='larspensjo' timestamp='1344516756' post='4967765']
In the creation of the shadow map, the camera is moved "near" the sun, looking in the same direction as the sun light is going.
[/quote]Another version of Ashaman's suggestion would be to render one shadow map like this, and then to move the camera "opposite" the sun (looking back towards the sun) and render a 2nd shadow map. This gives you a kind of minimum and maximum distance for occluders from the sun. You could use one map to draw really soft shadows, and the other to draw hard shadows. Edited by Hodgman
2

Share this post


Link to post
Share on other sites
Thanks for the elaborate description!

I think I get it; using Ashaman's suggestion will not give a perfect penumbra, but it may be a good enough approximation. Which is what much about game graphics is about...
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0