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 / Shader for object blooming?

Author
Message
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 12th Jan 2013 04:08
Hi,
Been up the last few hours trying to solve this one :/
I've been trying to find a shader that can be applied to a single object to give it a bloom effect (light brightens and expands when looked at directly)
Just so as you know, the situation in the game I'm working on is that there's a moon, and it'd really look good if instead of just hanging there like an ordinary, dull textured sphere, it could glow brightly!
Unfortunately, almost all games and applications I've made so far have been fairly graphically uninteresting, because I've never really given shaders a try before. I've seen some example code, which shows all this stuff about setting up a screen quad, and multiple cameras, and been a little confused by it, so probably if I did find a good shader file, I wouldn't know where to begin with it!
Thanks for any help! If anyone can recommend a shader, or an alternative method or something, that'd be great thanks
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 12th Jan 2013 09:23 Edited at: 12th Jan 2013 09:25
Yes this can be done.
If you specifically want No Bloom on anything else. Here's what you do:

1. Add the Bloom Shader to your game. Put it in proper and make everything all Bloomy.

2. Modify the Bloom code (the code the demo uses to make use of the shader). Basically hide everything but the moon.

3. Make the backdrop black for the Bloom Cameras.

4. Before Syncing Camera 0, Unhide everything. You may have to play with Sync Mask to force Camera 0 to be synced on it's own instead of grouped with the other cameras.


Now the Bloom shader will only be active for the moon. The bloom cameras will be completely black, except for when the moon is in frame. The only object those cameras will see is the moon. Only the moon will be Bloomy.

Voila.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th Jan 2013 09:31
that is interesting Mage...

I was also wondering if this was possible and in the past the answer was always no...

If I remember this I will give it a go...

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jan 2013 00:42
Quote: "I was also wondering if this was possible and in the past the answer was always no..."


What??!!

There are several bloom demos around. I'm sure Evolved has posted several over the years and DarkShader comes with one if I recall correctly.
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 13th Jan 2013 02:36
Ok, thank you
I do have Dark Shader, and I found a fullscreen bloom shader in there. Exported it as a .fx file, and copied the code (which still doesn't make total sense to me) from a bloom demo in the 'Snippets' example folder, which used a .dbs version of the same shader. So far, I've managed to get my head around it enough to make the whole backdrop of the scene bloom the edges of all the objects. It's not totally what I was looking for (I was more after something that glows brighter when you look at it), but it seems pretty good!
Not quite sure where to go from here though with hiding all but the moon from certain cameras, sorry!
Here's the code for syncing the cameras:
Object 3 is the moon
Object 10 is the screen quad plain thing, which is beyond me
Camera 1 is the bloom camera

Any pointers on what to do next?
Thanks
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 13th Jan 2013 02:39
Oh, and one more thing, I can't seem to get my game to display in anything above standard resolution whilst using this shader! I had it displayed at 1600x900 before, but using the 'Set display mode' command at all now just seems to result in a black screen
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 13th Jan 2013 06:47
If you do what I suggested, you can create a "Brightening As You Look At It" effect by using Object Screen X(), Object Screen Y(), Screen Width(), Screen Height().

The idea is you can measure how far the moon is from the center of the screen and dial the Bloom Intensity up and down, based on that distance.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jan 2013 16:23 Edited at: 13th Jan 2013 16:30
Quote: "but using the 'Set display mode' command at all now just seems to result in a black screen"


Hard to say what the problem is without seeing your code but it's possible you need to add the following line immediately after your `set display mode` command:

(Edited)

It's needed by some of the Dark Shader stuff and I forget which off-hand - and I have no idea why it's needed either.

Edit Sorry! It's "reload" not "reset".
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 13th Jan 2013 21:26
Thank you both for that
Now I understand about the brightening thing! Also, that trick worked Gandalf, thanks!
Still not sure about what to do with the code though, unfortunately. Been playing around with it, and haven't got anywhere so far. Unless anyone has any more suggestions, I might leave it for now, and play with it a little later in the game's development
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Jan 2013 22:10
Careful with bloom. Too many games overuse it I think and it becomes annoying.

"You're not going crazy. You're going sane in a crazy world!" ~Tick

Login to post a reply

Server time is: 2026-07-07 18:45:00
Your offset time is: 2026-07-07 18:45:00