Saturday, September 9, 2017

Animated Sparkling Water Texture - Tutorial for Gimp

Hello everyone,

did you ever sit on a beach in the sunlight, staring out on the water and enjoying all the pretty sparkles the sun creates on the waves?
I often thought, hey, if we could just transport this to Second Life as well.
And, guess what? Yes, we can!

So today, I want to show you how to easily make an impressively sparkling water texture.


And we will animate it:


Prerequisits: 

To make this animated texture, all we need are 2 things:

Gimp:
I use Gimp for making all kinds of textures and pictures. It's a free program and and just as powerful as other image editing programs you have to pay for.
You can download it here: Gimp


Basic Picture:
As we want to make water, we need a somewhat water colored texture or picture.
You can use every water picture you like, but the results will be better if it had some very good contrasts and is not too bright.
For best results, it shouldn't be smaller than 512 x 512 pixels.

For this tutorial, I will use an image I have found on Pixabay.



It doesn't matter if your picture is seamless - when you animate a texture in Second Life, it will ignore all texture settings anyway.

1. Making Waves:

Open your picture in Gimp.
We don't need it bigger than 512 x 512 pixels.
Go to the top menu and select "Image" → "Scale Image".
Set the Width and Height to 512. You probably need to click on the little chain if your original image is not square.


Now, as we have our image scaled, open the Filters menu and select "Animation" → "Waves".
In the window that pops up, we leave Amplitude and Wavelength on 10.0 (default).
Set the frames to 16.
This will give a smooth animation.


Click on "ok".
After the filter has done it's work, we end up with a new picture that has 16 layers - those are our frames.



We can now click on "Filters" → "Animation" → "Playback" to see how it looks like.
Very nice already, isn't it?

This way, we can already use it as a pretty water texture for Second Life.
If you don't want to add any sparkles, you can just go ahead to Chapter 3 and convert your frames into a single texture, useable for Second Life Cell Animation Scripts.

2. Adding Sparkles:

To add the sparkles, we need to add them to every single frame.
But no worries, this won't be as hard as it sounds. 😉

We will start on the top frame (Frame 16) and work our way to the bottom.
Select your top frame (in the small "Layers"-window).

Then select "Filters" → "Light and Shadow" → "Sparkle..."


In the window that pops up now, we have to make a few adjustments:

The luminosity threshold shouldn't be too high or we will get too many sparkles, so we'll leave it at 0.001.
The flare intensity might be a big stronger, so we set this to 0.50.
The spike length we probably also want a bit longer, so we set this to 30.
The spike points should do well with 4 but you can also set it to 6 if you want more of a star shine shape on them.
The spike density shouldn't be too high or it will be too bright, so we set this to 0.70.
The rest, we leave as it is, but we make sure that "Natural color" is checked.


When you're done with the settings, click on "ok".
This will distribute fine sparkles all over layer 16 (the top layer) of our image.

Now we have to repeat this for all the other layers.
I don't know about you, but I'm more the lazy type, so we will do this the easy way:

First of all, we will hide our top layer. We're done with it already, so it will only be in the way.
Click on the little eye beside the layer on the layer window. The layer gets hidden, so we see the next lower one (without sparkles).
Click on the new layer (Frame 15) in the layer window to select it.



Now all you need to do is to select "Filters" and then "Repeat Sparkle" right on top of the menu.
This will just repeat the last filter with the same settings as we had before.

Do this for all the layers of the image. Make sure you always select the new layer you want to work on in the layer window, or it will run the filter twice on the same layer (which would give very heavy results...).

When you're done, you can play the animation again to see how it looks like.

3. Converting the the layers into a single texture

First of all, you don't want so very big textures in Second Life. The bigger the texture, the longer it will take to load and the more lag it will cause for you.
In fact, there are only very few occasions we need a texture of 1024 x 1024 pixels in size at all.
But... a good animated water texture is one of them.

Still, 1024 x 1024 is all the size we need, so we will scale our water picture down to 256 x 256 pixels.
Select "Image" → "Scale Image" and enter 256 into both width and height.
This will scale all the single layers, so we don't need to worry about it anymore.

Now create a new picture in Gimp:
Select "File" → "New Image".
Set width and height both to 1024.

With this size, we can put our 16 layers into a 4 x 4 grid in the new image.

To have it easy, we will first set up a grid that "catches" our single images and snap them into the right place, without any gaps or overlappings.

Open the "View" menu of your new image and check "Show Grid" and "Snap to Grid".
Then go to "Image" → "Configure Grid".


Set the Spacing to 256 in both Width and Height.

Now we need to copy-paste all our frames into the new image we just created.

Caution:
The order of the single images is important for the animation to look right later.
Start with Frame 1 (the lowest layer) and put it into the upper left corner of the new image.
Frame 2 (the next upper layer) needs to go into the next square to the right.

Here is an outline for the texture layout:


Copy-paste all the 16 frames of the water animation into the new image.
When you're done, your image should look like this:


Now all that is left to do in Gimp is to export the texture to a format that can be read by Second Life.
Select "File" → "Export As" and enter the name of the picture and the format you want to have. 
You can use .png, .jpg and .tif for Second Life.

Don't worry about the black grid lines, they won't be visible in the done texture.

Please also save both images (the animation with the 16 Frames in layers and the single texture) as gimp files, so you can still make changes in case something has gone wrong. 

4. Final Touches  

The last step is to upload the texture into Second Life.

I recommend to test the texture first in locally which is possible in most viewers. There will be an article about using local textures here soon.

For the animation, you will need a Cell Animation Script which is set to play texture animation in 4 columns / 4 rows.
A script of this kind you can find in Outworlz for free but you need to change the number of columns in the script to 4.

The script will delete itself out of the prim after the animation has started. This is perfectly fine, the script doesn't need to be in the prim, the animation will stay anyway.
This way, we reduce script lag down to 0.



I hope you liked this tutorial and find it useful. Please leave a comment and let me know about your experiences with this technique. I'm looking forward to hear about your projects. 
Thank you :)


No comments:

Post a Comment

Create a Custom Texture for Bought Mesh

  Mesh! What a wonderful and beautiful thing to have! How much detail, how many faces, shadows and SO realistic! We all want it, don't w...