Thursday, June 4, 2009

Brazil Basics: the Matte material in studio shots


My big issue as a rendering newbie when making studio-style shots was how to get a certain background gradient or solid colour quickly and independently of lighting the actual product.

My previous Brazil tutorial showed a method that works well when looking for a reflection in the 'floor' but was a little elaborate.

To start with this little duck, here's the simple gradient environment that I want to see. It's lit only with global illumination from the environment.

Here it is with a Global Illumination environment, one of the 'Studio' HDRIs included with Brazil.

Now the gradient background is what you see, but the GI environment is providing the lighting and reflections. There is more than one way to do such 'overriding,' but in this case I combined them using a Composite Environment. The GI environment was simply plugged into the first slot and the gradient into the second.


So that the duck doesn't appear to be floating in space, I add a plane.


And finally, the plane is assigned a Matte material. It makes the surface 'invisible' but it still receives shadows (and/or reflections,) and those shadows make the duck appear to actually be sitting on the background.

Buy Brazil here.

Saturday, May 30, 2009

Looking for a few Rhino instructors

I'm trying to develop a formal unofficial "Level III" 3-day modeling course using my material, and I'm looking for a few experienced Rhino instructors to give their opinion on it.

Sunday, May 17, 2009

Rhino View Basics

There's been an issue come up from time to time on the newsgroup with apparent confusion over how the standard viewport views in Rhino work, that the Right or Left views seem to show the "wrong" side.


The above illustrates how Rhino defines the standard view directions, and is familiar to anyone who's had to take a drafting class. If your first introduction to "drafting" is Rhino, then perhaps some explanation is in order.

The confusion comes from the fact that with something like a car or a plane, the "Left" view shows what is commonly referred to as the "Right" side, it's referenced from the point of view of someone sitting in it. That's not how Rhino works, to put it most simply it's using more general-purpose principles.

You can always make up your own views that show you the projection you want with the label you want, but this is indeed the view convention used by all CAD users in all fields. I did not get different instructions on how to make drawings from the one car designer in the faculty of my Industrial Design school, or my introductory Architecture course, or my Engineering drafting class.

Wednesday, January 28, 2009

Online Rhino Classes

A few years ago I taught online Rhino training classes for an American reseller(who sadly passed away and no one was able to keep his business going,) and have decided to offer them again directly myself.

I'm offering the 'standard' Level I and II Rhino training based on McNeel's curriculum, as well as a "Level III" based on my own material. The classes will typically run 3 weeks, with weekly online 'lectures' via GoToMeeting or any other convenient online communication method. Not only do you save on travel but the cost is lower still than a regular class since I don't need to provide a classroom. Read more here.

Tuesday, January 27, 2009

Now with newfangled moving pictures

I've just released a new version of my Advanced Rhino Training CD with added video. There's about an hour of it, over three dozen clips. It doesn't replace the text but compliments it. I'm trying to find the best way to post samples online and if I try YouTube it seems like it randomly does or doesn't enable high-quality video, so apologies if this is a tiny blurry mess. If you'd like to see what the videos actually look like, you can download this 116MB self-executing demo with over 100 pages of content.

Monday, December 22, 2008

Recent Project


I did a few renderings of architectural and product design projects for Hawaii-based Global Living Systems. Design & modeling by Patrick Tozier and Hemasaila Rajan.

Monday, November 17, 2008

Rhinoscript Classes Introduction

Here's a simple example showing the use of VBScript's classes in a Rhino script. It assumes some knowledge of the basics of scripting. VBScript's classes offer a very primitive form of object-oriented programming, but it is enough to be helpful in organizing your scripts.

Why and when should you use classes? I'm not going to give you the theories you can read elsewhere about "abstraction" and the like, I'll say that it's fine, probably best to stick with basic functions and procedures when you're hacking out basic functionality, but once you get to a stage where you're struggling over what variables to make global and which to keep passing as arguments back and forth among several functions, it's time to think about packaging things up in objects. It's not necessarily going to make your code smaller, but it will make it a lot easier to manage, if you do it right(a bit of a caveat there, yes,)you'll smoothly construct really complex functionality from simple, robust components.

