Skip to content

Effect_BackLighting

XiaGu edited this page Apr 17, 2019 · 8 revisions

BackLighting

Back side render of water material.


Mode Artistic:

Artistic

Property Function
Color Color of the surface.
SpecularPow Specular power.
SpecularColor SpecularColor color.
ShadowAttenuation The intensity of the water receive shadow, the smaller the value, the stronger the shadow.
FresnelTexture Fresnel intensity map, use only alpha channel.
FresneIntensity Fresnel intensity.
FresnelColor Fresnel color.

Methods(HLSL)

half3 GetOceanBackArtisticLighting(half3 worldNormal, half3 worldViewDir, half3 lightDirection, half3 lightColor, float shadowAtten)
{
    half3 diffuse = max(0, dot(worldNormal, lightDirection)) * lightColor;
    half3 ambient = saturate(ShadeSH9(half4(worldNormal, 1.0)));
    half3 specular = pow(max(0, dot(lightDirection, -worldViewDir)), SpecularPow) * SpecularColor * lightColor;

    half fresnel = tex2D(FresnelTexture, half4(max(0, dot(worldViewDir, -worldNormal)), 0.5, 0, 0)).a;
    fresnel = saturate(fresnel * FresneIntensity);
    diffuse = lerp(diffuse, FresneColor, fresnel);

    half3 color = Color;
    color.rgb *= diffuse + ambient;
    color.rgb += specular;
    color.rgb *= saturate(shadowAtten + ShadowAttenuation);
}

Image

Disable under water fog:

BackLighting_Artistic_1

Enable under water fog:

BackLighting_Artistic_2

Clone this wiki locally