Looking at the code from:
discourse.panda3d.org/viewtopic.php?p=10093
I’d like to remove the excess multiply per vertex that uses the scale to create the texture matrix. I can do this because I already am computing world coordinates for the vertex position for another part of the shader. So I want to pass in a uniform float4x4 matrix that converts world->adjusted clip space.
So far, I’ve come up with:
void vshader(float4 vtx_position : POSITION,
float2 vtx_texcoord0 : TEXCOORD0,
in uniform float4x4 mat_modelproj,
in uniform float4x4 trans_model_to_world,
in uniform float4x4 trans_scaleMatrix_to_world,
out float4 l_position : POSITION,
out float2 l_texcoord0 : TEXCOORD0,
out float4 l_texcoord1 : TEXCOORD1,
) {
l_wsvtxposition = mul(trans_model_to_world,vtx_position);
l_texcoord0 = vtx_texcoord0;
l_position = mul(mat_modelproj, vtx_position);
l_texcoord1 = mul(trans_scaleMatrix_to_world,l_wsvtxposition);
}
and in the python code, I’m trying to set up that matrix by:
scaleMatrix = NodePath("scaleMatrix")
#Scale Matrix for transforming clip space -> texture space
scaleMatrix.setScale(.5)
scaleMatrix.setPos(.5,.5,.5)
depthcamtrans = self.depthCameraPath.getNetTransform().getMat()
depthcamtrans.invertInPlace()
stashedMatrix = depthcamtrans * self.depthCameraPath.node().getLens().getProjectionMat() * scaleMatrix.getMat()
scaleMatrix.setMat(stashedMatrix)
shadowNode.setShaderInput( "scaleMatrix", scaleMatrix)
(depthCameraPath is a NodePath at the location of the shadow camera)
Based on the article on matrices, I assume they are pre-multiply, but I’ve tried it both ways just in case. Either way, this does not preform the shadow rendering like I would expect. Any ideas?
Thanks,
Chris