Search Unity

  1. Unite Berlin 2018 schedule is now updated with talks on real-time ray-tracing, upcoming 2D features & many more. Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  4. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

[FPS Render] First Person View 2.0 - No Clipping, Environment Shadow Support and Independent FoV

Discussion in 'Assets and Asset Store' started by eskovas, Sep 23, 2015.

  1. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    FIRST PERSON VIEW 2.0

    Version 2.0 is now available on the Asset Store: http://u3d.as/xzu

    First Person View is an asset that offers a solution for first person perspective in Unity, where first person objects won’t clip through the environment, have a separate field of view and receive shadows from the environment.

    With version 2.0, a second solution is offered for first person perspective, which requires a simpler setup, is not scene complexity dependent, has less limitations and performs better than the first solution, making it, at the moment, the best solution available in Unity for a first person perspective.

    Both solutions are offered with this package, since one could be more appropriate than the other.

    Every script is well documented to make it easier to learn and understand how both solutions were made.

    Both solutions are offered with this package, since one could be more appropriate than the other.
    FirstPersonView_feature.jpg

    FirstPersonView_environmentFOV.jpg

    FirstPersonView_environmentFOVFPV.jpg

    Features

    Game Features
    • First Person View models don’t clip through the environment.
    • First Person View models receive shadows from the environment
    • Independent Field of View between First Person View and the World View
    Script Features
    • Ability to automatically change between World View + First Person View and World View only. (useful when the player interacts with the environment)
    • Ability to assign and remove objects to/from the First Person View perspective
    • Automatic Layer assignment for First Person Objects. It preserves original layers when changing the objects back to World View

    Release notes of Version 2:

    Overall

    · Created generic interfaces and classes that are used in both solutions (IFPV_Camera, IFPV_Object, IFPV_Renderer, FPV_Camera, FPV_Object, FPV_Renderer)
    · Created more examples for both solutions, along with examples on functionalities offered by these solutions. (Like aiming and firing)
    · Added each component to the Component menu of Unity, making it easier to add FPV components to the objects
    · Removed Editor scripts and Instantiate methods on the FPV static class

    Multi-Camera Solution

    · Improved overall performance of the system
    · Reduced garbage generated
    · Changed recursive methods to iterative methods
    · Merged FPV_Object_Custom to FPV_Object, making it support custom shadowcasttypes
    · Added support for first person objects to cast shadows on the environment
    · Added Prefab that demonstrates the Multi-Camera setup

    Shader-Material Solution

    · Added new solution for first person perspective
    · Simpler setup than the first solution
    · Uses only one active camera and one disabled camera
    · No screen-space effect limitations
    · Only requires scripts on first person objects (not scene complexity dependent)
    · Practically no performance cost
    · Requires one Shader Keyword
    · Geometry intersection only happens in some specific cases. This solution works for most cases very well.
     
    Last edited: Nov 12, 2016
  2. EMGPY

    EMGPY

    Joined:
    Jul 11, 2014
    Posts:
    91
    Thx for making free, Really is rare something assets of code and free and very well documented. :)
    Waiting to see in Github
     
  3. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Thanks :)
    regarding the GitHub, i'm going to wait until the asset is live on the Asset Store. It's been 7 days since i submitted it, so i hope it won't take much more time.

    Regarding the current state of the asset, i've already worked on a few things for the first patch:
    • The 3 cameras now have static variables on the FPV Class for easy access.
    • All cameras set their static components on Awake. A manual public function is provided to update the static variables if needed.
    • Removed the two camera variables on the FPV_ImageEffects class. It now gets the camera components from the static FPV class.
    • Changed the name of the FPV_ImageEffects to FPV_FinalCamera
    • Removed a few unecessary variables
    • Added FPV.FPVPointToWorldPoint(Vector3 point). It will transform a point from world to FPV screen to World
    • Added FPV.FPVToWorld(Vector3 point, Vector3 direction, out Vector3 resPoint, out Vector3 resDirection). It will transform a point and a direction from World to FPV screen to World.
    • Added FPV.FPVToWorld(Transform trans, out Vector3 resPoint, out Vector3 resDirection). It will transform a point and the forward direction from a Transform from world to FPV screen to World.
    After this, i'll be adding the possibility for:
    - FPV objects to cast or not shadows on World objects,
    - FPV objects to cast or not shadows on FPV objects.

    I'll also try to make it possible to have the terrain in the same layer as the world objects, but right now it's not supported.
    Maybe someone else can figure out some improvements for this :D

    Here's one more demonstration of the advantages of using the First Person View asset:


    One thing to note about using independent field of views for world objects and FPV objects, is that the direction and position of things in the FPV perspective are different from the world objects.
    This leads to lasers pointing in a different direction, FPV cameras pointing in a wrong direction, etc. This is why i included a few functions that automatically calculate the correct world position and direction of FPV objects/points.

    Here are a few examples:





    PS: These are all images from my game, as you might already know :D
    The link to it is in my signature if you are interested.
     
  4. EMGPY

    EMGPY

    Joined:
    Jul 11, 2014
    Posts:
    91
    Well a big update, so no problem waiting for that, In the first picture with independent FoV looks like free aiming of ArmA 2. That when your aiming you can still look the sides.
    Yep i know i waiting for your first launch. i am a follower from 2 years ago. :D
     
    eskovas likes this.
  5. Shkarface-Noori

    Shkarface-Noori

    Joined:
    Jun 10, 2013
    Posts:
    828
    this is really really helpful, I've been a silent follower of your game and I'm really impressed, i was always wondering how people got the 'FPS look' in unity while i had multi-camera setup problems in deferred, I'm so excited to try this! thank you for contributing to the community.
     
    eskovas likes this.
  6. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Thanks :)

    As far as i know, i've only seen these solutions in Unity:
    - One is to simply have two cameras and the second camera only renders the first person objects. As result, no shadows on the first person objects.
    - Another is to use the solution above, but with duplicated objects for the environment and set to shadow caster only. Having to duplicate everything is a pain and not optimal. Also doesn't work well with dynamic objects, trees, etc. Very difficult or too impractical/performance costly to keep everything in sync.
    - Another is to use replacement shaders on the second camera. This means every single shader must have a keyword/tag to it, and the replacement shader can get really big. Performance was also a problem when i made it, and didn't work very well with deferred as far as i remember.

    There are a few other solutions, but i've never been able to replicate (like custom matrix for objects and shader modifications for the objects to not clip)

    The solution i've come up with, in simple terms, is to enable shadow caster only on objects that are not in First Person View when the second camera is going to render.

    Of course this has its own issues, for example doesn't work on terrains, or at least i still have to come up with a solution, and trees planted on the terrain also doesn't work. It does however work with trees outside of terrain.

    I like my solution, since it's fairly easy to setup, requires no shader modification and is easily interactive. Also from performance tests i did, it also performed very well.

    Another 'issue' is that every parent object of each object needs to have a component attached to it, and if it doesn't and is near the player, it will be rendered twice.
    Of course you can put it in a separate layer that the camera doesn't render.

    There are basically 3 rules for this:
    - If you know that an object will never be close to the player, then no need to do anything to it as it will never be rendered by the second camera.
    - If you can afford to have objects in a separate layer, that you don't want to cast shadows to the first person view, then you won't need to attach any components to it and just make the second camera not render that layer.
    - If you can't afford it and if you know that those objects will be near the player, then you need to attach a component to it.


    Anyway, i still have a few things i will be adding to the asset that will improve the functionality and add a few more features. For example, in the future it's not going to be needed to have a First Person View Layer for the first person objects.

    The asset was submitted 11 days ago and still hasn't been accepted :( it's understandable though, since it's a new asset. Hopefully next week :)
     
    EMGPY and Shkarface-Noori like this.
  7. Shkarface-Noori

    Shkarface-Noori

    Joined:
    Jun 10, 2013
    Posts:
    828
    Thanks, I've downloaded it and will give it a try right now :D
     
    eskovas likes this.
  8. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Hello everyone,

    I might have some exciting news for this asset :D

    Apparently, i was able to make an "overhaul" to this system and improved it alot!
    Here are some of the improvements:
    - 2x performance increase,
    - No more subscription and unsubscription of objects from a collection of objects, everything is automatic, so no need to manage objects and there is no main collection of all objects,
    - As result, the code is much more simplified.

    (i'm sure i'm missing a few more things)

    When i finish this, i'll introduce enable/disable shadows from player/environment on environment/player :)

    EDIT: and i'll also make it so you don't need that FirstPersonView layer to use this system.

    EDIT2:
    hum...
    correction, performance is now 7x better than before. I'll try to make heavier stress tests to really test the system.
     
    Last edited: Oct 9, 2015
    Shkarface-Noori and EMGPY like this.
  9. EMGPY

    EMGPY

    Joined:
    Jul 11, 2014
    Posts:
    91
    Well thats is very good think, i make a lite testing, In my machine, was getting good fps but was dificult to me see how was working your script system. When i have more time new test and with better and exacts results to show you.
     
  10. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Just updated the repository on GitHub with this new major update to the First Person View asset.

    Here's the change log:
    With this, you no longer need to keep ANY object updated in a collection of objects. No need to worry about anything.

    Performance also increased 4-7 time, depending on the scene. There are still some improvements i can make.
    On my PC with the stress test scene, i was getting around 0.55ms average performance cost of this system. The new update, on average, costs 0.08ms :)

    Let me know what you think :)


    EDIT:
    Made a couple more updates.
    One fixed some summary of methods.
    The other one fixed a problem when setting a FPV_Object as a First Person Object.
     
    Last edited: Aug 4, 2016
  11. Shkarface-Noori

    Shkarface-Noori

    Joined:
    Jun 10, 2013
    Posts:
    828
    this is really really cool, though the last version downgraded my fps a bit (this was when enabling Unity SSR), I will try to get the new version and try it out, thank you very much for the contribution...
     
  12. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Are you sure the downgraded fps was due this system and not the SSR being enabled? I don't see how that image effect would affect the performance of the system.
    When i use Candela SSRR, the cost of this system stays the same.


    EDIT:
    In the second last post i said this:
    When i finish this, i'll introduce enable/disable shadows from player/environment on environment/player.

    What i meant was this:
    The next goal is to have a way to:
    Enable/Disable shadows from player on player
    Enable/Disable shadows from player on environment.
     
    Last edited: Oct 10, 2015
  13. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Thank you for your enthusiasm, but can you please remove the comment from this thread? This thread is not about my game and your comment is way too long for this.
    You can remove the comment by asking a moderator, or simply edit your comment and remove its content.

    Also please don't post that on the thread of my game too, since it is way too long of a comment and will only make it difficult to read the thread.

    You can post that in the weapons thread on the Steam forum for my game here:
    http://steamcommunity.com/workshop/filedetails/discussion/102544767/846946775251791036/

    Everyone posts their ideas of weapons there, so it's the best place for you to put them on.

    Thanks
     
  14. flashkh

    flashkh

    Joined:
    Oct 16, 2015
    Posts:
    2
    I'm unable to post on forums on steam due to me not spending $5 dollars on a game.
    any other places I can send feedback?
     
  15. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Submitted the First Person View asset again to the Unity's Asset Store.

    It failed last time because i didn't have the publisher info set up. Unity shouldn't have let me publish it and make me wait a couple of weeks just to say that i need to complete my info o_O but it's all done and taken care of now.

    If everything goes well, the asset will be available probably at the end of next week or the week after.

    I also updated the package to the latest version on GitHub
     
  16. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Happy to say that the First Person View is live on the Unity's Asset Store :)

    http://u3d.as/jQT
     
  17. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    142
    I'm confused. I know what it should be doing, but I'm sure I did something wrong.
    1. I started a fresh new project, but the layers weren't actually available (empty)aqsz
    2. Implementing the ExampleWeapon-prefab.. It will fall through the ground.
    3. I'm sorry to say this, but an asset such as this is easy to remake by ourselves. Or that's just because I know how the system actually works. It would've been more interesting if you would make the No Heroes-like FPS controller available to the public. Ofcourse, again without the additional 3D Assets.
     
  18. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    @Justice0Juic3
    1- In the manual, it says that you need to add that specific layer to the layers list. without it, it won't work
    2- that's just a test example, it's not meant to be a real fps controller. it's just to show how to set everything up for the system to work, and translate world objects to first person view.
    3- Well, after knowing how its done, it's quite simple to do. It's just, from all the time i've been here, i've never seen a solution to this problem, so i thought i would offer one. It's not perfect but works for the most of it.
    This asset is not meant to be a FPS controller, it's just a mechanism to have a first person view. What you are asking for is not the purpose of this asset.

    Also, this system only works with Deferred Rendering, so make sure you have that checked.
     
    Fenixake likes this.
  19. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    142
    @eskovas
    OK​

    3. It was meant to be a suggestion anyway, not a must. ;) Good luck on your project!
     
  20. marf

    marf

    Joined:
    Jul 20, 2011
    Posts:
    122
    Hello and thank you for this! Is there any way to use it with Forward Rendering? Why it only works with deferred?

    Thank again for this asset!

    Marco
     
  21. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Thank you :)
    Well, to be honest, i'm not exactly exactly sure why it doesn't work with Forward Rendering, since i'm not very familiar with the rendering pipeline. I need to research that ;)

    Were you able to get it all working properly?
     
  22. marf

    marf

    Joined:
    Jul 20, 2011
    Posts:
    122
    I will make some tests and than I will give you a reply :)
     
  23. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    In just a week, the First Person View has been downloaded 580+ times on the Asset Store, bringing the asset to the top of the Scripting section on the store. That's incredible ;)

    Would love to hear some feedback or know if any of you had problems with it and if it's working as you would expect :)
     
  24. Ysgramor

    Ysgramor

    Joined:
    Jan 23, 2014
    Posts:
    69
    Hi i have some problem, everytime i push P button, this error appeared

    A game object can only be in one layer. The layer needs to be in the range [0...31]
    UnityEngine.GameObject:set_layer(Int32)
    FirstPersonView.FPV_Renderer_Base:SetAsFirstPersonObject() (at Assets/FirstPersonView/Scripts/Renderer/Base/FPV_Renderer_Base.cs:73)
    FirstPersonView.FPV_Object:EnableAsFirstPersonObject() (at Assets/FirstPersonView/Scripts/Objects/FPV_Object.cs:115)
    FirstPersonViewer.Example.FPV_Example_Weapon:SetWeaponOnPlayer(Transform) (at Assets/FirstPersonView/Example/Scripts/FPV_Example_Weapon.cs:35)
    FirstPersonViewer.Example.FPV_Example_Player:SetWeaponOnPlayer() (at Assets/FirstPersonView/Example/Scripts/FPV_Example_Player.cs:96)
    FirstPersonViewer.Example.FPV_Example_Player:CreateWeapon() (at Assets/FirstPersonView/Example/Scripts/FPV_Example_Player.cs:79)
    FirstPersonViewer.Example.FPV_Example_Player:Update() (at Assets/FirstPersonView/Example/Scripts/FPV_Example_Player.cs:33)

    And also the shadow on weapon seems cutted if i close enough to wall.
    bug.jpg

    But still this is great free assets
     
  25. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Did you add the Layer that the manual says to add?
    For this to work, you need to add the FirstPersonView to the layer's list.

    The image is normal because the weapon goes through the geometry, and on the other side, there's no shadow.


    EDIT:
    Just as an example, from an old image of an early test with this asset:



    You see the light on the other side because of what actually happens here.
    Without this, you wouldn't be able to see the gun.
     
    Last edited: Oct 31, 2015
  26. Ysgramor

    Ysgramor

    Joined:
    Jan 23, 2014
    Posts:
    69
    Thank you for ur asnwer, it works now, i missed that layer part :)
    So best solution for shadow problem is adding a collider on end of gun to prevent the weapon through wall?
    or any better methods?

    I saw ur No heroes game in steam, its a good game, if u dont mind, can i get some idea how to use fps cam and character body together without clipping with body when look downside.?

    right now im using IK headtracking, then update target based on camera, but it clipped badly to body.


    Thank you for ur response, sorry if my english is bad. :(

    EDIT:
    for IK headtracking, nvm now i found the solution.
     
    Last edited: Nov 2, 2015
  27. Demonith88

    Demonith88

    Joined:
    Jun 30, 2014
    Posts:
    213
    I download this asset i dont see any scene with soldier like on pics ?
     
  28. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    This package doesn't include those art assets because that's not the purpose of the asset. The assets are also from my own game, so i couldn't include them in this.
    The package is meant to give you a solution for first person style cameras.
     
  29. Demonith88

    Demonith88

    Joined:
    Jun 30, 2014
    Posts:
    213
    Will be grate to see how did u put it in and how is it working with real character and such things will be cool to share looks awesome thou :)
     
    Justice0Juic3 likes this.
  30. KieranSaunders14

    KieranSaunders14

    Joined:
    Apr 24, 2016
    Posts:
    1
    How do I replace the stick (weapon) for a gun PS- I'm new
     
  31. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    The process is pretty much how it is described in the asset.
    There is a script attached to the weapon's main object and you call the enable/disable method in the script when you put/remove on the first person player.

    There isn't much else to it.
     
    Last edited: Apr 26, 2016
  32. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    To those who use this asset, there is another limitation that i will try to solve in the future.

    It currently has a few problems with some assets that use other cameras is some specific ways (still figuring it out).
    For example, Suimono - Water System breaks this setup.
     
  33. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Well, to correct what i said before, after updating Suimono to the latest version, i was still having problems with it, but i figured out that it wasn't Suimono causing the weird glitches, but it was the SSAO effect i had on the camera in conjunction with Suimono, which i believe it's a known problem with Suimono? @chingwa can probably confirm it.

    Using SSAO only works, and using Suimono only works, but both at the same time will not work.

    To prove this setup works with some Water systems, here are a few images:
    1.jpg 2.jpg 3.jpg 4.jpg
     
    chingwa likes this.
  34. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    2,864
    @eskovas yeah the Standard SSAO effect does not work with Suimono in general. If you're using forward rendering there is a small code switch that can be done in Suimono to get SSAO working(if you are, then let me know), but this does not work in deferred.

    Some people have better luck using the ScreenSpaceAmbientObscurrance effect instead... and I've had reports that SSAO Pro (on the asset store) works as well, though I have not tested this personally. The standard SSAO effect is starting to show it's age and has not been properly updated for years.

    You may also find luck using an alternative SSAO that is bult specifically for deferred, such as this one... https://github.com/keijiro/DeferredAO
     
    theANMATOR2b and eskovas like this.
  35. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    I'm using SSAO Pro and i just tested it with a normal camera and it keeps flickering when using with Suimono.
    One interesting thing on the camera is that the "Info" located at the end of the Camera component also keeps flickering between "Info: renders Depth & DepthNormals textures" and "Info: renders Depth texture".

    Might be something you could take a look at maybe?

    Since this is related to Suimono, it's best that i post in your thread about this
     
  36. Abelmangeunebanane

    Abelmangeunebanane

    Joined:
    Jun 13, 2016
    Posts:
    1
    Hello !
    I'm french, and I need to change the controls for a french keyboard. Is it possible?
    Great asset !
     
  37. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    The controls are inside the player's script FPV_Example_Player.cs. There you can change the KeyCode to any other key you want.
     
  38. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Here's a comparison with the stress test scene in the asset. As you can see, since we don't need 3 cameras and don't need a script for every since renderer in the scene, the performance is fantastic.
    With this, no need for any complex setup.

    fpvshader.jpg

    I'm still working on a few problems, and will update the asset on github and asset store when it's ready :)

    Edit:
    The only "bad" thing is that the shader used in first person objects needs to have 3 specific lines in the vertex function.
     
    Mister-D, chingwa and sjm-tech like this.
  39. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Hello everyone.

    I'm happy to say that i'll be updating this asset to V2.0 sometime soon with new features and improvements.

    Here's a preliminary list of the changes in First Person View V2.0:

    - Support for First Person Objects to cast shadows on the world,
    - Improved performance of various methods,
    - Changed recursive methods to iterative methods (should have been made before 1.0 release),
    - Reduced garbage generated,
    - Merged and simplified some components,
    - Better examples for offered functionalities (correctly firing bullets from the barrel of the gun with First Person View, aiming down sights while changing the FPV FoV)

    - New solution for achieving a First Person View in Unity using modifications in the shaders:
    - Only needs 1 Camera + 1 disabled camera instead of 3 in the previous method,
    - No screen-space effects limitations,
    - Requires simple changes in the shader,
    - Only First Person Objects need to have scripts (Not scene complexity dependent like last method),
    - Examples provided for Surface shaders and Fragment shaders,
    - First Person Objects can cast shadows on the world,
    - Same functionality offered as the previous method,
    - ( - ) Shadows on first person objects can be distorted but can still be recognized,
    - ( - ) Clipping with the environment can still be possible, but only in few cases.

    Changing from the first version, this update will have a small fee.

    If you have any requests for this asset, please share below.
     
  40. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Here's an update on the new update :)

    I was starting to get worried about the new second solution i came up with using shaders, because skinned meshes didn't work with that setup. It also required some changes in shaders and didn't work with all shader types.

    BUT,
    After researching a bit more and trying a few more things, i was able to make a pretty awesome solution for the first person view. I believe it's probably the best solution for a first person perspective in Unity. You can use it with probably every single possible shader! (i'll include examples).

    With this solution, there won't be any need for multiple cameras, scripts for environment objects, screen-space effects are not limited, and many more.
    I'll also include the first solution if this one isn't the right for your game.
    Even though this new solution works really well, environment shadows can still become a bit stretched on first person objects, but they are still recognizable. There's also a small possibility that the first person objects will clip through the environment if they are too close, but it's only in few cases.
    A pretty good thing is that the second solution has much better performance, specially in complex environments.

    Both solutions work well, but each one has its own advantages and weaknesses.

    Here's a screenshot i took showing the new second solution On and Off.
    fpv.jpg

    Like the first version of First Person View, i'll be offering a complete package that will make this system work efficiently, along with examples (not from my game).

    I'm currently working on support for multiple materials per mesh. After that, and a few more tests, i believe i'll be ready to submit V2 to the asset store.
     
    HerrDarKy, theANMATOR2b and Mister-D like this.
  41. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    449
    Sounds Great!!!! Having a two camera setup seems always a bit confusing. Great work by the way!
     
  42. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Finished yesterday implementing support for renderers with multiple materials, but since its implementation is more expensive than an implementation with renderers with one material, i'll make those two cases separate.
    In the end, it will be less costly, more efficient, same setup.

    I was able to do some tests in my own game using this new solution.
    On average, this system costs ~1ms less on a fairly complex scene (with my kind of powerful pc, so it will have much less impact on worse hardware). I was getting average 7.5ms and with this solution i get on average around 6.7ms.
    Basically, the first solution costs 1ms on my pc with this scene, since the second implementation is basically free.

    The scene in question, on average gets around 1000 renderers rendered, so essentially, it had 1000 FPV renderer scripts attached to each with a callback on OnWillRenderObject, so you can see where it can be a problem. If the scene complexity isn't high, it should still work very well with the first solution.


    Thanks!
    Well, it's not really confusing, but there are some limitations that can't be worked around with that setup. I was able to get around a few with my first solution, but not all.
     
  43. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    First Person View 2 has been submitted to the Asset Store and is now pending review.

    Since the asset is less that 1 year old, i can't make an upgrade to it, so i'm creating a new package for it and deprecating the old one.

    Here are the release notes of version 2:

    Overall

    · Created generic interfaces and classes that are used in both solutions (IFPV_Camera, IFPV_Object, IFPV_Renderer, FPV_Camera, FPV_Object, FPV_Renderer)
    · Created more examples for both solutions, along with examples on functionalities offered by these solutions. (Like aiming and firing)
    · Added each component to the Component menu of Unity, making it easier to add FPV components to the objects
    · Removed Editor scripts and Instantiate methods on the FPV static class

    Multi-Camera Solution

    · Improved overall performance of the system
    · Reduced garbage generated
    · Changed recursive methods to iterative methods
    · Merged FPV_Object_Custom to FPV_Object, making it support custom shadowcasttypes
    · Added support for first person objects to cast shadows on the environment
    · Added Prefab that demonstrates the Multi-Camera setup

    Shader-Material Solution

    · Added new solution for first person perspective
    · Simpler setup than the first solution
    · Uses only one active camera and one disabled camera
    · No screen-space effect limitations
    · Only requires scripts on first person objects (not scene complexity dependent)
    · Practically no performance cost
    · Requires one Shader Keyword
     
  44. shadobox255

    shadobox255

    Joined:
    Jul 30, 2016
    Posts:
    1
    I'm kind of a noob at this sorta thing and I don't know how to put this into the game.
     
  45. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Hello,

    It's fairly straight forward by reading through the manual in the package and examining the example. It explains how it works and how to set it up.
    The new version 2.0 should be released this week hopefully, and it will include a new solution for first person perspective which is much better than the current one, and also much simpler to setup.
     
  46. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    First Person View 2 is now available on the Asset Store: http://u3d.as/xzu

    "First Person View is an asset that offers a solution for first person perspective in Unity, where first person objects won’t clip through the environment, have a separate field of view and receive shadows from the environment.

    With version 2.0, a second solution is offered for first person perspective, which requires a simpler setup, is not scene complexity dependent, has less limitations and performs better than the first solution, making it, at the moment, the best solution available in Unity for a first person perspective.

    Both solutions are offered with this package, since one could be more appropriate than the other.

    Every script is well documented to make it easier to learn and understand how both solutions were made."

    Change Log:

    Overall :
    - Created generic interfaces and classes that are used in both solutions (IFPV_Camera, IFPV_Object, IFPV_Renderer, FPV_Camera, FPV_Object, FPV_Renderer)
    - Created more examples for both solutions, along with examples on functionalities offered by these solutions. (Like aiming and firing)
    - Added each component to the Component menu of Unity, making it easier to add FPV components to the objects
    - Removed Editor scripts and Instantiate methods on the FPV static class

    Multi-Camera Solution :
    - Improved overall performance of the system
    - Reduced garbage generated
    - Changed recursive methods to iterative methods
    - Merged FPV_Object_Custom to FPV_Object, making it support custom shadowcasttypes
    - Added support for first person objects to cast shadows on the environment
    - Added Prefab that demonstrates the Multi-Camera setup

    Shader-Material Solution :
    - Added new solution for first person perspective
    - Simpler setup than the first solution
    - Uses only one active camera and one disabled camera
    - No screen-space effect limitations
    - Only requires scripts on first person objects (not scene complexity dependent)
    - Practically no performance cost
    - Requires one Shader Keyword
     
  47. local306

    local306

    Joined:
    Feb 28, 2016
    Posts:
    58
    Thanks for the asset! I picked it up today and it solved my problem using UFPS and two cameras with deferred rendering and post effects.

    Would you have any insight into how to position objects in the world view such that they appear to match the FPS view when it has a different FOV? As in, if I had a laser sight on my weapon, how could I have the laser render in the world view and have its end point match up with where ever it is projecting from on the weapon?
     
    eskovas likes this.
  48. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    Thank you very much!
    Yes, the asset contains a few functions for this exact purpose. You can see some image examples in this post: http://forum.unity3d.com/threads/fi...port-and-independent-fov.356711/#post-2319161

    Basically, you call the FPV.FPVToWorld with a world position and world direction, or a transform, and it will return a new position and direction that is transformed into first person perspective. That way, lasers, projectiles, etc will point in the direction of the first person FoV.
    There's a very simple example in the asset that demonstrates shooting through the barrel of the weapon, and the bullets will spawn in the right position and will have the right direction according to the first person field of view.
     
    local306 likes this.
  49. local306

    local306

    Joined:
    Feb 28, 2016
    Posts:
    58
    Thanks @eskovas! I will look into this when I get a chance.
     
  50. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,230
    I'll be making a small update soon to fix a small problem with the initialization of multi-material renderers in the new solution.
    I'll also try to make it easier to setup and update the system.

    Thank you very much for those who purchased the asset! If you have any questions or requests, please let me know.

    Don't forget to submit a review/rating