Search Unity

[ShaderForge] Does anyone know how to get texture splatting working in C#?

Discussion in 'Formats & External Tools' started by Lethn, Sep 11, 2017.

  1. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    So I was lucky enough to spot the sale on shader forge and I have been keeping my eye on this really nice looking software for a very specific reason, not least of which because of the amazing dissolve effects and so on but because of what I now know is called 'texture splatting'.

    I did some digging and found a tutorial on how to make these effects and that's all well and good but what I'm looking for is how on earth do I get this transferred to script if it is at all possible?

    http://acegikmo.com/shaderforge/wiki/index.php?title=Texture_Splatting#Using_Vertex_colors

    Now some people may remember awhile back I actually made a thread about this and shader forge was suggested to me as a genuine way of doing it, now I have it, I'm going to re-visit this issue again. The ideal thing I'd like to do is to have whatever shader I choose be put onto a gameobject with a mouse click or any sort of event, I just need to know how to access these shaders through a script and apply them.

    An example of this would be Starcraft 2, where you have the zerg creep spreading across the floor.

     
  2. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    I just had a total duh moment as you do and realised that what I'm talking about is likely completely separate from shader forge, it just creates the shaders you need easily. So what I would need to do is access the shader itself through unity and load that up then have it instantiate on a mouse position.

    In this case, it seems that SetPixels is the appropriate thing, so what I'll need to do is figure out how to load up a shader, then use SetPixels on the current mouse position which should then hopefully put the nice blending effect straight onto whatever gameobject I'm using.

    http://answers.unity3d.com/questions/178778/painting-on-objects-at-runtimeor-not.html

    Let me know if I have the right idea guys, it seems to all check out.

    Edit: I think I found the right sort of thing, it wasn't SetPixels at all, I had no idea SetTexture could be used for loading up shaders as well, so for the painting things onto the terrain at least I just need to make my shader in shader forge.

    http://answers.unity3d.com/questions/143680/painting-on-textures-at-runtime.html

    Looks like I've got a whole new topic to learn about.
     
    Last edited: Sep 12, 2017
  3. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    I just found a really great video by the shader forge creator that goes into scripting shaders and how to tweak things during runtime.