Hi, I am trying to implement own deferred rendering and I wonder if there is a way to apply shader to whole scene. I am able to create gPosition texture by applying ShaderMaterial to every object but I guess it’s like scratching over head when I import model from Blender where might be thousands objects.
I can imagine applying that shader directly for renderFragment or retrieving geometryBuffer for whole scene that I pass to shader.
Maybe Scene.overrideMaterial can simplify your workflow. In this way, you don’t have to replace each material manually. This property is frequently used in post-processing related code.
I have additional question. Since I override all materials, how could I get data of original materials to create albedo texture for gBuffer? I thought about making one more render pass before I override materials and create texture from it that I input as uniform sample2D. But at first I think there has to be better way and at second albedo shouldn’t be affected by light, but that way it would be black.
*Edit → Maybe the “pre-render” pass could be good idea. Do that with forward rendering and hopefully achieve anti-aliasing and transparent materials, use just ambient light for that since that one is shining all the time and in second render pass fill gBuffer other textures and in third calculate lights. Is that totally dumb or am I up to something ?
I thought about making one more render pass before I override materials and create texture from it that I input as uniform sample2D.
That should do the trick.