BlackMojito Posted December 19, 2017 Share Posted December 19, 2017 I took a quick look at the source code and it seems that we have no way to update only one element of an uniform array? Just like below.. // in JavaScript at init time var someVec2Element0Loc = gl.getUniformLocation(someProgram, "u_someVec2[0]"); var someVec2Element1Loc = gl.getUniformLocation(someProgram, "u_someVec2[1]"); var someVec2Element2Loc = gl.getUniformLocation(someProgram, "u_someVec2[2]"); // at render time gl.uniform2fv(someVec2Element0Loc, [1, 2]); // set element 0 gl.uniform2fv(someVec2Element1Loc, [3, 4]); // set element 1 gl.uniform2fv(someVec2Element2Loc, [5, 6]); // set element 2 Well I need to hack like this... var locs = engine.getUniforms(material.getEffect()._program, ['test1[0]']); engine.setFloat3(locs[0], 0.0, 1.0, 0.0); Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted December 19, 2017 Author Share Posted December 19, 2017 Another problem I found was that there was no setInt() in class Engine... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 19, 2017 Share Posted December 19, 2017 Hello, are you using the engine directly or are you using the ShaderMaterial? For the latter we can definitely add the required API for you Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted December 20, 2017 Author Share Posted December 20, 2017 4 hours ago, Deltakosh said: Hello, are you using the engine directly or are you using the ShaderMaterial? For the latter we can definitely add the required API for you Hi Deltakosh, Yeah I am using ShaderMaterial, and also the CustomMaterial made by NasamiAsl. I am just hacking by using engine directly. If you add such API, that would be super cool! Thanks Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted December 20, 2017 Author Share Posted December 20, 2017 4 hours ago, Deltakosh said: Hello, are you using the engine directly or are you using the ShaderMaterial? For the latter we can definitely add the required API for you So for now if I would like to use uniform int, I should use an float instead and cast it to float in the shader (for workaround)? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 20, 2017 Share Posted December 20, 2017 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted December 20, 2017 Share Posted December 20, 2017 https://www.babylonjs-playground.com/#UXCB15#23 for customMaterial material.getEffect().setArray3('test1', [ // fs vec3 0.,0.,1, // sc vec3 1,0.,0.]); notice array struct for vec3[2] Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 20, 2017 Share Posted December 20, 2017 Please feel free to open an issue to describe your need so I won;t forget about it Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted December 21, 2017 Author Share Posted December 21, 2017 8 hours ago, Deltakosh said: Please feel free to open an issue to describe your need so I won;t forget about it Sure. It is logged at https://github.com/BabylonJS/Babylon.js/issues/3432. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 21, 2017 Share Posted December 21, 2017 Will work on it asap! 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.