Joint-based Hair / Cloth Physics for Unity

I was doing the MMD4Unity research. I do this because, on Google, if you want a Hair Physics, you have to wrote a script, or key frame it naturally in your model. Ain’t nobody got time for that keyframing! So, this might be very useful for easy Joint-based hair / cloth physics, even wrote a script was useful too.

Okay, so it’ll be like this. It could be very awesomely epic if you are not lazy to set the character joint setting.

“It’s long and complicated, i better use keyframe method.” Yeah true, but what to do when the hair colliding object because of your keyframing method ?

Let’s get Neru Akita as example (Model from MMD, some motion from Unity-chan).

Unity 2014-07-27 14-07-06-60_2

1. Now Select cloth / hair bones and then add Capsule Collider like the picture below.
1(bones)

2. After that, adjust the size of the colliders and then add Character Joint.
2(bones)

3. If your character has a Character Controller on it / Playable, Open Tags & Layer, add 2 layers. Set ‘Player’ layer to object that has Character Controller on it. Else, set the object that you want to have a hair / cloth physics like Hair Bones1, Hair Bones2, and so on, or Hair/Cloth physics collider like MidSpine (That has Collider, so hair / cloth wont clip like hell). Basically, Just set Cloth Layer to Skinned Mesh Renderer, and set it to all children.
3b (Bones)

4. Go to your character controller script. Whatever script is OK as long as its located on Object that has Character Controller on it. Don’t make a new script. Just add this line to function Start() or void Start(). Works on both C# and JS. 8 is Cloth layer, 9 is Player layer. it’s all up to you on what layer you set the Cloth or Player layer. If you set cloth layer to 10, then write 10.

Physics.IgnoreLayerCollision(8,9);

3c (bones)
5. Alright now let’s add Rigidbody on cloth’s / hair’s root bone. For the root of the cloth (like this below), turn on isKinematic and turn off useGravity. Root doesn’t need a Character Joint, Collider is optional.

4 (bones)
6. Now set the Character Joint’s connected body. For instance, 1 (Cloth Root), 2 (1′s child), 3 (2′s child). 3′s connected body is 2, 2′s connected body is 1, and 1 doesn’t have a Character Joint. Like the picture below.
5 (bones)
7. Set bone’s swing limit, spring, high twist limit, low twist limit that suits to your model.
6 (bones)
8. Now add some collider to body that Hair or cloth will collide. Remember to set the body layer to CLOTH, so your character controller wont collide it. I add the colliders on Body, Hands, and Head.
7 (bones)

Because if you don’t add colliders, it’ll look like this:
Unity 2014-07-27 14-07-06-60

Now look! A cloths dynamic! It much better than the method I use on Wild West Showdown (Skinned Cloth). Look at her front hair and tie.
Unity 2014-07-27 14-07-06-60_1

 

As I said, I leave making games because I need to level up my CG level. I said I was give up right ? No, and never. I just need to learn to make a better CG Artwork. I’m currently making a mascot model for Imagination, named Imajine-chan. but, I don’t have an inspiration for her character design.

If you have something to ask, don’t hesitate to comment, I’ll reply it fast.

EDIT : “My Character raycast’s script is broken because of this.” Well, you could replace Cloth to IgnoreRaycast layer.

Random Rant About Copyright

NOTE : I’m kinda off for a while. You maybe wont see any research for a while. I’ll be back on August or September, I’m kinda busy on upgrading my CG Level. Sorry about that.

I already had this problem since 2009, and real hate with all those copyrights. The creator of copyright is just like they want an infinite money. I seriously don’t care about copyright.

Remember that day, October 31 2013, my game Nitro Racer XD Full Version was shared freely in the universe by VACE ? Do I really care about it ? I don’t even got a penny from making this game, and my game was shared in the universe, but I ain’t even mad. If you were the creator of Nitro Racer XD, you would kill all of them. I just like “Meh, if they pirated my game, that means my game was nice.” Okay, let’s return to the topic.

So, how can I say that if Copyright is a Creativity Killer. Look, if you are a famous singer, you made a song, and then someone cover your song and said “I do not own this song, all copyright goes to <your name>”, but you still insist to kill / block them, then you’re a total a****le for blocking them.

I feel sad for my client that already made more than 10 fan videos for famous singer as tribute on YouTube. They made it really nice and good, they even always bought original CD and souvenirs. And you know what ? Sorry this video has been copyrighted by “Copyright-thirsty company”. That’s such a waste of time, energy, and internet (it’s a struggle to upload 300MB with slow internet).

Back then, when I was dumb, I made a remix of Canon song and it was blocked by SoundCloud or YouTube. Does that mean Johann Pachelbel going to sue me ? After that incident, I started to compose my own song, even it’s bad as hell.

Because of this, I’m concerned to make A Certain Musical Vocaloid 3D Animation Experiment. Will it be banned by YouTube because I make a crossover video of Vocaloid and To aru Universe ? It such a waste of time if it was banned.

I heard that if you craft a costume of your favorite character, you’ll be executed (copyright) so you have to buy official licensed costume. Licensed costume be like $30,000 and handmade costume only $10 comes with creativity.

If copyright gone crazy, this world’ll be like :

  • You are NOT allowed to craft an action figure from Pencil, Wood, or anything craftable.
  • You are NOT allowed to make a fan art, fan video, tributes to the artist, music cover, or something like that even you wrote their name as big as hell.
  • You are NOT allowed to share anything to your friend. ex: if you want your friend to listen to some music, they have to buy it first.
  • You are NOT allowed to print your favorite poster that you got from internet.
  • You are NOT allowed to tell a news that you read on the internet to your friend. Because your friend have to read it from original source.
  • You are NOT allowed to watch TV together. ONE TV FOR ONE PEOPLE!
  • You are NOT allowed to give a newspaper that you already read to other person. One newspaper only for one people (just like One Antivirus only for one PC).
  • You are NOT allowed to give a charity things, because Poor people have to buy Licensed one.
  • You are NOT allowed to copy someone’s quote / lyrics as your status or anything even you write their name.
  • All drawings be like, “ORIGINAL CHARACTER DO NOT COPY”. There’ll be no fan arts anymore, or “Character X in my style”
  • Every images on the internet will be blank because they afraid you’ll copy it and share it.
  • There’ll be no “Tweet” or “Share” button.
  • “1,000 years of dungeon!” Why ? “Because he shared a file!”
  • Every people in Earth will be dumb as hell because they are not allowed to use their creativity (I’ve seen so many fan crafts on 9GAG, such as Pencil Craft Adventure Time, or famous artist statue made from glass. That thing will probably blocked if Copyrights gone wild) , and they also depends on copyright makers.
  • If it become more crazier, One Software License only for ONE PERSON. That’s mean you are NOT allowed to let your friend use it.
  • Ah so many, it makes me puke copyrights.

 

Conclusion

Copyright can be accepted as long as it respects other’s creativity too. Fans just want to give you an appreciation, that’s why they made a Fan art, Fan video, or Fan music cover. Don’t be such a d***, Fan arts wont kill you. I’d be very thankful if only I have a fan art, remixed song, or even my works posted on other website.

Some people aren’t just rich as you, so don’t insist poor people to buy $10,000 item just because you don’t want they use a replicated one / handmade. I much like creative commons than all rights reserved s***.

Note : My game or artwork doesn’t have any copyright (I guess mine is Creative Commons), so you may spread it to the universe if you want. As long as people doesn’t misunderstood me (people wont believe if I’m the creator of that thing).

[Personal] Miserable Life

First of all, I’m sorry for posting something long and personal here, but I feel very miserable, I couldn’t continue on some researches. The purpose I wrote this is, when all my mission / dreams accomplish, I can look how I deal so many difficult times.

