All pastes #543891 Raw Edit

Stuff

public text v1 · immutable
·published 2007-06-06 06:45 UTC
rendered paste body
float iSize : register(c0);
float4x4 WorldViewProjection;

float4 tint;

texture Tex0;
sampler Tex0Sampler=
sampler_state
{
    Texture = <Tex0>;
    
    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;    
};

struct a2v
{ 
    float4 position     : POSITION0;
    float3 normal		: NORMAL;
    float2 texCoord		: TEXCOORD0;
    float4 newColor		: COLOR;
    float4 deltaPos		: DEPTH;
    
};
 
struct v2p
{   	
	float4 position    : POSITION0;
	float4 color		: COLOR;
};
 
struct p2f
{
    float4 color    : COLOR0;
};

float4 fetchPosition( int index )
{
    float4 pos;
    asm {
		vfetch pos, index, position
    };
    return pos;
}


float4 fetchDelta(int index)
{
	float4 pos;
    asm {
		vfetch pos, index, depth
    };
    return pos;
}

float4 fetchColor(int index)
{
	float4 pos;
    asm {
		vfetch pos, index, color
    };
    return pos;
}

void ps( in v2p IN,  out p2f OUT)
{	
	OUT.color = IN.color;
};

void vs( int i : INDEX, out v2p OUT )
{      	
	int outerIndex = (i + 0.5) / iSize;
	int innerIndex = i - outerIndex * iSize;
	
	float4 temp = fetchPosition(innerIndex) + fetchDelta(outerIndex);
	
	OUT.position = mul(temp, WorldViewProjection);
	OUT.color = fetchColor(outerIndex);
};

technique Instancing360
{
    pass P0
    {      
        VertexShader = compile xvs_3_0 vs();           
        PixelShader  = compile xps_3_0 ps();          
    }
}