Texture visibility switch


(CYNIC78) #1

Hello all. Is there way to dynamicly change texture visibility in BGE? Let’s say my mesh has base and secondary texture that i want to be visible only when i need. I was trying to make action changing texture color from 0 to 1 but such action doesn’t work in game and even in preview window. How to do such thing?


(Chaosfuchs GameDev) #2

replaceMesh()
or
a childObject with the second texture with visible and invisble logic


(CYNIC78) #3

Thank you for advice.


(Daedalus_MDW) #4

mix rgb by object color


(CYNIC78) #5

Hello Deadalus. Will it be possible to apply “dirt” texture (or any other “overlay” texture) over base texture using such technique? Could you be so kind to explain how exactly achive this with mix RGB?


(Daedalus_MDW) #6

if you are using upbge, then object color is easier to get.

but all you need to do is mix the textures, then after add another mix rgb with you dirt texture. mix rgb is mostly the same as traditional material texture settings. mix, multiply, overlay, etc. fac is like the slider.

after that, plug into diffuse of a material node, then into output.

repeat for glossy. however, the object color mixer can be reused/branched off.


(CYNIC78) #7

Thank you very much for directing me. I am currently using BGE. It seems this is what i want. If I got it right I can easily “apply” overlay effects like scars, blood or dirt overlays using only fac ‘slider’. I am gonna try this.


(Daedalus_MDW) #8

with normal bge:

  • Shader material is a normal material. add bumpmaps into this material (select it and texture tab)
  • Material is the material assigned to the object (IMPORTANT) and is shadeless and has object color checked

(Daedalus_MDW) #9

upbge 0.2.0 object color node makes it easy. added an optional greater than to prevent mixing.


(CYNIC78) #10

Ok I done what you say and it’s works. I can control mix value via animating object color. Base texture is mixing with overlay and i get some kind dirt over surface. This is cool feature .
I have question how to make ‘overlay’ texture not to mix with base one but completely ‘replace’ it? I was playing with these nodes but yet didn’t managed to do it. Couldn’t you show me pleeeez. :slight_smile: Here is my example blend - spacebar to activate action:

RGB mix.blend (987.0 KB)


(Cotaks) #11

(Daedalus_MDW) #12

Blue nodes are one texture setup, Yellow is the other. the Detail texture is any shared effects, like dirt.

Alternative, simpler. Details are added after the mix, so the same effect apply to both textures


(CYNIC78) #13

Thank you guys. Now i have two variants to switch textures\add overlays - via python or material nodes. I will use both for different situations! This is great.