Announcement

Collapse
No announcement yet.

Projecting a Moon image within a SphereMask/SkyBoxImage

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Projecting a Moon image within a SphereMask/SkyBoxImage

    Hey guys,

    I use calculations that feed Moon position & phase data to the material based on TOD and date, which works great, I'm a bit stuck with the material though. I'm trying to decide how to go about this, I have tried both a SphereMask and the SkyBoxImage material function, both almost work, but for different reasons.

    The SkyBoxImage makes it simple to project the moon image, but it is causing some weird stretching along the Z axis when the moon is close (or below) the horizon. I can live with it so long as it only happens below the horizon, but certain days of the year cause the moon to be capsule shaped about 25 degrees above the horizon. Below the horizon it can sometimes stretch the image into a large rectangle that fills the whole lower half of the sphere.

    The SphereMask is much more promising without a texture being used. With 2 SphereMask's overlapping the moon phase looks great, but there are 2 big problems with it:
    1) The "earth shadow" SphereMask should only occlude the moon, as it is now it will also occlude the stars/blue sky
    2) I can't seem to get an image to project itself properly so far within the SphereMask (and stay aligned as it moves across the sky)

    Here's an image showing the basic SphereMask setup:
    Click image for larger version

Name:	MoonPhase.JPG
Views:	1
Size:	184.4 KB
ID:	1185658

    Right now my sky is set to Opaque, something I might be changing later (might move all moon/sun/stars to a new sphere behind the atmosphere, haven't decided yet).

    Anyone have any ideas or alternate methods that might work?

    Thanks!
    Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

    #2
    You could just clamp between 0-1 after that. I am guessing the reason it happens is because you added a negative number and then that negative number was passed outside of this material function and messed up either the overall material opacity or something down the chain that you were using to blend on top of or behind this.
    Ryan Brucks
    Principal Technical Artist, Epic Games

    Comment


      #3
      Originally posted by RyanB View Post
      You could just clamp between 0-1 after that. I am guessing the reason it happens is because you added a negative number and then that negative number was passed outside of this material function and messed up either the overall material opacity or something down the chain that you were using to blend on top of or behind this.
      Genius! Ok that looks great, thank you.

      Now I just need to get my Moon image into the moon disc SphereMask. Is it just a matter of scaling trial and error, or is there a smarter way to do this?

      Thanks again Ryan!
      Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

      Comment


        #4
        Here is what I would do:

        Store that circle in the alpha of the moon texture. Set the UVs to be "Clamp" mode. Sample the same texture a 2nd time with offset UVs, offsetting only the X. The strength of the offset will tell you how 'new' a moon is. Then it automatically lines up.
        Ryan Brucks
        Principal Technical Artist, Epic Games

        Comment


          #5
          Originally posted by RyanB View Post
          Here is what I would do:

          Store that circle in the alpha of the moon texture. Set the UVs to be "Clamp" mode. Sample the same texture a 2nd time with offset UVs, offsetting only the X. The strength of the offset will tell you how 'new' a moon is. Then it automatically lines up.
          Pardon my ignorance here, I'm probably missing something obvious...

          I have set the sampler to Shared: Clamp, and the texture already had the mask in it's alpha channel so it's ready to go, I'm just not quite sure what I should be plugging into the UVs slot of the sampler to get it to align/scale itself to fit into the SphereMask for the Moon Disc. Is it possible to use the size of the SphereMask to scale the texture properly or should I scale it manually with a TexCoord? or not even use the SphereMask for the moon disc? SphereMask is something I haven't messed with much, so I'm probably just misunderstanding something simple here sorry.

          Also I have my Moon Phase scalar input which has a range of 0 to 1 that drives the shadow SphereMask (set in a blueprint from the date), where 0 & 1 == Full Moon, 0.5 == new moon. I have removed the Multiply * 3 (the radius was too high) and plugged it in directly to the MakeFloat 3 Y-input, which works well previewing the clamp, but not in game. Is this where you are referring to offsetting on the X instead?

          Thanks for your help Ryan. Sorry to be a pain
          Last edited by DotCam; 06-08-2016, 03:04 PM.
          Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

          Comment


            #6
            Might as well post it here for anyone else who is interested.

            Click image for larger version

Name:	moon.JPG
Views:	1
Size:	94.1 KB
ID:	1107962
            This is a way to project the moon texture based on a direction vector.
            For some reason it projects two moons (one in the opposite side?) so I used SphereMask to fix that.

            I'm sure there is a better way of doing this though

            Now we are trying to figure out a way to shadow the texture to simulate lunar phases.
            The idea is to use a projected sphere normal map (matching the moon size and position) and then use that normal map for the dot product with a light vector.

            Any ideas or advice on the subject are more than welcome

            4.10 Update! -> [Community Project] WIP Weather & Ocean Water Shader
            WIP Interactive Water Shader, WIP 2D Water Sim
            WIP FFT Ocean w/ Foam, Quad-tree Infinite Ocean LOD

            Comment

            Working...
            X