About Particles Instancing and textures

Hi !

Is it possible to pass a Texture in a VertexDeclaration used to feed instances with the data, to have the particles draw, say… 2 (ore more) different textures ?
Or is Instancing not intended to this ?

The problem is I have thousands of smoke particles, and thousands ember particles, mixing the 2 systems into one would mix them instead of drawing one or another first accoding to the camera’s distance, and not correctly overlapping the quads from each system that should effectively overlap.
Smoke is not flat, so do embers, drawing them separately increases the “flatness” feeling.

public struct InstanceData: IVertexType
{
	public static readonly VertexDeclaration VertexDeclaration;
	public Matrix World;
	public Texture2D tex;
	...
	static InstanceData()
	{
		var elements = new VertexElement[]
                {
                	new VertexElement(...
				//Here, is it possible to use the texture "tex" ?
		}
	}
}

EDIT:Just had to look into VertexElementFormat.

yes, but the easiest way to achieve this is to make a texture atlas with all of the particle textures. So you always read from one texture in your pixel shader. You can simply modify the UVs to be [0…0.5, 0…1] for example if you have 2 textures in your atlas.

This does mean however that you don’t have mip maps generated for you by default.

Otherwise you can just pass anything you like in your vertex, it really doesn’t matter. Can be anything really, so a bool or int as the index of texture works, too.

That’s exactly what I was thinking of as last resort :wink:
But to mix different particles, I’ll need to create the atlas at runtime. That’s another story ^^
I’ll read some things about atlas and hlsl, never I’ve used this till now.