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 / Bloom Shader Blurring Entire Scene

Author
Message
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 15th Mar 2014 15:15
Hi all,

I have this shader (ignore the fact that it's from Reloaded). I'm trying to make it not blur the entire scene and just overlay the glow on top. In theory, the glow should by blurred, not the base scene, right?

The reason I'm doing this is because I'm doing everything I can to help Lee get Reloaded up to scratch, and I can't stand the awful blurriness of his screenshots.

I want to 1) fix the shader for Lee and 2) learn how it was fixed. I don't want to steal credit, so anyone that helps me would get full credit, but I also want to learn more about shaders and try to understand what would need to be changed to fix it.

Here's the shader; it works perfectly in Dark Shader which helps greatly for testing:



So if anyone could help, I would greatly appreciate it (because I learn something) and I think Lee would appreciate it also (because he gets a better shader).

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Mar 2014 18:05
Have you tried using PSPresentClassic instead of PSPresent in the final pass? You may need to check the called arguments. I haven't studied the code carefully yet so the usual warning applies to my suggestion.



Powered by Free Banners
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 15th Mar 2014 23:14
Quote: "Have you tried using PSPresentClassic instead of PSPresent in the final pass?"


I have, and it's just as blurry with every final pass. I also commented out every other pass and just left PSPresentClassic and it was still blurry, so now I'm wondering if it's the vertex shader. I'll do some more experimenting soon

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 16th Mar 2014 00:18
I do realize my comment is not going to be the magic solution, just some inspiration.

What I am doing in my bloom shader is reducing the opacity of the blur based on its brightness on a per pixel basis; the dark parts of the blur are not mixed; the bright parts are mixed with the original source camera shot. In a nutshell, a blend mode or calculation can be used to affect how your bloom mixes with the scene; otherwise a complete mix will lead to blurry results.

I hope that inspires some ideas. To note, I am not sure how the vertex function is going to help you there; after-all, it is just the screen's 'vertices' it is setting.

The effect I am working on for the future is to have specific entities become a part of the bloom rendering; not just any object; not everything bright yellow or white must glow; that might also be a good way to improve screenshots.

Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 16th Mar 2014 00:27
Quote: "I do realize my comment is not going to be the magic solution, just some inspiration."


Haha Appreciated, it is.

Quote: "I hope that inspires some ideas. To note, I am not sure how the vertex function is going to help you there; after-all, it is just the screen's 'vertices' it is setting."


I think what may be happening is the vertex shader is not taking into account this and the sampler is sampling between pixels. I don't even know if that's possible, it just seems that was to me. I'm no shader guru....well, not yet

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Mar 2014 00:49
Quote: "What I am doing in my bloom shader is reducing the opacity of the blur based on its brightness on a per pixel basis; the dark parts of the blur are not mixed; the bright parts are mixed with the original source camera shot. In a nutshell, a blend mode or calculation can be used to affect how your bloom mixes with the scene; otherwise a complete mix will lead to blurry results."


That's sensible and it's what some of the code in the shader seems to be trying to do. However, I only had a quick look at it so I might have misunderstood what it's actually doing. What I expected to see in the shader was something like



in which brightness = 0 would give the original and 1 would give the blurred version. I thought the shader was doing something like that so if it isn't I need to study it more carefully. The variable brightness could be computed from either the original colour or from the blurred version with slightly different results I guess.

Quote: "The effect I am working on for the future is to have specific entities become a part of the bloom rendering; not just any object; not everything bright yellow or white must glow; that might also be a good way to improve screenshots."


That's a good idea too - and should be easy to implement.



Powered by Free Banners
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 16th Mar 2014 01:32
Quote: "That's sensible and it's what some of the code in the shader seems to be trying to do. However, I only had a quick look at it so I might have misunderstood what it's actually doing. What I expected to see in the shader was something like "


I don't know if you are, but you sound like you've become confused as to who has the problem :/

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Mar 2014 12:12
You've got me really confused now.

Have you looked at the Dark Shader version of bloom?



Powered by Free Banners
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 16th Mar 2014 12:31 Edited at: 16th Mar 2014 12:42
Quote: "You've got me really confused now."


Haha Well, you were quoting Chris Tate (who posted here also) and commenting as though he were me Re-read the posts carefully and you may see what I mean.

See, you said this:

Quote: "That's sensible and it's what some of the code in the shader seems to be trying to do. However, I only had a quick look at it so I might have misunderstood what it's actually doing. What I expected to see in the shader was something like"


After quoting Chris, yet you're talking as though you can see his shader.....and he didn't post his shader. See what I mean?

Quote: "Have you looked at the Dark Shader version of bloom?"


Yes, I have examined the bloom shader that comes with Dark Shader. It does exactly the same thing the shader I'm trying to fix, and I suspect that's because Mr. Blosser has made use of the Dark Shader bloom shader and taken some of its code.

I've tried commenting out everything except the last pass (PSPresentNoBloom), and all it does is sample the original rendered texture (as far as I can tell). This is why I think it must be the vertex shader that's causing the blurring.

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Mar 2014 18:23 Edited at: 16th Mar 2014 23:34
Quote: "After quoting Chris, yet you're talking as though you can see his shader.....and he didn't post his shader. See what I mean?"


Yes I do - but since only your shader had been revealed I thought it was clear I was talking about the one you posted. But I take your point - in fact I should never post anything after or even just before midnight.

Quote: "This is why I think it must be the vertex shader that's causing the blurring."


I don't really see what the vertex shader has to do with it. Sounds far more like a filtering issue to me. The only way to have a hope of avoiding filtering issues is to make sure the camera target image dimensions match the screen resolution. Do they?

Since you think the DS one has the same issue I'll dig out an old demo of mine and look at it more closely. Sounds like a fix for that would fix your problem as well.

[Edit Just dug out one of my old bloom demos using the DS bloom.dbs shader and made the demo a bit more user friendly (so that I understand it ). As you say, there seems to a bit of residual blurring that I haven't yet succeeded in removing. However, having had another look at the vertex shader code I can now see why you might think that's to blame. The half pixel shift is supposed to remove that potential cause of blurring - but perhaps it hasn't for some reason. I haven't yet compared the shader output with the output without the shader - and I haven't quite convinced myself that my test objects and images aren't slightly misaligned. The residual blurring I'm getting seems to only affect adjacent pixels. Is that what you are seeing?]

[Edit2 Just compared the screen image with and without the shader (with all filtering turned off and bloom turned right down) and the residual blurring seems to be identical. In other words the shader hasn't introduced any blurring which can't be removed by suitable fiddling with the settings. There are several sources to check:
1. the default texturing mode in DBPro - I turned off mipmapping (but just realised I forgot to turn off texture filtering so that might be the final one to check);
2. turn off all filtering in the sampler of the scene image for the final pass - I made a separate copy of the sampler, turned off its filtering and used that sampler for the final pass;
3. turned off anti-aliasing on the GFX card just in case (at least I think I did - I was forced to use the Intel rather than NVidia one for reasons I won't dwell on here );
4. bound to be something else I've forgotten for the moment. ]

[Edit3 Yep. Texture filtering on unshadered objects was the final cause of blurring. So that seems to settle that. ]



Powered by Free Banners
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 17th Mar 2014 02:45
I'll do some experimenting with texture filtering and mipmapping and the like.

This is what I see. This is a comparison between no shader at all and the default .dbs DS shader.

Without bloom:


With bloom:


Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 11:30 Edited at: 17th Mar 2014 11:32
Thanks for that. If it helps, here's the version of the DS bloom shader I'm using (attached plus the full screenshot for the following fragment).

The following fragment of a screenshot shows individual dots on a background object without blurring:





Powered by Free Banners

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 11:31
Image for previous post.



Powered by Free Banners

Attachments

Login to view attachments
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 17th Mar 2014 15:31
Ok, so as it turns out the greatest issue was the fact that Dark Shader was mucking me around The fix is really easy - use PSPresentClassic as the final pass. I had tried this already, but only in Dark Shader, and even shaders that are fine in a test DBPro project are very slightly blurry in Dark Shader....go figure

The blurriness was in fact caused by the intentional supersampling antialiasing (which looks terrible IMO because it effectively blurs the entire scene - I'd much rather do without antialiasing at all) in the bloom shader.

On the bright side (almost-pun not intended....we're talking about bloom, see...? ), I understand more about shaders and how to achieve a particular effect

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 15:52
Quote: "Ok, so as it turns out the greatest issue was the fact that Dark Shader was mucking me around "


I get a compile error when I use the latest version of Dark Shader - but earlier versions of Dark Shader work fine. It's a minor error caused by Paul overlooking "warning" messages issued by the FX compiler and these error messages vary from one version of the compiler to another. Anyway, that's my problem and it should be easy to fix. DBPro itself handles warning messages correctly.

Quote: "The fix is really easy - use PSPresentClassic as the final pass."


Now I think someone suggested that right near the beginning of this thread.



Powered by Free Banners
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 19th Mar 2014 01:51 Edited at: 19th Mar 2014 01:51
Quote: "Now I think someone suggested that right near the beginning of this thread."


eek? I know, I did try it even before you suggested it, but not in Reloaded itself, only by using Dark Shader

Login to post a reply

Server time is: 2025-05-14 21:50:41
Your offset time is: 2025-05-14 21:50:41