0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Adobe Substance 3D Painterのシェーダーについて (1)

Last updated at Posted at 2025-01-04

環境

  • Windows
  • Adobe Substance 3D Painter 10.1.2

シェーダーコードについて

Substance 3D Painterの使用されるシェーディング言語はGLSLです。
ただし、コーディング可能なのはフラグメントシェーダーの一部 (サーフェースシェーダー) のみです。また、独自の書式を用いてパラメータ調整用のUIを定義出来ます。

エントリーポイント

shade関数がエントリーポイントです。

void shade(V2F inputs);

シェーダーリソースを作成するにはこの関数が必要です。

頂点シェーダーから渡されるデータ

頂点シェーダーからフラグメントシェーダーに渡されるデータは構造体 V2F として定義されています。

struct V2F { 
  vec3 normal;
  vec3 tangent;
  vec3 bitangent;
  vec3 position;
  vec4 color[1];
  vec2 tex_coord;
  SparseCoord sparse_coord;  
  vec2 multi_tex_coord[8];
};

上記の値のみモデルデータ (FBX, USDなど) から参照可能です。

フラグメントのプロパティの設定

定義済みの関数を用いてフラグメントのプロパティを設定することで最終出力が決まります。

void alphaOutput(float);  // default: 1.0
void diffuseShadingOutput(vec3);  // default: vec3(0.0) 
void specularShadingOutput(vec3);   // default: vec3(0.0) 
void emissiveColorOutput(vec3);  // default: vec3(0.0) 
void albedoOutput(vec3);  // default: vec3(1.0) 
void sssCoefficientsOutput(vec4);  // default: vec4(0.0) 

また、デフォルト値から変更しないプロパティについては設定の省略が可能です。

シンプルなサンプルコード

void shade(V2F inputs) { 
	diffuseShadingOutput(vec3(1.0)); 
}

Substance 3D Painter の基本的なレンダリング方程式は

emissiveColor + albedo * diffuseShading + specularShading 

となるため、上記のサンプルでは最終出力が白となります。

公式ドキュメント

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?