浏览代码

Merge branch 'master' of https://github.com/Unity-Technologies/ScriptableRenderLoop

# Conflicts:

#	Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Material.hlsl
/main
sebastienlagarde 8 年前
当前提交
b8c1da00
共有 27 个文件被更改,包括 963 次插入186 次删除
  1. 24
      Assets/Editor/Tests/ShaderGeneratorTests/ShaderGeneratorTests.cs
  2. 15
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  3. 42
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs
  4. 4
      Assets/ScriptableRenderLoop/common/ShaderBase.h
  5. 8
      Assets/ScriptableRenderLoop/fptl/FinalPass.shader
  6. 72
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  7. 2
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
  8. 37
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs
  9. 34
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl
  10. 2
      Assets/ScriptableRenderLoop/fptl/scrbound.compute
  11. 15
      Assets/ShaderGenerator/CSharpToHLSL.cs
  12. 9
      Assets/Editor/Tests/RenderloopTests.meta
  13. 513
      Assets/Editor/Tests/TestScene.unity
  14. 8
      Assets/Editor/Tests/TestScene.unity.meta
  15. 125
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs.hlsl
  16. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs.hlsl.meta
  17. 9
      Assets/ScriptableRenderLoop/Tests.meta
  18. 43
      Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs
  19. 12
      Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs.meta
  20. 59
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  21. 12
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs.meta
  22. 29
      Assets/ScriptableRenderLoop/Tests/RenderLoopWrapper.cs
  23. 12
      Assets/ScriptableRenderLoop/Tests/RenderLoopWrapper.cs.meta
  24. 42
      Assets/ScriptableRenderLoop/common/ShaderBase.cs
  25. 12
      Assets/ScriptableRenderLoop/common/ShaderBase.cs.meta

24
Assets/Editor/Tests/ShaderGeneratorTests/ShaderGeneratorTests.cs


return foundError;
}
[Test]
public void Fail_NestedWithNonPrimitiveType()
[Test(Description = "Disallow non-primitive types in nested structs")]
public void Fail_NestedWithNonPrimitiveType()
{
string source;
List<string> errors;

Assert.IsTrue(HasErrorString(errors, "contains a non-primitive field type"));
}
[Test]
public void Fail_UnsupportedPrimitiveType()
[Test(Description = "Check for unsupported types in primitive structs")]
public void Fail_UnsupportedPrimitiveType()
{
string source;
List<string> errors;

Assert.IsTrue(HasErrorString(errors, "contains an unsupported field type"));
}
[Test]
[Test(Description = "Disallow mixed types in nested structs")]
public void Fail_MixedTypesInNestedStruct()
{
string source;

Assert.IsTrue(HasErrorString(errors, "contains mixed basic types"));
}
[Test]
public void Fail_TooManyFields()
[Test(Description = "Disallow more than 16 bytes worth of fields in nested structs")]
public void Fail_TooManyFields()
bool success = CSharpToHLSL.GenerateHLSL(typeof(FailureTypes.TooManyFields), new GenerateHLSL(PackingRules.Aggressive), out source, out errors);
bool success = CSharpToHLSL.GenerateHLSL(typeof(FailureTypes.TooManyFields), new GenerateHLSL(PackingRules.Exact), out source, out errors);
[Test]
public void Fail_MergeIncompatibleTypes()
[Test(Description = "Disallow merging incompatible types when doing aggressive packing")]
public void Fail_MergeIncompatibleTypes()
{
string source;
List<string> errors;

Assert.IsTrue(HasErrorString(errors, "incompatible types"));
}
[Test]
public void Fail_MergeCrossBoundary()
[Test(Description = "Disallow placing fields across register boundaries when merging")]
public void Fail_MergeCrossBoundary()
{
string source;
List<string> errors;

15
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


sRGBWrites[index] = inSRGBWrite;
}
public void InitGBuffers(CommandBuffer cmd)
public void InitGBuffers(int width, int height, CommandBuffer cmd)
/* RTs[index] = */ cmd.GetTemporaryRT(IDs[index], -1, -1, 0, FilterMode.Point, formats[index], sRGBWrites[index]);
/* RTs[index] = */ cmd.GetTemporaryRT(IDs[index], width, height, 0, FilterMode.Point, formats[index], sRGBWrites[index]);
}
}

