LoginSignup
0
2

More than 3 years have passed since last update.

【完結編!】SDF EditorでShadertoyやGLSLのモデリングが劇的に簡単に!

Last updated at Posted at 2021-05-25

21年5月30日に、SDF Editorのソースコードが公開され、
より簡単にGLSL用のコードが出力できるようになりました。

下記記事をごらんいただき、本記事は下記記事の参考としてください。


本記事は、以下の二つの記事の完結編です。

SDF EditorでShadertoyやGLSLのモデリングが劇的に簡単に!
https://qiita.com/quittardis/items/7a0d23359fcebaeb21a6

【改良版!】SDF EditorでShadertoyやGLSLのモデリングが劇的に簡単に!
https://qiita.com/quittardis/items/7a0d23359fcebaeb21a6  

shadertoy.png

SDF Editorの全プリミティブ、モディファイア、オペレータに対応

cnvSDF.py https://github.com/ultrahamlet/cnvSDF

cnvSDF.pyは、"SDF Editor" https://joetech.itch.io/sdf-editor 出力結果をShadertoy(GLSL)の
コードに変換する。"SDF Editor"の以下の要素に対応している。

プリミティブ Primitives
Box, Frame, Cylynder, InfCylynder, Capsule, Cone, Capped Cone, Round Cone, InfCone
Sphere, Ellipsoid, Solid Angle, TriPrism, Hexprism, Torus, CappedTorus, Link,
Octahedron, Pyramid, Plane,

モディファイヤ Modifires

Translation, Rotation, Mirror, RepInf, Replim, Elongation

オペレータ Operator

Union, Subtraction, Interection, Onion, Thicken, SmoothUnion, SmoothSubtraction, SumoothIntersection  

cnvSDF.pyの使い方

 1. "SDF Editor"でモデリングする。
 
 2. データをデフォルトのファイル名、"test.json"で保存する。

 3. ShadertoyのプラグインをインストールしたVisual Studo Codeで、
 viewSDF.fragを開き、sdfという文字列をサーチし、"SDF Editor"の
 下方の出力枠の中のsdf関数とsdf(vec3 p0){...}を置き換える。

 4. cnvSDF.pyを実行し、その出力結果であるテキストをviewSDF.fragの先頭
 にコピーする。

 5. いったん、viewSDF.fragをセーブし、再び開く。

 6. マウス右ボタン-> Shadertoy:Show GLSL Preview でRaymarchingの結果を表示。

これを
 7. マウス右ボタン-> Shadertoy:Create Protbale GLSL Preview で得られる
 viewSDF.html はローカルでもweb上でも同じRaymarchingのリアルタイムCGが表示できる。

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