Home CGenie Tutorials

CGenie Tutorials



Introduction

This tut should take about 5 mins to complete.

I'll hopefully do a few of these over the next while. I'll start off really really basic for those who have always wanted to learn maxscript but haven't been able to get started. (that was me for a long time!)

The best way to learn maxscript is to learn a few basic tricks that you can use in your everyday work. You can then extend your knowledge as you come across tasks that you can *almost do with your current knowledge.

The Basics

Ok, first of all I'll go over a few basics.

To follow allong with these tuts, open the maxscript listener by hitting F11.

The pink area up the top is the listener where if you enable the macrorecorder, it will tell you what max is doing in maxscript terms as you do regular tasks in max. We won't pay attention to this area in this tut.

The white area is where everything will be happening. Delete the "Welcome to maxscript" message so we have a blank slate to start with.

Create a sphere in the scene so we have an object to talk to.

There are two simple ways to refer to an existing scene object in max. You can select it and refer to the selection or you can refer to it by name. The way maxscript refers to objects is by their name with a $ in front. So to refer to the sphere you just created, type:

$Sphere01

Now, with the cursor at the end of that, hit the enter on the numeric keypad. That will execute the current line. If you want to execute more than one line, select them all and hit numeric enter.

once you hit enter, maxscript will return the following in blue:

$Sphere:Sphere01 @ [10,-5,0]

The last numbers will vary depending on where you created the sphere in the scene.
This is confirmation that you are talking about the sphere and that your syntax is correct.

Object Attributes

Now lets try something slightly more useful. Type:

$Sphere01.radius

and hit numeric enter to execute. maxscript will return the radius of the sphere!
Notice how there is a hierarchy to the command. You started with the object itself then a period (.) then the parameter belonging to the object. You can refer to other parameters the same way. ie;

$Sphere01.segments will return the segments value.

Setting attribute values

Now what we want to do is change the values not just look at them.

Simply type:

$Sphere01.segments = 35

You'll notice as soon as you execute the line, the sphere changes it's segments to 35!
Well you could have done that faster with the GUI right? What if you have 25 spheres all with different radii and you want to just change their segment count? (a common problem)

Working on selections of many objects

I referred earlier to the fact we can refer to objects by referring to the current selection. In maxscript the shortcut to this is to simply select an object (select your sphere) and type:

$

When you execute this, you'll get the same result as if you had typed $Sphere01
Now we are going to exploit the power of "mapped functions"

Create 10 spheres of random radii and position. Select them all. Now type the following and execute it:

$.segments = 10

All the spheres will retain all their setting except the segments on all of them will be set to 10.

Thats it for now!

Conclusion

Play around with other objects and other attributes.
if you want to know what parameters are availiable to you on a given object, type:

showproperties $

For the sphere, that will return the following list:

.smooth : boolean
.radius : float
.segs : integer
.mapcoords : boolean
.slice : boolean
.hemisphere : float
.sliceFrom : angle
.sliceTo : angle
.chop : integer
.recenter : boolean
.realWorldMapSize : boolean
false

 
Quick Post

Enter code here  

Discuss this item on the forums. (0 posts)

Introduction

In this tutorial you will learn to create a realistic looking stormy ocean. We will also be setting it up to animate so you know how to breathe life into your static scenes. Full credit for this tutorial has to go to TimTamFin and his extraordinary knowledge of all things wet and watery!

As always, if there's anything unclear or confusing, please let us know either by email or in the forum and we'll be happy to help and also ensure the tutorial is made clearer for others.

Let's Begin!

Create a plane in the top viewport:

  • Width: 750
  • Height: 750
  • Length Segs: 50
  • Width Segs: 50
  • Density: 10.0

This'll be our water surface. If you've done everything correctly, you should have a total faces count of 500,000 - this'll give us a suitable detail level in the final render.

Making Waves

Next open the material editor ('m') and click on the first free material slot. Scroll down and in the diffuse slot add a noise modifier.

Go back up to the top level and drag the noise box over the actual preview window (the first slot you selected). Choose instance (doesn't matter) and you'll see the slot change to a 2D representation.

Click the text box where it says "01 - Default" and rename it to 'small waves'.

Now go down to the noise settings and alter it as follows:

  • X Tiling: 2.54
  • Y Tiling: 1.27
  • Z Tiling: 2.54
  • Noise Type: Turbulence
  • Size: 70
  • Levels: 10
  • Click the 'swap' button so the black color is at the bottom.

Next click the top map slot in the noise parameters and add another noise effect to this noise effect!

For this noise map, fill in as follows:

  • X Tiling: 2.54
  • Y Tiling: 2.54
  • Z Tiling: 2.54
  • Noise Type: Fractal
  • Size: 100
  • Levels: 10
  • Color #1: click the color selector and choose a mid grey (R157,G157,B157)

Now close the material editor and select our wave object again, click 'modifiers' and add a 'displace' modifier to it.

Right-click on this in the stack and choose 'rename' and set it's name to 'displace-small'.

Set Strength to 7.874 (you can tweak this according to your scene size) and under Map click 'none' and choose your wave material you just made (you'll need to click Browse From: Mtl Editor to see it) - it should be called 'small waves' as you named it earlier.

You should immediately see your scene update in the viewport with some subtle wave effects, but let's render at this point to see a higher resolution version and to make sure we're all at the same place! Tongue out

Here's my render (look similar?):

Not bad eh? You can see this displacement layer is adding all the small details of a real wave and will eventually add a lot of realism to our scene.

Incidentally, if you're just looking for a slightly choppy scene, you could skip the Making Bigger Waves section on the next page and end up with something neatly between the ocean waves tutorial and this stormy ocean tutorial.

Making bigger waves

Now we want to follow exactly the same process, but we're going to be adding larger waves to add a stronger roll to the surface. This layer of effect will be what actually adds the big waves to your scene.

Open your material editor again ('m') and drag your map from slot one into the next slot.

You now have two maps and they are identical - so before you do anything else click on the name dropdown and change it from 'Small waves' to 'Large waves'.

In the top noise setting (it should already be visible when you click the large wave material) we need to adjust a few settings to scale up our waves!

  • Tiling needs to be set to X:1.0 Y:0.3 Z:1.0
  • Size: 150
  • Noise Type: Fractal
  • Levels: 4.0
  • Click the Swap button

Finally let's get rid of that extra sub-noise layer - so just drag the 'none' box up and drop it on the other slot (which contains something like Noise #3).

Now let's apply it to our object.

Close the material editor and add another displace modifier.

  • Rename it as before but to 'Displace - Large'
  • Click the map slot and select your large waves material as before.
  • Tick Luminance Center

At this point, you'll need to tweak according to your scene ratio and your object size.

The two values you'll need to tweak are (a) the noise size in the material editor and (b) the displacement strength.

To give you an idea, my settings worked well at noise size: 250 and displacement strength: 150.

This gave me something like this:

Adding smaller waves

This next step is the first part of material building. We'll use a bump map to add some really small details to the wave object to give us some really intricate details - it'll also be very useful in adding a realistic reflection to light.

So, open the material editor and click the third slot - apply this to your object straight away.

Scroll right down and under the Maps rollout click the bump slot. Click the <none> box and choose Mix.

You'll see there are three slots, and in these we want to add various sizes and shapes of noise maps to add some randomness. The first two are our actual details and the third slot (mix amount) is what'll decide which of the above two to use.

Click the first slot and choose a noise map fill in as follows:

  • Noise Type: Fractal
  • Size: 10.0
  • Levels: 10

Click the second slot and choose a noise map fill in as follows:

  • Noise Type: Turbulence
  • Size: 20.0
  • Levels: 10

This'll give us two fairly different styles of detail.

Finally choose the third slot at the mix level and add a noise material with the following settings:

  • Noise Type: Fractal
  • Size: 150 (you may want to tweak this according to your scene scale)
  • Noise threshold high: 0.7
  • Noise threshold low: 0.3

If you render, you'll see your object now has some subtle, but very nifty, bump mapping, adding thousands of intricate details to your wave.

Adding materials

Now let's add some colour!

Now I'm going to step you through this so you can understand what's happening and so you'll be able to go back to tweak as your scene requires.

What we want to achieve is a material that'll automatically deal with the wave colour depending on the height of the wave. So if the wave is low, we want a deep ocean colour, if it's high we want a lighter tone with a touch of foam.

To do this we need to first apply a planar UVW map - so click your object and add UVW Mapping to the modifier stack. Then set the Map Channel to 2 and the alignment to Y.

If you now click the Fit button, the gizmo should nicely frame the wave in the front viewport.

Go back to the top level of your material and under diffuse color click the slot and apply a mix material. First click the Mix amount slot and add a gradient map.

In this gradient map set it's Map channel to 2 (to match our UVW map) and set color #1 to white, #2 to black and #3 to black.

Set the Color #2 position to 0.7.

If you render you should find you have only the highest parts of your map visible with a foam effect being applied to them.

Now let's fill the black areas in.

Go back up to your mix map and click the top slot (with none in it) and choose a falloff map.

Fill it in as follows:

  • Top colour - dark blue - R0 G43 B57 looked good
  • Bottom Colour - light blue - try R169 G188 B191.

If you render you should have something like:

A wet look

Now we want to add a wet look to our water and so we need to deal with the reflection. So go to the top layer again.

Under Shader Basic Parameters at the top, set the material to Anisotropic.

Under Anisotropic Basic Parameters set:

  • Specular Level: 69
  • Glossiness: 99
  • Specular colour to white.

Scroll down and under the Maps rollout add a falloff material to the reflection slot. In this material add a raytrace to the top slot and set the falloff type to fresnel.

Finally set the index of refraction to 1.33

Render and you should have something like:

Not looking too bad? Let's add some environment colour (depending on your scene you may or may not have to do this, but hey no harm in telling you).

Click a free material slot and under the diffuse slot add a gradient map - drag it up and drop it on the material sphere itself (as we did before) so you have a 2d map.

Now enter the following:

  • Tick Environ and choose Screen.

Set the three colours to:

  • Color #1: R22 G28 B33
  • Color #2: R51 G57 B62
  • Color #3: R59 G71 B80

At the very top menu of Max choose Rendering > Environment and drag your gradient material into the envrionment map slot.

Now render and you should see a subtle difference in the color of your waves.

Lighting

Now we're going to add some basic lighting - lighting is what'll tranform our scene into something that looks even more nifty.

I'll show you the basic setup, however I also want to play extensively at this point. Move the lights around and see how it affects your render. Play with the colour of the lights and the intensity and so on!

Anyway here's the setup from the front viewport:

You'll see I've added two lights a target direct light and an omni light.

Here are the settings I used, but remember to play yourself!

Omni Light:

  • Multiplier: 0.1
  • Color:R214,G214,B214

Direct Light:

  • Multiplier: 0.3
  • Color:R214,G214,B214

Under Directional Parameters tweak the hotspot and falloff/field sizes so the light covers an area much bigger than your scene.

Now render your scene - looks awesome!

Add a camera and position it as you desire and hit render. You'll see the water looks great, however the contrast with the background is a little harsh.

So add some fog (click Rendering > Environment, click the Add button under Atmosphere and choose fog).

  • Scroll down and set its colour to R57 G65 B7
  • Tick exponential and reduce far to 70.0
  • Click your camera and tick the show box under environment ranges
  • Adjust the far range to the end of your scene.

You should now have something like this:

 
Quick Post

Enter code here  

Discuss this item on the forums. (0 posts)

Introduction

This quick tutorial will walk you through creating a very simple, yet realistic, ocean shader. It will not require any plugins or any other extras and we'll construct everything using gradient maps so you won't even need a texture collection for the sky materials.

Requirements

  • 3d Studio Max
  • Brain

Background

If there's one thing that you take from this tutorial, it should be an understanding that water is highly reflective. It may sound stupid, but it's amazing how many people try to tweak their 'water texture' to make better water. The colouring of your water should be entirely absorbed from the surrounding environment, therefore if your water looks the wrong colour, it's the envrionment textures you need to change, not the water.

 

Step 1 - Create your Scene

  • Create a big, flat plane (use plane or a box with 0.0 height)
  • Create a skydome (just create a big geosphere/hemisphere that encapsulates your whole scene)
  • Create a camera (use a target camera low down, pointing towards the centre of your water)
  • Create some lighting (add a few omnis around your scene - place one on the horizon in front of the camera)


You should now have a scene something like this:


setup.jpg

Step 2 - Create the sky

The sky in this scene is critical and will determine the colour of the water, so we need to spend a little time on this. You can, of course, do it any way you want, but I'd recommend just using a gradient ramp material and applying it to your skydome object.

Set the colours of your gradient to whatever sort of scene you envisage - deep blues for standard ocean, aquamarine blues for tropical, reds for sunsets etc...

Here's the gradient that I came up with:

gradient.jpg


You can see I've chosen various deepening blues and a white colour (the white will be the horizon tint).

I've also added a tiny bit of noise just to break up the order of the gradient a little.

Feel free to play with your own setup (you can of course come back and try some variations once we've finished!)

You will also need to apply a planar UVW map to your skydome and position the gizmo to get the correct gradient for your scene - just keep rendering and previewing till it looks like the sky you imagined.

Step 3 - Texture the water

As discussed before the water should simply be a reflection, therefore we don't need a texture - so set a new map up with the following settings:


basicmap.jpg

You'll note I've used absolute black as the colour and set a nice high specular and glossiness to give the water a sparkle.

All that remains is to add the reflection and the bump -

Adding Waves

Add a noise map to the bump slot of this material.

Make sure you set the noise map to:

  • Noise Type: Fractal
  • Size: 5 (you may need to tweak this to suit the scale of your own scene)
  • Levels: 10
You may also want to tweak the bump amount later, again the scale of your scene will dictate this - for me the default of 30 looked fine.

Adding reflection

Finally let's add some reflection to the water to transform it completely. It might be worth rendering your water now just so you can understand just how big a role the reflection plays in realistic water, it should be pretty black with maybe a little bit of white specular showingif you have a light positioned low in front of the camera.

Click the 'none' slot next to 'reflection' and add a raytrace shader. Go back up a level and set the reflection amount to something like 70. This'll mean it doesn't act like a perfect mirror, water absorbs a little of the light and so is neraly always a darker shade.

Now render and marvel at your brilliant ocean!

This water will also reflect any objects in the water nicely so there's nothing stopping you making a great-looking scene now!

Here's my quick render - I'm sure you can do better though. If you do come up with any variations, please email them to me so we can make begin to accumulate a collection of settings for everyone to easily reference!

Hope you enjoyed the tutorial and if there's anything you didn't understand or that you'd like to see in a future tutorial, just ask away in the forum.

 
Quick Post

Enter code here  

Discuss this item on the forums. (0 posts)
Page 2 of 2