Author Topic: Controlling under water shader render camera with multiple camera setup  (Read 3791 times)

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Hello all.

I am  using a multiple camera setup with a depth camera and a far camera. I am rending the boat to the depth camera and suimono to the far camera.

The ship is large and has decks that are under water. I am trying to get the under water shader to render to the far camera only so that the water appears outside the ships through the windows in the below decks.

So far the shader renders to the depth camera even with manual camera and camera set on module to the far camera. I cant seem to find in the code how it is rendering this shader to what camera and I need to be able to control what camera the under water shader renders too.

So far the system works the water does not clip though the ship, however the underwater fog is inside the ship on the near depth camera instead of on the far camera so i have the appearnce of being underwater outside the ship while the player is below decks and the water plane.

Thank you,
johnny brown


PS.

I see that the shader is being passed through "surfaceRenderer" but where are the camera controls. I want to force the underwater shader to render to my far clipping camera.


......

   cam = gameObject.GetComponent<Camera>() as Camera;
         if (suimonoModuleObject != null && suimonoModuleObject.setCamera != null){
            copyCam = suimonoModuleObject.setCamera.GetComponent<Camera>();
         }

Am I onto something here, perhaps i should try switching this to my far camera see what happens.

......

Ok with my current setup being I have a Near Depth Camera and a Far camera. The ships is being redered to the Depth camera and suimono to the far camera. I have it working where the ocean does not clip through the boat boat the underwater shader will not render texture to my far camera because I am assuming it only renders to a depth camera?

Can I render the under water fog shader to a non depth camera?


.....

I have done it. I have water outside the windows on the bottom decks of the ship as the waves pass by and no water on the interior and im not using the depth plane shader ;) ;) The only thing i need to do is disable underwater effects on some low lying areas of the exterior of the ship.
« Last Edit: September 23, 2017, 02:16:48 PM by onephpmastermind »

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #1 on: September 23, 2017, 07:09:34 PM »
video to follow! Need to optimize the boat, its 47 mill verts at the moment before i post a video of me walking around the lower submerged decks with the ocean seamlessly kept out of the boat where you can see under the ocean from within the interior of the boat ;)

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1704
    • View Profile
    • Tanuki Digital
Re: Controlling under water shader render camera with multiple camera setup
« Reply #2 on: September 23, 2017, 07:48:42 PM »
Hi onephpmastermind,

It sounds like you were able to achieve your goal here regarding the depth and far cameras?  Let me know if you still run into any trouble.

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #3 on: September 23, 2017, 08:15:29 PM »
Hi onephpmastermind,

It sounds like you were able to achieve your goal here regarding the depth and far cameras?  Let me know if you still run into any trouble.

Yup sure did, it needs a little tweaking as far as timing. But you can look at the under view of the ocean from within the cabin below the waters surface and watch the fish swim by without any clipping of of the ocean into the boat. I am setting up the model now so that transparency works on the low lying parts of the aft and doing some optimizing of the very large ship and i will post a video here of the prototype.

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #4 on: September 23, 2017, 11:38:29 PM »
Hi onephpmastermind,

It sounds like you were able to achieve your goal here regarding the depth and far cameras?  Let me know if you still run into any trouble.

https://www.youtube.com/watch?v=ErCP13NLv_w&feature=youtu.be


Check out the multiple camera setup here, still a work in progress ;)
https://www.youtube.com/watch?v=ErCP13NLv_w&feature=youtu.be

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1704
    • View Profile
    • Tanuki Digital
Re: Controlling under water shader render camera with multiple camera setup
« Reply #5 on: September 24, 2017, 07:47:33 AM »
Very Nice!  :)  Thanks for sharing!

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #6 on: September 24, 2017, 11:34:59 AM »
Very Nice!  :)  Thanks for sharing!

now im going to implement a camera switching system for interior and exterior views because of issues with the depth camera and transparency because I want transparency around the boats mesh for exterior view.

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #7 on: September 24, 2017, 08:25:21 PM »
Very Nice!  :)  Thanks for sharing!

https://www.youtube.com/watch?v=jifE__Brj2o&feature=youtu.be

