[SOLVED] Mipmap Bias

Hi,

I’m trying to push up the mipmap bias on a few materials, but having little luck following breadcrumbs in the docs.

The Scripting docs point to the Renderer class, which is fair enough… but I don’t see how I’m supposed to address all the Rendering components in my scene.

I’ve tried recursively searching with FindObjectsOfType from an Awake function in my initialisation script, but no matter what object type I try, it fails every time, usually with a NullException, and other times telling me the empty object my init script is attached to has no renderer (obviously).

I’m missing a lot of little things - it’s frustrating because in Obj-C I’d be doing this stuff over a cup of tea, but discovery in Unity is incredibly slow going. So don’t be shy to tell me I’m being thick (it’s getting late, too…!) :slight_smile:

Ta in advance,
Phil

You set mipmap bias on some particular texture: Texture.mipMapBias

(how did I find out? I entered “bias” in the scripting reference search box on the left)

Now, how do you access the texture, is up to you. You could use a script like this somewhere (typing out of my head, might not compile):

var textures : Texture[];
var bias = 0.0;
function Start() {
    for (var t in textures)
        t.mipMapBias = bias;
}

Now attach the script to any game object, setup array of textures bias value via Inspector.

Ahh excellent.

Thanks Aras. I am actually using the docs (how about a search facility on the Manual and Reference pages too?), but was going about assignments the wrong way.

Exposing variables as targets in the IDE is nice, very Renderware, but I was trying to access Components of other GameObjects explicitly - I think I need to read the docs from scratch to find this as, while the texture bias code works (your example compiled first time, ta), I’ll still need to do this later on.

I’ll keep that for another post though :wink:

My near clip is 2.0 btw…:wink:

Is there any way to use a texture’s Alpha in order to map the mipmaps of another texture?