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
234 stars 16 forks source link

Basic materials #262

Closed vorg closed 1 year ago

vorg commented 4 years ago

PEX Renderer is proudly "PBR-First". But this turns out to be quite heavy for development and basic dataviz scenarios. We have unlit but cheap materials like simple diffuse or matcap could help reduce number of cases where we fallback to pex-context.

dmnsgn commented 4 years ago

Question: should they be part of the core or an update to https://github.com/pex-gl/pex-materials?

simonharrisco commented 4 years ago

Definite +1 from me, especially for webxr this would be super useful.

vorg commented 4 years ago

@dmnsgn pex-materials are nice starting point but meant to be used with raw pex-context.

To use them with pex-renderer they would need to be split into chunks so I can e.g. import vec4 matcap(sampler2D tex, vec3 n) function and then inject into customized pex-renderer material using the right uniforms and variables like data.normalView.

While that patching could be done in e.g. custom MatCapMaterial node (when in Nodes) it would require significant work to support more advanced renderer features like SSAO or shadowmapping. Although that again should be simpler in the future. I wonder how flexible Node based material in ThreeJS is for this kind of cherrypicked shader development.

Another downside of making this kind of simpler materials by string replacing chunks in PBR shader is that while lighting model is simpler it's still a mega uber shader that depends on GLSL compiler to remove unused code and uniforms during compilation. Also our render pipeline still collects all the possible uniform data even if shader ends up not using it e.g. reflection probes and light colors are saved in uniforms array of material with unlit: true. At least the data will be not sent as we submit only active uniforms to the GPU

dmnsgn commented 1 year ago

Duplicate #311