Skip to content

Commit

Permalink
matdbg: add more info to the details panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
prideout committed Aug 23, 2019
1 parent 2af8ef8 commit 8765343
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
39 changes: 35 additions & 4 deletions libs/matdbg/src/JsonWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ static std::string arraySizeToString(uint64_t size) {
return "";
}

template<typename T, typename V>
static void printChunk(ostream& json, const ChunkContainer& container, ChunkType type,
const char* title) {
T value;
if (read(container, type, reinterpret_cast<V*>(&value))) {
json << "\"" << title << "\": \"" << toString(value) << "\",\n";
}
}

static void printFloatChunk(ostream& json, const ChunkContainer& container, ChunkType type,
const char* title) {
float value;
if (read(container, type, &value)) {
json << "\"" << title << "\": " << setprecision(2) << value << ",\n";
}
}

static void printUint32Chunk(ostream& json, const ChunkContainer& container,
filamat::ChunkType type, const char* title) {
uint32_t value;
Expand All @@ -71,11 +88,25 @@ static bool printMaterial(ostream& json, const ChunkContainer& container) {
printUint32Chunk(json, container, filamat::MaterialVersion, "version");
printUint32Chunk(json, container, filamat::PostProcessVersion, "pp_version");
json << "\"shading\": {\n";
// TODO
json << "},\n";
printChunk<Shading, uint8_t>(json, container, MaterialShading, "model");
printChunk<VertexDomain, uint8_t>(json, container, MaterialVertexDomain, "vertex_domain");
printChunk<Interpolation, uint8_t>(json, container, MaterialInterpolation, "interpolation");
printChunk<bool, bool>(json, container, MaterialShadowMultiplier, "shadow_multiply");
printChunk<bool, bool>(json, container, MaterialSpecularAntiAliasing, "specular_antialiasing");
printFloatChunk(json, container, MaterialSpecularAntiAliasingVariance, "variance");
printFloatChunk(json, container, MaterialSpecularAntiAliasingThreshold, "threshold");
printChunk<bool, bool>(json, container, MaterialClearCoatIorChange, "clear_coat_IOR_change");
json << "\"_\": 0 },\n";
json << "\"raster\": {\n";
// TODO
json << "},\n";
printChunk<BlendingMode, uint8_t>(json, container, MaterialBlendingMode, "blending");
printFloatChunk(json, container, MaterialMaskThreshold, "mask_threshold");
printChunk<bool, bool>(json, container, MaterialColorWrite, "color_write");
printChunk<bool, bool>(json, container, MaterialDepthWrite, "depth_write");
printChunk<bool, bool>(json, container, MaterialDepthTest, "depth_test");
printChunk<bool, bool>(json, container, MaterialDoubleSided, "double_sided");
printChunk<CullingMode, uint8_t>(json, container, MaterialCullingMode, "culling");
printChunk<TransparencyMode, uint8_t>(json, container, MaterialTransparencyMode, "transparency");
json << "\"_\": 0 },\n";
return true;
}

Expand Down
32 changes: 27 additions & 5 deletions libs/matdbg/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
name = {{ name }}
version = {{ version }}

DIR = DIRECTIONAL_LIGHTING
DYN = DYNAMIC_LIGHTING
SRE = SHADOW_RECEIVER
SKN = SKINNING_OR_MORPHING

<b>Required attributes</b>
{{#required_attributes}}
{{.}}
{{/required_attributes}}

DIR = DIRECTIONAL_LIGHTING
DYN = DYNAMIC_LIGHTING
SRE = SHADOW_RECEIVER
SKN = SKINNING_OR_MORPHING

<b>OpenGL shaders</b>
{{#opengl}}
<a class="shader {{classes}}" data-glindex="{{index}}">{{index}} {{shaderModel}} {{pipelineStage}} {{variantString}}</a>
Expand All @@ -58,6 +58,28 @@
{{#metal}}
<a class="shader {{classes}}" data-metalindex="{{index}}">{{index}} {{shaderModel}} {{pipelineStage}} {{variantString}}</a>
{{/metal}}

<b>Material details</b>
{{#shading}}
shading model = {{model}}
vertex domain = {{vertex_domain}}
interpolation = {{interpolation}}
shadow multiply = {{shadow_multiply}}
specular antialiasing = {{specular_antialiasing}}
variance = {{variance}}
threshold = {{threshold}}
clear coat IOR change = {{clear_coat_IOR_change}}
{{/shading}}
{{#raster}}
blending = {{blending}}
mask threshold = {{mask_threshold}}
color write = {{color_write}}
depth write = {{depth_write}}
depth test = {{depth_test}}
double sided = {{double_sided}}
culling = {{culling}}
transparency = {{transparency}}
{{/raster}}
</pre>
</template>

Expand Down

0 comments on commit 8765343

Please sign in to comment.