Author Topic: Camera Rendering issues with multiple cameras + Ultimate FPS  (Read 17145 times)

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Camera Rendering issues with multiple cameras + Ultimate FPS
« on: September 27, 2013, 10:57:06 PM »
Hello,

I purchased your kit today.  When I create a new project and import your package and open your example scene, everything works well except for that ghosting graphics problem that you mentioned happens in Unity 4.2.0 (which is my current version I'm running).

However, when I open my existing project and simply import your package and open your example scene, when I go under water, there is no underwater effect.  When I look in the scene hierarchy I can see that it's disabled but if I try to enable it, it disables instantly.  I've set my project's Quality Settings to "Fantastic" but that doesn't appear to do anything.  Do you have any recommendations as to how I can fix this?

I also tried dragging your WATER_Module and WATER_Surface into my own project scene that I was working on before I purchased your product.  I'm using the Ultimate FPS Camera system and your shaders do some really unusual things to the rendering of the scene.  For instance, if I get close to a WATER_Surface, my main camera simply stops rendering and whatever the image was in the image buffer is just stuck on screen until I move the camera and look away from the water, then the camera comes back but as soon as I move a little bit, the renderer freezes again.  I know that I'm walking around because I can hear footsteps and I can see in the Editor that I'm walking, it's just my game camera isn't rendering anymore.  Ultimate FPS has 2 cameras and I tagged the top-most camera as the Main Camera.

Lastly, when I walk into the water it will give me a console error about the Player not having a rigid body on it.  The Ultimate FPS doesn't comes with a rigid body but I put one on anyways and set it to isKinematic but for some reason I still get the no rigid body error (var hitVeloc = CurrentColliders[cx].gameObject.rigidbody.velocity; < that line water_splashHandler.js script).

Any suggestions would be greatly appreciated.

Justin

« Last Edit: October 01, 2013, 12:01:30 PM by justinl »

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #1 on: September 28, 2013, 02:04:40 AM »
I did some further tests to figure out why the refraction isn't working and it looks like the Physics.Raycast() in waterModule_underwaterEffect.js (around line 65 in checkWaterTransition()) isn't detecting that it's hitting water.  Do you have any idea why this would happen?  I did a debug raycast and I can see the Ray is going through through the water, yet it's not detecting that it's hitting it.  I noticed you're using a layer mask so I disabled it from the Physics.Raycast() and tried again and the Raycast still shoots right through the WATER_Surface layer even though the surface is enabled and the mesh collider is on it and it's still set toe Layer: Water (remember, I didn't touch anything I just opened your scene in my project and it doesn't work).  And since the Raycast doesn't work, the isUnderwater never gets set to true (btw if I explicitly set the isUnderwater to true, then the refraction pane shows all the time.  So the shader is fine).  Thoughts?

Justin
« Last Edit: September 28, 2013, 02:08:21 AM by justinl »

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #2 on: September 28, 2013, 02:44:41 AM »
Okay!  After more testing it looks like the reason the raycast wasn't working is because the water is a trigger, and I had set my physics settings to ignore triggers on Raycast.  So that's figured out!  Also, for Ultimate FPS the way the camera is positioned, I had to change one of the lines of code to position the refraction pane in the proper place:

waterModule_underWaterEffect.js
underwaterRefractPlane.transform.localPosition = Vector3(0.0,0.0,(setCamera.camera.nearClipPlane+0.5)); // changed this from 0.02 to 0.5

There's still some crazy rendering issues going on though but I'll see if they get fixed for Unity 4.2.1.  Cheers!

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: Suimono not working in my project
« Reply #3 on: September 28, 2013, 05:13:23 AM »
Hi Justinl :D

Well, I have to say I'm impressed (and relieved) that you've been able to figure out all these issues!

I've seen the trigger/raycast problem before, but it seems this variable hasn't been exposed by Unity unfortunately.  Luckily it doesn't come up that often. :)  The camera offset issue you brought up is a good one, and has convinced me to increase the default setting and hook it into the offset variable as well in the next version.

Are you still getting the rigidbody errors in the console?  I've made a couple edits regarding this, but they haven't been posted yet.  Send me an email to konnichiwa@tanukidigital.com and I'll send you an updated code snippet that I think will address this problem for you.

Unity 4.2 really messed up shaders across the board... I think you'll find 4.2.1 fixes all your visual shader issues.  Of course if you run into any further problems let me know and I'll try and figure them out before you do :D

All the best,
Justin Kellis

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #4 on: September 30, 2013, 01:14:08 AM »
Hi!

I've upgraded to 4.2.1 but I'm still getting a camera rendering problem as I explained before.

Quote
I also tried dragging your WATER_Module and WATER_Surface into my own project scene that I was working on before I purchased your product.  I'm using the Ultimate FPS Camera system and your shaders do some really unusual things to the rendering of the scene.  For instance, if I get close to a WATER_Surface, my main camera simply stops rendering and whatever the image was in the image buffer is just stuck on screen until I move the camera and look away from the water, then the camera comes back but as soon as I move a little bit, the renderer freezes again.  I know that I'm walking around because I can hear footsteps and I can see in the Editor that I'm walking, it's just my game camera isn't rendering any more.  Ultimate FPS has 2 cameras and I tagged the top-most camera as the Main Camera.

Have you ever implemented your system with 2 cameras?  I'm confident this is the the issue because when I disable my second camera, I don't have the problem.  Also, it doesn't seem to matter which camera I have tagged as the Main Camera, because the problem always happens regardless of which camera is tagged as main.  The only way to stop the issue for me is if I disable my second camera.  Is there any special instructions for implementing with two cameras?  Also, if you'd like a video of the issue please let me know and I'll create one for you.

Cheers,
Justin
« Last Edit: September 30, 2013, 01:32:52 AM by justinl »

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #5 on: September 30, 2013, 01:27:56 AM »
Oh also, another issue I have is that I have these weird rings showing up every time I use your prefab (see attached image).  It's like the water ripples from your demo are baked into the texture on the shader or something.  How can I get rid of them?

Thanks!
Justin

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #6 on: September 30, 2013, 01:30:32 AM »
Oh also, another issue I have is that I have these weird rings showing up every time I use your prefab (see attached image).  It's like the water ripples from your demo are baked into the texture on the shader or something.  How can I get rid of them?

Okay, ignore that question as I see it has to do with the Flow Map on the mat_waves (as seen on your pinned thread on your forum).

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: Suimono not working in my project
« Reply #7 on: September 30, 2013, 03:51:16 AM »
Hi Justin,

Quote
I'm still getting a camera rendering problem as I explained before.
yes, If you can post a video of what you are seeing that would be very helpful.   The camera object in Suimono is tracked only for dynamic reflections and underwater effects.  The normal above surface view shouldn't be affected... :(   I haven't worked with UFPS... I'll see if I can find info on their camera setup.  Do you know why/how they are using the two cameras?

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #8 on: September 30, 2013, 07:18:31 PM »
Hi,

I frapped a video for you:  www.ubiqvisuals.com/media/unity.rar

What you see is me dropping in the stock SimplePlayer UltimateFPS player prefab into your scene and deleting your main camera that's in your example scene to start.  You see that as I move and look around, sometimes the camera rendering the world just stops rendering and if I continue to look around it will "come back" and I can see for a bit until I move or look in another place and then I cannot see again.

The reason for the two cameras is that 1 camera renders the weapon and the other camera renders the world.  The reason for this is so that the weapons don't protrude through walls and other geometry (the weapon camera is rendered on top of everything).  Also, it allows you to better adjust the weapon size in the game because you can change the FOV of the weapon separate from the FOV of the world camera.  This is probably the reason why the caustics projection when I go under the water is showing incorrectly.  The caustics is displaying on the weapon as if it's using the same FOV as the world, but it's not.  The world is maybe 70 FOV (clear flags: Skybox, culling mask is set to everything except the weapon layer) but the weapon camera is probably 40 FOV (Clear Flags Depth only, culling mask is weapon layer only).  Do you know how I could render a separate caustics pass onto the weapon camera to avoid this problem.  Also, I did try to set both FOV to the same to see it it fixed the problem but it didn't.  I should also mention I'm using Unity Pro 4.2.1 (latest version).

If you want to see the details of how the camera is set up, the Ultimate FPS documentation section explaining it is here: https://docs.google.com/document/d/17Ns3PwlSWg4kqWwnBZ4DRa9n_LMSOe7m3KzMfsPUGBI/pub?embedded=true#h.laoox2q9gmr0

There's also a bit of information about combining image effects with multiple cameras is you think that might be useful to you:
https://docs.google.com/document/d/17Ns3PwlSWg4kqWwnBZ4DRa9n_LMSOe7m3KzMfsPUGBI/pub?embedded=true#h.irtfok1ral0c

I look forward to hear if you have any thoughts about the rendering problem.  Thanks!
Justin
« Last Edit: September 30, 2013, 07:29:11 PM by justinl »

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: Suimono not working in my project
« Reply #9 on: September 30, 2013, 08:53:29 PM »
Hi Justin,

OK, this is not what I was expecting to see.  From what I can tell this looks like a camera clear flag issue.  The main UFPS cam only seems to be clearing the screen buffer whenthe camera is moving.... at all other times it seems to not be clearing the buffer which is why you see the whack screen artifacts.

You may be able to check this by watching the camera Clear Flag attribute and seeing if/how it changes as you move around the scene.

This doesn't seem to be a Suimono issue, as it's affecting the entire screen and not just the water surface, but you could try deleting the WATER_Module object from your scene and see if it still has the same effect on the scene objects.  Have you tried UFPS in other scenes not relating to Suimono?

The last thing I can think of that might cause an issue is that Suimono explicitly sets the main cameras depth rendering mode in order to retrieve view dephmask information, but it doesn't take into account two cameras.  You can try turning this off by opening up the "waterModule_underwaterEffect" script and commenting out line 35 temporarily....

Code: [Select]
//setCamera.camera.depthTextureMode = DepthTextureMode.Depth;
But I'm betting money on the UFPS camera clear flags not kicking in correctly.  in general the main camera ought to wrap to a skybox or color, and the gun camera ought to be set to don't clear or depth.

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: Suimono not working in my project
« Reply #10 on: September 30, 2013, 09:09:52 PM »
Oh, about the caustics... they're being projected onto the gun object in the space of the first camera, not the gun camera which is why it looks so strange.  What you can do is go to the Water_Module_caustic effect compononet and the "ignore these layers" flag to ignore whatever layer the camera is on.  This ought to remove this effect.

In order to get caustics projected onto the gun accurately you'll need to build a separate caustic object that only projects onto the gun layer.  The caustic object is located under the WATER_Surface object... you'll need to duplicate this and move it outside of the water_surface before you can change it's layer parameters.

Let me know how this works for you!

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #11 on: September 30, 2013, 09:13:26 PM »
Hi,  Thanks for the reply.

In the video I'm moving the whole time (I don't stop when the camera rendering issue is happening, it just looks like that because the screen freezes and the frame doesn't re-render.  It's stuck with whatever the last frame was and only the weapon cam is continuing to render).  I watched the clear flags field on both cameras and ran around the scene but they don't seem to change at any time. 

I've used UFPS for the past 3 months in multiple different scenes and I've never had this issue before.  It only seems to happened when I drag your WATER_Module into my scene.  And when I remove it from my scene the camera works fine.  I can also post to their forum about this to see if anyone else has run into this issue.  I've done some searching online but can't seem to find anything about this weird behaviour.

I did try to comment out the DepthTextureMode line but the problem unfortunately still persists.

Justin

ps - Thanks for the info about the caustics.  Seems like an easy fix now that I know what's doing what.  I'll give it a shot!

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: Suimono not working in my project
« Reply #12 on: September 30, 2013, 10:51:32 PM »
Hmmm.... then I'll get a copy of UFPS and see if I can recreate this on my end.  Does it make any difference if you're running in deferred mode or forward mode?

justinl

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Suimono not working in my project
« Reply #13 on: September 30, 2013, 11:08:21 PM »
Hi,

Just wanted to give you an update as I seem to have isolated the issue to 3 of the effect GameObjects inside the WATER_Module that cause the rendering issue.  It's the _splash_effects > splash_rings_normal_prefab, the effect_water_fade, and the effect_dropletsParticle.  I see that both of these objects are basically just particle systems.  I'm still trying to figure out exactly what is the problem with each one.  I tried using just a normal Diffuse material for them and they still have a problem.  I can't seem to narrow it down but I just wanted to to let you know the progress so you don't waste any time if you were looking into it.  Would love to hear if you have any clue as to why this is happening. haha.  seems like a very unusual bug.

Cheers,
Justin
« Last Edit: September 30, 2013, 11:44:51 PM by justinl »

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1596
    • View Profile
    • Tanuki Digital
Re: Camera Rendering issues with multiple cameras + Ultimate FPS
« Reply #14 on: October 01, 2013, 12:24:53 PM »
Interesting... I think it's more complicated than this though.  I can see it on my end as well, just as you describe.  When I disable the components you specified it makes it better... sometimes.  I'm going to keep looking into this and hopefully will have a solution for you soon.