I can't get paraboloid mapping to start working in view space. It works as it should if both paraboloid TranslationRotation matrix and vertices positions in World space but not when I convert both into View space.
Code is basically similar to Jason's greate article. Thank you Jason!
Basically vertex shader looks like this, it works just fine if all in world space:
float4 toWorld = mul(float4(input.pos.xyz, 1), object_to_world);
float4 clip_pos = mul( toWorld, mWVP ); //mWVP is a paraboloids InverseTraslationRotation matrix
clip_pos = clip_pos / clip_pos.w;
clip_pos.z = clip_pos.z * direction;
float L = length( clip_pos.xyz );
clip_pos = clip_pos / L;
output.z_value = clip_pos.z; //used for culling
clip_pos.z = clip_pos.z + 1;
clip_pos.xy = clip_pos.xy / clip_pos.z;
clip_pos.z = L / 500;
clip_pos.w = 1;
output.clip_pos = clip_pos;
return output;
Now I want to do it in view space so it goes like this at the beginning:
float4 toWorld = mul(float4(input.pos.xyz, 1), object_to_world);
float4 toView = mul(toWorld, viewM); //viewM is a projects view matrix
float4 clip_pos = mul( toView, mWVPv); //mWVPv is a paraboloids InverseTraslationRotationMatrix multiplyed by View matrix
It does rasterized as a paraboloid but content of rasterization changes as I move camera, I don't uderstand why, as both vertex and parabloid should be in view space right now.
Does anybode has an idea why and how it can be solved?
Maybe I need to first move paraboloid position and direction into view space, then make a matrix from it and use it as a basis, not sure that it will work and basically it will be kind a similar to what I have right now, if I'm not missing something here.