Home Unity

[Unity Shadergraph] Why are some of my grass cards totally black

Duckmamoll
node
Hello,

I've been trying to make a grass shader using my own assets, in unity. I've been able to make the asset and shader work perfectly in unreal. But inside Unity for some reason some of the grass cards are totally black. I tried removing everything from the shader, and set a simple albedo, and it's still black. I don't think the issue comes from the shader; But why is it happening?

Thank you for reading :)

Replies

  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Those are back faces. Flip the normal on the back faces (in the shader). Not sure about Unity, but in Unreal, there is a node called 2 sided sign. It returns 1 for front faces and -1 for back faces. And there you can use this node to detect and flip the normals on back faces. This would simulate that you have actual double sided geo (actually using double geo would also fix this, but simply flipping the normals in the shader is better because then you don't need extra geo)

    Its happening because a plane has vertex normals only for one of its side. And lighting uses the vertex normals to calculate the shading. Since the normal of those planes are facing the opposite direction relative to the light direction, they get dark.
  • Duckmamoll
    Options
    Offline / Send Message
    Duckmamoll node
    Oh I see, when I followed the tutorial on unreal I noticed he used a two sidded sign, I had no idea what it did. I will look into it in unity, thank you :D.
    But I am not sure it's the issue cause I did check earlier, and some planes are green on both sides, and the other are black on both sides, there isn't one that's black on one side and green on the other
  • Duckmamoll
    Options
    Offline / Send Message
    Duckmamoll node
    Yeah, no. As you can see in my screenshot the two sided is already ticked. I tried getting the model that brackey's uses in hist tutorial and it has the same issue, Idk what I'm missing
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Simply ticking 2 sided won't do anything. It will just display the back faces.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    If there is no 2 sided sign node, you can do this:

    vec3(0,0,1) * normalize(dot(camera vector, vertex normal));

    This is what the 2 sided sign node does except the vec3. I just multiplied tangent space flat normal there. Plug this into the normal input of the shader. This will make both front and back faces to be shaded the same and should remove the blackness.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    I think in Unitys shadergraph, the vertex normal node is called "normal direction" but I'm not sure. Then the camera vector is probably camera direction...
  • Duckmamoll
    Options
    Offline / Send Message
    Duckmamoll node

    It gives this interesting results, now the black cards seems to be dynamic based on where I look from
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Set the normal vector node to world space.
  • Duckmamoll
    Options
    Offline / Send Message
    Duckmamoll node
    I tried that already, and it didn't work either :'(

  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    I just noticed that you are the same guy as who couldn't reproduce my example with displacement a few days ago. I tried this out before I posted the screenshot so I'm pretty sure it works and I'm affraid you don't have much idea about what you are doing. Based on the last thread and this one. So again, sorry, but I can't help more. 

    Last idea:
    There is some space mismatch between the nodes. The normal input of the material should be tangent space, and the camera vector and normal vector should be world space.

    Also, next time please post in the dedicated Unity subforum here. There is one for that, and your displacement thread was moved there by admins. Save them some time, post Unity things there.

  • Duckmamoll
    Options
    Offline / Send Message
    Duckmamoll node
    Sorry I had no idea there's a unity forum. And yeah I'm a beginner especially at shader. Still I'm posting screenshot to prove that i'm doing exactly what I think you're telling me to do. You don't have to be a dick and say "you don't have much idea about what you are doing", I'd have no point in lying, I know how to try stuff, change numbers, orders of nodes etc to try things. If this sh*t doesn't work in unity there's not much I can do

    Also if you think I couldn't replicate your displacement but couldn't see anything wrong in any of my screenshot, posted with all the details of everything I did. Don't go and blame me for my incapacity of reproducing it
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    I just meant that its so much harder to help (for anybody) if you don't know much about vector math. Sorry if it sounded like an insult. It wasn't intended to be that. 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Ok I checked out the official documentation and that camera node is not what you need. It says its  "The Camera's forward vector direction". This will give you one direction instead of direction on all pixels. I think I also found the proper node and its called "view direction". Make sure to set it to world space.

    https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Camera-Node.html
    https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/View-Direction-Node.html

    If this still doesn't work, I'm not sure whats going on.
  • Duckmamoll
    Options
    Offline / Send Message
    Duckmamoll node
    I took it badly too, but it did sound mean. I have 0 knowledge of any kind of vector math, so my knowledge is limited to "normal" is the blue picture that makes  fake 3d.

     And I have no idea how to make your last suggestion work as the camera vector has no world space so I just tried all different camera output dot producted with world space normal vector. And nothing change

    I thank you a lot again for trying to help me. I'm almost sure there's a basic setting somewhere that's obvious to a veteran and that would fix most problem but I have no idea
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Have you tried the view direction node from my last post?
  • Duckmamoll
    Options
    Offline / Send Message
    Duckmamoll node
    I just did, I tried with both set as world, both set as object, then with one set as object and the other as world, then vice versa, I changed the vector 3 in every tries too.
    The one weird thing with this set-up, is that If I look at it on a specific side, everything looks normal, but on the backside everything is broken
    OH WAIT NEVERMIND NOW IT WORKS, the dark side is the shadows now, not some weird normal bug, MANY THANKS DUDE
    (also I did try to find this view direction node, but as I had no idea what to google for, I didn't find it, thank you for finding it :D )
Sign In or Register to comment.