浏览代码

HDRenderLoop: Add velocity shader pass

/main
Sebastien Lagarde 8 年前
当前提交
c03433e2
共有 19 个文件被更改,包括 313 次插入117 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset.meta
  2. 57
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  3. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs.hlsl
  4. 31
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.hlsl
  5. 27
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitData.hlsl
  6. 39
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader
  7. 13
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDepthPass.hlsl
  8. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitMetaPass.hlsl
  9. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitSharePass.hlsl
  10. 56
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Material.hlsl
  11. 1
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs
  12. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl
  13. 5
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl
  14. 124
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitVelocityPass.hlsl
  15. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitVelocityPass.hlsl.meta
  16. 18
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassVelocity.hlsl
  17. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassVelocity.hlsl.meta
  18. 13
      Assets/HDRenderLoop.asset
  19. 8
      Assets/HDRenderLoop.asset.meta

2
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset.meta


fileFormatVersion: 2
guid: 2400b74f5ce370c4481e5dc417d03703
timeCreated: 1477406009
timeCreated: 1478740672
licenseType: Pro
NativeFormatImporter:
userData:

57
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


static private int s_CameraColorBuffer;
static private int s_CameraDepthBuffer;
static private int s_VelocityBuffer;
#if VELOCITY_IN_GBUFFER
private const bool m_velocityInGBuffer = true;
#else
private const bool m_velocityInGBuffer = false;
#endif
private bool m_requireVelocityBuffer = false;
static private ComputeBuffer s_punctualLightList;
static private ComputeBuffer s_envLightList;

// Init Lit material buffer - GBuffer and init
m_LitRenderLoop = new Lit.RenderLoop(); // Our object can be garbacge collected, so need to be allocate here
m_BuiltinRenderLoop = new Builtin.RenderLoop();
m_gbufferManager.gbufferCount = m_LitRenderLoop.GetGBufferCount();
for (int gbufferIndex = 0; gbufferIndex < m_gbufferManager.gbufferCount; ++gbufferIndex)
for (int gbufferIndex = 0; gbufferIndex < m_LitRenderLoop.GetGBufferCount(); ++gbufferIndex)
m_gbufferManager.gbufferCount = m_LitRenderLoop.GetGBufferCount();
// In forward we still name the buffer as if they were gbuffer, it doesn't matter
int previousGbufferCount = m_gbufferManager.gbufferCount;
m_gbufferManager.gbufferCount += m_BuiltinRenderLoop.GetGBufferCount();
for (int gbufferIndex = previousGbufferCount; gbufferIndex < m_gbufferManager.gbufferCount; ++gbufferIndex)
// In forward we still name the buffer as if they were gbuffer, it doesn't matter
for (int gbufferIndex = 0; gbufferIndex < m_BuiltinRenderLoop.GetGBufferCount(); ++gbufferIndex)
m_gbufferManager.SetBufferDescription(gbufferIndex, "_CameraGBufferTexture" + gbufferIndex, m_BuiltinRenderLoop.RTFormat[gbufferIndex], m_BuiltinRenderLoop.RTReadWrite[gbufferIndex]);
m_gbufferManager.SetBufferDescription(m_gbufferManager.gbufferCount + gbufferIndex, "_CameraGBufferTexture" + gbufferIndex, m_BuiltinRenderLoop.RTFormat[gbufferIndex], m_BuiltinRenderLoop.RTReadWrite[gbufferIndex]);
m_gbufferManager.gbufferCount += m_BuiltinRenderLoop.GetGBufferCount();
if (m_velocityInGBuffer)
{
int gbufferIndex = m_gbufferManager.gbufferCount;
m_gbufferManager.gbufferCount++;
m_gbufferManager.SetBufferDescription(gbufferIndex, "_VelocityTexture", m_BuiltinRenderLoop.RTFormat[gbufferIndex], m_BuiltinRenderLoop.RTReadWrite[gbufferIndex]);
}
#if VELOCITY_IN_GBUFFER
m_gbufferManager.SetBufferDescription(m_gbufferManager.gbufferCount, "_VelocityTexture", m_BuiltinRenderLoop.GetVelocityBufferFormat(), m_BuiltinRenderLoop.GetVelocityBufferReadWrite());
m_gbufferManager.gbufferCount++;
#endif
m_LitRenderLoop.Rebuild();
m_BuiltinRenderLoop.Rebuild();

