浏览代码

Merge pull request #1535 from Unity-Technologies/sg/error-for-incompatible-pipeline

Warn about lack of compatible render pipeline asset
/main
GitHub 6 年前
当前提交
86a4970b
共有 13 个文件被更改,包括 60 次插入14 次删除
  1. 9
      com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRSubShader.cs
  2. 9
      com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitSubShader.cs
  3. 2
      com.unity.render-pipelines.high-definition/package.json
  4. 7
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs
  5. 6
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightUnlitSubShader.cs
  6. 2
      com.unity.render-pipelines.lightweight/package.json
  7. 2
      com.unity.shadergraph/CHANGELOG.md
  8. 2
      com.unity.shadergraph/Editor/Data/MasterNodes/ISubShader.cs
  9. 2
      com.unity.shadergraph/Editor/Data/Nodes/IMasterNode.cs
  10. 15
      com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs
  11. 11
      com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs
  12. 5
      com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs
  13. 2
      com.unity.shadergraph/package.json

9
com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRSubShader.cs


using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

subShader.AddShaderChunk("}", true);
return subShader.GetShaderString(0);
}
public bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset)
{
return renderPipelineAsset is HDRenderPipelineAsset;
}
}
}

9
com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitSubShader.cs


using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

subShader.AddShaderChunk("}", true);
return subShader.GetShaderString(0);
}
public bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset)
{
return renderPipelineAsset is HDRenderPipelineAsset;
}
}
}

2
com.unity.render-pipelines.high-definition/package.json


"dependencies": {
"com.unity.postprocessing": "2.0.7-preview",
"com.unity.render-pipelines.core": "3.0.0-preview",
"com.unity.shadergraph": "3.0.0-preview"
"com.unity.shadergraph": "4.0.0-preview"
}
}

7
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs


using System.Linq;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
namespace UnityEditor.Experimental.Rendering.LightweightPipeline
{

}
return subShader.ToString();
}
public bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset)
{
return renderPipelineAsset is LightweightPipelineAsset;
}
static string GetTemplatePath(string templateName)

6
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightUnlitSubShader.cs


using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Experimental.Rendering.LightweightPipeline;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph;

}
return subShader.ToString();
}
public bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset)
{
return renderPipelineAsset is LightweightPipelineAsset;
}
static string GetTemplatePath(string templateName)

2
com.unity.render-pipelines.lightweight/package.json


"dependencies": {
"com.unity.postprocessing": "2.0.7-preview",
"com.unity.render-pipelines.core": "3.0.0-preview",
"com.unity.shadergraph": "3.0.0-preview"
"com.unity.shadergraph": "4.0.0-preview"
}
}

2
com.unity.shadergraph/CHANGELOG.md


- Deserialization of subgraphs now works correctly.
- Sub graphs are now suffixed with (sub), so you can tell them apart from other nodes.
- The preview of a node does not obstruct the selection outliner anymore.
- If the current render pipeline is not compatible, master nodes now display an error badge.
- The preview shader now only considers the current render pipeline. Because of this there is less code to compile, and therefore the preview shader will compile faster.
- When you rename a shader graph or sub shader graph locally on your disk, the title of the Shader Graph window, black board, and preview also updates.

2
com.unity.shadergraph/Editor/Data/MasterNodes/ISubShader.cs


using System;
using System.Collections.Generic;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.ShaderGraph
{

bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset);
}
}

2
com.unity.shadergraph/Editor/Data/Nodes/IMasterNode.cs


public interface IMasterNode : INode
{
string GetShader(GenerationMode mode, string name, out List<PropertyCollector.TextureInfo> configuredTextures, List<string> sourceAssetDependencyPaths = null);
bool IsPipelineCompatible(IRenderPipeline renderPipeline);
bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset);
}
}

15
com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Rendering;
namespace UnityEditor.ShaderGraph
{

}
foreach (var subShader in m_SubShaders)
finalShader.AppendLines(subShader.GetSubshader(this, mode, sourceAssetDependencyPaths));
{
if (mode != GenerationMode.Preview || subShader.IsPipelineCompatible(GraphicsSettings.renderPipelineAsset))
finalShader.AppendLines(subShader.GetSubshader(this, mode, sourceAssetDependencyPaths));
}
finalShader.AppendLine(@"FallBack ""Hidden/InternalErrorShader""");
}

public bool IsPipelineCompatible(IRenderPipeline renderPipeline)
public bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset)
return true;
foreach (var subShader in m_SubShaders)
{
if (subShader.IsPipelineCompatible(GraphicsSettings.renderPipelineAsset))
return true;
}
return false;
}
public override void OnBeforeSerialize()

11
com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs


using Object = UnityEngine.Object;
using Edge = UnityEditor.Experimental.UIElements.GraphView.Edge;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
namespace UnityEditor.ShaderGraph.Drawing
{

public bool forceRedrawPreviews = false;
ColorSpace m_ColorSpace;
RenderPipelineAsset m_RenderPipelineAsset;
GraphEditorView m_GraphEditorView;

m_ColorSpace = PlayerSettings.colorSpace;
}
if (GraphicsSettings.renderPipelineAsset != m_RenderPipelineAsset)
{
graphEditorView = null;
m_RenderPipelineAsset = GraphicsSettings.renderPipelineAsset;
}
try
{
if (graphObject == null && selectedGuid != null)

assetName = asset.name.Split('/').Last()
};
m_ColorSpace = PlayerSettings.colorSpace;
m_RenderPipelineAsset = GraphicsSettings.renderPipelineAsset;
}
if (forceRedrawPreviews)

try
{
m_ColorSpace = PlayerSettings.colorSpace;
m_RenderPipelineAsset = GraphicsSettings.renderPipelineAsset;
var asset = AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(assetGuid));
if (asset == null)

5
com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs


using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.UIElements.StyleEnums;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEngine.Rendering;
using Node = UnityEditor.Experimental.UIElements.GraphView.Node;
namespace UnityEditor.ShaderGraph.Drawing

var masterNode = node as IMasterNode;
if (masterNode != null)
{
if (!masterNode.IsPipelineCompatible(RenderPipelineManager.currentPipeline))
if (!masterNode.IsPipelineCompatible(GraphicsSettings.renderPipelineAsset))
IconBadge wrongPipeline = IconBadge.CreateError("The current render pipeline is not compatible with this node preview.");
IconBadge wrongPipeline = IconBadge.CreateError("The current render pipeline is not compatible with this master node.");
Add(wrongPipeline);
VisualElement title = this.Q("title");
wrongPipeline.AttachTo(title, SpriteAlignment.LeftCenter);

2
com.unity.shadergraph/package.json


{
"name": "com.unity.shadergraph",
"description": "Shader Graph",
"version": "3.0.0-preview",
"version": "4.0.0-preview",
"unity": "2018.2",
"displayName": "Shader Graph",
"dependencies": {
正在加载...
取消
保存