Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Skip CI] Shader Graph Targets (#4940)
* Move GetShader to static utility and remove excess SubShader interfaces

* First pass preview refactor

* Fix Facesign

* Remove old code

* Move description input templates to SG package

* Remove more old code

* Update CHANGELOG.md

* Initial Targets implementation

* Pass Target reference down to generator

* Move Universal passes to Target

* Add defines to ShaderPass

* Move Preview shader pass to Target

* Add custom templates

* Add dots instancing support

* Unlit

* PBR

* HD Lit

* HD Lit Raytracing

* Decal

* Eye

* Fabric

* Hair

* StackLit

* HD Unlit

* Remove HD generation path

* First step fields rework

* First working version

* add descriptors

* rough implement struct generator

* First step fields rework

* First working version

* Update Sprite masters

* Remove old template path

* vague attempt at generating packing structs

* nevermind that didn't work

* Move field conditions to master nodes (StackLit WIP)

* Update Fields for HDRP use

* Update Fields for HDRP use

* StackLit fields

* Update StructDescriptor.cs

* interpolators correctly generate

* update mesh targets with default structs

* RenderStateOverrides for Universal

* Delete SurfaceMaterialOptions

* Apply DoubledSided field

* Remove more uneeded pass code

* base branch related changes

* temporary universal implementation

* cleanup a few todos

* Move render states to conditionals

* add todos

* Move pragmas to conditionals

* Move render states to single splice

* Move includes to conditionals

* Move required fields to one member

* Move keywords to conditionals

* Move defines to conditionals

* Updating render states (WIP)

* structs generate via ifield

interpolator functions aren't wrapped in keywords properly
$features.graph pixel and graph vertex from template aren't spliced
preview target still doesn't have all struct declarations
not everything is deleted from spliceutil
keywords not tested at all

* keyword collection works properly in generator for packed types

* preview target uses new struct generation

* gut splice util, add collection for splice commands but keyword splice commands don't work

* splice commands filter by keyword permutation but still don't compile

* delete unused code from generator

* fix missing tangent space position

* fix keyword generation for packing functions

* put that build type back where it came from or so help me

* Update all HDRP passes

* Update constructors for HDRP

* gut build type

* clean up merge conflicts

* intitial struct declaration

* First pass generation switch (remove ISubShader)

* Merge branch 'sg/targets' into sg/targets-structs

* Merge branch 'sg/targets-structs' into sg/targets-cleanup

* add field definitions to each pass

* First pass ITarget <> ITargetVariant

* HDRP c# compiles again feck yes

* fix typo in mesh and preview targets

* all master nodes in HD compile correct shaders

* gut unused resources

* merge targets-structs in

* fix missing requirement gather for view direction

* pass at raytracing support

* Change target tracking on GraphData

* Targets GUI

* first pass conditional shader pass -- doesn't compile

* Rename ITargetVariant > ITargetImplementation

* Add asset dependency paths

* update target implementation for HD

* remove subshaders

* cleanup sub shader migration

* Move generator to class instance

* Remove ShaderGenerator and SubShaderGenerator

* resolve conflict

* Update Generator.cs

* Move to full Active Fields

* Fix bitmask issues

* Fix dots instancing options

* fixes keyword whitespace in generated shader

* remove unused shader structs from preview target

* Build all pragmas from passes in HDRP

* Fix asset dependency paths

* pre and post graph includes implementation

* fix typo

* fix pbr keyword cullface indent

* fix vertex conditional field on HD master nodes

* Fix HDRP vertex port IDs

* Fix SHADERPASS inconsistency between pipelines

* fix raytracing pass commands

* fix null reference on vertex ports

* handle subgraphs when adding valid targets

* slightly cleaner subgrpah handling

* Fix PBR 2D pass includes

* Collections

* Continue Collections and clean up

* More cleanup

* Remove Subscript and IField

* Update HDRP implementations

* Fix crash and Universal Unlit includes

* Add Vfx target

* Fix URP unlit meta

* Bump importers

* Fix merge

* Fix merge

* enable custom editor overrides in generator for subshaders

* Fix preview shader generation

* Fix unit tests

* Fix HDRP raytracing target compilation

* give an early out for subshaders that should never generate in preview mode

* fix errors in shader generation for subgraph output nodes

not very clean, would like to do another pass over this before merging

* allow targets to specificy compatible render pipelines

display an error when the graph can't find a valid render pipeline compatible with active targets

* fix material graph merge error

* update stencil bit usage in hd render states

* surface gradient support

* resolve merge conflicts with bug fix pr 5515

* resolve conflict with bug fix pr 5060

XR multiview supprt in shadergraph

* update fog on transparent from pr 5479

* fix support for vertex skinning in pr 4617

* add shadow matte to hdunlit in pr 5125

* attempt at adding pathtracing pass in pr 5126

* extend collections for pass structure

* update universal field dependencies and includes

* reorg default field dependencies

* initial cleanup of hd includes (probably doesn't compile)

* more HD cleanup on includes (still won't compile)

* finish HD cleanup includes

* resolve master node merge conflict

* fix PBR tags and render state in HDRP

* hd raytracing to use conditional include declaration

* update raytracing template references

* resolve some test failures

* fix blendices order from thomasZ feedback

* cleanup keyword collections and enable alpha test in HD

* required fields to field collection

* minor HD cleanup

* raytracing subsurface pass

* strip out target selection drop down menu

* Updated renderTypeTag to HDRP ones

* fix alpha test on transparent pre and post pass

* fix distortion fields on lita nd stack lit master node

* clear error message when valid target is found

* Revert "clear error message when valid target is found"

This reverts commit 41a5c5e7bd99a6d57493ce0d018399b2c8ccb971.

* fix alpha test and double sided on PBR graph

* properly clear the error message this time

* Fixed depth post-pass and distortion write mask

* fix universal shadow cascade

* forward port case 1215767

* forward port case 1218714

cull face must be defined last

* blend state tests pass

* fix unlit shadow matte requirements

* small cleanup on HDRP

* Revert "small cleanup on HDRP"

This reverts commit 8fbae7414297648664af8feeba8d25c782c76585.

* delete unused raytracing pass

* rename internal folder to generation

* rename codegen folder to processors

* move preview and processors to generation

* move templates to generation

* update tempalte file path reference

* move targets code to shadergraph namespace

* generation API to internal

Co-authored-by: Alex Lindman <39529353+alindmanUnity@users.noreply.github.com>
Co-authored-by: Peter Bay Bastian <pbbastian@users.noreply.github.com>
Co-authored-by: Antoine Lelievre <alelievr@student.42.fr>
  • Loading branch information
4 people committed Mar 4, 2020
1 parent 9090805 commit db4dddf
Show file tree
Hide file tree
Showing 352 changed files with 14,407 additions and 16,442 deletions.
Expand Up @@ -10,14 +10,14 @@
using UnityEngine;
using UnityEngine.UIElements;
using UnityEngine.Rendering.HighDefinition;

using UnityEditor.Rendering.HighDefinition.ShaderGraph;

namespace UnityEditor.Rendering.HighDefinition
{
[Serializable]
[Title("Master", "Decal (HDRP)")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.DecalMasterNode")]
class DecalMasterNode : MasterNode<IDecalSubShader>, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class DecalMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionSlotName = "Vertex Position";
public const string PositionSlotDisplayName = "Vertex Position";
Expand Down Expand Up @@ -62,6 +62,21 @@ class DecalMasterNode : MasterNode<IDecalSubShader>, IMayRequirePosition, IMayRe
public const string VertexTangentSlotName = "Vertex Tangent";
public const int VertexTangentSlotID = 11;

[SerializeField]
SurfaceType m_SurfaceType;

public SurfaceType surfaceType
{
get { return m_SurfaceType; }
set
{
if (m_SurfaceType == value)
return;

m_SurfaceType = value;
Dirty(ModificationScope.Graph);
}
}

// Just for convenience of doing simple masks. We could run out of bits of course.
[Flags]
Expand Down Expand Up @@ -202,11 +217,50 @@ public sealed override void UpdateNodeAfterDeserialization()
RemoveSlotsNameNotMatching(validSlots, true);
}

protected override VisualElement CreateCommonSettingsElement()
public VisualElement CreateSettingsElement()
{
return new DecalSettingsView(this);
}

public string renderQueueTag
{
get
{
return HDRenderQueue.GetShaderTagValue(
HDRenderQueue.ChangeType(HDRenderQueue.RenderQueueType.Opaque, drawOrder, false));
}
}

public string renderTypeTag => HDRenderTypeTags.Opaque.ToString();

public ConditionalField[] GetConditionalFields(PassDescriptor pass)
{
return new ConditionalField[]
{
// Features
new ConditionalField(Fields.GraphVertex, IsSlotConnected(PositionSlotId) ||
IsSlotConnected(VertexNormalSlotID) ||
IsSlotConnected(VertexTangentSlotID)),
new ConditionalField(Fields.GraphPixel, true),

// Material
new ConditionalField(HDFields.AffectsAlbedo, affectsAlbedo.isOn),
new ConditionalField(HDFields.AffectsNormal, affectsNormal.isOn),
new ConditionalField(HDFields.AffectsEmission, affectsEmission.isOn),
new ConditionalField(HDFields.AffectsMetal, affectsMetal.isOn),
new ConditionalField(HDFields.AffectsAO, affectsAO.isOn),
new ConditionalField(HDFields.AffectsSmoothness, affectsSmoothness.isOn),
new ConditionalField(HDFields.AffectsMaskMap, affectsSmoothness.isOn || affectsMetal.isOn || affectsAO.isOn),
new ConditionalField(HDFields.DecalDefault, affectsAlbedo.isOn || affectsNormal.isOn || affectsMetal.isOn ||
affectsAO.isOn || affectsSmoothness.isOn ),
};
}

public void ProcessPreviewMaterial(Material material)
{

}

public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability)
{
List<MaterialSlot> slots = new List<MaterialSlot>();
Expand Down Expand Up @@ -381,5 +435,21 @@ public int drawOrder
Dirty(ModificationScope.Graph);
}
}

[SerializeField]
bool m_DOTSInstancing = false;

public ToggleData dotsInstancing
{
get { return new ToggleData(m_DOTSInstancing); }
set
{
if (m_DOTSInstancing == value.isOn)
return;

m_DOTSInstancing = value.isOn;
Dirty(ModificationScope.Graph);
}
}
}
}

0 comments on commit db4dddf

Please sign in to comment.