#UE4 #UE4Study 半径変更可能なRingをHLSLで描く #Shader #HLSL

Code : return MyFunction(texCoord,resolution,R);

OutputType: Float4

Inputs : texCoord,resolution,R,B

IncludeFilePath:/Project/Ring.usf

// ring
float centerR= length(p);//その座標の中心からの距離  中心が1 まわり0
float gradationOffset=R-centerR; //グラデーションをずらす。
float ring= abs(gradationOffset); //中心から距離が 0.5 となる場所ほど値を小さく
float t = B/ring;//見た目が天使の輪に見えるように係数をかける
//Ring.usf

//return MyFunction(texCoord,resolution,R,B);
float4 MyFunction(float2 texCoord,float2 resolution,float R,float B)
{
    // グラデーションのcenterをずらす
	float2 p = (texCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);
	
    // ring
    float centerR= length(p);//その座標の中心からの距離  中心が1 まわり0
    float gradationOffset=R-centerR; //グラデーションをずらす。
    float ring= abs(gradationOffset); //中心から距離が 0.5 となる場所ほど値を小さく
    float t = B/ring;//見た目が天使の輪に見えるように係数をかける

    return float4(t,t,t, 1.0);;
}

参考

https://wgld.org/d/glsl/g004.html

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です