概要
shadertoyのコードをjsdoでやってみた。
webgl2でなくても、shadertoyは、textureLodが、動く。魔法だ。
サンプルコード
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 uv = fragCoord.xy / iResolution.xy;
vec3 col = textureLod(iChannel0, uv, (sin(iGlobalTime) + 1.) * 2.).xyz;
fragColor = vec4(col, 1.0);
}
魔法の正体
EXT_shader_texture_lodがTrueなら、以下のコードを挿入すれば、textureLodが、動く。
スクリプトへ
gl.getExtension("EXT_shader_texture_lod");
シェーダーソースへ
#extension GL_EXT_shader_texture_lod : enable
vec4 textureLod(sampler2D s, vec2 c, float b)
{
return texture2DLodEXT(s, c, b);
}
成果物
http://jsdo.it/ohisama1/6ae2
http://jsdo.it/ohisama1/Wp2X
以上