浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master' into LightmapSupport

/main
Sebastien Lagarde 8 年前
当前提交
f3b6f913
共有 25 个文件被更改,包括 93 次插入53 次删除
  1. 2
      Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs
  2. 2
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  3. 4
      Assets/Editor/Tests/ShaderGeneratorTests/ShaderGeneratorTests.cs
  4. 2
      Assets/ScriptableRenderLoop/AdditionalLightData.cs
  5. 4
      Assets/ScriptableRenderLoop/ForwardRenderLoop/ForwardRenderLoop.cs
  6. 3
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  7. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs
  8. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs
  9. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs
  10. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs
  11. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.cs
  12. 3
      Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
  13. 4
      Assets/ScriptableRenderLoop/ScriptableRenderLoop.cs
  14. 4
      Assets/ScriptableRenderLoop/ScriptableRenderLoopPicker.cs
  15. 4
      Assets/ScriptableRenderLoop/Tests/RenderLoopWrapper.cs
  16. 1
      Assets/ScriptableRenderLoop/common/SkyboxHelper.cs
  17. 16
      Assets/ScriptableRenderLoop/common/TextureCache.cs
  18. 9
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  19. 9
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs
  20. 12
      Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl
  21. 21
      Assets/ScriptableRenderLoop/fptl/ReflectionTemplate.hlsl
  22. 24
      Assets/ScriptableRenderLoop/fptl/UnityStandardForwardNew.cginc
  23. 2
      Assets/ShaderGenerator/CSharpToHLSL.cs
  24. 2
      Assets/ShaderGenerator/ShaderGeneratorMenu.cs
  25. 2
      Assets/ShaderGenerator/ShaderTypeGeneration.cs

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


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using NUnit.Framework;
[TestFixture]

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


using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using NUnit.Framework;
[ExecuteInEditMode]

4
Assets/Editor/Tests/ShaderGeneratorTests/ShaderGeneratorTests.cs


using System.Reflection;
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using UnityEngine.ScriptableRenderLoop;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.ScriptableRenderLoop;
using NUnit.Framework;
[TestFixture]

2
Assets/ScriptableRenderLoop/AdditionalLightData.cs


namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
//@TODO: We should continously move these values
// into the engine when we can see them being generally useful

4
Assets/ScriptableRenderLoop/ForwardRenderLoop/ForwardRenderLoop.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public class ForwardRenderLoop : ScriptableRenderLoop
{

3
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[ExecuteInEditMode]
// This HDRenderLoop assume linear lighting. Don't work with gamma.

2
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs


//using EditorGUIUtility=UnityEditor.EditorGUIUtility;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[CustomEditor(typeof(HDRenderLoop))]
public class HDRenderLoopInspector : Editor

4
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs


//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
// These structures share between C# and hlsl need to be align on float4, so we pad them.
[GenerateHLSL]

{
public Vector3 positionWS;
};
} // namespace UnityEngine.ScriptableRenderLoop
} // namespace UnityEngine.Experimental.ScriptableRenderLoop

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs


//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
namespace Builtin
{

4
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs


//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
namespace Lit
{

isInit = false;
}
public void RenderInit(UnityEngine.Rendering.RenderLoop renderLoop)
public void RenderInit(UnityEngine.Experimental.Rendering.RenderLoop renderLoop)
{
var cmd = new CommandBuffer();
cmd.name = "Init PreFGD";

4
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.cs


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
namespace Unlit
{

3
Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[System.Serializable]
public struct ShadowSettings

4
Assets/ScriptableRenderLoop/ScriptableRenderLoop.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public abstract class ScriptableRenderLoop : ScriptableObject
{

4
Assets/ScriptableRenderLoop/ScriptableRenderLoopPicker.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
//@TODO: This should be moved into GraphicsSettings
[ExecuteInEditMode]

4
Assets/ScriptableRenderLoop/Tests/RenderLoopWrapper.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.ScriptableRenderLoop;
using UnityEngine.Rendering;
using UnityEngine.Experimental.ScriptableRenderLoop;
using UnityEngine.Experimental.Rendering;
[ExecuteInEditMode]
public class RenderLoopWrapper : MonoBehaviour

1
Assets/ScriptableRenderLoop/common/SkyboxHelper.cs


using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityEngine;
public class SkyboxHelper

16
Assets/ScriptableRenderLoop/common/TextureCache.cs


public class TextureCache2D : TextureCache
{
private Texture2DArray cache;
private Texture2DArray m_Cache;
var mismatch = (cache.width != texture.width) || (cache.height != texture.height);
var mismatch = (m_Cache.width != texture.width) || (m_Cache.height != texture.height);
mismatch |= (cache.format != (texture as Texture2D).format);
mismatch |= (m_Cache.format != (texture as Texture2D).format);
texture.name, cache.width, cache.height, cache.format);
texture.name, m_Cache.width, m_Cache.height, m_Cache.format);
Graphics.CopyTexture(texture, 0, cache, sliceIndex);
Graphics.CopyTexture(texture, 0, m_Cache, sliceIndex);
return cache;
return m_Cache;
}
public bool AllocTextureArray(int numTextures, int width, int height, TextureFormat format, bool isMipMapped)

cache = new Texture2DArray(width, height, numTextures, format, isMipMapped)
m_Cache = new Texture2DArray(width, height, numTextures, format, isMipMapped)
{
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Clamp

public void Release()
{
Texture.DestroyImmediate(cache); // do I need this?
Texture.DestroyImmediate(m_Cache); // do I need this?
}
}

9
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[ExecuteInEditMode]
public class FptlLighting : ScriptableRenderLoop

cmd.SetGlobalTexture("_spotCookieTextures", m_CookieTexArray.GetTexCache());
cmd.SetGlobalTexture("_pointCookieTextures", m_CubeCookieTexArray.GetTexCache());
cmd.SetGlobalTexture("_reflCubeTextures", m_CubeReflTexArray.GetTexCache());
var topCube = ReflectionProbe.GetDefaultCubemapIBL();
var defdecode = ReflectionProbe.CalculateHDRDecodeValuesForDefaultTexture();
cmd.SetGlobalTexture("_reflRootCubeTexture", topCube);
cmd.SetGlobalFloat("_reflRootHdrDecodeMult", defdecode.x);
cmd.SetGlobalFloat("_reflRootHdrDecodeExp", defdecode.y);
if (enableClustered)
{

9
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs


using UnityEngine;
using UnityEngine.Experimental.ScriptableRenderLoop;
[UnityEngine.ScriptableRenderLoop.GenerateHLSL]
[GenerateHLSL]
public struct SFiniteLightData
{
// setup constant buffer

public float probeBlendDistance;
};
[UnityEngine.ScriptableRenderLoop.GenerateHLSL]
[GenerateHLSL]
public struct SFiniteLightBound
{
public Vector3 boxAxisX;

public float radius;
};
[UnityEngine.ScriptableRenderLoop.GenerateHLSL]
[GenerateHLSL]
public struct DirectionalLight
{
public Vector3 color;

public float pad1;
};
[UnityEngine.ScriptableRenderLoop.GenerateHLSL]
[GenerateHLSL]
public class LightDefinitions
{
public static int MAX_NR_LIGHTS_PER_CAMERA = 1024;

12
Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl


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;
// todo (simplify): m22 is zero and m23 is +1/-1 (depends on left/right hand proj)
float m22 = g_mInvScrProjection[2].z, m23 = g_mInvScrProjection[2].w;
float m32 = g_mInvScrProjection[3].z, m33 = g_mInvScrProjection[3].w;
return (m22*zDptBufSpace+m23) / (m32*zDptBufSpace+m33);
//float3 vP = float3(0.0f,0.0f,zDptBufSpace);
//float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0));
//return v4Pres.z / v4Pres.w;
}

21
Assets/ScriptableRenderLoop/fptl/ReflectionTemplate.hlsl


UNITY_DECLARE_TEXCUBEARRAY(_reflCubeTextures);
UNITY_DECLARE_TEXCUBE(_reflRootCubeTexture);
//uniform int _reflRootSliceIndex;
uniform float _reflRootHdrDecodeMult;
uniform float _reflRootHdrDecodeExp;
half3 Unity_GlossyEnvironment (UNITY_ARGS_TEXCUBEARRAY(tex), int sliceIndex, half4 hdr, Unity_GlossyEnvironmentData glossIn);

light.dir = 0;
float3 ints = 0;
// root ibl begin
{
Unity_GlossyEnvironmentData g;
g.roughness = percRoughness;
g.reflUVW = worldNormalRefl;
half3 env0 = Unity_GlossyEnvironment(UNITY_PASS_TEXCUBE(_reflRootCubeTexture), float4(_reflRootHdrDecodeMult, _reflRootHdrDecodeExp, 0.0, 0.0), g);
//half3 env0 = Unity_GlossyEnvironment(UNITY_PASS_TEXCUBEARRAY(_reflCubeTextures), _reflRootSliceIndex, float4(_reflRootHdrDecodeMult, _reflRootHdrDecodeExp, 0.0, 0.0), g);
UnityIndirect ind;
ind.diffuse = 0;
ind.specular = env0;// * data.occlusion;
ints = EvalIndirectSpecular(light, ind);
}
// root ibl end
uint l=0;
// don't need the outer loop since the probes are sorted by volume type (currently one type in fact)

24
Assets/ScriptableRenderLoop/fptl/UnityStandardForwardNew.cginc


#include "LightingUtils.hlsl"
static FragmentCommonData gdata;
static float occlusion;
half4 fragNoLight(VertexOutputForwardNew i) : SV_Target
{

float3 EvalIndirectSpecular(UnityLight light, UnityIndirect ind)
{
float occlusion = 1.0; // have none for now
return occlusion * UNITY_BRDF_PBS(gdata.diffColor, gdata.specColor, gdata.oneMinusReflectivity, gdata.smoothness, gdata.normalWorld, -gdata.eyeVec, light, ind);
}

uint2 pixCoord = ((uint2) i.pos.xy);
//float atten = 0.0;
//half occlusion = Occlusion(i.tex.xy);
//UnityGI gi = FragmentGI (gdata, occlusion, i.ambientOrLightmapUV, atten, mainLight);
float atten = 1.0;
occlusion = Occlusion(i.tex.xy);
UnityGI gi = FragmentGI (gdata, occlusion, i.ambientOrLightmapUV, atten, DummyLight(), false);
// direct light contributions
res += ExecuteReflectionList(numReflectionsProcessed, pixCoord, vP, gdata.normalWorld, Vworld, gdata.smoothness);
// don't really have a handle on this yet
//UnityLight mainLight = MainLight ();
//res += UNITY_BRDF_GI (gdata.diffColor, gdata.specColor, gdata.oneMinusReflectivity, gdata.smoothness, gdata.normalWorld, -gdata.eyeVec, occlusion, gi);
res += Emission(i.tex.xy);
// specular GI
res += ExecuteReflectionList(numReflectionsProcessed, pixCoord, vP, gdata.normalWorld, Vworld, gdata.smoothness);
// diffuse GI
res += UNITY_BRDF_PBS (gdata.diffColor, gdata.specColor, gdata.oneMinusReflectivity, gdata.smoothness, gdata.normalWorld, -gdata.eyeVec, gi.light, gi.indirect).xyz;
res += UNITY_BRDF_GI (gdata.diffColor, gdata.specColor, gdata.oneMinusReflectivity, gdata.smoothness, gdata.normalWorld, -gdata.eyeVec, occlusion, gi);
//res = OverlayHeatMap(numLightsProcessed, res);
//UNITY_APPLY_FOG(i.fogCoord, res);

2
Assets/ShaderGenerator/CSharpToHLSL.cs


using System.Reflection;
using UnityEditor;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public class CSharpToHLSL
{

2
Assets/ShaderGenerator/ShaderGeneratorMenu.cs


namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public class ShaderGeneratorMenu
{

2
Assets/ShaderGenerator/ShaderTypeGeneration.cs


using System.Collections.Generic;
using System.Reflection;
namespace UnityEngine.ScriptableRenderLoop
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public enum PackingRules
{

正在加载...
取消
保存