元々こちらのサイトで知ったのだが、いかんせんダウンロードがわかりにくいのでここに書いておく
① https://beemuse.com/ へ行く
② 右上の「Install」のGitHub projectをクリック
https://github.com/itmustbe/beemuse
③ 下の方のREADME.mdの枠の中にある https://github.com/itmustbe/package-beemuseをクリック
https://github.com/itmustbe/package-beemuse
④ 中央のファイル一覧の中の「dist」をクリック
https://github.com/itmustbe/package-beemuse/tree/master/dist
⑤ beemuse.css をダウンロード
beemuse.css内、 .stitchの部分をいろいろ変えると色を変えられる
技術系の記事だけで三日ごとに更新するのはさすがにきつすぎることが最近わかってきたので(一つの記事が薄くなりすぎる)、色々混ぜることにする。
そもそも、vrayのノードの組み合わせの記事とか、殆ど文字にならないんだけれども、cycles等々と違って巷に答えが転がってないので、ガラスにcausticsつけるのに一ヶ月調査したからね。いやマジで。それでvrayの試用期間終わってよくわからんうちに買う羽目になったわけで、それを三日ごとに公開してりゃネタも無くなるのである。
といいつつBlender+Cycles。なぜvrayにしなかったかというと、PlantFactory→vrayの変換がまだできなかったから。まあやればできることはわかっているのだけど面倒くさすぎるうえに多分結果があまり変わらないから。
月は: https://free3d.com/3d-model/moon-photorealistic-2k-853071.html から。
木はPlantFactoryで自作。
かなりこだわった草は殆ど見えない←
背景は透明でレンダリングして後からgimpでグラデーションをつけている。
std::shared_ptrを使うに当たり、自分のポインタをshared_ptrで誰かに渡したいことがある。
当然thisを使うのだが、
auto ptr = shared_ptr(this); // NG
こんなことをしてはいけない。thisを使いたい場合、そのクラスをenable_shared_from_thisクラスからpublic継承し、shared_from_this関数を用いてthisを取得する必要がある。その際、以下のことに気を付ける必要がある
①.thisを使いたいときはenable_shared_from_thisを継承する
②.コンストラクタの中でshared_from_thisを使ってはいけない
③.自分自身がshared_ptrで管理されていなければならない
#include <memory> #include <iostream> // ① OK enable_shared_from_this を使う class myData: public std::enable_shared_from_this<myData>{ int i; public: myData(){ //②NG コンストラクタでshared_from_thisを使ってはいけない std::cout << shared_from_this()->i << std::endl; }; void func(){ //②OK thisの取得にshared_from_thisを使う std::cout << shared_from_this()->i << std::endl; } }; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// int _tmain(int argc, _TCHAR* argv[]) { //③ enable_shared_from_thisを使う場合は、自信もshared_ptrで管理されなければならない myData data1;// ③ NG myData *data2 = new myData;// ③ NG // ③ OK std::shared_ptr<myData> data3 = std::shared_ptr<myData>( new myData ); // ③ OK std::shared_ptr<myData> data4 = std::make_shared<myData>(); data4->func(); getchar(); return 0; }
[Mapping] - [Object]ノードを追加
[Math] - [Transform]
Scale
Scale | |
0.01 0.01 0.01 |
![]() |
0.1 0.1 0.1 |
![]() |
1.000 1.000 1.000 |
![]() |
10.00 10.00 10.00 |
![]() |
Cycles用のDynamic Skyというアドオンがあって、楽に空を作れる。さしてリアルな物ではないが、もの凄く適当(ちょうど良いの意味)な事がある。
それを他のレンダラで使おうと思うと、環境テクスチャにするのが一番いい。
① レンダラをCyclesにする
② カメラを選択し、LensをPanoramicにする
③ TypeをEquirectangularにする
④ 必要に応じて、カメラの位置と角度を変える
⑤ せっかくなので出力形式をhdrにする
結果
注意:
Gizmo |
allows you to connect a Fog Gizmo so that the effect is confined within a specified volume Fog Gizmoを接続することで、指定された領域内にのみエフェクトが発生するようにします |
Color |
defines the color of the fog when it is illuminate by light sources. You can also use a texture map to drive the fog color. 光源によって照らされるときのfogの色を定義します。テクスチャマップを使用することもできます。 |
Emission |
controls the fog emission (self-illumination). You can use this parameter to substitute the ambient illumination inside the fog, instead of using GI. fogの自己照明を制御します。このパラメータを使用すると、GIを使用する代わりに、霧の中の環境光を置き換えることができます。 |
Emission Mult |
a multiplier for the Emission parameter Emissionパラメータの倍率 |
Fog Density |
a multiplier for the fog Distance parameter that allows a texture to be used for the density of the fog |
Lights |
allows you to specify which lights are going to affect the fog fogに影響するライトを指定します |
Use Height |
when enabled allows you to limit the fog height 有効にすると、fogの高さを制限できます |
Height |
specifies an upper limit for the fog fogの上限を指定する |
Subdivs |
this parameter determines the number of points inside the fog at which volumetric lighting is evaluated. Smaller values for this parameter render faster, but may produce noise in the image. Higher values render longer, but with less noise. このパラメータは、体積照明が評価される霧の中の点の数を決定します。このパラメータの値を小さくするほど、レンダリングは高速になりますが、画像にノイズが発生する可能性があります。値が大きくなるほど、ノイズは少なくなります。 |
Fog Distance |
controls the fog density. Larger values make the fog more transparent, while smaller values make it more dense. You can also control the density with a texture map. fogの濃度を制御します。値を大きくすると霧がより透明になり、値が小さいほど霧が濃くなります。テクスチャマップで密度を制御することもできます。 |
Simplify Textures for GI |
When this option is checked V-Ray will use a simplified method for calculating the GI when rendering parts of the fog that are textured or are being faded out. このオプションをオンにすると、V-Rayは、ぼかしの一部がテクスチャリングされているか、フェードアウトされているときにGIを計算するための簡単な方法を使用します。 |
Scatter GI |
when on, the fog will also scatter global illumination. Note that this can be quite slow. In many cases, global illumination within the fog can be substituted with a simple emission term. When this option is on, the currently selected global illumination algorithm in the V-Ray settings will be used to accelerate GI inside the volume. オンにすると、霧は大域照明も散乱させます。これは非常に遅いことに注意してください。多くの場合、霧内の大域照明は簡単な発光項で置き換えることができます。このオプションをオンにすると、現在選択されている大域照明アルゴリズムがV-Ray設定で使用され、ボリューム内のGIが加速されます |
Scatter Bounces |
when Scatter GI is enabled, this controls the number of GI bounces that will be calculated inside the fog. Scatter GIが有効になっている場合、フォグ内で計算されるGIバウンスの数を制御します。 |
Light Mode |
this option allows you to specify which lights will be considered when rendering the environment fog. It is used when you have certain lights affecting just specific objects in the scene while another group of lights is affecting the environment fog. このオプションを使用すると、environment fogをレンダリングするときに考慮するライトを指定できます。 これは、特定のライトがシーン内の特定のオブジェクトにのみ影響を与え、ライトの別のグループが環境フォグに影響を与えている場合に使用されます。 --------------------------------------------------------------- No lights - the lights in the scene will not affect the environment fog. Per-Gizmo (default) - the lights attached to the environment fog set will be ignored. Only the lights affecting the shape where the fog resides, will be used. Override - only the lights affecting the environment fog set will be considered. Intersect - only lights that are affecting both the shape and the environment fog set will be considered. Add - both lights that are affecting the shape and the environment fog set will be considered.
|
Fade Out Mode |
this option allows you to chose between two different falloff modes: Multiply by density and Add density to falloff. フォールオフモードを選択します。密度で乗算か、減算に密度を加算かから選択します。 |
Fade Out Radius |
when the fog effect is contained within a gizmo this option allows you to specify a falloff radius for it. This way the fog effect does not have sharp edges at the edges of the gizmo. Fogエフェクトがgizmoに含まれている場合、このオプションでフォールオフ半径を指定できます。 これにより、fogはgizmoのエッジが鋭くなくなります。 |
Step size |
determines the size of one step through the volume. Smaller steps produce more accurate results but are slower to render. In general, dense volumes require smaller step sizes than more transparent volumes. In practice, step sizes that are two to three times smaller than the Fog distance parameter work well. ボリューム内の1ステップのサイズを決定します。 ステップが小さくなるほど正確な結果が得られますが、レンダリングが遅くなります。 一般に、高密度ボリュームは、より透明なボリュームよりも小さなステップサイズを必要とします。 実際には、フォグ距離パラメータの2〜3倍小さいステップサイズがうまく機能します。 |
Tex Samples |
determines the number of texture samples for each step through the volume. This allows to sample textures more accurately than the volumetric lighting. It is useful in cases where the textures vary much faster than the lighting itself (e.g. for detailed fractal textures). ボリュームを通る各ステップのテクスチャサンプル数を決定します。 これにより、体積測定照明よりも正確にテクスチャをサンプリングすることができます。 テクスチャが照明自体よりもはるかに速く変化する場合(例えば、詳細なフラクタルテクスチャの場合)に有用である。 |
Max steps |
specifies the maximum number of steps through the volume. ボリュームの最大ステップ数を指定します。 |
Cutoff Threshold |
this parameter controls when the raymarcher will stop traversing the volume. If the accumulated volume transparency falls below this threshold, the volume will be considered opaque and tracing will be aborted. Higher values make the rendering faster but may introduce artifacts. このパラメータは、レイマーチャがボリュームをトラバースするのを止めるときを制御します。 蓄積されたボリュームの透明度がこのしきい値を下回ると、ボリュームは不透明とみなされ、トレースは中断されます。 値を大きくするほどレンダリングは速くなりますが、アーティファクトが発生する可能性があります。 |
Shadow Opacity |
this parameter controls the opacity of the shadows cast by the fog このパラメータは、fogによって落ちる影の不透明度を制御します |
Solid Mode |
when enabled V-Ray will sample the fog uniformly 有効にすると、V-Rayはfogを一様にサンプリングします |
Solid Threshold |
a fraction of the Density parameter at which V-Ray will sample the fog when Solid Mode is enabled 上記ソリッドモードが有効になっているときにV-Rayがfogをサンプリングする濃度パラメータの一部 |
Affect Shadows |
specifies if the fog should affect shadow rays. fogがシャドウレイに影響するかどうかを指定します。 |
Affect Background |
when this option is off, the background will not be obscured by the fog. このオプションをオフにすると、背景が霧によって隠されることはありません。 |
Affect Camera |
specifies if the fog will be visible to camera rays. カメラの光線に霧が表示されるかどうかを指定します。 |
Affect GI |
specifies if the fog should affect GI rays. 霧がGI線に影響するかどうかを指定します。 |
Affect Reflections |
specifies whether the fog will be rendered in reflections. フォグが反射でレンダリングされるかどうかを指定します。 |
Affect Refractions |
specifies whether the fog will be rendered in refractions. フォグが屈折でレンダリングされるかどうかを指定します。 |
モーダレスダイアログボックスを作成する関数には、CreateDialogの他にCreateDialogParamがある。
https://msdn.microsoft.com/ja-jp/library/cc410696.aspx
HWND CreateDialogParam( HINSTANCE hInstance, // アプリケーションのインスタンスのハンドル LPCTSTR lpTemplateName, // ダイアログボックステンプレートを指定します HWND hWndParent, // オーナーウィンドウのハンドル DLGPROC lpDialogFunc, // ダイアログボックスプロシージャへのポインタ LPARAM dwInitParam // 初期値 );
この初期値と呼ばれる第五引数dwInitParamは何かというと、ダイアログ初期化の際に呼ばれるWM_INITDIALOGのlParam値である。
オブジェクト指向ではないCreateDialogにとって、CreateDialogに渡せる、ユーザが任意に指定できるグローバル変数以外の唯一のパラメータがこれなのである。
以下はこのdwInitParamで初期値を渡す例である:
#include <Windows.h> #include "resource.h" #include <tchar.h> INT_PTR CALLBACK WndProcModeless(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: if (lParam) { TCHAR* c = (TCHAR*)lParam; MessageBox(hWnd, c, 0, 0); ShowWindow(hWnd, SW_SHOW); } return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: MessageBox(hWnd, _T("IDOK"), 0, 0); PostQuitMessage(0); return TRUE; } return FALSE; } return FALSE; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) { CreateDialogParam( hInstance, MAKEINTRESOURCE(IDD_DIALOG1), nullptr, WndProcModeless, (LPARAM)_T("鵺") ); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; }
#pragma once #include <windows.h> class CnuDlgModeless { HWND m_hwnd; HINSTANCE m_hInstance; static INT_PTR CALLBACK StaticWndProcDlg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); public: HWND GetHWnd()const { return m_hwnd; } HINSTANCE GetHInstance()const { return m_hInstance; } virtual ~CnuDlgModeless(); //CreateDialogParam関数の呼び出し HWND nuCreateDialog( HINSTANCE hInstance, // インスタンスハンドル LPCTSTR lpTemplate, // ダイアログボックスの名前 HWND hWndParent // 親ウィンドウのハンドル ); //個別のウィンドウプロシージャ virtual INT_PTR WndProcDlg( HWND hWnd, UINT msg, WPARAM wp, LPARAM lp ); };
CnuDlgModeless.cpp
#include "CnuDlgModeless.h" CnuDlgModeless::~CnuDlgModeless() { } //CreateDialogParam関数の呼び出し HWND CnuDlgModeless::nuCreateDialog( HINSTANCE hInstance, // インスタンスハンドル LPCTSTR lpTemplate, // ダイアログボックスの名前 HWND hWndParent // 親ウィンドウのハンドル ) { m_hInstance = hInstance; m_hwnd = CreateDialogParam(GetHInstance(), lpTemplate, hWndParent, (DLGPROC)CnuDlgModeless::StaticWndProcDlg, (LPARAM)this); return m_hwnd; } INT_PTR CALLBACK CnuDlgModeless::StaticWndProcDlg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { CnuDlgModeless* This = (CnuDlgModeless*)GetWindowLongPtr(hWnd, GWLP_USERDATA);; if (message == WM_INITDIALOG) { if (lParam) { This = (CnuDlgModeless*)lParam; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)This); return This->WndProcDlg(hWnd, message, wParam, lParam); } } else if (This == 0) { return FALSE; } return This->WndProcDlg(hWnd, message, wParam, lParam); } INT_PTR CnuDlgModeless::WndProcDlg( HWND hWnd, UINT msg, WPARAM wp, LPARAM lp ) { BOOL ret = FALSE; switch (msg) { case WM_INITDIALOG: ShowWindow(hWnd, SW_SHOW); ret = TRUE; break; case WM_CLOSE: DestroyWindow(hWnd); ret = TRUE; break; case WM_DESTROY: PostQuitMessage(0); ret = TRUE; break; } return ret; }
main.cpp
#include <Windows.h> #include "resource.h" #include <tchar.h> #include "CnuDlgModeless.h" class CnuDlgModeless_special : public CnuDlgModeless { //CnuDlgModalからオーバーライド。このために親クラスでvirtual指定をしている INT_PTR WndProcDlg( HWND hWnd, UINT msg, WPARAM wp, LPARAM lp ) { BOOL ret = FALSE; switch (msg) { case WM_INITDIALOG: ShowWindow(hWnd, SW_SHOW); ret = TRUE; break; case WM_CLOSE: DestroyWindow(hWnd); ret = TRUE; break; case WM_DESTROY: ret = TRUE; PostQuitMessage(0); return 0; } return ret; } }; /////////////////////////////////////////////////// //エントリーポイント int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) { CnuDlgModeless_special modelesssp; modelesssp.nuCreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), nullptr); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; }
CnuDlgModeless.zip
モーダルダイアログボックスを作成する関数には、DialogBoxの他にDialogBoxParamがある。
https://msdn.microsoft.com/ja-jp/library/cc410761.aspx
int DialogBoxParam( HINSTANCE hInstance, // アプリケーションのインスタンスのハンドル LPCTSTR lpTemplateName, // ダイアログボックステンプレートを指定します HWND hWndParent, // オーナーウィンドウのハンドル DLGPROC lpDialogFunc, // ダイアログボックスプロシージャへのポインタ LPARAM dwInitParam // 初期値 );
この初期値と呼ばれる第五引数dwInitParamは何かというと、ダイアログ初期化の際に呼ばれるWM_INITDIALOGのlParam値である。
オブジェクト指向ではないDialogBoxにとって、DialogBoxに渡せる、ユーザが任意に指定できるグローバル変数以外の唯一のパラメータがこれなのである。
以下はこのdwInitParamで初期値を渡す例である:
#include <Windows.h> #include "resource.h" #include <tchar.h> //ダイアログプロシージャ INT_PTR CALLBACK WndProcModal(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: if (lParam) { TCHAR* c = (TCHAR*)lParam; MessageBox(hWnd, c, 0, 0); } return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: MessageBox(hWnd, _T("IDOK"), 0, 0); EndDialog(hWnd, 0); return TRUE; } return FALSE; } return FALSE; } //エントリーポイント int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR lpCmdLine,int nCmdShow) { DialogBoxParam( hInstance, MAKEINTRESOURCE(IDD_DIALOG1), nullptr, WndProcModal, (LPARAM)_T("鵺")//このパラメータがWM_INITDIALOGのlParamへ入る ); return 0; }
要はCreateWindow関数の第十一引数lpParam「ウィンドウ作成データ」と同じ性質の物だと思えばいい。
https://msdn.microsoft.com/ja-jp/library/cc410713.aspx
これを使えば、CreateWindow関数の時と同様に、DialogBoxをカプセル化できる。考え方はCreateWindowの時と同じだ。
CnuDlgModal.h
#pragma once #include <windows.h> class CnuDlgModal{ INT_PTR m_dlg;//DialogBoxの戻り値 HINSTANCE m_hInstance; //このクラスで作成したモーダルダイアログの全てのイベントが入ってくるダイアログプロシージャ static INT_PTR CALLBACK StaticWndProcDlg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); public: HINSTANCE GetHInstance()const { return m_hInstance; } virtual ~CnuDlgModal() {} //DialogBoxParam関数の呼び出し INT_PTR nuDialogBox( const HINSTANCE hInst, LPCTSTR lpTemplate, HWND hWndParent ); //個別のウィンドウプロシージャ virtual INT_PTR WndProcDlg( HWND hWnd, UINT msg, WPARAM wp, LPARAM lp ); };
CnuDlgModal.cpp
#include "CnuDlgModal.h" //このクラスで作成したモーダルダイアログの全てのイベントが入ってくるダイアログプロシージャ INT_PTR CALLBACK CnuDlgModal::StaticWndProcDlg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { CnuDlgModal* This = (CnuDlgModal*)GetWindowLongPtr(hWnd, GWLP_USERDATA); if (message == WM_INITDIALOG) { if (lParam) { This = (CnuDlgModal*)lParam; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)This); return This->WndProcDlg(hWnd, message, wParam, lParam); } } else if (This == 0) { return FALSE; } return This->WndProcDlg(hWnd, message, wParam, lParam); } ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// //DialogBoxParam関数の呼び出し INT_PTR CnuDlgModal::nuDialogBox( const HINSTANCE hInst, LPCTSTR lpTemplate, HWND hWndParent ) { m_hInstance = hInst; m_dlg = DialogBoxParam(GetHInstance(), lpTemplate, hWndParent, (DLGPROC)CnuDlgModal::StaticWndProcDlg, (LPARAM)this); return m_dlg; } //個別のウィンドウプロシージャ INT_PTR CnuDlgModal::WndProcDlg( HWND hWnd, UINT msg, WPARAM wp, LPARAM lp ) { switch (msg) { case WM_CLOSE: EndDialog(hWnd, 0); PostQuitMessage(0); return TRUE; } return FALSE; }
main.cpp
#include <Windows.h> #include "resource.h" #include <tchar.h> #include "CnuDlgModal.h" //モーダルダイアログを扱うクラス class CnuDlgModal_special :public CnuDlgModal { //CnuDlgModalからオーバーライド。このために親クラスでvirtual指定をしている INT_PTR WndProcDlg(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp) override{ switch (msg) { case WM_COMMAND: switch (wp) { case IDOK: EndDialog(hWnd, 100); return TRUE; } return FALSE; case WM_CLOSE: EndDialog(hWnd, 0); return TRUE; } return FALSE; } }; /////////////////////////////////////////////////////// //エントリーポイント//////////////////////////////////// int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) { CnuDlgModal_special modalsp;//新たなモーダルダイアログを定義 modalsp.nuDialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), nullptr);//ダイアログ作成・待機 PostQuitMessage(0); return 0; }
CnuDlgModal.zip