changing shader on the fly

Hi

I have a bunch of materials with my own little shader called “blended”. It is cpu intensive though, so I want to have an option to switch to the cheaper one “diffuse” on the fly.

Is this possible by script? To switch back and forth between the shaders on that material so that it will go faster.

Also, is it possible to change a texture from non-mipmap to mipmap on the fly? I’m guessing no since it’s an import feature so I would need to create 2 textures and switch among them on the fly (right? how to switch on script?)

Regards,
Joaquin

in code every material has a shader, so if you gain access to both of those you can use this attribute and swap it whenever you want

hi

thanks for the reply. I see the link but I see no sample code. If I want to change the shader to diffuse I just go shader=“difusse” ? since they are in the standard assets I don’t know how to reference it

Thanks. I didn’t see that one.
It did the trick :slight_smile:

About the mip maps, I guess the only choice is to duplicate the texture and change them on the fly right?

I’d just keep two materials as variables and switch what the renderer uses when appropriate. As for the mipmaps, you can’t change the way the texture was imported, but you can completely get rid of any contribution of the mipmaps using this, which you can change in real-time.

looks promising but the documentation is lacking :frowning:

if I want to remove mip maps completely what value should I use? I would like to display only the highest quality texture.

then if I want to put back all the mip maps, what value should I use?

I want the user to be able to select graphics quality on the fly

regards,
Joaquin

Not using mipmaps might reduce quality.

Zero.

Mipmaps are probably not the way to do it. This is. Specifically, this.