When you're making an "object" what you're making is your own custom type of variable, made up one or more of the basic variable types(integers, strings, etc.)or other objects. In this example, I've made a simple "Cylinder" object.
Download and load this rvb file into Rhino. As soon as you do that, a cylinder will appear. That's thanks to this code down on line 63, after defining the Cylinder Class:
Dim objPersistentCylinder
'create the cylinder object on loading the script file
Set objPersistentCylinder=New Cylinder
objPersistentCylinder.Height=10
Looks pretty clear, doesn't? We've made a new Cylinder, without having to worry about how, and set it's Height to 10. Much more elegant than without classes, if you wanted to keep track of these things you'd have to store the required parameters to build the cylinder and the identifying string for the solid as separate variables and pass them to a "ModifyCylinder" function. Then if you wanted to build an array of cylinders...ugh!
Now run the RunScript command in Rhino. You'll be given two subroutines to choose from, MakeTemporaryCylinder and ChangePersistentCylinder.
Line 68
Sub MakeTemporaryCylinder()
Dim objMyCylinder
Set objMyCylinder=New Cylinder
objMyCylinder.Radius=3
objMyCylinder.Pick
'pause for user input, just to show it exists
Dim strInput
strInput=Rhino.GetString("The volume of this cylinder is " & objMyCylinder.Volume &". Press any key to continue...")
'after this sub exists, the object ceases to exist and the cylinder is deleted as per Class_Terminate()
End Sub
This illustrates how objects have "scope" just like normal variables. The objMyCylinder variable was declared inside the function, so as soon as you press any key at the prompt, the object ceases to exist. In the class definition there's a special subroutine called Class_Terminate() you can use to execute any cleanup code you like at that time, like in this case deleting the actual solid.

You'll also notice the Pick method I added to highlight the cylinder, it's on line 57:
Public Sub Pick()
Rhino.SelectObject int_strSolid
End Sub
Functions, Subs, and variables can be defined as Public or Private. Pick is Public, so that the rest of the program can call it, but int_strSolid, the GUID of the cylinder solid itself, is one of the Private properties.

Now I could have made the GUID of the solid Public and used it to call Rhino.SelectObject outside the class, but the idea of classes--of course there have been books and books written about this stuff, pay little attention to my limited experience!--is that you want to keep as much private as possible so that you can change how things work inside the class without breaking the code that actually uses it.

There's also the problem that if the property is public, then any other code can modify it willy-nilly, which may or may not be a good idea. In this case it is probably a bad idea, if the GUID of the cylinder changes, what happened to the old one? Was it deleted or is it still hanging around? It's sort of the "responsibility" of the Cylinder class to keep track of it, so it needs to control it.

Now there is a way around it, if some outside functions did need the GUID but we didn't want it to be changeable. Notice how the volume of the cylinder is added to the command line prompt, and on line 42, how that property is called inside the class:
Public Property Get Volume
'Retrieve the volume of the cylinder
Volume=Rhino.SurfaceVolume(int_strSolid)(0)
End Property
So, we could make a Property Get for the GUID like this:
Public Property Get GUID
GUID=int_strSolid
End property

This gives the same result as if we returned a value from a function:
Public Function GetGUID()
GetGUID=int_strSolid
End Function
The difference is that as far as the calling code is concerned, "GUID" is just a property like any other rather than the result of a function. So both more elegant, isolating the logic of what you want to do with your object from the nasty dirty business of making it work, plus it means that if at some stage your GUID was a simple public property, and you decided to do something more complex with it, then that change would be transparent to the rest of your code.

Moving on to the ChangePersistentCylinder subroutine on line 79.
Sub ChangePersistentCylinder()
'randomly change radius and height
Randomize
Dim dblRadius,dblHeight
dblRadius=1+Rnd*7
dblHeight=5+Rnd*10
objPersistentCylinder.Radius=dblRadius
objPersistentCylinder.Height=dblHeight
End Sub
This function randomly modifies the radius and height of the cylinder, automatically redrawing. The last chunk of code made use of Public Property Get, this makes use of Public Property Let, and shows why you would use it.

Setting the Radius of the cylinder calls this code on line 36:
Public Property Let Radius(dblRadius)
'Set the radius
int_dblRadius=dblRadius
Redraw
End Property
The Property Let stores the entered radius in the internal radius variable, so that it can't get changed unexpectedly by outside code, and calls a Redraw function that deletes the cylinder and rebuilds it with the new dimensions.

There's a whole lot more to object-oriented programming, but this pretty much covers the features of VBScript classes. The only major feature I neglected is Property Set, which is just like Property Let except it takes an object as a parameter instead of a regular variable.

You can go crazy with arrays of objects and objects inside objects, and there are some details about using them that may trip you up, but these mechanisms are your building blocks.

