浏览代码

HDRenderPipeline: Attempt to do somerthing with velocity pass

/main
Sebastien Lagarde 8 年前
当前提交
e32ad29b
共有 3 个文件被更改,包括 81 次插入45 次删除
  1. 30
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitAttributesVarying.hlsl
  2. 86
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
  3. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl

30
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitAttributesVarying.hlsl


#ifdef ATTRIBUTES_WANT_COLOR
float4 color : COLOR;
#endif
#ifdef VARYING_WANT_PASS_SPECIFIC
AttributesPass attributesPass;
#endif
// UNITY_INSTANCE_ID
};

#endif
#ifdef VARYING_WANT_COLOR
float4 color;
#endif
#ifdef VARYING_WANT_PASS_SPECIFIC
VaryingsPass varyingPass;
#endif
};

// Allocate only necessary space if shader compiler in the future are able to automatically pack
#ifdef VARYING_WANT_TEXCOORD1
float4 interpolators4 : TEXCOORD3;
float4 interpolators4 : TEXCOORD4;
float2 interpolators4 : TEXCOORD3;
float2 interpolators4 : TEXCOORD4;
float4 interpolators5 : TEXCOORD4;
float4 interpolators5 : TEXCOORD5;
float2 interpolators5 : TEXCOORD4;
float2 interpolators5 : TEXCOORD5;
#endif
#ifdef VARYING_WANT_PASS_SPECIFIC
PackedVaryingsPass packedVaryingsPass;
#endif
#if defined(VARYING_WANT_CULLFACE) && SHADER_STAGE_FRAGMENT

output.interpolators6 = input.color;
#endif
#ifdef VARYING_WANT_PASS_SPECIFIC
output.packedVaryingsPass = PackVaryingsPass(input.varyingPass);
#endif
return output;
}

output.color = input.interpolators6;
#endif
#ifdef VARYING_WANT_PASS_SPECIFIC
output.varyingPass = UnpackVaryingsPass(input.packedVaryingsPass);
#endif
#if defined(VARYING_WANT_CULLFACE) && SHADER_STAGE_FRAGMENT
output.isFrontFace = IS_FRONT_VFACE(input.cullFace, true, false);
#endif

#if defined(VARYING_WANT_COLOR) || defined(ATTRIBUTES_WANT_COLOR)
float4 VARYING_DS_WANT_COLOR;
#endif
#endif // TESSELLATION_ON
// Varying for domain shader
// Position and normal are always present (for tessellation) and in world space

86
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl


// TODO: For now disable per pixel and per vertex displacement mapping with motion vector
// as vertex normal is not available + force UV0 for alpha test (not compatible with layered system...)
#define VARYING_WANT_POSITION_WS
#define VARYING_WANT_PASS_SPECIFIC
struct Attributes
#if defined(_ALPHATEST_ON)
#define ATTRIBUTES_WANT_UV0
#ifdef LAYERED_LIT_SHADER
#define ATTRIBUTES_WANT_UV1
#if defined(_REQUIRE_UV2) || defined(_REQUIRE_UV3)
#define ATTRIBUTES_WANT_UV2
#endif
#if defined(_REQUIRE_UV3)
#define ATTRIBUTES_WANT_UV3
#endif
#endif
#endif
#if defined(_ALPHATEST_ON)
#define VARYING_WANT_TEXCOORD0
#ifdef LAYERED_LIT_SHADER
#define VARYING_WANT_TEXCOORD1
#if defined(_REQUIRE_UV2) || defined(_REQUIRE_UV3)
#define VARYING_WANT_TEXCOORD2
#endif
#if defined(_REQUIRE_UV3)
#define VARYING_WANT_TEXCOORD3
#endif
#endif
#endif
// Available semantic start from TEXCOORD4
struct AttributesPass
float3 positionOS : POSITION;
float2 uv0 : TEXCOORD0;
struct Varyings
struct VaryingsPass
float4 positionCS;
float3 positionWS;
float2 texCoord0;
struct PackedVaryings
// Available interpolator start from TEXCOORD8
struct PackedVaryingsPass
float4 positionCS : SV_Position;
#if NEED_TANGENT_TO_WORLD
float4 interpolators[5] : TEXCOORD0;
#elif NEED_TEXCOORD0
float4 interpolators[3] : TEXCOORD0;
#else
float4 interpolators[3] : TEXCOORD0;
#endif
// Note: Z component is not use
float3 interpolators0 : TEXCOORD8
float3 interpolators1 : TEXCOORD9;
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions
PackedVaryings PackVaryings(Varyings input)
PackedVaryingsPass PackVaryingsPass(VaryingsPass input)
PackedVaryings output;
output.positionCS = input.positionCS;
output.interpolators[0] = float4(input.positionWS, 0.0);
output.interpolators[1] = float4(input.transferPositionCS.xyw, 0.0);
output.interpolators[2] = float4(input.transferPreviousPositionCS.xyw, 0.0);
PackedVaryingsPass output;
output.interpolators0 = float3(input.transferPositionCS.xyw);
output.interpolators1 = float3(input.transferPreviousPositionCS.xyw);
}
#if NEED_TANGENT_TO_WORLD
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1].w = input.texCoord0.y;
output.interpolators[3].xyz = input.tangentToWorld[0];
output.interpolators[4].xyz = input.tangentToWorld[1];
VaryingsPass UnpackVaryingsPass(PackedVaryingsPass input)
{
PackedVaryingsPass output;
output.interpolators0 = float3(input.transferPositionCS.xyw);
output.interpolators1 = float3(input.transferPreviousPositionCS.xyw);
}
output.interpolators[2].w = input.tangentToWorld[2].x;
output.interpolators[3].w = input.tangentToWorld[2].y;
output.interpolators[4].w = input.tangentToWorld[2].z;
#elif NEED_TEXCOORD0
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1].w = input.texCoord0.y;
#endif
return output;
}
FragInputs UnpackVaryings(PackedVaryings input)
{

10
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl


#error SHADERPASS_is_not_correctly_define
#endif
#if SHADER_STAGE_VERTEX
#endif
#if SHADER_STAGE_FRAGMENT
float4 Frag(PackedVaryings packedInput) : SV_Target
{
FragInputs input = UnpackVaryings(packedInput);

return outBuffer;
}
#endif
正在加载...
取消
保存