unicomp21 Posted August 28, 2015 Share Posted August 28, 2015 Need help on this one, trying to create a custom procedural texture, need access to the varying vPositionW, which I'm assuming is the lerp of the world vertex position. Thanks! This is the simple case I'm trying to get working, get link errors on vPositionW. "#ifdef GL_ES\n" +"precision highp float;\n" +"#endif\n\n" +"varying vec3 vPositionW; \n" +"void main(void) {\n" +" gl_FragColor = vec4(vPositionW.x,vPositionW.y,vPositionW.z, 1.0);\n" + Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 28, 2015 Share Posted August 28, 2015 can you please provide a playground demo? Quote Link to comment Share on other sites More sharing options...
unicomp21 Posted August 29, 2015 Author Share Posted August 29, 2015 Not sure I understand. I'm failing to get it to work. I should put together my code, that doesn't work, and issue a pull request? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 29, 2015 Share Posted August 29, 2015 Hi unicomp21! It's not common for people to work-on shaders in the Babylon Playground, so I thought I'd show you a tasty shader-playground that forum user hw3web was working-on. (and lots of others, too) I believe these shaders and this water effect originally came from the World Monger demo and the "How to Create a Convincing World" tutorial. http://playground.babylonjs.com/#R894C The "original" is at http://playground.babylonjs.com/#BHX7Q#16 but I figured I would start a fresh one for you. The playground is a great place to do experiments and hit RUN over and over again, saving and bookmarking the new save location, every so often. When you discover something interesting or telling, save it, and paste the new url to this thread... and tell us what you discovered. (so everyone can learn) Keep in mind that textures used in the playground must be CORS-clear. Textures from wikiMedia commons or from the playground's textures/ folder will work fine. Any CORS-clear image should work. When an image IS BLOCKED by CORS, the playground won't report that. The image will just silently fail to load, but maybe check your browser's dev tools. Possibly, the failed texture load will be reported in that area. I wish I knew more about shaders, but, sorry. I sometimes hear things like "time is the only variable that is passed to the shaders automatically". I'm not overly sure what that means, but maybe you or others do. I think I have seen someone set a shader's time vary-able from within a renderLoop... which means it can be over-ridden. In other words... just because the vary-able is named 'time' does not mean you have to let it be "fed" by scene elapsed time (the default). MAYBE, you can make "pokes" to the shader's time vary-able with anything, and at any rate (every frame, every 4th frame, only when an event happens, etc). YOU could control the speed of 'time'. Don't mark my words... I'm not shader-trained.... yet. Maybe YOU will help me with that. Anyway, now you have seen a Babylon Playground with shaders in the code. Try to make a playground similar to the one above... that shows your problem. That will assist the shader experts in helping you find the problem. Good luck, be well. Quote Link to comment Share on other sites More sharing options...
unicomp21 Posted August 29, 2015 Author Share Posted August 29, 2015 Thanks Wingnut! I'm clear now, here's the url. http://playground.babylonjs.com/#24PO9L Look at the commented lines in the shader, I need a UVW corresponding to world space coords of vertex so I can index into more complex 3D procedural textures, and splat them to this render-to 2D texture. The idea would be using quad patches in the mesh and rendering them into the 2D procedural texture as squares. Make sense? Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 29, 2015 Share Posted August 29, 2015 Hell no. Oh wait, maybe. First, you'd have a procedural texture grid... available... one of the coolest ways to make a grid that I've heard-of. But... hmm... You could make a fake heightmap grid, too, I think. A fake mountain in the middle of a grid... that isn't really there? A shader is making it LOOK like it's really a mountain? (ie. more complex 3D procedural textures) Yeah, I think I'm on your frequency, or in the vicinity. I hope you're going to teach us what you learn, and show us lots of demos. And I KNOW the BJS procedural texture library is wholeheartedly welcoming new additions. I'm excited! You sound determined to kick butt! You've been to CYOS, right? Suggestions or code to add new features to CYOS... are most-welcome, too. Yeah, we're all watching, UC. Show us everything! Oh yeah, and I hope you get your issues answered. Quote Link to comment Share on other sites More sharing options...
unicomp21 Posted August 29, 2015 Author Share Posted August 29, 2015 Thanks Wingnut, will do my best. Deltakosh, is it clear what I'm trying to do? ie index something like 3D perlin noise w/ a UVW derived from vertex position, and splat to texture Quote Link to comment Share on other sites More sharing options...
unicomp21 Posted August 29, 2015 Author Share Posted August 29, 2015 Having a world normal would be useful too for generating bump map procedural texture. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 30, 2015 Share Posted August 30, 2015 Hi again! While you are waiting for experts to reply, maybe http://urbanproductions.com/wingy/babylon/ACP/acp_pretty.js will be helpful for you someday. This is the main code (pretti-fied) for the Assassin's Creed - Pirates game from the BJS website. About 1/3 down the page... is a pile of shader code... messy, but still quite steal-able. This project uses structures called jsm's (apparently). It looks a bit strange, but interesting. That's mostly irrelevant, but DO notice the many jsm modules AFTER the shaders... with 'Type': ["Shader"]. With a little bit of bushwhacking... you can determine which shaders bind to which scene items/mats. I don't know if answers to your questions can be gotten from that, but I thought I would show it to you. Maybe none of them use positions... I haven't investigated them at all. I am simply collecting shaders for when unicomp21 creates our new and exciting BabylonJS Shaders Tutorial! YAY! It will be featured in the little help menu at CYOS. Yay! Am I being pushy? I hope so. heh. Ok, now back to our show. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 31, 2015 Share Posted August 31, 2015 Hey this is clear, but I think you may want to use custom materials instead of custom procedural textures. Procedural textures are more about generating a single texture and I'm wondering if you want to simply generate a texture and then use it with a material OR just develop your own material? (BTW custom material are far more flexible) For custom material:http://doc.babylonjs.com/tutorials/15._Understanding_Shaders_with_Babylon.js_and_ShaderMaterial Wingnut 1 Quote Link to comment Share on other sites More sharing options...
unicomp21 Posted August 31, 2015 Author Share Posted August 31, 2015 The computation intensity of my shader(s) is too high to run every frame. I need video memory backed persistence of the resulting texture. Will custom materials still fill my need? Quote Link to comment Share on other sites More sharing options...
unicomp21 Posted August 31, 2015 Author Share Posted August 31, 2015 Looks like my need is to generate a texture and use w/ a material. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 31, 2015 Share Posted August 31, 2015 you're right: if you need computation intensive stuff,then custom procedural textures is the way to go But in this case you have to replace the vertex shader by default (https://github.com/BabylonJS/Babylon.js/blob/master/src/Shaders/procedural.vertex.fx) by one defined by yourself Quote Link to comment Share on other sites More sharing options...
unicomp21 Posted September 1, 2015 Author Share Posted September 1, 2015 Thx David! 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.