Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@Tanutan93337836

シェーダーの練習でパーティーボールもどきを作った

パーティボールもどきをサーフェースシェーダーで書いてみた(もどきですらないけど)
コードは以下。

    Properties{
        _Diffuse("Diffuse Color", color) = (0, 0, 0, 1)
        _EmissionColor("Emission Color", color) = (1, 1, 1, 1)
    }

    SubShader{

        Tags {"RenderType" = "Opaque"}

        CGPROGRAM
        #pragma surface surf Lambert finalcolor:outemission vertex:yaxis

        struct Input {

            float customData_1;
            float customData_2;
        };

        float4 _Diffuse;
        float4 _EmissionColor;

        void yaxis(inout appdata_full v, out Input data) {

            UNITY_INITIALIZE_OUTPUT(Input, data);
            data.customData_1 = max(0, 0.5 * sin((v.vertex.y + _Time.x * 5) * 3.14159 * 8));
            data.customData_2 = max(0, 0.5 * sin((v.vertex.x + _Time.x * 5) * 3.14159 * 8));
        }

        void outemission(Input IN, SurfaceOutput o, inout fixed4 color) {
            color += (_EmissionColor * IN.customData_1 + _EmissionColor * IN.customData_2);
        }

        void surf(Input IN, inout SurfaceOutput o) {
            o.Albedo = _Diffuse;
        }
        ENDCG
    }
    FallBack "Diffuse"

実行時はこんな感じ。
スクリーンショット (3).png

このクロスした白線が時間に応じて動く感じです。サーフェースシェーダーのモディファイヤーを使って、アウトプットを加工してます。
個人的に、引数に戻り値を定義するところあたり、どうにも不快感があります。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?