royibernthal Posted April 27, 2018 Share Posted April 27, 2018 How do I trigger shader compilation for: -Particles -HighlightLayer with inner and/or outer glow -Custom made shaders - what are the guidelines to finding how to trigger a specific shader? For instance, in order to trigger a light shader compilation for a mesh you'd need to push that mesh into Light/includedOnlyMeshes and wait for material.isReady(mesh). JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted April 28, 2018 Share Posted April 28, 2018 Sorry I was completely focus and forgot to answer you: - Particles: call particleSystem.effect.isReady() - HighlightLayer: call layer.currentEffect.isReady() - Custom shaders: just all material.isReady(mesh) Quote Link to comment Share on other sites More sharing options...
royibernthal Posted April 28, 2018 Author Share Posted April 28, 2018 No problem HighlightLayer - by layer.currentEffect are you referring to EffectLayer/_mergeEffect which is locally referred to as currentEffect in EffectLayer/render()? Other than that I can't see a currentEffect. So this is how I check if they're ready, how do I trigger them? Particles - ? -HighlightLayer - highlightLayer.addMesh()? -Custom shaders - applying the shader material to mesh? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 28, 2018 Share Posted April 28, 2018 I'm referring to currentEffect in EffectLayer/render particles: you need to call animate() to trigger the compil HL: no need to trigger it is automatic Custom shaders: yes royibernthal 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 5, 2018 Author Share Posted May 5, 2018 1) Would it make sense to trigger hemi light shader compilation with a different hemi light instance than the one used later on? Would the same answer apply to other lights, highlightLayer and particleSystem? I'm asking this because it seems like the same shader is compiled regardless of instance or even settings like light direction. 2) It seems that EffectLayer/_mergeEffect.isReady() only takes into account meshes that are currently displayed in the scene, correct me if I'm wrong. I'd like to trigger HighlightLayer shader compilation for meshes that are not yet displayed in the scene. I gave addMesh() a try anyway but it didn't really help much. How should I go about it? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 10, 2018 Share Posted May 10, 2018 1. Yes no problem 2. Yeah you need to add them..sorry about that Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 10, 2018 Author Share Posted May 10, 2018 1. Okay great 2. On 5/5/2018 at 10:30 PM, royibernthal said: I gave addMesh() a try anyway but it didn't really help much. Is there something else perhaps that I need to take into account? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 10, 2018 Share Posted May 10, 2018 If you are talking about the shader I developed for you msg me. I know the answer. Its because some of the shaders variables are on defines and need to be migrated to a uniform, so different instances can have different settings. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 10, 2018 Author Share Posted May 10, 2018 I'm talking about HighlightLayer, we'll get to manually triggering compilation for the shader you created as well once it's up and running Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 12, 2018 Author Share Posted May 12, 2018 On 5/10/2018 at 10:52 PM, royibernthal said: 1. Okay great 2. I gave addMesh() a try anyway but it didn't really help much. Is there something else perhaps that I need to take into account? DK? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 14, 2018 Share Posted May 14, 2018 Can you repro on the PG? Will help me find the good way to update Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 15, 2018 Author Share Posted May 15, 2018 How can we see in the PG which shaders are compiled? In a local project I can add logs to bjs source Quote Link to comment Share on other sites More sharing options...
Guest Posted May 15, 2018 Share Posted May 15, 2018 Just use engine.onBeforeShaderCompilationObservable JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 16, 2018 Author Share Posted May 16, 2018 After some debugging I noticed that the meshes were (intentionally) removed from the scene beforehand, which caused the highlight shaders to not compile. (Although for some reason it didn't stop light shaders from compiling) Is this the equivalent of Engine/createEffect()/name in engine.onBeforeShaderCompilationObservable/onAfter...? engine.onAfterShaderCompilationObservable.add((e) => { setTimeout(() => console.log(e._currentEffect._key)); }); e._currentEffect is not defined immediately in the callback, am I likely to miss some shader compilations by setting a timeout? Is there a parameter which is defined at the moment of the callback? Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 17, 2018 Author Share Posted May 17, 2018 More questions: 1) Do GPU and CPU ParticleSystems need to compile different shaders? 2) Does a ParticleSystem need to have a texture and an emitter assigned in order for shader to be compiled? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 17, 2018 Share Posted May 17, 2018 1/ Yes 2/ No:) Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 17, 2018 Author Share Posted May 17, 2018 Weird, it doesn't trigger compilation for me, I'll try to repro in PG. Can you please also answer the questions in the previous reply? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 17, 2018 Share Posted May 17, 2018 Well I agree that the observables are not providing enough info here. The timeout could be the right way but it needs testing Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 17, 2018 Author Share Posted May 17, 2018 Got it. 1) Can I see particles shader info anywhere else except for _compiledShaders? I'm asking because _currentEffect is null when particles are compiled. 2) It seems for CPU ParticleSystem, the shader is compiled in the PG simply by creating an instance, animate() is not required. http://www.babylonjs-playground.com/#7UJDBL#1 In my local project though, the only way it works is if I'm setting an emitter and calling start(). If an emitter is not set or if it's set and animate() is called instead of start() - no shader is compiled. It appears as if it's only compiled when particles are actually being rendered in the scene (which is not good for my purposes). Any idea why that might happen? I haven't tested yet GPU ParticleSystem. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2018 Author Share Posted May 24, 2018 bump Quote Link to comment Share on other sites More sharing options...
Guest Posted May 25, 2018 Share Posted May 25, 2018 1/ it should be in particleSystem._effect 2/ You can manually force it with particleSystem._getEffect() Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 28, 2018 Author Share Posted May 28, 2018 I think it works for CPU. What should I do for GPUParticleSystem? I tried this to trigger: particleSystem._recreateUpdateEffect(); particleSystem._recreateRenderEffect(); and this to check if ready: particleSystem._updateEffect.isReady() && particleSystem._renderEffect.isReady(); I don't see any shader compiled for it. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 29, 2018 Share Posted May 29, 2018 This is fine: particleSystem._recreateUpdateEffect(); particleSystem._recreateRenderEffect(); and to check just run particleSystem.isReady() Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 2, 2018 Author Share Posted June 2, 2018 It does not seem to trigger compilation: http://www.babylonjs-playground.com/#7UJDBL#3 particleSystem.isReady() also requires having an emitter and a texture Quote Link to comment Share on other sites More sharing options...
Guest Posted June 4, 2018 Share Posted June 4, 2018 sure but you can fake them right? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.