andras
November 15, 2006, 5:25pm
1
The docs says that I can use binding semantics on uniforms like this:
float4 main(const uniform color : C0) : COLOR { return color; }
But how can I set a uniform using the semantics? It seems like I still have to call cgGetNamedProgramParameter, but then what’s the point?
Toni
November 16, 2006, 4:18am
2
To get the texture unit binding semantic i do something like this, it might work for you, but check the name for color
CGparameter paramStruct = cgGetFirstStructParameter(mParam);
if(0 == strcmp("texunit 0",cgGetResourceString(cgGetParameterResource(paramStruct))))
{
samplers[0] = paramStruct;
}
Anyway i think you have function in the API definition, am i right?
const char* value = cgGetParameterSemantic(paramStruct);
andras
November 16, 2006, 5:37am
3
I think you misunderstood. I don’t want to use names in the code. I would like to use semantics in the shader to bind a uniform to a register location, and then just set the value of that location.
For example, with vertex attributes, I can use the semantics ATTR0, and then in the code, I just say glVertexAttrib4fv(0, pos)… Unfortunately I coulnd’t figure out how to do the same with uniforms. There are similar semantics allright (C0 - C15), but they don’t seem to work…
There are tables listing the binding semantics for the various profiles in the Cg 1.5 specification:
ftp://download.nvidia.com/developer/cg/Cg_Specification.pdf
jra101
November 16, 2006, 12:02pm
5
You can set the uniform using the profile specific uniform function:
arbvp1/vp40: glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 0, …);
vp20/vp30: glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 0, …);
arbfp1/fp40: glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, …);
fp30: glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_NV, 0, …);
system
Closed
October 19, 2021, 7:40pm
6
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.