浏览代码

no need to use .xy to determine z

no need to use .xy to determine lin z
/main
mmikk 8 年前
当前提交
7b51125d
共有 3 个文件被更改,包括 15 次插入12 次删除
  1. 7
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader
  2. 9
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
  3. 11
      Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute

7
Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader


StructuredBuffer<SFiniteLightData> g_vLightData;
float GetLinearDepth(float3 vP)
float GetLinearDepth(float zDptBufSpace) // 0 is near 1 is far
Vec3 var = 1.0;
//float4 v4Pres = mul(float4(vP,1.0), g_mInvScrProjection);
float3 vP = float3(0.0f,0.0f,zDptBufSpace);
float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0));
return v4Pres.z / v4Pres.w;
}

float3 ExecuteReflectionProbes(uint2 pixCoord, const uint offs)
{
float3 v3ScrPos = float3(pixCoord.x+0.5, pixCoord.y+0.5, FetchDepth(_CameraDepthTexture, pixCoord.xy).x);
float linDepth = GetLinearDepth(v3ScrPos);
float linDepth = GetLinearDepth(v3ScrPos.z);
float3 vP = GetViewPosFromLinDepth(v3ScrPos.xy, linDepth);
float3 worldPos = mul(g_mViewToWorld, float4(vP.xyz,1.0)).xyz; //unity_CameraToWorld

9
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


float GetLinearDepth(float3 vP)
float GetLinearDepth(float zDptBufSpace) // 0 is near 1 is far
Vec3 var = 1.0;
//float4 v4Pres = mul(float4(vP,1.0), g_mInvScrProjection);
float3 vP = float3(0.0f,0.0f,zDptBufSpace);
float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0));
return v4Pres.z / v4Pres.w;
}

float3 ExecuteLightList(uint2 pixCoord, const uint offs)
{
float3 v3ScrPos = float3(pixCoord.x+0.5, pixCoord.y+0.5, FetchDepth(_CameraDepthTexture, pixCoord.xy).x);
float linDepth = GetLinearDepth(v3ScrPos);
float linDepth = GetLinearDepth(v3ScrPos.z);
float3 vP = GetViewPosFromLinDepth(v3ScrPos.xy, linDepth);
float3 vWSpaceVDir = normalize(mul((float3x3) g_mViewToWorld, -vP).xyz); //unity_CameraToWorld

11
Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute


groupshared int ldsModelListCount[2]; // since NR_LIGHT_MODELS is 2
float GetLinearDepth(float3 vP)
//float GetLinearDepth(float3 vP)
//{
// float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0));
// return v4Pres.z / v4Pres.w;
//}
float GetLinearDepth(float zDptBufSpace) // 0 is near 1 is far
float3 vP = float3(0.0f,0.0f,zDptBufSpace);
float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0));
return v4Pres.z / v4Pres.w;
}

int idx = t + i*NR_THREADS;
uint2 uCrd = min( uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1) );
float3 v3ScrPos = float3(uCrd.x+0.5, uCrd.y+0.5, FetchDepth(g_depth_tex, uCrd));
vLinDepths[i] = GetLinearDepth(v3ScrPos);
vLinDepths[i] = GetLinearDepth(v3ScrPos.z);
}
uint uLightsFlags[2] = {0,0};

正在加载...
取消
保存