 Home
 » Viewing Profile: Posts: Narutokun
Narutokun
Member Since 15 Oct 2012Offline Last Active Sep 29 2016 08:50 AM
Community Stats
 Group Members
 Active Posts 149
 Profile Views 4,750
 Submitted Links 0
 Member Title Member
 Age Age Unknown
 Birthday Birthday Unknown

Gender
Not Telling
406
Prototype
User Tools
Latest Visitors
Posts I've Made
In Topic: Direction to point for lighting purposes
26 September 2016  11:48 PM
Perfect. Thanks a bunch.
In Topic: Converting world rotation to body rotation
30 August 2016  01:17 PM
Thanks a bunch. Apologies for the misunderstanding.
In Topic: Converting world rotation to body rotation
30 August 2016  12:34 AM
I need the camera rotation for custom 3D sound engine purposes. Since I didn't create the camera (it is created internally by the simulator and I have to use a bit of reverse engineering to get hold of it) I need to be able to transform it so that I know where it is looking relative to the nose of the aircraft.
In Topic: Distance to a pixel
28 August 2016  01:07 PM
Looking over the output results, it appears that the x and y values of the vector after being multiplied by the inverse projection matrix are the angles to the pixel in radians (x converted to degrees is roughly 60 which fits with my horizontal FOV of 120 deg, and y is roughly 3.75 deg which fits my vertical FOV of 7.5 deg). I'm guessing the key is in what relationship the z and w values have with my far and near clip planes?
In Topic: Distance to a pixel
28 August 2016  11:13 AM
Here is the geometry shader I am working with. The basic idea, is that the X axis of the texture (depth buffer) I am sampling from will correlate with the X axis of the final image, and the distance to the pixel calculated using the depth buffer will correspond to the Y axis of the final image (in otherwords, a modified Bscope radar display where the horizontal corresponds to the azimuth of the return and the vertical corrosponds to the slant range).
Here I have the camera even further from the target.
[maxvertexcount(80)] void GS( point GS_INPUT sprite[1], inout TriangleStream<PS_INPUT> triStream ) { PS_INPUT v; uint ux = sprite[0].id % 256; uint uy = sprite[0].id / 256; float x = float(ux) / 256.0f; float y = float(uy) / 75.0f; float x1 = x + (1.0f / 256.0f); float y1 = y + (1.0f / 75.0f); float4 fdepth = float4( depth.SampleLevel(SampleType, float2(x, y1), 0), depth.SampleLevel(SampleType, float2(x, y), 0), depth.SampleLevel(SampleType, float2(x1, y1), 0), depth.SampleLevel(SampleType, float2(x1, y), 0) ); float4 v1 = float4((2.0f*x)  1.0f, 1.0f  (2.0f*y1), fdepth.x, 1.0f); float4 v2 = float4((2.0f*x)  1.0f, 1.0f  (2.0f*y), fdepth.y, 1.0f); float4 v3 = float4((2.0f*x1)  1.0f, 1.0f  (2.0f*y1), fdepth.z, 1.0f); float4 v4 = float4((2.0f*x1)  1.0f, 1.0f  (2.0f*y), fdepth.w, 1.0f); float4 m1 = mul(v1, inprj); float4 m2 = mul(v2, inprj); float4 m3 = mul(v3, inprj); float4 m4 = mul(v4, inprj); float l1 = length(m1.xyz / m1.w); float l2 = length(m2.xyz / m2.w); float l3 = length(m3.xyz / m3.w); float l4 = length(m4.xyz / m4.w); v.m = 0; v.p.x = v1.x; v.p.y = l1  1.0f; v.p.zw = float2(0, 1.0f); v.t = float2(x, y1); triStream.Append(v); v.p.x = v2.x; v.p.y = l2  1.0f; v.p.zw = float2(0, 1.0f); v.t = float2(x, y); triStream.Append(v); v.p.x = v3.x; v.p.y = l3  1.0f; v.p.zw = float2(0, 1.0f); v.t = float2(x1, y1); triStream.Append(v); v.p.x = v4.x; v.p.y = l4  1.0f; v.p.zw = float2(0, 1.0f); v.t = float2(x1, y); triStream.Append(v); triStream.RestartStrip(); }Here is the first sample, using the top left corner of the texture source image (dimensions are 256x75). The screenshot below gives you an idea of where the camera is looking. The actual texture source image would only contain a thin strip from the center of the screenshot.
ux 0 uint uy 0 uint x 0.000000000 float y 0.000000000 float x1 0.003900000 float y1 0.013300000 float fdepth x = 0.968700000, y = 0.964700000, z = 0.968600000, w = 0.964700000 float4 m1 x = 1.048700000, y = 0.063800000, z = 0.099900000, w = 1.068700000 float4 m2 x = 1.048700000, y = 0.065500000, z = 0.099900000, w = 1.064700000 float4 m3 x = 1.040500000, y = 0.063800000, z = 0.099900000, w = 1.068600000 float4 m4 x = 1.040500000, y = 0.065500000, z = 0.099900000, w = 1.064700000 float4 l1 0.987600000 float l2 0.991300000 float l3 0.980000000 float l4 0.983700000 float //Inverse projection matrix inprj[0] x = 1.048700000, y = 0.000000000, z = 0.000000000, w = 0.000000000 float4 inprj[1] x = 0.000000000, y = 0.065500000, z = 0.000000000, w = 0.000000000 float4 inprj[2] x = 0.000000000, y = 0.000000000, z = 0.000000000, w = 1.000000000 float4 inprj[3] x = 0.000000000, y = 0.000000000, z = 0.099900000, w = 0.100000000 float4Here is what the final output looks like. A bit confusing to say the least.
Here I have the camera even further from the target.
ux 0 uint uy 0 uint x 0.000000000 float y 0.000000000 float x1 0.003900000 float y1 0.013300000 float fdepth x = 0.999300000, y = 0.999200000, z = 0.999300000, w = 0.999200000 float4 m1 x = 1.048700000, y = 0.063800000, z = 0.099900000, w = 1.099300000 float4 m2 x = 1.048700000, y = 0.065500000, z = 0.099900000, w = 1.099200000 float4 m3 x = 1.040500000, y = 0.063800000, z = 0.099900000, w = 1.099300000 float4 m4 x = 1.040500000, y = 0.065500000, z = 0.099900000, w = 1.099200000 float4 l1 0.960000000 float l2 0.960300000 float l3 0.952600000 float l4 0.952900000 float //Inverse projection matrix inprj[0] x = 1.048700000, y = 0.000000000, z = 0.000000000, w = 0.000000000 float4 inprj[1] x = 0.000000000, y = 0.065500000, z = 0.000000000, w = 0.000000000 float4 inprj[2] x = 0.000000000, y = 0.000000000, z = 0.000000000, w = 1.000000000 float4 inprj[3] x = 0.000000000, y = 0.000000000, z = 0.099900000, w = 0.100000000 float4I hope this helps to give a better idea of what I'm trying to do.