Hello everyone,
I have here quite an interesting problem for which I haven't succeded to find any answer yet![Frown :( :(](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Imagine you have a shader which needs some arrays(for example blurring needs arrays for offseting tex coords and weighting these pixels).
The header of the shader will look something like this:
float4 fragment_simple(uniform sampler2D tex0,
uniform float4 parOffset[1],
float2 texcoord : TEXCOORD0)
We are particularly interested in the uniform parOffset parameter.
My cgfx file looks like this:
float4 myArray[1] : OffsetArray; // the parameter
//vertex and fragment shaders cut off
//the technique
technique SimpleTech {
pass {
VertexProgram = compile arbvp1 vertex_simple(mvp);
FragmentProgram = compile arbfp1 fragment_simple(OnlyTex0,myArray) ;
}
}
I load these from my OGL based engine as follows:
// in init
cgArray = cgGetNamedEffectParameter(cgSimpleFX,"myArray");
//in render
float temp[4] = {1.0,0.2,0.4,0.0};
cgGLSetParameterArray4f(cgArray,0,1,temp);
Now what is the problem, it doesn't matter what I do the array inside the shader embedded in the cgfx file is alway full of zeros.
Now what is really interesting is the fact that when I use stand-alone shader file(cg), which is loaded manually, it works, the array gets filled properly.
Does anybode have any idea how this can be solved? Or what can be causing this strange behaviour?
Thanks in advance
I have here quite an interesting problem for which I haven't succeded to find any answer yet
Imagine you have a shader which needs some arrays(for example blurring needs arrays for offseting tex coords and weighting these pixels).
The header of the shader will look something like this:
float4 fragment_simple(uniform sampler2D tex0,
uniform float4 parOffset[1],
float2 texcoord : TEXCOORD0)
We are particularly interested in the uniform parOffset parameter.
My cgfx file looks like this:
float4 myArray[1] : OffsetArray; // the parameter
//vertex and fragment shaders cut off
//the technique
technique SimpleTech {
pass {
VertexProgram = compile arbvp1 vertex_simple(mvp);
FragmentProgram = compile arbfp1 fragment_simple(OnlyTex0,myArray) ;
}
}
I load these from my OGL based engine as follows:
// in init
cgArray = cgGetNamedEffectParameter(cgSimpleFX,"myArray");
//in render
float temp[4] = {1.0,0.2,0.4,0.0};
cgGLSetParameterArray4f(cgArray,0,1,temp);
Now what is the problem, it doesn't matter what I do the array inside the shader embedded in the cgfx file is alway full of zeros.
Now what is really interesting is the fact that when I use stand-alone shader file(cg), which is loaded manually, it works, the array gets filled properly.
Does anybode have any idea how this can be solved? Or what can be causing this strange behaviour?
Thanks in advance