Hello all,

I read about some special parameters of OpenSG, OSGProjectionMatrix, 
OSGViewMatrix, etc. 
And I want to use it in my Cg program.

Instead using of glstate.matrix.mvp, I want to use OpenSG special parameters.

So I did belows.
First, I modified "checkOSGParameters" function in OSGCGChunk.cpp file because 
I did not call "updateProjectionMatrix" function. (Of course, I do rebuild and 
use new library.)

else if(parameter->getName() == "OSGProjectionMatrix")
{
    paramtercbfp fp = updateProjectionMatrix;
    _osgParametersCallbacks.push_back(fp);
}

And I registered some parameters before the "glutMainLoop" function.

_cgparameter->setUniformParameter("OSGProjectionMatrix", Real32(0.0));
_cgparameter->setUniformParameter("OSGViewMatrix", Real32(0.0));

Then, in my vertex program I added new uniform parameters and used it.

void C7E1v_reflection(float4 position : POSITION,
    float2 texCoord : TEXCOORD0,
    float3 normal   : NORMAL,

    out float4 oPosition  : POSITION,
    out float2 oTexCoord  : TEXCOORD0,
    out float3 R          : TEXCOORD1,

    uniform float3   eyePositionW,
    uniform float4x4 modelToWorld,
    uniform float4x4 OSGProjectionMatrix,
    uniform float4x4 OSGViewMatrix)

Instead of using glstate.matrix.mvp, I tried many cases with OpenSG special 
parameters like belows.

float4x4 modelViewProj = 
transpose(OSGProjectionMatrix)*transpose(OSGViewMatrix);    
float4x4 modelViewProj = OSGProjectionMatrix*OSGViewMatrix;    
float4x4 modelViewProj = transpose(OSGViewMatrix);    
float4x4 modelViewProj = OSGProjectionMatrix;    

But it seems it doesn't work. :(

If there is anybody who tried this already, please tell me what I'm wrong. 

Thank you.


Best regards,
Estee

Reply via email to