почему не работает с фреснелем, а без
Синтаксис:
Используется glsl
+fresnel
Синтаксис:
Используется glsl
Shader "Custom/water" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Specular("Specular", Color) = (1,1,1,1)
_BumpMap ("Bumpmap", 2D) = "bump" {}
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
_Cube ("Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
_ReflectStrength( "Reflection Strength" , Range(0,1)) = 0.5
_Fresnel( "Fresnel " , Range(0,5)) = 1.0
}
SubShader {
Tags { "Queue"="Transparent" "RenderType" = "Transparent" }
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _BumpMap;
float4 _Color;
float4 _Specular;
samplerCUBE _Cube;
float4 _ReflectColor;
float _ReflectStrength;
float _Fresnel;
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
float3 viewDir;
float3 worldRefl;
float3 worldNormal;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o)
{
float4 texcol = tex2D(_MainTex, IN.uv_MainTex)*_Color;
float3 bump = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
o.Albedo = texcol.rgb;
o.Normal = bump;
float fresnel = pow(1.0 - saturate ( dot (normalize( IN.viewDir ), o.Normal )), _Fresnel);
float3 worldRefl = WorldReflectionVector (IN, o.Normal);
float4 refl = texCUBE (_Cube,worldRefl);
o.Specular = _Specular.a;
o.Emission = refl.rgb*_ReflectStrength*_ReflectColor.rgb;
o.Alpha = texcol.a * _ReflectColor.a+fresnel;
}
ENDCG
}
FallBack "Transparent/Diffuse"
}
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Specular("Specular", Color) = (1,1,1,1)
_BumpMap ("Bumpmap", 2D) = "bump" {}
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
_Cube ("Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
_ReflectStrength( "Reflection Strength" , Range(0,1)) = 0.5
_Fresnel( "Fresnel " , Range(0,5)) = 1.0
}
SubShader {
Tags { "Queue"="Transparent" "RenderType" = "Transparent" }
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _BumpMap;
float4 _Color;
float4 _Specular;
samplerCUBE _Cube;
float4 _ReflectColor;
float _ReflectStrength;
float _Fresnel;
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
float3 viewDir;
float3 worldRefl;
float3 worldNormal;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o)
{
float4 texcol = tex2D(_MainTex, IN.uv_MainTex)*_Color;
float3 bump = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
o.Albedo = texcol.rgb;
o.Normal = bump;
float fresnel = pow(1.0 - saturate ( dot (normalize( IN.viewDir ), o.Normal )), _Fresnel);
float3 worldRefl = WorldReflectionVector (IN, o.Normal);
float4 refl = texCUBE (_Cube,worldRefl);
o.Specular = _Specular.a;
o.Emission = refl.rgb*_ReflectStrength*_ReflectColor.rgb;
o.Alpha = texcol.a * _ReflectColor.a+fresnel;
}
ENDCG
}
FallBack "Transparent/Diffuse"
}