浏览代码
Pipeline specific graph functions and nodes (#1673)
Pipeline specific graph functions and nodes (#1673)
* Refactor GraphFunctions includes to per-pipeline * Add Scene Color node - And camera opaque requirements - Returns 0s in HD * Add Scene Depth node * Rename GraphFunctions.hlsl > ShaderGraphFunctions.hlsl * Update references to ShaderGraphFunctions.hlsl/main
GitHub
6 年前
当前提交
8908da09
共有 23 个文件被更改,包括 324 次插入 和 16 次删除
-
4com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRPass.template
-
4com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDSubShaderUtilities.cs
-
4com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitPassForward.template
-
7com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs
-
7com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightUnlitSubShader.cs
-
4com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRExtraPasses.template
-
2com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRForwardPass.template
-
4com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitExtraPasses.template
-
2com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitPass.template
-
10com.unity.shadergraph/Editor/Data/Graphs/ShaderGraphRequirements.cs
-
28com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl
-
19com.unity.render-pipelines.high-definition/HDRP/ShaderGraphFunctions.hlsl
-
8com.unity.render-pipelines.high-definition/HDRP/ShaderGraphFunctions.hlsl.meta
-
46com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl
-
9com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/ShaderGraphFunctions.hlsl.meta
-
18com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireCameraOpaqueTexture.cs
-
11com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireCameraOpaqueTexture.cs.meta
-
18com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireDepthTexture.cs
-
11com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireDepthTexture.cs.meta
-
51com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneColorNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneColorNode.cs.meta
-
51com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneDepthNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/SceneDepthNode.cs.meta
|
|||
#ifndef UNITY_GRAPHFUNCTIONS_HD_INCLUDED |
|||
#define UNITY_GRAPHFUNCTIONS_HD_INCLUDED |
|||
|
|||
#define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_HDSampleSceneDepth(uv); |
|||
|
|||
float shadergraph_HDSampleSceneDepth(float2 uv) |
|||
{ |
|||
#if defined(REQUIRE_DEPTH_TEXTURE) |
|||
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv); |
|||
return Linear01Depth(rawDepth, _ZBufferParams); |
|||
#endif |
|||
return 0; |
|||
} |
|||
|
|||
// Always include Shader Graph version |
|||
// Always include last to avoid double macros |
|||
#include "ShaderGraphLibrary/Functions.hlsl" |
|||
|
|||
#endif // UNITY_GRAPHFUNCTIONS_HD_INCLUDED |
|
|||
fileFormatVersion: 2 |
|||
guid: 609118ca59c7543f59f7b5967e96b463 |
|||
timeCreated: 1472205826 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef UNITY_GRAPHFUNCTIONS_LW_INCLUDED |
|||
#define UNITY_GRAPHFUNCTIONS_LW_INCLUDED |
|||
|
|||
#define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_LWSampleSceneDepth(uv); |
|||
#define SHADERGRAPH_SAMPLE_SCENE_COLOR(uv) shadergraph_LWSampleSceneColor(uv); |
|||
|
|||
#if defined(REQUIRE_DEPTH_TEXTURE) |
|||
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) |
|||
TEXTURE2D_ARRAY(_CameraDepthTexture); |
|||
#else |
|||
TEXTURE2D(_CameraDepthTexture); |
|||
#endif |
|||
SAMPLER(sampler_CameraDepthTexture); |
|||
#endif // REQUIRE_DEPTH_TEXTURE |
|||
|
|||
#if defined(REQUIRE_OPAQUE_TEXTURE) |
|||
TEXTURE2D(_CameraOpaqueTexture); |
|||
SAMPLER(sampler_CameraOpaqueTexture); |
|||
#endif // REQUIRE_OPAQUE_TEXTURE |
|||
|
|||
float shadergraph_LWSampleSceneDepth(float2 uv) |
|||
{ |
|||
#if defined(REQUIRE_DEPTH_TEXTURE) |
|||
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) |
|||
float rawDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, unity_StereoEyeIndex).r; |
|||
#else |
|||
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv); |
|||
#endif |
|||
return Linear01Depth(rawDepth, _ZBufferParams); |
|||
#endif // REQUIRE_DEPTH_TEXTURE |
|||
return 0; |
|||
} |
|||
|
|||
float3 shadergraph_LWSampleSceneColor(float2 uv) |
|||
{ |
|||
#if defined(REQUIRE_OPAQUE_TEXTURE) |
|||
return SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv); |
|||
#endif |
|||
return 0; |
|||
} |
|||
|
|||
// Always include Shader Graph version |
|||
// Always include last to avoid double macros |
|||
#include "ShaderGraphLibrary/Functions.hlsl" |
|||
|
|||
#endif // UNITY_GRAPHFUNCTIONS_LW_INCLUDED |
|
|||
fileFormatVersion: 2 |
|||
guid: 9adc879d74aec4400bbdce89ff664a05 |
|||
timeCreated: 1488965025 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public interface IMayRequireCameraOpaqueTexture |
|||
{ |
|||
bool RequiresCameraOpaqueTexture(ShaderStageCapability stageCapability = ShaderStageCapability.All); |
|||
} |
|||
|
|||
public static class MayRequireCameraOpaqueTextureExtensions |
|||
{ |
|||
public static bool RequiresCameraOpaqueTexture(this ISlot slot) |
|||
{ |
|||
var mayRequireCameraOpaqueTexture = slot as IMayRequireCameraOpaqueTexture; |
|||
return mayRequireCameraOpaqueTexture != null && mayRequireCameraOpaqueTexture.RequiresCameraOpaqueTexture(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 93fdbd040dca943cbbd42c33416450a6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public interface IMayRequireDepthTexture |
|||
{ |
|||
bool RequiresDepthTexture(ShaderStageCapability stageCapability = ShaderStageCapability.All); |
|||
} |
|||
|
|||
public static class MayRequireDepthTextureExtensions |
|||
{ |
|||
public static bool RequiresDepthTexture(this ISlot slot) |
|||
{ |
|||
var mayRequireDepthTexture = slot as IMayRequireDepthTexture; |
|||
return mayRequireDepthTexture != null && mayRequireDepthTexture.RequiresDepthTexture(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6f00cea5e23a84b5bbe1ac581ebfc64e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input", "Scene", "Scene Color")] |
|||
public sealed class SceneColorNode : CodeFunctionNode, IMayRequireCameraOpaqueTexture |
|||
{ |
|||
const string kScreenPositionSlotName = "UV"; |
|||
const string kOutputSlotName = "Out"; |
|||
|
|||
public const int ScreenPositionSlotId = 0; |
|||
public const int OutputSlotId = 1; |
|||
|
|||
public SceneColorNode() |
|||
{ |
|||
name = "Scene Color"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Scene-Color-Node"; } |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_SceneColor", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_SceneColor( |
|||
[Slot(0, Binding.ScreenPosition)] Vector3 UV, |
|||
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector3 Out) |
|||
{ |
|||
Out = Vector3.one; |
|||
return |
|||
@"
|
|||
{ |
|||
Out = SHADERGRAPH_SAMPLE_SCENE_COLOR(UV); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
public bool RequiresCameraOpaqueTexture(ShaderStageCapability stageCapability) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c4ba33edde21e400685cf0fb5c8f2551 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input", "Scene", "Scene Depth")] |
|||
public sealed class SceneDepthNode : CodeFunctionNode, IMayRequireDepthTexture |
|||
{ |
|||
const string kScreenPositionSlotName = "UV"; |
|||
const string kOutputSlotName = "Out"; |
|||
|
|||
public const int ScreenPositionSlotId = 0; |
|||
public const int OutputSlotId = 1; |
|||
|
|||
public SceneDepthNode() |
|||
{ |
|||
name = "Scene Depth"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Scene-Depth-Node"; } |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_SceneDepth", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_SceneDepth( |
|||
[Slot(0, Binding.ScreenPosition)] Vector3 UV, |
|||
[Slot(1, Binding.None, ShaderStageCapability.Fragment)] out Vector3 Out) |
|||
{ |
|||
Out = Vector3.one; |
|||
return |
|||
@"
|
|||
{ |
|||
Out = SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
public bool RequiresDepthTexture(ShaderStageCapability stageCapability) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f8e0a75d065844105a06ca48151adb7b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue