Home Unreal Engine

Need help with UDK hatching material

polycounter lvl 10
Offline / Send Message
Pangahas polycounter lvl 10
Hi So I'm playing around with the UDK material editor to come up with a hatching shader. Here is what I ended up with.
screenshot1.jpg
I increased the UV tiling to make it easier to see the first one has the hatching texture multiplied on the shadowed areas while the second one only has the hatching effect on the parts where light hits.

Here is how it is setup.I'm kind of new to this so I'm not entirely sure if I'm doing it right.

screenshot2.jpg
screenshot3.jpg

For the hatch texture I quickly made one in Photoshop deleted the white parts and saved it as png. when I imported it I did not check the options encircled thinking it would make the texture transparent on those part I deleted.But apparently when I applied it, it is still not transparent(circled part on screenshot 1)

So my question is how do I make the alpha for that texture?what am I doing wrong?What node do I need to add?

One more thing I can't seem to figure it out but I want my hatching texture to not appear on parts that are lighted but only on the shadowed areas..Number 2 basically but in reverse. Would Anyone with more experience with UDK materials kindly help me with this? I would be using this for a scene I'm planning to make.

Replies

  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    I'm a little confused as to what you're asking for with the pictures, so for now, I'll assume you want your image to have the traditional hatch and sketch effect? Like this:

    [ame="http://www.youtube.com/watch?v=TUwY4D5cl6o&feature=related"]Hatching Shader - Non Photorealistic Rendering - YouTube[/ame]

    The Alpha issue is showing up because your Alpha is an Alpha being treated like a texture. It's not being fed into any masking options. You already have your Lerp node's Alpha occupied with the Light Vector node.

    What your currently have is a 'masked diffuse' in terms of color information, what you're asking (from what I understood) was a localized Alpha masking from the Light Vector? In which case, switch out the Light and your texture nodes.

    Hmm, I'm not sure about the shadow masking part, you might need a custom solution. However, did you try inverting your light vector? Will that change anything? Careful however, since pending on what type of tangents you exported with can cause issues as UDK could show up the seams if you invert you light vector.

    Secondly, I think it really depends on the style you're aiming for. I personally would have created two different hatch effects and put them up via a Screen Position node, so that when the camera moves, the hatch effect doesn't seem frozen on the surface.

    If you could post up some references as to what style exactly you're going for, I'm sure peeps will have a better solution.
  • Pangahas
    Options
    Offline / Send Message
    Pangahas polycounter lvl 10
    Thanks for the reply angel I have only started tinkering with UDK material editor so there is really a lot that I don't quite understand yet.

    As for the style and the effect yes your correct I want it to look like the traditional hatch and sketch effect like the video you posted except that I only want the hatching to appear on the shadowed areas multiplied to the diffuse texture.

    The pencil sketch texture for this I did post process in photoshop but this is basically the style I'am aiming for.

    wip5copy.jpg
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    hmm, well the shadow casting in UDK is done somewhat outside of the object shader level.

    If you want hatching JUST where the shadows are what you'll want to do is:

    use the full light vector, not just the blue component. multiply this by -1. Take the dot product of that inverted light vector and your object's normal map if it has one, if not use 0,0,1.

    Use a Constant Clamp node to the output of that dot product. Plug this into the alpha slot of a lerp node.

    Plug your scaled hatching texture into the B slot of the lerp, and a 3 vector set to 1,1,1 for the A slot.

    Multiply the output of the lerp by your diffuse texture and plug that into the diffuse slot.

    Note that this will only account for form shadows of the object. It will not place the hatching in self shadowed areas, or in areas which have shadows cast on them, as the method by which those shadows are calculated occurs outside the object shader level.

    IF you need hatching across a certain brightness level of your whole scene, a post process material may be a better way to go, though the hatching won't line up with the object's form. It would just be projected in screen space.
  • Pangahas
    Options
    Offline / Send Message
    Pangahas polycounter lvl 10
    I tried that and this is the result that I got.I might be missing something here the hatch won't appear any idea why?

    Untitled-2-2.jpg
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    bah.. well aside from UDK not handling nodes like I expect the shadow algorithms aren't working so well for a texture based effect either.

    Could make this work a bit better for you.

    Just do a light and normal dot product, put that into the alpha, and swap the a and B nodes on the lerp.
    Its not likely going to be perfect, but its what I can figure out at the moment.
  • Pangahas
    Options
    Offline / Send Message
    Pangahas polycounter lvl 10
    I did that as well but the result is similar to my 2nd example wherein the shadowed areas won't have the hatching instead its the part where light hits that is affected so I tried adding a 1-x node and suprisingly it seems to work the shadowed parts have darker hatching while the hatching is lighter on the other side.I would have wanted it to have no hatching on those light areas but this is as close as I get to what I want.
    Thanks a ton to you guys now I can finally work on the scene.
    here's the result:
    Untitled-1-2.jpgUntitled-3-1.jpg
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    to get light modulated hatching you might want to look at this shader I made:

    5177430382_f929a65484.jpg
    halftoneShader_07112010 by sprunghunt, on Flickr

    Also to do the outlines it's probably easier to do it using a post process using the depth buffer to find the edges.

    here's a thread with a shader network for generating outlines:

    http://eat3d.com/forum/dvd-reviews/oniram-udk-lighting-and-post-processing-review
  • Pangahas
    Options
    Offline / Send Message
    Pangahas polycounter lvl 10
    Hey thanks I remember seeing that somewhere glad you posted it here I was googling the wrong keyword its halftone shader indeed.
    I'm new to this material node thing so would this allow me to multiply the tone effect on my diffuse?Can it be done simply by plugging it in the diffuse node? or does it have to be somewhere between your node setup?
Sign In or Register to comment.