May 5, 2014

Glass apple in Vray and 3D Studio Max Tutorial


Ok as I have found in the last few days learning to do anything in Vray can be tricky due
to the lack of good beginner/advanced tutorials. That’s why I have been reading the Vray online manual for the last few days and trying to make myself accustomed to Irradiance mapping combined with a secondary bounce coefficient calculated with a QMC engine, precalcing the caustics to a photon map and all sorts of other mind boggling techniques...

 So to save you the trouble, I thought I should put my newly
learned knowledge to good use and make a tutorial for the good people of 3dpalace..;)
Bear in mind that I am pretty knew to this so I am sure that there are loads of different
ways to do this, many of which would probably be better/faster/easier/...you get the
idea,

Anywhooo...lets get to it, I personally have always had a fascination with rendered glass
(especially coloured glass) and the beauty of caustics, I am sure its something that a lot of people have wanted to be able to make. So I will do my best to show you how to get a pretty nice effect in a pretty simple way, and if any of the technical terms come up (and usually for rendering engines the names of settings and features can be completely confusing) I will try to explain them as best I can. 
And we’re off!!...also this is not a complete beginner tutorial as I don’t explain the basics of poly modeling and/or sub-d modeling…
Required Apps:
3D Studio Max 5/6/7 
Vray Advanced/Basic 1.4* (I think basic supports all needed  features used but not sure)
Goal:
Teapots??...what’s cool about a teapot?...so because of my dislike of drinking discoloured tap water ;) I will be doing something slightly different to show off the nice lighting features of vray….yes that’s right…an apple…I mean seriously who doesn’t like apples and also who doesn’t like glass…so I am cunningly combining the two to make a glass apple…with a leaf!!!...*sighs of amazement*
Step 1.
Ok so as you might have guessed this is not a modeling tutorial so I will only quickly
cover the modeling aspect. And for the apple I am using pretty much the max tutorial found in the help section.
The apple (modeling)
1.
Start off with a sphere of about 32 segments, convert it to editable poly and turn on soft selection, now select about a third of the apple below the middle and pull downwards a bit…you might have to tweak the falloff to get a nice tapering effect like in the picture.
2.
Now that we have the basic tapering shape of the apple we are gonna use a displacement map to make it look more like and apple. With the soft selection still from before still selected, Select the Displace modifier from the list and browse through your max/maps directory to find the AppleDis.jpg and slap this into the bitmap slot.
If you have trouble getting the required effect try these settings…
Strength -10.685
Decay: 2.0
3. Now we want to displace only the top half of the apple so we use an Edit Mesh mod and use soft selection again to select the top half of the apple like so…
4. The make a copy of the first Displace mod (by shift dragging the mod in the modifier stack to the slot just above the edit mesh) And adjust the settings to get the required affect…make it a bit less strong than the base.
Strength: 9.5
Decay: 5
5.
Now we have the shape but the top is still very un-apple-like, to fix this and make that trademark apple indentation on the top we use another Edit mesh mod and select the center vertex….use a soft selection again and pull this vertex down. To make a fairly sharp indentation, this can be exaggerated because the Meshsmooth mod we will add is gonna completely round this off and make it much less severe.
6.
MESHSMOOTH!!!!...the ultimate king of all mods ;)..I get a warm tingly feeling inside whenever I apply this modifier…lol…set it to 2 iterations and marvel at the awesome apple ;)…
The Stem (Modeling) 
Make a cylinder in the left view port convert to an Editable Poly chamfer a few edgs like so
apply a bend mod to it and twiddle the gizmo till you get this, finally add a meshsmooth mod…:D
Well that’s the stem done, now on to the leaf!.
The leaf (modeling)
Because we want to make a glass replica of a leaf this one will be very basic in detail and also fairly thick…like a real glass replica of an apple…
1. So start in the top view port with a plane…just because I love working from reference I will import a picture of a real apple leaf for view port reference. Download map below.

