Announcement

Collapse
No announcement yet.

Speedtree and shadows

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

    Speedtree and shadows

    Sigh.. this one is really bugging my mind, tried this and that.. I have made some trees in speedtree, with a mesh for leaves instead of billboards, and imported them into UDK. The shadowing really is beyond me, and I got some questions about it. The result can be seen below, lighting built on preview with lightmass:

    http://img257.imageshack.us/img257/2697/speedtree.jpg

    Question 1: Trees on the left got Precomputer shadows enabled, while trees on the right don't. The issue is, that while the trees on the right look lot better and more natural (because of better light spread within leaves), they dont cast good enough shadows, but just some blocky outline. How do I get more detailed shadows on the trees without using precomputed shadows, or how to get a better lighting effect in the leaves when using it?

    Question 2: Is there any way to control shadow density the trees cast, since speedtree lack the normal options a static mesh have.

    Question 3: Is there any way to control shadow quality the trees cast, as in more/less blurry edges. Since I have to use OpacityMask option in material editor, I cant use opacity for that purpose. I'd like leaves to stop less light.

    Question 4: Is there any way to get more realistic shadows, as in when two shadows overlap they create a deeper shadow in the overlap? At the moment, as you can see on the left trees, all shadows blend together in one same gradient.

    Sorry for that many questions, I actually came to ask only number one but figured I might as well fire away few other smaller stuff which are bugging me. Big thanks to anyone who helps, specially with number 1

    #2
    1. maybe using a higher lightmass setting
    3. I'm pretty sure objects can't cast different densities in their shadows. it's a property of the light itself
    3. Again, a property of the light, not per object. Depending on the light you might be able to blur the shadows more or not, or doing it in the lightmass settings
    4. In theory they should, but only if you're using more than one light. "intersecting shadows becoming more dense" never really happens on a single light on real life either

    Comment


      #3
      Originally posted by Chosker View Post
      1. maybe using a higher lightmass setting
      3. I'm pretty sure objects can't cast different densities in their shadows. it's a property of the light itself
      3. Again, a property of the light, not per object. Depending on the light you might be able to blur the shadows more or not, or doing it in the lightmass settings
      4. In theory they should, but only if you're using more than one light. "intersecting shadows becoming more dense" never really happens on a single light on real life either
      1. Which setting are we talking about? I can't find anything that would directly increase quality of shadowmaps in lightmaps settings under world info (speedtrees dont have the same settings for lightmap as a static mesh).

      2&3 I was referring to the trick used on the fence in this guide: http://udn.epicgames.com/Three/ShadowingReference.html , where they used opacity to make shadows more blurry. However I cant seems to be able to use both opacity and opacityMask channels at same time, any work around for that? I need opacityMask channel for leaves, but also would like to increase the amount of light the leaves material let through.

      4. Ignore it, wasn't thinking straight after all the hours I was spending on the issue x)

      Comment


        #4
        1. I don't use lightmass or lightmaps (for me its all dynamic lights+shadows) so I don't know, but I'd say using something other than the lightmass 'preview' setting, maybe 'production'.
        anyway if it's only regarding the lightmaps perhaps it's a problem of the terrain's lightmaps, as it's the terrain what's using low-res lightmaps. remember that the trees are not responsible for the lightmaps of the rest of objects even if it's the tree's shadow what's being baked into them

        2&3. if you're using that guide just plug the node into both opacity and opacityMask. if one of the 2 is greyed-out (new in Aug or Sept build) then set the material as translucent, plug into opacity, set to masked, plug into opacityMask, set back to translucent.

        Comment


          #5
          Originally posted by Chosker View Post
          2&3. if you're using that guide just plug the node into both opacity and opacityMask. if one of the 2 is greyed-out (new in Aug or Sept build) then set the material as translucent, plug into opacity, set to masked, plug into opacityMask, set back to translucent.
          That trick didnt quite work, if the material is set to translucent, it ignores opacitymask, unless I am doing something wrong (I did switch as you advised). You can see result in screen below:

          http://img832.imageshack.us/img832/525/unledzou.jpg

          Comment


            #6
            Your texture sample for the opacity is wrong. You are plugging the complete diffuse channel into the opacity node, thats why it isnt working. You need a black and white mask texture for that node, where 100% white = completely opaque, 100% black = completely translucent with linear blending in-between the greyscale portions.

            Comment


              #7
              Originally posted by hunharibo View Post
              Your texture sample for the opacity is wrong. You are plugging the complete diffuse channel into the opacity node, thats why it isnt working. You need a black and white mask texture for that node, where 100% white = completely opaque, 100% black = completely translucent with linear blending in-between the greyscale portions.
              Ive solved that problem by plugging the alpha (white) channel of the leaf texture into opacity, resulting in leaves having both translucent around them and being bit translucent themselves. That however gave rise to other issues of leaves gaining glow effect when trying to decrease opacity amount, so I guess your suggestion would solve that, gonna give it a try.

              However I think I am taking a wrong approach here, what I want is to let light pass through the leaves without making the material visibly translucent, if that is even possible? I think I am getting lost here, at what exactly I need to do in order to make shadows more realistic.

              I think I will export the speedtree as a staticmesh, which will give me extra options on lighting, and then work from there. Thanks for all the help!

              Comment


                #8
                Turn on cascaded shadow mapping for better shadows from the trees. The settings can be found in the dominant directional light's properties.

                Comment


                  #9
                  Originally posted by Cronnix View Post
                  Ive solved that problem by plugging the alpha (white) channel of the leaf texture into opacity, resulting in leaves having both translucent around them and being bit translucent themselves. That however gave rise to other issues of leaves gaining glow effect when trying to decrease opacity amount, so I guess your suggestion would solve that, gonna give it a try.
                  if the leaves are translucent themselves then your alpha channel is wrong. if you paint white what will be opaque and black what will be transparent then the leaves will not be translucent at all.
                  if there's a glow effect is because one of the values is coming out as more than 1.0, so plug a constant clamp before plugging into opacity.
                  you're going at this right, it just seems you haven't grasped all of a Material's concepts totally right yet. hunharibo's suggestion was absolutely right btw

                  Originally posted by Cronnix View Post
                  However I think I am taking a wrong approach here, what I want is to let light pass through the leaves without making the material visibly translucent, if that is even possible? I think I am getting lost here, at what exactly I need to do in order to make shadows more realistic.

                  I think I will export the speedtree as a staticmesh, which will give me extra options on lighting, and then work from there. Thanks for all the help!
                  yes, I'm trying to guide you through it but if your translucency is wrong in the first place then you'll need to fix that first.

                  Comment


                    #10
                    Originally posted by Xendance View Post
                    Turn on cascaded shadow mapping for better shadows from the trees. The settings can be found in the dominant directional light's properties.
                    Thanks, that solved the lack of dynamic shadows!

                    Originally posted by Chosker View Post
                    if the leaves are translucent themselves then your alpha channel is wrong. if you paint white what will be opaque and black what will be transparent then the leaves will not be translucent at all.
                    if there's a glow effect is because one of the values is coming out as more than 1.0, so plug a constant clamp before plugging into opacity.
                    you're going at this right, it just seems you haven't grasped all of a Material's concepts totally right yet. hunharibo's suggestion was absolutely right btw
                    Thanks for suggestions! I've now plugged in the new source of opacity, as you can see in picture below:

                    http://img59.imageshack.us/img59/1664/trans1d.jpg

                    That results in just what I am looking for, in the preview window! However once used as material, it's far from perfect in the actual level. As you can see on the picture below, there are two issues (built with lightmass on preview):

                    http://img545.imageshack.us/img545/4981/trans3.jpg

                    First, the leaves are transparent even at the most whitest part of the opacity (you can see the texture I used here: http://img855.imageshack.us/img855/5...vesopacity.png ), even thou I did try controlling the opacity amount with multiply, which obviously didn't work. So I guess the question is, how do I control how many % of the opacity texture material will take up? Should be a way of adjusting how transparent I want material to handle the opacity channel as, I guess. I also tried scalar parameter instead of a constant, however no matter the value, I cant get leaves non transparent at the white, it seems to be partially translucent everywhere no matter what.

                    Second, the leaves don't throw any shadow for some reason on eachother or on the trunk, resulting in lightmass generating one bland shadow in the "forest", instead of deeper shadow in with less shadow outside.
                    Just compare this (opacity used)
                    http://img267.imageshack.us/img267/6005/trans4b.jpg

                    With this (opacity mask used)
                    http://img546.imageshack.us/img546/3720/trans5.jpg

                    Gah, more I fix, more problems occurs. Once I've got this right I am getting back to studying how materials work before moving on.. baby steps. Thanks for having patience with me.

                    Comment


                      #11
                      Small bump, none knows how to control how transparent I want opacity to be? Since I cant get the white to be non transparent.

                      Comment


                        #12
                        Originally posted by Cronnix View Post
                        Once I've got this right I am getting back to studying how materials work before moving on.. baby steps. Thanks for having patience with me.
                        Exactly
                        first off, there is no reason to waste a texture just to use it as the opacity map. what we were trying to tell you earlier is that the same grayscale image that you're using as opacity, it should be in your regular diffuse map, existing only in the alpha channel (while RGB channels are your diffuse colors). then go back to using the diffuse's alpha as the source of your material's alpha as you were doing before. results are the same except you use 1 texture instead of 2. in games this is common knowledge and good practice.

                        Originally posted by Cronnix View Post
                        Thanks for suggestions! I've now plugged in the new source of opacity, as you can see in picture below:

                        http://img59.imageshack.us/img59/1664/trans1d.jpg

                        That results in just what I am looking for, in the preview window! However once used as material, it's far from perfect in the actual level. As you can see on the picture below, there are two issues (built with lightmass on preview):

                        http://img545.imageshack.us/img545/4981/trans3.jpg

                        First, the leaves are transparent even at the most whitest part of the opacity (you can see the texture I used here: http://img855.imageshack.us/img855/5...vesopacity.png ), even thou I did try controlling the opacity amount with multiply, which obviously didn't work. So I guess the question is, how do I control how many % of the opacity texture material will take up? Should be a way of adjusting how transparent I want material to handle the opacity channel as, I guess. I also tried scalar parameter instead of a constant, however no matter the value, I cant get leaves non transparent at the white, it seems to be partially translucent everywhere no matter what..
                        the results are what people usually get in this cases. 100% white means it will be opaque, but your image has fading edges so it's no surprising a lot of it becomes semi-transparent.
                        to fix this just multiply it, right. use a big number like 10 or something. actually use a scalar param and control it via your material instance which is easier because you see the results in real-time, in the level, without having to re-compile.

                        if you'd wanted to control how much % of the opacity texture it will take up... think a little. most of the materials people do require this sort of thinking, people do much and more with materials and a lot of it involves this kind of problem-solving. and this is an easy one, an everyday thing in materials! also thinking about this is good because there's usually a lot of ways to get the same effect, the tricky part is finding the one that'll be simpler (and therefore less CPU/GPU consuming)
                        but if you just want the answer: one of the multiple ways to do it is to multiply your opacity by, say, 0.3, then add 0.7, then the constant clamp you already have. legend: 0.3 is how much your opacity map will be used, 0.7 is the rest needed for the opacity to go into 1.0 which is fully opaque.
                        then again what you're asking for is wrong. in this case you'll get the whole polygon to be 70% visible, and the leaf itself 100% visible. and you don't want the polygon to look like that because you're back to square one. just multiplying is fine.

                        Originally posted by Cronnix View Post
                        Second, the leaves don't throw any shadow for some reason on eachother or on the trunk, resulting in lightmass generating one bland shadow in the "forest", instead of deeper shadow in with less shadow outside.
                        Just compare this (opacity used)
                        http://img267.imageshack.us/img267/6005/trans4b.jpg

                        With this (opacity mask used)
                        http://img546.imageshack.us/img546/3720/trans5.jpg
                        that's a whole different story. translucent materials do not produce shadows as is. I won't bore you with the technical explanation, just know that if you want them to, you need to tell them to cast shadows as if the material was masked. somewhere in the material there's a tick called 'cast shadows as masked' or something like that.

                        I hope you can get this to work because it'll help you learn...
                        but all in all the usual recommendation here is to just make your leaves use a masked material. why? because too much translucent polygons in a scene kill the GPU's performance, and trees do have a lot of polygon leaves. if you take a look at UDK's grass and trees, and hell, any other modern game, they're all good hard-masked opacity.
                        masked leaves produce good shadows, are not GPU-expensive, work fine with lightmass and never will produce depth errors. just make a big enough opacity map and stick to masked

                        Comment


                          #13
                          Originally posted by Chosker View Post
                          the results are what people usually get in this cases. 100% white means it will be opaque, but your image has fading edges so it's no surprising a lot of it becomes semi-transparent.
                          to fix this just multiply it, right. use a big number like 10 or something. actually use a scalar param and control it via your material instance which is easier because you see the results in real-time, in the level, without having to re-compile.

                          if you'd wanted to control how much % of the opacity texture it will take up... think a little. most of the materials people do require this sort of thinking, people do much and more with materials and a lot of it involves this kind of problem-solving. and this is an easy one, an everyday thing in materials! also thinking about this is good because there's usually a lot of ways to get the same effect, the tricky part is finding the one that'll be simpler (and therefore less CPU/GPU consuming)
                          but if you just want the answer: one of the multiple ways to do it is to multiply your opacity by, say, 0.3, then add 0.7, then the constant clamp you already have. legend: 0.3 is how much your opacity map will be used, 0.7 is the rest needed for the opacity to go into 1.0 which is fully opaque.
                          then again what you're asking for is wrong. in this case you'll get the whole polygon to be 70% visible, and the leaf itself 100% visible. and you don't want the polygon to look like that because you're back to square one. just multiplying is fine.
                          Update: http://img12.imageshack.us/img12/523/trans4i.png

                          Thanks for indepth explanation! I have added the opacity mask into the alpha channel now, which did result in the desired edge fade on the leaves. However, as you can see, no matter what or how I multiply it with, the white part is still about transparent, even thou it should be completely opaque. I have tried to multiply it just once, two times (as you can see on screenshot, even thou mathematically they take out each other I think) and as you suggested to just multiply it with 1 which should result in white part of opacity mask being fully opaque.. but no. I really don't know what is wrong, probably some checkbox I forgot?

                          As you suggested, I will stick to the opacity mask instead, for performance sake as you explained, but would really like to get opacity working way I want, for learning. I don't understand why no mater what I multiply it with it remains partly transparent even at most nontransparent part (it is fully white there).

                          Last question thou. Do you happen to have some tips on literature/online indepth guides on how texturing works technically? The whole thing of how memory handles texture, how to optimize the material for performance, ect? I feel I have a huge gap in my knowledge when it comes to that and need to read up on the subject of optimization.

                          Comment


                            #14
                            Originally posted by Cronnix View Post
                            Update: http://img12.imageshack.us/img12/523/trans4i.png
                            Thanks for indepth explanation! I have added the opacity mask into the alpha channel now, which did result in the desired edge fade on the leaves. However, as you can see, no matter what or how I multiply it with, the white part is still about transparent, even thou it should be completely opaque. I have tried to multiply it just once, two times (as you can see on screenshot, even thou mathematically they take out each other I think) and as you suggested to just multiply it with 1 which should result in white part of opacity mask being fully opaque.. but no. I really don't know what is wrong, probably some checkbox I forgot?

                            As you suggested, I will stick to the opacity mask instead, for performance sake as you explained, but would really like to get opacity working way I want, for learning. I don't understand why no mater what I multiply it with it remains partly transparent even at most nontransparent part (it is fully white there).

                            Last question thou. Do you happen to have some tips on literature/online indepth guides on how texturing works technically? The whole thing of how memory handles texture, how to optimize the material for performance, ect? I feel I have a huge gap in my knowledge when it comes to that and need to read up on the subject of optimization.
                            well your setup seems just right, no missing checkboxes. it is weird though because in theory it outputs 1-0 at the most opaque value, unless your constant clamp's values are not 1.0 and 0.0. notice though that while your object seems to be visible through itself, the grid lines are totally blocked out by the object for example on the left of the cylinder, which makes me think there's some weird z-fighting.so this might be something about your video drivers, but this goes beyond me.
                            try activating both 'use lit translucency depth pass' and 'use lit translucency post render depth pass' to see if that fixes it. maybe translucency and the 'non directional' lighting model arent friends? try using phong instead.
                            if not, update your video cards' drivers. if not... I don't know.

                            btw I have no idea why you're multiplying by 10 and then by 0.3. you're wasting nodes there when multiplying by 3 would do the same.

                            about technical literature/guides I don't know any, all I've know has been by reading here and there I'm sorry. it comes down to trying to get the most out of using less resources (textures, texture size, polygons, material instructions, etc), but some things just are a certain way and you probably won't find out until someone tells you (like the 'not use a lot of translucency thing')

                            Comment


                              #15
                              Bingo, 'use lit translucency depth pass' did the trick! Was after all a checkbox I didnt us. They still dont throw noticeable shadows, but meh, moving on.

                              Thanks a lot for all the help, it gave me good insight in the materials. Thou for now I will stick with opacity mask and get back to the schooldesk to learn about basics!

                              Comment

                              Working...
                              X