int h = camera.pixelHeight;
var cmd = new CommandBuffer { name = "Velocity Pass" };
// If we are not using the velocity buffer inside GBuffer, allocate one
if (m_requireVelocityBuffer)
{
cmd.GetTemporaryRT(s_VelocityBuffer, w, h, 0, FilterMode.Point, m_BuiltinRenderLoop.GetVelocityBufferFormat(), m_BuiltinRenderLoop.GetVelocityBufferReadWrite());
}
cmd.GetTemporaryRT(s_VelocityBuffer, w, h, 0, FilterMode.Point, m_BuiltinRenderLoop.GetVelocityBufferFormat(), m_BuiltinRenderLoop.GetVelocityBufferReadWrite());
// If opaque haven't been render during gbuffer pass, render them now
if (m_requireVelocityBuffer)
{
RenderOpaqueRenderList(cullResults, camera, renderLoop, "MotionVectors");
}
RenderTransparentRenderList(cullResults, camera, renderLoop, "MotionVectors");
RenderOpaqueRenderList(cullResults, camera, renderLoop, "MotionVectors");
}
void FinalPass(RenderLoop renderLoop)

m_LitRenderLoop.RenderInit(renderLoop);
}
// Allocate a velocity buffer if we are forward only or if we haven't set the velocity buffer to be part of GBuffer
m_requireVelocityBuffer = debugParameters.useForwardRenderingOnly || (!debugParameters.useForwardRenderingOnly && !m_velocityInGBuffer);
// Do anything we need to do upon a new frame.
NewFrame();

RenderForward(cullResults, camera, renderLoop);
RenderForwardUnlit(cullResults, camera, renderLoop);
// If opaque velocity have been render during GBuffer no need to render them here
// TODO: What about forward opaque object that will come later, (with stencil bit to avoid double lighting), we need to
// also render their velocity inside the buffer. So It mean that when they are deferred opaque they should render during GBuffer pass
// but when they are forward they should render a second time here in velocity pass... Maybe we should enable MRT during forward pass ?
// TODO: implement MRT velocity buffer as an option in case of forward
RenderVelocity(cullResults, camera, renderLoop);
#if VELOCITY_IN_GBUFFER
if (debugParameters.useForwardRenderingOnly)
#endif
RenderVelocity(cullResults, camera, renderLoop);
FinalPass(renderLoop);
}

5
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs.hlsl


#define DEBUGVIEW_BUILTIN_LIGHTRANSPORTDATA_DIFFUSE_COLOR (120)
#define DEBUGVIEW_BUILTIN_LIGHTRANSPORTDATA_EMISSIVE_COLOR (121)
//
// UnityEngine.Experimental.ScriptableRenderLoop.Builtin.GBufferBuiltin: static fields
//
#define GBUFFERBUILTIN_COUNT (1)
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.Builtin.BuiltinData
// PackingRules = Exact
struct BuiltinData

31
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.hlsl


#include "BuiltinData.cs.hlsl"
//-----------------------------------------------------------------------------
// common Encode/Decode functions
//-----------------------------------------------------------------------------
// Encode/Decode velocity in a buffer (either forward of deferred)
// Design note: We assume that VelocityVector fit into a single buffer (i.e not spread on several buffer)
void EncodeVelocity(float2 velocity, out float4 outBuffer)
{
// RT - 16:16 float
outBuffer = float4(velocity.xy, 0.0, 0.0);
}
float2 DecodeVelocity(float4 inBuffer)
{
return float2(inBuffer.xy);
}
// Encode/Decode into GBuffer - This is share so others material can use it.
// Design note: We assume that BakeDiffuseLighting and emissive fit into a single buffer (i.e not spread on several buffer)
void EncodeBakedDiffuseLigthingIntoGBuffer(float3 bakeDiffuseLighting, out float4 outBuffer)
{
// RT - 11:11:10f
outBuffer = float4(bakeDiffuseLighting.xyz, 0.0);
}
float3 DecodeBakedDiffuseLigthingFromGBuffer(float4 inBuffer)
{
return float3(inBuffer.xyz);
}
void GetBuiltinDataDebug(uint paramId, BuiltinData builtinData, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)

27
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitData.hlsl


struct FragInput
{
float4 unPositionSS; // This is the position return by VPOS, only xy is use
float4 unPositionSS; // This is the position return by VPOS (That is name positionCS in PackedVarying), only xy is use
// For velocity
// Note: Z component is not use
float4 positionCS; // This is the clip spae position. Warning, do not confuse with the value of positionCS in PackedVarying which is VPOS and store in unPositionSS
float4 previousPositionCS;
// For two sided lighting
bool isFrontFace;
};

