【Defold】セピア調シェーダー
2020/07/12Defold, DEVELOP
少しレトロな見た目になるセピア調シェーダーコードです。
Material プロパティ
Vertex Constants
Name | Type | Value |
view_proj | viewproj | 0, 0, 0, 0 |
Fragment Constants
Name | Type | Value |
tint | User | 1, 1, 1, 1 |
Tags
シェーダーコード
uniform highp mat4 view_proj;
// positions are in world space
attribute highp vec4 position;
attribute mediump vec2 texcoord0;
varying mediump vec2 var_texcoord0;
void main()
{
gl_Position = view_proj * vec4(position.xyz, 1.0);
var_texcoord0 = texcoord0;
}
varying mediump vec2 var_texcoord0;
uniform lowp sampler2D texture_sampler;
uniform lowp vec4 tint;
const vec3 monochromeScale = vec3(0.298912, 0.586611, 0.114478);
const vec3 sepiaScale = vec3(1.07, 0.74, 0.43);
void main()
{
// Pre-multiply alpha since all runtime textures already are
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
vec4 sampleColor = texture2D(texture_sampler, var_texcoord0.xy) * tint_pm;
float grayColor = dot(sampleColor.rgb, monochromeScale);
vec3 monoColor = vec3(grayColor) * sepiaScale;
sampleColor = vec4(monoColor, 1.0);
gl_FragColor = sampleColor;
}
結果
お知らせ