3D Fish Tank debuts

Posted by admin
May 19 2009

You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “3D Fish Tank debuts”.

Subscribe without commenting

2 Responses

  1. Fang Jin says:

    I came by your post at unity forum, very impressed, just wonder how this illusion of moving water is implemented, I am working on a project of tumor growth, needs some water illusion.

    thanks
    Fang

    • admin says:

      It is very simple. Just find a little software software named : Caustic Generator. With this software, generate a list of pictures JPG of the caustic animation.
      Then create a plane and give it a material that is Transparent / Vertext Lit
      Drag and drop this script on your plane :


      #pragma strict
      //@script ExecuteInEditMode
      public var material : Material;
      public var caustics : Texture[];
      public var framesPerSecond =0.5;
      private var shader : Shader = null;
      var exindex : int=0;
      function Start()
      {
      shader = Shader.Find("Transparent/VertexLit");
      material.SetTexture("_MainTex", caustics[0]);
      }
      function Update ()
      {
      if (exindex!=GUIstuff.indexcaustics)
      {
      exindex = GUIstuff.indexcaustics;
      material.SetTexture("_MainTex", caustics[exindex]);
      }
      }

      Now with your script in the inspector, you can decide of the number of texture of your animation (set it to the number of textures you generated with Caustic Generator).
      You need to drag and drop each textures in the right order in their respective spots. (I use 16 textures animations and name them caustic01.jpg caustic02.jpg etc…)

      Now run and it should work… you can even set the speed of the animation in Frames per seconds!

You must be logged in to post a comment.

Trackback URL for this entry