initial commit

This commit is contained in:
Jo 2025-01-07 02:06:59 +01:00
parent 6715289efe
commit 788c3389af
37645 changed files with 2526849 additions and 80 deletions

View file

@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace UnityEditor.ShaderGraph
{
internal class AdditionalCommandDescriptor
{
public string token { get; }
public string content { get; }
public AdditionalCommandDescriptor(string token, string content)
{
this.token = token;
this.content = content;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 443389252e1f464fb537873630611201
timeCreated: 1607706972

View file

@ -0,0 +1,56 @@
using System;
namespace UnityEditor.ShaderGraph
{
internal class BlockFieldDescriptor : FieldDescriptor
{
public string displayName { get; }
public IControl control { get; }
public ShaderStage shaderStage { get; }
public bool isHidden { get; }
public bool isUnknown { get; }
public bool isCustom { get; }
internal string path { get; set; }
public BlockFieldDescriptor(string tag, string referenceName, string define, IControl control, ShaderStage shaderStage, bool isHidden = false, bool isUnknown = false, bool isCustom = false)
: base(tag, referenceName, define)
{
this.displayName = referenceName;
this.control = control;
this.shaderStage = shaderStage;
this.isHidden = isHidden;
this.isUnknown = isUnknown;
this.isCustom = isCustom;
}
public BlockFieldDescriptor(string tag, string referenceName, string displayName, string define, IControl control, ShaderStage shaderStage, bool isHidden = false, bool isUnknown = false, bool isCustom = false)
: base(tag, referenceName, define)
{
this.displayName = displayName;
this.control = control;
this.shaderStage = shaderStage;
this.isHidden = isHidden;
this.isUnknown = isUnknown;
this.isCustom = isCustom;
}
}
// TODO: This exposes the MaterialSlot API
// TODO: This needs to be removed but is currently required by HDRP for DiffusionProfileInputMaterialSlot
internal class CustomSlotBlockFieldDescriptor : BlockFieldDescriptor
{
public Func<MaterialSlot> createSlot;
public CustomSlotBlockFieldDescriptor(string tag, string referenceName, string define, Func<MaterialSlot> createSlot)
: base(tag, referenceName, define, null, ShaderStage.Fragment)
{
this.createSlot = createSlot;
}
public CustomSlotBlockFieldDescriptor(string tag, string referenceName, string displayName, string define, Func<MaterialSlot> createSlot)
: base(tag, referenceName, displayName, define, null, ShaderStage.Fragment)
{
this.createSlot = createSlot;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 82f47029c21684be390696599c52fb76
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,54 @@
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal class FieldDescriptor
{
// Default
public string tag { get; }
public string name { get; }
public string define { get; }
public string interpolation { get; }
// StructField
public string type { get; }
public int vectorCount { get; }
public string semantic { get; }
public string preprocessor { get; }
public StructFieldOptions subscriptOptions { get; }
public FieldDescriptor(string tag, string name, string define)
{
this.tag = tag;
this.name = name;
this.define = define;
}
public FieldDescriptor(string tag, string name, string define, ShaderValueType type,
string semantic = "", string preprocessor = "", StructFieldOptions subscriptOptions = StructFieldOptions.Static, string interpolation = "")
{
this.tag = tag;
this.name = name;
this.define = define;
this.type = type.ToShaderString();
this.vectorCount = type.GetVectorCount();
this.semantic = semantic;
this.preprocessor = preprocessor;
this.interpolation = interpolation;
this.subscriptOptions = subscriptOptions;
}
public FieldDescriptor(string tag, string name, string define, string type,
string semantic = "", string preprocessor = "", StructFieldOptions subscriptOptions = StructFieldOptions.Static, string interpolation = "")
{
this.tag = tag;
this.name = name;
this.define = define;
this.type = type;
this.vectorCount = 0;
this.semantic = semantic;
this.preprocessor = preprocessor;
this.interpolation = interpolation;
this.subscriptOptions = subscriptOptions;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f5db19d167675764da0c07a0fb031d9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,49 @@
using System;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
[Serializable]
internal class IncludeDescriptor : IConditional
{
public IncludeDescriptor(string guid, string path, IncludeLocation location, FieldCondition[] fieldConditions)
{
_guid = guid;
_path = path;
_location = location;
this.fieldConditions = fieldConditions;
}
[SerializeField]
string _guid;
public string guid => _guid;
// NOTE: this path is NOT guaranteed to be correct -- it's only the path that was given to us when this descriptor was constructed.
// if the file was moved, it may not be correct. use the GUID to get the current REAL path via AssetDatabase.GUIDToAssetPath
[SerializeField]
string _path;
public string path => _path;
[SerializeField]
IncludeLocation _location;
public IncludeLocation location => _location;
// NOTE: this is not serialized at the moment.. as it's not needed.
// (serialization only used for subgraph includes, coming from nodes, which can't have conditions)
public FieldCondition[] fieldConditions { get; }
public string value
{
get
{
// we must get the path from asset database to ensure it is correct after file moves
var realPath = AssetDatabase.GUIDToAssetPath(guid);
if (string.IsNullOrEmpty(realPath))
return $"// missing include file: {path} ({guid})";
else
return $"#include \"{realPath}\"";
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5c3e582d15e186547aa916699e3bfb34
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,26 @@
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal struct KeywordDescriptor
{
public string displayName;
public string referenceName;
public KeywordType type;
public KeywordDefinition definition;
public KeywordScope scope;
public KeywordShaderStage stages;
public int value;
public KeywordEntry[] entries;
public void AppendKeywordDeclarationStrings(ShaderStringBuilder builder)
{
if (definition != KeywordDefinition.Predefined)
{
if (type == KeywordType.Boolean)
KeywordUtil.GenerateBooleanKeywordPragmaStrings(referenceName, definition, scope, stages, str => builder.AppendLine(str));
else
KeywordUtil.GenerateEnumKeywordPragmaStrings(referenceName, definition, scope, stages, entries, str => builder.AppendLine(str));
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: be7dc61bbad850044be1020424c0d22c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,39 @@
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal struct PassDescriptor
{
// Definition
public string displayName;
public string referenceName;
public string lightMode;
public bool useInPreview;
public bool virtualTextureFeedback;
// Templates
public string passTemplatePath;
public string[] sharedTemplateDirectories;
// Port mask
public BlockFieldDescriptor[] validVertexBlocks;
public BlockFieldDescriptor[] validPixelBlocks;
// Collections
public StructCollection structs;
public FieldCollection requiredFields;
public DependencyCollection fieldDependencies;
public RenderStateCollection renderStates;
public PragmaCollection pragmas;
public DefineCollection defines;
public KeywordCollection keywords;
public IncludeCollection includes;
public AdditionalCommandCollection additionalCommands;
public CustomInterpSubGen.Collection customInterpolators;
// Methods
public bool Equals(PassDescriptor other)
{
return referenceName == other.referenceName;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ff52c01a22cf93409b31a2bf5a73fea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,42 @@
using System.Linq;
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal struct PragmaDescriptor
{
public string value;
}
[GenerationAPI]
internal static class Pragma
{
static string GetPlatformList(Platform[] platforms)
{
var rendererStrings = platforms.Select(x => x.ToShaderString());
return string.Join(" ", rendererStrings);
}
public static PragmaDescriptor Target(ShaderModel value) => new PragmaDescriptor { value = $"target {value.ToShaderString()}" };
public static PragmaDescriptor Vertex(string value) => new PragmaDescriptor { value = $"vertex {value}" };
public static PragmaDescriptor Fragment(string value) => new PragmaDescriptor { value = $"fragment {value}" };
public static PragmaDescriptor Geometry(string value) => new PragmaDescriptor { value = $"geometry {value}" };
public static PragmaDescriptor Hull(string value) => new PragmaDescriptor { value = $"hull {value}" };
public static PragmaDescriptor Domain(string value) => new PragmaDescriptor { value = $"domain {value}" };
public static PragmaDescriptor Raytracing(string value) => new PragmaDescriptor { value = $"raytracing {value}" };
public static PragmaDescriptor OnlyRenderers(Platform[] renderers) => new PragmaDescriptor { value = $"only_renderers {GetPlatformList(renderers)}" };
public static PragmaDescriptor NeverUseDXC(Platform[] renderers) => new PragmaDescriptor { value = $"never_use_dxc {GetPlatformList(renderers)}" };
public static PragmaDescriptor ExcludeRenderers(Platform[] renderers) => new PragmaDescriptor { value = $"exclude_renderers {GetPlatformList(renderers)}" };
public static PragmaDescriptor PreferHlslCC(Platform[] renderers) => new PragmaDescriptor { value = $"prefer_hlslcc {GetPlatformList(renderers)}" };
public static PragmaDescriptor InstancingOptions(InstancingOptions value) => new PragmaDescriptor { value = $"instancing_options {value.ToShaderString()}" };
public static PragmaDescriptor MultiCompileInstancing => new PragmaDescriptor { value = "multi_compile_instancing" };
public static PragmaDescriptor MultiCompileForwardBase => new PragmaDescriptor { value = "multi_compile_fwdbase" };
public static PragmaDescriptor MultiCompileForwardAddFullShadowsBase => new PragmaDescriptor { value = "multi_compile_fwdadd_fullshadows" };
public static PragmaDescriptor MultiCompilePrePassFinal => new PragmaDescriptor { value = "multi_compile_prepassfinal" };
public static PragmaDescriptor MultiCompileShadowCaster => new PragmaDescriptor { value = "multi_compile_shadowcaster" };
public static PragmaDescriptor DOTSInstancing => new PragmaDescriptor { value = "multi_compile _ DOTS_INSTANCING_ON" };
public static PragmaDescriptor MultiCompileFog => new PragmaDescriptor { value = "multi_compile_fog" };
public static PragmaDescriptor EditorSyncCompilation => new PragmaDescriptor { value = "editor_sync_compilation" };
public static PragmaDescriptor SkipVariants(string[] variants) => new PragmaDescriptor { value = $"skip_variants {string.Join(" ", variants)}" };
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6b8a24ec57997b4096041c3ee80b679
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,47 @@
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal enum RenderStateType
{
Cull,
Blend,
BlendOp,
ZTest,
ZWrite,
ColorMask,
ZClip,
Stencil,
AlphaToMask,
}
[GenerationAPI]
internal struct RenderStateDescriptor
{
public string value;
public RenderStateType type;
}
[GenerationAPI]
internal static class RenderState
{
public static RenderStateDescriptor Cull(Cull value) => new RenderStateDescriptor { type = RenderStateType.Cull, value = $"Cull {value}" };
public static RenderStateDescriptor Cull(string value) => new RenderStateDescriptor { type = RenderStateType.Cull, value = $"Cull {value}" };
public static RenderStateDescriptor Blend(Blend src, Blend dst) => new RenderStateDescriptor { type = RenderStateType.Blend, value = $"Blend {src} {dst}" };
public static RenderStateDescriptor Blend(string src, string dst) => new RenderStateDescriptor { type = RenderStateType.Blend, value = $"Blend {src} {dst}" };
public static RenderStateDescriptor Blend(Blend src, Blend dst, Blend alphaSrc, Blend alphaDst) => new RenderStateDescriptor { type = RenderStateType.Blend, value = $"Blend {src} {dst}, {alphaSrc} {alphaDst}" };
public static RenderStateDescriptor Blend(string src, string dst, string alphaSrc, string alphaDst) => new RenderStateDescriptor { type = RenderStateType.Blend, value = $"Blend {src} {dst}, {alphaSrc} {alphaDst}" };
public static RenderStateDescriptor Blend(string value) => new RenderStateDescriptor { type = RenderStateType.Blend, value = value };
public static RenderStateDescriptor BlendOp(BlendOp op) => new RenderStateDescriptor { type = RenderStateType.BlendOp, value = $"BlendOp {op}" };
public static RenderStateDescriptor BlendOp(string op) => new RenderStateDescriptor { type = RenderStateType.BlendOp, value = $"BlendOp {op}" };
public static RenderStateDescriptor BlendOp(BlendOp op, BlendOp opAlpha) => new RenderStateDescriptor { type = RenderStateType.BlendOp, value = $"BlendOp {op}, {opAlpha}" };
public static RenderStateDescriptor BlendOp(string op, string opAlpha) => new RenderStateDescriptor { type = RenderStateType.BlendOp, value = $"BlendOp {op}, {opAlpha}" };
public static RenderStateDescriptor ZTest(ZTest value) => new RenderStateDescriptor { type = RenderStateType.ZTest, value = $"ZTest {value}" };
public static RenderStateDescriptor ZTest(string value) => new RenderStateDescriptor { type = RenderStateType.ZTest, value = $"ZTest {value}" };
public static RenderStateDescriptor ZWrite(ZWrite value) => new RenderStateDescriptor { type = RenderStateType.ZWrite, value = $"ZWrite {value}" };
public static RenderStateDescriptor ZWrite(string value) => new RenderStateDescriptor { type = RenderStateType.ZWrite, value = $"ZWrite {value}" };
public static RenderStateDescriptor ZClip(string value) => new RenderStateDescriptor { type = RenderStateType.ZClip, value = $"ZClip {value}" };
public static RenderStateDescriptor ColorMask(string value) => new RenderStateDescriptor { type = RenderStateType.ColorMask, value = $"{value}" };
public static RenderStateDescriptor AlphaToMask(string value) => new RenderStateDescriptor { type = RenderStateType.AlphaToMask, value = $"AlphaToMask {value}" };
public static RenderStateDescriptor Stencil(StencilDescriptor value) => new RenderStateDescriptor { type = RenderStateType.Stencil, value = value.ToShaderString() };
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 490eb33c72bded5438bc8d55900ad68f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal struct StencilDescriptor
{
public string WriteMask;
public string Ref;
public string Comp;
public string ZFail;
public string Fail;
public string Pass;
public string CompBack;
public string ZFailBack;
public string FailBack;
public string PassBack;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: be68c990e95a1654e9642087a2c0d2f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal struct StructDescriptor
{
public string name;
public bool packFields;
public bool populateWithCustomInterpolators;
public FieldDescriptor[] fields;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a36f03009b35b47a3ad4cc28a7f43cfe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,13 @@
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal struct SubShaderDescriptor
{
public string pipelineTag;
public string customTags;
public string renderType;
public string renderQueue;
public bool generatesPreview;
public PassCollection passes;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aff9190e7c4f0f2418d0b551cdfac094
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: