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 / SetObjectDepthReadMode and SetObjectDepthRange help needed

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 17th Jul 2017 20:25
No posts on here for this, so I've not got a lot to refer to.
I'm not getting how this works, although I got something nearly working how I want.

So, let us look at SetObjectDepthReadMode first.
There are numerous values such as - The available options are 0=never pass, 1=less than, 2=equal, 3=less than or equal, 4=greater than, 5=not equal, 6=greater than or equal, 7=equal, 8=always pass

There a 2 "equals" for a start. I understand 0 and 8, but what use would the other values be and what are they compared against? Each object's Depth value?

Also, if I set 8 (I want this object on top at all times) it still gets drawn behind an object set up with SetObjectDepthRange(obj,0,0). Does SetObjectDepthRange(obj,0,0) clash with depth check values?

Is there an example (or is it possible) to set something like:

Object A is in front of all objects
Object B is in front of all objects except object A

A good explanation / example of how the depth commands work together would be great.

janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 17th Jul 2017 21:32 Edited at: 17th Jul 2017 21:34
SetObjectDepthReadMode() compares the Depth-Buffer to the Objects-Fragment-Depth.

For example:
ObjectFragmentDepth=0.5
DepthBuffer=0.6
Object setup with SetObjectDepthReadMode( objID, 4 )=Greater Than
If Buffer>ObjectFragment then Pass the DepthTest
0.6>0.5=1: results in the object being visible where it normally isn't and is invisible where it normally is visible.

And yes it seems that SetObjectDepthRange(obj,0,0) overwrites/interferes with SetObjectDepthReadMode()... didn't knew that also

Using AGKv2 Tier1
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 18th Jul 2017 19:58
Ok, so how do I get/set the depth buffer value and the ObjectFragmentDepth?

Do I set the objectFragmentDepth depth to 0.5 using SetObjectDepthRange(obj,0.5,0.5) ?
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 18th Jul 2017 22:15 Edited at: 18th Jul 2017 22:21
Normally You don't want to set them manually.
Yes you could use SetObjectDepthRange(obj,0.5,0.5) to map the depth value to just 0.5
You read the depth buffer with the help of a rendertarget (SetRenderToImage(0,ImageID))
And you write the depth buffer via rendering an object to it i.e. DrawObject or Render3D

But It may be better if I/we try to help you to achieve a specific result instead of hacking some depth values into the render pipeline.
Quote: "I want this object on top at all times"

As you suggested SetObjectDepthReadMode(ObjectID,8) does exactly that.
It seems that it is not working for you...can you give me/us more informations please

Using AGKv2 Tier1
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 18th Jul 2017 22:59
Seems like a lot of work then if you need to use a depthbuffer rendertarget.

Maybe the DepthReadmode(ObjectiD,8) does work, but that doesn't help me with controlling middle depth objects (e.g. on top of everything except the object I set to 8).

OK, here's an explanation of what I'm trying to do.
I have created some spotlights using cones with lightmaps and they work really well.

I have a problem with the cones going through the floor so I thought about obscuring them with some planes. I have coloured one red for reference in the screen shots.
I figured I'd use the planes to selectively clip away the spurious parts of the cone that fall outside the arena. However, I can only seem to do this using SetObjectDepthRange(obj,0,0) because transparent objects still show on top if I use SetObjectDepthReadmode(obj,8)

I expect the pre-set rules for transparent objects supersede the "always on top" so it doesn't work without setting up depth tests for everything (e.g. the transparent light cone in front of this and behind that)

Anyway, you can see from the screens that it works using depthrange but under some conditions, the spotlight can overlap the red plane and I cannot force it on top because of using the SetObjectDepthRange(obj,0,0) seems to take ultimate top depth (near and near). If I use SetObjectDepthRange(obj,0,0.2) for the blocker and SetObjectDepthRange(obj,0,0.1) for the light it "should" work?
^^ I just tried this while I thought about it and it works
However, I'm not using DepthReadmode at all now, so it seems a bit hacky still. My guess with these settings then is that the blocker is hard-coded at a depth of 20% of the total camera depth range and the spotlight object is hard-coded at a depth of 10% of the total camera depth range?
Does depthrange map to camera range? Currently my camera range is near 1 >> far 6000.

Attachments

Login to view attachments
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 19th Jul 2017 00:14 Edited at: 19th Jul 2017 00:15
Quote: "Does depthrange map to camera range? "

Yes

I could also imagine to write a shader that clips away everything outside of a given object...
Or even like grouping some objects to a specified clipping object... very possible, but time consuming ^^

I'm glad you have a solution... you are putting much energy in this project
If you need another solution...I may write you a quick clipping box code thingy

Using AGKv2 Tier1
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 23rd Jul 2017 01:17
Actually, I scrapped the whole idea

Now, I used a really nice smooth Gaussian blur on my lightmap and it doesn't need clipping.
Was an interesting diversion and a useful experiment, but I will move on with my new lovely lightmaps

Login to post a reply

Server time is: 2024-09-30 05:22:57
Your offset time is: 2024-09-30 05:22:57