浏览代码

HDRenderloop: lot of missing file...

/main
Sebastien Lagarde 8 年前
当前提交
4e046798
共有 4 个文件被更改,包括 22 次插入21 次删除
  1. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Deferred.shader
  2. 27
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader
  3. 1
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitShare.hlsl
  4. 6
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Deferred.shader


// Chose supported lighting architecture in case of deferred rendering
#pragma multi_compile LIGHTLOOP_SINGLE_PASS
#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
//-------------------------------------------------------------------------------------
// Include

struct Varyings
{
float4 positionHS : SV_POSITION;
float4 positionCS : SV_POSITION;
};
Varyings VertDeferred(Attributes input)

Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
return output;
}

Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw);
float4 unPositionSS = input.positionCS; // as input we have the vpos
Coordinate coord = GetCoordinate(unPositionSS.xy, _ScreenSize.zw);
// No need to manage inverse depth, this is handled by the projection matrix
float depth = _CameraDepthTexture.Load(uint3(coord.unPositionSS, 0)).x;

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


{
switch (paramId)
{
case DEBUGVIEW_VARYING_DEPTH:
// TODO: provide a customize parameter (like a slider)
float linearDepth = frac(LinearEyeDepth(input.positionHS.z, _ZBufferParams) * 0.1);
result = linearDepth.xxx;
break;
case DEBUGVIEW_VARYING_TEXCOORD0:
result = float3(input.texCoord0 * 0.5 + 0.5, 0.0);
break;

struct Varyings
{
float4 positionHS;
float4 positionCS;
float2 texCoord0;
float2 texCoord1;
};

float4 positionHS : SV_Position;
float4 positionCS : SV_Position;
float4 interpolators[1] : TEXCOORD0;
};

PackedVaryings output;
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
output.interpolators[0].xy = input.texCoord0;
output.interpolators[0].zw = input.texCoord1;

FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.positionHS = input.positionHS;
output.unPositionSS = input.positionCS;
output.texCoord0 = input.interpolators[0].xy;
output.texCoord1 = input.interpolators[0].zw;

}
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
output.texCoord0 = input.uv0;
output.texCoord1 = input.uv1;

struct Varyings
{
float4 positionHS;
float4 positionCS;
#if NEED_TEXCOORD0
float2 texCoord0;
#endif

struct PackedVaryings
{
float4 positionHS : SV_Position;
float4 positionCS : SV_Position;
#if NEED_TANGENT_TO_WORLD
float4 interpolators[4] : TEXCOORD0;
#elif NEED_TEXCOORD0

PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
#if NEED_TANGENT_TO_WORLD
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[1].xyz = input.tangentToWorld[0];

FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.positionHS = input.positionHS;
output.unPositionSS = input.positionCS;
#if NEED_TANGENT_TO_WORLD
output.positionWS.xyz = input.interpolators[0].xyz;

Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
#if NEED_TEXCOORD0
output.texCoord0 = input.uv0;

// TEMP until pragma work in include
// #include "../../Lighting/Forward.hlsl"
#pragma multi_compile LIGHTLOOP_SINGLE_PASS
#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
#include "../../Lighting/Lighting.hlsl"
#include "LitData.hlsl"

1
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitShare.hlsl


FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.unPositionSS = input.positionCS;
output.positionWS.xyz = input.interpolators[0].xyz;
output.tangentToWorld[0] = input.interpolators[1].xyz;
output.tangentToWorld[1] = input.interpolators[2].xyz;

6
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


// This function is use to provide an easy way to sample into a screen texture, either from a pixel or a compute shaders.
// This allow to easily share code.
// If a compute shader call this function unPositionSS is an integer usually calculate like: uint2 unPositionSS = groupId.xy * BLOCK_SIZE + groupThreadId.xy
// TODO: How to detect automatically that we are a compute shader ?
coord.positionSS = unPositionSS;
#if SHADER_STAGE_COMPUTE
// In case of compute shader an extra half offset is added to the screenPos to shift the integer position to pixel center.
coord.positionSS.xy += float2(0.5, 0.5);

coord.unPositionSS = int2(unPositionSS);
return coord;
}

// For information. In Unity Depth is always in range 0..1 (even on OpenGL) but can be reversed.
float3 UnprojectToWorld(float depth, float2 screenPos, float4x4 invViewProjectionMatrix)
{
float4 positionCS = float4(screenPos.xy * 2.0 - 1.0, depth, 1.0);
float4 hpositionWS = mul(invViewProjectionMatrix, positionCS);
return hpositionWS.xyz / hpositionWS.w;
}

正在加载...
取消
保存