MaterialSetMaterial type action?

#1

Is there a way to capture the material from one entity and apply it to another? For now I am saving each texture to a DataTable but it is tedious to setup.

0 Likes

#2

There isn’t such action atm. One of the issue to consider is that when you set a custom material on another entity it might require a completely different set of shaders, this is an issue with MaterialSetTexture to a degree aswell but its much much smaller since its only a possible issue if you set a texture that has never been used before. With something like MaterialCopy (from one mesh to another) you have to take into account everything, including custom shaders, the flags, etc… and there there’s a lot of potential issue.

One of the real potential problem is that you wont have the shaders you need once the app is packaged.

That being said maybe “happy medium” could be attained. One way could be to just add a MaterialCopyTexture with a “copy all channels” and/or MaterialCopyColor and/or MaterialCopyChannel.

MaterialCopyChannel would look somewhat like this:

  • CopyTexture: On/Off
  • CopyColor: On/Off
  • SourceEntity
  • SourceChannel: Channel to copy in the source
  • DestinationEntity
  • DestinationChannel: Channel to copy to in the destination

How does that sound?

1 Like

#3

I can see how there could be some issues but the way you described a possible solution is infinity better than then brutal hack job I am doing right now. In my use case the materials are already in scene and will be copied to a similar mesh. Each mesh has 8 materials with Diffuse, Diffuse Modulate, Opacity, Specular, Emissive, Environment, Refractive textures and then the respective Vec3 values. Creating a DT to hold all that info takes a lot of time to setup without messing up and each mesh needs to have their info copied to the property values.

Your proposed actions sound excellent to me. Even if I have to use several actions instead of one ‘CopyMaterial’ it will remove a lot of stress from the process.

So the way I am looking at the CopyChannel action is that for each channel used I would just add another CopyChannel - Diffuse, Opacity, Specular… right?

For my use the 'MaterialCopyTexture with a “copy all channels” would work best if that means it is copying the material and all the textures and channels used with it.

CopyTexture, CopyColor, and CopyChannel would all be very useful actions for general development. They would allow a great deal of freedom and expand the state of the possible.

TL;DR:
It sounds great!

0 Likes

#4

So the way I am looking at the CopyChannel action is that for each channel used I would just add another CopyChannel - Diffuse, Opacity, Specular… right?

Yes. But its probably going to end up with an “all channels” flag so that should take care of that.

I’ve added MaterialCopyChannel to the todo list :slight_smile:

1 Like