Jump to content

vec3 uniforms array into shader


PyroStunts
 Share

Recommended Posts

I would like to create an array of colors in my shader code. What is the correct way to do this. Apparently you can't code this directly into the shader, but doing it via uniforms is supposed to work. The following code I have returns this error message in the console:

Pixi.js Shader Warning: Unknown uniform type: undefined

This is my shader code:

precision mediump float;
uniform vec3 cols[127];
uniform float screenHeight; 
uniform float screenWidth; 
void main(){
    //Not implemented yet
    gl_FragColor =vec4(1.0,1.0,1.0,1.0);
}

And my JS code which is supposed to set up the uniforms:

uniforms.screenHeight = {type:"f",value:dims.width};
uniforms.screenWidth = {type:"f",value:dims.height};
var cols =["0B5624", /* 125 more colors*/ "5B5A57"];
var mycols = [cols.length] ;
for(var i=0; i<cols.length; i++){
     mycols[i] = {type: "v3v", value:[(hexToR(cols[i])/256).toFixed(2),
                                      (hexToG(cols[i])/256).toFixed(2),
                                      (hexToB(cols[i])/256).toFixed(2)]};
}
uniforms.cols = mycols;
shady = new PIXI.AbstractFilter('',myShaderCode,uniforms);

 

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...