Search Unity

[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. yung

    yung

    Joined:
    Nov 22, 2010
    Posts:
    274
    Any chance this would work with UFPS with minimal modding?
     
  2. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Yes, it should work very well. This is a solution for the FPS perspective, so you'll only need to setup the specific parts of this system, like the camera script, FPS objects scripts, and switch them on/off when it's on or off the player.

    I'll quote a review of the asset on the asset store:
    Let me know if you have any questions about the asset.
     
  3. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Just submitted a very small update fixing the initialization of renderers that contain multiple materials.
    I also added a GUI note in the example scene to make sure you follow the manual before running the example.

    It should be updated soon.
    Also, be sure to leave a rating/review :)
     
  4. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    V2.0.1 is live on the Asset Store with the fix from the previous post! http://u3d.as/xzu
     
  5. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Giving an update on compatibility with Unity 5.4:
    Yesterday i updated my own game to 5.4, and i can confirm that the First Person View 2 asset works in 5.4.
    One big note is that the setup of the new solution in 5.4 is a little different from 5.3, since Unity changed quite a lot of things in the required file. (due to VR and one-pass render i think)
    I'll update the documentation asap with a section on how to setup the system in 5.4. You can still change it on your own just by looking how it was done in 5.3 and translate it to 5.4. The setup itself remains the same, but the positions in the file changed.

    Let me know of any issues you might find and if you have any suggestions or requests.

    Don't forget to leave a review/rating! It really helps out the asset. There's still only 2 reviews/ratings from everyone that got the asset :(
     
  6. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Submitted a new version that contains the instructions to setup the asset in Unity 5.4.

    Should be updated on the asset store in the next days.
     
  7. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Well, something really obvious escaped me when making this asset and just now i noticed it was needed.
    So, particle systems are currently not supported in First Person View 2 (In the new solution. Old solution supports it). I'll be adding support for particle systems in the next update.

    I've also been thinking of making a small video just showing what this asset can give you and comparing results against not using it. What do you think?
     
  8. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Sorry about the confusion, but particle systems are actually already supported in the asset. Something was wrong that wasn't related to this asset, so everything's okay.

    In other news, the asset is now updated with instructions for Unity 5.4: http://u3d.as/xzu
     
  9. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Made a simple video demonstration of the asset First Person View 2, available on the Unity's Asset Store: http://u3d.as/xzu



    I use No Heroes to showcase the asset in action.
    Note that the asset doesn't include the game or any of the assets shown in the video.
     
  10. funderburk5

    funderburk5

    Joined:
    Nov 25, 2014
    Posts:
    9
    Hey i'm getting namespace errors for FPV_Object_Custom.cs which states that the FPV_Object can't be found and that i'm missing a using directive or an assembly reference. This is also happening with another script called FPV_Renderer_Custom. What do i need to do to fix this? Looking forward to hearing back with you.
     
    Last edited: Aug 29, 2016
  11. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    That probably happened because this is technically a different asset from the first version, so Unity will not remove assets that are no longer there. So you'll need to remove the asset from your project and then import the new version. That should make it work.

    in this new version, the names of some classes were changed, and many new classes were added, and some removed.
    For example, to differentiate between both versions, version 1 is named as FPV_MC_... and version 2 is named as FPV_SM_...
    Both solutions were also put into different namespaces.


    Also, that solution that you're referring to is the old solution. Be sure to check the newest solution (version 2) of the asset, which is the one that i show in the video and is also the best solution.
    Remember to follow the manual before using it, since it requires you to setup a few things for it to work properly.

    If you have any more questions, let me know :)
     
    funderburk5 likes this.
  12. funderburk5

    funderburk5

    Joined:
    Nov 25, 2014
    Posts:
    9
    Thanks for your feedback i'll be sure to keep you posted :)
     
    eskovas likes this.
  13. johny256

    johny256

    Joined:
    Mar 3, 2015
    Posts:
    186
    Compatible asset UnitZ???
     
  14. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    I don't have that asset, so i can't tell you for sure if it will work, but i don't see why not. This asset should work well with any type of controller.

    Only things that the controller will need to do with this asset is to call the appropriate FirstPersonView methods on the scripts to enable/disable the first person view state of the object when those objects are on or off the character. Nothing too complicated to do really.

    If you have any questions, feel free to ask.
     
  15. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Will be making a new small update to the First Person View 2 Asset.

    This update will fix FPV objects being affected in other views and cameras other than the main camera.
    Here are a couple of images, showing the problem and the update:

    In this first image, you can see that the FPV objects are scaled in multiple views and cameras when changing the first person camera FOV.
    fov_old.jpg

    Now, these won't occur, and all objects should be seen correctly in the scene view and any other cameras you are using.
    fov_new.jpg
     
  16. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    I'm guessing I could write a script that automatically switches over to your shader at runtime? I dont like having lots of variants of materials in my project assets. No reason why this should't work? Also, are there any FPV-2-World examples? E.g laser? I always learn best from examples, not documentation :p
     
  17. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    This solution offers a mechanism to automatically do that for you. It has two options:
    - Create instances of the used material when FPV becomes active, so the material can be changed without affecting non-FPV objects that also use that material,
    - Or, you can give a specific FPV material that will not be instanced. But be sure it is not used outside of the player.

    Of course, this system will revert these changes back to normal when you disable the first person view for the object. That way, objects not part of the player will continue as normal and everything stays consistent.

    There are a few examples:
    - Spawn projectiles / raycast with correct position and direction,
    - Alter the FoV of the first person objects, and also alter the FoV of the environment,
    - Enable/Disable objects from first person view (dropping weapon on the floor and picking it up).

    There isn't an example for the laser, but you can use the same logic i demonstrate for the projectiles. I'll add that example in the future to the list of the examples, but it's very simple to do.

    Let me know if you have more questions :)
     
    Stormy102 likes this.
  18. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Great once I have enougth $$$ I need to pick up this and another asset. Expect a purchase from me soon :)

    EDIT: Also, good luck with NH
     
    eskovas likes this.
  19. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    Already bought it, really happy with the results, but the Shader-Material solution sometimes doesnt work as expected and the first person view get overriden by other geometry, is it a known bug?
     
  20. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    That's a known problem that might be solvable but everything i've tried hasn't worked yet. (At least i think that's what you're talking about)
    That only happens at very narrow angles or when the camera almost intersects with the geometry at an angle. Since the first person geometry isn't "hidden" or "overrides" the environment, intersection can happen in some cases, but for the most part it's ok.

    For 100% of the cases, the first solution works, but at a performance and setup cost.

    Let me know if the problem is worse than expected.
     
    shkar-noori likes this.
  21. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    with our scene complexities, there is no way we can use the two-camera setup again, but we're trying to design our scenes in a way that the shader-material solution work well, I'm not a shader guru or anything, but can't somebody just make a shader that renders after the geometry :/ , something like { "Queue" = Geometry+2} or something like that..

    again I'm no shader expert nor do i know little about the way they are written, so :)
     
  22. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Changing the render order won't do anything, because the rendering stays the same. Intersecting geometry will still be intersecting, even with the trick used for this solution.
    Can you show me in a private message an image of a case where this happens? Your case might be worse than i'm thinking. I have a solution for your case but at a cost of worse environment shadows on the first person objects. It's a simple solution.
     
    shkar-noori likes this.
  23. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    Sure, as soon as I return back to my workstation (in 14 hours) I'll send you some examples! But it mostly happens when my view goes horizontally from not having anything in front of me to having an object in front of the view, but going towards (vertically) the same geometry doesn't show the bug
     
  24. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    Sorry I lost this thread! i was able to fix (some of) my problems by bringing my weapons backwards so they won't overlap with geometry as much, but i still have problems with the body overlapping the weapons sometimes, have you found any good solutions?

    EDIT: and i made a test port into 5.5b11, and its not working properly.
     
    Last edited: Nov 12, 2016
    eskovas and Stormy102 like this.
  25. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    I haven't tested the First Person View asset in 5.5 beta, so i can't 100% tell if it will work the same as with Unity 5.4. I'll have to verify if the needed internal changes are different in 5.5. (I think they changed something about how the Z buffer is used, so this asset probably won't work out of the box with the new Unity version).

    Just make sure to re-do everything i tell in the manual when upgrading/changing Unity versions. Unity automatically resets the internal scripts and you'll have to update them. Also make sure to recompile the shaders that use the system.

    In regards to lowering the probability of intersection, go to the FPV_SM_WorldCamera.cs, at line 25, and modify the value to something slightly lower like 0.6 instead of 0.7. It's not guaranteed, but will lower the chances.

    If i can, i'll see if i can download the beta and see if there is a solution for 5.5. Note that it is a beta, and Unity already changed a lot of internal things.

    Looks like the asset will need to have yet another special setup for this specific Unity version, like it is different between 5.3 and 5.4. Thanks Unity! o_O

    PS: Your game is looking really good btw :)
     
    Stormy102 and shkar-noori like this.
  26. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I have already made some (script) changes to your asset to fit my needs, I'll try lowering that value and see if it helps our case, and it would be great if 5.5 support came as I'm thinking about porting our game over to 5.5 for some specific reasons...

    PS: thanks :) , I try to not steal any of your ideas from time to time XD
     
    eskovas likes this.
  27. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Just to let everyone know, the First Person View 2 asset works with Unity 5.5 with a very small change to one of the scripts.
    I'll update the asset as soon as possible.

    If you have the asset and want to use Unity 5.5, send me a PM and i'll tell you how to make the asset work in 5.5.
     
    Stormy102 and shkar-noori like this.
  28. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    553
    did you update for 5.5? cuz I can't get this to work at all with ufps
     
  29. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Hello. Giving an update on new developments for First Person View 2!

    First of all, the asset on the asset store still doesn't work for Unity 5.5, but pm me for the very easy fix. I'll update the asset when i have the new features finished.

    Jumping onto what i've been working on, i'm working on making shadows work properly with FPV2.
    This includes correct shadow casting from the player onto the environment and correct shadow casting from the environment onto the player.
    The second one is already technically supported, but due to the z-buffer shortening for FPV objects, the shadows on those objects become on/off for the whole character.

    Remember, FPV objects have a different projection matrix (different FOV and short z-buffer) than the environment.

    The good news is that i'm managing to solve these problems, making FPV objects look a lot better!
    Here are some screenshots with correct shadows (lighting is exaggerated for easier shadow visualization):
    l_1.jpg l_2.jpg l_3.jpg
     
    HerrDarKy, arnoob, jmjd and 2 others like this.
  30. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    289
    Could you please post the fix for 5.5 ? Thank you
     
  31. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    While i'm still working on the new update FPV 2.1, here is the quick fix for Unity 5.5:

    Open the script FPV_SM_WorldCamera.cs and make this addition to the OnPreCull() method after the projection modifications:

    Code (CSharp):
    1.  
    2. void OnPreCull()
    3. {
    4.     ...
    5.  
    6. #if UNITY_5_5
    7.     fpvProjection.m23 *= -1;
    8. #endif
    9.    
    10.    ...
    11. }
    12.  
    First person objects will still cast shadows on the environment with the projection matrix modified (projection on the shadow map of the lights get affected), so it will result in very wrong results, so i advise to disable shadow casting for all first person objects.

    I'm working on fixing those issues like i demonstrated in the previous post.
     
  32. FuRy

    FuRy

    Joined:
    Apr 16, 2013
    Posts:
    28
    For some reason I can't get the shader approach to work in 5.4.3. I have modified the cginc file with the instructions for 5.4 but the example scene my gun still clips through objects. Any help would be appreciated.
     
  33. akauper

    akauper

    Joined:
    Jun 16, 2013
    Posts:
    7
    Hey eskovas. Any word on the update for Unity 5.5? I'm eagerly awaiting the fix :)
     
  34. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Sorry for late response.

    Make sure to restart Unity when you change the cginc. Also re-import all shaders that use FPV.

    Well, the 5.5 fix is shown in the post above.
    Regarding the improved shadows, it's still WIP, since the current setup kind of messes up a bit with the scene window camera shadows, and that's not ideal, so i don't want to update FPV like that. I'm still working on it.

    EDIT:
    Well, just after i posted this, an idea came to my head and i was actually able to fix the problem with the shadow setup on other cameras and the editor scene window camera.

    This update still needs some more work though, but it will be worth it :)
     
    Last edited: Feb 5, 2017
    HerrDarKy likes this.
  35. HolyFireGames

    HolyFireGames

    Joined:
    Apr 23, 2014
    Posts:
    116
    Hi there, any update on the update? :)
     
  36. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    @eskovas We are considering using a full-body animation system. The model would be split into arms, torso, head and legs. If we put the FPV material on just the arms, this shouldn't cause any issues?
     
  37. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Not yet. I've been trying to decrease the amount of setup needed to be able to have the correct shadows, but haven't had much luck. It requires more than double the work that is needed with the current version, and i don't think people would feel comfortable with that.

    It should work without a problem. This system lets you assign any renderer to the First Person View system, so you can assign just the arms and weapons and only those will be affected.
     
    HerrDarKy, shkar-noori and Stormy102 like this.
  38. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Your post made me consider to also do the same thing in my game (thanks :D ). Here's a video showing that it's possible to have different body parts in first person and some of them not being included in the FPV system. (Legs have the world FOV, and hands/weapons have the player's FOV)
    Just a note, this is using the future FPV 2.1 (includes shadows). You can see the shadows still need improvement.

    https://twitter.com/Tiago11F/status/838100555117518849
     
    Stormy102 likes this.
  39. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    That's pretty cool! Guessing you just split the character into different components and then just animated the legs?
     
  40. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Only thing i changed is what i included in the FPV system. You can add specific renderers to a FPVObject by script, so when i instantiate the character gear, i just assign the upper body parts to the FPV system, instead of assigning everything.
    It was really simple to do in my case.

    I already have the character parts split because of customization, so i didn't have to modify anything else.
     
    Stormy102 likes this.
  41. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Yeah we're planning on using a character split workflow. Seems to be the default nowadays.
     
  42. eskovas

    eskovas

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

    Sorry for the very very long delay, but i just submitted an update for FPV2 with the instructions for Unity 5.5 and 5.6.0(RC).

    It includes everything you need to do in the manual, and i also included the already altered files for each version in the FPV folder.

    I also added some more notes into the description of the asset:

    I also decided that this version will be the last version that supports Unity 5.3 and 5.4. This is because Unity changes things this asset uses in every release, so it's very time consuming and a bit of a pain to keep everything working with every new release, specially with the new version i'm working on.

    If you have any questions or issues, don't hesitate to contact me or ask here.
     
  43. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    First Person View 2.0.4 is now avaliable! http://u3d.as/xzu

    As always, if you have any questions or issues, don't hesitate to contact me or ask here.
     
    shkar-noori and Stormy102 like this.
  44. SkywatchGames

    SkywatchGames

    Joined:
    Mar 28, 2017
    Posts:
    4
    Hello eskovas. I love your asset, however, I'm having some trouble getting it to work on Mac. When running on osx the first person objects are flipped upside down and they are semi-transparent.

    It works fine on windows. Any suggestions for a solution? THanks!
     
  45. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Sent you a PM. Let me know if it works for you.
     
  46. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    First Person View 2 is on the Unity's Madness Sale with 30% off!
    fpv.png



    If you're interested in the current only solution on the asset store for the first person shooter type of camera in Unity, with no clipping, separate field of view and shadows, get it now on sale!
     
    Stormy102 likes this.
  47. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    @eskovas You mention changing a cginclude file. What does this mean exactly? You change a core cginclude file within a Unity installation?
     
  48. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    Yes, it requires making a very small change to one of Unity's .CGInc. This change is very well documented in the manual for 5.3, 5.4, 5.5 and 5.6 Unity versions.

    It's very important to know that this change doesn't affect anything else in Unity. It only affects FPV supported shaders.

    While it's very uncommon to do changes like this, i did it for a very specific reason. This way, it's really simple for anyone to make practically any shader support the First Person View perspective, by just adding one #pragma line code to their shaders.

    If it wasn't made this way, you would have to make a lot more changes to all of your shaders that you want to use in first person mode, with special treatment for surface shaders.

    The way i did it, you can just add that line of code to mostly any shader, and it will just work.
    For example, in my game, i'm using Unity's standard shader, which i downloaded from Unity's website (Built-in Shaders), then i changed the name of the shader, added the one line, and it's all done.
     
    Stormy102 likes this.
  49. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Ok cool. I'd need to make sure I reflect this change across the computer's that we work on. It's a bit annoying for version control and Unity updates though - is it not an option to add it as a separate cginclude in the actual project's Assets folder?
     
  50. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,340
    I agree that it's not very ideal, since it's unity specific and not project specific.

    I've tried many things, but none of them worked.

    I guess the second best thing i could do is to have a custom CGInc folder in the project folder, and import those CGInc in your shaders instead of Unity ones. It might require a lot more steps, and to keep the CGInc files updated with Unity versions, but i guess it could be feasible.

    I'll see what i can do.