LoginSignup
0
0

More than 5 years have passed since last update.

jsdoでshadertoy sandbox その9

Posted at

概要

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

以上

0
0
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
0
0