# DX11 DX11 - Position Maps + Depth Maps

## Recommended Posts

Migi0027    4628

Hi guys,

how can you, in the most correct way, map normals and position to a texture, I'm guessing like this, but I think I'm wrong:

PS. Is depth maps the same as position maps?

VS:

output.NormalW = mul(normal, worldMatrix);
output.depthPosition = output.position;

PS:


float depth = (input.depthPosition.w / 1000.0f);
output.Depth = float4(depth, depth, depth, 1);

output.Normals = float4(input.NormalW, 1);

float depth = (input.depthPosition.w / 1000.0f);
output.Depth = float4(depth, depth, depth, 1);

When I mean, 'the correct way', I mean so that this texture can be used in e.g:

Thanks!

Edited by Migi0027

##### Share on other sites
Migi0027    4628

I'm sure you all know, but you're awfully quiet, again.

Am I doing something really stupid here?

##### Share on other sites
ongamex92    3254

output.NormalW = mul(float4(normal.xyz, 0.f), worldMatrix);

float depth = input.depthPosition.z / input.depthPosition.w;

##### Share on other sites
Styves    1792

Better to output depth linearly for better precision distribution.

float depth = input.depthPosition.w * inverseFarPlaneDistance;

## Create an account

Register a new account

• ### Similar Content

• By gsc
Hi! I am trying to implement simple SSAO postprocess. The main source of my knowledge on this topic is that awesome tutorial.
But unfortunately something doesn't work... And after a few long hours I need some help. Here is my hlsl shader:
float3 randVec = _noise * 2.0f - 1.0f; // noise: vec: {[0;1], [0;1], 0} float3 tangent = normalize(randVec - normalVS * dot(randVec, normalVS)); float3 bitangent = cross(tangent, normalVS); float3x3 TBN = float3x3(tangent, bitangent, normalVS); float occlusion = 0.0; for (int i = 0; i < kernelSize; ++i) { float3 samplePos = samples[i].xyz; // samples: {[-1;1], [-1;1], [0;1]} samplePos = mul(samplePos, TBN); samplePos = positionVS.xyz + samplePos * ssaoRadius; float4 offset = float4(samplePos, 1.0f); offset = mul(offset, projectionMatrix); offset.xy /= offset.w; offset.y = -offset.y; offset.xy = offset.xy * 0.5f + 0.5f; float sampleDepth = tex_4.Sample(textureSampler, offset.xy).a; sampleDepth = vsPosFromDepth(sampleDepth, input.uv).z; const float threshold = 0.025f; float rangeCheck = abs(positionVS.z - sampleDepth) < ssaoRadius ? 1.0 : 0.0; occlusion += (sampleDepth <= samplePos.z + threshold ? 1.0 : 0.0) * rangeCheck; } occlusion = saturate(1 - (occlusion / kernelSize)); And current result: http://imgur.com/UX2X1fc
I will really appreciate for any advice!
• By isu diss
I'm trying to code Rayleigh part of Nishita's model (Display Method of the Sky Color Taking into Account Multiple Scattering). I get black screen no colors. Can anyone find the issue for me?

• I made my obj parser
and It also calculate tagent space for normalmap.
it seems calculation is wrong..
any good suggestion for this?
https://gamedev.stackexchange.com/questions/147199/how-to-debug-calculating-tangent-space
and I uploaded my code here

• Hi guys,

I dont know if this is the right section, but I did not know where to post this.
I am implementing a day night cycle on my game engine and I was wondering if there was a nice way to interpolate properly between warm colors, such as orange (sunset) and dark blue (night) color. I am using HSL format.
Thank  you.

• I am aiming to learn Windows Forms with the purpose of creating some game-related tools, but since I know absolutely nothing about Windows Forms yet, I wonder:
Is it possible to render a Direct3D 11 viewport inside a Windows Form Application? I see a lot of game editors that have a region of the window reserved for displaying and manipulating a 3D or 2D scene. That's what I am aiming for.
Otherwise, would you suggest another library to create a GUI for game-related tools?

EDIT:
I've found a tutorial here in gamedev that shows a solution:
Though it's for D3D9, I'm not sure if it would work for D3D11?

• 17
• 9
• 16
• 68
• 12