#endif
}
float2 CalculateVelocity(float4 positionCS, float4 previousPositionCS)
{
// This test on define is required to remove warning of divide by 0 when initializing empty struct
#if SHADERPASS == SHADERPASS_VELOCITY || (SHADERPASS == SHADERPASS_GBUFFER && defined(VELOCITY_IN_GBUFFER))
// Encode velocity
positionCS.xy = positionCS.xy / positionCS.w;
previousPositionCS.xy = previousPositionCS.xy / previousPositionCS.w;
return (positionCS.xy - previousPositionCS.xy) * _ForceNoMotion;
#else
return float2(0.0, 0.0);
#endif
}
#if !defined(LAYERED_LIT_SHADER)
void GetSurfaceAndBuiltinData(FragInput input, out SurfaceData surfaceData, out BuiltinData builtinData)

builtinData.emissiveIntensity = _EmissiveIntensity;
builtinData.velocity = float2(0.0, 0.0);
builtinData.velocity = CalculateVelocity(input.positionCS, input.previousPositionCS);
builtinData.distortion = float2(0.0, 0.0);
builtinData.distortionBlur = 0.0;

PROP_BLEND_SCALAR(emissiveIntensity, weights);
builtinData.emissiveIntensity = emissiveIntensity;
builtinData.velocity = float2(0.0, 0.0);
builtinData.velocity = CalculateVelocity(input.positionCS, input.previousPositionCS);
builtinData.distortion = float2(0.0, 0.0);
builtinData.distortionBlur = 0.0;

39
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader


Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 300
// ------------------------------------------------------------------
// Deferred pass
// ------------------------------------------------------------------
Pass
{
Name "GBuffer" // Name is not used

ENDHLSL
}
// ------------------------------------------------------------------
// Debug pass
// ------------------------------------------------------------------
Pass
{
Name "Debug"

ENDHLSL
}
// ------------------------------------------------------------------
// ------------------------------------------------------------------
Pass
{
Name "META"

ENDHLSL
}
// ------------------------------------------------------------------
// Depth only
// ------------------------------------------------------------------
Pass
{
Name "ShadowCaster"

ENDHLSL
}
// ------------------------------------------------------------------
// forward pass
// ------------------------------------------------------------------
Pass
{
Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
Cull[_CullMode]
ZTest LEqual
ZWrite Off // TODO: Test Z equal here.
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../Material/Material.hlsl"
#include "LitData.hlsl"
#include "LitVelocityPass.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"
ENDHLSL
}
Pass
{
Name "Forward" // Name is not used

13
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDepthPass.hlsl


#error Undefine_SHADERPASS
#endif
#define NEED_TANGENT_TO_WORLD (defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT))
#define NEED_TEXCOORD0 defined(_ALPHATEST_ON) || NEED_TANGENT_TO_WORLD
// Check if Alpha test is enabled. If it is, check if parallax is enabled on this material
#define NEED_TEXCOORD0 defined(_ALPHATEST_ON)
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && !defined(_HEIGHTMAP_AS_DISPLACEMENT))
struct Attributes
{

FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.unPositionSS = input.positionCS;
output.unPositionSS = input.positionCS; // as input we have the vpos
#if NEED_TANGENT_TO_WORLD
output.positionWS.xyz = input.interpolators[0].xyz;

output.positionWS = positionWS;
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w);
output.tangentToWorld[0] = tangentToWorld[0];
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w);
output.tangentToWorld[0] = tangentToWorld[0];
output.tangentToWorld[1] = tangentToWorld[1];
output.tangentToWorld[2] = tangentToWorld[2];
#endif

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitMetaPass.hlsl


FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.unPositionSS = input.positionCS;
output.unPositionSS = input.positionCS; // as input we have the vpos
output.texCoord0 = input.interpolators[0].xy;
output.texCoord1 = input.interpolators[0].zw;

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitSharePass.hlsl


FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.unPositionSS = input.positionCS;
output.unPositionSS = input.positionCS; // as input we have the vpos
output.positionWS.xyz = input.interpolators[0].xyz;
output.tangentToWorld[0] = input.interpolators[1].xyz;
output.tangentToWorld[1] = input.interpolators[2].xyz;

56
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Material.hlsl


#include "EntityLighting.hlsl"
//-----------------------------------------------------------------------------
// common Encode/Decode functions
//-----------------------------------------------------------------------------
// Encode/Decode velocity in a buffer (either forward of deferred)
// Design note: We assume that VelocityVector fit into a single buffer (i.e not spread on several buffer)
void EncodeVelocity(float2 velocity, out float4 outBuffer)
{
// RT - 16:16 float
outBuffer = float4(velocity.xy, 0.0, 0.0);
}
float2 DecodeVelocity(float4 inBuffer)
{
return float2(inBuffer.xy);
}
// Encode/Decode into GBuffer - This is share so others material can use it.
// Design note: We assume that BakeDiffuseLighting and emissive fit into a single buffer (i.e not spread on several buffer)
void EncodeBakedDiffuseLigthingIntoGBuffer(float3 bakeDiffuseLighting, out float4 outBuffer)
{
// RT - 11:11:10f
outBuffer = float4(bakeDiffuseLighting.xyz, 0.0);
}
float3 DecodeBakedDiffuseLigthingFromGBuffer(float4 inBuffer)
{
return float3(inBuffer.xyz);
}
//-----------------------------------------------------------------------------
// BuiltinData
//-----------------------------------------------------------------------------

#ifdef GBUFFERMATERIAL_COUNT
#if GBUFFERMATERIAL_COUNT == 3
#if GBUFFERMATERIAL_COUNT == 2
#define OUTPUT_GBUFFER(NAME) \
out float4 MERGE_NAME(NAME, 0) : SV_Target0, \
out float4 MERGE_NAME(NAME, 1) : SV_Target1
#define DECLARE_GBUFFER_TEXTURE(NAME) \
TEXTURE2D(MERGE_NAME(NAME, 0)); \
TEXTURE2D(MERGE_NAME(NAME, 1));
#define FETCH_GBUFFER(NAME, TEX, UV) \
float4 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), uint3(UV, 0)); \
float4 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), uint3(UV, 0));
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, NAME) EncodeIntoGBuffer(SURFACE_DATA, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2))
#define DECODE_FROM_GBUFFER(NAME) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2))
#define GBUFFER_BAKE_LIGHTING_NAME(NAME) MERGE_NAME(NAME, 2)
#define GBUFFER_BAKE_LIGHTING_TARGET(TARGET) MERGE_NAME(TARGET, 2)
#ifdef VELOCITY_IN_GBUFFER
#define GBUFFER_VELOCITY_NAME(NAME) MERGE_NAME(NAME, 3)
#define GBUFFER_VELOCITY_TARGET(TARGET) MERGE_NAME(TARGET, 3)
#endif
#elif GBUFFERMATERIAL_COUNT == 3
#define OUTPUT_GBUFFER(NAME) \
out float4 MERGE_NAME(NAME, 0) : SV_Target0, \

1
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs


// #define USE_BSDF_PRE_LAMBDAV
// Caution: If you change one of the define below you need to regenerate the hlsl code (Push Generate Shader Includes)
// TODO: Currently it is not yet possible to use this feature, we need to provide previousPositionCS to the vertex shader as part of Attribute for GBuffer pass
//#define VELOCITY_IN_GBUFFER

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl


float3 unity_ProbeVolumeMin;
CBUFFER_END
CBUFFER_START(UnityVelocityPass)
float4x4 _NonJitteredVP;
float4x4 _PreviousVP;
float4x4 _PreviousM;
bool _HasLastPositionData;
bool _ForceNoMotion;
float _MotionVectorDepthBias;
CBUFFER_END
// ----------------------------------------------------------------------------
// TODO: move this to constant buffer by Pass

5
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl


//
// LightDefinitions: static fields
//
#define USE_LEFTHAND_CAMERASPACE (0)
#define USE_LEFTHAND_CAMERASPACE (0)
#define IS_CIRCULAR_SPOT_SHAPE (1)
#define HAS_COOKIE_TEXTURE (2)
#define IS_BOX_PROJECTED (4)

124
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitVelocityPass.hlsl


