Search Unity

Get Mud Off of Object

Discussion in 'Editor & General Support' started by renman3000, Jan 16, 2020.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,699
    Hi there
    If you can imagine a game where you need to hand wash an object, like a shoe, or dish or window and this object has mud, or dirt, some caked on, some more fluid etc,...

    a) how would you “paint” this object in a random coating pattern of mud and dirt etc? Would you use shaders or actual model objects?
    b) and how would you “wash it” off?

    Image shown is an example of something I like but not particularly exactly what I am going for.

    Anyhow,
    Thank you
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I haven't personally done this, but I think a reasonable approach would be the following:
    • Create a procedural map, starting off all white, to represent the dirt. Call it a dirt map. Have the shader use the dirt map to apply the actual dirt texture to the UV coordinates indicated in the dirt map.
    • Use RaycastHit.textureCoord to determine the coordinates of the part being cleaned, and set those pixels to black in the dirt map.
    Seems reasonably simple, but again, I haven't tested it. Probably a bit more complex when you're dealing with sub-objects, or multiple renderers.
     
    renman3000 likes this.
  3. dmennenoh

    dmennenoh

    Joined:
    Jul 1, 2015
    Posts:
    379
    I think something like this would work for you:
     
    renman3000 likes this.