This is how I feel right now. It’s like I’m 500 parsecs away to my dream.

I’m unemployed

It has been 2 months my school life has ended. 40% of my classmates already got a job. It makes me concern about “Will I get a job soon ?” Everyday I’m looking for the newspaper, they all hiring a job that I can’t do. It’s really hard to find a job that I have a skill on it, like After Effect, Cinema 4D, Unity, or even Photoshop. Finding a Digital job in Traditional country is just like finding gold fish in Ocean.

Last week, I tried to send an application letter to some bridal company for photo editor position, but I think I had no luck with it. Just because I don’t have Diploma, Doesn’t mean I can’t do it. All of them seems underestimate me.

This one thing I really hate is, when I was in school, everyone wants me to work at their company, but when I finally graduated, No one wants me anymore. I just feel that I’m not worthy sitting in front of computer all time feeling miserable.

Am I fated to always fail on everything, not getting a job, and always unfortunate ? I hate the word ‘fate’. It makes people think everything is impossible just because fate don’t let them.

All my ‘friends’ are ready to laugh at me because I’m still don’t get a job. But it’s not a problem for me. Go ahead! Laugh me as loud as you want. I have no feelings after all…

About my research

I’ve been offline for so long huh ? yeah I’m sorry I didn’t post Unity research anymore. I’m very busy upgrading my AE and 3D Modelling skills. I always think that making games just not worth. But however, I’m still going to make it. The main reason I cancel Personified Fear, Crystal Guardians, and London Traffic Jam is the artwork is poor, so I need to upgrade my Modelling skill.

I was just kidding about I’m quitting making games. I have a dream to make Imagination (game and animation studio) happen. It’s a read-only dream, so if someone gonna make me down, it’s not gonna change even I said I’m very down and miserable. Everytime I listen to fripSide’s Level 5 and Future Gazer music, it gains my spirit back.

I’LL REACH THE NEXT STAGE TO REALIZE ALL!

Ending

Even I feel really miserable (I always think to kill myself), I’ll still continue making everything. I have so many projects, from Project “Magic of Effect” to Project Sequence (my first anime with Unity / visual novel). So I wish I could done everything without tons of failure anymore (yeah if I could release 1 game successfully, that’d be great!). I know that success always come from failure.

Thanks for reading! Have a great week!

This motivates me

[Shader] Reflective Transparent / Water-like Unity Indie

This is what I promised. Sorry for being late, I’m kinda busy recently. I made this shader by merging between Transparent>Diffuse and Reflective>Diffuse. But I haven’t done with Normal Mapped Specular. My Unity kinda hates me, everytime I add Normal Map to this shader Unity Yells “Too many texture interpolators would be used for ForwardBase pass!” or “_ReflectColor no Properties!”. Perhaps you can do it yourself.

NOTE : I didn’t copy this script from internet. I just merge Unity’s Transparent>Diffuse and Reflective>Diffuse. So, if you are saying that I copy your script like that movie script I was made in 2012 and you found in 2014, go f*** yourself… By the way, this script ALREADY Exist on Nitro Racer XD on Epic Living Room track. I just made a lot of modification from Nitro Racer XD.

Shader name in Unity is “Glass Reflective_N”, and this is the preview / how to use the shader.

Ref_BLWater Ref_Full Ref_BLRef Ref_MStUnity - Untitled - RT - PC, Mac & Linux Standalone_4

Want More Realistic ?

If you want more realistic, you could add UVMover (Moving main texture’s offset from script * Time.deltaTime), and Realtime Reflection INDIE. Adding some Caustic effects or Underwater effects or Normal Map or Specular Shininess. You can also use this shader for a glass…

Glass Reflective_N

Shader name is a little bit ironic isn’t it ? It says N for Normal Map support, but this shader couldn’t support Normal Map. Alright here’s the shader.

