浏览代码

Merge branch 'master' into stacklit

/stacklit
Stephane Laroche 6 年前
当前提交
b3ee7f83
共有 14 个文件被更改,包括 93 次插入48 次删除
  1. 25
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/UnityInstancing.hlsl
  2. 1
      ScriptableRenderPipeline/HDRenderPipeline/CHANGELOG.md
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BuildPlayer/HDRPVariantStripper.cs
  4. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs
  5. 16
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs.hlsl
  6. 16
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightEvaluation.hlsl
  7. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  8. 1
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  9. 37
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputBuiltin.hlsl
  10. 3
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl
  11. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightSampling.shader
  12. 5
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader
  13. 1
      ShaderGraph/CHANGELOG.md
  14. 15
      ShaderGraph/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs

25
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/UnityInstancing.hlsl


#define UNITY_SUPPORT_INSTANCING
#endif
#if defined(SHADER_API_D3D11)
#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3)
#define UNITY_SUPPORT_STEREO_INSTANCING
#endif

// - UNITY_TRANSFER_VERTEX_OUTPUT_STEREO Copy stero target from input struct to output struct. Used in vertex shader.
// - UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX
#ifdef UNITY_STEREO_INSTANCING_ENABLED
#if defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)
#define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO uint stereoTargetEyeIndexSV : SV_RenderTargetArrayIndex; uint stereoTargetEyeIndex : BLENDINDICES0;
#define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output) output.stereoTargetEyeIndexSV = unity_StereoEyeIndex; output.stereoTargetEyeIndex = unity_StereoEyeIndex;
#else
#endif
#define DEFAULT_UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(input, output) output.stereoTargetEyeIndex = input.stereoTargetEyeIndex;
#define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) unity_StereoEyeIndex = input.stereoTargetEyeIndex;
#elif defined(UNITY_STEREO_MULTIVIEW_ENABLED)

void UnitySetupInstanceID(uint inputInstanceID)
{
#ifdef UNITY_STEREO_INSTANCING_ENABLED
// stereo eye index is automatically figured out from the instance ID
unity_StereoEyeIndex = inputInstanceID & 0x01;
unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1);
#if defined(SHADER_API_GLES3)
// We must calculate the stereo eye index differently for GLES3
// because otherwise, the unity shader compiler will emit a bitfieldInsert function.
// bitfieldInsert requires support for glsl version 400 or later. Therefore the
// generated glsl code will fail to compile on lower end devices. By changing the
// way we calculate the stereo eye index, we can help the shader compiler to avoid
// emitting the bitfieldInsert function and thereby increase the number of devices we
// can run stereo instancing on.
unity_StereoEyeIndex = round(fmod(inputInstanceID, 2.0));
unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1);
#else
// stereo eye index is automatically figured out from the instance ID
unity_StereoEyeIndex = inputInstanceID & 0x01;
unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1);
#endif
#else
unity_InstanceID = inputInstanceID + unity_BaseInstanceID;
#endif

1
ScriptableRenderPipeline/HDRenderPipeline/CHANGELOG.md


- Fix unnecessary division by PI for baked area lights.
- Fix line lights sent to the lightmappers. The backends don't support this light type.
- Fix issue with shadow mask framesettings not correctly taken into account when shadow mask is enabled for lighting.
- Fix directional light and shadow mask transition, they are now matching making smooth transition
## [2018.1.0f2]

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BuildPlayer/HDRPVariantStripper.cs


using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Build;
using UnityEditor.Rendering;

ShaderKeyword m_TileLighting;
ShaderKeyword m_ClusterLighting;
ShaderKeyword m_FeatureSSS;
//ShaderKeyword m_FeatureSSS;
public HDRPVariantStripper()
{

m_TileLighting = new ShaderKeyword("USE_FPTL_LIGHTLIST");
m_ClusterLighting = new ShaderKeyword("USE_CLUSTERED_LIGHTLIST");
m_FeatureSSS = new ShaderKeyword("_MATERIAL_FEATURE_SUBSURFACE_SCATTERING");
//m_FeatureSSS = new ShaderKeyword("_MATERIAL_FEATURE_SUBSURFACE_SCATTERING");
}
bool LitShaderStripper(Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData)

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs


public Vector3 up; // Rescaled by (2 / shapeHeight)
public float diffuseScale;
public Vector2 fadeDistanceScaleAndBias; // Use with ShadowMask feature
public float unused0;
public float volumetricDimmer;
public float volumetricDimmer; // TODO: improve the cache locality
};
[GenerateHLSL]

16
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightDefinition.cs.hlsl


float specularScale;
float3 up;
float diffuseScale;
float2 fadeDistanceScaleAndBias;
float unused0;
float volumetricDimmer;
float volumetricDimmer;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.LightData

{
return value.diffuseScale;
}
float2 GetFadeDistanceScaleAndBias(DirectionalLightData value)
{
return value.fadeDistanceScaleAndBias;
}
float GetUnused0(DirectionalLightData value)
float GetVolumetricDimmer(DirectionalLightData value)
return value.unused0;
return value.volumetricDimmer;
}
int GetDynamicShadowCasterOnly(DirectionalLightData value)
{

{
return value.shadowMaskSelector;
}
float GetVolumetricDimmer(DirectionalLightData value)
{
return value.volumetricDimmer;
}
//

16
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightEvaluation.hlsl


#endif
#ifdef SHADOWS_SHADOWMASK
float fade = saturate(posInput.linearDepth * lightData.fadeDistanceScaleAndBias.x + lightData.fadeDistanceScaleAndBias.y);
// TODO: Optimize this code! Currently it is a bit like brute force to get the last transistion and fade to shadow mask, but there is
// certainly more efficient to do
// We reuse the transition from the cascade system to fade between shadow mask at max distance
uint payloadOffset;
real fade;
int cascadeCount;
int shadowSplitIndex = EvalShadow_GetSplitIndex(lightLoopContext.shadowContext, lightData.shadowIndex, positionWS, payloadOffset, fade, cascadeCount);
// we have a fade caclulation for each cascade but we must lerp with shadow mask only for the last one
fade = ((shadowSplitIndex + 1) == cascadeCount || shadowSplitIndex == -1.0) ? fade : 0.0;
shadow = lerp(shadow, shadowMask, fade); // Caution to lerp parameter: fade is the reverse of shadowDimmer
// In the transition code (both dithering and blend) we use shadow = lerp( shadow, 1.0, fade ) for last transition
// mean if we expend the code we have (shadow * (1 - fade) + fade). Here to make transition with shadow mask
// we will remove fade and add fade * shadowMask which mean we do a lerp with shadow mask
shadow = shadow - fade + fade * shadowMask;
// Note: There is no shadowDimmer when there is no shadow mask
#endif

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs


int m_lightCount = 0;
int m_densityVolumeCount = 0;
bool m_enableBakeShadowMask = false; // Track if any light require shadow mask. In this case we will need to enable the keyword shadow mask
float m_maxShadowDistance = 0.0f; // Save value from shadow settings
private ComputeShader buildScreenAABBShader { get { return m_Resources.buildScreenAABBShader; } }
private ComputeShader buildPerTileLightListShader { get { return m_Resources.buildPerTileLightListShader; } }

m_CurrentSunLightShadowIndex = shadowIdx;
}
float scale;
float bias;
GetScaleAndBiasForLinearDistanceFade(m_maxShadowDistance, out scale, out bias);
directionalLightData.fadeDistanceScaleAndBias = new Vector2(scale, bias);
directionalLightData.shadowMaskSelector = Vector4.zero;
if (IsBakedShadowMaskLight(light.light))

// If any light require it, we need to enabled bake shadow mask feature
m_enableBakeShadowMask = false;
m_maxShadowDistance = shadowSettings.maxShadowDistance;
m_lightList.Clear();
// We need to properly reset this here otherwise if we go from 1 light to no visible light we would keep the old reference active.

1
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


}
SetRenderTarget(cmd, colorRT, depthRT, clearFlag);
m_CurrCameraColorRT = colorRT;
// If rendering to an intermediate RT we resolve viewport on blit due to offset not being supported
// while rendering to a RT.

37
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputBuiltin.hlsl


#ifndef LIGHTWEIGHT_SHADER_VARIABLES_INCLUDED
#define LIGHTWEIGHT_SHADER_VARIABLES_INCLUDED
#if (defined(SHADER_API_D3D11) || defined(SHADER_API_PSSL)) && defined(STEREO_INSTANCING_ON)
#if defined(STEREO_INSTANCING_ON) && (defined(SHADER_API_D3D11) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE) || defined(SHADER_API_PSSL))
#endif
#if defined(STEREO_MULTIVIEW_ON) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)) && !(defined(SHADER_API_SWITCH))
#define UNITY_STEREO_MULTIVIEW_ENABLED
#endif
#if defined(UNITY_SINGLE_PASS_STEREO) || defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)

CBUFFER_END
#if defined(UNITY_STEREO_MULTIVIEW_ENABLED) || ((defined(UNITY_SINGLE_PASS_STEREO) || defined(UNITY_STEREO_INSTANCING_ENABLED)) && (defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL)))
#define GLOBAL_CBUFFER_START(name) cbuffer name {
#define GLOBAL_CBUFFER_END }
#else
#define GLOBAL_CBUFFER_START(name) CBUFFER_START(name)
#define GLOBAL_CBUFFER_END CBUFFER_END
#endif
CBUFFER_START(UnityStereoGlobals)
GLOBAL_CBUFFER_START(UnityStereoGlobals)
float4x4 unity_StereoMatrixP[2];
float4x4 unity_StereoMatrixV[2];
float4x4 unity_StereoMatrixInvV[2];