Sunday, November 16, 2008

Recent Scripting Project



I've been working with Tube Guage Inspection Fixtures, Inc. on some scripting to assist with the Rhino design of their inspection fixtures, sets of wood or metal forms used for checking tolerances on piping, usually used in the automotive industry. A simple enough concept, a perfect situation for scripting automation, but there were enough details to handle that it was still about 130Kb of script.

The script works from a user-defined centerline and chosen dimensions to make a set of blocks under the straight sections of the pipe. It automatically adds clearances for tube bends, applies specific profiles to the end blocks, and formats 2D output with particular tool path requirements. It wasn't considered a good use of time to try to automatically adapt to all possible details, since they can vary quite a lot and these are made working from often dubious imported geometry, so I simply made it as simple as possible to make modifications.

Friday, October 31, 2008

PC game review: Grid

I’m a bit behind the gaming times. I don't have a video game system and just recently finally grew weary of shooting down police helicopters in San Andreas and had a hankering for a more serious driving game. Because it was available on Valve’s Steam service and decently reviewed, I opted for Grid from Codemasters.

Grid is marketed as being focused on driving. That’s code for not being able to tweak your car. That’s okay, it means that learning to win is a matter of driving, not manipulating a spreadsheet, though some would probably wish for more cars than the included 45, which isn’t that many when they’re spread out over disciplines ranging from Le Mans prototypes to drifting. However they do all handle distinctly while being “balanced” so that cars in the same class are more or less competitive, which is not realistic but does mean you might actually drive more than a handful of them regularly.

The other task is managing your team in the career mode, which consists of hiring and firing a teammate and juggling sponsors. Once a “year,” you get the option to run the 24 Hours of Le Mans, and it is appropriately gruelling, even if actually only 12 minutes.

The graphics are about as good as you can get without the hardware requirements of a Crysis. Cars—up to 20 per race--and hospitality tents literally glimmer in the sunlight. Bugs and tar accumulate on your bumper. The 3D spectators react if you crash into the wall in front of them. The cars have probably been made unrealistically durable to better show off the damage modeling that runs the gamut from scratches to missing body panels and crumpled suspension.

I can’t say how accurate the reproduction of the gear whine from a Koenigsegg CCX is, but pieces of bodywork that get knocked off cars will stay on the track, and if you run into them they might stick to your car and you’ll hear them flapping around. That’s adequate for me to rate the sound effects “excellent.”

The rest of the audio is my one big disappointment in the presentation, especially after spending a month or four on GTA. That may not be fair, but when the game yaps at you, giving you such useful information as explaining how fourth place is one step from the podium, I must assume the goal of such chatter must be to create atmosphere just like the radio stations in San Andreas. There is nothing close to what’s needed in the quantity or quality of quips from your crew chief, teammate, and business manager for them to do anything but get on your nerves.

As you’ve probably already gathered, Grid is not a hardcore simulation. It’s realistic enough that taking a high-speed turn in a new Dodge Challenger at about 130mph, going wide and having the wheels bite the gravel in a slight depression at just the right angle, will result in rolling eight times, losing a door and the windshield, shattering the mirrors, and caving the roof...but it’s still 100% drivable. If you do manage to bend a wheel into the passenger seat, you get a second chance with the Flashback feature, which lets you rewind the last few moments and restart from any point. If you turn off the electronic nannies there is a general air of realism, but the cars do accelerate and brake too fast, which I would extrapolate helps it tend towards a driving style a bit too much like off-road rallying(which makes sense considering where the physics engine originated.)

It’s definitely fun, though, and definitely challenging. It can be tricky to simply get the faster prototypes around a track without hitting anything and you can dial the AI’s skill level up to 11. Enter a race that you’re not quite ready for and the AI will quite deliberately push you out of its way. There are some real tracks and some fantasy settings, unless there really is a street course in Milan that goes through a cathedral.

Because I’m afraid of never getting any work done again I haven’t tried online multiplayer, though skimming user forums shows some concern about races turning into demolition derbies. The online feature I have used is the “test drive” mode where you can race against a “ghost” of your personal best time or the "world record," though there seem to be some glitches or cheating since the world record for most tracks is something less than one second.

Wednesday, September 3, 2008

Google Chrome

It looks like my order form has some trouble with the new browser. I don't know if it's my code or the Mootools library, it's probably early days to try much troubleshooting anyway.
UPDATE: It's working okay now, except that the product titles are overlapping the quantity input boxes.