Closed Spiri0 closed 4 months ago
When you configure in webgl2_multiple_rendertargets the render target with a count of 3
, the following WebGL warning in the console appears:
GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs.
The issue could be fixed by making sure the object's shader writes data to the new layout(location = 2)
. Or by not rendering the object at all.
I'm not sure if the engine should automatically handle this use case. It seems to me the the developer instead is responsible to configure its scene correctly. So if you have objects with different shader outputs in your scene, you could
a) create multiple scenes and render them separately with different render targets.
b) use Layers
or Object3D.visible
and configure the objects with a respective value that you want include/exclude from rendering.
The problem is that objects with non-matching outputs are some sort of invalid input for MRT in the first place. It must be defined how objects are treated if they write e.g. no normal or velocity values and that is an application specific thing.
I use different layers. But your comment is correct because that's exactly why I introduced the layers and I use 4 of them. According to logic there should be no conflicts.
Yesterday I worked more intensively on the readRenderTargetPixels topic. To do this, I have to familiarize myself with webgl much more intensively. I actually only deal with WebGPU
Please take the issue out so I can examine it more intensively with the layers.
I'm juggling with a little too many topics at the moment and am becoming less attentive as a result. I'm usually very thorough with my analyses. I'll slow down a bit.
Don't worry! The discussions here at GitHub are also intended to sort out one thoughts.
Description
I use the outputStruct node to be able to store the result of several shaders with a renderTarget in textures. Everything works perfectly so far. If you have several objects in the scene you have to render the relevant object that uses several shaders directly in the renderTarget if not all objects have several shaders.
The reason is because the renderTarget expects the same count of shaders from all objects in the scene as in the renderTarget count. As a rule, you only want to equip certain objects with multiple shaders. So if you have an object in the scene that uses two shaders and one that only uses one, then there will be endless warnings in the console because the renderTarget also expects two shaders from the second object.
If you have a complex dynamic object hierarchy and use groups for it, unfortunately it doesn't work with direct rendering because groups aren't objects and it has to be the scene.
Solution: With a count > 1, the renderTarget must ignore objects with only one shader when processing count 2. Analogously with a count of 3 if an object only has 2 shaders
Reproduction steps
Code
Live example
[* jsfiddle-latest-release
Screenshots
No response
Version
r163
Device
No response
Browser
No response
OS
No response