User Tag List

Results 1 to 26 of 26

Thread: Sprite model? How did they do this?

  1. #1
    0
    Patron
    Join Date
    Mar 2014
    Posts
    56

    Sprite model? How did they do this?

    Just had a quick look around in CoD Ghosts to see how they made their foliage. When I came across their barbed wire (Which I had some issues with earlier). I walked up to it to see how they'd made it, and it looked like they had actually modeled the wire and the razor. But upon closer inspection i could see that the razor part was constantly facing me at all times, sprite behavior. How do you make a 3D model have a sprite texture? I've never heard of that before lol.

    http://s26.postimg.org/7r3pxou3b/2014_04_21_00008.jpg

    http://s26.postimg.org/xldingu3b/2014_04_21_00009.jpg

  2. #2
    0
    Cross planes with a texture?
    VFX Artist
    Portfolio: Here

  3. #3
    0
    Are you sure the razor parts are facing you from every angle? Because it doesn't make sense to have that effect for this kind of wire. To me it looks like masked material on a spiral plane, and normal map is helping with that "3d" illusion.

  4. #4
    0
    Probably did what I did with some ReBar recently, modelled a small section of it in high-poly, then baked that to a normal map to use on a very low-poly model. In this case it just looks like one plane to me.

    Failing that, grab the PC version of the game and check their editor!

  5. #5
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    Could be using a technique similar to the spline thicken material function. That material function projects a mesh width wise across the chosen tangent space vector. It has not been used too much yet but it is very powerful.

    Just make 2d poly strips with UVs 0to1 on the desired width axis, and make the geometry very thin. It also outputs normals for lighting but the current version that's checked in has some lighting errors. The next ue4 build, (sadly not the immediate next one) will have those fixes. I will try to post more info in a bit.
    Last edited by RyanB; 04-21-2014 at 10:35 AM.

  6. #6
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    93
    You could use a billboard material. I have a tutorial here if you want to go that route!

  7. #7
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    You wouldn't use that kind of camera facing sprite for this though, it needs to maintain the spiral form of the base mesh. What you want is the "SplineThicken" material function. It is similar to a billboard in that it is camerafacing, but only along the specified tangent vector. That means you can model pipes or tree branches or wires as single quads and they look correct from all angles except when the view is perfectly parallel with the tangent vector (ie, looking at a cylinder or pipe directly from the top).

    Here is what that looks like. Wireframe of '2d' poly strips aligned to face the camera:
    Name:  01.jpg
Views: 1962
Size:  74.8 KB

    What this fake geometry looks like with normals calculated:
    Name:  02.jpg
Views: 1977
Size:  71.4 KB

    This is the model in 3dsmax. The polys are scaled down to be practically invisible on purpose, because we want to project outwards from the center of the virtual 'pipe'. We could have some thickness and then counteract it in the shader (which you sometimes *need* to do in order to have better lighting calculations built), but that will cost some extra vertex shader instructions and in most cases is not necessary. For example barb wire shadows will probably be too thin to care about.
    Name:  3dsmaxwireframe.jpg
Views: 1959
Size:  28.0 KB

    The UV's go from 0-1 on X for all the polys, and the entire length of the mesh goes 0-1 on Y. The Y component allows you to blend between different base and tip thickness (kind of like the cone primitive in 3dsmax). The material function also allows you to flip the tangent basis so it is the other way around.
    Note that in the current engine version, the normals will be slightly wacky for these, but they will be close. 4.2 should have the better normals.
    Last edited by RyanB; 04-21-2014 at 02:10 PM.

  8. #8
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    Quote Originally Posted by Jacky View Post
    Are you sure the razor parts are facing you from every angle? Because it doesn't make sense to have that effect for this kind of wire. To me it looks like masked material on a spiral plane, and normal map is helping with that "3d" illusion.
    I agree it may not make sense, but this effect may still have been implemented to reduce the artifact of aliasing. Sometimes you can even do things like increase the thickness slightly with distance to decrease aliasing etc.

  9. #9
    0
    Quote Originally Posted by RyanB View Post
    I agree it may not make sense, but this effect may still have been implemented to reduce the artifact of aliasing. Sometimes you can even do things like increase the thickness slightly with distance to decrease aliasing etc.
    Good to know. Thanks for the tip Ryan!

  10. #10
    0
    Could you show us how the connections are made? The documentation is very vague and I tried using it in the material editor but the results were so weird.

  11. #11
    0
    Quote Originally Posted by macoywen View Post
    Could you show us how the connections are made? The documentation is very vague and I tried using it in the material editor but the results were so weird.
    Seconded!
    That'd be lovely, thank you!

  12. #12
    0
    Quote Originally Posted by RyanB View Post
    see above
    Hi Ryan,

    Is there any chance you can ellaborate on how to use the SplineThicken node? I mean just on a super basic level? So far i've just tried popping in randomness in the input pins, WidthBase, WidthTip both to ie. 100 just to see what they did. WorldPosition, do i need to feed in the Camera Position there? UV's for Projection and Thickness, what do i plug in there?

    I made a thin plane and been experimenting with rotating my UV's 90 degrees in 3dsmax to see what results i get, and either way i get weird results. I can post a super short video showing what i experience.

    Name:  Question to setup of SplineThicken.png
