Q: How to create the material what highlight selected/raycast objects and how to apply it?
…like in that game Prison Simulator? Actually i know the code block that with raycast and gameObject set/hidefunc but idk how to create materials what highlight objects’s edges.
(check the photos pls)
the absolute easiest method in shader would be a two pass shader where you render the backface in gold and push it out using offset command. i might write a simple unlit one if you’re interested, as i could crank it out in like 5 minutes
ok, here’s what i whipped up, if you want to prevent the outline artifacts that happen when an object is far away you’ll have to do less outlining at a distance, though i assume you’re only outlining things that are close to the player.
This asset is popular and free, which supports a number of additional modes, and handles the material list management for you: https://assetstore.unity.com/packages/tools/particles-effects/quick-outline-115488 Drop a single component on whatever parent object you like, and it does the rest with all the renderers in all children.
firstly, thank you so much for your kind and helper answers. for the first way, idk how to work with shaders. how to apply, how to write and so on… in which language did you write the shaders? also where can i learn them?
also how can i edit this code for to make more thin corners, colors et.
thank you so much again
If you don’t understand that sentence, you should probably start looking at Unity Learn resources to get your way around. Try the Roll-a-Ball tutorial series.
But you literally just add this component to a model. Done. That’s it. (It won’t show up in Scene view, just in Game view while playing.) And if you disable it or remove it, the outline goes away.
i’m not sure if you’re going to use this anymore, as halley’s solution is very simple, but the language is hlsl/shaderlab and to control thickness you would change the values in the offset command (the -10). to change color you change the value returned at the end of the shader, where it says return float4. a float4 represents an rgba color.
this below will answer most basic questions about writing shaders, and it’s how i learned at the beginning. ShaderLab FAQ - Unity Forum