浏览代码

wip fix lens flare, geom coord is ok, occlusion is not

/main
etienne cella 5 年前
当前提交
eb22eaf3
共有 4 个文件被更改,包括 14 次插入5 次删除
  1. 2
      Assets/Scripts/LensFlare/Shader/LensFlareHDRPAdditive.shader
  2. 11
      Assets/Scripts/LensFlare/Shader/LensFlareHDRPCommon.hlsl
  3. 2
      Assets/Scripts/LensFlare/Shader/LensFlareHDRPLerp.shader
  4. 4
      Assets/Scripts/LensFlare/Shader/LensFlareHDRPPremultiplied.shader

2
Assets/Scripts/LensFlare/Shader/LensFlareHDRPAdditive.shader


#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "LensFlareHDRPCommon.hlsl"
#pragma multi_compile __ USING_GLOBAL_SCREEN_SPACE
float4 frag (v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv);

11
Assets/Scripts/LensFlare/Shader/LensFlareHDRPCommon.hlsl


#include "Packages\com.unity.render-pipelines.high-definition\Runtime\ShaderLibrary\GlobalScreenSpace.hlsl"
struct appdata
{
float4 vertex : POSITION;

float4 extent = TransformWorldToHClip(GetCameraRelativePositionWS(v.worldPosRadius.xyz + cameraUp * v.worldPosRadius.w));
float2 screenPos = clip.xy / clip.w;
float2 screenPosLocal = clip.xy / clip.w;
float2 screenPos = CLIP_SPACE_GLOBAL(screenPosLocal);
float occlusion = GetOcclusion(screenPos, depth - v.worldPosRadius.w, radius, ratio);
float occlusion = GetOcclusion(screenPosLocal, depth - v.worldPosRadius.w, radius, ratio);
// Distance Fade
float4 d = v.lensflare_fadeData;

float2 rayOffset = -screenPos * v.lensflare_data.x;
o.vertex.w = v.vertex.w;
o.vertex.xy = screenPos + local + rayOffset;
o.vertex.xy = CLIP_SPACE_LOCAL(screenPos + local + rayOffset);
o.color = v.color * occlusion * distanceFade * saturate(length(screenPos * 2));
o.color = v.color;// * occlusion * distanceFade * saturate(length(screenPos * 2));
return o;
}

2
Assets/Scripts/LensFlare/Shader/LensFlareHDRPLerp.shader


#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "LensFlareHDRPCommon.hlsl"
#pragma multi_compile __ USING_GLOBAL_SCREEN_SPACE
float4 frag (v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv);

4
Assets/Scripts/LensFlare/Shader/LensFlareHDRPPremultiplied.shader


#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "LensFlareHDRPCommon.hlsl"
#pragma multi_compile __ USING_GLOBAL_SCREEN_SPACE
return col * i.color;
return i.color;
}
ENDHLSL

正在加载...
取消
保存