Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Fog not working ?

Discussion in 'PSM' started by bakanekofr, Jun 20, 2014.

  1. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    Hello,

    It seems colored fog still not work even in the final version. The fog color don't appears, even with a high density.

    Here's a shot of my fog settings :
    fog.png

    I've tried in both deferred and forward paths.
     
  2. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    No one having this problem ? Any solutions ?
     
  3. PeterD

    PeterD

    Joined:
    Feb 6, 2013
    Posts:
    120
    screenshot?
     
  4. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    Here's a comparison from an old build. Still having the same problem in every level, even with the final Unity for PSM.

    no_fog.png
     

    Attached Files:

  5. PeterD

    PeterD

    Joined:
    Feb 6, 2013
    Posts:
    120
    Um, I'm clearly blind because, aside from some colour differences between the Vita screen and your PC screen I can't see any issue here. Remember that the Vita screen is a much lower resolution than your PC one so some effects will look different on the actual Vita hardware. I have to be honest and say that this is all I am seeing in those screenshots.
     
  6. PadTheMad

    PadTheMad

    Joined:
    May 19, 2013
    Posts:
    1
    I can see the difference between the two, because I'm having the same problem myself. I'm using the same fog settings (with a density of 0.2 and black as the colour) and on the PSM Build there is no fog at all.

    The following image is running on PC:
    fog-ex-pc.jpg

    and on the Vita:
    fog-ex-psv.jpg

    All the materials in the scene are using the Unlit/Texture shader.
     
  7. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    @PeterD: I assure you there is a difference, maybe not visible in this comparison, but very visible on other cases.

    @PadTheMad: Yes this is the same problem. BTW, I'm using the default diffuse shader, so this is not a shader problem it seems.
     
  8. PeterD

    PeterD

    Joined:
    Feb 6, 2013
    Posts:
    120
    Yes I too can confirm that Fog is not working with the current shaders.
     
  9. unaji

    unaji

    Joined:
    May 13, 2013
    Posts:
    1
    I have the same problem:
    fog works on PC, Mac, Linux, Android
    fog doesn't work on Vita

    I'm not using special fog or texture settings
     
  10. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Ok, so the problem / current situation is this:

    If the material is using fixed function shaders, then fog should work and provide the same result as in the editor.

    Now, if you use a 'regular' shader things get a bit tricky.
    The whole idea of a 'fog state' is inherited from the fixed function days - regular shaders don't have a fog state.
    To solve this for the other mobiles (iOS/Android) we patch the shader at runtime to include the fog calculation (basically include a small code snippet) to tweak the values.
    This part (patching your shaders at runtime) is currently not available on PSM for PS Vita. Instead the shader has to be edited manually in the editor, before building the game.

    This is of course not ideal, and I'm looking into bringing the patching mechanism from iOS/Android to PSM.
    The workaround, if you don't want to manually edit the shader, is to use a fixed function shader instead.
     
  11. PeteD

    PeteD

    Joined:
    Jul 30, 2013
    Posts:
    71
    Can you put up a list (doesn't have to be complete) of which shaders to use if you want fog and also the snippet code that we need to patch into the existing shaders. Presumably it's the same for all non fixed function shaders.
     
  12. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    PeterD likes this.
  13. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    Any chance someone could take the current diffuse shader and apply this patch, then share the result ? I'm a total noob at shaders (in Unity) so I can't do it myself. Thanks in advance :)
     
  14. PeterD

    PeterD

    Joined:
    Feb 6, 2013
    Posts:
    120
  15. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    Do you plan to add this automatic patching in an upcoming update ?
    By the way, do you plan to update Unity for PSM 4.3 or do we need to wait for Unity 5 for the PSM bug fixes ?
     
  16. KheltonHeadley

    KheltonHeadley

    Joined:
    Oct 19, 2010
    Posts:
    1,685
    I'd like to see this in the official build.
     
  17. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    How fog patching will be implemented, if at all, depends somewhat on the changes we already have in Unity 5.
    It's very likely there will be a minor bug fix release still based on 4.3 before we move to Unity 5.
     
    bakanekofr likes this.
  18. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    Hi, and thanks for today's hotfix update.

    Unfortunately, fog is still not fixed in this update. Can you please share your plans on this ? (do we need to wait for 4.3 hotfix2, or Unity 5 ?). Fog is the only lacking feature that I'm looking for for my game.
     
  19. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Fog patching would be a way too invasive (risk for regression) change, and was never considered for the just-released hotfix.
    Also since fog can be implemented in the shader, with what is currently supported, it's also not a critical bug.

    As I already explained - fog in fixed function shaders are supported "automatically".
    With proper shaders fog needs to be implemented in the shader - and this is not something that is unique to PSM.
    As such, it's not a critical feature lacking from what is currently supported, and thus not something considered for a hotfix.

    My comment regarding the now released hotfix was a response to the question
    - not an indication that fog patching would be added in a hotfix.

    And as I mentioned - fog patching (existing for GLES, but not for a lot of other APIs) is something that possibly will have changes in 5.0, which would affect the support also for PSM.
     
  20. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    I do think it is a critical bug, for these two reasons :
    - You have to patch every shader in the game, and this mess up the others platform builds as the standard fog effect is still applied (the 2 fogs are active at the same time), a lot of time lost by switching the shaders.

    - I've tried the patched diffuse shader on the Vita, with a red fog, the effect is visible, but with a black fog, I don't see any effect, or the result is not as expected, here's a comparison shot between the same scene on the Vita (with the patch) and on PC (without the patch), with a black fog applied. (consider only the center pillar, the other parts have black textures).

     
  21. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    It's not a bug since it's the expected behavior from the perspective that runtime fog patching of Cg shaders simply isn't something that is supported with Unity - on any platform.
    And PS Vita unfortunately uses Cg shaders (had it been using GLSL instead this wouldn't have been a problem).
    Runtime fog patching is also not a key feature on all other platforms - some platforms do support it (like iOS and Android) while others (WP8 and consoles for example) don't.

    From that outset adding runtime fog patching to Unity for PSM is a feature addition. One might argue it's a critical feature, but one could also argue that it can be worked around (by manually fixing the shader - which could be annoying).

    In short :
    Yes, we might add runtime fog patching (or solve it some other way) in Unity 5.x.
    But no, we won't release a hotfix just to solve the lack of runtime fog patching in 4.3.
     
  22. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    OK, thanks for the information. I hope you guys will find a solution for this feature somehow :)
     
  23. Black_Eagle

    Black_Eagle

    Joined:
    Jul 19, 2014
    Posts:
    36
    Yes me too cause that's is what my game's lacking, its hard to make a zombie/horror fps without fog haha, that's all im waiting for, it's critical also
     
  24. Black_Eagle

    Black_Eagle

    Joined:
    Jul 19, 2014
    Posts:
    36
    Ok I don't know how to make the fog to appear in the air but on items I just figured it out, use legacy diffused fast shaders
     
  25. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    I've tried the legacy diffuse fast shader, but I have a strange problem, the model appears without textures, with a white / pink color, this happen also using other shaders such as vertex lit ect. (maybe fixed fonction shaders ?). I'm running in forward rendering. Any idea ?

     
  26. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Pink output usually means that the shader failed to compile (for whatever reason).
    Have a look the the PSM log output when loading the scene - it should output some information if the shader compilation failed.
     
  27. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    Are you talking about the generic Unity's Log that you access from the console's top right? I did not find anything related to shader compilation error.

    Anyway, I've been testing a few things, and found that linear fog doesn't work if it have a black color, in every platform (even in the editor), that's why I did not see a difference using your Windows Phone fog patch (which was a linear fog I suppose).

    Then I've found this link, and tried the exponential fog patch, and now my black fog appears on Vita, still need to patch every shader in my game, but better than nothing...
     
    Black_Eagle likes this.
  28. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    No, the device log - using PsmDeviceForUnity.exe -get_log [GUID], or the Publishing Utility for Unity's [Package & App] panel - [Console Output].

    You cannot see shader compilation errors in the editor since all the shaders are compiled at runtime.
     
    bakanekofr likes this.
  29. Black_Eagle

    Black_Eagle

    Joined:
    Jul 19, 2014
    Posts:
    36
    Yea its better than nothing that's what imma do, I need to release my game asap...people always wanted a zombie game for the vita and a lot of people are asking for the release date
     
  30. Black_Eagle

    Black_Eagle

    Joined:
    Jul 19, 2014
    Posts:
    36
    ok I tried that link and guess what, it still doesn't work... I NEED FOGG
     
  31. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Anyone having an issue with a shader or with fog on a specific shader, please start a new thread, post what you need the shader to do, and the code for the current shader you're trying to use (if it's just a standard Unity one and if it's unmodified just post the name is fine) I'll be happy to patch the shader for you as I've done most of them for my game (they aren't the standard unity ones they are my own, but it was pretty easy once you know what to do) so it would only take me 10 mins to fix one for you. Please don't just PM me, as I'm sure the fixes will be to everyones benefit.
     
  32. Black_Eagle

    Black_Eagle

    Joined:
    Jul 19, 2014
    Posts:
    36
    Can u not post it here?
     
  33. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    What shader do you need fog for? Is it one of the built in ones? If not can you post the source.

    Thanks,

    Jon
     
    twobob likes this.
  34. Jordan100X

    Jordan100X

    Joined:
    Jan 31, 2017
    Posts:
    2