opengl - LWGL // reconstruct position in fragment shader -


I have the correct inverse estimation matrix. But nothing seems right! The rebuilding situation is totally useless and the z-value is too small? Any suggestions?

  vec3 calculation status (vec2 sync, float depth) {vec4 clipspace location; Clipspace location X = coord.x * 2.0 - 1.0; Clipspace location Y = coord.y * 2.0 - 1.0; ClipSpaceLocation.z = Depth * 2.0 - 1.0; ClipSpaceLocation.w = 1.0; Vec4 homogenousPosition = uProjectionInverse * clippace location; Return homogenousPosition.xyz / homogenousPosition.w; }  

The z-value is approximately -0,001; Why is it like this?

Coordination and depth:

  vec2 coord = vec2 (gl_FragCoord.x / width, gl_FragCoord.y / height); Float currentDepth = texture (depth buffer, coordinate). R;  

I have to implement SSA for university and I will use Eclipse and Java with LWGLL plugin. Please help me, I've got less than a week.

EDIT: I've tried it now ... but have not been so familiar:

  float camera_space_gie_frame_develop (sampler 2D gafter, wk2 uv) {Float depth = texture (deep, UV) .x; Return (2 * uNearPlane) / (uFarPlane + uNearPlane - Depth * (uFarPlane - uNearPlane)); } Vec3 calculation status (vec2 coordinate, float depth) {vec4 clipspace location; Clipspace location X = coord.x * 2.0 - 1.0; Clipspace location Y = coord.y * 2.0 - 1.0; ClipSpaceLocation.z = Depth * 2.0 - 1.0; ClipSpaceLocation.w = 1.0; Vec4 homogenousPosition = uProjectionInverse * clippace location; Return homogenousPosition.xyz / homogenousPosition.w; } Vec3 getPosition (vec2 sync) {float currentdream = camera_space_z_from_depth (depth buffer, coordinate); Vec3 position = calculation count (coordination, current diphth); Return status; }  

I think you need to line your depth values , As it is said here:

Just try.

  float camera_space_z_from_depth (sampler 2D gaft, vec2 uv) {const float depth = texture (depth, UV). X; Return (camera_near / (camera_fire - depth * (camera_fire - camera_near))) * camera_freeze; }  

Edit:

Try the variable meaning should be self explanatory (no liner required) :)

  vec3 getpeten (vec2 frument coresnets, float depth) {vec3 normalizedDeviceCoordinatesPosition; Generalized Device Correction Xy = (2.0 * piece coordinate) / uScreenSize - 1; Generalized Device Cordines Possibilities = 2.0 * Depth - 1.0; Vec4 clippaceposition; Clippaceposition.v = Uprogication [3] [2] / (Generalized Device Cordinates Pauses.) - (Uprogication [2] [2] / U Projection [2] [3])); Clipspace position. Xyz = Generalized Device CreditsPosition * ClipspacePosition. Vec4 eyeline = uInverseProjection * clippaceposition; Return eye position. Xyz / eyeposition.w; }  

Note: By now I'm assuming my depth texture is a GL_DEPTH_COMPONENT and attached to the framebuffer with GL_DEPTH_ATTACHMENT.

Ie:

  Globinated (GL_TEXTURE_2D, mDepthTextureId); GlTexImage2D (GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, MRSCREVENTH, MRScreenHIGHT, 0, GL_DP TH_COMPONENT, GL_UnSIGNED_BYTE, 0); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); GlFramebufferTextxture2D (GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, mDepthTextureId, 0);  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -