-
Notifications
You must be signed in to change notification settings - Fork 855
Reorganize HDRP shader targets to share code between them (part 1) #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
elizabeth-legros
merged 14 commits into
sg/master-stack
from
HDRP/stack-targets-refactor
May 27, 2020
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
60a327c
Moved sub-target upgrade code to migration files and refactored the H…
alelievr 53c2f9a
Merge branch 'sg/master-stack' into HDRP/stack-targets-refactor
alelievr 64d3581
Made property row labels flexible
alelievr 021e99d
Fixed indent level of propertyRow
alelievr f3cf3d5
Added more control to indent level and clear foldout
alelievr abf7d0e
Merge remote-tracking branch 'origin/sg/flexible-property-row' into H…
alelievr 2d9adfd
Refactored inspector GUI for HD lit and hair master node
alelievr 3ac3ae8
Merge branch 'sg/master-stack' into HDRP/stack-targets-refactor
alelievr fe1c534
Fixed compilation
alelievr 5d37b43
Moved fabric subtarget GUI to new system
alelievr 1ccbcba
Converted Eye and stacklit settings to new GUI system
alelievr 026cc02
Finished decal and unlit inspector settings
alelievr 70216ed
Fixed bent normal compilation issue
alelievr c8aa459
Rename file EyeSurfaceOptionPropertyBlock.cs
sebastienlagarde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
....render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPropertyBlock.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine.Rendering; | ||
using UnityEngine.Rendering.HighDefinition; | ||
using UnityEditor.ShaderGraph; | ||
using UnityEngine.UIElements; | ||
using UnityEditor.UIElements; | ||
using UnityEngine; | ||
|
||
// We share the name of the properties in the UI to avoid duplication | ||
using static UnityEditor.Rendering.HighDefinition.DecalSurfaceInputsUIBlock.Styles; | ||
using static UnityEditor.Rendering.HighDefinition.SurfaceOptionUIBlock.Styles; | ||
|
||
namespace UnityEditor.Rendering.HighDefinition.ShaderGraph | ||
{ | ||
class DecalPropertyBlock : SubTargetPropertyBlock | ||
{ | ||
class Styles | ||
{ | ||
public static GUIContent normalModeText = new GUIContent("Affect Normal", "TODO"); | ||
public static GUIContent affectEmissionText = new GUIContent("Affect Emission", "TODO"); | ||
} | ||
|
||
DecalData decalData; | ||
|
||
protected override string title => "Surface Settings"; | ||
protected override int foldoutIndex => 4; | ||
|
||
public DecalPropertyBlock(DecalData decalData) => this.decalData = decalData; | ||
|
||
protected override void CreatePropertyGUI() | ||
{ | ||
AddProperty(albedoModeText, () => decalData.affectsAlbedo, (newValue) => decalData.affectsAlbedo = newValue); | ||
AddProperty(Styles.normalModeText, () => decalData.affectsNormal, (newValue) => decalData.affectsNormal = newValue); | ||
AddProperty(affectMetalText, () => decalData.affectsMetal, (newValue) => decalData.affectsMetal = newValue); | ||
AddProperty(affectAmbientOcclusionText, () => decalData.affectsAO, (newValue) => decalData.affectsAO = newValue); | ||
AddProperty(affectSmoothnessText, () => decalData.affectsSmoothness, (newValue) => decalData.affectsSmoothness = newValue); | ||
AddProperty(Styles.affectEmissionText, () => decalData.affectsEmission, (newValue) => decalData.affectsEmission = newValue); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ic/ShaderGraph/FabricSettingsView.cs.meta → ...al/ShaderGraph/DecalPropertyBlock.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
84 changes: 0 additions & 84 deletions
84
...y.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSettingsView.cs
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
...r-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.Migration.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using UnityEngine; | ||
using UnityEngine.Rendering.HighDefinition; | ||
using UnityEditor.ShaderGraph; | ||
using UnityEditor.ShaderGraph.Internal; | ||
using UnityEditor.Graphing; | ||
using UnityEditor.ShaderGraph.Legacy; | ||
using UnityEditor.Rendering.HighDefinition.ShaderGraph.Legacy; | ||
using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; | ||
using static UnityEditor.Rendering.HighDefinition.HDShaderUtils; | ||
|
||
namespace UnityEditor.Rendering.HighDefinition.ShaderGraph | ||
{ | ||
sealed partial class DecalSubTarget : HDSubTarget, ILegacyTarget, IRequiresData<DecalData> | ||
{ | ||
public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary<BlockFieldDescriptor, int> blockMap) | ||
{ | ||
blockMap = null; | ||
if(!(masterNode is DecalMasterNode1 decalMasterNode)) | ||
return false; | ||
|
||
// Set data | ||
systemData.surfaceType = (SurfaceType)decalMasterNode.m_SurfaceType; | ||
systemData.dotsInstancing = decalMasterNode.m_DOTSInstancing; | ||
decalData.affectsMetal = decalMasterNode.m_AffectsMetal; | ||
decalData.affectsAO = decalMasterNode.m_AffectsAO; | ||
decalData.affectsSmoothness = decalMasterNode.m_AffectsSmoothness; | ||
decalData.affectsAlbedo = decalMasterNode.m_AffectsAlbedo; | ||
decalData.affectsNormal = decalMasterNode.m_AffectsNormal; | ||
decalData.affectsEmission = decalMasterNode.m_AffectsEmission; | ||
decalData.drawOrder = decalMasterNode.m_DrawOrder; | ||
target.customEditorGUI = decalMasterNode.m_OverrideEnabled ? decalMasterNode.m_ShaderGUIOverride : ""; | ||
|
||
// Convert SlotMask to BlockMap entries | ||
var blockMapLookup = new Dictionary<DecalMasterNode1.SlotMask, BlockFieldDescriptor>() | ||
{ | ||
{ DecalMasterNode1.SlotMask.Position, BlockFields.VertexDescription.Position }, | ||
{ DecalMasterNode1.SlotMask.VertexNormal, BlockFields.VertexDescription.Normal }, | ||
{ DecalMasterNode1.SlotMask.VertexTangent, BlockFields.VertexDescription.Tangent }, | ||
{ DecalMasterNode1.SlotMask.Albedo, BlockFields.SurfaceDescription.BaseColor }, | ||
{ DecalMasterNode1.SlotMask.AlphaAlbedo, BlockFields.SurfaceDescription.Alpha }, | ||
{ DecalMasterNode1.SlotMask.Normal, BlockFields.SurfaceDescription.NormalTS }, | ||
{ DecalMasterNode1.SlotMask.AlphaNormal, HDBlockFields.SurfaceDescription.NormalAlpha }, | ||
{ DecalMasterNode1.SlotMask.Metallic, BlockFields.SurfaceDescription.Metallic }, | ||
{ DecalMasterNode1.SlotMask.Occlusion, BlockFields.SurfaceDescription.Occlusion }, | ||
{ DecalMasterNode1.SlotMask.Smoothness, BlockFields.SurfaceDescription.Smoothness }, | ||
{ DecalMasterNode1.SlotMask.AlphaMAOS, HDBlockFields.SurfaceDescription.MAOSAlpha }, | ||
{ DecalMasterNode1.SlotMask.Emission, BlockFields.SurfaceDescription.Emission }, | ||
}; | ||
|
||
// Set blockmap | ||
blockMap = new Dictionary<BlockFieldDescriptor, int>(); | ||
foreach(DecalMasterNode1.SlotMask slotMask in Enum.GetValues(typeof(DecalMasterNode1.SlotMask))) | ||
{ | ||
if(decalMasterNode.MaterialTypeUsesSlotMask(slotMask)) | ||
{ | ||
if(!blockMapLookup.TryGetValue(slotMask, out var blockFieldDescriptor)) | ||
continue; | ||
|
||
var slotId = Mathf.Log((int)slotMask, 2); | ||
blockMap.Add(blockFieldDescriptor, (int)slotId); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...cal/ShaderGraph/DecalSettingsView.cs.meta → ...derGraph/DecalSubTarget.Migration.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.