Can I implement deferred rendering?

I don’t confirm if Defold support multiple render target, I need write vertex position, normal, albedo and specular value into render target.

There’s no engine support for MRTs out of the box (yet), but you can pack your vector values into a float texture. It’s not universally supported and I think that the enum value isn’t exposed so you kind of need to know the magic number… Perhaps @sven knows if this would work or not :slight_smile:

Greetings!
It’s 2022, it’s time to remember the MRT, God bless it.

MRT is pretty critical for PBR with most post effects.
On the one hand, of course, Defold is not a 3D engine. On the other hand, if it had the right features, it would be very good in 3D.
Also relevant is the question of float textures. Such textures could make the lack of MRT easier. Also, I need them for cluster lighting.

Tell me something good. Please…

2 Likes

OK, I can do without MRT (using the method known as Forward+ rendering). But in doing so, I need to do an extra render pass with geometry, for which it would be a good idea to disable texture samplers to optimise. Or use on the same geometry shader without texture sampling.
But that would require going through all the models and rearranging their materials. That’s not a good idea. Is there any way to globally change the material? Or disable texture sampler (usually implemented within the engine)?

Floating point render targets will be investigated in this or the next release:

You can change the material used when drawing using render.enable_material().

7 Likes

Holy news! May the developers of Defold be praised!
A lot can be done with float rendertarget!

GL_RGBA32F contains 96 bits that can be used for useful purposes. Unfortunately, it would be impossible to use the alpha channel without EXT_blend_func_separate (https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_blend_func_separate.txt).

But I’d still like to know about MRT…

5 Likes

I’ve done a MRT exploration previously, which worked fine but I wonder if it requires extensions or not. I honestly can’t remember :thinking:

1 Like

As for float textures specifically, I personally would be more comfortable with a GL_RGBA32UI texture, as an integer texture won’t have bit loss due to floating point.
Actually I think it’s a more versatile solution than float textures, as a 32 bit integer can easily be converted to float number in a custom shader.

Please share your knowledge.
I would like to use these features in my pet project for mobiles.

3 Likes

Well, this is the commit for the MRT exploration, but we can’t just merge this in as-is I think:

We have to discuss how such a feature would be implemented “for real” I think. Ping @JCash @britzl :thinking: Just by having a quick glance at the code, API wise this commit exposes an index to the render script so when you bind a render target you can pass an index to which render target you want to draw to and then when it gets bound for drawing you can bind the backing textures to different samplers.

What do you need more specifically in terms of rendering support?

5 Likes

This is roughly how i saw the situation when i was digging through the engine’s source code. Unfortunately, there’s no way this can be made into a separate extension.

1 Like