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
Material shader assembly system (v0.6.5) #32
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RenderDoc says no error but when an actual drawcall is issued, pipeline viewer says 'no vertex shader bound'. What on earth is happening :/
glShaderSource() must end with '\n'. - Fix wrong calculation of vertex position offset.
- Set texture parameters for materials.
Let's debug in Nsight as RenderDoc says nothing
Now I can delete triplanar mapping code from PBRTextureMaterial.
- Resolve unlit after lighting passes.
This time not a driver bug but my silly typo. Also fix a case where material UBO size is zero.
Material template now supports both deferred shading and forward shading. Currently opaque materials always use deferred shading path, and translucent materials always use forward shading path. If I abstract lighting calculation further, I'm finally able to support full forward & deferred shading pipeline both!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This system needs more refinement but I'm so exhausted. Merging now as basic functionalities are working.
Initial backlog
Currently all material shader variations are hard-coded.
I can't make a full GUI-based material editor now, but at least let's make a material assembler that generates material shaders.
Material shaders only define specialized things - vertex position offset, texture input, Gbuffer attributes, so on. Common code is provided by a material template.
The assembler generates final material shaders, replacing various parts of a material template with a given concrete material.
Complete rework of material shader management
Previous implementation defined a hard-coded base pass shader, a subclass of
Material
, and a corresponding render pass class.For example, for a material that samples PBR textures:
deferred_pack_pbr_texture_vs.glsl
deferred_pack_pbr_texture_fs.glsl
class PBRTextureMaterial : public Material { ... };
class Deferred_Pack_PBR_Texture : public Deferred_Pack_Base { ... };
These things were defined for each material type, and I also had to add ad-hoc logic for depth prepass and shadowmap pass if a material has non-trivial depth only shader (that is, final position is not just MVP * localPosition, due to vertex animation or manual control of gl_FragDepth, etc.).
Everything above is now gone. No separate VS/FS shaders, no subclasses, no separate render pass classes.
MaterialShader
s.Material
, it is related to aMaterialShader
.Material
clones uniform and texture parameters info from itsMaterialShader
.Material
s are created from the sameMaterialShader
, they have different instance IDs. Even if twoMaterial
s have the sameMaterialShader
, they can have their own parameters.In rendering pipeline, mesh batches are split into an opaque mesh list and a translucent mesh list. Each list is first sorted by material shader, then by material instance ID. The opaque list is rendered in depth prepass and base pass. The translucent one is rendered in translucency pass.
TODO