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 / Multiple camera shader rendering

Author
Message
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 18th Oct 2010 20:06 Edited at: 18th Oct 2010 20:07
Hi,

I would like to render the output of several camera shaders at the same time.

In this case, it is the Sixty Squares' heat haze:

[Shader] Heat Haze / Distortion (Easy to Use)

And the DarkShader fullscreen Bloom shader.

The problem is that when the Bloom shader renders, it overwrittes the output of the heat haze shader.

The output of the Heat haze shader must be passed as input of the Bloom shader, but I don't know exactly how to do this

Here is the DBPro source code:



Here is a pic of both effects, but not at the same time:



Attachments

Login to view attachments
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 18th Oct 2010 20:08
Here I attach the whole thing (includes DGDK version), watch out because the output picture of the previous post is from the DGDK project.
When I run the DBPro project without the REMSTART/REMEND comenting the Bloom shader, I get a blue screen and graphic drivers output an error, so please take care. However you can run the attached 'project.exe' to see it running (DGDK version has no crashing.)

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2010 20:35
I'm a bit baffled.

I'm assuming you want to do the heat haze first then apply the bloom - i.e. NOT "at the same time". If you do the heat haze first and send the output to the bloom screen quad then the bloom camera needs to see that quad. What's the problem exactly?

I guess you could do it all with one multi-pass shader using the new RenderColorTarget feature, i.e. the first pass applies the heat haze, the second applies bloom to the result of the first pass and sends the result to the screen.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2010 21:05
I've just tried your demo with the bloom added and it runs without crashing - but you need the mysterious RELOAD DISPLAY POINTER command immediately after the SET DISPLAY MODE command. See attached file which should be on your system somewhere (it was in my Keywords folder but I might have put it there ).

As you say, you don't see the haze. But I'd guess you haven't shown the quad with the heat haze output to the bloom camera. If you haven't spotted the problem I'll delve into your code later.

Attachments

Login to view attachments
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 18th Oct 2010 21:24
Hey thanks GG.

Quote: "I'm assuming you want to do the heat haze first then apply the bloom - i.e. NOT "at the same time"."

Yeah sorry I wrote too fast. I would like to concatenate them, as you say.

Quote: "If you do the heat haze first and send the output to the bloom screen quad then the bloom camera needs to see that quad. What's the problem exactly?"

It is that I don't know how to "send the output to the bloom screen quad"

Quote: "you could do it all with one multi-pass shader using the new RenderColorTarget feature"

Interesting although having independent shaders is also useful for the flexibility of user options.

Quote: "I've just tried your demo with the bloom added and it runs without crashing - but you need the mysterious RELOAD DISPLAY POINTER command immediately after the SET DISPLAY MODE command."

Alright thanks I'll check this, maybe I have to update DBPro.

Quote: "... I'd guess you haven't shown the quad with the heat haze output to the bloom camera."

Emm, well I haven't hided it either! I hope it is as easy as you say. I'll give it another try tomorrow, I cannot stand another blue screen crash and recover today. Thanks again

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2010 22:53 Edited at: 18th Oct 2010 22:54
Quote: "Emm, well I haven't hided it either! I "


I think you have:



If you comment that line then you do get something. I know it isn't right yet but I think that is part of the problem. I'll see if I can fathom the rest of it - e.g. you obviously used set object mask for a reason which escapes me for the moment. The light will dawn on me I'm sure.

Quote: "I cannot stand another blue screen crash and recover today"


I haven't seen one of those for a long time. I'd have a beer or two if I were you (in case you need an excuse ).

Incidentally, your DGDK version only runs correctly on my old laptop - I get a black screen until I press shift on my main machine.

Looks like another evening's gaming scuppered.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Oct 2010 01:06
I'm not sure, but I wonder if the problem is related to the following bug report/feature request:

transparency and cameras

Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 19th Oct 2010 06:06
Quote: "you obviously used set object mask for a reason which escapes me for the moment. The light will dawn on me I'm sure. "

That was to make sure that the heat haze object wouldn't draw on its on input camera.

Anyway, I think I found the solution

The way that the heat haze shader works is that it takes a camera's input image and distorts it on any object you choose. This object is then drawn to the main camera.

DarkShader's bloom shader takes the input of one camera (the bloom camera) and then outputs it to that camera's image, which is then textured onto a quad object. This quad object is then drawn on the main camera.

As GG said, to make these two shaders work together, the finalized heat haze object has to be drawn onto the bloom shader's input camera. Otherwise the bloom shader doesn't even know it's there.

The only thing that needs to be drawn onto the main camera is the bloom shader's quad object, since it holds the final picture of the scene (this is why the level object is only shown when the bloom camera is sync'd, and then hidden again for the main camera's sync). Showing all of the objects on the main camera won't change the way things look, but it could cause lag since everything would be drawn an extra time.

This line:


is telling the heat haze object to only draw on the main camera. But we want it to draw on the bloom camera, because at the moment the bloom shader has no idea that the heat haze object exists. So, your BloomCam variable needs to be made global and that line has to be changed to this:


Now it will only draw on the bloom camera, and will be shown in the bloom shader's input image. But the object will look too bright. This is because the Bloom Shader's QUAD object is also being drawn on the heat haze shader's input camera. So the heat haze shader is distorting the bloom image and then the bloom shader is making this distorted image even brighter. To fix this, just tell the bloom quad to only draw to the main camera using SET OBJECT MASK:



Now all you have to do is make sure that all of your level objects draw for the heat haze camera AND the bloom shader's input camera. You can show the objects manually before each camera is synced like you are already doing with the bloom shader camera and object #1, or you can use SET OBJECT MASK on all of your objects so they only sync for the bloom and heat haze cameras, like this:


Anyway, making those 3 changes should get the two shaders working together. Let me know if you have any questions


Guns, cinematics, stealth, items and more!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Oct 2010 12:34
Fixed. Try the following code:



I think this is another way of doing what SixtySquares has suggested which should also work for the reasons he gives.

[Why did the solution have to come to me at 4am in the morning rather than when I was in front of my computer yesterday? ]
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 19th Oct 2010 14:34 Edited at: 19th Oct 2010 14:50
You guys are fantastic!
It works like a charm

Yes, basically the solution was what Sixty Squares described, to render the heaz haze object in the bloom cam, and show the bloom quad only to the main camera.
Of course GG solution works equally fine. I'm finally relying on Set Object Mask because the resulting code seems less messy to me.

Here is the result:




And here the output in the main project
(click to enlarge)





Needless to say I'm very happy
I was a little bit overloaded with too many details to see it clear, you saved me a lot of time with this, many many thanks!

Attachments

Login to view attachments
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 21st Oct 2010 01:21
Looks good and I'm glad you've got it working. Can't wait for the next video


Guns, cinematics, stealth, items and more!

Login to post a reply

Server time is: 2024-04-25 05:05:16
Your offset time is: 2024-04-25 05:05:16