Announcement

Collapse
No announcement yet.

"Camera-aligned triangle strips" :)

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

    "Camera-aligned triangle strips" :)

    ... Or, at least, that what it says in the Samaritan Demo tech presentation...

    So I'm replicating the effect, got the network set up, but it doesn't seem to be aligning anything to the camera (I won't post images until it works unless specifically requested, since, well, I'll only be posting an image of a plain old plane. Wow. Not exciting or helpful to anyone).

    So I know the issue is basically the VectorTransform node. What I can't figure out is what the input and output should be set to. I'm guessing "Local" in and "View" out, based on what the effect is supposed to do, but, well, it ain't doing it.

    Any tips? Cheers!

    #2
    OK, I guess I do need pictures then

    Here's the network as presented in the GDC Tech Presentation of the Samaritan Demo:



    And here's my network with the problem highlighted:



    (Yes, I know I have the TexCoord and Constant nodes swapped, but it's going into an add, so it won't make a difference to the result)

    From what I know of the HLSL underlying this, the VectorTransform node is simply converting the 3Vector to a WorldSpace Normal, so that Up is always Up; however, none of the 12 possible combinations of VectorTransform seem to provide this functionality.

    Any help? Cheers!

    Comment


      #3
      [EDIT 8/2/2011: OK, ignore this: Got over-enthusiastic and misread it. DarthViper is right; it isn't what I thought it was! Embarrassment all round! ]
      Weirdly, this implementation works just as well (if not better), and uses lighter code.

      Comment


        #4
        But does that work on faces inside an object? Or is that based on many copies of the same plane with a pivot point set on each

        Comment


          #5
          The 3Dality one is for planes... It's a per-object rather than per-vertex shader.
          Actually, almost all billboard code is for planes. Objects with depth tend to squish oddly if you try it. Can you help with the first example? The second one works okay, but I'd like to understand where I was going wrong with the first...

          Comment


            #6
            Oops, sorry, just re-read your reply.

            I think you may be right on the object based nature of the effect.

            Hmmm, it works for hair, but not perfectly; I guess I'll have to work out the first shader for sure.

            Comment


              #7
              OK, pretty sure I got it now: it's Tangent to World, but the other parts of the network basically reduce the effect so it's not so noticeable (the Width parameter reduces it by a lot, of course) so that the hair doesn't screw up and turn completely to face the camera full face-on.

              It doesn't work well with anything other than the short-type hair seen in the demo, of course, but I'm looking at other methods for that...

              Comment


                #8
                DifferenceEngine3D,

                I struggled also to get the Smaritan method to work for camera facing polys, finally with success. I use it now for all types of camera facing objects from grass to foliage sheets in trees. The polys themselves need to be very thin for it to work correctly. The key to understanding it is the TexCoord. The way they use it in Samaritan, is that if the TexCoord of a vertex is 0, in other words it is to the left of the texture, then the vertex is moved to the left of the camera. If the TexCoord is 1, it is to the right of the texture and the vertex is moved to the right of the camera. The method used in the samaritan have the polys rotating on one axis to face the camera. This works very well for bushes and grass. You can made some additions to the node network to get it working in 3d so that polys will also rotate up and down to face the camera. I use that for tree foliage.

                It is a very efficient method of implementing camera facing.

                Comment


                  #9
                  Could someone explain this to a guy that doesn't understand the material editor?

                  Comment


                    #10
                    @Caeru: Thanks for the input! I know HLSL, but the vagaries of the UDK Material Editor are only just now starting to come into focus for me! Could you just confirm the Vector Transform Node settings for me, to make sure that I understand them correctly? Is it "Tangent" Input and "World" Output? Thanks!

                    @Blade [UG]: I don't mean anything by this, but do you not understand the material editor? By the amount and nature of the posts you make, I confess I'm surprised, but fair enough. I honestly don't mean any offense by this, I swear! My main interest so far (in the few months I've been working with the UDK) has been the material editor alone, so I understand that we all focus on that which makes most difference to us. For example, I don't understand much if anything of UnrealScript.

                    Basically, You subtract the World Position of the object from the world position of the camera to get a "screen space normalized" vector (basically the angle between the screen and the object. The 3Vector (green square) obtains the "up" vector of the strip (Z-Axis). These are then crossed and normalized to create a vector matrix that the renderer can use to determine the position of a vertex.

                    The second block below the first is the "test" that informs the renderer where the vertex lies so that it knows which direction, and by how much, to move the vertex in view-space.

                    Hope this helps!

                    And thanks again for the help, guys; looking forward to confirming my suspicions about the vector transform! (Mad fishing expedition here!)

                    Comment


                      #11
                      @DifferenceEngine3D

                      The Vector Transform Node settings are ok.
                      You should also play with the value of width param. In your screen you have it at 0.1 which means that vertices will at maximum be stretched by 0.05 to the left and 0.05 to the right of the screen. If the polys your are applying this to are of a width similar to this you will not see much difference and no camera facing effect.
                      In fact the real width of the polys should be very small, compared to the width parameter you use. The other thing you need to think about is the texcoords of the vertices.
                      If you have the lefthand verts close to the left of the texture space and the right hand verts close to the right the texture space, then you will have a larger multiplier for the width parameter. I use a similar network for foliage polys in my trees and the multiplier is 200, which means that the foliage polys always have a camera facing width of 200 unreal units.
                      I hope that helps

                      Comment


                        #12
                        Thanks for that, Caeru! Yeah, I figured the effect was way too subtle for it to be very visible; I was copying the Tech Demo settings in the first place, which are tweaked for the guy's hair, so of course the effect will be teenytiny.

                        Again, in the Samaritan demo, all the polys were built with the verts essentially on top of one another, so a tiny "opening" effect would be noticeable in close up, but only in reference to the original strip. For hair, of course, you'd want a really subtle effect so that there was no noticeable "turning" for the hair as the figure moves past the camera!

                        Thanks again for your help; the transform was bugging me

                        Comment


                          #13
                          Just to be clear about the vector transform node.
                          The source should be tangent and the destination should be world. This is what works for me.

                          Comment


                            #14
                            @Caeru: you' re a life-saver! Thanks for your help. If only there was a reputation or thank button on this forum, I'd press it a few times!

                            Comment


                              #15
                              Originally posted by Caeru View Post
                              You can made some additions to the node network to get it working in 3d so that polys will also rotate up and down to face the camera. I use that for tree foliage.

                              It is a very efficient method of implementing camera facing.
                              In order to get this working on a 3d model like a simple billboard tree but with a few extra polys to pick up some shading, what would the network changes be that you mention above?
                              I have your material network working on a quad obj nicely but it's not behaving once some vertices are added to the model.



                              I know this a very old thread but hopefully you guys are still around.

                              Comment

                              Working...
                              X