push texture to vshader sha file

I am coding Water Effect with Perlin Noise algorithm. It need to change height of geomipmap by time. This algorithm use a image to set height of geomipmap. i try to put texture to vshader (in sha file) but it return a errors :

I try to set

But nothing change.

I try to put all value to Array and use setShaderInput but it say

This is Array Code :

And this is shader file

Please help me what i have to do that ?!


My Project too big to upload here (over 150 classes) so i can’t upload all project. But I use original source and a little edit.



Passing a texture to a shader requires Vertex Texture Fetch, which not all cards support. All of my NVIDIA cards have no problem with it. Which card do you have?

I run it on my laptop
Graphic card is AMD Radeon 5470M…

have another way to generate it ?!
I think it like a geomipmap with heighmap file change by time. And all GPU support geomipmap :frowning:

I can be wrong, but as I see, you pass the array to the shader, not a Texture.
May be do something like
tex = Texture()
root.setShaderInput(‘PerNoise’, tex)

Also try to remove some uniform inputs or temporary replace it with hardcoded constants. Before, I had some problems with it on ATI card.

Well, the bug with adding an float array is a different one, and it’s probably a bug in Panda3D. Does it work if you use a float4 array instead of a float array?

I change in shader file from float to float4… But nothing change

I try by your way. But like a result in top of topic. It’s Say

Is original example works as expected? Give me link on this example, plz.

My Project too big to upload here (over 150 classes) so i can’t upload all project. But I use original source and a little edit.



I hope you can help :slight_smile:

In any case, you should get rid of the “//Cg profile arbvp1 arbfp1” on top of your file. That’s telling your shader to use the weakest profile available, overriding your setting of basic-shaders-only.

Well, seems that Cg actually is very outdated or strongly dislikes ATI :). My videocard supports 16 texture units in the vertex shader, but Cg tell me that “Cg program too complex for driver”. I rewrote shader in GLSL and it’s works as expected for me.
Here my equivalent GLSL vertex and fragmet shaders:

uniform vec4 lightvec;
uniform vec4 lightcolor;
uniform vec4 ambientlight;
uniform sampler2D p3d_Texture0;

varying vec4 brightness;

void main()
    float test = texture2D(p3d_Texture0, vec2(gl_MultiTexCoord0)).x;
    vec4 co = gl_Vertex;
    co.z += test; // displace
    gl_Position = gl_ModelViewProjectionMatrix * co;
    gl_TexCoord[0] = gl_MultiTexCoord0;

    vec3 N = normalize( gl_NormalMatrix * gl_Normal );
    vec3 L = normalize(lightvec.xyz);
    brightness = max( dot( -N, L ), 0.0f ) * lightcolor + ambientlight;
uniform sampler2D p3d_Texture0;
uniform sampler2D p3d_Texture1;
uniform sampler2D p3d_Texture2;
uniform sampler2D p3d_Texture3;
uniform sampler2D p3d_Texture4;
uniform sampler2D p3d_Texture5;

varying vec4 brightness;

void main(void)
    vec4 tex0 = texture2D(p3d_Texture0, vec2(gl_TexCoord[0]));
    vec4 tex1 = texture2D(p3d_Texture1, vec2(gl_TexCoord[0]));
    vec4 tex2 = texture2D(p3d_Texture2, vec2(gl_TexCoord[0]));
    float alpha0 = texture2D(p3d_Texture3, vec2(gl_TexCoord[0])).z;
    float alpha1 = texture2D(p3d_Texture4, vec2(gl_TexCoord[0])).z;
    float alpha2 = texture2D(p3d_Texture5, vec2(gl_TexCoord[0])).z;
    gl_FragColor = tex0 * alpha0 + tex1 * alpha1 + tex2 * alpha2;
    gl_FragColor *= brightness;

and result:

It’s not Cg itself that’s the problem, it’s how the shader is compiled. He forced it into arbfp1 arbvp1 mode, which doesn’t have much functionality at all.

Cg can be compiled to GLSL using the glslf and glslv profiles (in fact, I think that’s what’s supposed to happen if you don’t request an explicit profile and set basic-shaders-only to false) anyway.

Hmm. Yes, indeed I found “//Cg profile arbfp1 arbvp1” entry at top of the original shader. I’ve tryed to replace it with “//Cg profile glslf glslv” and tryed fully remove this entry, and of course, I used “basic-shaders-only #f”, but nothing changes, Cg still reports that program too complex.

I have same result like [color=red]ninth

Can you upload full package?
I really need it


I don’t change nothing else shaders code. You can load it like this

shader = Shader.load(Shader.SLGLSL, 'vert.glsl', 'frag.glsl')

One thing - you need last dev version of Panda, or may be 1.7.2. In 1.8.0 GLSL is broken.

If you relly need full package, I can search it if not deleted.

For the record, when you get the “too complex” error, you should try “vp40 fp40”.

I guess have problem with Cg profile. When I change default profile but when debug profile is no change…

My videocard is and radeon 5470m and with default driver of xubuntu

Yes, I found out that Cg is simply fundamentally broken on AMD unless you set “basic-shaders-only” and don’t use advanced functionality. Try to use GLSL instead.