浏览代码

[Material graph]Fix preview render for 2d nodes (use correct color space.

/main
Tim Cooper 8 年前
当前提交
9398ce96
共有 2 个文件被更改,包括 50 次插入5 次删除
  1. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/MaterialGraphNode.cs
  2. 51
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Editors/MaterialGraphEditor.cs

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/MaterialGraphNode.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using RMGUI.GraphView;

name = "preview", // for USS&Flexbox
pickingMode = PickingMode.Ignore,
};
m_currentPreviewData = new List<NodePreviewData>();
}

51
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Editors/MaterialGraphEditor.cs


return DoRenderPreview(mat, mode, size, Time.realtimeSinceStartup);
}
static Mesh s_Quad;
public static Mesh quad
{
get
{
if (s_Quad != null)
return s_Quad;
var vertices = new[]
{
new Vector3(-1f, -1f, 0f),
new Vector3(1f, 1f, 0f),
new Vector3(1f, -1f, 0f),
new Vector3(-1f, 1f, 0f)
};
var uvs = new[]
{
new Vector2(0f, 0f),
new Vector2(1f, 1f),
new Vector2(1f, 0f),
new Vector2(0f, 1f)
};
var indices = new[] { 0, 1, 2, 1, 0, 3 };
s_Quad = new Mesh
{
vertices = vertices,
uv = uvs,
triangles = indices
};
s_Quad.RecalculateNormals();
s_Quad.RecalculateBounds();
return s_Quad;
}
}
public Texture DoRenderPreview(Material mat, PreviewMode mode, Rect size, float time)
{
if (mat == null || mat.shader == null)

}
else
{
EditorUtility.UpdateGlobalShaderProperties(Time.realtimeSinceStartup);
Graphics.Blit(null, mat);
m_PreviewUtility.m_Camera.projectionMatrix = Matrix4x4.identity;
EditorUtility.SetCameraAnimateMaterialsTime(m_PreviewUtility.m_Camera, time);
InternalEditorUtility.SetCustomLighting(m_PreviewUtility.m_Light, Color.black);
m_PreviewUtility.DrawMesh(quad, Matrix4x4.identity, mat, 0);
var oldFog = RenderSettings.fog;
Unsupported.SetRenderSettingsUseFogNoDirty(false);
m_PreviewUtility.m_Camera.Render();
Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
InternalEditorUtility.RemoveCustomLighting();
}
return m_PreviewUtility.EndPreview();
}
正在加载...
取消
保存