Howto: Surface Shader for Borders of a World-Space Width?

Your feedback is very important to us. We are listening.

Howto: Surface Shader for Borders of a World-Space Width?

Postby S_Darkwell » Sun Feb 17, 2019 11:48 pm

Hello!

I am attempting to create a surface shader that colors each surface a base color, with a border of a different color of a specified width. For example, with a _BorderWidth of 0.1F, each of a cube's six faces should have a 0.1m perimeter of the border color, with the center of each face being the base color.

I've been able to come close to what I seek, except the width is calculated in object space, no world space. If I scale a cube to be 2.0m on the x axis, the borders on the left and right sides of the top face are also scaled on the x. I've tried for a couple weeks now and have not succeeded in keeping the border width despite both scale and rotation.

If anyone has any tips or suggestions, I will greatly appreciate them. This is actually a task I've attempted on and off for a few years with various shader plugins and code, and I have yet to be successful.

Thank you in advance and be well!
- S.
S_Darkwell
 
Posts: 1
Joined: Sun Feb 17, 2019 11:31 pm

Re: Howto: Surface Shader for Borders of a World-Space Width

Postby Amplify_Borba » Tue Feb 19, 2019 3:56 pm

Hello, thank you for getting in touch and for your support!

I believe that the solution for that is to pass the object's scale values to your shader through scripting, and use them in a formula which will ensure that the borders behave as desired.

We have a few samples that showcase how you can use scripting together with shaders, such as the Smear and the ForceShield.

Please let us know if this helps and if you have any further questions.
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 General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests