- Home /
Add decal parameter to shader
I have a nice car paint shader, but it doesnt have a decal parameter. How would I go about adding a decal parameter?
Answer by MaT227 · Jan 26, 2015 at 04:25 PM
You need to add a new texture parameter and in you shader add a blending between your decal texture and your regular car texture using the decal alpha channel.
It could be hard if you don't have any shader programming experience. I suggest you to post some code sample so we might be able to help you.
Thanks, yeah I don't have any shader program$$anonymous$$g experience, but here's the shader:
//Hard Surface Shader Package, Written for the Unity engine by Bruno Rime: http://www.behance.net/brunorime brunorime@gmail.com Shader "HardSurface/Hardsurface Free/Opaque Specular"{ Properties { _Color ("$$anonymous$$ain Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (1, 1, 1, 1) _Shininess ("Shininess", Range (0.01, 3)) = 1.5 _Gloss("Gloss", Range (0.00, 1)) = .5 _Reflection("Reflection", Range (0.00, 1)) = 0.5 _Cube ("Reflection Cubemap", Cube) = "Black" { TexGen CubeReflect } _FrezPow("Fresnel Reflection",Range(0,2)) = .25 _FrezFalloff("Fresnal/EdgeAlpha Falloff",Range(0,10)) = 4 EdgeAlpha("Edge Alpha",Range(0,1)) = 0 $$anonymous$$etalics("$$anonymous$$etalics",Range(0,1)) = .5
_$$anonymous$$ainTex ("Diffuse(RGB) Alpha(A)",2D) = "White" {}
_Bump$$anonymous$$ap ("Normalmap", 2D) = "Bump" {}
_Spec_Gloss_Reflec_$$anonymous$$asks ("Spec(R) Gloss(G) Reflec(B)",2D) = "White" {}
}
SubShader {
Tags {"Queue"="Geometry" "RenderType"="Opaque" "IgnoreProjector"="False" }
UsePass "Hidden/Hardsurface Pro Front Opaque Specular/FORWARD"
}
Fallback "Diffuse"
}
Ok, this is a shader from the Hard Surface Shader Package which is a great package :) but it's going to be hard as it is separated in multiple pass and files and I don't think that you have the right to publish those files. I suggest you to write to the author of the package, he might be able to help you. You should also format your post.
Thanks, sorry bout the formatting. I'll try to contact him.
According to the code you posted, you need to find the file Hidden/Hardsurface Pro Front Opaque Specular/FORWARD then your need to find the albedo variable then you could use the alpha channel of your decal function to blend between the default albedo and the decal texture. Unfortunately, without the source code it's hard to tell where to do this blending.
Yes, exactly. I have found the pass its using, unfortunately is 18 thousand lines long :(
What you can do is test every variable of the function by returning each one by one and look at the output in your scene view. Once you've found the good one, you can blend between this variable and the decal texture using the decal alpha channel like this:
lerp(variable.rgb, decal.rgb, decal.a);
Or use any blending technic. Don't forget to convert you decal sampler2D into a RGBA variable using the tex2D function.
Thanks. I've aready gone through a lot of the code but with no luck. I will investigate further, so I appreciate your advice. However I'm also looking into using a projector for this.