浏览代码

Merge pull request #212 from Unity-Technologies/metal-ios

metal-ios
/fptl_cleanup
GitHub 8 年前
当前提交
cfabde6f
共有 11 个文件被更改,包括 54 次插入24 次删除
  1. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-clustered.compute
  2. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.compute
  3. 16
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/scrbound.compute
  4. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/ComputeGgxIblSampleData.compute
  5. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
  6. 11
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/RuntimeFilterIBL.cs
  7. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  8. 7
      Assets/ScriptableRenderPipeline/ShaderLibrary/ImageBasedLighting.hlsl
  9. 2
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild-clustered.compute
  10. 8
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild.compute
  11. 16
      Assets/ScriptableRenderPipeline/fptl/scrbound.compute

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-clustered.compute


int nrBigTileLights = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+0];
for(int l0=(int) t; l0<(int) nrBigTileLights; l0 += NR_THREADS)
{
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
int l = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.compute


// build coarse list using AABB
#ifdef USE_TWO_PASS_TILED_LIGHTING
int NrBigTilesX = (nrTilesX+3)>>2;
const int bigTileIdx = (tileIDX.y>>2)*NrBigTilesX + (tileIDX.x>>2); // map the idx to 64x64 tiles
const uint log2BigTileToTileRatio = firstbithigh(64) - firstbithigh(16);
int NrBigTilesX = (nrTilesX+((1<<log2BigTileToTileRatio)-1))>>log2BigTileToTileRatio;
const int bigTileIdx = (tileIDX.y>>log2BigTileToTileRatio)*NrBigTilesX + (tileIDX.x>>log2BigTileToTileRatio); // map the idx to 64x64 tiles
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
int l = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

16
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/scrbound.compute


return mul(plane, InvProjection);
}
float4 EvalPlanePair(float2 posXY_in, float r)
float4 EvalPlanePair(out bool validPlanes, float2 posXY_in, float r)
{
// rotate by 90 degrees to avoid potential division by zero
bool bMustFlip = abs(posXY_in.y)<abs(posXY_in.x);

float D = posXY.y * sqrt(fLenSQ - r*r);
float diffSq = fLenSQ - r*r;
float D = posXY.y * sqrt(max(0.0, diffSq));
float4 res;
res.x = (-r*posXY.x - D) / fLenSQ;

// rotate back by 90 degrees
res = bMustFlip ? float4(res.y, -res.x, res.w, -res.z) : res;
validPlanes = diffSq>0.0;
float4 planeX = EvalPlanePair(float2(pos_view_space.x, pos_view_space.z), r);
float4 planeY = EvalPlanePair(float2(pos_view_space.y, pos_view_space.z), r);
bool validX, validY;
float4 planeX = EvalPlanePair(validX, float2(pos_view_space.x, pos_view_space.z), r);
float4 planeY = EvalPlanePair(validY, float2(pos_view_space.y, pos_view_space.z), r);
#if USE_LEFTHAND_CAMERASPACE

bIsMinValid = bool2(planeX.z<0, planeY.z<0);
bIsMaxValid = bool2((-planeX.x)<0, (-planeY.x)<0);
bIsMinValid = bool2(planeX.z<0, planeY.z<0) && bool2(validX,validY);
bIsMaxValid = bool2((-planeX.x)<0, (-planeY.x)<0) && bool2(validX,validY);
// hopefully the compiler takes zeros into account
// should be the case since the transformation in TransformPlaneToPostSpace()

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/ComputeGgxIblSampleData.compute


#include "../../../ShaderLibrary/Common.hlsl"
#include "../../../ShaderLibrary/ImageBasedLighting.hlsl"
#ifdef SHADER_API_MOBILE
#define MAX_IBL_SAMPLE_CNT 34
#else
#endif
RWTexture2D<float4> output; // [MAX_SAMPLE_CNT x UNITY_SPECCUBE_LOD_STEPS]

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/GGXConvolve.shader


TEXTURECUBE(_MainTex);
SAMPLERCUBE(sampler_MainTex);
TEXTURE2D(_GgxIblSamples);
TEXTURE2D_FLOAT(_GgxIblSamples);
#ifdef USE_MIS
TEXTURE2D(_MarginalRowDensities);

11
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/RuntimeFilterIBL.cs


public class IBLFilterGGX
{
RenderTexture m_GgxIblSampleData = null;
const int k_GgxIblMaxSampleCount = 89; // Width
int k_GgxIblMaxSampleCount = TextureCache.isMobileBuildTarget ? 34 : 89; // Width
const int k_GgxIblMipCountMinusOne = 6; // Height (UNITY_SPECCUBE_LOD_STEPS)
ComputeShader m_ComputeGgxIblSampleDataCS = null;

Material m_GgxConvolveMaterial = null; // Convolves a cubemap with GGX
bool m_SupportMIS = !TextureCache.isMobileBuildTarget;
public bool SupportMIS
{
get { return m_SupportMIS; }
}
public void Initialize(ScriptableRenderContext context)
{
if (!m_ComputeGgxIblSampleDataCS)

}
if (!m_BuildProbabilityTablesCS)
if (!m_BuildProbabilityTablesCS && SupportMIS)
{
m_BuildProbabilityTablesCS = Resources.Load<ComputeShader>("BuildProbabilityTables");
m_ConditionalDensitiesKernel = m_BuildProbabilityTablesCS.FindKernel("ComputeConditionalDensities");

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
if (m_useMIS)
if (m_useMIS && m_iblFilterGgx.SupportMIS)
{
m_iblFilterGgx.FilterCubemapMIS(renderContext, input, target, mipCount, m_SkyboxConditionalCdfRT, m_SkyboxMarginalRowCdfRT, m_CubemapFaceMesh);
}

7
Assets/ScriptableRenderPipeline/ShaderLibrary/ImageBasedLighting.hlsl


{
case 1: sampleCount = 21; break;
case 2: sampleCount = 34; break;
#ifdef SHADER_API_MOBILE
case 3: sampleCount = 34; break;
case 4: sampleCount = 34; break;
case 5: sampleCount = 34; break;
case 6: sampleCount = 34; break; // UNITY_SPECCUBE_LOD_STEPS
#else
#endif
}
return sampleCount;

2
Assets/ScriptableRenderPipeline/fptl/lightlistbuild-clustered.compute


int nrBigTileLights = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+0];
for(int l0=(int) t; l0<(int) nrBigTileLights; l0 += NR_THREADS)
{
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
int l = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

8
Assets/ScriptableRenderPipeline/fptl/lightlistbuild.compute


// build coarse list using AABB
#ifdef USE_TWO_PASS_TILED_LIGHTING
int NrBigTilesX = (nrTilesX+3)>>2;
const int bigTileIdx = (tileIDX.y>>2)*NrBigTilesX + (tileIDX.x>>2); // map the idx to 64x64 tiles
const uint log2BigTileToTileRatio = firstbithigh(64) - firstbithigh(16);
int NrBigTilesX = (nrTilesX+((1<<log2BigTileToTileRatio)-1))>>log2BigTileToTileRatio;
const int bigTileIdx = (tileIDX.y>>log2BigTileToTileRatio)*NrBigTilesX + (tileIDX.x>>log2BigTileToTileRatio); // map the idx to 64x64 tiles
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
int l = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

16
Assets/ScriptableRenderPipeline/fptl/scrbound.compute


return mul(plane, InvProjection);
}
float4 EvalPlanePair(float2 posXY_in, float r)
float4 EvalPlanePair(out bool validPlanes, float2 posXY_in, float r)
{
// rotate by 90 degrees to avoid potential division by zero
bool bMustFlip = abs(posXY_in.y)<abs(posXY_in.x);

float D = posXY.y * sqrt(fLenSQ - r*r);
float diffSq = fLenSQ - r*r;
float D = posXY.y * sqrt(max(0.0, diffSq));
float4 res;
res.x = (-r*posXY.x - D) / fLenSQ;

// rotate back by 90 degrees
res = bMustFlip ? float4(res.y, -res.x, res.w, -res.z) : res;
validPlanes = diffSq>0.0;
float4 planeX = EvalPlanePair(float2(pos_view_space.x, pos_view_space.z), r);
float4 planeY = EvalPlanePair(float2(pos_view_space.y, pos_view_space.z), r);
bool validX, validY;
float4 planeX = EvalPlanePair(validX, float2(pos_view_space.x, pos_view_space.z), r);
float4 planeY = EvalPlanePair(validY, float2(pos_view_space.y, pos_view_space.z), r);
#if USE_LEFTHAND_CAMERASPACE

bIsMinValid = bool2(planeX.z<0, planeY.z<0);
bIsMaxValid = bool2((-planeX.x)<0, (-planeY.x)<0);
bIsMinValid = bool2(planeX.z<0, planeY.z<0) && bool2(validX,validY);
bIsMaxValid = bool2((-planeX.x)<0, (-planeY.x)<0) && bool2(validX,validY);
// hopefully the compiler takes zeros into account
// should be the case since the transformation in TransformPlaneToPostSpace()

正在加载...
取消
保存