OGL + CgFX arrays

MePHyst0

Newcomer
Hello everyone,

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
 
Sorry for bumping this thread, but I am rather surprised that nobody in here came through this problem or at least have some experience with this. I must say that I have asked a few people about this topic and nobody had a clue, how can it be ? Cg is such a beatiful shader language that I though everyone here are using it so I will get an answer to this immediately :)
 
what do you expect - you post your question around e3 time ; )

me not being a cgfx expert, but:
what do an error query before and one after the parameter set report?
is that the only parameter that fails update?
are you sure you don't have parameter shadowing on?
 
Oh, you're right, I absolutely didn't realize that I was posting during E3 :oops:

No errors being reporter during program execution(no Cg nor OGL errors are reported).
Yes, array type parameters are the only ones that aren't working.
As far as I know, according to the Cg User Manual, parameter shadowing applies only for D3D-based applications, mine is OGL-based. Am I wrong?
 
strange. what happens if that var param is not an array? - it's a one-elemt array anyway, right? for the sake of experiment, can you make it an ordinary float4 and use the non-array SetParameter?

as about parameter shadowing, IIRC it should work in both d3d and ogl, but judgeing from your response you don't seem be using that at all.
 
Last edited by a moderator:
Back
Top