Point normals towards camera

Node-based Shader Editor

Point normals towards camera

Postby Evocentrica » Sun Jan 20, 2019 7:08 pm

Hello,
I have several single-sided grass meshes that are rendered with culling off.
The problem is that the backfaces render darker, so rotated meshes look "out of place" (too dark). My goal is to have all of the meshes render the same, regardless of their rotation and regardless of the orientation of the camera.
I tried tinkering with the local vertex normal port, which is the one needed for such things i believe, but unfortunately i couldn't manage to find a solution.
It is a Surface shader, with a standard specular light model, cull mode off. I'm moving the vertices for creating a "waving grass" effect, so yeah, the vertices are modified using the local vertex offset port. Pretty standard stuff. Vertex output is set to relative. Cast/Receive shadows make no difference if on or off (of course!). Render path is set to All (though if this could be accomplished by using deferred, that would be great!).

This is how the grass looks like atm:
screen1.jpg
Grass not shaded correctly
screen1.jpg (226.76 KiB) Viewed 2042 times


And this is how i'd like the grass to look like (no matter how camera is oriented, it should always look like the normals are facing the camera!):
screen2.jpg
Grass working ok
screen2.jpg (198.3 KiB) Viewed 2042 times


How can i achieve this?
Thanks a lot for you support, and for the incredible work done on ASE so far!
Andrea
Evocentrica
 
Posts: 3
Joined: Sun Jan 20, 2019 6:51 pm

Re: Point normals towards camera

Postby Amplify_Borba » Tue Jan 22, 2019 12:35 pm

Hello, thank you for your kind words and support, they mean a lot to us!

You might be able to achieve what you desire through the help of the Billboard node, have you had a chance of trying it out?

If it doesn't help solving your situation, please send us a simple sample so that we can look into how you've set up your project and assets and hopefully find a solution that works best for your specific case.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Point normals towards camera

Postby Evocentrica » Thu Jan 24, 2019 8:33 am

Hello,
Thanks for your support!

EDIT:
Unfortunately, once used in the game, it does seem to give any sort of trouble.
Even if i'm not connecting the billboard to the vertex offset port, it's still contributing to the vertex offset somehow (i know this is the expected behaviour for that node). Also, the lighting gets funky in some cases.
I'm attaching a sample of the shader, so you can check it out. I know it's a bit messy, but it's still "in the works" so please forgive me :-)


Why didn't i think of the billboard node in the first place?!
I'm trying the method you suggested and it's kind of working, but i need some further testing before being 100% sure of the result.
BTW, can you point me to how this is done without the billboard node? it's just for my personal knowledge :)
Best,

Andrea
Attachments
XL_Foliage_AMPLIFYSUPPORT.rar
Foliage shader sample
(7.84 KiB) Downloaded 112 times
Evocentrica
 
Posts: 3
Joined: Sun Jan 20, 2019 6:51 pm

Re: Point normals towards camera

Postby Amplify_Borba » Mon Jan 28, 2019 4:20 pm

In order to achieve the exact same result, I'd recommend looking into both the BillboardNode.cs and the BillboardOpHelper.cs scripts, as they contain the necessary math, which involves matrix calculations ( which are a bit beyond my knowledge I'm afraid ).

It's not exactly trivial to set this up via nodes and, although we should provide all the necessary means to do so, it's outside of the scope of our support to perform such conversion. However, should there be any issues with the billboard node or if it doesn't help you achieve the desired effect, please let us know, we'll do our best to help!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Point normals towards camera

Postby Evocentrica » Tue Jan 29, 2019 9:08 am

Thanks Amplify_Borba, indeed this is getting outside of the technical support scope, sorry for this. Didn't think it was going to get so much complicated :)
Cheers,
Andrea
Evocentrica
 
Posts: 3
Joined: Sun Jan 20, 2019 6:51 pm

Re: Point normals towards camera

Postby Amplify_Borba » Tue Jan 29, 2019 9:32 am

No worries, be sure to let us know if you have any feedback or come across any issues, we'll be happy to assist!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests