Help with ValueArrayRef and Shader

contains the latest version of our visualizer plugin (replacing Chrome)

Return to “ZGameEditor Visualizer forum”

[You can only see part of this thread as you are not logged in to the forums]
brandsbeats
Thu Jul 27, 2017 11:15 pm

0 x

Help with ValueArrayRef and Shader

What's up guys. I'm a long time time coder but just started experimenting with OpenGL and ZGE. I'm having trouble passing values from an array component to a shader component. Here's how I have it setup:
An array component Array1 filled with some dummy data(eventually this will be filled with either AudioArray or SpecBandArray data).
A shader component Shader1 with a uniform variable sba: VariableName = sba, ValueArrayRef = Array1,ArrayKind = Texture2D.

VertextShaderSource

Code: Select all

void main(){
  vec4 vertex = gl_Vertex;
  vertex.xy *= 2.0;
  gl_Position = vertex;
}

FragmentShaderSource

Code: Select all

uniform float resX;
uniform float resY;
uniform float itime;
uniform float viewportX;
uniform float viewportY;
uniform sampler2D sba;

vec2 iResolution = vec2(resX,resY);

void main()
{
  float val;
  vec2 uv = (gl_FragCoord.xy-vec2(viewportX,viewportY)) / iResolution.xy;
  if(uv.x > 0.2 && uv.x < 0.4)
  {
        val = texelFetch(sba, ivec2(0,0), 0).r;
        //val = clamp(textureLod(sba, vec2(0,0.0), 0.0).r, 0.0, 1.0);
        // val = texture2D(sba,vec2(0, 0.0)).x;
        //val = clamp(textureLod(sba, vec2(int(0),0.0), 0.0).r , 0.0, 1.0);
        //val = 0.5 ;
        gl_FragColor = vec4(val,val,val,1.0);
        //gl_FragColor = texelFetch(sba, ivec2(0,0), 0).;
  }
  else
  {
    gl_FragColor = vec4(uv,0.5+0.5*sin(itime),1.0);
  }

}


What I expect to see is a vertical grey band on top of a field of slowly shifting colors. Instead the band remains black meaning the data from Array1 is not effecting the shader(I think). As you can see from the comments in the fragment shader source, I tried a few things before throwing in the towel. I've attached the project in case I've made a mistake elsewhere. Any help would be Greatly appreciated :D
Thanks,
Brandon
You do not have the required permissions to view the files attached to this post.

VilleK (staff)
Fri Jul 28, 2017 8:47 am

0 x

Re: Help with ValueArrayRef and Shader

I checked this and code looks correct so I can'...
You do not have the required permissions to view the files attached to this post.

StevenM
Fri Jul 28, 2017 9:55 am

0 x

Re: Help with ValueArrayRef and Shader

I think this is what you were expecting to see....
You do not have the required permissions to view the files attached to this post.

VilleK (staff)
Fri Jul 28, 2017 11:16 am

0 x

Re: Help with ValueArrayRef and Shader

Aha, indeed in the first project there aren't r...

StevenM
Fri Jul 28, 2017 12:10 pm

1 x

Re: Help with ValueArrayRef and Shader

VilleK (staff) wrote:Aha, indeed in the first p...
You do not have the required permissions to view the files attached to this post.

brandsbeats
Sat Jul 29, 2017 12:21 am

0 x

Re: Help with ValueArrayRef and Shader

Wow, there was way more wrong with that project...


Return to “ZGameEditor Visualizer forum”