Search Unity

Azure[Sky] - Dynamic Skybox

Discussion in 'Works In Progress' started by DenisLemos, May 1, 2015.

  1. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    I'm sorry, this code snippet with the error is from the Lux Water support and I just forgot to look at this when create the new version. Just change the "IN" by "Input" in the line 406 of the shader with the error.

    Change from this:
    Code (CSharp):
    1. half4 fogMask = tex2D(_UnderWaterMask, UnityStereoTransformScreenSpaceTex(IN.uv));
    to this:
    Code (CSharp):
    1. half4 fogMask = tex2D(_UnderWaterMask, UnityStereoTransformScreenSpaceTex(Input.uv));
    Note that the asset was not designed to work on mobile devices, the precomputed sky model is even less suitable for mobile devices because it is the most complex and expensive for performance and it uses Texture3D that is not supported by some platforms.

    I do not recommend using Azure on mobile devices.
     
  2. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    526
    I leave a couple of videos to show a little bit of Azure [sky]. They are very basic tests but I think they reflect the power of this asset if you work properly. Enviroment Lighting -> Source is in Gradient
    As a water I use Crest.




    a greeting
     
    DenisLemos likes this.
  3. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    Amazing!
    Many thanks for sharing your feedback, Crest is amazing too and seems to be constantly improving.
     
    ftejada likes this.
  4. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    137
    i'm still using unity 5.6 pro for licensing reasons.

    regarding the AQUA water fog scattering edit

    i checked your front page and noticed the shader modification code , unfortunately, i received this error

    Shader error in 'AQUAS/Desktop and Web/Double-Sided/Triple-Textured Bumpy': 'ApplyAzureFog': cannot implicitly convert from 'float3' to 'float4' at line 316 (on d3d11)
     
    Last edited: Jul 30, 2019
  5. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    Sorry for the delay, I did some testing first, but couldn't replicate the problem.

    I followed the first page step-by-step using the latest version of Azure (v5.0.0) and also using the old version (v4.4.0) that comes with the package within a sub-pack and everything is working very well.
    Screenshot of Azure v4.4.0 test from Scene view.
    AzureAquas1.png

    Note that the instructions on the first page are for newer versions of Azure. I think you should be using an even older Azure version.

    Older versions of Azure required an extra argument in the "ApplyAzureFog" function to compute the projection:
    ApplyAzureFog (float4 fragOutput, float4 projPos, float3 worldPos)
    The package should contain a text file explaining how to edit transparent shaders to support the fog scattering and how to compute the projection (projPos).

    Newer versions no longer use the projection technique, so I recommend using the latest Azure[Sky] version. If I remember correctly, I successfully tested Azure version 5.0.0 and 4.4.0 on Unity 5.6. The only thing that should break is the transparent support for the Standard shader that I editted to work with the fog scattering because I used the shader from Unity 2017 and some shader features didn't exist in Unity 5.6.

    If you don't want to download the new version of Azure so you don't risk Unity overwriting the old package and you can no longer use it, I can send you the new version package by private message.

    While I was testing Azure and Aquas to find a solution to your problem, I ended up finding a issue with the step-by-step from the first page and already edited the post with the fix.

    The issue with the step-by-step from the first page is regarding the Aquas "FORWARDADD" pass. The same changes from the step-by-step should also be made in the "FORWARDADD" pass, but instead of using the following line of code:
    finalRGBA = ApplyAzureFog(finalRGBA, i.posWorld.xyz);
    You must use the following code:
    finalRGBA = ApplyAzureFog(finalRGBA, i.posWorld.xyz, float4(0,0,0,0));
    This is a variation of the "ApplyAzureFog" function with 3 arguments, this variation is special for handling additive passes.

    Without applying the same modifications to the Aquas "FORWARDADD" pass as well, the fog scattering will not affect point and spot lights over the water surface.
    AzureAquas2.png
    Now with the modifications also made to the "FORWARDADD" pass, the fog scattering properly fades the lighting over the water surface.
    AzureAquas3.png
     
    Last edited: Jul 31, 2019
    Ali-Nagori likes this.
  6. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    105
    Apparently Azure locks the IntensityMultiplier of the environment lighting. Is it a workaround for it?
     
  7. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    137
    i actually tested the new version in the 2019 version of unity and frankly i decided to use newer version of azure since the weather profile Data was much more better and less complecated
    however i had to change up some code to make it work

    in file
    AzureSkyManager.cs
    @line 66
    Code (CSharp):
    1. private Vector2 m_currentEventTime = Vector2Int.zero;
    2. private Vector2 m_previousEventTime = Vector2Int.zero;
    to

    Code (CSharp):
    1. private Vector2 m_currentEventTime = Vector2.zero;
    2.         private Vector2 m_previousEventTime = Vector2.zero;
    in file
    AzureSkyFogScattering.cs
    @line 19
    Code (CSharp):
    1. private static readonly int FrustumCorners = Shader.PropertyToID("_FrustumCorners");
    to

    Code (CSharp):
    1. private static int FrustumCorners;
    2.  
    3. private void Start()
    4. {
    5. FrustumCorners = Shader.PropertyToID("_FrustumCorners");
    6. .....
    7. .....
    and somewhere instead of AnimationCurve.Constant i passes the keyfram array instead

    you also used Vector3Int in some Vector3 operation
    for that i included this file as an extension for 5.6


    after this Azure was perfectly working in 5.6 and edited AQUAS shader and now every thing looks natural.

    Edit:
    i also followed your new instruction about the forwardadd
    and i tested it out with fire which uses point light and the result is perfectly natural.
     

    Attached Files:

    Last edited: Jul 31, 2019
    DenisLemos likes this.
  8. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    You cannot modify this property directly from the Lighting window because it is constantly being updated by the "AzureSkyManager" script as well as the environment colors.

    Instead you must set this property on each day profile, more precisely in the "Environment Lighting" section from the Lighting tab.
    EnvironmentLighting.PNG
    Note that to see the changes in real time, you need to edit the day profile currently in use by sky manager. Other properties of the Lighting window are also handled by Azure to allow you to set different values for each day profile and thus integrate with the weather system.



    I'm glad you managed to make everything work fine.
     
    Ali-Nagori likes this.
  9. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    105
    Cool!
    Thanks
     
  10. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    7
    Hi there and firstly thank you for this excellent asset.

    I am trying the event system and cannot seem to get the event to have an affect. I have set Day, Month, Year to -1 and have set Hour to 12. My understanding is the event should then fire at 12:00 every day.

    The event action is your SetNewWeatherProfile, I have tried various values in there (0, 1, 2 etc) and nothing happens. I would assume the weather profile should change at 12:00 when the event fires? I know the event is triggering because if I put a large value in for the parameter an exception is thrown in the log (index out of bounds) at the expected time.

    Finally, I'm a bit confused, what does SetNewWeatherProfile do compared to SetNewDayProfile (I've tried both in my event by the way).

    Anyway, thank you once again, I'm enjoying playing around with your creation.

    John
     
  11. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    Hi!
    Thank you for using Azure[Sky].

    I just tested it here and everything is working fine. As you mentioned that the event is firing, so the problem should not be with the Event System.

    This is the setting I used for the test.
    EventSystem.png

    Event Action 0: It fires every day at 12:00 and changes the weather to profile number 4 (storm) from the "Global Weather Profiles" list.

    Event Action 1: It fires every day at 14:00 and replaces instantly the profile currently in use by the sky manager. There is a variation of this method that you can set a transition time, but for some reason it is not showing in the Unity Event pick list.

    Some possible causes of the problem that I can think of right now:
    • The "Global Weather Profiles" list does not have the index you are setting in the "SetNewWeatherProfile ()" method, this explains the exception thrown on the console.

    • Maybe you are changing the weather for a profile already in use, so you don't notice any changes in the sky. To find out if a weather transition is currently in progress, just check the "Transition Progress" bar.

    • You cannot see the weather changing if you are within a local weather zone. Local weather zones are prevalent and you can only see if the global weather has changed when you leave the local weather zone.
     
    ftejada likes this.
  12. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    7
    Thank you sir for helpful response. I started again and it is now triggering as expected, must have been something I had not correct.

    Can I ask another question though, I'm quite confused with the difference between a weather profile and a day profile. In your example above for example, what would be the difference between setting a weather profile to "Storm" and setting a day profile to "Storm", isn't it the same thing?

    I have noticed that unless the weather profile is set to "Default" then the day weather won't change to a random day profile after midnight. Is this right.

    They're my last questions I promise (he says) :)

    thanks again

    John
     
  13. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    I'm glad it's working now.

    Yes, basically everything is the same thing!
    I just call "Weather Profile" a profile that is being used as a weather type in the "Global Weather Profiles" list.
    And I call "Default Day Profile" a profile that is being used as default by each regular day(@ Default). You can use the same profile in both cases.

    The system is designed to choose a random profile from the "Default Day Profiles" list and set it to the default day profile field(@ Default) whenever a new day starts regardless of the weather in use. But it's happening exactly as you said, the default day profile is only chosen randomly if the weather is set to default. Looking at the source code, I found that something is missing.

    Just add this line of code to the Update() of the AzureSkyManager.cs:
    Code (CSharp):
    1. profileController.defaultProfile = m_nextDayProfile;
    After this line:
    Code (CSharp):
    1.  
    2. // Make the transition to the next day only if the profile is different from the current profile and there is no weather profile in use.
    3. m_nextDayProfile = profileController.defaultProfileList[Random.Range(0, profileController.defaultProfileList.Count)];
    4.  
     
    Last edited: Aug 7, 2019
  14. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    7
    DenisLemos likes this.
  15. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    7
    I can't seem to be able to set Day Length and Timeline value via code. If I use the sliders in the Editor and then run they work fine, but trying to change those values in code at runtime has no effect. After changing daylength for example at runtime, the property value does change in the editor but it has no effect. I tried calling UpdateCalendar() after the change but that did not help.


    Thank you
     
  16. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    You need to call UpdateCalendar() always when you change the date by script to sync the calendar from inspector with the new date, it is not required if you want to change only the time.

    Changing day length will not take effect because it is only used to calculate the time progression step when starting the scene. So if you want to change the day length, you also need to recalculate the timeline progression step based on the new length value.
    Code (CSharp):
    1. if (Input.GetKey(KeyCode.Return))
    2. {
    3.     // Set the new timeline and day length
    4.     timeController.timeline = 19.0f;
    5.     timeController.dayLength = 10.0f;
    6.  
    7.     // Recalculates the progression step to move the timeline
    8.     m_timeProgression = timeController.GetTimeProgressionStep ();
    9. }
     
  17. Snark-s

    Snark-s

    Joined:
    Aug 2, 2019
    Posts:
    2
    Looks like I found an error.

    When changing the longitude, the starry sky changes twice as fast as necessary. When the longitude changes from -180 to 180, the Sun, as expected, makes one revolution, but the starry sky - two.
     
  18. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    492
    Thank you for letting me know.

    I could replicate the error and it only seems to happen when using realistic time mode. I'll take a look at this and try to find a solution.

    [Edited]
    @Snark-s I have already discovered the cause of the error and an update will be sent shortly to fix this and other bugs.

    Just need to change this line in the Update() of the AzureSkyManager.cs: It's located at the "switch" that checks the time mode, inside the case AzureTimeController.TimeMode.Realistic:
    Code (CSharp):
    1. m_starFieldMatrix = Matrix4x4.TRS(Vector3.zero, timeController.GetCelestialRotation() * Quaternion.Euler(options.starFieldPosition), Vector3.one);
    by this:
    Code (CSharp):
    1. m_starFieldMatrix = Matrix4x4.TRS(Vector3.zero, timeController.GetCelestialRotation() * Quaternion.Euler(options.starFieldPosition - new Vector3(0.0f, timeController.longitude, 0.0f)), Vector3.one);
     
    Last edited: Aug 12, 2019
  19. Snark-s

    Snark-s

    Joined:
    Aug 2, 2019
    Posts:
    2
    Thank you!