Views: 1403
Size:  186.3 KB
    Last edited by Jonas_Molgaard; 09-21-2016 at 05:04 PM.

  13. #13
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    Sure thing. I just wrote up a more detailed doc for a contractor so I have all the images. This probably has more info than you need.

    The basic idea behind spline thicken is that it is like a camera facing sprite that follows a path. The "path" is basically just a pre made row of thin hair like polygons. The vertex shader then extends these polygons in a direction that is always perpendicular to the camera direction so the mesh always appears to be of the same thickness when viewed from any direction.Here is a quick example I made using 3dsmax.

    First I draw a line with a bent pipe shape. Then go to settings for the line and check both "enable in renderer" and "enable in viewport" and "Generate Mapping Coords". Set sides to 4 since unfortunately that is the minimum and set angle to 45 so we can more easily delete the extra faces.

    Name:  SplineThicken_01.JPG
Views: 1407
Size:  45.2 KB

    Next convert to editable poly and select and delete all but one strip of faces (this step is only necessary when using the line tool and can usually be removed from modelling workflow by other means)

    Name:  SplineThicken_02.JPG
Views: 1397
Size:  28.0 KB

    The simplest method is to make the polys very thin, but you can also leave them at a specified thickness and then de-project in the material in UE4 in order to get better static lighting support but that shouldn't be necessary for this project:

    Name:  SplineThicken_03.JPG
Views: 1398
Size:  16.6 KB

    Finally you want to give each polygon 0-1 UVs by adding an UnwrapUVW modifier and stretching the UVs horizontally to fit 0-1. You can also adjust the Y to be uniform or just adjust it in the material later.

    Name:  SplineThicken_04.JPG
Views: 1400
Size:  61.3 KB

    In addition to checking 2-sided also make sure to uncheck "tangent space normal" on the material (the need for 2 sided is just a bug, I believe tangent direction flipped since this function was made. you can also use negative width params but that will flip the normals):

    Name:  SplineThicken_05.JPG
Views: 1386
Size:  28.9 KB

    For the material, if you are using the default projection along tangent U, you shouldn't have to do anything besides this:

    Name:  SplineThicken_06.JPG
Views: 1396
Size:  38.4 KB

    If you set it up right, it should match actual geometry almost perfectly, when the viewing angle is not parallel with the spline which causes artifacts:



    You can do tons of cool things with spline thicken. Here is a prototype stony coral I made using a really quick crappy material:



    This smaller one shows the wireframe:



    And yes, all of this has been passed on to the docs team but I am not sure when they can get to adding it.

    Re: your specific questions in the images:

    The "Expand U or V" option allows you to expand the spline either along the UV.X or the UV.Y channel. The example above uses the X channel and I suggest sticking to that and leaving it alone.

    WorldPosition input is only for very specific effects, such as when you want to apply other offsets to the spline before thickening. 99% of cases don't need to hook anything to WorldPosition input. Certainly don't put cameraposition there.

    The "Width Base" and tip are how wide it projects the verts from the spline in world units. It will use the opposite of the proection axis in the UVs to blend between the two values. So for the default option where it projects using U (UV.x), it will use UV.Y to fade between width base and tip.
    Last edited by RyanB; 09-21-2016 at 05:33 PM.
    Ryan Brucks
    Principal Technical Artist, Epic Games

  14. #14
    0
    Absolutely awsome man! This was excactly what i needed :-) Thanks a bunch for all that lovely tech info too on how it works. Makes it easier to go back and read if something doesnt work.

  15. #15
    0
    That is truly amazing, I'm gonna go play!

  16. #16
    0
    Champion
    Join Date
    Mar 2014
    Posts
    601
    Thanks for this thread and thanks for the answer all ! Very useful i think

  17. #17
    0
    Quote Originally Posted by RyanB View Post
    See above
    I just got home from work and sat down and set material to 2-sided and then it worked lol. So that was the reason i ended up with tons of wires going in, in the hopes that i would get a good result. Also one thing i realize just now, is that it was a materialfunction and i could have double clicked it to see how it worked or atleast get an idea about it.

    So one thing though which is now puzzeling me, is how the heck do you manage to control the thickness of your strips? I mean for building this kind of stuff, i need to be able to control it. I tried with a material parameter for base and end widths, but i would need one dynamic material instance pr. segment then , and change the parameter value to achieve this?

    Name:  Question to setup of SplineThicken2.png
