Jump to content

No way to update only one element of an uniform array


BlackMojito
 Share

Recommended Posts

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);
Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...