Cirno2022/script/sample/SamplePS03_HLSL.txt

108 lines
2.5 KiB
Plaintext
Raw Normal View History

2022-09-14 15:23:27 +00:00
//================================================================
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݒ<EFBFBD><DD92>l
//Texture
sampler sampler0_ : register(s0);
//--------------------------------
//<2F><EFBFBD>ݐ<EFBFBD><DD90><EFBFBD><EFBFBD>p<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>[<5B>^
static const float RENDER_WIDTH = 1024; //<2F><><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD>e<EFBFBD>N<EFBFBD>X<EFBFBD>`<60><><EFBFBD>̕<EFBFBD>
static const float RENDER_HEIGHT = 1024; //<2F><><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD>e<EFBFBD>N<EFBFBD>X<EFBFBD>`<60><><EFBFBD>̍<EFBFBD><CC8D><EFBFBD>
float frame_; //<2F>t<EFBFBD><74><EFBFBD>[<5B><><EFBFBD><EFBFBD>
float enemyX_; //<2F>G<EFBFBD>̈ʒuX
float enemyY_; //<2F>G<EFBFBD>̈ʒuY
float waveRadius_; //<2F>G<EFBFBD>t<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>̔<EFBFBD><CC94>a
//================================================================
//--------------------------------
//<2F>s<EFBFBD>N<EFBFBD>Z<EFBFBD><5A><EFBFBD>V<EFBFBD>F<EFBFBD>[<5B>_<EFBFBD><5F><EFBFBD>͒l
struct PS_INPUT
{
float4 diffuse : COLOR0; //<2F>f<EFBFBD>B<EFBFBD>t<EFBFBD><74><EFBFBD>[<5B>Y<EFBFBD>F
float2 texCoord : TEXCOORD0; //<2F>e<EFBFBD>N<EFBFBD>X<EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD>W
float2 vPos : VPOS; //<2F>`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>W
};
//--------------------------------
//<2F>s<EFBFBD>N<EFBFBD>Z<EFBFBD><5A><EFBFBD>V<EFBFBD>F<EFBFBD>[<5B>_<EFBFBD>o<EFBFBD>͒l
struct PS_OUTPUT
{
float4 color : COLOR0; //<2F>o<EFBFBD>͐F
};
//================================================================
// <20>V<EFBFBD>F<EFBFBD>[<5B>_
//--------------------------------
//<2F>s<EFBFBD>N<EFBFBD>Z<EFBFBD><5A><EFBFBD>V<EFBFBD>F<EFBFBD>[<5B>_
PS_OUTPUT PsWave( PS_INPUT In ) : COLOR0
{
PS_OUTPUT Out;
//--------------------------------
//<2F><><EFBFBD><EFBFBD><E782AC><EFBFBD>v<EFBFBD>Z
float dist2 = pow(In.vPos.x-enemyX_ ,2) + pow(In.vPos.y-enemyY_ ,2);
float dist = sqrt(dist2);
float sinTheta = (In.vPos.y - enemyY_) / dist;
float cosTheta = (In.vPos.x - enemyX_) / dist;
//<2F>c<EFBFBD>ݍ쐬<DD8D>p<EFBFBD><70>sin<69>Ɏg<C98E>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>x<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>[<5B>^
float angle = In.vPos.y - enemyY_ + In.vPos.x - enemyX_ + frame_;
angle = radians(angle);
//<2F>Y<EFBFBD><59><EFBFBD>s<EFBFBD>N<EFBFBD>Z<EFBFBD><5A><EFBFBD>̘c<CC98>݂̔<DD82><CC94>a<EFBFBD><61><EFBFBD>v<EFBFBD>Z
//<2F>G<EFBFBD>t<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>a<EFBFBD><61>1/16<31><36><EFBFBD>ő<EFBFBD><C591>̘c<CC98>ݕ<EFBFBD><DD95>Ƃ<EFBFBD><C682><EFBFBD>
float waveRadius = waveRadius_ + waveRadius_/16 * (-1 + sin(angle));
//<2F><><EFBFBD>S<EFBFBD><53><EFBFBD><EFBFBD><E78B97><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>قlje<C789><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float powerRatio = (waveRadius - dist) / waveRadius;
if(powerRatio < 0){powerRatio = 0;}
//<2F>F<EFBFBD><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E693BE><EFBFBD><EFBFBD><EFBFBD>ʒu<CA92>̃o<CC83>C<EFBFBD>A<EFBFBD>X<EFBFBD>l
float biasRadius = waveRadius * powerRatio;
float biasX = biasRadius * cosTheta;
float biasY = biasRadius * sinTheta;
//<2F>e<EFBFBD>N<EFBFBD>X<EFBFBD>`<60><><EFBFBD>̐F<CC90><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E693BE><EFBFBD><EFBFBD><EFBFBD>ʒu
float2 texUV;
texUV.x = -biasX / RENDER_WIDTH + In.texCoord.x;
texUV.y = -biasY / RENDER_HEIGHT + In.texCoord.y;
//--------------------------------
//<2F>e<EFBFBD>N<EFBFBD>X<EFBFBD>`<60><><EFBFBD>̐F
float4 colorTexture = tex2D(sampler0_, texUV);
//<2F><><EFBFBD>_<EFBFBD>f<EFBFBD>B<EFBFBD>t<EFBFBD>[<5B>Y<EFBFBD>F
float4 colorDiffuse = In.diffuse;
//<2F><><EFBFBD><EFBFBD>
float4 color = colorTexture * colorDiffuse;
//<2F>F<EFBFBD><46><EFBFBD>Ԃ<EFBFBD><D482>ۂ<EFBFBD><DB82>ω<EFBFBD><CF89><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(powerRatio > 0)
{
color.g = color.g * (1 - powerRatio);
color.b = color.b * (1 - powerRatio);
}
Out.color = color;
return Out;
}
//================================================================
//--------------------------------
//technique
technique TecWave
{
pass P0
{
PixelShader = compile ps_3_0 PsWave();
}
}