올바른 역 투영 행렬이 있습니다. 그러나 아무 것도 옳은 것처럼 보이지 않습니다! 재구성 된 위치가 완전히 변형되지 않았으며 z 값이 작아지지 않았습니까? 누구 제안?LWGL // 프래그먼트 쉐이더에서 위치 재구성
vec3 calculatePosition(vec2 coord, float depth)
{
vec4 clipSpaceLocation;
clipSpaceLocation.x = coord.x * 2.0 - 1.0;
clipSpaceLocation.y = coord.y * 2.0 - 1.0;
clipSpaceLocation.z = depth * 2.0 - 1.0;
clipSpaceLocation.w = 1.0;
vec4 homogenousPosition = uProjectionInverse * clipSpaceLocation;
return homogenousPosition.xyz/homogenousPosition.w;
}
z 값은 대략 -0,001입니다. 왜?
COORD 싶게 깊이는 다음과 같습니다
vec2 coord = vec2(gl_FragCoord.x/width, gl_FragCoord.y/height);
float currentDepth = texture(depthBuffer, coord).r;
나는 대학에 대한 SSAO를 구현해야하고 내가 LWJGL - 플러그인 이클립스와 자바를 사용합니다. 제발 도와주세요. 나는 일주일도 안 남았어.
편집 : 지금이 시도 ...하지만 여전히 lenearized되지 않은 :
float camera_space_z_from_depth(sampler2D depthbuffer, vec2 uv) {
float depth = texture(depthbuffer, uv).x;
return (2 * uNearPlane)/(uFarPlane + uNearPlane - depth * (uFarPlane - uNearPlane));
}
vec3 calculatePosition(vec2 coord, float depth)
{
vec4 clipSpaceLocation;
clipSpaceLocation.x = coord.x * 2.0 - 1.0;
clipSpaceLocation.y = coord.y * 2.0 - 1.0;
clipSpaceLocation.z = depth * 2.0 - 1.0;
clipSpaceLocation.w = 1.0;
vec4 homogenousPosition = uProjectionInverse * clipSpaceLocation;
return homogenousPosition.xyz/homogenousPosition.w;
}
vec3 getPosition(vec2 coord){
float currentDepth = camera_space_z_from_depth(depthBuffer,coord);
vec3 position = calculatePosition(coord, currentDepth);
return position;
}
원래 코드 (안 편집) 지금까지 확인을 보인다. 편집에서의 선형화는 깊이 렌더링 패스가 일반 z 좌표를 사용했다는 가정하에 실제로는 이해가되지 않습니다. 나에게 이것은 uProjectionInverse 또는 - 그리고 이것은 내 첫 번째 추측 일 것이다 - 깊이 텍스처 (또는 depth rende rpass 그 자체)에 문제가있는 것처럼 보인다. '투영 값 0.001'에 대한 가까운 값이 있을까요? 그렇다면, 당신이 개발하려고하는 깊이 값이 모든 점에서 단지 0 인 것처럼 보입니다. – derhass