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.

DarkBASIC Professional Discussion / object in screen, but..

Author
Message
Lucka
19
Years of Service
User Offline
Joined: 1st Oct 2004
Location:
Posted: 8th Jul 2015 11:05
I know i did it years ago, but i can't find a FAST solution for this (i mean, searching on forum).

I wanna know when a object is actually visible on screen.
OBJECT IN SCREEN tell me is in the bonduary of the screen
OBJECT VISIBLE tell me that is not hidden

But i wanna know if it is BEHIND some other object, in fact actually visible..



Lucka - gawteam coder - www.gawgames.com
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jul 2015 13:58
Quote: "in fact actually visible.."


Not quite sure what you mean by that. What's wrong with object visible()?



Powered by Free Banners
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 8th Jul 2015 15:07
Dark Occlusion has this function in the DLL version:

Quote: "
Get Object Visible

Returns a 1 if the given object is visible, 0 if it is occluded or not in the screen.


ObjectID The id of the object.


isVisible = Get Object Visible (ObjectID)
"


wattywatts
14
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 8th Jul 2015 16:27
Intersect object works pretty well.
Lucka
19
Years of Service
User Offline
Joined: 1st Oct 2004
Location:
Posted: 8th Jul 2015 17:48
in fact OBJECT VISIBLE means simply that you didn't use HIDE OBJECT on the target object.

what i wanna know is IF the object is
NOT hidden
IN screen
NOT occluded by anything

the usual application is the sun lensflare, the object SUN is not hidden, is in screen, but a zeppelin is flyng in front of the sun.. the lensflare must be turned OFF.

the dark occlusion solution seems EXACTLY what i need, intersect object is so slow..

Lucka - gawteam coder - www.gawgames.com
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 8th Jul 2015 17:48 Edited at: 8th Jul 2015 17:50
This is an advanced feature of modern game engines which cull objects hidden behind other objects, portals or event trigger boxes. I am curious as to how you achieved it before, assuming you did not use Dark Occlusion or raycasting.

***
Out of curiosity, why do you need to check visibility? Are you experiencing slow downs in your application and are thinking of excluding objects blocked by other objects?**** OK you just answered this as I made the post.

Lucka
19
Years of Service
User Offline
Joined: 1st Oct 2004
Location:
Posted: 8th Jul 2015 21:12
the only solution is dark occlusion.
cuz all other methods work only with a limited number of objects.

i'd like to analize how evolved did it for his advanced lightning (for the sun lens flare)

start investigate

Lucka - gawteam coder - www.gawgames.com
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 8th Jul 2015 21:47
I'm making two a wild guesses; my first guess is that Evolved did not use Dark Occlusion, or any third party plugin for any of his frameworks for that matter; he tends to not require dependancies but the two possible exceptions are Blitz Terrain and Matrix1 for the odd example build.

My second guess is that he did not use culling or occlusion to hide or show the sun; or the rays of light between the leaves in his tree demo for that matter. I think Evolved would use a shader based rendering pass to provide the 'len flare' as a post rendering effect; I say this because most of his shader engines make use of post rendering, which is an ideal part of the pipeline for rendering lense flares given the seperation of concern whereby all one needs is the location of the sun in the screen along with a rendering layer revealing the edges of geometry.

All in all, there are many ways to skin a cat. It may be worth downloading AL to see what was done. And perhaps look at techniques used in other engines like Unity.

Mikko
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: Finland
Posted: 13th Aug 2015 23:19 Edited at: 13th Aug 2015 23:24
Hi,
I don't know how lensflares are done nowadays, but you could
just test with couple of the point commands near the middle of the light
source in the screen.

If the test is done before placing the flares it works because
the obscuring object in front is usually not so bright, than the light source.

If you can find by testing, which is the rgb of the light (or average),
then you know if its different (there is object in front) and you
can shut down the flares.

This was my first attemp to help someone in a looong time here
Mikko

mikko_ketonen( )hotmail.com
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Aug 2015 08:49
I haven't thought about this for a while, and I don't have anything in front of me to verify or review, but reaching into the depths of my memory, I think the math may not be that complicated.

You need an invisible plane. The plane represents the minimal distance in space something is considered in front of or behind. Use the dot product to calculate the distance to the plane. The value returned is either negative or positive. The sign determines in front or behind.

I think this idea applies to something passing in front of the camera and the sun at the same time. I'm short on the details at the moment but I think this is the track.

Enjoy your day.
Lucka
19
Years of Service
User Offline
Joined: 1st Oct 2004
Location:
Posted: 14th Aug 2015 09:55
in fact my pain is that the work is already done..
when an object is "culled" by another the gpu simply don't render it.
i'd like to reach that flag and use it

i have something like 600 different object that can pass in front of the sun or the camera, i can't test all (for all the lights, i have lot ofo light )

you can see in WIP board how i arranged it out, but thx for the help!

Lucka - gawteam coder - www.gawgames.com
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 15th Aug 2015 18:32
I did this for an intro screen where the camera flies around earth and picks up lens flare when the sun comes into view. The earth passes between the camera and the sun.

I used the sc_raycast command in Sparky's Collision plugin. It worked great.



Not the most elegant code, but it works.

Login to post a reply

Server time is: 2024-03-28 10:15:10
Your offset time is: 2024-03-28 10:15:10