- Home /
Question by
Eco-Editor · Nov 25, 2019 at 12:40 PM ·
shadersurfaceenvironmentgradientambient light
Why the shader responds differently to Tri-color ambient light vs. Skybox lighting?
Hello all,
In my scene I have a shoreline and a quad that adds foam effect to a sea.
Please see pictures:
Skybox Environment Lighting (only Skybox), this is the expected outcome With Gradient (tri-color) environment lighting - you can see the quad has a blueish tint
Why does this happen?
This is the shader code (taken from this github page):
// Crest Ocean System
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE)
// Draw cached depths into current frame ocean depth data
Shader "Crest/Inputs/Depth/Cached Depths"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
// Min blending to take the min of all depths. Similar in spirit to zbuffer'd visibility when viewing from top down.
// To confuse matters further, ocean depth is now more like 'sea floor altitude' - a height above a deep water value,
// so values are increasing in Y and we need to take the MAX of all depths.
BlendOp Min
CGPROGRAM
#pragma vertex Vert
#pragma fragment Frag
//#pragma surface surfaceFunction lightModel noambient
#include "../../OceanLODData.hlsl"
sampler2D _MainTex;
float4 _MainTex_ST;
#include "UnityCG.cginc"
struct Attributes
{
float3 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 position : SV_POSITION;
float2 uv : TEXCOORD0;
};
Varyings Vert(Attributes input)
{
Varyings output;
output.position = UnityObjectToClipPos(input.positionOS);
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
return output;
}
half4 Frag(Varyings input) : SV_Target
{
return half4(tex2D(_MainTex, input.uv).x, 0.0, 0.0, 0.0);
}
ENDCG
}
}
}
Thank you
[3]: https://forum.unity.com/threads/ignore-ambient-in-a-surface-shader.64664/
[4]: https://docs.unity3d.com/2018.4/Documentation/Manual/SL-SurfaceShaders.html
quadwithfoam-skybox.png
(159.3 kB)
quadwithfoam-gradient.png
(98.3 kB)
Comment