testing this with polyvox 0.2, irrlicht1.7.2(still not 1.8), dx9, shader 2.0( the shading is added direct from irrlichtshaderexample).
its almost beyzends code except that the materialnr is tunneled through colorred like 0xdeadc0de-code.
seems that something works but only something, the colors from texatlas are correct, but the textures are missing. that means that the material is correct sent to vertexshader and the pixelshader does something (in the lower line of voxels is the material 1,2,3,4,5,6,1 see pic (below you see the top of the textureatlas and above it are some voxels, you see that they have the colors from the first textures):

please someone sees why the texture(the numbers i wrote in middle of the first textures) is missing?
Code:
// Global variables ------------------------------------------------------------------
float4x4 mWorldViewProj; // World * View * Projection transformation
float4x4 mInvWorld; // Inverted world matrix
float4x4 mTransWorld; // Transposed world matrix
float3 mLightPos; // Light position
float4 mLightColor; // Light color
float4 mworldPos;
#define ATLAS_WIDTH 4096.0
#define TEXTURE_WIDTH 256.0
#define eOffset TEXTURE_WIDTH / ATLAS_WIDTH
// Vertex shader --------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float4 Diffuse : COLOR0; // vertex diffuse color
float4 textureAtlasOff : TEXCOORD0; // tex coords
};
VS_OUTPUT vertexMain( in float4 vPosition : POSITION,
in float3 vNormal : NORMAL,
float2 texCoord : TEXCOORD0,
float4 tile1 : COLOR )
{
VS_OUTPUT Output;
//here code from irrlichtshaderexample for getting Output.Diffuse color
mworldPos=vPosition + float4(0.5f, 0.5f, 0.5f, 0.5f);
Output.textureAtlasOff = float4(0.0f, 0.0f, 0.0f, 0.0f);
float idx = tile1.r * 256.0 -1;
float blocky = floor(idx / 16.0);
float blockx = (idx - blocky * 16.0);
Output.textureAtlasOff = float4(blockx + 0.25f, blocky + 0.25f, 0.0, 0.0) *eOffset;
return Output;
}
// Pixel shader -------------------------------------------------------------------------
struct PS_OUTPUT
{
float4 RGBColor : COLOR0; // Pixel color
};
sampler2D tex0;
PS_OUTPUT pixelMain( float4 textureAtlasOffset : TEXCOORD0,
float4 Position : POSITION,
float4 Diffuse : COLOR0 )
{
PS_OUTPUT Output;
float3 normal = cross(ddy(mworldPos.xyz),ddx(mworldPos.xyz));
normal = normalize(normal);
float2 uv0 = float2(1.0, 1.0);
if(normal.x > 0.5) uv0 = frac(float2(-mworldPos.z, -mworldPos.y));
if(normal.x < -0.5) uv0 = frac(float2(-mworldPos.z, mworldPos.y));
if(normal.y > 0.5) uv0 = frac(mworldPos.xz);
if(normal.y < -0.5) uv0 = frac(float2(-mworldPos.x, mworldPos.z));
if(normal.z > 0.5) uv0 = frac(float2(mworldPos.x, -mworldPos.y));
if(normal.z < -0.5) uv0 = frac(float2(-mworldPos.x,-mworldPos.y));
textureAtlasOffset += float4(uv0 * 0.5,0.0,0.0)*eOffset;
float4 col1=tex2D(tex0, textureAtlasOffset.xy);
Output.RGBColor = col1*Diffuse;
return Output;
}