Views: 1337
Size:  850.0 KB

    And btw, yes i was very much inspired by your Paragon POM/Produral vines stream when i made this :-)

  18. #18
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    As before, you use the UV.Y coordinate. So if a vertex has a uv.y of 0, it should use BaseWidth. If it has a UV value of 1, it should use BaseTip. You can apply a curve by putting a power on UVs and plugging that into 'UVs for Thickness'.

    If you want one of the sub branches to be less thick than the parent, you would need to make its base verts start above 0 in the UV.y layout.

    This isn't always that flexible, so for my procedural branching blueprint I did some custom stuff and also modified with using vertex colors which let each segment be any size but even that has some issues as there are only 256 available vertex color values. That means if you apple a unique vertex color to the start and end of each segment, some of them may eventually stair step. for that reason I tend to use a combination of the UV control with the vertex colors of modification.
    Ryan Brucks
    Principal Technical Artist, Epic Games

  19. #19
    0
    Ok i see... but since i deal with small strips of 8x1 plane segments, which are replicated layed out along the path of the spline as splinemeshes, they will all individually have the same uv space, so to become thinnner towards the end, doesnt that mean i need to somehow read it's position along the spline and normalize that into a uv.y value? Or am i misunderstanding this?

  20. #20
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    If you are actually instancing them then yes. If you are making it by hand in 3ds max you can just stitch them together to form a line so they dont all have the same UVs.

    I ended up doing a slightly different solution when using my procedural branching blueprint. basically I encode segment length along the whole tree into one of the vertex colors. Then it uses that information to offset the UVs of each segment so that the UV tiling can be changed to be whatever and still be seamless between pieces. And then I also encoded the branch with directly into another vertex color. Have you tried using the blueprint node "paint vertices lerp along axis"? It is perfect for this kind of thing.

    You can also do stuff like use the overall object height gradient and perform slight offsets using the vertex colors. For some things thats all you need. It would at least make sub branches the same branch as the part of the parent that it came from, unless there is more horizontal branching than vertical.
    Last edited by RyanB; 09-22-2016 at 12:40 PM.
    Ryan Brucks
    Principal Technical Artist, Epic Games

  21. #21
    0
    Tbh. im not that advanced with materials yet, so no i haven't tried using "paint verticies lerp along axis", but from the name of it, it sounds like it could very much be usefull in this situation. I will investigate this. That other stuff you write about encoding, im sure i'll understand later, but hopefully someone else can make use of it. In the meantime i tried out a different approach and wanted to hear your oppinion on that. I do realize this will not work with a merged actor, and then i would need to take care of the thickening like you do. But instancing a new material like i do with each Splinemeshcomponent, is that a total no-no?


  22. #22
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    Its not the worst thing in the world from a prototype perspective but I wouldn't go shipping any games like that since it won't be very efficient.

    If all you are doing is making the sub branches start a bit thinner, you can simply paint a solid color on each segment that represents how far along the parent it was when spawning (you will want to invert it by doing 1-x once its in the 0-1 range). Then you just multiply the width param by that vertex color. Should actually be simpler than making separate MIDs per branch.
    Ryan Brucks
    Principal Technical Artist, Epic Games

  23. #23
    0
    I kinda knew you'd say that hehe. That's why i wanted to convert this to a static mesh without all the generation logic and material logic. So the thing is, i do understand the concept you say about painting a solid color for each segment as a representation for how far along the parent it is, but i just don't know how to do that. And on top of that, my UV's for the strip i use, is the same for the generated merged Static Mesh, so it's not like i get unique UV's for each face after the merge. Did that last part make sense or?

  24. #24
    0
    Unreal Engine Developer
    Join Date
    Apr 2014
    Posts
    1,911
    Yes I had the same problem where each segment has the same UVs.

    To paint the solid color you just do "paint vertices solid color" (name may not be exact but my editor is stuck saving a huge map atm). You would need to know how far the current parent segment is going to get, and then track the local iteration within the branch. Then you just divide the 2nd number by the 1st, do 1-x and use that on the paint node.

    Then you can reference the vertex color node in the materials and use that to multiply the width values. you could also do power etc on the color to make it non linear.
    Ryan Brucks
    Principal Technical Artist, Epic Games

  25. #25
    0
    Ah i see the idea yes. But won't this create some substepping, since im painting with a solid color? (Paint Verticies Single Color) Anyway, im gonna try it out and see how far i can go with this.

    Doh! So using Paint Verticies Lerp Along Axis as you said, allows me to set a start and end color yes, and even the Axis. Think i can work this out
    Last edited by Jonas_Molgaard; 09-22-2016 at 04:40 PM.

  26. #26
    0
    Yay, i got it to work. Thanks again Ryan for all the patience with me. I ended up doing excactly as you said in one of the first posts, to use the "paint vertices lerp along axis". Just had to read a bit up on vertex painting.



    Im gonna talk about this on one of my upcoming videos and share what i have learned today.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •