[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
プログラミング、3DCGとその他いろいろについて
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
float4x4 View;
float4x4 Projection;
float Time;
texture ExplosionTexture;
sampler explosionSampler = sampler_state
{
Texture = <ExplosionTexture>;
};
struct ExplosionVertexShaderOutput
{
float4 Position : POSITION;
float4 Color : COLOR;
};
float4 ComputeColor(float normalizedAge)
{
float4 color = 1;
color.a *= normalizedAge * (1 - normalizedAge) * (1 - normalizedAge) * 6.7;
return color;
}
ExplosionVertexShaderOutput ExplosionVertexShader(float4 velocity:COLOR)
{
ExplosionVertexShaderOutput output;
float4 worldPosition = float4(velocity.xyz * Time, 1);
output.Position = mul(worldPosition, mul(View, Projection));
output.Color = ComputeColor(Time / 2);
return output;
}
float4 ExplosionPixelShader(
float2 textureCoordinate:TEXCOORD,
float4 color:COLOR
):COLOR
{
return tex2D(explosionSampler, textureCoordinate) * color;
}
technique ExplosionShaderTechnique
{
pass P0
{
VertexShader = compile vs_2_0 ExplosionVertexShader();
PixelShader = compile ps_2_0 ExplosionPixelShader();
}
}