Rasagar/Assets/Visual Design Cafe/Nature Shaders/Common/Translucency.templatex

40 lines
1.1 KiB
Plaintext
Raw Normal View History

{% comment %}
// Copyright 2020 Visual Design Cafe. All rights reserved.
// This shader was created using ShaderX, a shader framework by Visual Design Cafe.
// https://www.visualdesigncafe.com/shaderx
// Package: Nature Shaders
// Website: https://www.visualdesigncafe.com/nature-shaders
// Documentation: https://support.visualdesigncafe.com/hc/categories/900000043503
{% endcomment %}
struct TranslucencyInput
{
float Scale;
float NormalDistortion;
float Scattering;
float Thickness;
float Ambient;
half3 Color;
float Shadow;
};
half3 Translucency(
TranslucencyInput input,
float3 bakedGI,
float3 surfaceAlbedo,
float3 surfaceNormal,
float3 viewDirectionWS,
Light light )
{
half3 lightDir = light.direction + surfaceNormal * input.NormalDistortion;
half transVdotL =
pow( saturate( dot( viewDirectionWS, -lightDir ) ), input.Scattering ) * input.Scale;
half3 translucency =
(transVdotL + bakedGI * input.Ambient)
* (1-input.Thickness)
* lerp(1, light.shadowAttenuation, input.Shadow)
* light.distanceAttenuation;
return half3( surfaceAlbedo * light.color * translucency * input.Color );
}