• 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
riuthamus

Point Lights Issue ( reconstructing position from logarithmic depth )

6 posts in this topic

We are having a problem with our point lights not working. Our current setup is a deferred rendering for lighting. Now somebody can correct me if I am wrong but this is how we are doing it:[list]
[*]We render stuff and our colors are recorded on a color RT
[*]Normals on another RT
[*]Depth on another RT ( our depth is logarithmic )
[/list]
When we render the point lights they need to read the depth RT so they can use the depth to calculate the world position of the pixel and then we can do the lighting calculations.

Our problem is we have no way of reversing that logarithmic depth at this point... any clues on how we could go about doing this? Or maybe there is a better way to handle the scenario all together. Thanks for your help in advance.
1

Share this post


Link to post
Share on other sites
hm... interesting okay ill give that a go. Thank you! any other advice people have is welcomed. We have a very nice fireball effect and I would like to add a point light to the process, that and we want lanterns! [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]

[b]EDIT:[/b]
showed this to the coders and this was the response i got:

[quote]yea yea
that's what we used to set it up in the first place
its literally the only xna deferred tutorial[/quote]

Also note we are not using XNA, we are using SlimDX, not sure if that matters at this point. I guess the big issue is that we are using Log depth, and this tutorial and others are not. We are attempting to use log depth to create better precision... but not sure if that is the main reason as to why ours does not work when others have no issues. Edited by riuthamus
0

Share this post


Link to post
Share on other sites
[quote name='riuthamus' timestamp='1346389963' post='4975042']
Our problem is we have no way of reversing that logarithmic depth at this point..
[/quote]You probably should have named your thread "reconstructing position from logarithmic depth" then [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]

WolframAlpha can be useful for tasks like this.
e.g. assuming you're using the formula: [font=courier new,courier,monospace]depth = [/font][font=courier new,courier,monospace]log(c*originalZ + 1) / log(c*far + 1)[/font]
You can copy that into wolfram, and ask it to solve for z: [url="http://www.wolframalpha.com/input/?i=d+%3D+log2%28c*z+%2B+1%29+%2F+log2%28c*f+%2B+1%29+%3B+solve+for+z"]http://www.wolframal...) ; solve for z[/url]
And it spits out [font=courier new,courier,monospace]originalZ = [/font][font=courier new,courier,monospace](pow(c*far+1,depth)-1)/c[/font]

I make no guarantees about the validity of this formula -- just giving you another tool to try ;) Edited by Hodgman
2

Share this post


Link to post
Share on other sites
Hm... thank you very much and if i can rename it, i will. I know on my ipforums you can if you are a thread owner.. but not sure how this one works. I will give it a good ol' college try!
0

Share this post


Link to post
Share on other sites
If I use the formula that wolframalpha gives, it gives us a closer result then we were getting before but the position is still off by a bit. I debugged a pixel in PIX and the position came out to (101.089287, 618.003845, -55.915211, -105.442390). Our blocks are 10 units big. The pixel I was debugging should have had a value close to (0, 600, 0). The Y axis (our up axis) is pretty close, but the other 2 are off by a bit.

This is how the log depth is encoded in the gbuffer:

[code]output.Position.z = log(0.001 * output.Position.z + 1) / log(0.001 * FarPlane + 1) * output.Position.w;[/code]

The vertex shader of the point light also adjusts the light's z position in the same way. And this is how the position is reconstructed in the light:

[code]
input.ScreenPosition.xy /= input.ScreenPosition.w;
float2 texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1);

//read depth
float depthVal = DepthMap.Sample(depthSampler, texCoord).r;
depthVal = (pow(0.001 * FarPlane + 1, depthVal) - 1) / 0.001;

//Compute screen-space position
float4 position = float4(input.ScreenPosition.xy, depthVal, 1.0f);

// transform to world space
position = mul(position, InvertViewProjection);
position /= position.w;
[/code]

Every time I debug a pixel, the attenuation always equals 0 since the position it calculates is out of the lights range. This is what it ends up looking like:
[attachment=11022:RuinValor 2012-08-31 17-49-01-90.png]
1

Share this post


Link to post
Share on other sites

Hm... not sure if this is reviving a dead topic... but we never got an answer and have started development on this. If this is a dead topic please close it mod. I will make another.

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