linkNow make a plane1 height segment and one width segment. We don’t need more because we will shift drag the shape of this leaf. Convert to Editable Poly
2. Now select an edge and while holding Shift use the move tool to drag a new edge.
Use a combination of shift drag and Uniform scale to follow the outline of the leaf.
3. Now select all the vertical edges and press connect to cut a line along the center, this will sharpen the ends and make for a denser mesh. Also apply a meshsmooth now to see the final outline in high res.
4. Time to add a bit of body to the leaf…remember this is meant to be glass so some nice rounded edges will do nicely, and for people with max6/7 you can use a Shell mod for this, in fact I will use only this technique because its much faster.
5. This is for tweaking the leaf, I applied both a shell mod and a spherify mod to give the leaf some body, this will also give a nice lens effect latter when it comes to the caustics.
6. Finally we will make the leaf a little more interesting by bending it nicely, ,Use a Bend Mod for this and you should end up with something like this.
This should be enough for it to Wrap itself nicely around the apple, ;) When your happy with the bend amount and thickness move the leaf to the apple and position it correctly, Something like this
In fact this is probably the best position of it so make a target camera and with it selected press Ctrl + C to match the camera to the perspective view, this will be out render angle.
And for anyone too lazy (or feels superior to the skills required) to model the stuff thus far here is the finished apple Scene.

scene
Lighting: (GI/Photons and other such cool toys)
This is arguably the most important aspect of this scene because so much of the final effect that the materials will have is down to the lighting,
For this scene I am gonna use a Single point lighting system and a filler GI lighting setup. For anyone unfamiliar to Vray I will explain a bit about the
Today marketing and web design is more important than technical requirements of broadband, for the hosting experts.
Vray Light
This is a special vray light
  1. To set up the lighting in this scene we will make a vray light ands and set its state to pla
Like this 
Now turn the multiplier up to 5.

We will tweak the size and position latter once the GI has been configured and we can get an idea of how the scene lighting will lookGI (Global Illumination):
Although the Plane light is our main point light source we will need some filler lighting from the environment, If you were to render the scene now it would look like this.
(Note: Enable Vray in the render tab first)
As you can see the lighting is not yet right, its way too dark, the Vray light source is seen as the only light source so the object is only illuminated from one point, the GI lighting setup is currently disabled, Lets summarized the GI or Indirect Illumination.
The GI calculations are very different to direct lighting used in Max or even the default lighting seen in the above render. In direct lighting a photon (light particle ;)) is sent out from a light and as soon as it hits an object it illuminates it but stops, it does not bounce around the scene as real light does. This is where Global Illumination comes in, it calculates not only the first hit (called the Primary Bounce) that a photon makes with an object but also the second and subsequent bounces (Called secondary Bounces). In GI as in the real world every object reflects light in a certain quantity depending on its reflectivity and brightness, so a self illuminated object in a scene lit with the Vray GI algorithm will be seen as a light source. In this way the lighting is very true to life but this comes at a price in the form of rendering times. There are countless measures you can take to optimize the scene to save on rendering time but for this tutorial we will stick to a brute force method of calculating the GI.
Setting up The GI Engines:
1. Once the Vray Renderer has been enabled in the Render Tab, Click on the Renderer Tab and Scroll down toIndirect Illumination (GI) Tab Turn it on but don’t change anything just yet, leave it at the default settings and render again.
As you can see the render time has increased dramatically, with 4 prepass stages and then the final render. In these stages the GI is being calculated in progressively more accurate passes.
This is what you should be getting
There is immediately more life in the scene and notice the very soft shadow to the right of the apple, this is being cast by the extra photons coming from the box light on the upper left. Of course these default settings take too long for test renders so we will check out some of the settings in the GI tab.
The GI options should look like this…
Note that the Primary and Secondary Bounces Boxes have an option of which Gi algorithm you wish to use to calculate those bounces, leave these as they are for now, Basically the…
Irradiance Map
Is a fairly good all round and very smooth GI engine, it calculates by taking actual  light samples and interpolating probable photon points in between, this allows for very smooth renders with next to no noise even at lower settings but especially at lower settings it is very poor at capturing small details. You will see this especially on detailed objects where two faces come into contact, it manifests itself as dark splotches and blurry artifacts.
Examples of Irradiance map artifacts on My Ninja Model
High Quality Sampling:
Notice the clean gaps between objects
Lower Quality Sampling:
Notice the rather ugly splotches and unclean gaps.
Well those are the basics of the Primary Bounce Engine, the Secondary Bounce is by default calculated by the.,…
 QMC (Quasi Monte Carlo)
