mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
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:
parent
d9bedbe31c
commit
b70faae38f
10 changed files with 206 additions and 172 deletions
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue