Skip to main content
Commonmark migration
Source Link

###First I was storing 5 textures as so:

First I was storing 5 textures as so:

Currently I get this:

##Currently I get this:## wow such gross so depth

#Why are my positions being output like they are?#

Why are my positions being output like they are?

###First I was storing 5 textures as so:

##Currently I get this:## wow such gross so depth

#Why are my positions being output like they are?#

First I was storing 5 textures as so:

Currently I get this:

wow such gross so depth

Why are my positions being output like they are?

Tweeted twitter.com/#!/StackGameDev/status/398694449502773248
added 272 characters in body
Source Link
RamblingMad
  • 287
  • 3
  • 12
#version 150 uniform sampler2D depth_tex; uniform sampler2D normal_tex; uniform sampler2D diffuse_tex; uniform sampler2D specular_tex;  uniform mat4 inv_proj_mat; uniform vec2 nearz_farz; in vec2 uv_f; ... other uniforms and such ... layout(location = 3) out vec4 PostProcess; vec3 reconstruct_pos(){ float z = texture(depth_tex, uv_f).x; vec4 sPos = vec4(uv_f * 2.0 - 1.0, z, 1.0); sPos = inv_proj_mat * sPos; return (sPos.xyz / sPos.w); } void main(){ vec3 pos = reconstruct_pos(); vec3 normal = texture(normal_tex, uv_f).rgb; vec3 diffuse = texture(diffuse_tex, uv_f).rgb; vec4 specular = texture(specular_tex, uv_f); ... do lighting ... PostProcess = vec4(pos, 1.0); // Just for testing } 
#version 150 uniform sampler2D depth_tex; uniform mat4 inv_proj_mat; uniform vec2 nearz_farz; in vec2 uv_f; ... other uniforms and such ... layout(location = 3) out vec4 PostProcess; vec3 reconstruct_pos(){ float z = texture(depth_tex, uv_f).x; vec4 sPos = vec4(uv_f * 2.0 - 1.0, z, 1.0); sPos = inv_proj_mat * sPos; return (sPos.xyz / sPos.w); } void main(){ vec3 pos = reconstruct_pos(); ... do lighting ... PostProcess = vec4(pos, 1.0); // Just for testing } 
#version 150 uniform sampler2D depth_tex; uniform sampler2D normal_tex; uniform sampler2D diffuse_tex; uniform sampler2D specular_tex;  uniform mat4 inv_proj_mat; uniform vec2 nearz_farz; in vec2 uv_f; ... other uniforms and such ... layout(location = 3) out vec4 PostProcess; vec3 reconstruct_pos(){ float z = texture(depth_tex, uv_f).x; vec4 sPos = vec4(uv_f * 2.0 - 1.0, z, 1.0); sPos = inv_proj_mat * sPos; return (sPos.xyz / sPos.w); } void main(){ vec3 pos = reconstruct_pos(); vec3 normal = texture(normal_tex, uv_f).rgb; vec3 diffuse = texture(diffuse_tex, uv_f).rgb; vec4 specular = texture(specular_tex, uv_f); ... do lighting ... PostProcess = vec4(pos, 1.0); // Just for testing } 
deleted 1 characters in body
Source Link
RamblingMad
  • 287
  • 3
  • 12
#version 150 uniform sampler2D depth_tex; uniform mat4 proj_mat;inv_proj_mat; uniform vec2 nearz_farz; in vec2 uv_f; ... other uniforms and such ... layout(location = 3) out vec4 PostProcess; vec3 reconstruct_pos(){ float z = texture(depth_tex, uv_f).x; vec4 sPos = vec4(uv_f * 2.0 - 1.0, z, 1.0); sPos = inverse(proj_mat)inv_proj_mat * sPos; return (sPos.xyz / sPos.w); } void main(){ vec3 pos = reconstruct_pos(); ... do lighting ... PostProcess = vec4(pos, 1.0); // Just for testing } 
#version 150 uniform sampler2D depth_tex; uniform mat4 proj_mat; uniform vec2 nearz_farz; in vec2 uv_f; ... other uniforms and such ... layout(location = 3) out vec4 PostProcess; vec3 reconstruct_pos(){ float z = texture(depth_tex, uv_f).x; vec4 sPos = vec4(uv_f * 2.0 - 1.0, z, 1.0); sPos = inverse(proj_mat) * sPos; return (sPos.xyz / sPos.w); } void main(){ vec3 pos = reconstruct_pos(); ... do lighting ... PostProcess = vec4(pos, 1.0); // Just for testing } 
#version 150 uniform sampler2D depth_tex; uniform mat4 inv_proj_mat; uniform vec2 nearz_farz; in vec2 uv_f; ... other uniforms and such ... layout(location = 3) out vec4 PostProcess; vec3 reconstruct_pos(){ float z = texture(depth_tex, uv_f).x; vec4 sPos = vec4(uv_f * 2.0 - 1.0, z, 1.0); sPos = inv_proj_mat * sPos; return (sPos.xyz / sPos.w); } void main(){ vec3 pos = reconstruct_pos(); ... do lighting ... PostProcess = vec4(pos, 1.0); // Just for testing } 
edited body
Source Link
RamblingMad
  • 287
  • 3
  • 12
Loading
Source Link
RamblingMad
  • 287
  • 3
  • 12
Loading