LoginSignup
33
8

More than 5 years have passed since last update.

頭悪いからカービィシェーダー作ったったw

Posted at

ぽよみ

あ~ぽよみが足りない、ぽよみが足りないよ~:sob::sob::sob:

そーだ、全てをぽよみにしよう(唐突)

シェーダーを書こう

とりあえず全てカービィになってしまうという超絶頭の悪いシェーダーを書こう!

やりかた

  • まず、色を取得するあたまの悪い関数を作ります。
  • 次にピクセルシェーダーを書いてuv座標からその位置の色をさっきの関数から取得します。
  • できた!

コード

kirby.hlsl
float4 GetColor(int x, int y)
{

    static const int kirbyDot[16][16] =
    {
        {0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0},
        {0,0,0,0,1,1,2,3,3,3,2,1,1,0,0,0},
        {0,0,0,1,2,3,3,3,3,3,3,3,2,1,0,0},
        {0,0,1,2,3,3,3,3,3,3,3,3,3,1,0,0},
        {0,0,1,3,3,3,3,3,3,3,3,3,3,2,1,0},
        {0,1,3,3,3,3,3,3,3,1,3,1,3,2,1,0},
        {1,2,3,3,3,3,3,3,3,1,3,1,3,3,3,1},
        {1,3,3,3,3,3,3,3,3,1,3,1,3,3,3,1},
        {1,3,3,3,3,3,2,2,3,3,3,3,2,2,3,1},
        {1,2,3,3,2,3,3,3,3,3,3,3,3,2,3,1},
        {0,1,2,3,1,3,3,3,3,3,1,3,3,1,2,1},
        {0,0,1,1,2,3,3,3,3,3,3,3,2,1,1,0},
        {0,0,0,1,1,2,2,3,3,3,3,2,1,1,0,0},
        {0,0,1,2,2,1,1,1,1,1,1,1,2,2,1,0},
        {0,1,2,2,2,2,2,1,1,1,1,2,2,2,2,1},
        {0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,0},
    };

    int colorNum = kirbyDot[y][x];

    switch (colorNum)
    {
    case 0:return float4(1, 1, 1, 0);
    case 1:return float4(0, 0, 0, 1);
    case 2:return float4(0.9137,0.3411,0.5843,1);
    case 3:return float4(0.949,0.6352,0.7411, 1);
    }

    return float4(0, 0, 0, 0);

}




//ピクセルシェーダ
float4 PS(OutputVS input) : SV_Target
{
    float4 outPut = input.color;
    const float2 uv = input.tex;

    int x = uv.x * 16;
    int y = uv.y * 16;

    outPut = GetColor(x, y);


    if (outPut.a == 0)
        discard;

    return outPut;
}

実行

2017-02-15 (1).png

:blush::blush::blush::blush::blush:

まとめ

  • ぽよみが得られた
  • カービィ25周年おめでとう
33
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
8