filament icon indicating copy to clipboard operation
filament copied to clipboard

Multiple passes rendering support in one rendering call

Open kaelsass opened this issue 7 years ago • 12 comments

I'd like to implement fur effect described in this post: http://www.xbdev.net/directx3dx/specialX/Fur/index.php The fur need to be rendered layer by layer. In filament API call it may be like this:

if (renderer.beginFrame(swapChain)) {
	for(int layer = 0; layer < layerCount; layer++){
		//update some param
		renderer.render(view);
	}
  renderer.endFrame();
}

The next rendering result needs to be mixed with the previous rendering result. Does Filament support multiple passes rendering in this situation? We try it but it seems that driver.beginRenderPass call will clear the color buffer. If we use View.setClearTargets(false, false, false), we got a blurred screen. Does Filament support multiple passes rendering in this situation? Or are there any other ways for us to implement this feature?

kaelsass avatar Sep 25 '19 11:09 kaelsass

You can render multiple views yes, do you have more details about what you are seeing and what you are trying to do exactly?

You can also check out the bloom sample which shows how to render into offscreen targets. You can render into a target and then use that target as a texture for the next rendering step. This seems like a better approach for your use case than rendering multiple times in the same buffer.

romainguy avatar Sep 25 '19 12:09 romainguy

image I'd like to render like this, layer by layer. Render first layer in the first rendering step, then second layer, then third layer, etc. All layers are using same gltf model and rendering in the same texture. It's hard to render into a target and then use that target as a texture for the next rendering step because the rendering area of different layers are not totally covered, so it's impossible to blend the green area of first layer and second layer as the area of second layer doesn't cover green area. Or should I just add first layer as a renderable entity to the scene?

kaelsass avatar Sep 26 '19 03:09 kaelsass

To do this you should be able to render a View multiple times. You'll definitely want to turn off screen clearing for the second, etc. layers, but keep it on for the first layer. The easiest way to do this is to use multiple View instances (they can share the same camera/scene/etc.). You may also want to turn off post-processing on your view(s).

romainguy avatar Sep 26 '19 08:09 romainguy

We do something like this in our samples for imgui, for an example see these lines of code.

prideout avatar Sep 26 '19 17:09 prideout

note that you'd have to turn off post processing currently, due to a known limitation/bug (we're not blending views when post-process is enabled).

pixelflinger avatar Oct 02 '19 12:10 pixelflinger

You should be able to use custom RenderTargets for this. With recent version of filament all this should be possible.

pixelflinger avatar Jul 07 '21 21:07 pixelflinger

We do something like this in our samples for imgui, for an example see these lines of code.

this link is invalid

dandingol03 avatar Apr 18 '22 10:04 dandingol03

@kaelsass 请教下大佬最后选择了什么方案,multi view?

dandingol03 avatar Apr 18 '22 10:04 dandingol03

Updated link is here, which demonstrates a simple multi-view scenario. For custom blending between layers, you would need to use our RenderTarget API (see our rendertarget.cpp demo for that)

prideout avatar Apr 18 '22 16:04 prideout

setClearTargets

there is no setClearTargets function in View class

dandingol03 avatar May 01 '22 11:05 dandingol03

You can render multiple views yes, do you have more details about what you are seeing and what you are trying to do exactly?

You can also check out the bloom sample which shows how to render into offscreen targets. You can render into a target and then use that target as a texture for the next rendering step. This seems like a better approach for your use case than rendering multiple times in the same buffer.

HI @romainguy , is the bloom sample you mentioned is bloom post-process?

dandingol03 avatar May 01 '22 11:05 dandingol03

@kaelsass 请教下大佬最后选择了什么方案,multi view?

我也想实现fur,可以交流一下么?

toby018 avatar Feb 05 '24 07:02 toby018