Shader "Glass Reflective_N" {
 Properties {
 _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
 _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
 //_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
 //_BumpMap ("Normalmap", 2D) = "bump" {}
 _Cube ("Reflection Cubemap", Cube) = "black" { TexGen CubeReflect }
 }
 SubShader {
 Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
 Blend SrcAlpha OneMinusSrcAlpha
 //Pass {
 // Color [_Color]
 // SetTexture [_MainTex] {
 // combine texture * primary
 // }
 // }
 LOD 300
 
 CGPROGRAM
 //#pragma surface surf BlinnPhong decal:add nolightmap
 #pragma surface surf BlinnPhong alpha
 //#pragma target 3.0
 sampler2D _MainTex;
 //sampler2D _BumpMap;
 samplerCUBE _Cube;
 //half _Shininess;
 
 fixed4 _ReflectColor;
 fixed4 _Color;
 
 struct Input {
 float3 worldRefl;
 float2 uv_MainTex;
 //float2 uv_BumpMap;
 INTERNAL_DATA
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
 fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
 //o.Albedo = 1;
 //o.Gloss = 0;
 o.Albedo = tex.rgb * _Color.rgb;
 o.Gloss = tex.a;
 //o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
 
 //o.Specular = _Shininess;
 float3 worldRefl = WorldReflectionVector (IN, o.Normal);
 fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);
 reflcol *= tex.a;
 o.Emission = reflcol.rgb * _ReflectColor.rgb;
 //o.Alpha = reflcol.a * _ReflectColor.a;
 o.Alpha = tex.a * _Color.a;
 
 }
 ENDCG
 }
 FallBack "Transparent/VertexLit"
}

 

School life ends today

First of all, I’m sorry that I post a long personal post here.

So, yeah. I finally fought final boss today. The final boss was really tough, it has 160 parts (different questions). Should I be happy or sad ?

We had so many adventures

I don’t really have so many adventures, because I’m not allowed to go outside house. I rather had so much fun in school. Me and my friends did something crazy even my bro said that we’re like jackass. We slide through ceramics with school uniform, we took a picture in every room including toilets and principal offices, we ride a shopping cart in a mall’s parking lot (launch from top level to bottom), and many more.

We had so many fights

In March, I had so many relation fight with my friend just because I refused to do their homework and they also liked to ignore me making me like talking to a wall or sometimes acted that I’m invisible. That made me hated them. I thought this fight will lasts forever, but not. I’m glad this fight over in April. In April, me and all my classmates were like “All Together Now”. No more fights… 

The end of school life / The end of the line

I feel really ancient. I didn’t realize times goes really fast. It has been over 12 years in this school. I had so many awesome memories (I already made a 17 minutes school video named ‘PROJECT-CLARITY’). Listening to Secret Base really makes me cry. So, what to do after school life ?

Everyone seems so caring me

Everyone asked me, “What you do after school life ends ?”, “What college you’ll attend ?”, “What’s your dream job ?”. The answer is I don’t know! Every that information is secret, my top secret. Why ? Because if I can’t do that, I’m sure you’ll laugh at me and make me as a joke. This special question “Who do you’ll marry ?” is also same, I don’t know, and I don’t care if I’d get married or not. My teacher also like to ask me this “Why you don’t want to marry ?”, the answer is I still don’t know about that. I could only buy Uiharu pillow. However, my parent will still insist me. Besides, who’d like a heavy geek / nerd with dyslexia anyway ? 

So what I do next ?

All my friends went to college, I probably don’t go to college, because I don’t have money, and there also no Animation school. In June 2014, I probably start working in printing company and become a young adult (that’s sad, I’m not classified as High School Game Dev anymore). I probably life with infinite loop principal (Eat – Sleep – Anime <- Return). 

But before that, till now, I still had some social problem. The problem is, I can’t talk to other people like other people do. I always feel nervous, lost all my mind and stutter when talking even worst, I changed the order (like “How, Hi are you?”). This probably I’m too shy. I need to fix this problem soon.

All the skills I have from Photoshop to After Effects, seems useless here. But however, I wont give up. Everything I said I’ll give up on Game Deving and Animating is just a joke. I’m very ambitious, I do whatever it takes to reach my dream. Now I have so much time to experimenting with Unity, After Effect, and C4D. 

So, even I’m not a high school student anymore, there’ll still a lot project will going on (From PROJECT LEVEL UP to PROJECT SEQUENCE). Wish me luck…

In The End

Dear My Friend, Even we’re separated with a long distances, I hope we all be happy!
I believe that we’ll met in August 10 years later.
The Best Memories.
-[CLARITY]-
2013/2014
IMG_20140416_151528 IMG_20140416_151502
The picture was taken with iPhone 5. Geez, what a really hi tech phone…

[Tutorial] Realtime Render Animation With Unity3D

Seiten Taisei's MV Intro | ‎Wednesday, ‎February ‎27, ‎2013, ‏‎6:26:49 PM

Seiten Taisei’s MV Intro | ‎Wednesday, ‎February ‎27, ‎2013, ‏‎6:26:49 PM

That’s my first ever Realtime Render Animation. Back then I used FRAPS to record the animation in Unity, but now, I use better Sequenced PNG renderer. I found this script on Unity3D Wiki named ScreenshotMovie. But in this tutorial, let’s just use my version of ScreenshotMovie (It’s running on background, so you can play psxfin while Unity rendering). It works both on Indie and Pro. But Indie wont get an epic effect. If you use Indie but you want to get an epic effect, use After Effect.

You’ll need this

  • Unity3D
  • VirtualDub
  • Xvid Codec (Optional)
  • A knowledge on Animation (At least Level 3(You’ll need to know what is Flat, Spline, Constant, Keying, Free Smooth and something like that))
  • And Not TLDR Personality (Too long, didn’t read. :D)

Create a new Javascript, named it whatever you wanted, then attach this on MainCamera, and then REMEMBER to disable it (So you wont got lag when previewing the animation).

var folder = "ScreenshotFolder";
var frameRate = 25;

private var realFolder = "";

function Start () {
	Screen.showCursor = false;
	Application.runInBackground = true;

    // Set the playback framerate!
    // (real time doesn't influence time anymore)
    Time.captureFramerate = frameRate;

    // Find a folder that doesn't exist yet by appending numbers!
    realFolder = folder;
    count = 1;
    while (System.IO.Directory.Exists(realFolder)) {
        realFolder = folder + count;
        count++;
    }
    // Create the folder
    System.IO.Directory.CreateDirectory(realFolder);
}

function Update () {
    // name is "realFolder/0005 shot.png"
    var name = String.Format("{0}/{1:D04}.png", realFolder, Time.frameCount );

    // Capture the screenshot
    Application.CaptureScreenshot (name); // Use Application.CaptureScreenshot(name,2) if you want 1080HD
}

function OnDisable(){ enabled = true; }
  1. RT-1You have to animate the scene first, create a new Game Object, then child all objects that you want to animate. Character and NPC also able to animate using this (with NavMeshAgent), but it’s kinda very difficult. I created a special script to animate the movement of the AI using NavMeshAgent and Animator. In this tutorial, I’ll only teach you how to make a simple realtime camera animation.
  2. RT-2Select ‘Actor’ GameObject then click Record on Animation Tab (Press CTRL+6 if you don’t have an Animation Tab).
  3. RT-3You can animate everything you want (turning off gameObject, turning off a certain script, adjusting script value, everything). To animate the Camera, just change any value that you wanted. The animator will automatically key it.
  4. So, if you are saying that you want change camera, you just simply key the first position, then select camera key > Right Click  > Right Tangent > Constant, and then go for 1 frame , and then change the camera position again > Select The camera key > Right Click > Left Tangent > Constant. Repeat this step everytime you wanted to change camera position.
  5. Camera moves crazily ? Check your Position or Rotation Curves, or just set Select The Camera Key > Right Click > Flat.
  6. NOTE : Your animation clip will automatically Loop, to disable this, go to the folder where you save this animation clip and then uncheck Loop.
  7. RT-4After you finish with animating, Click Record Button to stop recording, and then Add that script to Main Camera. You need to adjust the Folder name (It’ll save to your Unity Project’s folder), and the frame rate (I usually use 24). Press Play and LET IT RENDER!
  8. RT-5The renderer will running in background, so you can do anything while Unity Render this (I play psxfin while rendering, haha yeah). Go back and check your Unity, if you believe your animation already finished render, press play again (that button above).
  9. RT-6Check your Unity Project folder, you’ll found a folder that you’ve named on Unity. That’s a large amount of PNG Sequences!
  10. RT-7Go launch VirtualDub, click File > Open Video File
  11. RT-8Open your Unity Project Folder, and then Select the First Image (Usually it’s 0002.png), then Open.
  12. RT-9Now let’s adjust the frame rate, so it wont look very lag (Default frame rate was 10)
  13. RT-10Remember to change the Frame Rate as the rate that you set in Unity (I set 24FPS)
  14. RT-11This is an optional step. You don’t want a huge video file, do you ? Skipping this step will give you 2GB Video for 40 seconds. So you’ll need to compress it using Xvid.
  15. RT-12Alright this is the final step. Click File > Save as AVI. “Hey! Wait! What about the resolution?” Ahaha, yeah. I’m sorry, I was forgot about that. The Resolution will be same as how large you render it on Unity. I use 16:9 Aspect on Unity while rendering. If you are using Free Aspect, you’ll gonna have a large letter box. “My monitor just 1360px, can I render 1920?” Sure you can! Just read back my script comment. Also, you’ll gotta be very patient when rendering 1080.

That’s just a simple camera animation. I’m tired writing very long text with slow internet, so I’ll post about Full Character Animation later. But here, I’ll give you an example of using Full Character Animation.

I don't have Motion Capture, So I have to animate non Walking motion.

I don’t have Motion Capture, So I have to animate non Walking motion.

Here's a sample to play sound. All animation event controlled by ANIMATOR CORE.

Here’s a sample to play sound. All animation event controlled by ANIMATOR CORE.

This is how my Camera Position looks like

This is how my Camera Position looks like

Also make a new Scene everytime you want to shot other location. It makes animating easier, and faster. Since NavMeshAgent only can do walk motion, you’ll need to duplicate the character (1 NavMeshAgent, and 1 just animator). I also made new Animator Controller on the character. I’ll explain what are those (Animator Core)

  • Actors[] : All walkable actors in this scene.
  • ActorsHead[] : All actors that have facial animation.
  • ActorAnimatorValue[] : Unused. Should be set like “Speed”, or “Direction”
  • ActorAnimatorValue[] : Unused. Should be like 1.0, or 0.2
  • NPCDestination[] : an empty game object tells NavMeshAgent where to go.
  • SoundBank[] : All AudioSource that available on this scene.

And this is the final product.

[Research] Unity Underwater Caustic Effect

I can't see the caustic effect clearly. That's why this is still just a research.

I can’t see the caustic effect clearly. That’s why this is still just a research.

Hello everybody, yeah I’m a bit late. I was promised that I’ll give Underwater Caustic Effect on this thread. So yeah, it was simple enough to create this Caustic Effect. It only use Directional Light’s cookie or Projector. For the water, I use Reflective>Bumped Specular. You can create double-sided by adding ” Cull Off ” on Reflective>Bumped Specular shader, but if you are lazy to add it, you can duplicate the water mesh and mirror it (Original(Quad) : 90,0,0, doubleSided : -90,0,0).

1. Go make a new JavaScript and then attach it to your water mesh. Your player also need to be tagged as “Player”. You’ll need this

#pragma strict

var scrollSpeed = 0.25;
var waterCausticSpeed = 2;

var cubeMap : Cubemap;
var causticTextures : Texture;
var causticSize = 10.0;

private var entered = false;
private var awakeFogCol : Color;
private var awakeFogDense : float;
private var defSky : Material;
private var lungColor = Color.green;
private var causticator : GameObject;

function Awake () {
    if(isWater){ 
        ply = GameObject.FindWithTag("Player").GetComponent(HeroCtrl);
        player = GameObject.FindWithTag("Player").GetComponent(PlayerCore);

        awakeFogCol = RenderSettings.fogColor;
        awakeFogDense = RenderSettings.fogDensity;
        defSky = RenderSettings.skybox;

        renderer.material.SetTexture("_Cube",cubeMap);

    }
}

function FixedUpdate(){
    var offset = Time.time * scrollSpeed;
    renderer.material.mainTextureOffset = Vector2(0,-offset);
    renderer.material.SetTextureOffset("_BumpMap", Vector2(0,-offset));

    if(isWater && entered){
        /*lungCapacity -= 0.5;
        if(lungCapacity < 125) lungColor = Color.yellow;
        if(lungCapacity < 50) lungColor = Color.red;
        if(lungCapacity <= 0)player.ApplyDamage(1);*/

        if(causticator){
            causticator.transform.Rotate(Vector3(0,waterCausticSpeed*Time.deltaTime,0),Space.World);
        }
    }
}

function OnTriggerEnter(col : Collider){    
    if(col.gameObject.tag == "Player" && isWater){
        entered = true;
        RenderSettings.fogColor = Color(0,0.4,0.7,0.6);
        RenderSettings.fogDensity = 0.1;

        CreateCaustic();
    }
}    

function OnTriggerExit(col : Collider){
    if(col.gameObject.tag == "Player" && isWater){
        entered = false;
        RenderSettings.fogColor = awakeFogCol;
        RenderSettings.fogDensity = awakeFogDense;

        Destroy(causticator);
    }
}

function CreateCaustic(){
    causticator = new GameObject("Causticator");
    causticator.AddComponent(Light);
    causticator.light.type = LightType.Directional;
    causticator.light.intensity = 0.5;
    causticator.light.color = Color(0.5,0.5,0.5);
    causticator.light.cookie = causticTextures;
    causticator.light.cookieSize = causticSize;
    causticator.transform.rotation.eulerAngles = Vector3(90,0,0);
}

2. After that, You’ll need Loopable Caustic Texture, you can find it on Google.

3. And then import that texture to Unity, remember to enable Alpha from Grayscale.

4. Also, remember to add Triggered BoxCollider on water mesh. Make sure that Box Collider Size covered all ground, but you also need to adjust the center of Y Axis because You don’t want an obvious transition, do you ?

As you can see, the Box Collider was offset-ed from water mesh. So it'll give you a nice transition.

As you can see, the Box Collider was offset-ed from water mesh. So it’ll give you a nice transition.

5. Finally, you just have to adjust all those thing until you fully satisfied.

6. So, you want to use Projection Method ? Well… Create empty Game Object, Add Projector to it, set it to Orthographic projection, set the rotation to 90,0,0. After that adjust the size until you happy. But you’ll need a Light Projection Shader (You can obtain it on Assets > Import Package > Projector). Create new material with Light Projection Shader, insert Caustic Texture to Cookie and Falloff Texture to Falloff. Use the script to rotate it.

So what’s the best ? What should i choose ?
Here’s the comparison between Directional Light Method and Projector Method

Directional Light

  • Quick, fast, and easy to use.
  • All area included.
  • Sometimes causes Obvious Transition.
  • My eyes! Too bright! The intensity must be high, if low, you wouldn’t be able to see the caustic.

Projector

  • OK transition (No screen brightening)
  • You don’t need to adjust the intensity, you’ll always be able to see the caustic.
  • Difficult, Requires High patience, and High Accuracy.
  • You have to adjust the projection area.