Pryme8 Posted July 18, 2018 Share Posted July 18, 2018 https://www.babylonjs-playground.com/#NAG06Y#70 "Error: Varyings with the same name but different type, or statically used varyings in fragment shader are not declared in vertex shader: nUV" Not sure why I am getting this error, the two fragments in question are at the top of the file. Here is the desired result: https://www.babylonjs-playground.com/#NAG06Y#71 The thing is normally just adding a varying two both of the fragments makes it work, gotta be missing something simple. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 18, 2018 Share Posted July 18, 2018 Only thing I could see is the nUv.xxx. shader compiler seems to not want to allow that - maybe incorrectly thinks it's a vec3? https://www.babylonjs-playground.com/#NAG06Y#74 edit: no, i was wrong Interestingly a different message in Firefox. Error: Varying `nUV` has static-use in the frag shader, but is undeclared in the vert shader. https://dxr.mozilla.org/mozilla-beta/source/dom/canvas/WebGLShaderValidator.cpp#363 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 19, 2018 Share Posted July 19, 2018 the error comes from the postprocess; https://github.com/BabylonJS/Babylon.js/blob/master/src/Shaders/postprocess.vertex.fx https://doc.babylonjs.com/api/classes/babylon.postprocess#useownoutput don't ask me any further i don't use postprocess, have no idea how you can make it fully functional dbawel and brianzinn 2 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 19, 2018 Share Posted July 19, 2018 @Nabroski I just renamed the varying and that error went away. Thanks! Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 I was under the impression that it should use the vertex shader that is matching in name to the fragment. If not then looks like Im gonna have to figure something out. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 19, 2018 Share Posted July 19, 2018 yes you right, but you in the default vertex so the debugger prints the right error: FRAGMENT varying ...etc. becourse, and i say it again, you in the default VERTEX of babylonjs postprocess shader, see link i shared. https://www.babylonjs-playground.com/#NAG06Y#82 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 19, 2018 Share Posted July 19, 2018 55 minutes ago, Pryme8 said: should use the vertex shader that is matching in name to the fragment You are right. I checked my projects and I have many different shaders using "varying vec2 vUV;". I think I had already commented out your post process, so that's why the effect was compiling for me. Looks like maybe something in the post process is clobbering your shader code or removing the varyings? Would be nice if there was a way to see the full shader program, because what you have looks OK to me. I really want to see where the voodoo is here... Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 https://github.com/BabylonJS/Babylon.js/blob/master/src/PostProcess/babylon.passPostProcess.ts I think this is the culprit. the super defaults to "pass" *EDIT* Nevermind found it: https://github.com/BabylonJS/Babylon.js/blob/master/src/PostProcess/babylon.postProcess.ts#L243 * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess") Quote Link to comment Share on other sites More sharing options...
Guest Posted July 19, 2018 Share Posted July 19, 2018 So:) You cannot reuse the same fragment for a material and a postprocess: https://www.babylonjs-playground.com/#NAG06Y#83 The postprocess assumes that you only provide the fragment shader (the associated vertex shader is provided by babylon.js: https://github.com/BabylonJS/Babylon.js/blob/master/src/Shaders/postprocess.vertex.fx) So as you do not provide the vertex shader, you cannot add varyings in your fragment. brianzinn, dbawel and Pryme8 1 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 Nope, it was using the nUV vec2 that was declared in the main loop not the varying. https://www.babylonjs-playground.com/#NAG06Y#88 Here is my "working" setup which does not allow me to define any varyings https://www.babylonjs-playground.com/#NAG06Y#96 And then here is the post Process with a custom vertex defined in it constructor, which seems to break it all https://www.babylonjs-playground.com/#NAG06Y#97 I have also tried your above suggestion, with not reusing but that did not fix it as well. Can anyone tell me what #97 is saying in the spector report? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 I mean honestly its not important, cause the work around is to just define the nUV var that I want in the main loop or as a define so Im not to pressed. But it would be cool to work out some of this for future/more dynamic problems. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 19, 2018 Share Posted July 19, 2018 Well even in your #97 you are sharing the same fragment between Postprocess and material and as I mentioned before this is not possible. Postprocesses have a already defined vertex shader that you can't change so fragment shader used with postprocesses CANNOT add varyings Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 I did a version where they were not sharing the same ones and it gave me the same results. Also the post process has a constructor argument for a custom vert shader but I can not seem to get it to work correctly. https://www.babylonjs-playground.com/#NAG06Y#100 ^ as demonstrated by this. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 https://github.com/BabylonJS/Babylon.js/blob/master/src/PostProcess/babylon.postProcess.ts#L336 bet if I add uv to this line it would fix things.... <-actually it would not because there is no uv data to be passed for this. BUTTTTTTT I GOT AN IDEA. 1 second. Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 19, 2018 Share Posted July 19, 2018 I hate waiting...? I've called and left messages, but haven't heard from you in a while. DB Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 https://www.babylonjs-playground.com/#NAG06Y#101 POWER LEVEL OVER 9000!!!!! @Deltakosh Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 11 minutes ago, dbawel said: I've called and left messages, but haven't heard from you in a while. I'm impossible to get a hold of these days. I leave my phone at home as to not get distracted by life. Email is the best method brother ^_^. dbawel 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 19, 2018 Author Share Posted July 19, 2018 So this is "solved" The reason for the error that I was experiencing while trying to define a custom varying was that I was referencing an attribute that effectively would never be bound because that data does not exist in the postPass due to there not being geometry and only really being in screenspace coordinates. Which essentially make the positions attribute a vec2 in the postPass and I was trying to bind to the wrong attribute. -> lost of headache over something that honestly does not matter... smh, cause honestly how much more performance am I getting out of using the attribute vs defining it in the main for a single frame being processed.... It was more a matter of principal. brianzinn 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted July 20, 2018 Share Posted July 20, 2018 Well, good job!!! 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.