As title,
In my main.cpp, how can I pass the variables(ex. texture, float4, matrix..) to shader code?
Is there any tutorial to teach these things?
Thanks a lot!!
How to pass variables to shader code through main program?
-
- Greenskin
- Posts: 103
- Joined: Wed Mar 12, 2008 5:12 pm
-
- Kobold
- Posts: 39
- Joined: Thu Sep 01, 2005 1:10 am
I've never used it, and I'm not sure if this is what you're looking for:
http://www.ogre3d.org/docs/api/html/cla ... eters.html
http://www.ogre3d.org/docs/api/html/cla ... eters.html
Code: Select all
GpuProgramParametersSharedPtr mParams;
mParams = material->getTechnique()->getPass()->getVertexProgram();
mParams = material->getTechnique()->getPass()->getFragmentProgram();
mParams->setNamedConstant("name", value);
-
- Greenskin
- Posts: 103
- Joined: Wed Mar 12, 2008 5:12 pm
Got it!! Thanks!!^^Princess_ConeCloon wrote:I've never used it, and I'm not sure if this is what you're looking for:
http://www.ogre3d.org/docs/api/html/cla ... eters.html
Code: Select all
GpuProgramParametersSharedPtr mParams; mParams = material->getTechnique()->getPass()->getVertexProgram(); mParams = material->getTechnique()->getPass()->getFragmentProgram(); mParams->setNamedConstant("name", value);
If there is more detailed information, please tell me.
- betajaen
- OGRE Moderator
- Posts: 3447
- Joined: Mon Jul 18, 2005 4:15 pm
- Location: Wales, UK
- x 58
- Contact:
http://www.ogre3d.org/wiki/index.php/Fa ... ect_Shadershaill wrote:Got it!! Thanks!!^^
If there is more detailed information, please tell me.
-
- Greenskin
- Posts: 103
- Joined: Wed Mar 12, 2008 5:12 pm
Thanks for ur help. But this seems not about my topicbetajaen wrote: http://www.ogre3d.org/wiki/index.php/Fa ... ect_Shader
- HexiDave
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
Yes, it is - read the page. It talks about setting custom parameters through each renderable item. If you're just talking about materials, that's covered there a bit too.shaill wrote:Thanks for ur help. But this seems not about my topicbetajaen wrote: http://www.ogre3d.org/wiki/index.php/Fa ... ect_Shader
-
- Gnoblar
- Posts: 24
- Joined: Wed Aug 02, 2006 1:02 pm
- Location: Copenhagen, Denmark
I love this feature in OGRE... I setup some named parameters in a program definition:shaill wrote:Got it!! Thanks!!^^Princess_ConeCloon wrote:I've never used it, and I'm not sure if this is what you're looking for:
http://www.ogre3d.org/docs/api/html/cla ... eters.html
Code: Select all
GpuProgramParametersSharedPtr mParams; mParams = material->getTechnique()->getPass()->getVertexProgram(); mParams = material->getTechnique()->getPass()->getFragmentProgram(); mParams->setNamedConstant("name", value);
If there is more detailed information, please tell me.
Code: Select all
...
default_params
{
// These are overwritten from within code when FFF changes
param_named fFFOptions float4 0.0 0.0 0.0 0.0
param_named fFFForceFactor float 0.0
param_named fFFNearFarClipDistances float4 0.0 1000.0 0 1
param_named fFFViewMatrix matrix4x4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
...
Code: Select all
MaterialPtr mat = (MaterialPtr)MaterialManager::getSingleton().getByName("MyMaterial");
Pass* pass = mat->getTechnique("Default")->getPass(0);
GpuProgramParametersSharedPtr parameters = pass->getVertexProgramParameters();
parameters->setNamedConstant("fFFOptions", mData->fFFToggleOptions);
parameters->setNamedConstant("fFFForceFactor", mData->forceFieldCameraForceFactor);
parameters->setNamedConstant("fFFNearFarClipDistances", mData->fFFNearFarClipDistance);
parameters->setNamedConstant("fFFViewMatrix", mData->fFFCameraViewMatrix);
...