Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes/Lighting refractor #158

Merged
merged 2 commits into from
Apr 19, 2022
Merged

Conversation

QuantumEntangledAndy
Copy link
Contributor

@QuantumEntangledAndy QuantumEntangledAndy commented Apr 16, 2022

This adds features from #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

  1. Reduce repeated code in light.inc.wgsl
  • Done with a kind of iter funtion over any light objects calculate_nth_light_ray
  • You can see the improvment in pbr.inc.wgsl where what used to be four for loops one for each type of
    light is now reduced to a single loop
  1. Seperate lighting and pbr code into light.inc.wgsl and pbr.inc.wgsl
  2. Remove redundant normal vector in light.inc.wgsl

I would also like to discuss moving Lights (and their light.inc.wgsl) into core and leaving only pbr.inc.wgsl indotrix_pbr but feel that should be another PR

@QuantumEntangledAndy QuantumEntangledAndy changed the title Lighting fixes/Lighting optimisation Apr 18, 2022
@QuantumEntangledAndy QuantumEntangledAndy changed the title fixes/Lighting optimisation fixes/Lighting refractor Apr 18, 2022
@voxelias
Copy link
Member

Looks good to me and this is definitely not the last change in pbr/lighting code

@voxelias voxelias merged commit 7d862ac into lowenware:main Apr 19, 2022
@QuantumEntangledAndy
Copy link
Contributor Author

QuantumEntangledAndy commented Apr 20, 2022

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.

@voxelias
Copy link
Member

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.

@QuantumEntangledAndy
Copy link
Contributor Author

QuantumEntangledAndy commented Apr 20, 2022

I am using tera in #152 already so maybe look at how it works there would help too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants