[ create a new paste ] login | about

Link: http://codepad.org/hxCVES1g    [ raw code | fork ]

C++, pasted on Dec 12:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
layout(binding=1) uniform sampler2D depth_texture;
uniform mat4 inverse_VP;

in vec2 tex_coord;

vec3 reconstruct_position(float depth, vec2 tex_coord)
{
	vec4 position = vec4(tex_coord, depth, 1);
	position.xyz = position.xyz*2-1;
	position = inverse_VP*position;
	position.xyz /= position.w;
	return position.xyz;
}
void main()
{
	float depth = texture(depth_texture, tex_coord).r;
	vec3 position = reconstruct_position(depth, tex_coord);
}


Create a new paste based on this one


Comments: