Evgenii Golubev 8 年前
当前提交
abed39d7
共有 16 个文件被更改,包括 238 次插入183 次删除
  1. 42
      Assets/LowEndMobilePipeline/LowEndMobilePipeline.cs
  2. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute
  3. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-clustered.compute
  4. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.compute
  5. 336
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  6. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  7. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  8. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl
  9. 3
      Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl
  10. 10
      Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingInternal.hlsl
  11. 3
      Assets/ScriptableRenderPipeline/common/CubeToSpherical.shader
  12. 3
      Assets/ScriptableRenderPipeline/common/ShaderBase.h
  13. 4
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild-bigtile.compute
  14. 2
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild-clustered.compute
  15. 2
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild.compute
  16. 2
      Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs

42
Assets/LowEndMobilePipeline/LowEndMobilePipeline.cs


namespace UnityEngine.Experimental.Rendering.LowendMobile
{
[Serializable]
public class ShadowSettings
{
public bool enabled;
public int shadowAtlasWidth;
public int shadowAtlasHeight;
public float maxShadowDistance;
public int directionalLightCascadeCount;
public Vector3 directionalLightCascades;
public float directionalLightNearPlaneOffset;
static ShadowSettings defaultShadowSettings = null;
public static ShadowSettings Default
{
get
{
if (defaultShadowSettings == null)
{
defaultShadowSettings = new ShadowSettings();
defaultShadowSettings.enabled = true;
defaultShadowSettings.shadowAtlasHeight = defaultShadowSettings.shadowAtlasWidth = 4096;
defaultShadowSettings.directionalLightCascadeCount = 1;
defaultShadowSettings.directionalLightCascades = new Vector3(0.05F, 0.2F, 0.3F);
defaultShadowSettings.directionalLightCascadeCount = 4;
defaultShadowSettings.directionalLightNearPlaneOffset = 5;
defaultShadowSettings.maxShadowDistance = 1000.0F;
}
return defaultShadowSettings;
}
}
}
public struct ShadowSliceData
{
public Matrix4x4 shadowTransform;
public int atlasX;
public int atlasY;
public int shadowResolution;
}
public class LowEndMobilePipeline : RenderPipeline, IComparer<VisibleLight>
{
private readonly LowEndMobilePipelineAsset m_Asset;

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute


if(t==0) lightOffs = 0;
GroupMemoryBarrierWithGroupSync();
int i;
for(i=t; i<iNrCoarseLights; i+=NR_THREADS) if((int)lightsListLDS[i]<g_iNrVisibLights) InterlockedAdd(lightOffs, 1);
for(i=t; i<iNrCoarseLights; i+=NR_THREADS) if(lightsListLDS[i]<(uint)g_iNrVisibLights) InterlockedAdd(lightOffs, 1);
GroupMemoryBarrierWithGroupSync();
iNrCoarseLights = lightOffs;

g_vLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*offs + i] = i==0 ? iNrCoarseLights : lightsListLDS[i-1];
g_vLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*offs + i] = i==0 ? iNrCoarseLights : lightsListLDS[max(i-1, 0)];
}

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 = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.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 = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

336
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


{
m_lightList.Clear();
if (cullResults.visibleLights.Length == 0 && cullResults.visibleReflectionProbes.Length == 0)
return;
if (cullResults.visibleLights.Length != 0 || cullResults.visibleReflectionProbes.Length != 0)
{
// 0. deal with shadows
{
m_FrameId.frameCount++;
// get the indices for all lights that want to have shadows
m_ShadowRequests.Clear();
m_ShadowRequests.Capacity = cullResults.visibleLights.Length;
int lcnt = cullResults.visibleLights.Length;
for (int i = 0; i < lcnt; ++i)
// 0. deal with shadows
if (cullResults.visibleLights[i].light.shadows != LightShadows.None)
m_ShadowRequests.Add(i);
}
// pass this list to a routine that assigns shadows based on some heuristic
uint shadowRequestCount = (uint)m_ShadowRequests.Count;
int[] shadowRequests = m_ShadowRequests.ToArray();
int[] shadowDataIndices;
uint originalRequestCount = shadowRequestCount;
m_ShadowMgr.ProcessShadowRequests(m_FrameId, cullResults, camera, cullResults.visibleLights,
ref shadowRequestCount, shadowRequests, out shadowDataIndices);
m_FrameId.frameCount++;
// get the indices for all lights that want to have shadows
m_ShadowRequests.Clear();
m_ShadowRequests.Capacity = cullResults.visibleLights.Length;
int lcnt = cullResults.visibleLights.Length;
for (int i = 0; i < lcnt; ++i)
{
if (cullResults.visibleLights[i].light.shadows != LightShadows.None)
m_ShadowRequests.Add(i);
}
// pass this list to a routine that assigns shadows based on some heuristic
uint shadowRequestCount = (uint)m_ShadowRequests.Count;
int[] shadowRequests = m_ShadowRequests.ToArray();
int[] shadowDataIndices;
uint originalRequestCount = shadowRequestCount;
m_ShadowMgr.ProcessShadowRequests(m_FrameId, cullResults, camera, cullResults.visibleLights,
ref shadowRequestCount, shadowRequests, out shadowDataIndices);
// update the visibleLights with the shadow information
m_ShadowIndices.Clear();
for (uint i = 0; i < shadowRequestCount; i++)
{
m_ShadowIndices.Add(shadowRequests[i], shadowDataIndices[i]);
// update the visibleLights with the shadow information
m_ShadowIndices.Clear();
for (uint i = 0; i < shadowRequestCount; i++)
{
m_ShadowIndices.Add(shadowRequests[i], shadowDataIndices[i]);
}
}
float oldSpecularGlobalDimmer = m_PassSettings.specularGlobalDimmer;
// Change some parameters in case of "special" rendering (can be preview, reflection, etc.
if (camera.cameraType == CameraType.Reflection)
{
m_PassSettings.specularGlobalDimmer = 0.0f;
}
float oldSpecularGlobalDimmer = m_PassSettings.specularGlobalDimmer;
// Change some parameters in case of "special" rendering (can be preview, reflection, etc.
if (camera.cameraType == CameraType.Reflection)
{
m_PassSettings.specularGlobalDimmer = 0.0f;
}
// 1. Count the number of lights and sort all light by category, type and volume
int directionalLightcount = 0;
int punctualLightcount = 0;
int areaLightCount = 0;
int projectorLightCount = 0;
// 1. Count the number of lights and sort all light by category, type and volume
int directionalLightcount = 0;
int punctualLightcount = 0;
int areaLightCount = 0;
int projectorLightCount = 0;
int lightCount = Math.Min(cullResults.visibleLights.Length, k_MaxLightsOnScreen);
var sortKeys = new uint[lightCount];
int sortCount = 0;
int lightCount = Math.Min(cullResults.visibleLights.Length, k_MaxLightsOnScreen);
var sortKeys = new uint[lightCount];
int sortCount = 0;
for (int lightIndex = 0, numLights = cullResults.visibleLights.Length; (lightIndex < numLights) && (sortCount < lightCount); ++lightIndex)
{
var light = cullResults.visibleLights[lightIndex];
for (int lightIndex = 0, numLights = cullResults.visibleLights.Length; (lightIndex < numLights) && (sortCount < lightCount); ++lightIndex)
{
var light = cullResults.visibleLights[lightIndex];
// We only process light with additional data
var additionalData = light.light.GetComponent<AdditionalLightData>();
// We only process light with additional data
var additionalData = light.light.GetComponent<AdditionalLightData>();
if (additionalData == null)
{
// Don't display warning for the preview windows
if (camera.cameraType != CameraType.Preview)
if (additionalData == null)
Debug.LogWarningFormat("Light entity {0} has no additional data, will be rendered using default values.", light.light.name);
// Don't display warning for the preview windows
if (camera.cameraType != CameraType.Preview)
{
Debug.LogWarningFormat(light.light, "Light entity {0} has no additional data, will be rendered using default values.", light.light.name);
}
additionalData = DefaultAdditionalLightData;
additionalData = DefaultAdditionalLightData;
}
LightCategory lightCategory = LightCategory.Count;
GPULightType gpuLightType = GPULightType.Point;
LightVolumeType lightVolumeType = LightVolumeType.Count;
LightCategory lightCategory = LightCategory.Count;
GPULightType gpuLightType = GPULightType.Point;
LightVolumeType lightVolumeType = LightVolumeType.Count;
// Note: LightType.Area is offline only, use for baking, no need to test it
if (additionalData.archetype == LightArchetype.Punctual)

// 5 bit (0x1F) light category, 5 bit (0x1F) GPULightType, 5 bit (0x1F) lightVolume, 1 bit for shadow casting, 16 bit index
sortKeys[sortCount++] = (uint)lightCategory << 27 | (uint)gpuLightType << 22 | (uint)lightVolumeType << 17 | shadow << 16 | (uint)lightIndex;
#else
// 5 bit (0x1F) light category, 5 bit (0x1F) GPULightType, 6 bit (0x3F) lightVolume, 16 bit index
sortKeys[sortCount++] = (uint)lightCategory << 27 | (uint)gpuLightType << 22 | (uint)lightVolumeType << 16 | (uint)lightIndex;
// 5 bit (0x1F) light category, 5 bit (0x1F) GPULightType, 6 bit (0x3F) lightVolume, 16 bit index
sortKeys[sortCount++] = (uint)lightCategory << 27 | (uint)gpuLightType << 22 | (uint)lightVolumeType << 16 | (uint)lightIndex;
}
}
Array.Sort(sortKeys);
Array.Sort(sortKeys);
// TODO: Refactor shadow management
// The good way of managing shadow:
// Here we sort everyone and we decide which light is important or not (this is the responsibility of the lightloop)
// we allocate shadow slot based on maximum shadow allowed on screen and attribute slot by bigger solid angle
// THEN we ask to the ShadowRender to render the shadow, not the reverse as it is today (i.e render shadow than expect they
// will be use...)
// The lightLoop is in charge, not the shadow pass.
// For now we will still apply the maximum of shadow here but we don't apply the sorting by priority + slot allocation yet
int directionalShadowcount = 0;
int shadowCount = 0;
// TODO: Refactor shadow management
// The good way of managing shadow:
// Here we sort everyone and we decide which light is important or not (this is the responsibility of the lightloop)
// we allocate shadow slot based on maximum shadow allowed on screen and attribute slot by bigger solid angle
// THEN we ask to the ShadowRender to render the shadow, not the reverse as it is today (i.e render shadow than expect they
// will be use...)
// The lightLoop is in charge, not the shadow pass.
// For now we will still apply the maximum of shadow here but we don't apply the sorting by priority + slot allocation yet
int directionalShadowcount = 0;
int shadowCount = 0;
// 2. Go thought all lights, convert them to GPU format.
// Create simultaneously data for culling (LigthVolumeData and rendering)
var worldToView = WorldToCamera(camera);
// 2. Go thought all lights, convert them to GPU format.
// Create simultaneously data for culling (LigthVolumeData and rendering)
var worldToView = WorldToCamera(camera);
for (int sortIndex = 0; sortIndex < sortCount; ++sortIndex)
{
// In 1. we have already classify and sorted the light, we need to use this sorted order here
uint sortKey = sortKeys[sortIndex];
LightCategory lightCategory = (LightCategory)((sortKey >> 27) & 0x1F);
GPULightType gpuLightType = (GPULightType)((sortKey >> 22) & 0x1F);
for (int sortIndex = 0; sortIndex < sortCount; ++sortIndex)
{
// In 1. we have already classify and sorted the light, we need to use this sorted order here
uint sortKey = sortKeys[sortIndex];
LightCategory lightCategory = (LightCategory)((sortKey >> 27) & 0x1F);
GPULightType gpuLightType = (GPULightType)((sortKey >> 22) & 0x1F);
LightVolumeType lightVolumeType = (LightVolumeType)((sortKey >> 17) & 0x1F);
LightVolumeType lightVolumeType = (LightVolumeType)((sortKey >> 17) & 0x1F);
LightVolumeType lightVolumeType = (LightVolumeType)((sortKey >> 16) & 0x3F);
LightVolumeType lightVolumeType = (LightVolumeType)((sortKey >> 16) & 0x3F);
int lightIndex = (int)(sortKey & 0xFFFF);
int lightIndex = (int)(sortKey & 0xFFFF);
var light = cullResults.visibleLights[lightIndex];
var additionalData = light.light.GetComponent<AdditionalLightData>() ?? DefaultAdditionalLightData;
var light = cullResults.visibleLights[lightIndex];
var additionalData = light.light.GetComponent<AdditionalLightData>() ?? DefaultAdditionalLightData;
// Directional rendering side, it is separated as it is always visible so no volume to handle here
if (gpuLightType == GPULightType.Directional)
{
if (GetDirectionalLightData(shadowSettings, gpuLightType, light, additionalData, lightIndex, ref shadowOutput, ref directionalShadowcount))
directionalLightcount++;
// Directional rendering side, it is separated as it is always visible so no volume to handle here
if (gpuLightType == GPULightType.Directional)
{
if (GetDirectionalLightData(shadowSettings, gpuLightType, light, additionalData, lightIndex, ref shadowOutput, ref directionalShadowcount))
directionalLightcount++;
#if (SHADOWS_ENABLED && SHADOWS_FIXSHADOWIDX)
// fix up shadow information
int shadowIdxDir;
if (m_ShadowIndices.TryGetValue(lightIndex, out shadowIdxDir))
{
var lightData = m_lightList.directionalLights[m_lightList.directionalLights.Count - 1];
lightData.shadowIndex = shadowIdxDir;
m_lightList.directionalLights[m_lightList.directionalLights.Count - 1] = lightData;
}
#endif
continue;
}
// Punctual, area, projector lights - the rendering side.
if (GetLightData(shadowSettings, camera, gpuLightType, light, additionalData, lightIndex, ref shadowOutput, ref shadowCount))
{
switch (lightCategory)
{
case LightCategory.Punctual:
punctualLightcount++;
break;
case LightCategory.Area:
areaLightCount++;
break;
case LightCategory.Projector:
projectorLightCount++;
break;
default:
Debug.Assert(false, "TODO: encountered an unknown LightCategory.");
break;
}
// Then culling side. Must be call in this order as we pass the created Light data to the function
GetLightVolumeDataAndBound(lightCategory, gpuLightType, lightVolumeType, light, m_lightList.lights[m_lightList.lights.Count - 1], worldToView);
}
int shadowIdxDir;
if (m_ShadowIndices.TryGetValue(lightIndex, out shadowIdxDir))
int shadowIdx;
if (m_ShadowIndices.TryGetValue(lightIndex, out shadowIdx))
var lightData = m_lightList.directionalLights[m_lightList.directionalLights.Count - 1];
lightData.shadowIndex = shadowIdxDir;
m_lightList.directionalLights[m_lightList.directionalLights.Count - 1] = lightData;
var lightData = m_lightList.lights[m_lightList.lights.Count - 1];
lightData.shadowIndex = shadowIdx;
m_lightList.lights[m_lightList.lights.Count - 1] = lightData;
continue;
// Punctual, area, projector lights - the rendering side.
if (GetLightData(shadowSettings, camera, gpuLightType, light, additionalData, lightIndex, ref shadowOutput, ref shadowCount))
{
switch (lightCategory)
{
case LightCategory.Punctual:
punctualLightcount++;
break;
case LightCategory.Area:
areaLightCount++;
break;
case LightCategory.Projector:
projectorLightCount++;
break;
default:
Debug.Assert(false, "TODO: encountered an unknown LightCategory.");
break;
}
// Sanity check
Debug.Assert(m_lightList.directionalLights.Count == directionalLightcount);
Debug.Assert(m_lightList.lights.Count == areaLightCount + punctualLightcount + projectorLightCount);
// Then culling side. Must be call in this order as we pass the created Light data to the function
GetLightVolumeDataAndBound(lightCategory, gpuLightType, lightVolumeType, light, m_lightList.lights[m_lightList.lights.Count - 1], worldToView);
}
m_punctualLightCount = punctualLightcount;
m_areaLightCount = areaLightCount;
m_projectorLightCount = projectorLightCount;
#if (SHADOWS_ENABLED && SHADOWS_FIXSHADOWIDX)
// fix up shadow information
int shadowIdx;
if (m_ShadowIndices.TryGetValue(lightIndex, out shadowIdx))
{
var lightData = m_lightList.lights[m_lightList.lights.Count - 1];
lightData.shadowIndex = shadowIdx;
m_lightList.lights[m_lightList.lights.Count - 1] = lightData;
}
#endif
}
// Redo everything but this time with envLights
int envLightCount = 0;
// Sanity check
Debug.Assert(m_lightList.directionalLights.Count == directionalLightcount);
Debug.Assert(m_lightList.lights.Count == areaLightCount + punctualLightcount + projectorLightCount);
m_punctualLightCount = punctualLightcount;
m_areaLightCount = areaLightCount;
m_projectorLightCount = projectorLightCount;
int probeCount = Math.Min(cullResults.visibleReflectionProbes.Length, k_MaxEnvLightsOnScreen);
sortKeys = new uint[probeCount];
sortCount = 0;
// Redo everything but this time with envLights
int envLightCount = 0;
for (int probeIndex = 0, numProbes = cullResults.visibleReflectionProbes.Length; (probeIndex < numProbes) && (sortCount < probeCount); probeIndex++)
{
var probe = cullResults.visibleReflectionProbes[probeIndex];
int probeCount = Math.Min(cullResults.visibleReflectionProbes.Length, k_MaxEnvLightsOnScreen);
sortKeys = new uint[probeCount];
sortCount = 0;
// probe.texture can be null when we are adding a reflection probe in the editor
if (probe.texture == null || envLightCount >= k_MaxEnvLightsOnScreen)
continue;
for (int probeIndex = 0, numProbes = cullResults.visibleReflectionProbes.Length; (probeIndex < numProbes) && (sortCount < probeCount); probeIndex++)
{
var probe = cullResults.visibleReflectionProbes[probeIndex];
// TODO: Support LightVolumeType.Sphere, currently in UI there is no way to specify a sphere influence volume
LightVolumeType lightVolumeType = probe.boxProjection != 0 ? LightVolumeType.Box : LightVolumeType.Box;
++envLightCount;
// probe.texture can be null when we are adding a reflection probe in the editor
if (probe.texture == null || envLightCount >= k_MaxEnvLightsOnScreen)
continue;
// 16 bit lightVolume, 16 bit index
sortKeys[sortCount++] = (uint)lightVolumeType << 16 | (uint)probeIndex;
}
// TODO: Support LightVolumeType.Sphere, currently in UI there is no way to specify a sphere influence volume
LightVolumeType lightVolumeType = probe.boxProjection != 0 ? LightVolumeType.Box : LightVolumeType.Box;
++envLightCount;
// Not necessary yet but call it for future modification with sphere influence volume
Array.Sort(sortKeys);
// 16 bit lightVolume, 16 bit index
sortKeys[sortCount++] = (uint)lightVolumeType << 16 | (uint)probeIndex;
}
for (int sortIndex = 0; sortIndex < sortCount; ++sortIndex)
{
// In 1. we have already classify and sorted the light, we need to use this sorted order here
uint sortKey = sortKeys[sortIndex];
LightVolumeType lightVolumeType = (LightVolumeType)((sortKey >> 16) & 0xFFFF);
int probeIndex = (int)(sortKey & 0xFFFF);
// Not necessary yet but call it for future modification with sphere influence volume
Array.Sort(sortKeys);
VisibleReflectionProbe probe = cullResults.visibleReflectionProbes[probeIndex];
for (int sortIndex = 0; sortIndex < sortCount; ++sortIndex)
{
// In 1. we have already classify and sorted the light, we need to use this sorted order here
uint sortKey = sortKeys[sortIndex];
LightVolumeType lightVolumeType = (LightVolumeType)((sortKey >> 16) & 0xFFFF);
int probeIndex = (int)(sortKey & 0xFFFF);
GetEnvLightData(probe);
VisibleReflectionProbe probe = cullResults.visibleReflectionProbes[probeIndex];
GetEnvLightVolumeDataAndBound(probe, lightVolumeType, worldToView);
}
GetEnvLightData(probe);
// Sanity check
Debug.Assert(m_lightList.envLights.Count == envLightCount);
GetEnvLightVolumeDataAndBound(probe, lightVolumeType, worldToView);
// Restore values after "special rendering"
m_PassSettings.specularGlobalDimmer = oldSpecularGlobalDimmer;
// Sanity check
Debug.Assert(m_lightList.envLights.Count == envLightCount);
// Restore values after "special rendering"
m_PassSettings.specularGlobalDimmer = oldSpecularGlobalDimmer;
UpdateDataBuffers();
}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 1
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilBits.Standard
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 1
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilBits.Standard
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VertMesh.hlsl


#if _VERTEX_WIND
float3 rootWP = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1)).xyz;
ApplyWind(positionWS, normalWS, rootWP, _Drag, _Stiffness, _ShiverDrag, _InitialBend, vertexColor.a, _Time);
ApplyWind(positionWS, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _InitialBend, vertexColor.a, _Time);
#endif
#ifdef TESSELLATION_ON

3
Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl


// Texture format sampling
// ----------------------------------------------------------------------------
float2 DirectionToLatLongCoordinate(float3 dir)
float2 DirectionToLatLongCoordinate(float3 dir_in)
float3 dir = normalize(dir_in);
// coordinate frame is (-Z, X) meaning negative Z is primary axis and X is secondary axis.
return float2(1.0 - 0.5 * INV_PI * atan2(dir.x, -dir.z), asin(dir.y) * INV_PI + 0.5);
}

10
Assets/ScriptableRenderPipeline/ShaderLibrary/SampleUVMappingInternal.hlsl


// TODO: Handle BC5 format, currently this code is for DXT5nm - After the change, rename this function UnpackNormalmapRGorAG
// This version is use for the base normal map
#define ADD_NORMAL_FUNC_SUFFIX(Name) Name
#if defined(UNITY_NO_DXT5nm)
#define UNPACK_NORMAL_FUNC UnpackNormalRGB
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalRGB
#else
#endif
#include "SampleUVMappingNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC

#define ADD_NORMAL_FUNC_SUFFIX(Name) Name##AG
#if defined(UNITY_NO_DXT5nm)
#define UNPACK_NORMAL_FUNC UnpackNormalRGB
#define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalRGB
#else
#endif
#include "SampleUVMappingNormalInternal.hlsl"
#undef ADD_NORMAL_FUNC_SUFFIX
#undef UNPACK_NORMAL_FUNC

3
Assets/ScriptableRenderPipeline/common/CubeToSpherical.shader


return o;
}
half2 DirectionToSphericalTexCoordinate(half3 dir) // use this for the lookup
half2 DirectionToSphericalTexCoordinate(half3 dir_in) // use this for the lookup
half3 dir = normalize(dir_in);
// coordinate frame is (-Z,X) meaning negative Z is primary axis and X is secondary axis.
float recipPi = 1.0/3.1415926535897932384626433832795;
return half2( 1.0-0.5*recipPi*atan2(dir.x, -dir.z), asin(dir.y)*recipPi+0.5 );

