Passing Variables from ShapeBase Object to Shader
by Tim Dix (Raverix) · in Torque 3D Professional · 08/10/2010 (11:11 pm) · 5 replies
Hello, I'm trying to pass a variable from a ShapeBase derived object to it's custom material shader. I added the following code to ::prepBatchRender(), but it's not making it's way to the shader.
I keep getting the "The '%s' shader constant in shader '%s' was unassigned!" assert. Any suggestions?
for(int i = 0; i < mShapeInstance->getMaterialList()->getMaterialCount(); i++)
{
MatInstance *matInstance = dynamic_cast<MatInstance*>(mShapeInstance->getMaterialList()->getMaterialInst(i));
MaterialParameterHandle *handle = matInstance->getMaterialParameterHandle("$testset");
MaterialParameters *params = matInstance->getMaterialParameters();
params->set(handle, 3.14f);
}I keep getting the "The '%s' shader constant in shader '%s' was unassigned!" assert. Any suggestions?
About the author
#2
I'm going to have to assume that replicating all of this logic in a custom delegate is probably not the best way...
Once again, all I need to do is pass a variable from the object, to the shader. There has to be a more direct route than this.
08/11/2010 (11:44 pm)
After following ShapeBaseprepBatchRender()-> TSShapeInstance::render()-> TSShapeInstance::render()-> TSShapeInstance::MeshObjectInstance::render()-> TSSkinMesh::render()-> TSSkinMesh::innerRender()-> renderPass->addInst( ri );
I'm going to have to assume that replicating all of this logic in a custom delegate is probably not the best way...
Once again, all I need to do is pass a variable from the object, to the shader. There has to be a more direct route than this.
#3
Does anyone know the correct way to pass a variable into a shader constant for a CustomMaterial shader from a shape base object? Does T3D support this?
08/16/2010 (1:29 pm)
Shameless attempt to bump the topic.Does anyone know the correct way to pass a variable into a shader constant for a CustomMaterial shader from a shape base object? Does T3D support this?
#4
gameclay.com/documentation/per-shape-shader-values-t3d
08/23/2010 (4:25 am)
backwards but maybe helpful..gameclay.com/documentation/per-shape-shader-values-t3d
#5
08/23/2010 (11:46 am)
Damn... if only I saw that last week! I actually managed to get this to work my own way, a bit similar to what's posted there, but requiring less changes to the core engine. I'm writing a resource on it, but basically it also creates a shader feature like Pat Wilson's method, but instead of setting up a particular variable to be passed all the way through, I make use of the new 1.1 mMaterialHint feature of TSRenderState to pass a pointer to the object that's rendering it, and then the feature can call any function on that object it wants to get values.
Torque 3D Owner Tim Dix (Raverix)