phil1234 Posted October 5, 2015 Share Posted October 5, 2015 Hello, is there any way to create a shader code(v&f) that comes from an ajax request like stored in a variable ?? regards Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 5, 2015 Share Posted October 5, 2015 Hello, a bit of documentation first: http://blogs.msdn.com/b/eternalcoding/archive/2014/04/17/learning-shaders-create-your-own-shaders-with-babylon-js.aspx To answer your question, just copy your shader to BABYLON.Effect.ShadersStore["MyShaderVertexShader"] and BABYLON.Effect.ShadersStore["MyShaderFragmentShader"] Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 5, 2015 Share Posted October 5, 2015 An example here: http://www.babylonjs-playground.com/#BLA36#4 Line 48/49 the shader is defined. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 6, 2015 Author Share Posted October 6, 2015 ok thanksI also noticed by step debugging the engine, that passing shader code in place of <script> tag id should also work, not tested yet Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 7, 2015 Author Share Posted October 7, 2015 I got a problem with code and coments //seems like the code is contatenated into a big line, so everything after the ferst // is discaredone solution is to use /* */ but is there no other way ? like injecting \r\n or something ? [edit : solution in php : str_replace("\r\n", "\\r\\n\\\r\n", $text); ] Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 7, 2015 Share Posted October 7, 2015 Hi Phil, Can you provide an example and paste the code where you're having issues with remarks? (example "//") I'm not certain why this would be causing any issues for you. But if you can post a real example where the script fails, it should be very easy to see what the problem is. DB Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 8, 2015 Author Share Posted October 8, 2015 Hi Phil, Can you provide an example and paste the code where you're having issues with remarks? (example "//") I'm not certain why this would be causing any issues for you. But if you can post a real example where the script fails, it should be very easy to see what the problem is. DB just take any shader(the one in http://www.babylonjs-playground.com/#BLA36#4) and add a comment with // I mean it's quiet predictable, since if there is no line break, there is noway for the compiler to wknow where comments stops and new line starts to solve this I had to add \n\r inside the string, and voilà(the shader code is read in php and injected in javascript code) Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 8, 2015 Share Posted October 8, 2015 Hi Phil, I must not understand at all what problems you are running into. I added dozens of remarks in your playground script, and in pllces where I thought I might have a problem completing a line. I looked at the shaders, and couldn't break them either. I saved out a layground scene, however, it's simply a bunch of remarks placed in random lines as well as potentially problematic lines. But it's so remedial, I won't post unless you ask - but it's really is a worthless example. As I must be misiing the point here, I'll let the dialogue continue, and see what others say concerning your issues. By the way, the scene is a practicle example of a useful shader for many types of projects and scenes. It looks great and works well. Cheers, DB Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 9, 2015 Author Share Posted October 9, 2015 Hi Phil, I must not understand at all what problems you are running into. I added dozens of remarks in your playground script, and in pllces where I thought I might have a problem completing a line. I looked at the shaders, and couldn't break them either. I saved out a layground scene, however, it's simply a bunch of remarks placed in random lines as well as potentially problematic lines. But it's so remedial, I won't post unless you ask - but it's really is a worthless example. As I must be misiing the point here, I'll let the dialogue continue, and see what others say concerning your issues. By the way, the scene is a practicle example of a useful shader for many types of projects and scenes. It looks great and works well. Cheers, DB ??? ok whatever, I dont really follow you, we're like chating at the wrong frequencies or somethingnevermindI could make it work anywaysheers 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.