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. Momo_Manbavaran

    Momo_Manbavaran

    Joined:
    Sep 9, 2015
    Posts:
    1
    Hey @eskovas, how's FPV 2.1 going? Can't wait for the update!
     
  2. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Thanks man. The more options available, the better and higher quality the asset :)
     
  3. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    152
    Hello @eskovas,

    I just tried to implement FPV 2.0 SMS in my game.
    It works great (just a little notice, you need to modify the disabled camera's FOV when changing the aspect ratio in order to be correctly displayed).
    My problem however is that it seems to have problem with the Unity's motion vectors. For example, Temporal antialiasing and motion blur from the official post processing stack, making it unusable for now. Is there a fix planned or already available for that?
     
  4. eskovas

    eskovas

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

    Never noticed the issue with having to modify the FOV value for it to update to a new aspect ratio. I'll have a look at it.
    Regarding temporal effects, unfortunately the asset has issues with it and it's not supported at the moment. (there's a warning about this in the asset description)

    I've been asked by other developers about supporting temporal effects, but i haven't been able to find a solution for it yet. Maybe in the future, but at the moment it's not supported.
     
    arnoob likes this.
  5. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    152
    I understand.
    Thank you for the answer!
     
    Last edited: May 10, 2017
  6. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    Hello,

    i followed the instructions in the Manual, but i ran into an issue.
    After i edited the cginc file, i'm getting the following error from the FPV_StandardSpecular Shader.
    Bildschirmfoto 2017-05-14 um 09.54.09.png
    undeclared identifier 'UNITY_LIGHTMODEL_AMBIENT'
    Compiling Vertex program with SHADOWS_DEPTH FIRSTPERSONVIEW
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA

    Somehow the "Firstperson Weapon" looks kinda strange after editing the cginc file and it's still going through walls.
    Bildschirmfoto 2017-05-14 um 09.55.08.png

    That's how my edited UnityShaderVariables.cginc file looks like atm.
    //Deleted
    I'm pretty sure i made a mistake with the
    #define UNITY_LIGHTMODEL_AMBIENT (glstate_lightmodel_ambient * 2)
    line, but i don't know how to fix it, since it's the first time i'm working with these kind of things, i'm using Unity3d 5.6.0 on MacOS.
    kind regards
     
    Last edited: May 15, 2017
  7. Michael2D

    Michael2D

    Joined:
    Mar 5, 2014
    Posts:
    17
    Hi, I would like to ask you why my custom weapon is still going through walls.
    I have added my weapon on your custom weapon in example to test it out.
    also added the "Object script" to the model, but when I try put the weapon next to the wall. My weapon is going trough but yours not. Also I changed shader to your shader so I really dont know. UnityShaderVariables.cginc is edited properly... Can you please help me ?
     
  8. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Sent you a PM on the forums with a possible solution. Let me know if it works for you.
     
  9. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Hello,
    You will still need to enable the effect through script on the script you added to the object. Check the example on how i enable and disable the "weapon" object. It's the same process.

    Let me know if it works. If not, send me a PM with more details on how you're trying to use FPV.
     
  10. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    To anyone that is using or supporting MacOS, there is some issue with it in the current version of FPV on the Asset Store. I'll try to update the asset ASAP. Meanwhile, if needed, PM me for the fix.
     
  11. Michael2D

    Michael2D

    Joined:
    Mar 5, 2014
    Posts:
    17
    Thank you for help. I already sended you PM(Started converstation)... Sorry Iam not good in this. This is my second post :)
     
  12. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    Can anybody help setting this up with UFPS. I'm really struggling right now and i would appreciate it, if someone who already was able to get this work could assist.
     
  13. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    I've never used UFPS, but can you tell what you're trying to do that's not working?
    A few people have used the asset with UFPS successfully. Make sure to check the manual and example scripts on how to setup FPV and make it work.
     
  14. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    I got it to work now. It was not hard at all, once i studied the example scripts and now it's working better than i expected.
    Big compliment to you, for developing such a great asset. It solves pretty much every problem you will get, when you are using UFPS.
     
    eskovas likes this.
  15. SteveRyu

    SteveRyu

    Joined:
    Apr 9, 2014
    Posts:
    121
    Hi, is this plugin works fine on mobile?
    Thanks.
     
  16. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    60
    Which approach did you used? The Material / Shader approach? Using two cameras?

    It is partially working, world shadows working fine but i can't have different FOV for each camera, also the "clipping thing" is not working.. i just added de FPV camera with the 2 UFPS cameras..

     
    Last edited: Jun 16, 2017
  17. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    I'm using the material Setup, because it's fitting my needs more than the two camera setup. You will run into huge issues when you are using ufps with two active cameras if you are moving to far from the origin point.
    You will need to modify one of the ufps scripts to change the FOV of the arms and weapon.
    I also ran into issues first when i was trying to setup this system with ufps, but it's pretty easy once you get how First Person View 2 works.
    If you're still stuck you can message me.
     
    eskovas and Weendie-Games like this.
  18. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    I've never tried it on mobile, but at first glance i don't see why it shouldn't work.
    Maybe someone here has tried it and can comment on it?

    Since i haven't tried it myself, i can't confirm if it will work :(
     
  19. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Hello everyone!

    Doing some cross promotion here :D

    My newest Asset has been released on the Asset Store, called Object Construction Kit.


    This tool allows you to very efficiently create detailed and varied scenes in a very short amount of time, and generate combined geometry with LODs for use in games!
    It also includes a few other tools, like an Atlas creation tool.

    Go check it out on the Asset Store:
    https://www.assetstore.unity3d.com/en/#!/content/91477

    If you have any questions, feedback or feature requests, check out the official forum page: https://forum.unity3d.com/threads/o...ailed-and-efficient-scenes-in-minutes.473139/
     
    TheMessyCoder and K4rha like this.
  20. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Hello everyone!

    As a thank you to all of you that purchased First Person View 2, i decided to include a discount price on my new asset Object Construction Kit for those who purchased FPV2!

    Object Construction Kit is currently on a limited time sale with 40% OFF, but if you have the First Person View 2 Asset, you will be able to get it with 50% OFF!

    If you are interested in both assets, you can buy FPV2 first and OCKit second to have this extra discount!

    https://www.assetstore.unity3d.com/en/#!/content/91477
     
  21. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Hello everyone!

    Just sharing some developments on FPV. This has been long overdo, but i might have a pretty nice solution to not having to edit Unity's internal .cginc file to make this work. ( @Stormy102 )

    I'm still doing some testing to make sure it works correctly, but here it is:
    Basically, by including the .cginc file in the same directory of your FPV shaders, the shaders will use this .cginc file instead of Unity's own.
    This means all your FPV shaders must be inside the same folder of the .cginc file.

    I'm still testing this to see if there are no problems with it, but if you want, you can test it and let me know if it works on your end.
    I've tested on my end, in 5.5, in-editor and in a build, and everything seems to work.

    What to do:
    - Put all FPV shaders inside the same folder,
    - Copy the edited .cginc file into that same folder,
    - Reset Unity's .cginc file (save that file in case you still want/need to use it after)
    - Restart Unity
    - Re-import the .cginc file in the shaders folder
    - Re-import all shaders
    - Test it

    Let me know how that works out.


    By the way, for everyone that bought First Person View 2, please take some time and rate the asset. Just a little over 5% of you have rated the asset. Would be great if it could have more ratings if you think the asset is worth getting for people developing first person games.

    Thank you and let me know if this solution works for you. :)
     
    Stormy102 and arnoob like this.
  22. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Makes it much better for developers using source control, like me. This is the only thing holding me back rn, so if this works fine, I will definitely be picking this up :) Keep it up @eskovas
     
    eskovas likes this.
  23. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    I can confirm this method works and no-one will need to modify Unity's own .cginc file anymore. This should simplify setup a lot more, especially in projects with multiple people that would require that manual change in every pc.

    I've tested in 5.5, 5.6 and 2017.1.

    I will update the asset soon with new setup instructions.
    If any of you don't want to wait for the new setup, you can just follow what i posted in the last post:

    - Put all FPV shaders inside the same folder,
    - Copy the edited .cginc file into that same folder,
    - Reset Unity's .cginc file
    - Restart Unity
    - Re-import the .cginc file in the shaders folder
    - Re-import all shaders
    - Enjoy!

    Make sure the .cginc file is in the same folder as all of your FPV shaders, and the .cginc file is the correct one for the Unity version.

    This might also enable me to add a few more things that are related to V2.1. Since it did require more changes to .cginc files, i wasn't comfortable with adding that complexity for you to edit unity files, but now, since you don't have to anymore, i might be okay with doing it, allowing for better shadows and lighting on FPV models.

    Btw, don't forget to rate the asset ;)
     
    Last edited: Jul 14, 2017
    Stormy102 likes this.
  24. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Good work Eskovas! Hopefully this change will improve the workflow for other developers as well as yourself! :)
     
    eskovas likes this.
  25. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Just submitted the new update and is now pending review!

    Changed the setup section of the manual with the new solution for using the CGInc file without having to edit the file in Unity's own directory. This will simplify the setup and update process.

    I also decided to finally update the key images of the asset, and it's looking much better :D

    FPV2_1.png

    FPV2_3.png

    For comparison, here's the before picture:

    7da26b57-86b8-4e7b-85f5-799d92863032.jpg

    And i also included a new image in the screenshot section for a close-up first person view and outside view:
    5.png
     
    Weendie-Games and Stormy102 like this.
  26. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Stormy102 and arnoob like this.
  27. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    152
    Excellent news! I can't ait to get back home to try it!

    Just a little question, I know I talk about it a lot but... Does the velocity buffer works correctly now? (for official motion blur and TAA)? :-D
     
    eskovas likes this.
  28. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Sadly that's one thing that i haven't been able to fix yet. I was able to improve it a lot, but the problem still persisted.
     
    Stormy102 and arnoob like this.
  29. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    152
    No problem, I know you're are working on it, I was just checking how it was so far. ;-)

    Keep up, you're doing a fantastic job here!
     
  30. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    60
    Hi Thiago, how are you? After updating to 2.0.5 i'm getting this error:

    Code (CSharp):
    1. A game object can only be in one layer. The layer needs to be in the range [0...31]
    2. UnityEngine.GameObject:set_layer(Int32)
    3. FirstPersonView.ShaderMaterialSolution.FPV_SM_Renderer:SetAsFirstPersonObject() (at Assets/FirstPersonView/FPV_Shader_Material_Solution (V2)/Scripts/Renderer/FPV_SM_Renderer.cs:47)
    4. FirstPersonView.FPV_Object`1:SetAsFirstPersonObject() (at Assets/FirstPersonView/_Generic/Objects/FPV_Object.cs:121)
    Did just what you said, all the FPV shaders are inside the same folder as my UnityShaderVariables.cginc.

    I'm missing something here? Thank you in advance
     
  31. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Hi, everything going well, what about you? :)

    That usually happens in Unity when you try to use a layer that doesn't exist. Can you check that you have the FirstPersonView layer in the layer settings?
     
    Weendie-Games likes this.
  32. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Well, seems that when i re-wrote the manual, i forgot to include a couple of things that were there before.

    First, You'll need to set the "FirstPersonView" Layer on the Layer Settings. Both solutions need this layer to exist, and Unity will throw an error if it's not there.

    Second, the Shader-Material solution doesn't support casting first person objects shadows onto the environment, only the other way around. You'll need to disable Shadow Casting on FPV objects.

    These two things were included in the past, but i forgot to include them in the updated manual. I'll update the asset with these notes asap.
    Sorry for any inconvenience.
     
    Weendie-Games likes this.
  33. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    I just submitted the updated version to the Asset Store.

    The second note in the post above is now included in the description of the asset, and everything else is now correctly included in the manual.

    I'll let everyone know here when the update is live.
     
  34. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    People, please, please ALWAYS read the description of assets before buying them.

    Someone rated and described the asset as a scam because it didn't include my game in it, which is clearly said in the description of the asset that all content showed in the video and screenshots are NOT included with the asset, and is also clearly said that the asset is NOT a first person controller.

    Please always read the description.

    I'll try to have a better looking gun in the demo, but it will be a really simple weapon. this is not supposed to be an art asset or FPS controller asset.

    Edit:
    The Multi-Camera solution (the old one) isn't currently working with the version 2017. I'll have a look at fixing it asap.
     
    Last edited: Aug 1, 2017
    Weendie-Games, K4rha and Stormy102 like this.
  35. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Not your fault. If someone didn't read it properly, its their money wasted.
     
  36. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    15$ is already such a little amount of money for such an awesome Asset.
    I just saw the review, it's just rude to not read the description and complaining about it then.
    You're doing great work, if someone does not know what he's buying, it's not your problem at all.
     
    Weendie-Games and Stormy102 like this.
  37. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    60
    Hi Thiago!

    I'm experiencing some weird clipping planes changes on my integration with UFPS. Right now i'm trying to figure out what is happening and elimate some possibilities..

    There's anywhere on FPV changing the nearClipping from "weapon cam" ?

    Somewhere in my project keeps changing the near clip to 0.1f i don't know why yet.

    best regards,
    Dênis Fernandes - Weendie Games
     
  38. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    Your vp_FPWeapon script (which is attached to every weapon) handles your far and near clipping planes.
    At line 1000 or so just remove m_WeaponCamera.nearClipPlane = 0.1f;

    As i know vp_FPCamera does also controls the near clipping plane.
    Just remove weaponCam.nearClipPlane = 0.01f;

    regards,
    Karim
     
    eskovas and Weendie-Games like this.
  39. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    60
    Thank you so much, once again saving me a lot of time (Btw, I added an acknowledgment to you on my game credits page) :D

    There's anybody facing issues with the FPV shader? My materials has only albedo and specular channels.. Using Unity 5.6.1f1

     
  40. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    Sounds good ;)

    I had the same issue. Recompiling / reimporting didn't change anything.
    You're probably using the Specular Shader from an older Unity Version.
    Just replace your current Specular Shader with the newer build-in shader (in your case Unity 5.6.1f).
    You can download it here:
    https://unity3d.com/de/get-unity/download/archive
     
    eskovas and Weendie-Games like this.
  41. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Sorry for the late response @Weendie-Games but seems like @Wazingoo was able to help out! Thank you very much :)

    Yes, the Standard version included in the asset i think it's from way back, probably version 5.3 or 5.4. Although i didn't have any problem with it with every other version of Unity, it would still probably be better to update it with more recent versions.

    I'm still having a look at the other issue with the Multi-Camera Solution not working in 5.6 and 2017.
    Does anybody actually use this solution? I have no idea if anyone does, since the Shader-Material Solution is probably much better and more efficient, and i've been thinking of removing it in the future. No point in trying to update the solution with every change Unity does if no-one uses it :p

    Please take 10 seconds to vote on this strawpoll, so i know the percentage of users that use each solution:
    http://www.strawpoll.me/13711873
     
    K4rha, Weendie-Games and Stormy102 like this.
  42. eskovas

    eskovas

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

    Just to update on the issue with the Multi-Camera setup, i'm not having much luck in fixing it for Unity 5.6 and 2017.1. I've tried many things and can't seem to make it work, i don't really know why. Unity changed something that messes with that solution.

    So, because of this, i may no longer be able to support the Multi-Camera setup for Unity 5.6+ versions for the time being.

    One person voted on the Multi-Camera setup on the strawpoll. If that person sees this, can you tell me why you are using that solution instead of the Shader-Material solution?

    Since the SM solution is the most used and i think it's the best, and since it seems that i can't support the MC solution past 5.5, i might just remove the MC solution from the asset.

    Let me know what you think. Is anyone using that solution? And if so, why?
     
  43. ryanflees

    ryanflees

    Joined:
    Nov 15, 2014
    Posts:
    24
    So that's the reason why my multi-camera example is blacking out? I mean I just bought it and have no idea why the camera is black , using Unity 5.6.

    I followed the setup and the shader example runs good. I was trying to implement a FPS demo and every tutrial or FPS framework use duel cameras making the shadow not projected on the weapon. And people just add an extra mesh with cast shadow only option to make shadow but that apparently would cause great overkill as for dobuling the vertices, culling and light calculations for an actual game.

    I tried sole camera and ask some friends how to change ZWrite in shader and it works but I can't stop guns casting shadow on the ground.(I don't know how to write shaders actually)

    Just bought your asset and it's working great. Gun casts shadow on itself, gun don't cast shadow on world objects, world objects shadow on gun, gun don't clip objects, gun get shadowed outline when clip into the wall. That's wonderful beyond my expect.

    Thanks dude!!
     
    Last edited: Sep 4, 2017
  44. ryanflees

    ryanflees

    Joined:
    Nov 15, 2014
    Posts:
    24
    And hi I have some other question, the shader you provided doesn't have normal texture on it. And I'm just about to start learning shader scripting next week.

    So in the future if I want to use other shaders on the gun(like outline toon shaders, and with normal textures), could I do following what you do in your shaders and make it work? It's doable right?
     
  45. K4rha

    K4rha

    Joined:
    Aug 7, 2014
    Posts:
    26
    You can use any shader with fpv, also particle shaders and stuff like that ;)
     
  46. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    308
    Hi there -- big fan of your asset, although I'm just finally really getting into using it. Getting it working with the Alloy shaders was a bear, but I do have that functioning now, which is great.

    The problem I'm having, however, is that when I switch away from DX11 over to OpenGLCore (which runs as OpenGL 4.5 on my machine), everything continues to work EXCEPT the clipping protection. The actual fov adjustments and things of that nature work just fine.

    This is in 2017.1p1, and I found a workaround for the problem.

    Basically the problem is that it SHOULD have usesReversedZBuffer as true in this instance, but for some reason it is not. So it's running the non-inverted zbuffer matrix multiplication in FPV_SM_WorldCamera. If I manually override it to have it think that the zbuffer is reversed, then things work as expected.

    I seem to recall some sort of change around this area from the patch notes from unity, but I haven't dug that up just yet. Some sort of API change on their part is likely what is breaking this, though. If you figure out what the appropriate thing is to check (instead of SystemInfo.usesReversedZBuffer), then please do let me know. I'd appreciate having that before you go through the wait time of the full asset store push.

    Thanks!
     
  47. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    308
    Actually, strike the above. The inversion of the z buffer is working just fine. When actually testing this in my own scenes, doing the reversed z buffer DID fix my problem of the clipping, but also made all the other z-tests backwards. Oops!

    It turns out that this line is not always going to be sufficient:

    fpvProjection.m22 *= 0.7f; // Shorten the Z value of the MVP vertex position

    In the non-inverted axis I notice that you're multiplying by -0.3f, so the foreshortening is very different between the two directions near as I can tell. Simply either using shorter weapons, or using the 0.3 instead of 0.7 gives a result that is not clipping and also not reversed.
     
    Last edited: Oct 2, 2017
  48. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,341
    Hello there!

    Thanks for the feedback. Yes it is an issue with OpenGL that the values used for the projection are different from DX. A few users contacted me with the same issue and we managed to get better results for OpenGL by changing that m22 value.

    It's still something that i haven't figured out how to make it look exactly like with DX, but you can get somewhat similar results by adjusting that value.
     
  49. CTPEJIOK22

    CTPEJIOK22

    Joined:
    Sep 4, 2013
    Posts:
    80
    hi. i wanted to ask - there are any solution with antialliasing for this shader? i tested temporal aa and it caused some glitches at weapon, fxaa looks without glitches, but with less quality.
     
  50. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    308
    TAA uses motion vectors, which this tool doesn't support yet since it's specifically messing those up with the transformed matrices. I don't have a solution for you, but that's why TAA is having issues.
     
    Weendie-Games likes this.