Updates the handling of the baking of shape asset previews to generate them with support for view angle control to improve visibility, as well as supporting overriding of a material in the preview bake

Also utilizes the updated bake handling to have material asset previews render as a sphere shape asset, overriding with the material asset's material, improving distinction of what is a material asset vs image asset
Also updates the sphere preview mesh to be more generic and not only for reflection probes
This commit is contained in:
JeffR 2021-12-24 17:26:45 -06:00
parent d9bedbe31c
commit b70faae38f
10 changed files with 206 additions and 172 deletions

View file

@ -433,7 +433,7 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData)
%generatePreview = false;
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.png";
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
if(!isFile(%previewFilePath))
{
%generatePreview = true;
@ -457,17 +457,11 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData)
if(isObject(%assetDef.materialDefinitionName))
{
if(isFile(%assetDef.materialDefinitionName.getDiffuseMap(0)))
{
%difMap = %assetDef.materialDefinitionName.getDiffuseMap(0);
}
else if(%assetDef.materialDefinitionName.getDiffuseMapAsset(0) !$= "")
{
%imgAsset = AssetDatabase.acquireAsset(%assetDef.materialDefinitionName.getDiffuseMapAsset(0));
%difMap = %imgAsset.getImagePath();
}
%previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
%generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, %assetDef.materialDefinitionName);
%success = saveScaledImage(%difMap, %previewFilePath);
pathCopy(%generatedFilePath, %previewFilePath);
fileDelete(%generatedFilePath);
%previewAsset = new ImageAsset()
{

View file

@ -258,7 +258,7 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData)
%generatePreview = false;
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.png";
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
if(!isFile(%previewFilePath) || (compareFileTimes(%assetDef.getShapeFile(), %previewFilePath) == 1))
{
%generatePreview = true;
@ -272,21 +272,11 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData)
//This is slightly hacky, but we're going to utilize the imposter/last detail system
//to generate our previews for us and then clean up the unneeded bits
%oldImposterSetting = $TSLastDetail::dumpImposters;
$TSLastDetail::dumpImposters = true;
%filePath = %assetDef.generateCachedPreviewImage();
%imposterPath = %filePath @ ".imposter.png";
pathCopy(%imposterPath, %previewFilePath);
//cleanup
fileDelete(%imposterPath);
fileDelete(%filePath @ ".imposter.dds");
fileDelete(%filePath @ ".imposter_normals.png");
fileDelete(%filePath @ ".imposter_normals.dds");
$TSLastDetail::dumpImposters = %oldImposterSetting;
pathCopy(%filePath, %previewFilePath);
fileDelete(%filePath); //cleanup
%previewAsset = new ImageAsset()
{

View file

@ -1,6 +0,0 @@
<ShapeAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="ReflectProbeSphere"
fileName="@assetFile=ReflectProbeSphere.dae"
constuctorFileName="@assetFile=ReflectProbeSphere.tscript" />

File diff suppressed because one or more lines are too long

View file

@ -1,11 +0,0 @@
singleton TSShapeConstructor(ReflectProbeSpheredae)
{
baseShapeAsset = "ToolsModule:ReflectProbeSphere";
singleDetailSize = "0";
flipUVCoords = "0";
JoinIdenticalVerts = "0";
reverseWindingOrder = "0";
removeRedundantMats = "0";
animFPS = "2";
};

View file

@ -0,0 +1,6 @@
<ShapeAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="previewSphereShape"
fileName="@assetFile=previewSphereShape.dae"
constuctorFileName="@assetFile=previewSphereShape.tscript" />

File diff suppressed because one or more lines are too long