浏览代码
Merge pull request #219 from keijiro/screenspace-slot
Merge pull request #219 from keijiro/screenspace-slot
Addition of ScreenPositionSlotControlView/main
GitHub
7 年前
当前提交
d2945014
共有 9 个文件被更改,包括 121 次插入 和 35 次删除
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ScreenPositionMaterialSlot.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Filter/DitherNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
-
28MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ScreenSpaceType.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ScreenSpaceType.cs.meta
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/ScreenPositionSlotControlView.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/ScreenPositionSlotControlView.cs.meta
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public enum ScreenSpaceType |
|||
{ |
|||
Default, |
|||
Raw, |
|||
Center, |
|||
Tiled |
|||
}; |
|||
|
|||
public static class ScreenSpaceTypeExtensions |
|||
{ |
|||
public static string ToValueAsVariable(this ScreenSpaceType screenSpaceType) |
|||
{ |
|||
switch (screenSpaceType) |
|||
{ |
|||
case ScreenSpaceType.Raw: |
|||
return string.Format("IN.{0}", ShaderGeneratorNames.ScreenPosition); |
|||
case ScreenSpaceType.Center: |
|||
return string.Format("float4(IN.{0}.xy / IN.{0}.w * 2 - 1, 0, 0)", ShaderGeneratorNames.ScreenPosition); |
|||
case ScreenSpaceType.Tiled: |
|||
return string.Format("frac(float4((IN.{0}.x / IN.{0}.w * 2 - 1) * _ScreenParams.x / _ScreenParams.y, IN.{0}.y / IN.{0}.w * 2 - 1, 0, 0))", ShaderGeneratorNames.ScreenPosition); |
|||
default: |
|||
return string.Format("float4(IN.{0}.xy / IN.{0}.w, 0, 0)", ShaderGeneratorNames.ScreenPosition); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d296e8d1103ed5c49a267d57be0f4d96 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.Experimental.UIElements; |
|||
using UnityEngine.Experimental.UIElements; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing.Slots |
|||
{ |
|||
public class ScreenPositionSlotControlView : VisualElement |
|||
{ |
|||
ScreenPositionMaterialSlot m_Slot; |
|||
|
|||
public ScreenPositionSlotControlView(ScreenPositionMaterialSlot slot) |
|||
{ |
|||
m_Slot = slot; |
|||
var enumField = new EnumField(slot.screenSpaceType); |
|||
enumField.OnValueChanged(OnValueChanged); |
|||
Add(enumField); |
|||
} |
|||
|
|||
void OnValueChanged(ChangeEvent<Enum> evt) |
|||
{ |
|||
var screenSpaceType = (ScreenSpaceType)evt.newValue; |
|||
if (screenSpaceType != m_Slot.screenSpaceType) |
|||
{ |
|||
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Screen Space Type"); |
|||
m_Slot.screenSpaceType = screenSpaceType; |
|||
m_Slot.owner.Dirty(ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1774f54355319894888ab5ec90b728e7 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue