Help us understand the problem. What is going on with this article?

jsdoでshadertoy sandbox その9

More than 3 years have passed since last update.

概要

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

以上

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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした