Remy
6 年前
当前提交
2883e443
共有 103 个文件被更改,包括 2478 次插入 和 796 次删除
-
2com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugWindow.cs
-
8com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs
-
8com.unity.render-pipelines.high-definition/CHANGELOG.md
-
11com.unity.render-pipelines.high-definition/HDRP/Camera/HDAdditionalCameraData.cs
-
30com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
-
162com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs
-
1com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/GlobalDecalSettingsUI.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/SerializedGlobalDecalSettings.cs
-
6com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/HDRPVersion.cs
-
35com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/UpgradeMenuItem.cs
-
27com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs
-
63com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
-
21com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
-
22com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
-
22com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DBufferManager.cs
-
23com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs
-
42com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs.hlsl
-
134com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.hlsl
-
422com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader
-
42com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalData.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalProjectorComponent.cs
-
32com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalSystem.cs
-
103com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalUtilities.hlsl
-
1com.unity.render-pipelines.high-definition/HDRP/Material/Decal/GlobalDecalSettings.cs
-
3com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLit.shader
-
3com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLitTessellation.shader
-
3com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader
-
3com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitTessellation.shader
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Material.hlsl
-
4com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
-
20com.unity.render-pipelines.high-definition/HDRP/Material/SubsurfaceScattering/SubsurfaceScattering.hlsl
-
26com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
-
20com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
-
81com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
-
80com.unity.render-pipelines.high-definition/HDRP/ShaderVariables.hlsl
-
10com.unity.render-pipelines.high-definition/HDRP/ShaderVariablesFunctions.hlsl
-
183com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs
-
183com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightUnlitSubShader.cs
-
44com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRExtraPasses.template
-
44com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitExtraPasses.template
-
27com.unity.shadergraph/CHANGELOG.md
-
2com.unity.shadergraph/Editor/Data/Graphs/TextureShaderProperty.cs
-
13com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalFromTextureNode.cs
-
10com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleTexture2DArrayNode.cs
-
2com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleTexture3DNode.cs
-
12com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs
-
2com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs
-
6com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
-
2com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/AtmosphericScattering.cs.meta
-
8com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering.meta
-
68com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/ShaderVariablesLightLoop.hlsl
-
9com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/ShaderVariablesLightLoop.hlsl.meta
-
8com.unity.render-pipelines.high-definition/HDRP/Lighting/ScreenSpaceLighting.meta
-
5com.unity.render-pipelines.high-definition/HDRP/Material/Decal/ShaderVariablesDecal.hlsl
-
9com.unity.render-pipelines.high-definition/HDRP/Material/Decal/ShaderVariablesDecal.hlsl.meta
-
18com.unity.render-pipelines.high-definition/HDRP/Material/SubsurfaceScattering/ShaderVariablesSubsurfaceScattering.hlsl
-
9com.unity.render-pipelines.high-definition/HDRP/Material/SubsurfaceScattering/ShaderVariablesSubsurfaceScattering.hlsl.meta
-
3com.unity.shadergraph/.data/normal_derive_nodes.PNG
-
3com.unity.shadergraph/.data/texel_size_node.PNG
-
436com.unity.shadergraph/.data/wave_form_nodes.PNG
-
131com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalFromHeightNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalFromHeightNode.cs.meta
-
39com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalReconstructZNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalReconstructZNode.cs.meta
-
52com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/TexelSizeNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/TexelSizeNode.cs.meta
-
8com.unity.shadergraph/Editor/Data/Nodes/Math/Wave.meta
-
9com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/AtmosphericScattering.cs.hlsl.meta
-
82com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl
-
9com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl.meta
-
9com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader.meta
-
33com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/ShaderVariablesAtmosphericScattering.hlsl
-
9com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/ShaderVariablesAtmosphericScattering.hlsl.meta
-
9com.unity.render-pipelines.high-definition/HDRP/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.hlsl.meta
-
29com.unity.render-pipelines.high-definition/HDRP/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.hlsl
-
41com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/NoiseSineWaveNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/NoiseSineWaveNode.cs.meta
-
35com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SawtoothWaveNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SawtoothWaveNode.cs.meta
-
35com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SquareWaveNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SquareWaveNode.cs.meta
-
35com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/TriangleWaveNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/TriangleWaveNode.cs.meta
-
10com.unity.render-pipelines.high-definition/HDRP/Sky/AtmosphericScattering.meta
-
10com.unity.render-pipelines.high-definition/HDRP/Sky/OpaqueAtmosphericScattering.shader.meta
-
10com.unity.render-pipelines.high-definition/HDRP/Sky/SkyVariables.hlsl.meta
-
20com.unity.render-pipelines.high-definition/HDRP/Sky/SkyVariables.hlsl
-
0/com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalFromTextureNode.cs.meta
-
0/com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalFromTextureNode.cs
-
0/com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
-
0/com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/AtmosphericScattering.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/ExponentialFog.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/LinearFog.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/AtmosphericScattering.cs.hlsl
-
0/com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/VolumetricFog.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Lighting/AtmosphericScattering/AtmosphericScattering.cs
|
|||
fileFormatVersion: 2 |
|||
guid: 41811d2641d454a48819f6e50a816af9 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifdef SHADER_VARIABLES_INCLUDE_CB |
|||
|
|||
#define MAX_ENV2D_LIGHT 32 |
|||
|
|||
uint _DirectionalLightCount; |
|||
uint _PunctualLightCount; |
|||
uint _AreaLightCount; |
|||
uint _EnvLightCount; |
|||
uint _EnvProxyCount; |
|||
int _EnvLightSkyEnabled; // TODO: make it a bool |
|||
|
|||
uint _NumTileFtplX; |
|||
uint _NumTileFtplY; |
|||
|
|||
// these uniforms are only needed for when OPAQUES_ONLY is NOT defined |
|||
// but there's a problem with our front-end compilation of compute shaders with multiple kernels causing it to error |
|||
//#ifdef USE_CLUSTERED_LIGHTLIST |
|||
float4x4 g_mInvScrProjection; // TODO: remove, unused in HDRP |
|||
|
|||
float g_fClustScale; |
|||
float g_fClustBase; |
|||
float g_fNearPlane; |
|||
float g_fFarPlane; |
|||
int g_iLog2NumClusters; // We need to always define these to keep constant buffer layouts compatible |
|||
|
|||
uint g_isLogBaseBufferEnabled; |
|||
//#endif |
|||
|
|||
//#ifdef USE_CLUSTERED_LIGHTLIST |
|||
uint _NumTileClusteredX; |
|||
uint _NumTileClusteredY; |
|||
|
|||
float4x4 _Env2DCaptureVP[MAX_ENV2D_LIGHT]; |
|||
|
|||
#else |
|||
|
|||
#include "HDRP/Lighting/LightDefinition.cs.hlsl" |
|||
#include "CoreRP/Shadow/ShadowBase.cs.hlsl" |
|||
|
|||
StructuredBuffer<uint> g_vLightListGlobal; // don't support Buffer yet in unity |
|||
|
|||
StructuredBuffer<uint> g_vLayeredOffsetsBuffer; // don't support Buffer yet in unity |
|||
StructuredBuffer<float> g_logBaseBuffer; // don't support Buffer yet in unity |
|||
//#endif |
|||
|
|||
#ifdef USE_INDIRECT |
|||
StructuredBuffer<uint> g_TileFeatureFlags; |
|||
#endif |
|||
|
|||
StructuredBuffer<DirectionalLightData> _DirectionalLightDatas; |
|||
StructuredBuffer<LightData> _LightDatas; |
|||
StructuredBuffer<EnvLightData> _EnvLightDatas; |
|||
StructuredBuffer<ShadowData> _ShadowDatas; |
|||
|
|||
// Used by directional and spot lights |
|||
TEXTURE2D_ARRAY(_CookieTextures); |
|||
|
|||
// Used by point lights |
|||
TEXTURECUBE_ARRAY_ABSTRACT(_CookieCubeTextures); |
|||
|
|||
// Use texture array for reflection (or LatLong 2D array for mobile) |
|||
TEXTURECUBE_ARRAY_ABSTRACT(_EnvCubemapTextures); |
|||
TEXTURE2D_ARRAY(_Env2DTextures); |
|||
|
|||
// XRTODO: Need to stereo-ize access |
|||
TEXTURE2D(_DeferredShadowTexture); |
|||
|
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: 63d561c067f228044bff7c3922047bf2 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8201940de2426934dbd592ff5cf182c9 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifdef SHADER_VARIABLES_INCLUDE_CB |
|||
uint _EnableDBuffer; |
|||
float2 _DecalAtlasResolution; |
|||
#else |
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: 9f6cea0783427804084f429e8502ad33 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifdef SHADER_VARIABLES_INCLUDE_CB |
|||
#include "HDRP/Material/DiffusionProfile/DiffusionProfileSettings.cs.hlsl" |
|||
|
|||
// Warning: Unity is not able to losslessly transfer integers larger than 2^24 to the shader system. |
|||
// Therefore, we bitcast uint to float in C#, and bitcast back to uint in the shader. |
|||
uint _EnableSubsurfaceScattering; // Globally toggles subsurface and transmission scattering on/off |
|||
float _TexturingModeFlags; // 1 bit/profile; 0 = PreAndPostScatter, 1 = PostScatter |
|||
float _TransmissionFlags; // 1 bit/profile; 0 = regular, 1 = thin |
|||
// Old SSS Model >>> |
|||
float4 _HalfRcpVariancesAndWeights[DIFFUSION_PROFILE_COUNT][2]; // 2x Gaussians in RGB, A is interpolation weights |
|||
// <<< Old SSS Model |
|||
// Use float4 to avoid any packing issue between compute and pixel shaders |
|||
float4 _ThicknessRemaps[DIFFUSION_PROFILE_COUNT]; // R: start, G = end - start, BA unused |
|||
float4 _ShapeParams[DIFFUSION_PROFILE_COUNT]; // RGB = S = 1 / D, A = filter radius |
|||
float4 _TransmissionTintsAndFresnel0[DIFFUSION_PROFILE_COUNT]; // RGB = 1/4 * color, A = fresnel0 |
|||
float4 _WorldScales[DIFFUSION_PROFILE_COUNT]; // X = meters per world unit; Y = world units per meter |
|||
#else |
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: 63af6347132378d43b75aa5e4efeb029 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:2c14e830338ddf74ff5479bb56e8aa4a4d0f9274e96390d9897d97228f281d8e |
|||
size 54715 |
|
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:7502c3fdf5b201b4460a317b577d4e0490e500a6926ba35c53e236afa15ab76a |
|||
size 82906 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
|
|||
public enum OutputSpace |
|||
{ |
|||
Tangent, |
|||
World |
|||
}; |
|||
|
|||
[Title("Artistic", "Normal", "Normal From Height")] |
|||
public class NormalFromHeightNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal, IMayRequirePosition |
|||
{ |
|||
public NormalFromHeightNode() |
|||
{ |
|||
name = "Normal From Height"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-From-Heightmap-Node"; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
private OutputSpace m_OutputSpace = OutputSpace.Tangent; |
|||
|
|||
[EnumControl("Output Space")] |
|||
public OutputSpace outputSpace |
|||
{ |
|||
get { return m_OutputSpace; } |
|||
set |
|||
{ |
|||
if (m_OutputSpace == value) |
|||
return; |
|||
|
|||
m_OutputSpace = value; |
|||
Dirty(ModificationScope.Graph); |
|||
} |
|||
} |
|||
|
|||
const int InputSlotId = 0; |
|||
const int OutputSlotId = 1; |
|||
const string kInputSlotName = "In"; |
|||
const string kOutputSlotName = "Out"; |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
string GetFunctionName() |
|||
{ |
|||
return string.Format("Unity_NormalFromHeight_{0}", outputSpace.ToString()); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector1MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, 0)); |
|||
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { InputSlotId, OutputSlotId }); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var sb = new ShaderStringBuilder(); |
|||
|
|||
var inputValue = GetSlotValue(InputSlotId, generationMode); |
|||
var outputValue = GetSlotValue(OutputSlotId, generationMode); |
|||
sb.AppendLine("{0} {1};", FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToString(precision), GetVariableNameForSlot(OutputSlotId)); |
|||
sb.AppendLine("{0}3x3 _{1}_TangentMatrix = {0}3x3(IN.{2}SpaceTangent, IN.{2}SpaceBiTangent, IN.{2}SpaceNormal);", precision, GetVariableNameForNode(), NeededCoordinateSpace.World.ToString()); |
|||
sb.AppendLine("{0}3 _{1}_Position = IN.{2}SpacePosition;", precision, GetVariableNameForNode(), NeededCoordinateSpace.World.ToString()); |
|||
|
|||
sb.AppendLine("{0}({1},_{2}_Position,_{2}_TangentMatrix, {3});", GetFunctionName(), inputValue, GetVariableNameForNode(), outputValue); |
|||
|
|||
visitor.AddShaderChunk(sb.ToString(), false); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(FunctionRegistry registry, GraphContext graphContext, GenerationMode generationMode) |
|||
{ |
|||
registry.ProvideFunction(GetFunctionName(), s => |
|||
{ |
|||
s.AppendLine("void {0}({2} In, {1}3 Position, {1}3x3 TangentMatrix, out {3} Out)", |
|||
GetFunctionName(), |
|||
precision, |
|||
FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType.ToString(precision), |
|||
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToString(precision)); |
|||
using (s.BlockScope()) |
|||
{ |
|||
s.AppendLine("{0}3 worldDirivativeX = ddx(Position * 100);", precision); |
|||
s.AppendLine("{0}3 worldDirivativeY = ddy(Position * 100);", precision); |
|||
s.AppendNewLine(); |
|||
s.AppendLine("{0}3 crossX = cross(TangentMatrix[2].xyz, worldDirivativeX);", precision); |
|||
s.AppendLine("{0}3 crossY = cross(TangentMatrix[2].xyz, worldDirivativeY);", precision); |
|||
s.AppendLine("{0}3 d = abs(dot(crossY, worldDirivativeX));", precision); |
|||
s.AppendLine("{0}3 inToNormal = ((((In + ddx(In)) - In) * crossY) + (((In + ddy(In)) - In) * crossX)) * sign(d);", precision); |
|||
s.AppendLine("inToNormal.y *= -1.0;", precision); |
|||
s.AppendNewLine(); |
|||
s.AppendLine("Out = normalize((d * TangentMatrix[2].xyz) - inToNormal);", precision); |
|||
|
|||
if(outputSpace == OutputSpace.Tangent) |
|||
s.AppendLine("Out = TransformWorldToTangent(Out, TangentMatrix);"); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresTangent(ShaderStageCapability stageCapability) |
|||
{ |
|||
return NeededCoordinateSpace.World; |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresBitangent(ShaderStageCapability stageCapability) |
|||
{ |
|||
return NeededCoordinateSpace.World; |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability) |
|||
{ |
|||
return NeededCoordinateSpace.World; |
|||
} |
|||
public NeededCoordinateSpace RequiresPosition(ShaderStageCapability stageCapability) |
|||
{ |
|||
return NeededCoordinateSpace.World; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3bf617c1fe220684696e5bf3850bc423 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Artistic", "Normal", "Normal Reconstruct Z")] |
|||
public class NormalReconstructZNode : CodeFunctionNode |
|||
{ |
|||
public NormalReconstructZNode() |
|||
{ |
|||
name = "Normal Reconstruct Z"; |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-Reconstruct-Z-Node"; } |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("NormalReconstructZ", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string NormalReconstructZ( |
|||
[Slot(0, Binding.None)] Vector2 In, |
|||
[Slot(2, Binding.None, ShaderStageCapability.Fragment)] out Vector3 Out) |
|||
|
|||
{ |
|||
Out = Vector3.zero; |
|||
return |
|||
@"
|
|||
{ |
|||
{precision} reconstructZ = sqrt(1 - ( In.x * In.x + In.y * In.y)); |
|||
{precision}3 normalVector = {precision}3(In.x, In.y, reconstructZ); |
|||
Out = normalize(normalVector); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 27615ef3e2e760b45b15895bd39d0954 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
|
|||
[Title("Input", "Texture", "Texel Size")] |
|||
public class Texture2DPropertiesNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV |
|||
{ |
|||
public const int OutputSlotWId = 0; |
|||
public const int OutputSlotHId = 2; |
|||
public const int TextureInputId = 1; |
|||
const string kOutputSlotWName = "Width"; |
|||
const string kOutputSlotHName = "Height"; |
|||
const string kTextureInputName = "Texture"; |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
public Texture2DPropertiesNode() |
|||
{ |
|||
name = "Texel Size"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Texel-Size-Node"; } |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotWId, kOutputSlotWName, kOutputSlotWName, SlotType.Output, 0, ShaderStageCapability.Fragment)); |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotHId, kOutputSlotHName, kOutputSlotHName, SlotType.Output, 0, ShaderStageCapability.Fragment)); |
|||
AddSlot(new Texture2DInputMaterialSlot(TextureInputId, kTextureInputName, kTextureInputName)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotWId, OutputSlotHId, TextureInputId }); |
|||
} |
|||
|
|||
// Node generations
|
|||
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
visitor.AddShaderChunk(string.Format("{0}2 {1} = {2}_TexelSize.z;", precision, GetVariableNameForSlot(OutputSlotWId), GetSlotValue(TextureInputId, generationMode)), true); |
|||
visitor.AddShaderChunk(string.Format("{0}2 {1} = {2}_TexelSize.w;", precision, GetVariableNameForSlot(OutputSlotHId), GetSlotValue(TextureInputId, generationMode)), true); |
|||
} |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel, ShaderStageCapability stageCapability) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ab454fbbbc9f31d4083c178cf885c672 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 24b10579e42f5f845a9f2ab79f921476 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 22ede5ad2c67e3148bf5bd9fa48b2734 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef UNITY_ATMOSPHERIC_SCATTERING_INCLUDED |
|||
#define UNITY_ATMOSPHERIC_SCATTERING_INCLUDED |
|||
|
|||
#include "CoreRP/ShaderLibrary/VolumeRendering.hlsl" |
|||
#include "CoreRP/ShaderLibrary/Filtering.hlsl" |
|||
|
|||
#include "AtmosphericScattering.cs.hlsl" |
|||
#include "HDRP/ShaderVariables.hlsl" |
|||
#include "HDRP/Lighting/Volumetrics/VBuffer.hlsl" |
|||
|
|||
#ifdef DEBUG_DISPLAY |
|||
#include "HDRP/Debug/DebugDisplay.hlsl" |
|||
#endif |
|||
|
|||
float3 GetFogColor(PositionInputs posInput) |
|||
{ |
|||
if (_FogColorMode == FOGCOLORMODE_CONSTANT_COLOR) |
|||
{ |
|||
return _FogColor.rgb; |
|||
} |
|||
else if (_FogColorMode == FOGCOLORMODE_SKY_COLOR) |
|||
{ |
|||
// Based on Uncharted 4 "Mip Sky Fog" trick: http://advances.realtimerendering.com/other/2016/naughty_dog/NaughtyDog_TechArt_Final.pdf |
|||
float mipLevel = (1.0 - _MipFogMaxMip * saturate((posInput.linearDepth - _MipFogNear) / (_MipFogFar - _MipFogNear))) * _SkyTextureMipCount; |
|||
float3 dir = -GetWorldSpaceNormalizeViewDir(posInput.positionWS); |
|||
return SampleSkyTexture(dir, mipLevel).rgb; |
|||
} |
|||
else // Should not be possible. |
|||
return float3(0.0, 0.0, 0.0); |
|||
} |
|||
|
|||
// Returns fog color in rgb and fog factor in alpha. |
|||
float4 EvaluateAtmosphericScattering(PositionInputs posInput) |
|||
{ |
|||
float3 fogColor = 0; |
|||
float fogFactor = 0; |
|||
|
|||
#ifdef DEBUG_DISPLAY |
|||
// Don't sample atmospheric scattering when lighting debug more are enabled so fog is not visible |
|||
if (_DebugLightingMode == DEBUGLIGHTINGMODE_DIFFUSE_LIGHTING || _DebugLightingMode == DEBUGLIGHTINGMODE_SPECULAR_LIGHTING || _DebugLightingMode == DEBUGLIGHTINGMODE_LUX_METER) |
|||
return float4(0, 0, 0, 0); |
|||
#endif |
|||
|
|||
switch (_AtmosphericScatteringType) |
|||
{ |
|||
case FOGTYPE_LINEAR: |
|||
{ |
|||
fogColor = GetFogColor(posInput); |
|||
fogFactor = _FogDensity * saturate((posInput.linearDepth - _LinearFogStart) * _LinearFogOneOverRange) * saturate((_LinearFogHeightEnd - GetAbsolutePositionWS(posInput.positionWS).y) * _LinearFogHeightOneOverRange); |
|||
break; |
|||
} |
|||
case FOGTYPE_EXPONENTIAL: |
|||
{ |
|||
fogColor = GetFogColor(posInput); |
|||
float distance = length(GetWorldSpaceViewDir(posInput.positionWS)); |
|||
float fogHeight = max(0.0, GetAbsolutePositionWS(posInput.positionWS).y - _ExpFogBaseHeight); |
|||
fogFactor = _FogDensity * TransmittanceHomogeneousMedium(_ExpFogHeightAttenuation, fogHeight) * (1.0f - TransmittanceHomogeneousMedium(1.0f / _ExpFogDistance, distance)); |
|||
break; |
|||
} |
|||
case FOGTYPE_VOLUMETRIC: |
|||
{ |
|||
float4 volFog = SampleVolumetricLighting(TEXTURE3D_PARAM(_VBufferLighting, s_linear_clamp_sampler), |
|||
posInput.positionNDC, |
|||
posInput.linearDepth, |
|||
_VBufferResolution, |
|||
_VBufferSliceCount.xy, |
|||
_VBufferUvScaleAndLimit.xy, |
|||
_VBufferUvScaleAndLimit.zw, |
|||
_VBufferDepthEncodingParams, |
|||
_VBufferDepthDecodingParams, |
|||
true, true); |
|||
|
|||
fogFactor = 1 - volFog.a; // Opacity from transmittance |
|||
fogColor = volFog.rgb * min(rcp(fogFactor), FLT_MAX); // Un-premultiply, clamp to avoid (0 * INF = NaN) |
|||
break; |
|||
} |
|||
} |
|||
|
|||
return float4(fogColor, fogFactor); |
|||
} |
|||
|
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: 14cc5dd8542c537438a7b0282cbc2a6f |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 32f724728cf19904291226f239ec16f0 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifdef SHADER_VARIABLES_INCLUDE_CB |
|||
int _AtmosphericScatteringType; |
|||
// Common |
|||
float _FogColorMode; |
|||
float4 _FogColorDensity; // color in rgb, density in alpha |
|||
float4 _MipFogParameters; |
|||
// Linear fog |
|||
float4 _LinearFogParameters; |
|||
// Exp fog |
|||
float4 _ExpFogParameters; |
|||
|
|||
float _SkyTextureMipCount; |
|||
#else |
|||
TEXTURE3D(_VBufferLighting); |
|||
TEXTURECUBE(_SkyTexture); |
|||
|
|||
#define _MipFogNear _MipFogParameters.x |
|||
#define _MipFogFar _MipFogParameters.y |
|||
#define _MipFogMaxMip _MipFogParameters.z |
|||
|
|||
#define _FogDensity _FogColorDensity.w |
|||
#define _FogColor _FogColorDensity |
|||
|
|||
#define _LinearFogStart _LinearFogParameters.x |
|||
#define _LinearFogOneOverRange _LinearFogParameters.y |
|||
#define _LinearFogHeightEnd _LinearFogParameters.z |
|||
#define _LinearFogHeightOneOverRange _LinearFogParameters.w |
|||
|
|||
#define _ExpFogDistance _ExpFogParameters.x |
|||
#define _ExpFogBaseHeight _ExpFogParameters.y |
|||
#define _ExpFogHeightAttenuation _ExpFogParameters.z |
|||
#endif |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 08e9d756e08b10445b237c82ec588e47 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c78e4b79bf403f44f87fc4f81662898e |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifdef SHADER_VARIABLES_INCLUDE_CB |
|||
// Buffer pyramid |
|||
float4 _ColorPyramidSize; // (x,y) = Actual Pixel Size, (z,w) = 1 / Actual Pixel Size |
|||
float4 _DepthPyramidSize; // (x,y) = Actual Pixel Size, (z,w) = 1 / Actual Pixel Size |
|||
float4 _CameraMotionVectorsSize; // (x,y) = Actual Pixel Size, (z,w) = 1 / Actual Pixel Size |
|||
float4 _ColorPyramidScale; // (x,y) = Screen Scale, z = lod count, w = unused |
|||
float4 _DepthPyramidScale; // (x,y) = Screen Scale, z = lod count, w = unused |
|||
float4 _CameraMotionVectorsScale; // (x,y) = Screen Scale, z = lod count, w = unused |
|||
|
|||
// Screen space lighting |
|||
float _SSRefractionInvScreenWeightDistance; // Distance for screen space smoothstep with fallback |
|||
float _SSReflectionInvScreenWeightDistance; // Distance for screen space smoothstep with fallback |
|||
int _SSReflectionEnabled; |
|||
int _SSReflectionProjectionModel; |
|||
int _SSReflectionHiZRayMarchBehindObject; |
|||
int _SSRefractionHiZRayMarchBehindObject; |
|||
|
|||
// Ambiant occlusion |
|||
float4 _AmbientOcclusionParam; // xyz occlusion color, w directLightStrenght |
|||
#else |
|||
// Rough refraction texture |
|||
// Color pyramid (width, height, lodcount, Unused) |
|||
TEXTURE2D(_ColorPyramidTexture); |
|||
// Depth pyramid (width, height, lodcount, Unused) |
|||
TEXTURE2D(_DepthPyramidTexture); |
|||
// Ambient occlusion texture |
|||
TEXTURE2D(_AmbientOcclusionTexture); |
|||
TEXTURE2D(_CameraMotionVectorsTexture); |
|||
#endif |
|
|||
using UnityEngine; |
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math", "Wave", "Noise Sine Wave")] |
|||
class NoiseSineWaveNode : CodeFunctionNode |
|||
{ |
|||
public NoiseSineWaveNode() |
|||
{ |
|||
name = "Noise Sine Wave"; |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Noise-Sine-Wave-Node"; } |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("NoiseSineWave", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string NoiseSineWave( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None, -0.5f, 0.5f, 1, 1)] Vector2 MinMax, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
{precision} sinIn = sin(In); |
|||
{precision} sinInOffset = sin(In + 1.0); |
|||
{precision} randomno = frac(sin((sinIn - sinInOffset) * (12.9898 + 78.233))*43758.5453); |
|||
{precision} noise = lerp(MinMax.x, MinMax.y, randomno); |
|||
Out = sinIn + noise; |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ee4eb305b2f727b47bbac99de0772c18 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math", "Wave", "Sawtooth Wave")] |
|||
class SawtoothWaveNode : CodeFunctionNode |
|||
{ |
|||
public SawtoothWaveNode() |
|||
{ |
|||
name = "Sawtooth Wave"; |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sawtooth-Wave-Node"; } |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("SawtoothWave", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string SawtoothWave( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = 2 * (In - floor(0.5 + In)); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ebd730c94c4864d4f84382b17d49447f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math", "Wave", "Square Wave")] |
|||
class SquareWaveNode : CodeFunctionNode |
|||
{ |
|||
public SquareWaveNode() |
|||
{ |
|||
name = "Square Wave"; |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Square-Wave-Node"; } |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("SquareWave", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string SquareWave( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = 1.0 - 2.0 * round(frac(In)); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0f19d607a01d3694e84c04c8eab68f9a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math", "Wave", "Triangle Wave")] |
|||
class TriangleWaveNode : CodeFunctionNode |
|||
{ |
|||
public TriangleWaveNode() |
|||
{ |
|||
name = "Triangle Wave"; |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Triangle-Wave-Node"; } |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("TriangleWave", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string TriangleWave( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = 2.0 * abs( 2 * (In - floor(0.5 + In)) ) - 1.0; |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6fb595d58ba0d304cac4cf188f4e8282 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: d522828bc0314e14cb6faa4291bb64da |
|||
folderAsset: yes |
|||
timeCreated: 1507718579 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 326059e48e5735e46a98047eff4f0295 |
|||
timeCreated: 1507736585 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7ed7d57e43fdd874ab5d047358e9fbe1 |
|||
timeCreated: 1508156067 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef UNITY_SKY_VARIABLES_INCLUDED |
|||
#define UNITY_SKY_VARIABLES_INCLUDED |
|||
|
|||
TEXTURECUBE(_SkyTexture); |
|||
|
|||
CBUFFER_START(SkyParameters) |
|||
float _SkyTextureMipCount; |
|||
CBUFFER_END |
|||
|
|||
float4 SampleSkyTexture(float3 texCoord) |
|||
{ |
|||
return SAMPLE_TEXTURECUBE(_SkyTexture, s_trilinear_clamp_sampler, texCoord); |
|||
} |
|||
|
|||
float4 SampleSkyTexture(float3 texCoord, float lod) |
|||
{ |
|||
return SAMPLE_TEXTURECUBE_LOD(_SkyTexture, s_trilinear_clamp_sampler, texCoord, lod); |
|||
} |
|||
|
|||
#endif |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue