Author Topic: Seethrough & terrain  (Read 175 times)

DavidBVal

  • Newbie
  • *
  • Posts: 26
    • View Profile
Seethrough & terrain
« on: November 22, 2019, 05:44:43 AM »
I have a highlighted character with seethrough enabled and works fine when view is blocked by other gameobjects. I have been able to configure what objects occlude the characters and which ones don't using the seethroughoccluder script. However, I am stuck with the terrain, because of two issues:

1) SeeThroughOccluder component doesn't work when added to a terrain (right now, terrain always causes a seethrough effect when blocking my characters).
2) I don't want the terrain details (grass, flowers) to cause seethrough. However, my terrain trees must cause seethrough.

Can seethrough be filtered by layer? My terrain is on "ground" layer but my trees are "obstacles" layer, so maybe that could be a solution.

I know this requirement is maybe beyond the scope of Highlight Plus, but I'd be very grateful for any pointers towards a solution, or even to comission a custom modification. Thanks in advance for any help!

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5390
    • View Profile
Re: Seethrough & terrain
« Reply #1 on: November 24, 2019, 01:34:23 PM »
Hey, thanks for posting this question. Iíll check the alternatives and get back to you soon.

DavidBVal

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Seethrough & terrain
« Reply #2 on: November 24, 2019, 05:43:10 PM »
Thankyou, looking forward to any help you can offer.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5390
    • View Profile
Re: Seethrough & terrain
« Reply #3 on: November 27, 2019, 02:01:04 AM »
Hi,

There're two options here to make the terrain cancel the see-through effect:

Option 1) Perform a CapsuleCast between camera and character. If the object hit is a terrain, cancel the see-through effect.

Option 2) Perform a custom render pass using a replacement shader in which the terrain is rendered again writing to stencil buffer to cancel the see-through effect.

As always we have to choose between performance and accuracy. Option 2 is a lot more expensive but more accurate and allows the effect to work along special situations like part of the character being occluded by the terrain and part occluded by a wall. In this case, the part of the character occluded by the wall will keep the see-through effect. On the other hand, option 1 is a lot faster but will disable completely see-through on the character as long as the raycast hit the terrain.


DavidBVal

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Seethrough & terrain
« Reply #4 on: November 27, 2019, 02:35:31 AM »
I think Option 2 is much better, at least in my case performance is not an issue.

But will I be able then to enable see-through for the trees that are in the terrain? they are on a different layer. Maybe the redraw you mention could be layer-specific, if I could just redraw my "ground" layer, it'd be solved for me.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5390
    • View Profile
Re: Seethrough & terrain
« Reply #5 on: November 27, 2019, 03:11:01 AM »
Check out latest beta which includes a solution for option 1 (attach occluder script to your terrain and select RayCasting as detection method in the inspector).

Option 2 can take some more time but I'll do some tests soon.

Regards