Game Development Community

Material updates

by Phil Carlisle · in Torque Game Engine Advanced · 04/17/2006 (5:17 pm) · 2 replies

Oooohkay.

I'm doing some render-to-texture cockpit controls. I've got the controls rendering into the texture fine, so I now need to take this further and map that new texture into the object rendering path.

So I've done some digging, I wrote a method to lookup and retrieve a GFXTexHandle for the texture I want to replace. However...

Of course, the shape (TSShapeInstance) doesnt render using the material itself!

ok.. here is what happens.

In TSShapeInstance::render it basically loops through each mesh, for each mesh, it calls the mesh's render method.

The mesh object inside its render function gets the material instance from the material object (getMaterialInst).

From that material instance, it calls setupPass() which effectively sets most of the render state.

Now that said, the materialinst contains a texture pointer and the texture ISNT the materials texture. Its basically the "instance" of that material. So changing the material texture isnt what I want to do, what I want to do, is change the material INSTANCE's texture.

Only, its stored as a set of render passes. Those render passes are setup based on how it reads and interprets the material specs. So if it can collapse passes it will.

This means it might be a bit risky simply changing a given texture index.

So... question is, whats a "safe" way of updating the texture inside the material instance???

Something I'm working on.

#1
04/17/2006 (5:58 pm)
Ahh, so I've fixed that.

Basically added a method on the Material Instance to get the texture handle of the first pass (assuming thats always going to be the base texture?), done that from the TSShapeInstance.

So... it kind of works. Just feels a tad kludgy, but I just needed it to work for now.
#2
08/10/2006 (8:12 pm)
This is a bit of an old post, but I was curious if you could post any source or such for this. I have put something together but it doesn't work exaclty like I think it should be


edit: I think I got it working with the SetSkinName information somebody had put together, just forgot I made changes to our Material loading (so it is done as-needed, not all at once).. so had to add in proper calls to load the Material