Skip to content

Commit

Permalink
#6212: Add examples to materialtest.py. Tweak MaterialSourceGenerator…
Browse files Browse the repository at this point in the history
… whitespace output.
  • Loading branch information
codereader committed Jan 2, 2023
1 parent 44733cb commit d2cda5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions install/scripts/materialtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
print('Coverage: {0}'.format(newMaterial.getCoverage()))
print('Light Falloff Map Type: {0}'.format(newMaterial.getLightFalloffCubeMapType()))
print('Renderbump Arguments: {0}'.format(newMaterial.getRenderBumpArguments()))
print('FrobStage Type: {0}'.format(newMaterial.getFrobStageType()))

# There are a couple of pre-defined sort requests, corresponding to the engine code
newMaterial.setSortRequest(dr.Material.SortRequest.NEAREST)
Expand All @@ -67,6 +68,17 @@
newMaterial.setIsBlendLight(0)
newMaterial.setDescription("New Material")

newMaterial.setFrobStageType(dr.Material.FrobStageType.DIFFUSE)
newMaterial.setFrobStageParameter(0, 0.4) # assign the same value to all RGB components
newMaterial.setFrobStageRgbParameter(1, dr.Vector3(0.1, 0.2, 0.3)) # assign RGB components separately

print('\n\Material definition with frobstage_diffuse:\n{0}\n{{{1}}}\n\n'.format(newMaterial.getName(), newMaterial.getDefinition()))

newMaterial.setFrobStageType(dr.Material.FrobStageType.TEXTURE)
newMaterial.setFrobStageMapExpressionFromString("textures/common/white")

print('\n\Material definition with frobstage_texture:\n{0}\n{{{1}}}\n\n'.format(newMaterial.getName(), newMaterial.getDefinition()))

stageIndex = newMaterial.addStage(dr.MaterialStage.Type.BLEND)

print('Material has now {0} stages'.format(newMaterial.getNumStages()))
Expand Down
4 changes: 3 additions & 1 deletion radiantcore/shaders/MaterialSourceGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ std::ostream& operator<<(std::ostream& stream, ShaderTemplate& shaderTemplate)
// FrobStage keywords
if (shaderTemplate.getFrobStageType() != Material::FrobStageType::Default)
{
stream << "\n";
stream << "\n\t";
stream << getStringForFrobStageType(shaderTemplate.getFrobStageType());

if (shaderTemplate.getFrobStageType() == Material::FrobStageType::Texture)
Expand All @@ -710,6 +710,8 @@ std::ostream& operator<<(std::ostream& stream, ShaderTemplate& shaderTemplate)
stream << " ";
writeScalarOrVector3(stream, shaderTemplate.getFrobStageRgbParameter(1));
}

stream << "\n";
}

return stream;
Expand Down

0 comments on commit d2cda5f

Please sign in to comment.