Skip to content

Commit

Permalink
add option for not baking textures to file
Browse files Browse the repository at this point in the history
to improve performance when the textures aren't being viewed
  • Loading branch information
juliasfx committed Aug 13, 2019
1 parent e802eea commit 80a9016
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Asset.C
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ void
Asset::computeMaterial(
const MPlug& plug,
MDataBlock& data,
AssetNodeOptions::AccessorDataBlock &options,
bool &needToSyncOutputs
)
{
Expand All @@ -957,7 +958,7 @@ Asset::computeMaterial(
MPlug materialPlug = materialsPlug.elementByLogicalIndex(i);
MDataHandle materialHandle = data.outputValue(materialPlug);

myMaterials[i]->compute(myTime, materialPlug, data, materialHandle);
myMaterials[i]->compute(myTime, materialPlug, data, materialHandle, options.bakeOutputTextures());
}
}

Expand Down Expand Up @@ -1142,7 +1143,9 @@ Asset::compute(
options,
needToSyncOutputs);

computeMaterial(plug, data, needToSyncOutputs);
computeMaterial(plug, data,
options,
needToSyncOutputs);

return stat;
}
Expand Down
1 change: 1 addition & 0 deletions Asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Asset {
void computeMaterial(
const MPlug& plug,
MDataBlock& data,
AssetNodeOptions::AccessorDataBlock &options,
bool &needToSyncOutputs
);

Expand Down
1 change: 1 addition & 0 deletions AssetNodeOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NODE_OPTION(outputMeshPreserveLockedNormals, bool, true)
NODE_OPTION(ungroupOnBake, bool, true)
NODE_OPTION(updateParmsForEvalMode, bool, true)
NODE_OPTION(connectGeoForAssetInputs, bool, false)
NODE_OPTION(bakeOutputTextures, bool, true)

NODE_OPTION(useInstancerNode, bool, true)

Expand Down
7 changes: 4 additions & 3 deletions OutputMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ OutputMaterial::compute(
const MTime &time,
const MPlug &materialPlug,
MDataBlock &data,
MDataHandle &materialHandle
MDataHandle &materialHandle,
bool bakeTexture
)
{
HAPI_Result hapiResult;
Expand Down Expand Up @@ -155,9 +156,9 @@ OutputMaterial::compute(

bool hasTextureSource = ((std::string)Util::HAPIString(texturePathSH)).size() > 0;
bool canRenderTexture = false;
if(hasTextureSource)
if(hasTextureSource && bakeTexture)
{
// this could fail if texture parameter is empty
// this could fail if texture parameter is empty
hapiResult = HAPI_RenderTextureToImage(
Util::theHAPISession.get(),
myNodeId,
Expand Down
3 changes: 2 additions & 1 deletion OutputMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class OutputMaterial
const MTime &time,
const MPlug &materialPlug,
MDataBlock &data,
MDataHandle &materialHandle
MDataHandle &materialHandle,
bool bakeTexture
);
private:
void update(MDataHandle &materialHandle);
Expand Down
10 changes: 10 additions & 0 deletions scripts/AEhoudiniAssetTemplate.mel
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,11 @@ global proc AEhoudiniAssetOptionsNew(string $attr)
"Connect Geo For Asset Inputs",
"When setting an input to a geo output of another asset, connect through the geo, not directly from the asset"
);
createAttrCheckBox(
"bakeOutputTextures",
"Bake Output Textures",
"When an Output Material has a Texture, bake to a file texture. Turn this off to improve performace when the texture is not needed."
);


setParent ..;
Expand Down Expand Up @@ -891,6 +896,10 @@ global proc AEhoudiniAssetOptionsReplace(string $attr)
$optionsLayoutFull + "|outputLayout|connectGeoForAssetInputs",
$nodeName + ".connectGeoForAssetInputs",
"");
replaceAttrCheckBox(
$optionsLayoutFull + "|outputLayout|bakeOutputTextures",
$nodeName + ".bakeOutputTextures",
"");
replaceAttrCheckBox($optionsLayoutFull + "|outputLayout|useInstancerNode",
$nodeName + ".useInstancerNode",
"houdiniEngine_syncAssetOutput \"" + $nodeName + "\";");
Expand Down Expand Up @@ -982,6 +991,7 @@ global proc AEhoudiniAssetTemplate(string $nodeName)
editorTemplate -suppress "output";
editorTemplate -suppress "ungroupOnBake";
editorTemplate -suppress "updateParmsForEvalMode";
editorTemplate -suppress "bakeOutputTextures";
editorTemplate -suppress "connectGeoForAssetInputs";

editorTemplate -suppress "useInstancerNode";
Expand Down

0 comments on commit 80a9016

Please sign in to comment.