本文整理汇总了C#中BlendMode类的典型用法代码示例。如果您正苦于以下问题:C# BlendMode类的具体用法?C# BlendMode怎么用?C# BlendMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlendMode类属于命名空间,在下文中一共展示了BlendMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTechnique
/// <summary>
/// Creates a new DrawTechnique using the specified <see cref="BlendMode"/> and <see cref="Duality.Resources.ShaderProgram"/>.
/// </summary>
/// <param name="blendType"></param>
/// <param name="shader"></param>
/// <param name="formatPref"></param>
public DrawTechnique(BlendMode blendType, ContentRef<ShaderProgram> shader, VertexDeclaration formatPref = null)
{
this.blendType = blendType;
this.shader = shader;
this.prefFormat = formatPref;
this.prefType = formatPref != null ? formatPref.DataType : null;
}
示例2: SetupMaterialWithBlendMode
public static void SetupMaterialWithBlendMode(Material material, BlendMode blendMode)
{
switch (blendMode)
{
case BlendMode.Opaque:
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.renderQueue = -1;
break;
case BlendMode.Cutout:
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.EnableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.renderQueue = 2450;
break;
case BlendMode.Transparent:
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.renderQueue = 3000;
break;
}
}
示例3: RenderStates
////////////////////////////////////////////////////////////
/// <summary>
/// Construct a set of render states with all its attributes
/// </summary>
/// <param name="blendMode">Blend mode to use</param>
/// <param name="transform">Transform to use</param>
/// <param name="texture">Texture to use</param>
/// <param name="shader">Shader to use</param>
////////////////////////////////////////////////////////////
public RenderStates(BlendMode blendMode, Transform transform, Texture texture, Shader shader)
{
BlendMode = blendMode;
Transform = transform;
Texture = texture;
Shader = shader;
}
示例4: GetNewInstanceOfBatch
protected override Batch GetNewInstanceOfBatch(Material material, BlendMode blendMode,
int numberOfQuadsToAdd)
{
if ((material.Shader as ShaderWithFormat).Format.Is3D)
throw new BatchRenderer2DCannotBeUsedToRender3D(); //ncrunch: no coverage
return new Batch2D(material, blendMode, numberOfQuadsToAdd);
}
示例5: DrawVertexBuffer
public void DrawVertexBuffer(IVertexBuffer<Vertex> buffer, int start, int length, PrimitiveType type, Sheet sheet, BlendMode blendMode)
{
shader.SetTexture("DiffuseTexture", sheet.GetTexture());
renderer.Device.SetBlendMode(blendMode);
shader.Render(() => renderer.DrawBatch(buffer, start, length, type));
renderer.Device.SetBlendMode(BlendMode.None);
}
示例6: UPALayer
// Constructor
public UPALayer (UPAImage img) {
name = "Layer " + (img.layers.Count + 1);
opacity = 1;
mode = BlendMode.NORMAL;
map = new Color[img.width * img.height];
tex = new Texture2D (img.width, img.height);
for (int x = 0; x < img.width; x++) {
for (int y = 0; y < img.height; y++) {
map[x + y * img.width] = Color.clear;
tex.SetPixel (x,y, Color.clear);
}
}
tex.filterMode = FilterMode.Point;
tex.Apply ();
enabled = true;
locked = false;
parentImg = img;
// Because Unity won't record map (Color[]) as an undo,
// we instead register a callback to LoadMapFromTex since undoing textures works fine
Undo.undoRedoPerformed += LoadMapFromTex; // subscribe to the undo event
}
示例7: Begin
public void Begin(GraphicsDevice gd)
{
Debug.Assert(batchMode == BatchMode.None, "Bad batch mode: " + batchMode);
matrixStack.Clear();
matrix = Matrix.Identity;
drawColor = Color.White;
blendMode = BlendMode.AlphaBlend;
if (graphicsDevice != gd)
{
graphicsDevice = gd;
spriteBatch = new SpriteBatch(graphicsDevice);
basicEffect = new BasicEffect(graphicsDevice);
int width = gd.Viewport.Width;
int height = gd.Viewport.Height;
Matrix worldMatrix = Matrix.Identity;
Matrix viewMatrix = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up);
Matrix projection = Matrix.CreateOrthographicOffCenter(0.0f, width, height, 0, 1.0f, 1000.0f);
camera = new Camera(worldMatrix, viewMatrix, projection);
basicEffect.World = worldMatrix;
basicEffect.View = viewMatrix;
basicEffect.Projection = projection;
basicEffect.VertexColorEnabled = true;
}
}
示例8: TerrainSpriteLayer
public TerrainSpriteLayer(World world, WorldRenderer wr, Sheet sheet, BlendMode blendMode, PaletteReference palette, bool restrictToBounds)
{
worldRenderer = wr;
this.restrictToBounds = restrictToBounds;
Sheet = sheet;
BlendMode = blendMode;
paletteIndex = palette.TextureIndex;
map = world.Map;
rowStride = 4 * map.MapSize.X;
vertices = new Vertex[rowStride * map.MapSize.Y];
vertexBuffer = Game.Renderer.Device.CreateVertexBuffer(vertices.Length);
emptySprite = new Sprite(sheet, Rectangle.Empty, TextureChannel.Alpha);
wr.PaletteInvalidated += () =>
{
paletteIndex = palette.TextureIndex;
// Everything in the layer uses the same palette,
// so we can fix the indices in one pass
for (var i = 0; i < vertices.Length; i++)
{
var v = vertices[i];
vertices[i] = new Vertex(v.X, v.Y, v.Z, v.U, v.V, paletteIndex, v.C);
}
for (var row = 0; row < map.MapSize.Y; row++)
dirtyRows.Add(row);
};
}
示例9: LayerProperties
public LayerProperties (string name, bool hidden, double opacity, BlendMode blendmode)
{
this.Opacity = opacity;
this.Hidden = hidden;
this.Name = name;
this.BlendMode = blendmode;
}
示例10: SetBlendMode
public void SetBlendMode(BlendMode blendMode)
{
Assert.IsNotNull(renderer, Errors.E_RENDER_TARGET_NULL);
int result = SDL.SDL_SetTextureBlendMode(Handle, (SDL.SDL_BlendMode)blendMode);
if (Utilities.IsError(result))
throw new InvalidOperationException(Utilities.GetErrorMessage("SDL_SetTextureBlendMode"));
}
示例11: Blit
/// <summary>
/// http://en.wikipedia.org/wiki/Alpha_compositing
/// </summary>
/// <param name="destination_rect"></param>
/// <param name="source"></param>
/// <param name="source_rect"></param>
/// <param name="blendMode"></param>
public void Blit(
Rectangle destination_rect,
IPixelCanvas source,
Rectangle source_rect,
BlendMode blendMode)
{
Blit(destination_rect, source, source_rect, 255, 255, 255, 255, blendMode);
}
示例12: Layer
public Layer(ImageSurface surface, bool hidden, double opacity, string name)
{
Surface = surface;
this.hidden = hidden;
this.opacity = opacity;
this.name = name;
this.blend_mode = BlendMode.Normal;
}
示例13: OnInspectorGUI
public void OnInspectorGUI(Action onValueChanged)
{
// blend mode.
var newBlendMode = (BlendMode)EditorGUILayout.Popup("Rendering Mode", (int)blendMode, Enum.GetNames(typeof(BlendMode)), new GUILayoutOption[0]);
if (newBlendMode != blendMode) {
this.blendMode = newBlendMode;
onValueChanged();
}
}
示例14: Blit
/// <summary>
/// http://en.wikipedia.org/wiki/Alpha_compositing
/// </summary>
/// <param name="destination_rect"></param>
/// <param name="source"></param>
/// <param name="source_rect"></param>
/// <param name="blendMode"></param>
public void Blit(
System.Drawing.Rectangle destination_rect,
IPixelCanvas source,
System.Drawing.Rectangle source_rect,
BlendMode blendMode
)
{
Blit(destination_rect, source, source_rect, 255, 255, 255, 255, blendMode);
}
示例15: SetRenderStateForSprite
void SetRenderStateForSprite(Sprite s)
{
renderer.CurrentBatchRenderer = this;
if (s.BlendMode != currentBlend || s.Sheet != currentSheet || nv + 4 > renderer.TempBufferSize)
Flush();
currentBlend = s.BlendMode;
currentSheet = s.Sheet;
}