Giter Club home page Giter Club logo

bubble_shader's Introduction

Bubble_Shader

bubble

実行環境

2021.1.13f1

起動方法

ダウンロードし, Unityを起動させ, Assets\ScenesにあるBubbleSceneを立ち上げるとシャボン玉があるシーンを見ることができる. このシャボン玉の色はpythonプログラムで事前に計算し, それを3DTextureの形式で出力し, それをシェーダプログラムに入力することで色を出している. 3Dtexture生成プログラムの説明は, 後ほど記す.

薄膜による構造色とは

シャボン玉は表面が薄膜になっており, 光が干渉しあう. 薄膜の厚さ(膜厚), 入射角, 反射角など多くのパラメータによって色が変わる. 入射角と反射角に依存して色が変わるため, 見る位置によって色が変わる.

Inspector

Color Space

colorspace

構造色ルックアップテーブルの色空間を指定する.色空間は,sRGBかwide gammutを選択できる.

Color Tempeture

color temp

光源の色温度を指定する. D光源の5500Kと6500Kと9300Kを選択することができる.

Film material

filmmaterial

薄膜の素材を選択できる。ここでは石鹸水であるsoapのみ選択可能

FilmThickness(nm)

filmthickness

シャボン玉の膜厚の値

Structual Color Alpha

struc color alpha

構造色とbasecolorテクスチャとのブレンド率を持つ.

Structural Color LUT

luts

構造色のルックアップテーブル. 横軸を入射角(0°から90°), 縦軸を膜厚(0nmから400nm), 奥行を反射角(0°から90°)として, それぞれの値の色が格納されている. Unityの3DTextureを用いている.

構造色を出すまでの流れ

flow

本プログラムでの流れを上図に示す. 大まかな流れを説明する. まず, pythonプログラムを用いて構造色を事前計算する. 事前計算結果をルックアップテーブル(LUT)に格納する. そして, そのLUTのデータを参照する形で, Shaderプログラムが最終的な色を計算する. 以下に図で示しているプログラムファイルやLUTファイルの説明をする.

create_colortemp_csv.py

「ThinfilmColor_LUT/」にあるプログラム. 光源スペクトルを計算し, csv形式で出力するプログラム.

strucmap.py

「ThinfilmColor_LUT/」にあるプログラム. 構造色を計算し, その計算結果をcsv形式で出力するファイル. 具体的なアルゴリズムの説明は, 「PDFs/薄膜干渉構造色の計算.pdf」でしている. このLUTは膜厚, 入射角, 反射角をパラメータとして色を格納している.

lin2012xyz2e_5_7sf.csv

x,y,zそれぞれの等色関数の値が入ったcsvファイル. https://zenodo.org/record/583697#.Y8tACXbP2Uk のデータを用いた.

strucmap_create_usecsv.cs

「Assets/Scripts/」にあるプログラム. csv形式のLUTを入力とし, Unityで扱えるTexture3D形式へと変換している.

bubbleProc_shader.shader

「Assets/Shader/」にあるプログラム. 最終的な色を計算しているシェーダープログラム. LUTを入力とし, 視点位置情報, 光源位置情報を用いて適切な色を取り出して出力している.

bubble_shader's People

Contributors

yuuk201 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.