- Home /
How to make a outline shader with custom attributes
Good Day ! I am making a unity project like Dressing Room. The basic function is to change the fabric of a gameobj ( such as a shoe). So i want to achieve outline effect when the gameobj is selected by player, I have found that modify the source shader to a outline shader work well. But the source shader have normalamp and lightmap properties , the outline shader only have :
Shader "Outlined/Silhouetted Diffuse" {
Properties {
_Color ("Main Color", Color) = (.0,.0,.0,0)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (0.0, 0.03)) = .01
_MainTex ("Base (RGB)", 2D) = "white" { }
}
So when the shader is changed the lightmap and normalmap properties lost at the same time. I have no idea how to add these two properties to the outline shader :
Shader "Outlined/Silhouetted Diffuse" {
Properties {
_Color ("Main Color", Color) = (.0,.0,.0,0)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (0.0, 0.03)) = .01
_MainTex ("Base (RGB)", 2D) = "white" { }
//**********add these two properties ***********
_BumpMap ("Normalmap", 2D) = "bump" {}
_LightMap ("Lightmap (RGB)", 2D) = "black" {}
}
Thanks!
You can't just add _Bump$$anonymous$$ap and _Light$$anonymous$$ap to the properties block of the outline shader - you'll have to add the shader code that actually does something with those properties as well :)
Open up the "source" shader you're using and extract the lines of code that relate to the normal and light map, then paste them into your outline shader (or, if it's easier, do it the other way round).
Or... even easier: create a new shader and use the UsePass command to first run the Pass(s) from the Outline Shader, and then the Pass(s) from the bumped shader.
Your answer
