startec Posted September 29, 2015 Share Posted September 29, 2015 I am basically asking the Babylon.js equivalent of this:http://stackoverflow.com/questions/15663859/threejs-predefined-shader-attributes-uniforms/15664900#15664900 In the tutorials I see that there are some uniforms supplied from the application code (like uniforms and view matrices) is there a place somewhere where the things that are provided automatically are documented? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 29, 2015 Share Posted September 29, 2015 yes sir:) http://blogs.msdn.com/b/eternalcoding/archive/2014/04/17/learning-shaders-create-your-own-shaders-with-babylon-js.aspx Quote Link to comment Share on other sites More sharing options...
startec Posted September 29, 2015 Author Share Posted September 29, 2015 Thanks for the prompt reply. I am really looking forward to working with Babylon.js! GameMonetize and NasimiAsl 2 Quote Link to comment Share on other sites More sharing options...
SpaceToast Posted December 26, 2017 Share Posted December 26, 2017 Dead link. Has this been added to the documentation? I wasn't able to find it. If not, maybe someone wouldn't mind pasting the relevent information into this thread for posterity's sake? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted December 27, 2017 Share Posted December 27, 2017 witch link? Quote Link to comment Share on other sites More sharing options...
SpaceToast Posted December 27, 2017 Share Posted December 27, 2017 (edited) Kosh's link. Based on the CYOS examples, I can verify that the following are available: // Attributes attribute vec3 position; //vertex x,y,z attribute vec3 normal; //normal x,y,z attribute vec2 uv; //uv (texture map) 2d coordinates // Uniforms uniform mat4 world; //convert from model space to world space uniform mat4 view; //convert world space to camera-relative space uniform mat4 projection; //flatten camera space to frame view uniform mat4 worldView; //world and view, pre-multiplied for you uniform mat4 worldViewProjection; //world, view & projection pre-multiplied uniform sampler2D textureSampler; //texture data uniform vec3 cameraPosition; //camera x,y,z uniform float time; //time Are there any predefined shader attributes or uniforms that I'm missing? Edited January 2, 2018 by SpaceToast Edited with more uniforms, from digging through built-in shaders Quote Link to comment Share on other sites More sharing options...
SpaceToast Posted January 2, 2018 Share Posted January 2, 2018 (Edited out into its own post, because, messiness.) A further discovery I'd love to have verified: It appears that the uniforms above do not need to be declared when creating a shaderMaterial -- Babylon.js supplies them for you. So rather than declaring: var shaderMaterial = new BABYLON.ShaderMaterial("shader", scene, {vertex: "custom", fragment: "custom"}, {attributes: ["position", "normal", "uv"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"]} ); You can omit the attributes section, unless supplying your own custom data to the shader: var shaderMaterial = new BABYLON.ShaderMaterial("shader", scene, {vertex: "custom", fragment: "custom"}, {attributes: ["position", "normal", "uv"], uniforms: ["capybaras"]} ); 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.