This project is read-only.
Rendering.NET allows to specify a custom format for vertices and pixels. This custom formats can be used in VertexBuffers and TextureBuffers.

Flexible vertex formats

Some custom vertex formats defined in Rendering.NET.
public sealed class CustomVertex
{
    public struct PositionVertex
    {
        [Position]
        public Vector3 Position;
    }

    public struct PositionNormal
    {
        [Position]
        public Vector3 Position;
	[Normal]
        public Vector3 Normal;
    }

    public struct PositionColoredTextured
    {
        [Position]
        public Vector3 Position;
        [Diffuse]
        public int Diffuse;
        [TextureCoordinates]
        public Vector2 TextureCoordinates;
    }
} 

You can also define your own custom vertex format and use it in your VertexBuffer data.
public struct PositionNormalTextured
{
    [Position]
    public Vector3 Position;
    [Normal]
    public Vector3 Normal;
    [TextureCoordinates]
    public Vector2 TextureCoordinates;
}

var vb = (VertexBuffer)(new PositionNormalTextured [] { 
    new PositionNormalTextured { 
        Position = new vec3 (0,0,0), 
        Normal = new vec3 (0,0,-1), 
        TextureCoordinates=new vec2 (0,1)  
    }, 
    new PositionNormalTextured { 
        Position = new vec3 (1,0,0), 
        Normal = new vec3 (0,0,-1), 
        TextureCoordinates=new vec2 (1,1)  
    },     
    new CubeVertex { 
        Position = new vec3 (1,1,0), 
        Normal = new vec3 (0,0,-1), 
        TextureCoordinates=new vec2 (1,0)  
    },
    ....
});

Flexible Custom Pixels

Some custom pixel formats defined in Rendering.NET.
[Alpha(24), Red(16), Green(8), Blue(0)]
public struct ARGB
{
    public byte B;
    public byte G;
    public byte R;
    public byte A;
}

public struct SRGBA
{
    [Red]
    public float R;
    [Green]
    public float G;
    [Blue]
    public float B;
    [Alpha]
    public float A;
}

You can also define your own custom vertex format and use it in your VertexBuffer data.
[Red(16), Green(8), Blue(0)]
public struct RGB
{
    public byte B;
    public byte G;
    public byte R;
}

private TextureBuffer texture;
public void Initialize(IRender render)
{
    texture = TextureBuffer.Empty<RGB>(512, 512);
    texture.GenerateNoise(123);
}

Last edited Oct 12, 2012 at 5:48 PM by acoto, version 2

Comments

No comments yet.