• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Swatchoos

      Hi Guys,
      We would like to present our new panel: Swatchoos, the most advanced swatch panel for Adobe Photoshop CC with lots of features and improvements like:
      - Group Creation and Management
      - Swatch and Group Reordering
      - Change brightness and darkness of any color
      - Sort Swatches by Luminosity or HUE
      - Fill any Shape/Text/Bitmap layer
      - Generate Swatches from bitmaps and .psd layers
      - Customisable the look of your color
      - Import .aco or bitmaps
      - Share your swatch palettes with others
      - Auto color naming
      and much much more.
      You can try it for free so go to www.swatchoos.com and test it out!
    • By Jens Eckervogt
      Hello guys, 
      Please tell me! 
      How do I know? Why does wavefront not show for me?
      I already checked I have non errors yet.
      using OpenTK; using System; using System.Collections.Generic; using System.IO; namespace Tutorial_08.net.sourceskyboxer { public class WaveFrontLoader { private static List<Vector3> vertices; private static List<Vector2> textures; private static List<Vector3> normals; private static List<int> indices; private static float[] verticesArray; private static float[] normalsArray; private static float[] texturesArray; private static int[] indicesArray; private static string[] lines; public static RawModel LoadObjModel(string filename, Loader loader) { if (!File.Exists("Contents/" + filename + ".obj")) { throw new FileNotFoundException("Error: wavefront file doesn't exist path: " + filename + ".png"); } vertices = new List<Vector3>(); textures = new List<Vector2>(); normals = new List<Vector3>(); indices = new List<int>(); lines = File.ReadAllLines("Contents/" + filename + ".obj"); try { foreach (string line in lines) { if (line == "" || line.StartsWith("#")) continue; string[] token = line.Split(' '); switch(token[0]) { case ("o"): string o = token[1]; break; case "v": Vector3 vertex = new Vector3(float.Parse(token[1]), float.Parse(token[2]), float.Parse(token[3])); vertices.Add(vertex); break; case "vn": Vector3 normal = new Vector3(float.Parse(token[1]), float.Parse(token[2]), float.Parse(token[3])); normals.Add(normal); break; case "vt": Vector2 texture = new Vector2(float.Parse(token[1]), float.Parse(token[2])); textures.Add(texture); break; case "f": texturesArray = new float[vertices.Count * 2]; normalsArray = new float[vertices.Count * 3]; verticesArray = new float[vertices.Count * 3]; indicesArray = new int[indices.Count]; int vertexPointer = 0; foreach (Vector3 vex in vertices) { verticesArray[vertexPointer++] = vex.X; verticesArray[vertexPointer++] = vex.Y; verticesArray[vertexPointer++] = vex.Z; } for (int i = 0; i < indices.Count; i++) { indicesArray[i] = indices[i]; } break; } } } catch (FileNotFoundException f) { throw new FileNotFoundException($"OBJ file not found: {f.FileName}", f); } catch (ArgumentException ae) { throw new ArgumentException("OBJ file is damaged", ae); } return loader.loadToVAO(verticesArray, texturesArray, indicesArray); } } } And It have tried other method but it can't show for me.  I am mad now. Because any OpenTK developers won't help me.
      Please help me how do I fix.

      And my download (mega.nz) should it is original but I tried no success...
      - Add blend source and png file here I have tried tried,.....  
      PS: Why is our community not active? I wait very longer. Stop to lie me!
      Thanks !
    • By Paszq
      Troglodytes are a playable races in Arpago - they usually don't talk much and most of them lives near water sources.
    • By Paszq
      a Fox in a dungeon :)
    • By Paszq
      Fox Folk is one of 3 playable races in Arpago.
  • Advertisement
  • Advertisement

3D D3D9 - How to linearize depth buffer obtained from closed source application

Recommended Posts

Hey guys, I hope for help on the following problem - hopefully an easy one for you, but I am an absolute beginner...

I want to simulate a Lidar in a closed source D3D9 game (ArmA2-based I think), meaning I want to get the pixel positions in view space. For that I intercept the D3D9 calls (via proxy dll) and retrieve the handle to the depth buffer texture (R32F) which I have identified .  I've attached an example of the contents of this depth buffer (just StretchRect'ed the contents to the back buffer) and the corresponding rendered image.

Now what I am trying to do is transform the depth buffer values to view space but I keep failing on this. I am trying to do it as described in this stackoverflow post (the only change I made after I saw that it does not work is to delete the first line 'z = depth*2.0 - 1.0' and instead directly using the depth value, because as far as I know the projection matrix(from MSDN: https://msdn.microsoft.com/de-de/library/windows/desktop/bb147302(v=vs.85).aspx,IC511470.png, Q = Zf/(Zf-Zn) )is already adjusted to output a depth in [0,1] - and thus should also be directly usable in inverted form for the transformatino from clip space to view space)

I should mention that I can query the game API for the view frustum values (left + right angle, top + bottom angle, near and far plane), but as you can see a large part of the depth buffer is black

So here are my questions:

1) What I don't quite understand is that apparently the whole depth buffer value interval is inverted, meaning far objects are dark (a color of (1,1,1,1) is white) . Are there any other projection matrices commonly used together with D3D9, that have this behavior and which I could try?

2) Is the approach shown in the mentioned stackoverflow post a valid one? Especially I'd really like to know if this division by w after applying the inverse projection matrix is correct - I thought, this division is necessary to get from clip space to normalized device coordinates. But why is it necessary here?

3) Is there any other approach I could use to get the pixel positions in view space?

Thanks in advance!



Edited by Apollo13

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement