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 / Draw only part of an object.

Author
Message
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2013 15:15
Here's a simple demo showing what can happen when an animated object walks through a clipping plane. The shader demonstrates what Chris Tate and I have been saying about the use of clip() - there are no weird gaps or uninitialized parts of the scene, i.e. the background plane is textured as you would expect.

The shader uses two passes: exposed unclipped back facing pixels are coloured red, front facing unclipped pixels are textured normally.



Powered by Free Banners
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Aug 2013 16:13
@TheComet & Green Gandalf

Until now, I didn't realize what a great shader you made guys ...Thanks for sharing

I'm not a grumpy grandpa
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Aug 2013 16:15 Edited at: 26th Aug 2013 16:21
Quote: "Here's a simple demo showing what can happen when an animated object walks through a clipping plane. The shader demonstrates what Chris Tate and I have been saying about the use of clip() - there are no weird gaps or uninitialized parts of the scene, i.e. the background plane is textured as you would expect.

The shader uses two passes: exposed unclipped back facing pixels are coloured red, front facing unclipped pixels are textured normally."


Could you possibly post a few screen shots of it in action? I'm at work right now and am itching to see it, but can't for another 6 hours or so.

[EDIT] Thanks chafari!

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2013 16:30 Edited at: 26th Aug 2013 16:31
Here's one as she starts to walk through the invisible clipping plane. Her nose, right forearm, chest and left leg have been clipped.



Moral: don't walk through sheets of glass.



Powered by Free Banners
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Aug 2013 16:50
Aah, so you're using the insides of the object to serve as the edge colour! That's quite ingenious, nicely done. I have one tiny proposal, would it make more sense to use no culling at all instead of clockwise culling in the first pass?



TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Aug 2013 17:33 Edited at: 26th Aug 2013 17:42
Quote: " I have one tiny proposal, would it make more sense to use no culling at all instead of clockwise culling in the first pass?"


No - because then the front and back polys would both be drawn and it would probably be a matter of luck which would be drawn first. In fact it probably makes sense to draw the front facing polys first since then only the exposed back facing polys would be drawn. At the moment all back facing polys are drawn when they pass the Z depth test even if the second pass subsequently draws over them. Results should be the same though but there might be a tiny performance boost.

Edit Just noticed:

Quote: "Location: I`m under ur bridge eating ur CATS"


Noooooooo!

Afterthought You're right about there being an issue with "open" objects. This can happen if you're using a sphere to do the culling as the reverse side might be culled too so you'll get a gap where you can see the background. But turning off culling won't be the solution.

Afterthought2 Ah! Just realised it might be the solution but you'd have to fiddle with the z tests or something to ensure the second pass doesn't fail the z test. I'll think about it. Good point!



Powered by Free Banners
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Aug 2013 18:00 Edited at: 26th Aug 2013 18:04
I think disabling writing to the depth buffer will do this:



Or was it ZENABLE? One of those.

[EDIT]
Quote: "Noooooooo!"


...WHO'S WALKING OVER MY KONGĀ® Denim Tunnel, growled the troll-cat with a deep voice...

Arguably one of the best children stories of all time.

TheComet

Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 26th Aug 2013 18:27 Edited at: 26th Aug 2013 18:40
hey. I'll compile the new sonar blast shader.

No, the edges don't need to be colored.

Edit:

Hey the update looks good. and yes I typed in the wrong thing, though to be fair I copied the code on how to use.

Also I found if I make the line really thick I get the effect I want-ish.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Aug 2013 18:51
Quote: "Also I found if I make the line really thick I get the effect I want-ish."


I'm guessing you want the "normal" texture to be drawn on one side of the sphere, and another, new texture to be drawn on the inside of the sphere?

TheComet

Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 26th Aug 2013 19:10 Edited at: 26th Aug 2013 19:11
No. I want only the part inside the radius to be drawn. But really I just needed to show a path that would otherwise not be seen.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Aug 2013 19:18
Ooh, you want to combine the two shaders? Well that's pretty straight forward, but I'm going to let GG do that (because I'm at work).

TheComet

Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 26th Aug 2013 19:30 Edited at: 26th Aug 2013 19:31
well work bro

edit:

mmm... well maybe combining them could work, you know? the Mario shader would only draw the part the player is standing on, and the sonar blast one would do the outline.
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 28th Aug 2013 01:44
Hey Comet. Is it possible to have multiple pings in your sonar effect? Or would I need to make more copies of the effect and apply them to copies of the object that would be pinged?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Aug 2013 01:59
Sure, two questions:

1) How many do you need at maximum?
2) Do they all originate from the same location, or different locations?

TheComet

Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 28th Aug 2013 02:01 Edited at: 28th Aug 2013 03:53
4 max. And at different locations.

edit:

thanks bro. this is really cool of you.

Login to post a reply

Server time is: 2026-07-06 18:46:03
Your offset time is: 2026-07-06 18:46:03