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 / Depth of field directly on camera

Author
Message
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 13th Oct 2014 05:30
How can i use the depth of field applied directly on camera with set camera effect? and where can i find the shader?
With dark shaders it says you can do that but when i open the example the effects are applied on the objects which is hard to add on my game because all of the variables already used: object numbers, image numbers, camera used, and even changing them i didnt get them to work, also having hundreds of objects where to apply the effect will be a pain to implement and cut down the speed too much.

How can i do that with a simple and painless set camera effect?
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 17th Oct 2014 01:21
still nobody knows how to apply effects directly with the camera with "set camera effect" command? and where to take the effects?
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 17th Oct 2014 05:58
I'd love to have a shader like this as well, but as far as I know you need to set the effect on all the objects as that's how it calculates distance from the camera.
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 17th Oct 2014 19:34
That s a shame as that would me thousands of times easier to implement a function for these effects, i am still not able to apply multiple shader as adding a new one will use the same camera of the other effect braking it, so far i have just been able to use the evolved water shader, if i try to apply some shadows effects, depth of field effects, blur effect etc it ends up just braking my water and don t get neither the new effects added to work, i tryed both evolved shaders and the dark shader example trying to add the code part required for them to work on my project but nothing works.
The evolved ones i tried the normal ones (shadow effects, post processing, which have not so many lines to add on my project, maybe like 100, which is fine) adding them to my project but nothing works, i even tried the advanced lighting but damn that s too much code to implement just for some effects, all files together would probably goes over 10000 lines which neither my main exe is
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 17th Oct 2014 23:38
Depending on the structure of your game you might be able to fake it, the project I'm working on has pretty small towns so any objects outside the bounds of the area I add to the skybox and blur them. But if you're making something with large levels of course it wouldn't work so well.
I know it can be frustrating, I'm not any sort of shader guru but it's still something we need if we want to create good looking games. We should probably both learn to write our own shaders really.
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 18th Oct 2014 00:03
How do you blur them? can you paste the code required to do that? perhaps linking the shader too?
To select which objects to blur i could just calculate the distance between camera and the object itself so that s not a problem
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 18th Oct 2014 02:55
There's no code or shader, the skybox uses textures so you just add renders of the objects to that texture and blur them in Photoshop or Gimp or whatever image editor you use.


Here's a screenshot from the game I'm working on. Nothing in the background is actual geometry, it's just a pre rendered image. If I wanted to put some trees in there or houses or whatever I could, and since it just uses 2d textures I have total control over how it looks independent of DBPro, I just have to load it.

Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 18th Oct 2014 03:08
Ah i got it, that will not work for me, as i have real geometry that i want to blur, how did you do for the shadows? using the evolved ones?
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 18th Oct 2014 07:18
Yeah, cubic shadow mapping. It will only work for specific things though, as you can only have one light and it's finite.
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 18th Oct 2014 07:39
I still have to manage to had dynamic shadows on my game, is that the only effect you use from evolved? i need to know how to merge multiple shaders in the same project
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 18th Oct 2014 08:30
Yeah that's currently the only evolved shader I'm using, but to use multiple shaders you'll need to set up multiple cameras. It can be tricky to do. The easiest way is to open up your first shader with just the example code, delete everything you can while still being able to confirm that the shader works, then do the same with the second shader but set the effect to camera 2 so you can merge them. Just make sure you set up camera 1 in the code, as camera 2 won't work if camera 1 doesn't exist.
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 18th Oct 2014 14:11
Is what i tried, the water shader i use, use camera 1 and 2, if i try to add for example the shadow shader to camera 3 it doesnt work, nor the depth of field one, do i need to change something on the shader file or what?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Oct 2014 18:36
One option would be to render a second camera with fog, probably using a basic copy of the 3D scene. Then, that image can be used to control the amount of blur applied because it represents the depth field, so effectively eliminating the need to affect all objects - overheads with this are another matter. I think this is the only way to do it, with a second camera and render plain... but it does invite some neat features as well, like for weapon scopes, instead of using the second camera render to decide the blur amount - use a fixed image. And fire sources too, have particle effects that only show on the second camera render, like raising up from a fire - then that will animate the depth image and give a shimmering effect. You could also affect the fog parameters to increase the depth blur directly, like blurring more when the player is hit.

I'm sure Evolved's shaders sometimes use this method.

I am the one who knocks...

Login to post a reply

Server time is: 2025-05-14 19:57:15
Your offset time is: 2025-05-14 19:57:15