浏览代码

materialpropertyblock

/main
xingwei.zhu 5 年前
当前提交
8d230eff
共有 6 个文件被更改,包括 64 次插入12 次删除
  1. 2
      Runtime/ui/utils/basic_types/canvas_impl.cs
  2. 16
      Runtime/ui/utils/basic_types/canvas_shader.cs
  3. 5
      Runtime/ui/utils/basic_types/render_cmd.cs
  4. 1
      Runtime/ui/utils/basic_types/ui_matrix.cs
  5. 41
      Runtime/ui/utils/basic_types/canvas_shader_utils.cs
  6. 11
      Runtime/ui/utils/basic_types/canvas_shader_utils.cs.meta

2
Runtime/ui/utils/basic_types/canvas_impl.cs


cmd.properties.SetFloatArray(CmdDraw.matId, array);
}
cmdBuf.DrawMesh(cmd.meshObj, CmdDraw.idMat, cmd.material, 0, cmd.pass, cmd.properties);
cmdBuf.DrawMesh(cmd.meshObj, CmdDraw.idMat, cmd.material, 0, cmd.pass, cmd.properties.mpb);
if (cmd.layerId != null) {
cmdBuf.SetGlobalTexture(CmdDraw.texId, BuiltinRenderTextureType.None);
}

16
Runtime/ui/utils/basic_types/canvas_shader.cs


static void _getShaderPassAndProps(
PictureFlusher.RenderLayer layer, Paint paint, uiMatrix3? meshMatrix, float alpha,
out int pass, out MaterialPropertyBlock props) {
out int pass, out MaterialPropertyBlockWrapper props) {
props = new MaterialPropertyBlock();
props = ItemPoolManager.alloc<MaterialPropertyBlockWrapper>();
props.SetVector(_viewportId, viewport);
props.SetFloat(_alphaId, alpha);

var mat = _fill0Mat.getMaterial(layer.ignoreClip);
var pass = 0;
var props = new MaterialPropertyBlock();
var props = ItemPoolManager.alloc<MaterialPropertyBlockWrapper>();
props.SetVector(_viewportId, viewport);
return PictureFlusher.CmdDraw.create(

var mat = _stroke1Mat;
var pass = 0;
var props = new MaterialPropertyBlock();
var props = ItemPoolManager.alloc<MaterialPropertyBlockWrapper>();
props.SetVector(_viewportId, viewport);
return PictureFlusher.CmdDraw.create(

var mat = _stencilMat;
var pass = 0;
var props = new MaterialPropertyBlock();
var props = ItemPoolManager.alloc<MaterialPropertyBlockWrapper>();
props.SetVector(_viewportId, viewport);
return PictureFlusher.CmdDraw.create(

var mat = _stencilMat;
var pass = 1;
var props = new MaterialPropertyBlock();
var props = ItemPoolManager.alloc<MaterialPropertyBlockWrapper>();
props.SetVector(_viewportId, viewport);
return PictureFlusher.CmdDraw.create(

var mat = _stencilMat;
var pass = 2;
var props = new MaterialPropertyBlock();
var props = ItemPoolManager.alloc<MaterialPropertyBlockWrapper>();
props.SetVector(_viewportId, viewport);
return PictureFlusher.CmdDraw.create(

var mat = _filterMat;
var pass = 0;
var props = new MaterialPropertyBlock();
var props = ItemPoolManager.alloc<MaterialPropertyBlockWrapper>();
props.SetVector(_viewportId, viewport);
props.SetFloat(_mfRadiusId, radius);

5
Runtime/ui/utils/basic_types/render_cmd.cs


public uiMeshMesh mesh;
public TextBlobMesh textMesh;
public int pass;
public MaterialPropertyBlock properties;
public MaterialPropertyBlockWrapper properties;
public int? layerId;
public Material material;
public Image image; // just to keep a reference to avoid GC.

public override void clear() {
this.mesh?.dispose();
this.textMesh?.dispose();
this.properties?.dispose();
}
public CmdDraw() {

MaterialPropertyBlock properties = null, int? layerId = null, Material material = null,
MaterialPropertyBlockWrapper properties = null, int? layerId = null, Material material = null,
Image image = null, Mesh meshObj = null,
bool meshObjCreated = false) {
CmdDraw newCmd = ItemPoolManager.alloc<CmdDraw>();

1
Runtime/ui/utils/basic_types/ui_matrix.cs


return mat.kMPersp2;
default: {
return -1;
break;
}
}
}

41
Runtime/ui/utils/basic_types/canvas_shader_utils.cs


using UnityEditor.Experimental.UIElements;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public class MaterialPropertyBlockWrapper : PoolItem {
public readonly MaterialPropertyBlock mpb;
public MaterialPropertyBlockWrapper() {
this.mpb = new MaterialPropertyBlock();
}
public override void clear() {
this.mpb.Clear();
}
public void SetVector(int mid, Vector4 vec) {
this.mpb.SetVector(mid, vec);
}
public void SetFloat(int mid, float value) {
this.mpb.SetFloat(mid, value);
}
public void SetMatrix(int mid, Matrix4x4 mat) {
this.mpb.SetMatrix(mid, mat);
}
public void SetTexture(int mid, Texture texture) {
this.mpb.SetTexture(mid, texture);
}
public void SetInt(int mid, int value) {
this.mpb.SetInt(mid, value);
}
public void SetFloatArray(int mid, float[] array) {
this.mpb.SetFloatArray(mid, array);
}
}
}

11
Runtime/ui/utils/basic_types/canvas_shader_utils.cs.meta


fileFormatVersion: 2
guid: 9ddd3cd95755643c98042e67ba4714a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存