Updated version check it out! Amazing. When i first started with unity I gave up on trying to do this, but after doing several other projects and mastering the camera system I have figured out how to do it ;)

There are some issues that are going to force me to make an interior/exterior camera switching system to allow for ocean transparency around the boat model due to depth camera issue. That will have to wait until next weekend, i'm only a weekend warrior on this project at the moment... back to my day job as a web developer.


Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1704
    • View Profile
    • Tanuki Digital
Re: Controlling under water shader render camera with multiple camera setup
« Reply #8 on: September 24, 2017, 08:44:39 PM »
Is that Styx??  ;D
Looks really great.  That is quite a boat it's bigger than my apartment.  Working around all this stuff in Unity is a lot to wrap your head around at first, and it can be really frustrating.  I've spent countless hours delving into the depths of Unity.  But when you finally get things working it's glorious and a great feeling.

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #9 on: September 24, 2017, 08:52:59 PM »
Is that Styx??  ;D
Looks really great.  That is quite a boat it's bigger than my apartment.  Working around all this stuff in Unity is a lot to wrap your head around at first, and it can be really frustrating.  I've spent countless hours delving into the depths of Unity.  But when you finally get things working it's glorious and a great feeling.

Yah it's styx lol.

Oh this is a work in progress, I am still a hobbyist game developer. (not a hobbyist programmer, however).

This system uses Ghosting method with camera mirroring to get the player controller walking around on the moving ship. Multiple camera's for depth and distance. Right now if you goto the back of the boat the transparency doesn't work with water above the aft because the ship is being rendered first in the depth camera and the ocean in the non depth. I can build a work around for this to make it work seamlessly by putting triggers around all of the ships lower deck entrances and switching the camera layers so that while you above deck the ocean will render first and boat second allowing for the transparency camera to work properly.

Next weekend I will demonstrate an orbiting camera around the boat and interior camera where the player can switch to orbiting camera to first person controller camera and seamlessly traverse the ship being able to view the ocean below and transparent water when it comes above the boat and around the boat model.

I will also program a controller so you can drive this monstrosity of a boat, however I may get a smaller boat off sketchup this one is pushing 20 Mill verts with the interior stripped out and that is where most of the performance draw is coming from, and I have turned it into a solid so it isnt the draw calls, its the deferred lighting I believe lighting so many pixels.

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #10 on: September 25, 2017, 04:03:23 AM »
Is that Styx??  ;D
Looks really great.  That is quite a boat it's bigger than my apartment.  Working around all this stuff in Unity is a lot to wrap your head around at first, and it can be really frustrating.  I've spent countless hours delving into the depths of Unity.  But when you finally get things working it's glorious and a great feeling.

I binged a little, kind of got a little obsessed lol..

check out the latest update, massive performance increase, possible to run in 4K resolution with high frame rate, volumetric clouds, sun shafts, pest fx stack ect.

https://www.youtube.com/watch?v=OFzQnEfc_tI

on a side not, i think im going to lerp the volume up and down when you pop in and out of the ocean surface plane for sea life, as you can see it just cuts on and off right now, but a gradual volume increase and decrease will be good. Not sure if I can make it "perfect" but it will be pretty good.

« Last Edit: September 25, 2017, 04:09:35 AM by onephpmastermind »

onephpmastermind

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Controlling under water shader render camera with multiple camera setup
« Reply #11 on: September 25, 2017, 03:02:39 PM »
Later I am going to add this submersible to the aft deck of the ship and it will be launchable and pilotable under the sea. There will be lot's of wild life and under water terrain to explore. I will add a radar map so you can explore marketed locations (reefs) and be able to return to the ship:

https://3dwarehouse.sketchup.com/model/aa8f53fcf483cac160690e4d6d20ec5c/Submersable

I have quite a bit of work to to get to that but what do you think ? Will be a nice demonstration of my ability to write controllers and your amazing suimono water system.

You never know this may actually turn into a little mini game that I will release for public download when its complete. If you like I can include your logo make it a free advertising tool for your product. I don't mind.
« Last Edit: September 25, 2017, 03:55:58 PM by onephpmastermind »