3
Assets/ScriptableRenderPipeline/common/ShaderBase.h


#ifndef __SHADERBASE_H__
#define __SHADERBASE_H__
half2 DirectionToSphericalTexCoordinate(half3 dir)
half2 DirectionToSphericalTexCoordinate(half3 dir_in)
half3 dir = normalize(dir_in);
// coordinate frame is (-Z,X) meaning negative Z is primary axis and X is secondary axis.
float recipPi = 1.0 / 3.1415926535897932384626433832795;
return half2(1.0 - 0.5 * recipPi * atan2(dir.x, -dir.z), asin(dir.y) * recipPi + 0.5);

4
Assets/ScriptableRenderPipeline/fptl/lightlistbuild-bigtile.compute


if(t==0) lightOffs = 0;
GroupMemoryBarrierWithGroupSync();
int i;
for(i=t; i<iNrCoarseLights; i+=NR_THREADS) if((int)lightsListLDS[i]<g_iNrVisibLights) InterlockedAdd(lightOffs, 1);
for(i=t; i<iNrCoarseLights; i+=NR_THREADS) if(lightsListLDS[i]<(uint)g_iNrVisibLights) InterlockedAdd(lightOffs, 1);
GroupMemoryBarrierWithGroupSync();
iNrCoarseLights = lightOffs;

g_vLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*offs + i] = i==0 ? iNrCoarseLights : lightsListLDS[i-1];
g_vLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*offs + i] = i==0 ? iNrCoarseLights : lightsListLDS[max(i-1, 0)];
}

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 = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

2
Assets/ScriptableRenderPipeline/fptl/lightlistbuild.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 = min(g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1], g_iNrVisibLights);
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

2
Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs


shaderText += "{\n";
foreach (var shaderFieldInfo in m_PackedFields)
{
shaderText += "\t" + shaderFieldInfo.ToString() + "\n";
shaderText += " " + shaderFieldInfo.ToString() + "\n";
}
shaderText += "};\n";

正在加载...
取消
保存