PyroStunts Posted August 2, 2016 Share Posted August 2, 2016 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); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 2, 2016 Share Posted August 2, 2016 It is for pixi-v3, right? according to https://github.com/pixijs/pixi.js/blob/master/src/core/renderers/webgl/shaders/Shader.js#L312 , for v3v you have to specify [{x: hexToR, y: hexToR, z: hexToR }] . Your current value is for "3fv" Quote Link to comment Share on other sites More sharing options...
PyroStunts Posted August 2, 2016 Author Share Posted August 2, 2016 Yes. This seems to be what I need. I wont be able to try it until later on today. I'll reply if I still can't get it to work. Thanks again. 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.