Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Easy Depth Of Field

Author
Message
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 9th Sep 2015 06:00
Does anyone knows an easy way to implement Depth Of Field in a Game?

I have tried to implement that with the evolved shaders but I can't get it to work, it uses also a lot of code and 4 different shaders, is there a simple way to implement this?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Sep 2015 14:41
I don't think there is. The issue is that the depth field needs to be pre-calculated so that a blur shader can control the level of blur based on the depth field. In DBPro a depth field tends to be an extra camera in a clone of the level geometry, coloured white with a black fog, so the brighter the pixel, the less blurring is applied. All this legwork is complicated and takes a real hit on performance. The extra camera, the extra render, the extra scene, then a variable range blur makes a big dent in your frame rate.

I would be tempted to control blurring on an individual object instead, based on it's distance to the camera - maybe even just hijacking the objects colour to control this, like use the red component to set the distance in code, then in the shader you could use that to control the blurring range of the texture. Would work nicely with flat plains and transparent textures, like foliage for example, but actual geometry might just look daft... you'd still have sharp edges on geometry. Really I think that if your project relies on a big terrain or lots of geometry with a long view range, then depth of field is not a good idea, it takes too much performance for what it gives. Depth of field works better for DBPro with stylistic games, like those short, minimalist, spooky adventure games that we saw a few years ago here.

Login to post a reply

Server time is: 2024-04-19 14:56:11
Your offset time is: 2024-04-19 14:56:11