• 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

God Rays + Alpha ( is it possible )?

13 posts in this topic

http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html

 

Would it be possible to get the above effect while using alphas from a model+texture? I ask because our cloud system works like so:

 

gallery_1_8_4831.png

 

We create a cylinder object that rotates in a selected direction ( slowly ).

 

gallery_1_8_70580.png

To get the desired cloud effect we apply a texture to it using SRGB and Alpha layer to remove the areas we do not want to cover by clouds.

 

gallery_1_8_113222.png

Our desire is to use the dome ( which encases the cylinder and the world ) where we apply the sun and generate the GPU gems lighting ( god rays ) from the clouds that are showing. I guess the question is, is there any way to create the same desired effect by using the Cloud system we have in place?

0

Share this post


Link to post
Share on other sites

I tried that in your almost exact same situation, but it was a failure (only 2 days spent on it though).

For two reasons:

- difficult to find the correct smearing direction for each pixel, though I'm sure there is a way had I put a bit of effort

- serious issue with desaturation over the whole sky. to have "god rays" somehow you need to "add haze" and that is terrible for the result. your image becomes whiter and desaturated overall. I tried various operators; like multiplication, or mix of mul and add, none were good. anyway, consider using somekind of pow() function to add godrays only near the solid angle that subtends the sun. Because physically, in-scattering mainly happens on light paths around this angle anyway.

- impossible to use with tiled rendering.

 

I will add one reason that could be a bother to your particular case, you have animated clouds so you will need to re-run this. but it is damn costly (100 samplings per pixel) so I suggest you use the fact that your rotation is very slow to smear progressively (in multiple passes over multiple frames).

 

But again, if I were you, I would still attempt this method, it seemed the easiest and best fit for cool results in a simple fasion for this case. I'm just saying it will require serious engineering. Kenny Mitchell gives us a theory, in practice it's always another story.

1

Share this post


Link to post
Share on other sites

Well, the inital test proved.... some what interesting. We used only the GPU gem tutorial and we got it working....

 

gallery_1_8_122071.jpg

 

But the cost of this was damn near 250 fps ( normally i get 350 or higher ). This would be a serious blowback for any rig since my machine is pretty beefy. That said, we have not optimized nor do we know if it is all correct. We do have some ideas on how we could get away with such things but the biggest part is that we got it working. I will keep you guys posted as we travel down this road. Any further suggestions or hints let us know! Thanks btw

0

Share this post


Link to post
Share on other sites
Post full shader code if you want help with it. Also fps is not measurement of cost because its all relative. Use milli seconds instead. So the cost of your implementation is 1/100fps - 1/350fps = 0.00714285715s or 7.14ms.
2

Share this post


Link to post
Share on other sites

Shader code is the exact same as that I linked in the first post. We mimicked the GPU gems. Not sure what you mean by FPS is not a measurement of cost. If i have 50 shaders and my FPS goes to 10 because of those shaders It is very much cost related. This is not a flight sim where 5 or 10 FPS will do so it is very much a relation to cost. You may have some valid point related to code as to how FPS = MS but in the world of the common person ( me ) FPS is the measurement of cost because it defines whether something is worth the effort or not to implement.

0

Share this post


Link to post
Share on other sites

Shader code is the exact same as that I linked in the first post. We mimicked the GPU gems. Not sure what you mean by FPS is not a measurement of cost. If i have 50 shaders and my FPS goes to 10 because of those shaders It is very much cost related. This is not a flight sim where 5 or 10 FPS will do so it is very much a relation to cost. You may have some valid point related to code as to how FPS = MS but in the world of the common person ( me ) FPS is the measurement of cost because it defines whether something is worth the effort or not to implement.

One rather obliviou optimization is move Weight multiply out of the loop and only does it once after loop.
sample *= illuminationDecay * Weight <-- This one!

Next but not that big optimization is move direction calculation to vertex shader.

half2 deltaTexCoord = (texCoord - ScreenLightPos.xy);
// Divide by number of samples and scale by control factor.
deltaTexCoord *= 1.0f / NUM_SAMPLES * Density

This all can be calculated at vertex shader and interpolated to pixel shader.

But I bet these modifications does not give any benefits and you are texel fetch bound. But all hope is not lost. This presentation walks through quite fast implementation of God rays. It even run at iPad2
http://www.unrealengine.com/files/downloads/Smedberg_Niklas_Bringing_AAA_Graphics.pdf


About fps. If someone only say that this effect cost 100fps you cannot say how much that effect use rendering time that why one should always use absolute time. If game run 1000fps then losing 50fps is not much(only 0.05ms) but if game run only 100fps then losing 50fps is rather big deal(10ms).
2

Share this post


Link to post
Share on other sites

Thank you for this help, I will have Goss try to add that in later today when he gets up.

 

As for the FPS, thank you for explaining it as I now have a better understanding of what you mean.

0

Share this post


Link to post
Share on other sites

Here's a cheap way to get God rays in screen-space. It's an adaptation of radial blur with the center pointing to the light source. Here's what looks like.


It works like this:

- Find the light's position in screen space

- Compute the intensity of the rays using the direction the camera is facing in relation to the light

- Create a low-res mask texture to only allow the sky to contribute to the blur (depth buffer is good for this)

- Apply the mask to a downsampled render target of your scene, so it only keeps sky pixels

- Blur the pixels in the direction of pixel position to light's screen space position (most costly step)

- Add the blurred texture times intensity to the original scene render

 

Optionally you can have a threshold for luminance on the blur.

1

Share this post


Link to post
Share on other sites

Not sure where goss took these links but this is what we have so far:

 

godrays.1.jpg

 

This is with 0 optimization and more or less just a test to see if it works correctly.

0

Share this post


Link to post
Share on other sites

nice link. Also, they neglected to mention that they also added a lens flare effect 

 

Aren't 5 passes kind of expensive? I've found ping-ponging between FBO's to have a MAJOR impact on performance.

 

wouldn't a simple radial blur act as a cheap approximation to the 2nd pass + 3rd pass combined? I'm not really sure why it's implemented in two separate passes,

1

Share this post


Link to post
Share on other sites

nice link. Also, they neglected to mention that they also added a lens flare effect 
 
Aren't 5 passes kind of expensive? I've found ping-ponging between FBO's to have a MAJOR impact on performance.
 
wouldn't a simple radial blur act as a cheap approximation to the 2nd pass + 3rd pass combined? I'm not really sure why it's implemented in two separate passes,

That 5th pass technique is optimized carefully to certain hardware. PowerVR hardware does not like texture fetches where texture coordinate is calculated at pixel shader. If you have simple radial blur without using any dependant texture reads could you please share it?
1

Share this post


Link to post
Share on other sites

Edit: Never mind I got it working. 

Edited by mgoss
1

Share this post


Link to post
Share on other sites

Btw, for those wondering we did get it working using the tutorials provided. They are very cheap and have a very nice end result. Thanks for all the help!

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