Start a new topic
Answered

Enable GPU instancing on imported materials

Hi,


I use the plugin to import models at runtime.

How can I enable GPU instancing on the imported materials?


Thanks,

Carsten


Best Answer

Hello Carsten,


GPU instancing is a property accessible in the Unity Material component.

You'd have to create a script parsing the Material components of your imported model and enable the parameter. But I'm not sure this property is accessible at runtime. Something like:


using UnityEngine;
using PiXYZ.Utils;
using System.Collections.Generic;
using System.Linq;
 
[...]
 
gameObject.GetChildren(true, true).GetMaterials().ToList().ForEach(x => x.enableInstancing = true);




Answer

Hello Carsten,


GPU instancing is a property accessible in the Unity Material component.

You'd have to create a script parsing the Material components of your imported model and enable the parameter. But I'm not sure this property is accessible at runtime. Something like:


using UnityEngine;
using PiXYZ.Utils;
using System.Collections.Generic;
using System.Linq;
 
[...]
 
gameObject.GetChildren(true, true).GetMaterials().ToList().ForEach(x => x.enableInstancing = true);



Hi Nicolas,


right, but I expected there would be an option for the importer that directly enables that parameter while importing.

At least this is a feature request :-)


Thanks,

Carsten

Login or Signup to post a comment