float3 unity_StereoWorldSpaceCameraPos[2];
float4 unity_StereoScaleOffset[2];
CBUFFER_END
GLOBAL_CBUFFER_END
CBUFFER_START(UnityStereoEyeIndices)
real4 unity_StereoEyeIndices[2];
CBUFFER_END
GLOBAL_CBUFFER_START(UnityStereoEyeIndices)
float4 unity_StereoEyeIndices[2];
GLOBAL_CBUFFER_END
#endif
#if defined(UNITY_STEREO_MULTIVIEW_ENABLED) && defined(SHADER_STAGE_VERTEX)
// OVR_multiview
// In order to convey this info over the DX compiler, we wrap it into a cbuffer.
#if !defined(UNITY_DECLARE_MULTIVIEW)
#define UNITY_DECLARE_MULTIVIEW(number_of_views) GLOBAL_CBUFFER_START(OVR_multiview) uint gl_ViewID; uint numViews_##number_of_views; GLOBAL_CBUFFER_END
#define UNITY_VIEWID gl_ViewID
#endif
#endif
#if defined(UNITY_STEREO_MULTIVIEW_ENABLED) && defined(SHADER_STAGE_VERTEX)

static uint unity_StereoEyeIndex;
#elif defined(UNITY_SINGLE_PASS_STEREO)
CBUFFER_START(UnityStereoEyeIndex)
GLOBAL_CBUFFER_START(UnityStereoEyeIndex)
CBUFFER_END
GLOBAL_CBUFFER_END
#endif
CBUFFER_START(UnityPerDrawRare)

3
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassDepthOnly.hlsl


{
float2 uv : TEXCOORD0;
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
VertexOutput DepthOnlyVertex(VertexInput v)

UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.clipPos = TransformObjectToHClip(v.position.xyz);

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightSampling.shader


{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Interpolators

UNITY_VERTEX_INPUT_INSTANCE_ID
};
Interpolators Vertex(VertexInput i)

5
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader


half4 Fragment(Interpolators i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
#if !defined(UNITY_STEREO_INSTANCING_ENABLED)
// Completely unclear why i.stereoTargetEyeIndex doesn't work here, considering
// this has to be correct in order for the texture array slices to be rasterized to
// We can limit this workaround to stereo instancing for now.
#endif
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, unity_StereoEyeIndex).r;

1
ShaderGraph/CHANGELOG.md


- Pasting a property node into another graph will now convert it to a concrete node. ([#300](https://github.com/Unity-Technologies/ShaderGraph/issues/300) and [#307](https://github.com/Unity-Technologies/ShaderGraph/pull/307))
- Make nodes that are copied from one graph to another spawn in the center of the current view. ([#333](https://github.com/Unity-Technologies/ShaderGraph/issues/333))
- Fixed an issue with editable sub graph paths, causing the search window to sometimes yield a null reference exception.
- Ensure that the blackboard is within view when deserialized.

15
ShaderGraph/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs


m_MasterPreviewView.previewTextureView.style.width = StyleValue<float>.Create(m_FloatingWindowsLayout.masterPreviewSize.x);
m_MasterPreviewView.previewTextureView.style.height = StyleValue<float>.Create(m_FloatingWindowsLayout.masterPreviewSize.y);
// Restore blackboard layout
m_BlackboardProvider.blackboard.layout = m_FloatingWindowsLayout.blackboardLayout.GetLayout(this.layout);
// Restore blackboard layout, and make sure that it remains in the view.
Rect blackboardRect = m_FloatingWindowsLayout.blackboardLayout.GetLayout(this.layout);
// Make sure the dimensions are sufficiently large.
blackboardRect.width = Mathf.Clamp(blackboardRect.width, 160f, m_GraphView.contentContainer.layout.width);
blackboardRect.height = Mathf.Clamp(blackboardRect.height, 160f, m_GraphView.contentContainer.layout.height);
// Make sure that the positionining is on screen.
blackboardRect.x = Mathf.Clamp(blackboardRect.x, 0f, Mathf.Max(1f, m_GraphView.contentContainer.layout.width - blackboardRect.width - blackboardRect.width));
blackboardRect.y = Mathf.Clamp(blackboardRect.y, 0f, Mathf.Max(1f, m_GraphView.contentContainer.layout.height - blackboardRect.height - blackboardRect.height));
// Set the processed blackboard layout.
m_BlackboardProvider.blackboard.layout = blackboardRect;
previewManager.ResizeMasterPreview(m_FloatingWindowsLayout.masterPreviewSize);
}

正在加载...
取消
保存