浏览代码

Changed shader functions per api v4 update

/main
Andre McGrail 6 年前
当前提交
f3d23e02
共有 3 个文件被更改,包括 9 次插入27 次删除
  1. 20
      Assets/Shaders/Graphs/RaceBoats.ShaderGraph
  2. 12
      Packages/com.verasl.water-system/Shaders/WaterCommon.hlsl
  3. 4
      Packages/com.verasl.water-system/Shaders/WaterLighting.hlsl

20
Assets/Shaders/Graphs/RaceBoats.ShaderGraph
文件差异内容过多而无法显示
查看文件

12
Packages/com.verasl.water-system/Shaders/WaterCommon.hlsl


#define WATER_COMMON_INCLUDED
#define _SHADOWS_SOFT
#define _SHADOWS_ENABLED
#define _DIRECTIONAL_SHADOWS
#define SHADOWS_SCREEN 0
#include "LWRP/ShaderLibrary/Core.hlsl"

half fresnelTerm = CalculateFresnelTerm(lerp(IN.normal, half3(0, 1, 0), 0.5), IN.viewDir.xyz);
// Shadows
half shadow = MainLightRealtimeShadowAttenuation(TransformWorldToShadowCoord(IN.posWS));
half shadow = DirectionalLightRealtimeShadow(TransformWorldToShadowCoord(IN.posWS));
Light mainLight = GetMainLight();
half3 ambient = SampleSHPixel(IN.lightmapUVOrVertexSH, IN.normal) * (mainLight.color * mainLight.attenuation) * 0.5;
Light mainLight = GetDirectionalLight();
half3 ambient = SampleSHPixel(IN.lightmapUVOrVertexSH, IN.normal) * (mainLight.color * mainLight.distanceAttenuation) * 0.5;
// Reflections
half3 reflection = SampleReflections(IN.normal, IN.viewDir.xyz, screenUV.xy, fresnelTerm, 0.0);

half depthMulti = 1 / _MaxDepth;
half3 color = (refraction + caustics) * (1 - foam);
color *= Absorption((depth.x - 0.5) * depthMulti);
color += Scattering(depth.x * depthMulti) * ambient * saturate(1-length(reflection));// TODO - scattering from main light(maybe additional lights too depending on cost)
color += Scattering(depth.x * depthMulti) * ambient * (shadow * 0.5 + 0.5) * saturate(1-length(reflection));// TODO - scattering from main light(maybe additional lights too depending on cost)
color *= 1 - foam;
// Foam lighting

float fogFactor = IN.fogFactorAndVertexLight.x;
ApplyFog(comp, fogFactor);
return half4(comp, 1);
//return half4(waterFX.r, 0, 0, 1); // debug line
//return half4(shadow.r, 0, 0, 1); // debug line
}
#endif // WATER_COMMON_INCLUDED

4
Packages/com.verasl.water-system/Shaders/WaterLighting.hlsl


//specular
half3 Highlights(half3 positionWS, half roughness, half3 normalWS, half3 viewDirectionWS)
{
Light mainLight = GetMainLight();
Light mainLight = GetDirectionalLight();
half roughness2 = roughness * roughness;
half3 halfDir = SafeNormalize(mainLight.direction + viewDirectionWS);

specularTerm = specularTerm - HALF_MIN;
specularTerm = clamp(specularTerm, 0.0, 5.0); // Prevent FP16 overflow on mobiles
#endif
return specularTerm * mainLight.color * mainLight.attenuation;
return specularTerm * mainLight.color * mainLight.distanceAttenuation;
}
///////////////////////////////////////////////////////////////////////////////

正在加载...
取消
保存