This method of calculating GI is much more precise than Irradiance maps and allows  the capturing of smaller details, Rather than interpolating between samples taken it calculates the photon bounces directly, if used on its own however it can cause a lot of noise at lower settings as the detail is directly dependant on the amount of photon calculations made. However it is very useful in conjunction with the irradiance map as they complement each other weaknesses and make for a fairly fast setup.
I will not go into detail about the other GI methods, Photon Map and Light Cache as I know too little about them at this stage, I might do another tutorial later outlining the use of these methods, depending on if this tutorial is well received, e.g.. hopefully  I don’t confuse the last bit of understanding out of people with my endless rambling…lol
  1. Optimizing the Irradiance map for speed.

The main area of control for this Map can be completely mind boggling at first as there are no fewer than 20 different options to tinker with each having a specific result on both render times and quality, I will not try to explain them all because A) I don’t know for sure what some of them do and I don’t want to give out wrong info and B) since this is a basic enough tutorial I will not go into too much detail. I suggest just sitting down for an afternoon and twiddling with the settings until you get what effect they all have.
    
We will only bother with 4 for now.
  1. The First Thing you should do to optimize the settings is change the Current Preset to Custom, Now we can change the Min/Max Rate options.
Lets simplify this rather complicated method of calculation,
The number of difference between the min and max rate is the number of prepasses that are calculated, e.g., the high preset is from -3 to 0 which is 4 prepass calculations, the higher the number of either the min/max rate is the accuracy of that particular pass, so a
-5 pass is one with very few samples while a 0 is one with very many samples.
Hope that made some kinda sense…lol…but basically its not that hard to understand.
I personally like having 3 prepasses for my renders which range from a Min of -4 to a max of -2. This is good for testing with a nice amount of quality. For final renders a -3 to -0 is excellent and will get very accurate sample rates.

  1. The second thing is the HSph Subdivs: this controls the amount of samples calculated on each pass and of course the higher the number the more accurate the final result, turn this down to25 for test renders and slap it back up to 50 for finals.
Now with that done your Irradiance Map Rollout should look like this. Make sure to check Show Calc. Phase, with this you can watch as the prepasses take place.
Also scroll down to the System Tab and switch on the Frame Stamp, this will give us an accurate example of the render time and other information.
Ok with this done render again now.
The results are not all too different to the last render but the render time has been cut in half, this is very good to work with now, giving you fast feedback on all your material and lighting changes.
That render is now ok to look at but in fairness the lighting is pretty poor, the apple seems to be lit too strongly from all sides and completely washed out where the main light hits it, lets see what we can do here.
The lighting is way too strong at the moment, the GI is effectively washing the image out with bright white light so we need to attenuate the Vray light as the main light by turning down the GI.
Try these settings 
and you will get
There that’s much better, BUT, the shadow of the apple is showing some nasty noise, there are two ways of solving this, as the Vray light is currently being calculated separately to Irradiance map changing the Irradiance settings will not get rid of the noise. But if you look at the Vraylight settings you will see spinner for subdivisions, increasing this from 8 to 16 will give you this result
The noise is reduced considerably but is still evident, also notice that the render time have increased somewhat, this may not be significant at this stage but when the render is taking hours this kind of increase could be unacceptable.
Thankfully there are always multiple ways of overcoming a problem and by clicking the Store with Irradiance Mapoption we effectively add the light to the environment as a light source and can therefore control the accuracy of its light together with the GI. Lets see what this does for the noise reduction and render times.
Voila!...nice clean Irradiance Style lighting at half the render time, but because we are working with the same Irradiance settings for the GI and the Vray light the Image has been darkened, to correct this simply Increase the Vray light multiplier, a setting of 8.5  got me back to almost the same illumination amount.
You’ll also notice the slight increase in render time, this is due to the extra photons being shot into the scene to increase the overall light output.
Ok Now that we have a good lighting setup and I think you’ll agree it looks pretty nice already, we can finally start on the materials.
Materials (Glass glass and more glass)
The main Glass Shader.
Three things to remember when making glass,
  1. It looks best with a dark environment, black works very well for most glass types.

  1. Use the fog colour and multiplier for colouring the glass because it is the only method of has photon energy absorption, this effectively means that thin areas of the glass will be lighter in colour and thicker areas will be darker….looks really great.
  1. Erm…forgot what I was gonna put here so if you’re reading this I couldn’t remember when I finished…lol…

