Page 1 of 1

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

PostPosted: Sun Feb 17, 2019 11:48 pm
by S_Darkwell
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.

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

PostPosted: Tue Feb 19, 2019 3:56 pm
by Amplify_Borba
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.