Closed QuantumEntangledAndy closed 2 years ago
Looks good to me and this is definitely not the last change in pbr/lighting code
We seem to be using something like jinja templating.
Have we considered about using the tera
crate for formally providing a templating engine. We could fill it will all our own includes and provide the Tera struct for users to extend too. If we pass code through Tera when we load a shader it will error early if there are any missing {{ binding }}
that would otherwise error at the Naga level with a perhaps harder to interpret message. We could also provide perhaps some common useful functions and use jinja templates and code to help write our shaders.
Yeah, exactly, I was thinking about using a template engine. At the time of PBR implementation I decided to use DUMB solution. Thank for the reference, I will check the tera
crate.
I am using tera
in #152 already so maybe look at how it works there would help too.
This adds features from https://github.com/lowenware/dotrix/pull/152 that I am adding here to make the PRs more modular
Mostly this is some house keeping in the lighting, that makes it easier for other modules to use the light code
light.inc.wgsl
calculate_nth_light_ray
pbr.inc.wgsl
where what used to be four for loops one for each type of light is now reduced to a single looplight.inc.wgsl
andpbr.inc.wgsl
light.inc.wgsl
I would also like to discuss moving Lights (and their
light.inc.wgsl
) into core and leaving onlypbr.inc.wgsl
indotrix_pbr
but feel that should be another PR