I discovered a unit shador with a customized lighting methodology that approaches the impact of subsoil dispersion. I attempted to make use of it in deferred and unlucky manner of illustration doesn’t work. From what I’ve learn on the Web, I suppose that I want to exchange the inner convention shador with mine and write my very own BRDF and lighting perform and modify Gbuffer’s contents, and so forth. Is that this the right method? Or is there a greater manner?
Right here is the shador code simply in case.
Shader "Customized/TranslucentMaterial"
{
Properties
{
_Color ("Colour", Colour) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MetallicGlossMap ("Metallic gloss (R, A)", 2D) = "white" {}
_Metallic ("Metallic", Vary(0,1)) = 0.0
_Smoothness ("Smoothness", Vary(0,1)) = 0.5
_BumpMap ("Regular map", 2D) = "bump" {}
_BumpScale ("Bump Scale", Float) = 1.0
_LocalThickness ("Native Thickness", 2D) = "grey" {}
_Distortion ("Materials Gentle Distortion", Vary(0, 1)) = 0.1
_Power ("Energy", Float) = 1.0
_Scale ("Scale", Vary(1.0, 100.0)) = 1.0
_Attenuation ("Attenuation", Vary(0.0, 1.0)) = 1.0
_Ambient ("Ambient Gentle", Vary(0.0, 100.0)) = 0.5
}
SubShader
{
Tags { "Queue"="Geometry" "RenderType"="Opaque" }
LOD 200
ZWrite On
CGPROGRAM
// Bodily based mostly Normal lighting mannequin, and allow shadows on all mild varieties
#pragma floor surf StandardTranslucent fullforwardshadows deferred
// Use shader mannequin 3.0 goal, to get nicer trying lighting
#pragma goal 3.0
sampler2D _MainTex;
sampler2D _MetallicGlossMap;
sampler2D _BumpMap;
sampler2D _LocalThickness;
struct Enter
{
float2 uv_MainTex;
};
fixed4 _Color;
half _Metallic;
half _Smoothness;
fastened _BumpScale;
float _Distortion;
float _Power;
float _Scale;
float thickness;
float _Attenuation;
float _Ambient;
#embrace "UnityPBSLighting.cginc"
inline half4 LightingStandardTranslucent(SurfaceOutputStandard s, fixed3 viewDirection, UnityGI gi) {
half4 standardPBR = LightingStandard(s, viewDirection, gi);
/**************************TRANSLUCENT LIGHTING PART*******************************/
//
// Gentle Path
float3 L = gi.mild.dir;
// View Path
float3 V = viewDirection;
// Regular of the present Vertex
float3 N = s.Regular;
// Half manner vector
float3 H = normalize(L + N * _Distortion);
// Depth of the backlight
float I = pow(saturate(dot(V, -H)), _Power) * _Scale;
I = _Attenuation * (I + _Ambient) * thickness;
standardPBR.rgb = standardPBR.rgb + gi.mild.colour * I;
standardPBR.a = 1.0f;
return standardPBR;
}
void LightingStandardTranslucent_GI(SurfaceOutputStandard s, UnityGIInput information, inout UnityGI gi)
{
LightingStandard_GI(s, information, gi);
}
void surf (Enter IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by colour
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
fixed4 mg = tex2D(_MetallicGlossMap, IN.uv_MainTex);
fixed3 nml = UnpackScaleNormal(tex2D(_BumpMap, IN.uv_MainTex), _BumpScale);
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = mg.r * _Metallic;
o.Smoothness = mg.a * _Smoothness;
o.Regular = nml;
o.Alpha = 1.0f;
float thick = tex2D(_LocalThickness, IN.uv_MainTex).r;
thickness = thick;
}
ENDCG
}
FallBack "Diffuse"
}