// Also we manage ourself the HDR format, here allocating fp16 directly.
// With scriptable render loop we can allocate temporary RT in a command buffer, they will not be release with ExecuteCommandBuffer
// These temporary surface are release automatically at the end of the scriptable renderloop if not release explicitly
cmd.GetTemporaryRT(s_CameraColorBuffer, -1, -1, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(s_CameraDepthBuffer, -1, -1, 24, FilterMode.Point, RenderTextureFormat.Depth);
gbufferManager.InitGBuffers(cmd);
int w = camera.pixelWidth;
int h = camera.pixelHeight;
cmd.GetTemporaryRT(s_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(s_CameraDepthBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
gbufferManager.InitGBuffers(w, h, cmd);
cmd.SetRenderTarget(new RenderTargetIdentifier(s_CameraColorBuffer), new RenderTargetIdentifier(s_CameraDepthBuffer));
cmd.ClearRenderTarget(true, false, new Color(0, 0, 0, 0));

float lightColorG = light.light.intensity * Mathf.GammaToLinearSpace(light.light.color.g);
float lightColorB = light.light.intensity * Mathf.GammaToLinearSpace(light.light.color.b);
l.color = new Vec3(lightColorR, lightColorG, lightColorB);
l.color.Set(lightColorR, lightColorG, lightColorB);
// Light direction is opposite to the forward direction
l.forward = -light.light.transform.forward;

42
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs


// Note: This file is included both in C# code and in hlsl code, avoiding duplication
using UnityEngine;
#if !__HLSL
#endif
// These structures share between C# and hlsl need to be align on float4, so we pad them.
struct PunctualLightData
// These structures share between C# and hlsl need to be align on float4, so we pad them.
[GenerateHLSL]
public struct PunctualLightData
public Vec3 positionWS;
public Vector3 positionWS;
public Vec3 color;
public Vector3 color;
public Vec3 forward;
public Vector3 forward;
public Vec3 up;
public Vector3 up;
public Vec3 right;
public Vector3 right;
public Vec2 unused2;
public Vector2 unused2;
struct AreaLightData
[GenerateHLSL]
public struct AreaLightData
public Vec3 positionWS;
public Vector3 positionWS;
struct EnvLightData
[GenerateHLSL]
public struct EnvLightData
public Vec3 positionWS;
public Vector3 positionWS;
struct PlanarLightData
[GenerateHLSL]
public struct PlanarLightData
public Vec3 positionWS;
public Vector3 positionWS;
#if !__HLSL
#endif

4
Assets/ScriptableRenderLoop/common/ShaderBase.h


#define public
#define Vec2 float2
#define Vec3 float3
#define Vec4 float4
#define Mat44 float4x4
#define unistruct cbuffer
#define hbool bool

8
Assets/ScriptableRenderLoop/fptl/FinalPass.shader


fixed4 frag (v2f i) : SV_Target
{
float4 c = tex2D(_MainTex, i.texcoord);
#if defined(UNITY_COLORSPACE_GAMMA)
return c;
#else
return float4(pow(c.xyz,1/2.2), c.w);
#endif
return tex2D(_MainTex, i.texcoord);
}
ENDCG

72
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


static private ComputeBuffer m_dirLightList;
// clustered light list specific buffers and data begin
const bool gEnableClustered = false;
const bool gUseDepthBuffer = false;//true; // only has an impact when gEnableClustered is true
public bool EnableClustered = false;
const bool gUseDepthBuffer = true;// // only has an impact when EnableClustered is true (requires a depth-prepass)
const int g_iLog2NumClusters = 6; // accepted range is from 0 to 6. NumClusters is 1<<g_iLog2NumClusters
const float m_clustLogBase = 1.02f; // each slice 2% bigger than the previous
float m_clustScale;

if (m_dirLightList != null)
m_dirLightList.Release();
if(gEnableClustered)
if(EnableClustered)
{
if(m_globalLightListAtomic!=null)
m_globalLightListAtomic.Release();

m_BuildPerTileLightListShader.SetBuffer(kGenListPerTileKernel, "g_vBoundsBuffer", m_aabbBoundsBuffer);
m_BuildPerTileLightListShader.SetBuffer(kGenListPerTileKernel, "g_vLightData", m_lightDataBuffer);
if(gEnableClustered)
if(EnableClustered)
{
kGenListPerVoxelKernel = m_BuildPerVoxelLightListShader.FindKernel(gUseDepthBuffer ? "TileLightListGen_DepthRT" : "TileLightListGen_NoDepthRT");
kClearVoxelAtomicKernel = m_BuildPerVoxelLightListShader.FindKernel("ClearAtomic");

ReleaseResolutionDependentBuffers();
m_dirLightList.Release();
if(gEnableClustered)
if(EnableClustered)
static void SetupGBuffer(CommandBuffer cmd)
static void SetupGBuffer(int width, int height, CommandBuffer cmd)
cmd.GetTemporaryRT(kGBufferAlbedo, -1, -1, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferSpecRough, -1, -1, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferNormal, -1, -1, 0, FilterMode.Point, format10, RenderTextureReadWrite.Linear);
cmd.GetTemporaryRT(kGBufferEmission, -1, -1, 0, FilterMode.Point, format10, RenderTextureReadWrite.Linear); //@TODO: HDR
cmd.GetTemporaryRT(kGBufferZ, -1, -1, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(kCameraDepthTexture, -1, -1, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(kGBufferAlbedo, width, height, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferSpecRough, width, height, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kGBufferNormal, width, height, 0, FilterMode.Point, format10, RenderTextureReadWrite.Linear);
cmd.GetTemporaryRT(kGBufferEmission, width, height, 0, FilterMode.Point, format10, RenderTextureReadWrite.Linear); //@TODO: HDR
cmd.GetTemporaryRT(kGBufferZ, width, height, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(kCameraDepthTexture, width, height, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(kCameraTarget, -1, -1, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
cmd.GetTemporaryRT(kCameraTarget, width, height, 0, FilterMode.Point, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Default);
var colorMRTs = new RenderTargetIdentifier[4] { kGBufferAlbedo, kGBufferSpecRough, kGBufferNormal, kGBufferEmission };
cmd.SetRenderTarget(colorMRTs, new RenderTargetIdentifier(kGBufferZ));

// setup GBuffer for rendering
var cmd = new CommandBuffer();
cmd.name = "Create G-Buffer";
SetupGBuffer(cmd);
SetupGBuffer(camera.pixelWidth, camera.pixelHeight, cmd);
loop.ExecuteCommandBuffer(cmd);
cmd.Dispose();

{
var cmd = new CommandBuffer();
if(gEnableClustered)
if(EnableClustered)
{
cmd.SetGlobalFloat("g_fClustScale", m_clustScale);
cmd.SetGlobalFloat("g_fClustBase", m_clustLogBase);

}
}
m_DeferredMaterial.SetBuffer("g_vLightList", gEnableClustered ? m_perVoxelLightLists : lightList);
//m_DeferredMaterial.SetBuffer("g_vLightList", EnableClustered ? m_perVoxelLightLists : lightList);
m_DeferredMaterial.SetBuffer("g_vLightList", lightList);
m_DeferredReflectionMaterial.SetBuffer("g_vLightList", lightList);
m_DeferredMaterial.SetBuffer("g_vLightData", m_lightDataBuffer);

l.vLaxisY = vy;
l.vLaxisZ = vz;
l.vCol = new Vec3(light.finalColor.r, light.finalColor.g, light.finalColor.b);
l.vCol.Set(light.finalColor.r, light.finalColor.g, light.finalColor.b);
l.fLightIntensity = light.light.intensity;
lights.Add(l);

Vector3 lightPos = lightToWorld.GetColumn(3);
boundData[i].vBoxAxisX = new Vec3(1, 0, 0);
boundData[i].vBoxAxisY = new Vec3(0, 1, 0);
boundData[i].vBoxAxisZ = new Vec3(0, 0, 1);
boundData[i].vScaleXY = new Vec2(1.0f, 1.0f);
boundData[i].vBoxAxisX.Set(1, 0, 0);
boundData[i].vBoxAxisY.Set(0, 1, 0);
boundData[i].vBoxAxisZ.Set(0, 0, 1);
boundData[i].vScaleXY.Set(1.0f, 1.0f);
lightData[i].vCol = new Vec3(cl.finalColor.r, cl.finalColor.g, cl.finalColor.b);
lightData[i].vCol.Set(cl.finalColor.r, cl.finalColor.g, cl.finalColor.b);
lightData[i].iSliceIndex = 0;
lightData[i].uLightModel = (uint)LightDefinitions.DIRECT_LIGHT;
lightData[i].uShadowLightIndex = shadowLightIndex;

float fAltDist = Mathf.Sqrt(fAltDy * fAltDy + (bIsCircularSpot ? 1.0f : 2.0f) * fAltDx * fAltDx);
boundData[i].fRadius = fAltDist > (0.5f * range) ? fAltDist : (0.5f * range); // will always pick fAltDist
boundData[i].vScaleXY = bSqueeze ? new Vec2(0.01f, 0.01f) : new Vec2(1.0f, 1.0f);
boundData[i].vScaleXY = bSqueeze ? new Vector2(0.01f, 0.01f) : new Vector2(1.0f, 1.0f);
// fill up ldata
lightData[i].uLightType = (uint)LightDefinitions.SPOT_LIGHT;

}
boundData[i].vCen = worldToView.MultiplyPoint(lightPos);
boundData[i].vBoxAxisX = new Vec3(range, 0, 0);
boundData[i].vBoxAxisY = new Vec3(0, range, 0);
boundData[i].vBoxAxisZ = new Vec3(0, 0, -range); // transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
boundData[i].vScaleXY = new Vec2(1.0f, 1.0f);
boundData[i].vBoxAxisX.Set(range, 0, 0);
boundData[i].vBoxAxisY.Set(0, range, 0);
boundData[i].vBoxAxisZ.Set(0, 0, -range); // transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
boundData[i].vScaleXY.Set(1.0f, 1.0f);
boundData[i].fRadius = range;
// represents a left hand coordinate system in world space since det(worldToView)<0

if (cl.lightType == LightType.Spot || cl.lightType == LightType.Point)
++i;
}
int numLightsOut = i;
// probe.m_BlendDistance
// Vector3f extents = 0.5*Abs(probe.m_BoxSize);

Texture cubemap = rl.texture;
if (cubemap != null) // always a box for now
{
i = numProbesOut + numLights;
i = numProbesOut + numLightsOut;
lightData[i].flags = 0;

Vector3 delta = combinedExtent - e;
lightData[i].vBoxInnerDist = e;
lightData[i].vBoxInvRange = new Vec3(1.0f / delta.x, 1.0f / delta.y, 1.0f / delta.z);
lightData[i].vBoxInvRange.Set(1.0f / delta.x, 1.0f / delta.y, 1.0f / delta.z);
boundData[i].vScaleXY = new Vec2(1.0f, 1.0f);
boundData[i].vScaleXY.Set(1.0f, 1.0f);
boundData[i].fRadius = combinedExtent.magnitude;
// fill up ldata

m_lightDataBuffer.SetData(lightData);
return numLights + numProbesOut;
return numLightsOut + numProbesOut;
}
/* public override void Render(Camera[] cameras, RenderLoop renderLoop)

cmd.SetComputeBufferParam(m_BuildPerTileLightListShader, kGenListPerTileKernel, "g_vLightList", lightList);
cmd.ComputeDispatch(m_BuildPerTileLightListShader, kGenListPerTileKernel, nrTilesX, nrTilesY, 1);
if(gEnableClustered) VoxelLightListGeneration(cmd, camera, numLights, projscr, invProjscr);
if(EnableClustered) VoxelLightListGeneration(cmd, camera, numLights, projscr, invProjscr);
loop.ExecuteCommandBuffer(cmd);
cmd.Dispose();

if (lightList != null)
lightList.Release();
if(gEnableClustered)
if(EnableClustered)
{
if(m_perVoxelLightLists != null)
m_perVoxelLightLists.Release();

lightList = new ComputeBuffer(LightDefinitions.NR_LIGHT_MODELS * nrDWordsPerTileFPTL * nrTiles, sizeof(uint)); // enough list memory for a 4k x 4k display
if(gEnableClustered)
if(EnableClustered)
{
m_perVoxelOffset = new ComputeBuffer(LightDefinitions.NR_LIGHT_MODELS * (1<<g_iLog2NumClusters) * nrTiles, sizeof(uint));
m_perVoxelLightLists = new ComputeBuffer(NumLightIndicesPerClusteredTile() * nrTiles, sizeof(uint));

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


GetLightCountAndStart(start, numLights, tileIDX, nrTilesX, nrTilesY, linDepth);
float3 c = ExecuteLightList(pixCoord, start, numLights, linDepth);
c = OverlayHeatMap(numLights, c);
//c = OverlayHeatMap(numLights, c);
return float4(c,1.0);
}

37
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs


//#define LEFT_HAND_COORDINATES
using UnityEngine;
[UnityEngine.ScriptableRenderLoop.GenerateHLSL]
public struct SFiniteLightData
{

public uint uLightType;
public uint uLightModel; // DIRECT_LIGHT=0, REFLECTION_LIGHT=1
public Vec3 vLpos;
public Vector3 vLpos;
public Vec3 vLaxisX;
public Vector3 vLaxisX;
public Vec3 vLaxisY;
public Vector3 vLaxisY;
public Vec3 vLaxisZ; // spot +Z axis
public Vector3 vLaxisZ; // spot +Z axis
public Vec3 vCol;
public Vector3 vCol;
public Vec3 vBoxInnerDist;
public Vector3 vBoxInnerDist;
public Vec3 vBoxInvRange;
public Vector3 vBoxInvRange;
public Vec3 vLocalCubeCapturePoint;
public Vector3 vLocalCubeCapturePoint;
public float fProbeBlendDistance;
};

public Vec3 vBoxAxisX;
public Vec3 vBoxAxisY;
public Vec3 vBoxAxisZ;
public Vec3 vCen; // a center in camera space inside the bounding volume of the light source.
public Vec2 vScaleXY;
public Vector3 vBoxAxisX;
public Vector3 vBoxAxisY;
public Vector3 vBoxAxisZ;
public Vector3 vCen; // a center in camera space inside the bounding volume of the light source.
public Vector2 vScaleXY;
public float fRadius;
};

public Vec3 vCol;
public Vector3 vCol;
public Vec3 vLaxisX;
public Vector3 vLaxisX;
public Vec3 vLaxisY;
public Vector3 vLaxisY;
public Vec3 vLaxisZ;
public Vector3 vLaxisZ;
public float fPad1;
};

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


int flags;
uint uLightType;
uint uLightModel;
float3 vLpos; // x: x y: y z: z
float3 vLpos;
float3 vLaxisX; // x: x y: y z: z
float3 vLaxisX;
float3 vLaxisY; // x: x y: y z: z
float3 vLaxisY;
float3 vLaxisZ; // x: x y: y z: z
float3 vLaxisZ;
float3 vCol; // x: x y: y z: z
float3 vCol;
float3 vBoxInnerDist; // x: x y: y z: z
float3 vBoxInnerDist;
float3 vBoxInvRange; // x: x y: y z: z
float3 vBoxInvRange;
float3 vLocalCubeCapturePoint; // x: x y: y z: z
float3 vLocalCubeCapturePoint;
float fProbeBlendDistance;
};

{
float3 vBoxAxisX; // x: x y: y z: z
float3 vBoxAxisY; // x: x y: y z: z
float3 vBoxAxisZ; // x: x y: y z: z
float3 vCen; // x: x y: y z: z
float2 vScaleXY; // x: x y: y
float3 vBoxAxisX;
float3 vBoxAxisY;
float3 vBoxAxisZ;
float3 vCen;
float2 vScaleXY;
float fRadius;
};

{
float3 vCol; // x: x y: y z: z
float3 vCol;
float3 vLaxisX; // x: x y: y z: z
float3 vLaxisX;
float3 vLaxisY; // x: x y: y z: z
float3 vLaxisY;
float3 vLaxisZ; // x: x y: y z: z
float3 vLaxisZ;
float fPad1;
};

2
Assets/ScriptableRenderLoop/fptl/scrbound.compute


res.w = (-r-res.z*posXY.x) / posXY.y;
// rotate back by 90 degrees
res = bMustFlip ? Vec4(res.y, -res.x, res.w, -res.z) : res;
res = bMustFlip ? float4(res.y, -res.x, res.w, -res.z) : res;
return res;
}

15
Assets/ShaderGenerator/CSharpToHLSL.cs


{
using (System.IO.StreamWriter writer = File.CreateText(fileName))
{
writer.WriteLine("//");
writer.WriteLine("// This file was automatically generated from " + it.Key + ". Please don't edit by hand.");
writer.WriteLine("//");
writer.WriteLine();
writer.Write("//\n");
writer.Write("// This file was automatically generated from " + it.Key + ". Please don't edit by hand.\n");
writer.Write("//\n\n");
writer.WriteLine(gen.EmitDefines());
writer.Write(gen.EmitDefines() + "\n");
}
}

{
writer.WriteLine(gen.EmitTypeDecl());
writer.Write(gen.EmitTypeDecl() + "\n");
}
}

{
writer.WriteLine(gen.EmitAccessors());
writer.Write(gen.EmitAccessors() + "\n");
writer.WriteLine();
writer.Write("\n");
}
}
}

9
Assets/Editor/Tests/RenderloopTests.meta


fileFormatVersion: 2
guid: d741d6a8894f49245a784b7cc5c329ca
folderAsset: yes
timeCreated: 1474988761
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

513
Assets/Editor/Tests/TestScene.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.18383996, g: 0.22856951, b: 0.30070874, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 4
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_DirectLightInLightProbes: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_LightingDataAsset: {fileID: 0}
m_RuntimeCPUUsage: 25
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &25849430
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 25849432}
- component: {fileID: 25849431}
m_Layer: 0
m_Name: Point light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &25849431
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 25849430}
m_Enabled: 1
serializedVersion: 7
m_Type: 2
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Intensity: 2.25
m_Range: 3
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &25849432
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 25849430}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 29.13, y: 10.87, z: -12.32}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &253520866
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 253520868}
- component: {fileID: 253520867}
m_Layer: 0
m_Name: Reflection Probe
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!215 &253520867
ReflectionProbe:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 253520866}
m_Enabled: 1
serializedVersion: 2
m_Type: 0
m_Mode: 0
m_RefreshMode: 0
m_TimeSlicingMode: 0
m_Resolution: 128
m_UpdateFrequency: 0
m_BoxSize: {x: 10, y: 10, z: 10}
m_BoxOffset: {x: 0, y: 0, z: 0}
m_NearClip: 0.3
m_FarClip: 1000
m_ShadowDistance: 100
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_IntensityMultiplier: 1
m_BlendDistance: 1
m_HDR: 1
m_BoxProjection: 0
m_RenderDynamicObjects: 0
m_UseOcclusionCulling: 1
m_Importance: 1
m_CustomBakedTexture: {fileID: 0}
--- !u!4 &253520868
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 253520866}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 31.42, y: 10.15, z: -11.86}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1135582007
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1135582009}
- component: {fileID: 1135582008}
m_Layer: 0
m_Name: Directional light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1135582008
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1135582007}
m_Enabled: 1
serializedVersion: 7
m_Type: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 0.31
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1135582009
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1135582007}
m_LocalRotation: {x: 0.2085781, y: -0.20525375, z: 0.157665, w: 0.9431372}
m_LocalPosition: {x: 22.522564, y: 3.5713508, z: -2.9280958}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 27.268002, y: -21.197, z: 13.783001}
--- !u!1 &1376655766
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1376655770}
- component: {fileID: 1376655769}
- component: {fileID: 1376655768}
- component: {fileID: 1376655767}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &1376655767
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1376655766}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!64 &1376655768
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1376655766}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &1376655769
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1376655766}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1376655770
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1376655766}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 29.983482, y: 10.2917185, z: -11.68843}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1575352313
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1575352315}
- component: {fileID: 1575352314}
m_Layer: 0
m_Name: Spotlight
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1575352314
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1575352313}
m_Enabled: 1
serializedVersion: 7
m_Type: 0
m_Color: {r: 0, g: 1, b: 0, a: 1}
m_Intensity: 1.93
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1575352315
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1575352313}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 29.34, y: 15.33, z: -9.55}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &1607679130
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1607679135}
- component: {fileID: 1607679134}
- component: {fileID: 1607679133}
- component: {fileID: 1607679132}
- component: {fileID: 1607679131}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1607679131
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1607679130}
m_Enabled: 1
--- !u!124 &1607679132
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1607679130}
m_Enabled: 1
--- !u!92 &1607679133
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1607679130}
m_Enabled: 1
--- !u!20 &1607679134
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1607679130}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &1607679135
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1607679130}
m_LocalRotation: {x: -0.11764297, y: -0.86998314, z: 0.25099322, w: -0.4077891}
m_LocalPosition: {x: 22.235256, y: 14.497136, z: -7.273508}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

8
Assets/Editor/Tests/TestScene.unity.meta


fileFormatVersion: 2
guid: 132b4d69c613305449cd1bb9476cdee1
timeCreated: 1474995476
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

125
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs. Please don't edit by hand.
//
// Generated from UnityEngine.ScriptableRenderLoop.PunctualLightData
// PackingRules = Exact
struct PunctualLightData
{
float3 positionWS;
float invSqrAttenuationRadius;
float3 color;
float useDistanceAttenuation;
float3 forward;
float diffuseScale;
float3 up;
float specularScale;
float3 right;
float shadowDimmer;
float angleScale;
float angleOffset;
float2 unused2;
};
// Generated from UnityEngine.ScriptableRenderLoop.AreaLightData
// PackingRules = Exact
struct AreaLightData
{
float3 positionWS;
};
// Generated from UnityEngine.ScriptableRenderLoop.EnvLightData
// PackingRules = Exact
struct EnvLightData
{
float3 positionWS;
};
// Generated from UnityEngine.ScriptableRenderLoop.PlanarLightData
// PackingRules = Exact
struct PlanarLightData
{
float3 positionWS;
};
//
// Accessors for UnityEngine.ScriptableRenderLoop.PunctualLightData
//
float3 GetPositionWS(PunctualLightData value)
{
return value.positionWS;
}
float GetInvSqrAttenuationRadius(PunctualLightData value)
{
return value.invSqrAttenuationRadius;
}
float3 GetColor(PunctualLightData value)
{
return value.color;
}
float GetUseDistanceAttenuation(PunctualLightData value)
{
return value.useDistanceAttenuation;
}
float3 GetForward(PunctualLightData value)
{
return value.forward;
}
float GetDiffuseScale(PunctualLightData value)
{
return value.diffuseScale;
}
float3 GetUp(PunctualLightData value)
{
return value.up;
}
float GetSpecularScale(PunctualLightData value)
{
return value.specularScale;
}
float3 GetRight(PunctualLightData value)
{
return value.right;
}
float GetShadowDimmer(PunctualLightData value)
{
return value.shadowDimmer;
}
float GetAngleScale(PunctualLightData value)
{
return value.angleScale;
}
float GetAngleOffset(PunctualLightData value)
{
return value.angleOffset;
}
float2 GetUnused2(PunctualLightData value)
{
return value.unused2;
}
//
// Accessors for UnityEngine.ScriptableRenderLoop.AreaLightData
//
float3 GetPositionWS(AreaLightData value)
{
return value.positionWS;
}
//
// Accessors for UnityEngine.ScriptableRenderLoop.EnvLightData
//
float3 GetPositionWS(EnvLightData value)
{
return value.positionWS;
}
//
// Accessors for UnityEngine.ScriptableRenderLoop.PlanarLightData
//
float3 GetPositionWS(PlanarLightData value)
{
return value.positionWS;
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs.hlsl.meta


fileFormatVersion: 2
guid: ff58597e731e7d5419b41b73325ddb47
timeCreated: 1475681650
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/Tests.meta


fileFormatVersion: 2
guid: 7641c43fc081f6d46b70eee4b602efcc
folderAsset: yes
timeCreated: 1474997398
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

43
Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs


using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
[TestFixture]
public class CullResultsTest
{
void InspectCullResults(Camera camera, CullResults cullResults, RenderLoop renderLoop)
{
VisibleReflectionProbe[] probes = cullResults.culledReflectionProbes;
Assert.AreEqual(1, probes.Length, "Incorrect reflection probe count");
VisibleReflectionProbe probeA = probes[0];
Assert.NotNull(probeA.texture, "probe texture");
ActiveLight[] lights = cullResults.culledLights;
Assert.AreEqual(3, lights.Length, "Incorrect light count");
LightType[] expectedTypes = new LightType[] { LightType.Directional, LightType.Spot, LightType.Point };
for (int i = 0; i != 2; i++)
{
Assert.AreEqual(expectedTypes[i], lights[i].lightType,
"Incorrect light type for light " + i.ToString() + " (" + lights[i].light.name + ")");
}
// @TODO..
}
[Test]
public void TestReflectionProbes()
{
UnityEditor.SceneManagement.EditorSceneManager.OpenScene("Assets/Editor/Tests/TestScene.unity");
// Asserts.ExpectLogError("Boing");
RenderLoopTestFixture.Run(InspectCullResults);
}
}

12
Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs.meta


fileFormatVersion: 2
guid: 4a5559aeb6036ca43895e4ed6e6cfc0d
timeCreated: 1474463564
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

59
Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using NUnit.Framework;
[ExecuteInEditMode]
public class RenderLoopTestFixture : MonoBehaviour
{
public delegate void TestDelegate(Camera camera, CullResults cullResults, RenderLoop renderLoop);
private static TestDelegate callback;
public static void Render(RenderLoopWrapper wrapper, Camera[] cameras, RenderLoop renderLoop)
{
foreach (Camera camera in cameras)
{
CullingParameters cullingParams;
bool gotCullingParams = CullResults.GetCullingParameters(camera, out cullingParams);
Assert.IsTrue(gotCullingParams);
CullResults cullResults = CullResults.Cull(ref cullingParams, renderLoop);
callback(camera, cullResults, renderLoop);
}
renderLoop.Submit();
}
public static void Run(TestDelegate renderCallback)
{
var sceneCamera = Camera.main;
var camObject = sceneCamera.gameObject;
var instance = camObject.AddComponent<RenderLoopWrapper>();
instance.callback = Render;
callback = renderCallback;
instance.enabled = true;
Transform t = camObject.transform;
// Can't use AlignViewToObject because it animates over time, and we want the first frame
float size = SceneView.lastActiveSceneView.size;
float fov = 90; // hardcoded in SceneView
float camDist = size / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad);
SceneView.lastActiveSceneView.LookAtDirect(t.position + t.forward * camDist, t.rotation, size);
// Invoke renderer
try
{
sceneCamera.Render();
}
finally
{
Object.DestroyImmediate(instance);
}
}
}

12
Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs.meta


fileFormatVersion: 2
guid: d226affce84ac7d4dafb4a6a7a2a5391
timeCreated: 1474463466
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

29
Assets/ScriptableRenderLoop/Tests/RenderLoopWrapper.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.ScriptableRenderLoop;
using UnityEngine.Rendering;
[ExecuteInEditMode]
public class RenderLoopWrapper : MonoBehaviour
{
public delegate void Callback(RenderLoopWrapper wrapper, Camera[] cameras, RenderLoop renderLoop);
public Callback callback;
void OnEnable()
{
RenderLoop.renderLoopDelegate += Render;
}
void OnDisable()
{
RenderLoop.renderLoopDelegate -= Render;
}
bool Render(Camera[] cameras, RenderLoop loop)
{
callback(this, cameras, loop);
return true;
}
}

12
Assets/ScriptableRenderLoop/Tests/RenderLoopWrapper.cs.meta


fileFormatVersion: 2
guid: 636306177ff5b4d4baaeed2249249f1b
timeCreated: 1475087186
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

42
Assets/ScriptableRenderLoop/common/ShaderBase.cs


#if !__HLSL
using UnityEngine;
public struct Vec2
{
public static implicit operator Vec2(Vector2 v) { return new Vec2(v.x, v.y); }
public Vec2(Vec2 v) { x = v.x; y = v.y; }
public Vec2(float fX, float fY) { x = fX; y = fY; }
public float x, y;
};
public struct Vec3
{
public static implicit operator Vec3(Vector3 v) { return new Vec3(v.x, v.y, v.z); }
public static implicit operator Vec3(Vector4 v) { return new Vec3(v.x, v.y, v.z); }
public Vec3(Vec3 v) { x = v.x; y = v.y; z = v.z; }
public Vec3(float fX, float fY, float fZ) { x = fX; y = fY; z = fZ; }
public float x, y, z;
};
public struct Vec4
{
public static implicit operator Vec4(Vector4 v) { return new Vec4(v.x, v.y, v.z, v.w); }
public static implicit operator Vec4(Vector3 v) { return new Vec4(v.x, v.y, v.z, 1.0f); }
public Vec4(Vec4 v) { x = v.x; y = v.y; z = v.z; w = v.w; }
public Vec4(float fX, float fY, float fZ, float fW) { x = fX; y = fY; z = fZ; w = fW; }
public float x, y, z, w;
};
public struct Mat44
{
public Mat44( Matrix4x4 m ) { c0 = new Vec4(m.GetColumn(0)); c1 = new Vec4(m.GetColumn(1)); c2 = new Vec4(m.GetColumn(2)); c3 = new Vec4(m.GetColumn(3)); }
public Vec4 c0, c1, c2, c3;
};
#endif

12
Assets/ScriptableRenderLoop/common/ShaderBase.cs.meta


fileFormatVersion: 2
guid: c1ebf357fa7277c4697f21c295e8c4c2
timeCreated: 1467917164
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存