Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Depth render bug...again?

Author
Message
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Oct 2019 02:35 Edited at: 24th Oct 2019 02:36
Hey.

I found the following thread...

https://forum.thegamecreators.com/thread/216625

in which Janbo tried getting depth rendering working, but it failed. Paul noted that a bug existed, however the bug still seems to be there, or at least for me. The below code should render a simple scene, witha depth image in the corner. I'm getting a totally white sprite, which suggests the depth buffer is always reporting zero depth?

The author of this post has marked a post as an answer.

Go to answer

SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 24th Oct 2019 03:50 Edited at: 24th Oct 2019 04:14
This post has been marked by the post author as the answer.
Your code appears to be working well. It appears almost entirely white (in OpenGL/#renderer "Basic" mode anyway, black with gray in Vulkan/#renderer "Advanced" mode since it's inversed) due to the disparity in the selected clipping range. If you snap a screenshot, you can paste the image in an editor and do a solid paint fill in the sprite area to see that the shapes are actually there, but are just too near the edge of the non-linear depth limit to render with more visible grayscale.

To change that, switch your near clipping range from 0.01 to something like 100.0 and you should see all of the depth details come into view better across a wider range of grayscale colors based on the sizes and distances of the objects you are using.

When you perform depth renders, the equation is almost always done (properly) in a non-linear fashion. This means that as objects get closer to the near clip range (frustrum) you specify, precision in increased... and this is what you want. The farther out things get, the less precise they are... also what you want. So as things move out from the camera, the faster they will drop to higher depth levels ('up' to white in OpenGL, 'down' to black in Vulkan as they appear in AGK's depth render images) with lower precision.

So when you have a wide range across a large scaling, things will drop or rise to the far depth range faster, especially the bigger they are. They will only appear in higher degrees of grayscale variation when they get pretty close to the camera at a higher precision level.

There are ways to compensate for this, such as cascading different ranges for shadows. But in general, you'll want to keep your depth render measurements fairly close and scale your object world accordingly for the effect you are trying to achieve so that you get a nice balance between image quality and effect behavior across a particular range of depth.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Oct 2019 10:38
Omg.....thanks SFSW. I'd written a simple shader solution before I saw this, but wasnt getting the same range....now it's working perfectly. I think I lowered the near plane before I got the rest sorted and changing it back never occurred to me as a potential issue.

Many thanks.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 10th Nov 2019 09:53 Edited at: 10th Nov 2019 09:56
I think I have the same problem,

but I don't understand the solution.

I need to use OpenGL ES 2.0 renderer.

3D asset from that video
https://www.youtube.com/watch?v=57fEpv_qZT8

This asset from madmos
https://sketchfab.com/3d-models/sketchfab-hand-painting-challengesummer-cottage-e4548772148c45a280f8d8136569c192


Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Nov 2019 12:40 Edited at: 10th Nov 2019 12:41
Xaby

You have just used transparency on an object and either need to enable depth buffer writing SetObjectDepthWrite( objID, 1) or use alpha masking instead of transparency SetObjectAlphaMask( objID, 1)

Your problem isnt related to the one above that was about the standard non linear depth buffer.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 11th Nov 2019 19:14
@Bengismo,

you helped me with SetObjectAlphaMask( obj, 1)
didn't know, that I had to set it up before.

thx.

Login to post a reply

Server time is: 2024-04-19 20:01:46
Your offset time is: 2024-04-19 20:01:46