x


changing both texture images on a material

i have an object which has a diffuse detail material attached. i want to be able to change both the main texture and the detail texture at different times. how would i refer to each element to do so? (the scenario is a car which changes colour on the main texture, but also gets dirtier on the detail texture

doorMaterial.mainTexture = doorColour[doorTexture];

this is the code i am using to change the car colour on the main texture

thanks

more ▼

asked Jan 03 '12 at 03:18 PM

mehowe7 gravatar image

mehowe7
31 15 15 17

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Use Material.SetTexture(). To know the name of a texture you will need to look at shader code used by the material. For builtin shaders take a look here.

The code for a material using Diffuse Detail would be:

doorMaterial.SetTexture("_Detail", detailTexture);
more ▼

answered Jan 03 '12 at 04:10 PM

luizgpa gravatar image

luizgpa
851 4 9

thankyou for that. I've used the _detail and an array to change them. do you know how i could fade between 2 details?

Jan 16 '12 at 11:50 AM mehowe7

I can think of 2 ways:

1 - create a texture dynamically that mix 2 detail textures you want to fade.

2 - write a shader, based on the built-in, that takes 2 textures instead of 1 and interpolate between them.

I don't know how are you planning to use it, but I think the 2nd approach would be better in most of the cases. It requires some shader programming skills though.

Jan 16 '12 at 02:43 PM luizgpa

I have gone with option 2, thank you. the shader has a main texture with 3 overlaying details. I'm just working out now how to apply alpha channels to the details to fade each one in

Jan 16 '12 at 04:32 PM mehowe7
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2197
x813
x57
x54
x36

asked: Jan 03 '12 at 03:18 PM

Seen: 781 times

Last Updated: Jan 16 '12 at 04:32 PM