Unityにある、Skybox/Cubemapのシェーダーは公開されているのでしょうか?6 Sidedなどは調べたら出てきたのですが...
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

回答1件
0
ベストアンサー
Unity ダウンロード アーカイブからビルトインシェーダーを入手し、その「DefaultResourcesExtra」フォルダの中の「Skybox-Cubed.shader」が目的のファイルかと思います。
2019.1.2f1版の内容は下記のようになっていました。
ShaderLab
1// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) 2 3Shader "Skybox/Cubemap" { 4Properties { 5 _Tint ("Tint Color", Color) = (.5, .5, .5, .5) 6 [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0 7 _Rotation ("Rotation", Range(0, 360)) = 0 8 [NoScaleOffset] _Tex ("Cubemap (HDR)", Cube) = "grey" {} 9} 10 11SubShader { 12 Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" } 13 Cull Off ZWrite Off 14 15 Pass { 16 17 CGPROGRAM 18 #pragma vertex vert 19 #pragma fragment frag 20 #pragma target 2.0 21 22 #include "UnityCG.cginc" 23 24 samplerCUBE _Tex; 25 half4 _Tex_HDR; 26 half4 _Tint; 27 half _Exposure; 28 float _Rotation; 29 30 float3 RotateAroundYInDegrees (float3 vertex, float degrees) 31 { 32 float alpha = degrees * UNITY_PI / 180.0; 33 float sina, cosa; 34 sincos(alpha, sina, cosa); 35 float2x2 m = float2x2(cosa, -sina, sina, cosa); 36 return float3(mul(m, vertex.xz), vertex.y).xzy; 37 } 38 39 struct appdata_t { 40 float4 vertex : POSITION; 41 UNITY_VERTEX_INPUT_INSTANCE_ID 42 }; 43 44 struct v2f { 45 float4 vertex : SV_POSITION; 46 float3 texcoord : TEXCOORD0; 47 UNITY_VERTEX_OUTPUT_STEREO 48 }; 49 50 v2f vert (appdata_t v) 51 { 52 v2f o; 53 UNITY_SETUP_INSTANCE_ID(v); 54 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 55 float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation); 56 o.vertex = UnityObjectToClipPos(rotated); 57 o.texcoord = v.vertex.xyz; 58 return o; 59 } 60 61 fixed4 frag (v2f i) : SV_Target 62 { 63 half4 tex = texCUBE (_Tex, i.texcoord); 64 half3 c = DecodeHDR (tex, _Tex_HDR); 65 c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb; 66 c *= _Exposure; 67 return half4(c, 1); 68 } 69 ENDCG 70 } 71} 72 73 74Fallback Off 75 76} 77
ZXY順オイラー角回転
ShaderLab
1// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) 2 3Shader "Skybox/Cubemap (3-Axis Rotation)" { 4Properties { 5 _Tint ("Tint Color", Color) = (.5, .5, .5, .5) 6 [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0 7 8 // 回転プロパティをX、Y、Zの3つに増やす 9 _RotationX ("Rotation X", Range(0, 360)) = 0 10 _RotationY ("Rotation Y", Range(0, 360)) = 0 11 _RotationZ ("Rotation Z", Range(0, 360)) = 0 12 13 [NoScaleOffset] _Tex ("Cubemap (HDR)", Cube) = "grey" {} 14} 15 16SubShader { 17 Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" } 18 Cull Off ZWrite Off 19 20 Pass { 21 22 CGPROGRAM 23 #pragma vertex vert 24 #pragma fragment frag 25 #pragma target 2.0 26 27 #include "UnityCG.cginc" 28 29 samplerCUBE _Tex; 30 half4 _Tex_HDR; 31 half4 _Tint; 32 half _Exposure; 33 34 // プロパティに合わせて回転角変数も3つに増やす 35 float _RotationX; 36 float _RotationY; 37 float _RotationZ; 38 39 // 回転用関数の名前を変更、引数をfloatからfloat3に変更 40 float3 RotateAroundZXYInDegrees (float3 vertex, float3 degrees) 41 { 42 // サイン、コサインも3成分についてそれぞれ算出し... 43 float3 alpha = degrees * UNITY_PI / 180.0; 44 float3 sina, cosa; 45 sincos(alpha, sina, cosa); 46 47 // 各軸周りの回転行列を作成し... 48 float3x3 rx = float3x3( 49 1.0, 0.0, 0.0, 50 0.0, cosa.x, -sina.x, 51 0.0, sina.x, cosa.x); 52 float3x3 ry = float3x3( 53 cosa.y, 0.0, sina.y, 54 0.0, 1.0, 0.0, 55 -sina.y, 0.0, cosa.y); 56 float3x3 rz = float3x3( 57 cosa.z, -sina.z, 0.0, 58 sina.z, cosa.z, 0.0, 59 0.0, 0.0, 1.0); 60 61 // Z軸、X軸、Y軸の順で回転を合成し... 62 float3x3 m = mul(ry, mul(rx, rz)); 63 64 // 回転を適用して返す 65 return mul(m, vertex); 66 } 67 68 struct appdata_t { 69 float4 vertex : POSITION; 70 UNITY_VERTEX_INPUT_INSTANCE_ID 71 }; 72 73 struct v2f { 74 float4 vertex : SV_POSITION; 75 float3 texcoord : TEXCOORD0; 76 UNITY_VERTEX_OUTPUT_STEREO 77 }; 78 79 v2f vert (appdata_t v) 80 { 81 v2f o; 82 UNITY_SETUP_INSTANCE_ID(v); 83 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 84 85 // 回転関数にX、Y、Z回転角を与える 86 float3 rotated = RotateAroundZXYInDegrees(v.vertex, float3(_RotationX, _RotationY, _RotationZ)); 87 88 o.vertex = UnityObjectToClipPos(rotated); 89 o.texcoord = v.vertex.xyz; 90 return o; 91 } 92 93 fixed4 frag (v2f i) : SV_Target 94 { 95 half4 tex = texCUBE (_Tex, i.texcoord); 96 half3 c = DecodeHDR (tex, _Tex_HDR); 97 c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb; 98 c *= _Exposure; 99 return half4(c, 1); 100 } 101 ENDCG 102 } 103} 104 105 106Fallback Off 107 108}
投稿2019/05/14 19:53
編集2019/05/16 01:19総合スコア10816
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2019/05/15 00:09
退会済みユーザー
2019/05/15 01:43
2019/05/15 09:01
退会済みユーザー
2019/05/15 11:32
2019/05/15 20:44
退会済みユーザー
2019/05/15 22:48
退会済みユーザー
2019/05/15 22:51
2019/05/16 01:30
退会済みユーザー
2019/05/16 08:23