как-то так получилось
правда весьма непроизводительно получилось
как можно оптимизировать?
float4x4 matWorld : MATRIX_WORLD;
float4x4 matView : MATRIX_VIEW;
float4x4 matProj : MATRIX_PROJ;
texture diffuseTexture : TEXTURE_0;
sampler diffuse = sampler_state
{
Texture = <diffuseTexture>; // привязываем текстуру
// устанавливаем адресацию координат
AddressU = WRAP;
AddressV = WRAP;
AddressW = WRAP;
// устанавливаем фильтрацию
MinFilter = NONE;
MagFilter = NONE;
MipFilter = NONE;
// устанавливаем уровень фильтрации
MaxAnisotropy = 4;
};
struct vsi
{
float4 position : POSITION;
float3 texCoords : TEXCOORD;
float4 color : COLOR;
float3 binormal : BINORMAL;
};
struct vso
{
float4 color : TEXCOORD1;
float4 position : POSITION;
float2 texCoords : COLOR;
float3 binormal : TEXCOORD0;
};
vso VS(vsi i)
{
vso o;
//i.position = mul(i.position, matWorld);
i.binormal.y /= 2.0f;
i.position = mul(i.position, matView);
o.position = (0, 0, 0, 0);
if (i.texCoords.x > 0){o.position.x += i.binormal.y;} else{o.position.x -= i.binormal.y;}
if (i.texCoords.y > 0){o.position.y += i.binormal.y;} else{o.position.y -= i.binormal.y;}
float c = cos(i.binormal.x);
float s = sin(i.binormal.x);
float4 rotationMatrix = float4(c, -s, s, c);
o.position.xy = mul(o.position.xy, float2x2(rotationMatrix));
o.position = i.position + o.position;
o.position = mul(o.position, matProj);
o.color = i.color;
o.texCoords = i.texCoords;
o.binormal = i.binormal;
return o;
}
float4 PS(vso i) : COLOR0
{
float4 color = tex2D(diffuse, i.texCoords);
i.color.a = (color.a / 0.01f) * (i.color.a / 100.0f); // анимационная прозрачность смешивается с альфой текстуры
i.color.a -= ((100.0f - (i.color.a / 0.01f)) * 0.1) * i.binormal.z;
//saturate(i.color.a);
i.color.rgb = color.rgb;
return i.color;
}
// техника для отрисовки
technique MainTechnique
{
pass p0
{
AlphaBlendEnable = true;
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}