- Home /
How to determine shader center?
I'm really confused due to created outline shader. The problem is that i dynamically generate meshes and pivot is outside of a shape. When i increase outline width, my outline moves in the opposite side from pivot. The code is here: https://pastebin.com/TDT6rihr
So my question is, what should I do to create outline when pivot is not within a mesh?
If you want the outline to scale relative to the centre of the object, you should subtract the object's centre position from the vertex position before scaling, then add it back after. I would think that would be automatic in your case, but I guess the object's origin is actually the anchor point, so you would need to pass the position info in to the shader.
Thanks for answer but i change my manner. I found almost completly working solution here: https://willweissman.wordpress.com/tutorials/shaders/unity-shaderlab-object-outlines/
Could you tell my what is the reason of increasingly enlarge outline? Here is the code: https://pastebin.com/aVyejxDb
That method is done in screen space as a post effect; meaning the outline will always be the same number of pixels wide. As your object gets smaller on screen, the outline will stay the same size, meaning it looks larger in comparison with the object.
Your answer
Follow this Question
Related Questions
Outline for ui 0 Answers
Change Z offset of lines 1 Answer
Is it possible for a shader to know the name of the mesh? 0 Answers
Edge outline & 2D shadow Shader for planar mesh 0 Answers
3D outline shader problem in a plane 0 Answers