Apple Glass
Now, lets make the apple glass shader first. Before you do anything make sure that Vray is also assigned to theMaterial Editor in the Render Tab under Assign Render. With that done open the material editor and call up a new map.
  1. Start off with a Vraymtl, this is the vray’s equivalent of scanline’s Raytrace mat, but much more powerful.

  1. Change the Diffuse to complete black.
  1. Go down to refraction tab and change the refraction to a pure white colour, this means the material is completely transparent. Which also cancels out the Black diffuse colour immediately.

Render now and you get this abomination…urgh!!!...but don’t worry we will be able to fix it in good time.
  1. Go to the reflection settings and make the reflection value a bright gray and turn fresnelreflections on,
And that’s what we get, still nothing cool but we’re not done yet.
Even in web hosting, everything from the website design to the layout matters to the online marketing experts, particularly when you are about to start pay per click.
  1. Now go to the Options rollout and Activate the reflect on Backside
tab, this will give the glass some more realistic internal reflections, though it will also increase the render time.
  1. Ok now to give this thing some colour. Also the ground plane can now be brightened up a bit, make it completely white to brighten the scene somewhat, it looks less drab.
For the colour settings you will need to go to the fog colour tab and use a very light colour along with a tiny multiplier amount, usually in the 0.0* range.
Here are the settings for the Fog
And the resulting render…
7.         Ok that’s better but there is still something wrong, that big black area at the base and top of the apple is not very realistic and we don’t want such a dark feeling to the glass, we will have to do something about this and by putting a gradient map into the Environment slot you can get a better exit colour,
Use these or similar settings for the gradient, just experiment a bit to find the look you’re after.
And the render once this environment map has been added, see a much better look already.
Now I think that pretty much sums it up for the Red Glass.
Green/yellow Glass
  For the other two colours simply change the Fog colour around a bit, don’t forget to change the gradient environment as well, in some colours the black reflections look good but for the majority this gradient is needed, IMO anyway ;), but remember when choosing the colours  to keep them ultra light otherwise the glass will not let any light through and it will be very dark…here is a test with the final materials.    
Reflections:
Now that the lighting and materials are in place its time to sort out the reflections, obviously that big white reflection on the front cast by the main light is not very good, its too distracting and bright, so we select the light and turn theInvisible option on, now the light will still illuminate but is no longer seen in the reflection. However now we have to create some other lights to cast some nice reflections on the Glass, simple copy and move the main light a few times and place them around so that the reflections start looking good, this may take some test renders and adjustment to get right. To avoid over lighting the scene you should turn down the multiplier values of all these copied lights, and exclude the ground plane from their illumination lists also variate their size and rotation to give some nice effects, this part is as much about trying out as it is about exact values so I will just show you what I came up with in a short time of tweaking
And here is the scene with the light positions shown, the highlighted one is the main light.
And here is the final scene, with everything set up as it is in that last render, if you wish to render out a bigger higher quality render simply increase the settings that we reduced at the start,

Well that pretty much covers the basics, of course my final render is only an example of what can be done very simply, with a lot more time you could make it into something cool, maybe try a hdri environment/lighting rig, anything really…
I hope this has helped someone, and let me know honestly what you thought of this tutorial, its my first proper tut for cg stuff so let me know if there is anything that I got completely wrong or anything that should be added, and if there is an area that I didn’t explain properly let me know and I will revise it.
Download finished scene:

scene
Linus (Nova) Hofmann
www.cg-files.com

0 comments:

Post a Comment