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 / Experimental Plugin: Multiple Render Targets

Author
Message
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 19th Jul 2017 08:51 Edited at: 8th Aug 2017 18:12
Notice: This plugin has been discontinued and is no longer receiving updates. Please direct all comments and questions to the new jGfx thread.


Hi everyone, I decided to see if I could get multiple render targets working in DBPro and it seems I have succeeded.
This plugin allows cameras to render to (up to) 4 target images simultaneously in a single sync. Rendering to MRTs requires usage of pixel shaders which return a structure of colors rather than a single float4 color.
I've included a simple example as well as a project using DBPro's native functionality for performance comparison.

Update 7/21/2017: Added 2 new commands for detecting gpu capabilities.
Update 7/28/2017: Fixed a memory leak, Added new command: MRTPostPixelFormatSupport(D3DImageFormat)

Command List (5 Total):

Attachments

Login to view attachments
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 19th Jul 2017 16:32 Edited at: 19th Jul 2017 16:34
Thats incredible!
I got 135 fps vs 89 fps with native DBP.
Tested with DBProEx v1009
About 51% boost .It will be very useful with AdvancedLighting which use multiple syncs.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 19th Jul 2017 16:46
Brilliant idea. Having just one sync call is so crucial for performance. I will test your plugin out when I get a spare moment.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Jul 2017 19:50
Likewise. Sounds very useful.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 20th Jul 2017 00:04
I am wondering where this would be useful.
Setting the single camera to draw to additional images when sync'd? Why not just point to the single image?

I see mention of Advanced Lighting. Isn't there a need to take the output of one pass so the second pass can be created, and so on when making advanced rendering effects?
I fail to see how a sole camera writing the same image to 4 indexes would help.
Yet I see reports of speed increases. I must be missing something.
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 20th Jul 2017 00:27
@Mage
AL use one single 32bit camera image to produce all geometry data ( diffuse, normals and materials ) which is fast enough
Still I think it is possible to find implementation for this plugin
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 20th Jul 2017 03:15
Quote: "I fail to see how a sole camera writing the same image to 4 indexes would help."

Did you try the example? The point of multiple render targets is to output different data to each of the four images, not the same image 4 times.

Quote: "Isn't there a need to take the output of one pass so the second pass can be created, and so on when making advanced rendering effects"

That is true for certain post-processing effects, but this could be used for rendering a deferred shading GBuffer which normally consists of re-rendering the same objects to different cameras using different effect techniques. Rendering to multiple targets at once alleviates cpu and vertex shader strain by reducing draw calls.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Jul 2017 10:45
Yep, that's the main advantage which can be worthwhile.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 20th Jul 2017 17:03
So this can make the HDR shader not half the frame rate. The same for reflective water?
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 21st Jul 2017 13:31
@So this can make the HDR shader not half the frame rate
Bloom and HDR shaders use camera sync which must be created one by one
Downscale Image -> Get luminance -> Blur image by x -> Blur image by y -> add to the final image
Each shader technique needs rendered image from previous
So i think that MRT is not useable here
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 21st Jul 2017 16:14
Quote: "So this can make the HDR shader not half the frame rate. The same for reflective water?"

Unfortunately no, as Kuper pointed out HDR works in the way you described where the result of each render is used to texture a screen quad in future renders. Reflection+Refraction shaders like water require rendering the scene from different perspectives, whereas MRTs can only be used to speed up the process of re-drawing objects from the same perspective.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 21st Jul 2017 18:32
Well sounds like its real useful all the same.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 21st Jul 2017 21:08
Updated the first post with a new version, includes two additional commands for detecting gpu capabilities.
I found some time to do a bit more testing and so far everything seems to work as expected. Attached is a simple deferred shading system that was used for testing.

Attachments

Login to view attachments
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Jul 2017 22:31
Updated first post with a new version. Attached a new example to this post demonstrating the speed gains which can be achieved by batching scene objects and lights.

Attachments

Login to view attachments
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 7th Aug 2017 08:56
This plugin has been discontinued will not receive any farther updates. It's functionality has been implemented into a soon-to-be released plugin which combines my ID3DXEffect and MRT tpcs; along with new commands for dynamic cubemapping and gpu-accelerated geometry instancing. The new plugin will be entitled jGfx, and I'm hoping to get it released within the next few days.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 7th Aug 2017 16:33
Looking forward to trying out your new plugin
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Aug 2017 11:14
Same here.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 9th Aug 2017 11:49
You can find it on the program announcements board https://forum.thegamecreators.com/thread/220206

Login to post a reply

Server time is: 2024-04-24 18:06:46
Your offset time is: 2024-04-24 18:06:46