11110
September 30, 2019, 6:17am
1
This worked in DirectX & OpenGL platform. But it repeat the same calculate every vertex, which is not efficient.
//Shader
float4x4 matWVP = mul(World, mul(View, Proj));
o.position = mul(i.position, matWVP);
But when i precalculate on CPU and pass into GPU, the rendering become weird.
_effect.Parameters[WVP].SetValue(worldview projection);
shadercode
//Shader
o.position = mul(i.position, WVP);
Pass the WVP in rather than doing the calc in the shader.
I think that OpenGL and DX use different multiplaction order, that is to say one multiples a matrix by column, the other by row, switching the multiplication order may help??
1 Like
11110:
But when i precalculate on CPU and pass into GPU, the rendering become weird.
_effect.Parameters[WVP].SetValue(worldview projection);
shadercode
//Shader
o.position = mul(i.position, WVP);
try transposing on the shader though im not to confident that is the problem.
WVP = transpose(WVP);
o.position = mul(i.position,WVP);
Does sound similar to a problem i had here.
VSOutputInstanced MainVsInstanced(in VSVertexInputInstanced vertexInput, VSInstanceInputInstanced instanceInput)
{
VSOutputInstanced output;
//vertexInput.Position is position of base vertex, multiple with instance transform matrix to get correct position
// effectparameter setvalue do column->row for matrix but this one not >>> transpose(instanceInput.Transform)
float4 wpos = mul(vertexInput.Position, transpose(instanceInput.Transform));/…
1 Like
11110
September 30, 2019, 4:40pm
4
Thanks for reply! it’s work, i did some research on it. I found this.
1 Like