pex-gl / pex-renderer

Physically based renderer (PBR) and scene graph for PEX.
https://pex-gl.github.io/pex-renderer/examples/index.html
MIT License
237 stars 16 forks source link

Program has no frag output at location 1 #210

Closed vorg closed 5 years ago

vorg commented 5 years ago

FF Error: WebGL warning: drawElements: Program has no frag output at location 1, but destination draw buffer has an attached image. Ch glDrawElements: buffer format and fragment output variable type incompatible

Screenshot 2019-05-24 at 16 19 16

vorg commented 5 years ago

So it breaks when postprocessing is on (even if all effects are set to false)

vorg commented 5 years ago

It looks like it's a bigger re-engineering because currently I always write to gl_FragData[1] as long as MRT are available. This is messy and I should and shouldn't write there depending on the number or color attachemnts in the parent pass

As the number of params in drawMeshes is already big we should probably switch to opts object at the same time.

vorg commented 5 years ago

Technically this means we need configurable fragment outputs. Eg gl_FragData[0]:color, 1:normal. And if we are there why not allow 0:roughness, 0:AO.. for debugging.. although that could be handled in user space with snippet string replace... our shaders have already too many if defs

vorg commented 5 years ago

Material.frag has #define USE_DRAW_BUFFERS by skybox doesn't.. which causes skybox.frag.js#L58 to never execute and render target at position 1 not written.

vorg commented 5 years ago

Skybox output was first added here https://github.com/pex-gl/pex-renderer/commit/d5740e035b55a425c508f431ebd7fb394ab42b2c#diff-3991c9c3206b207bfd2f9e34f26ad6c5R24 and wrapped in #ifdef USE_DRAW_BUFFERS here https://github.com/pex-gl/pex-renderer/commit/3008f45d1d169e5830fd8ec2e0d2d7089aff16fa#diff-3991c9c3206b207bfd2f9e34f26ad6c5R27