-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Small internal refactor of shader variants handling by renderer #4394
Conversation
Why not call the function |
Why not indeed. I'll make it change. |
Co-authored-by: Will Eastcott <will@playcanvas.com>
…nvas/engine into mvaligursky-getPassShader
if (!drawCall.isStatic) { | ||
const variantKey = pass + '_' + objDefs + '_' + lightHash; | ||
drawCall._shader[pass] = material.variants[variantKey]; | ||
if (!drawCall._shader[pass]) { | ||
this.updateShader(drawCall, objDefs, null, pass, sortedLights); | ||
drawCall.updatePassShader(scene, pass, null, sortedLights); | ||
material.variants[variantKey] = drawCall._shader[pass]; | ||
} | ||
} else { | ||
this.updateShader(drawCall, objDefs, drawCall._staticLightList, pass, sortedLights); | ||
drawCall.updatePassShader(scene, pass, drawCall._staticLightList, sortedLights); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-clarity of this blocks also still bothers be, and I'll refactor it later, probably soon as I might need it. I don't like that the caller of updateShader needs to calculate the variant key, and add the shader to material.variants. This should be completely internal ideally, the key computed from shader options generated, and not on some very few variables. I suspect that at the moment, this does not allow us to have all the variations we need, as the keys are the same for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I can't actually see what material.shader member is used for. Can it just be removed?
Co-authored-by: Donovan Hutchence <slimbuck7@gmail.com>
Co-authored-by: Donovan Hutchence <slimbuck7@gmail.com>
It's used to assign a user defined shader to the instance of Material class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is like excavation! Sorry few more questions.
@@ -879,8 +879,9 @@ class ParticleEmitter { | |||
customFace: this.emitter.orientation !== PARTICLEORIENTATION_SCREEN | |||
}); | |||
this.shader = shader; | |||
return shader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previous line can (should) be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I moved it outside of this function, as that's the consistent way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more of this code needs refactoring, but this is a step in the right direction. approving.
updateShader
togetShaderVariant
, and instead of updating Material.shader, it returns the generated shader variant, and only updates its internal variants cache.