#ifndef SHADERPASS
#error Undefine_SHADERPASS
#endif
#define NEED_TEXCOORD0 defined(_ALPHATEST_ON)
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && !defined(_HEIGHTMAP_AS_DISPLACEMENT))
struct Attributes
{
float3 positionOS : POSITION;
float3 previousPositionOS : NORMAL; // Contain previous transform position (in case of skinning for example)
#if NEED_TEXCOORD0
float2 uv0 : TEXCOORD0;
#endif
#if NEED_TANGENT_TO_WORLD
float4 tangentOS : TANGENT;
#endif
};
struct Varyings
{
float4 positionCS;
// Note: Z component is not use
float4 transferPositionCS;
float4 transferPreviousPositionCS;
#if NEED_TEXCOORD0
float2 texCoord0;
#endif
#if NEED_TANGENT_TO_WORLD
float3 positionWS;
float3 tangentToWorld[3];
#endif
};
struct PackedVaryings
{
float4 positionCS : SV_Position;
#if NEED_TANGENT_TO_WORLD
float4 interpolators[5] : TEXCOORD0;
#elif NEED_TEXCOORD0
float4 interpolators[2] : TEXCOORD0;
#else
float4 interpolators[2] : TEXCOORD0;
#endif
};
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions
PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionCS = input.positionCS;
output.interpolators[0].xyz = float4(input.transferPositionCS.xyw, 0.0);
output.interpolators[1].xyz = float4(input.transferPreviousPositionCS.xyw, 0.0);
#if NEED_TANGENT_TO_WORLD
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1].w = input.texCoord0.y;
output.interpolators[2].xyz = input.tangentToWorld[0];
output.interpolators[3].xyz = input.tangentToWorld[1];
output.interpolators[4].xyz = input.tangentToWorld[2];
output.interpolators[2].w = input.positionWS.x;
output.interpolators[3].w = input.positionWS.y;
output.interpolators[4].w = input.positionWS.z;
#elif NEED_TEXCOORD0
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1].w = input.texCoord0.y;
#endif
return output;
}
FragInput UnpackVaryings(PackedVaryings input)
{
FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.unPositionSS = input.positionCS; // as input we have the vpos
output.positionCS = float4(input.interpolators[0].xy, 0.0, input.interpolators[0].z);
output.previousPositionCS = float4(input.interpolators[1].xy, 0.0, input.interpolators[1].z);
#if NEED_TANGENT_TO_WORLD
output.texCoord0.xy = float2(input.interpolators[0].w, input.interpolators[1].w);
output.positionWS.xyz = float2(input.interpolators[2].w, input.interpolators[3].w, input.interpolators[4].w);
output.tangentToWorld[0] = input.interpolators[2].xyz;
output.tangentToWorld[1] = input.interpolators[3].xyz;
output.tangentToWorld[2] = input.interpolators[4].xyz;
#elif NEED_TEXCOORD0
output.texCoord0.xy = float2(input.interpolators[0].w, input.interpolators[1].w);
#endif
return output;
}
PackedVaryings Vert(Attributes input)
{
Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionCS = TransformWorldToHClip(positionWS);
// TODO: Clean this code, put in function ?
output.transferPositionCS = mul(_NonJitteredVP, mul(unity_ObjectToWorld, input.positionOS));
output.transferPreviousPositionCS = mul(_PreviousVP, mul(_PreviousM, _HasLastPositionData ? float4(input.previousPositionOS, 1.0) : input.positionOS));
#if NEED_TEXCOORD0
output.texCoord0 = input.uv0;
#endif
#if NEED_TANGENT_TO_WORLD
output.positionWS = positionWS;
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w);
output.tangentToWorld[0] = tangentToWorld[0];
output.tangentToWorld[1] = tangentToWorld[1];
output.tangentToWorld[2] = tangentToWorld[2];
#endif
return PackVaryings(output);
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitVelocityPass.hlsl.meta


fileFormatVersion: 2
guid: e20c8a8a58e51844aad6d4df1dc7d3cd
timeCreated: 1478738809
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

18
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassVelocity.hlsl


#if SHADERPASS != SHADERPASS_VELOCITY
#error SHADERPASS_is_not_correctly_define
#endif
float4 Frag(PackedVaryings packedInput) : SV_Target
{
FragInput input = UnpackVaryings(packedInput);
// Perform alpha testing + get velocity
SurfaceData surfaceData;
BuiltinData builtinData;
GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
float4 outBuffer;
EncodeVelocity(builtinData.velocity, outBuffer);
return outBuffer;
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassVelocity.hlsl.meta


fileFormatVersion: 2
guid: 5f5d2672c7761b44fb3d549f7cea8877
timeCreated: 1478738808
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

13
Assets/HDRenderLoop.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 558064ecdbf6b6742892d699acb39aed, type: 3}
m_Name: HDRenderLoop
m_EditorClassIdentifier:

8
Assets/HDRenderLoop.asset.meta


fileFormatVersion: 2
guid: a760b5cf201f0f5478077e4ee5df8236
timeCreated: 1474961622
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存