Announcement

Collapse
No announcement yet.

Dynamic sun position

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

    Dynamic sun position

    Hey guys,

    new day, new problem:
    I've been following this great tutorial: https://forums.epicgames.com/threads...DK-Dynamic-Sun and almost everything works perfectly.
    However, there's one thing that annoys me: The sun position is depending on the camera position, which is not always a good choice.
    I tried to fix it but I don't really get the mathematics behind the position calculation.
    Here is my material setup and a screenshot of the problem(The sun rays are okay, but as you can see, the sun is a moved a bit to the left!)


    What I see are 2 vectors with the directions(in degrees?) of the light and the camera. After googling a bit and with my little non game-programming mathematics knowledge,
    I figured out that the dot product calculates the angle between the 2 vectors. But the output is a scalar rather than a angle in degrees(a number without unit?).

    But I don't get what happens after....

    In short terms: how can I make the sun position completely depending on the dominant directional light instead of the camera and what exactly happens there.
    I may apologize for such a question but this kind of mathematics is not that easy for me.

    #2
    hmm I don't know that tutorial you followed. but I myself have made a tutorial series on how to get a moon into the sky. I have a segment on how to modify the udk sky master materials. ...
    here is part 3
    https://www.youtube.com/watch?v=OjAcXFU79XU if you don't want to watch whole thing it cool fast forward to 2:16ish and there is good screen shot of the sun section of the material. you can pause and recreate it your self. good luck and have fun.
    also here is a good tutorial I followed and learned a lot from a few years ago.
    http://allarsblog.com/blog/2010/09/1...ycle-tutorial/

    Comment


      #3
      I've looked into it and the sun is still depending on the cameras position. So more or less, its not helpful for me, but some other parts are a nice addition to my current setup, so thanks for the links.

      Comment


        #4
        The NightandDay demo map uses a very simple system, its just a matinee rotation. Very curious to know how two approaches compare regarding frame rates...

        Has anyone ever benchmarked this?

        Comment


          #5
          Originally posted by FrostByteGER View Post
          I've looked into it and the sun is still depending on the cameras position. So more or less, its not helpful for me, but some other parts are a nice addition to my current setup, so thanks for the links.
          I don't understand what your talking about then. sorry man.
          but the tutorial of mine the light does Not depend on the camera's position only the directional light.
          I mean there is a camera vector in there (gradient) but, I don't understand what your wanting I guess? my bad

          I have a decent sky material has 35 instructions runs real well hardly any frame rate drop at all as compared to same level with no sky.

          Comment


            #6


            This image should clarify the problem. In the real world, the sun doesn't follow us, right? So wouldn't it be logical if it does the same in UDK too?
            If so, the sun would be at the exact same position as the render shafts. But it the image proves this wrong...
            Its because the sun depends on the players cameraposition(not the rotation, otherwise we would see the sun all the time, even if we look to our right.).
            As long as we are at the center of the map, everythings fine because the suns position overlaps perfectly with the light source and its render shafts. But being in the center of the map is not always what we want.

            So what I want is that whenever I rotate and set my dominantdirectionallight, the sun should follow its direction AND exact position, even if the player moves away from the center of the map(image that the player flies with a plane to the
            farthest point possible in UDK). What would happen if the sun is still dependant on the camera-position? Yeah, it would follow us, even if we are billions of miles away from the center of the map.

            Comment


              #7
              *bump*
              no ideas?

              Comment


                #8
                I'm interested in this area also. I've spoken with Julio, but he wasn't sure if his tutorial is still applicable to recent versions of UDK. I'm just using a basic Matinee as I haven't delved into custom materials. It would be of interest to know why you're creating the Dynamic Sun as a material versus just a night / day color Matinee?... What are the advantages? What's the frame rate difference? BTW: Follow the links to get Julio's email or PM me.

                Comment


                  #9
                  Okay so I've sent him an email and he said that he'll look into it. He will also do a revision of the current tutorial, but of course, it may take a while.

                  Comment


                    #10
                    My god, I found the solution, and its so **** easy.
                    I found the crucial information in the Eat3D UDK Shader Production DVD I bought recently(btw. these Training vids are the best tutorials I've ever seen!).
                    In order to make the sun fixed to the direction of the light, plug a Constant3Vector with the following values into the A node of the DotProduct: 0,0,-1
                    Thats it. HOWEVER, this technique works only with a sphere/halfsphere. Other skydomes wont work since their surface normals are not uniform. The top of the dome is usually a bit dented.
                    Otherwise, the sun will be oddly stretched.

                    I assume that there is a way to fix this too, but I'm happy for now.

                    It would be a cool addition, if the sun never changes its size, even if the player moves towards it. Like it does when I use the camera vector.

                    Comment

                    Working...
                    X