Search Unity

Generating "wetness" mask

Discussion in 'Scripting' started by Ante, Aug 21, 2014.

  1. Ante

    Ante

    Joined:
    Oct 21, 2010
    Posts:
    48
    I was wondering how one might dynamically generate a texture to control the wetness of a rigged mesh, where white is wet and black is dry. What I'd want to do is generate a texture where, if a part of a skinned mesh is below a certain world point, white is drawn at that point in the texture. I can make a shader that draws white if the geometry is below a certain world point, but can I generate a texture from that? I'm pretty sure you can't? I don't think you can save this sort of thing in memory in the shader for the next frame to use, either.

    Anyway, how would you go about doing something like this? Basically, I want parts of a skinned character to be able to get wet by going into a pool of water in game and stay wet after leaving the pool.
     
  2. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Do you want the shader to work or the texture? If you want it to be shader then it would be easy. Manipulate the texture if it is below a world point. If you post that partial shader then I can work on it. But it may not work as you predict. :) Reason is a skinned mesh can be in any position below world point every anim frame.
     
  3. Ante

    Ante

    Joined:
    Oct 21, 2010
    Posts:
    48
    Can you manipulate a texture through a shader? If so, that would be the easiest. The texture would need to be saved for later so it can be used to display wetness when parts are not below a certain point. I don't have a shader to test with readily available. Could you just do something simple like modify the main texture of a simple textured shader?
     
  4. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Yes i would just bump up the glossy ness or somthing like that to make it look wet
     
  5. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    You cant save or manipulate the texture directly, but with parameters you can fake the wetness for later use too. But as said earlier, animated meshes would not look correct. I would like to see your wetness shader to give you a precise answer as what will work.
     
  6. Ante

    Ante

    Joined:
    Oct 21, 2010
    Posts:
    48
    I don't have a wetness shader. I'm on vacation and can't currently make one. The concept is pretty simple, though. I want to generate an image to use as a wetness mask where white is wet and black is dry. I'd just do it with the vertexes if I could, but you can't get the position of vertexes on rigged meshes.

    Basically, if I could "bake" an unshaded shader into a texture somehow, that would work fine. I'm not sure that's possible though.
     
  7. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    If anyone ever needs it i made a simple wetness shader using ShaderForge (I tested it without shader forge so it works if you dont own it)

    http://pastebin.com/Mm1LUtZ1

    it takes a texture and a normal map
     
    Roman_Keivan likes this.
  8. Ante

    Ante

    Joined:
    Oct 21, 2010
    Posts:
    48
    Thanks. My plan is to make a shader in shader forge with a mask. If I can't find a way to do this dynamic wetness, I'll find a way to fake it.
     
    Roman_Keivan likes this.
  9. Roman_Keivan

    Roman_Keivan

    Joined:
    May 31, 2019
    Posts:
    22