Korman:Lighting

Disambig gray.png

This is a tutorial page.Versions available: PyPRP; 3ds Max; Korman.
 

Disambig gray.png This page is a stub. You can help us by expanding it.

This tutorial will familiarize you with the lighting methods of Blender and how they can be used in Korman.

Introduction

As Plasma is an older engine that predates the advanced lighting effects many newer games use, an Age builder must consider lighting their Age carefully. Korman can automatically do some of the work, such as baking lightmaps and vertex colors, but needs the guidance of the artist in how they want to accomplish the desired effects and mood.

Lighting

When determining lighting, you need to also think about what kind of Age you're about to build. Will it be incredibly dark or is it an outdoor and sunny location?

Note that most sections of the cavern aren't completely dark; they have lamps and even a bit of light from the lake itself, still leaving it very atmospheric but still able to see things.

The Age itself will determine how many, as well as what type of, lamps you will need.

Types of Lighting

When lighting an Age, one needs to consider both types of lighting: direct and indirect.

Direct

There are points from which light in an Age actually emits. These are lamps, suns, spotlights...anything that, in-game, should actually be casting the light. These will be the lamps with the strongest Energy settings.

Indirect

Also known as diffuse lighting. For the most part, this is light that is reflected off of other surfaces due to direct lights.

For Blender and URU, these will be supplemental lamps with a much smaller Energy setting placed throughout the Age.

Using Both Types

Determining how to use both types of lighting depends on the location. It will affect how realistically your Age and the avatars are lit while walking around.

For instance, if you're outdoors, you'll need both a strong source of light (key) and less powerful surrounding diffuse lighting (fill) to simulate the sunlight reflecting off of other surfaces.

So a very strong sun lamp would go where your sun texture/object may be, then rotating it to point towards your Age. Ray Shadows and Plasma RT Shadows would then be used (see below).

For diffuse lighting, you can either add new sun lamps or copy the existing sun lamp, placing them horizontally with the Age on either side (still pointing towards the Age) and one below pointing up.

The Energy on the diffuse lamps on either side of the Age should be about 30-40 percent of the Energy of the main sun lamp. The diffuse lamp below should be around 10 percent of that energy.

If done correctly, this should get some very nice shadowing that's not too strong and give the impression that you're outdoors. If the lamps are set to cast onto the avatar, it should light them the same way.

You can adjust the Energy on all the lamps until you get the desired effect.

For indoor or darker locations, most of the lamp power will come from any point lamps. It's still recommended to use diffuse lighting, but it should be even more muted than if it were an outdoor location.

Types of Blender Lamps

There are five types of lamp objects in Blender that can be used to light an Age.

Point

A point lamp radiates light from its center outward using a given distance value. Checking the sphere option in the light properties will show you the circumference in 3D view.

This is probably the most common lamp you will use.

Sun

A sun lamp emits a more constant light from a certain direction. The lamp can be rotated to point in a particular direction for proper shadow casting.

It can also be locked onto an object's origin point if you right-click the lamp, hold Shift, then the tracking object, press Ctrl+T, then choose Track To Constraint.

Given the power of this particular lamp, it's best to use these sparingly for proper lighting.

Spot

As the name indicates, a spot lamp creates a spotlight effect, meaning the light is focused into a cone shape (shown in the 3D view). This can also be rotated to cast the light in a particular direction.

Hemi

A hemi lamp offers a constant 180 degree light source in the given direction. This can be used for minor diffuse lighting.

Area

An area lamp casts a light source within a given width, length, and height in the given direction. This lamp is best used for projection lamps.

Projection Lamps

URU can also use real time lighting in certain instances. This is helpful if you want to animate a lamp's position, energy or RGB value (color).

It's also useful if you want to project a texture onto any surface or even the avatar. The most prominent examples of this are the Great Zero beam and the tree shadows when on the roof of the entry building in Gahreesen.

For a projection lamp, you will need a texture with the proper blend settings. For example, the Great Zero beam uses a texture with the Add blend method. You can tweak the texture settings, as well as the width, height, and depth options of the area lamp to get the light looking just right.

NOTE: a projection lamp will NOT appear unless it's animated or attached to a Python script!

Lamp Settings

Each lamp has settings that you can adjust. This section will go over each.

Basic Settings

  • Lamp: You can switch the lamp between all five types by clicking on its associated button
  • Light color: Here, you can pick the color of your lamp.
  • Energy: The amount of power the light will have.
  • Falloff: Point lamp only. The default of Inverse Square should work fine.
  • Distance: Point, spot, and area lamps only. Determines the distance the light radiates from the source.
  • Gamma: Area lamp only. Adjust the gamma of the light source. This can usually be left at the default.
  • Negative: Checking this will cause the light source to subtract from other light sources. Useful for dimming interiors.
  • This Layer Only: Only illuminates objects on the same layer. Best to leave this off.
  • Specular: Adds specular highlights to the lamp. Materials need to have their specular color be non-black and textures need their Specular:Color flag checked.
  • Diffuse: Uses the diffuse color when casting light. Leave this checked for each lamp.

Note: lamps can be diffuse-only but not specular-only.

Shadows

  • Shadow: Determines whether the lamp (all except Hemi) will cast shadows onto objects. Note that this does NOT affect the avatar.
    • No Shadow: The light will cast no shadows.
    • Buffer Shadow: Spot lamp only. Lamp produces shadows using the buffer.
    • Ray Shadow: Lamp casts shadows on objects with a material set to do so. The most common setting for lamps that need to shadow.
  • This Layer Only: Only casts onto objects on the same layer. Again, best to leave this unchecked.
  • Only Shadow: the lamp will only create shadows, but won't actually light objects.

Warning: objects with their render flag set in the outliner pane (camera icon) will bake shadows. Be sure that regions and such have that flag cleared!

Sampling

These settings can smooth out any jagged edges you may be experiencing with the shadows on your lightmaps.

Note that jagged shadows can also be due to a lightmap that's set too small or bad lightmap UV mapping.

Also keep in mind that increasing any of these values may increase the time of your export, particularly if you have a lot of lightmaps that use the modified lamps.

  • Samples: Number of samples taken extra (samples x samples)
  • Soft Size: Light size for ray shadow sampling (raytraced shadows)
  • Adaptive QMC and Constant QMC: Either of these are fine, but best results are usually with Constant QMC, which can be slower, but offers smoother shadows.
  • Threshold: Adaptive QMC only. Threshold for raytraced shadows.

Plasma RT Lamp

  • Affect Avatars: Determines if the lamp's light will affect the avatar.
  • Soft Volume: Sets the lamp to a particular soft volume. If it's a normal soft volume, the light will only appear within the soft volume, while an inverse soft volume will cause the light to appear everywhere except the soft volume.

Plasma RT Shadow

Enabling this will cause the avatar to cast a shadow when in the lamp's light source.

Note that one should use this sparingly as the game engine can lag with multiple shadows at once.

  • Quality: Determines the smoothness of the shadow the avatar will cast. It's recommended that, the stronger the shadow, the higher the quality should be.
  • Self Shadow: When checked, this will allow objects within the light source to cast shadows on themselves.
  • Power: Sets the intensity of the shadow. This should be high when outside in the sun and low when in a darker space.
  • Falloff: Distance from the light source from which the shadow starts to disappear.
  • Fade Distance: Distance at which the shadow has completely faded out.

Lighting Objects

There are three ways to light objects in URU: Lightmaps, Vertex Colors and Real-Time Lighting. Each have their pros and cons, as described below.

Light Groups

Before working with any of these lighting options, it's best to group your lights depending on their use. For instance, if you have both an indoor and outdoor space, you'll want to group the lights within that structure while excluding the outdoor lights and vice versa. You can then set anything inside to that light group for more accurate lighting.

Light groups are helpful for lightmaps and vertex color lighting and absolutely essential for real-time lighting.

Note that lamps can be part of multiple groups if needed.

You can then use any existing light group in the Light Group field of the Bake Lighting modifier.

Render Layers

Another way to control lighting is using the Render Layers panel.

Using Blender's layers to better organize your various objects can be helpful. So in many cases, your lamps may be on a different layer than the objects you want to light.

This is where the Render Layers panel comes in. Here, you can set your various Bake Passes for use in the Lightmap Modifier.

Korman adds one upon export, but it uses all layers by default. Using various passes can help if you have different areas of your Age that require different lighting.

Note that using only this is best if you have only static lighting.

You can then use any of these in the Bake Pass field of the Bake Lighting modifier.

Method 1: Lightmaps

Lightmaps are created by baking a new greyscale texture using set light sources and blending it on top of all the other textures (ie the Multiply texture setting) into the other existing textures.

Note that, while these are more accurate than vertex coloring, they will also grow your Texture PRP. It's best to use these sparingly, especially for very complicated meshes.

UV Mapping

While some simple objects may be fine using the default UV map, it's best to create a separate UV map for a lightmap.

To do this, go to the Data panel in the Properties window, look for the UV Maps and press the +. You can name this anything with letters and numbers. Using "Lightmap" is the easiest.

Next, go to the 3D View window, switch to Edit Mode (TAB key), press U, then choose Lightmap Pack. The default settings for this should be fine, so click OK when the small settings window appears.

You can now use this UV map in your Bake Lighting modifier in the UV Texture field. You can do this for any object you'd like to lightmap.

Method 2: Vertex Colors

While not as accurate as lightmaps, it's a more low-cost way of lighting a more complicated mesh. They also don't inflate the texture PRP and using more of them instead can improve both export and loading times.

Vertex lit objects don't require a separate UV map (it's actually greyed out if Vertex Colors is selected), so you only need to set the Bake Pass and Light Group if needed.

Bug: Light baked onto vertex colors is colored by the material diffuse color then baked onto the material (which already has the diffuse color). The diffuse color's values are, incorrectly, squared.

Method 3: Real Time Lighting

Real-time lighting is quite useful as it's not static like the other two methods of lighting objects. It's best for animated objects and for Ages with day/night cycles.

The downside is a material can only utilize up to eight real-time lamps, meaning if you have a lot of lighting in your Age, it may not look completely accurate on a real-time lit object. This can be better controlled through light groups, however.

To use real-time lighting, you need to set up any object that needs it.

First, go to your Material panel in the Properties window.

Scroll down until you see the Light Group field in the lower left.

Choose the light group that will light this object in real-time. Remember, the material will only receive the eight strongest lights!

Also, if your material is used by more than one object, this will affect all objects with the material.

Once that is done, switch over to the Physics panel.

Click on Add Modifier and choose Lighting Info.

In the modifier, check Force RT Lighting.

This should now have the object set for real-time lighting using the chosen light group.

Note that objects with a lightmap or vertex colors (Bake Lighting modifier) can also receive real-time lighting.

Note that auto-smoothed objects don't have sharp edges for correct RT lighting. The Blender edge split modifier is needed for that.

Transparent Textures

There is a way to cast light through transparent textures with Korman. For more on this, see the transparent texture shadow tutorial.

This applies to both lightmaps and vertex colors.

Note that meshes with just transparent textures can be vertex lit, but not lightmapped.

Other Details

Once the Age has been lit as described above, there are still some added details and effects that really help make an Age come alive and feel less flat. Plasma doesn't perform any HDR, bloom, or in-camera effects, so these must be manually simulated where desired.

Lamp Flares

A Series of Lamp Flares

Lamp flares (sometimes called halos) are a visual effect that helps ground a light or other emissive source into a scene, much in the same way that a shadow grounds objects and avatars. Making a lamp flare look correct without causing artifacts takes some work, so Korman provides a premade template that does most of the work for the artist.

To create a premade lamp flare, place the 3D cursor at the light (or the object representing the light) as this will be the center of the lamp flare, and use Shift-A to Add->Plasma->Lamp Flare to add a new one to the scene.

KormanAddPlasmaLampFlare.png

KormanLampFlareTemplateOptions.png

In the "Add Lamp Flare" operator panel, you have the option to name this lamp flare (it may be a good idea to name it after the type or location of the lamp it's associated with, especially if you intend to create many!), the distance from the center the flare should rotate around, and the lamp flare's material. The first time you create a lamp flare, a new material will be automatically generated and selected for you, named "FLAREGEN".

Be sure to set these options before you modify the flare in the 3D view; as with all Blender "Add" tools, this commits your current options and you will not be able to modify the creation options through the operator panel once you've accepted it.
KormanLampFlareGenTexture.png

One last thing must be done to complete your lamp flare: setting the image texture to use for your halo. With the flare still selected, go to the Material pane, select the FLAREGEN material (or whichever you selected, if you changed this option), and then go to the Texture pane. Open or Select a texture image for the FLAREGEN texture the same as you would any other image texture in Blender for Korman. All other options should already be pre-set correctly. You're done!

Creating any subsequent lamp flares do not require additional texture set-up as long as you use the same material. If you want different lamp flares to appear differently (such as separate yellow lamps and blue lamps, demonstrated in D'ni city locations), the easiest way is to click the [+] button (Add New Material) on the FLAREGEN material (not the texture) to duplicate it. This will create a new copy of the original FLAREGEN, which you can edit to use a different texture image. Set any new lamp flares to use this material instead.

For your lamp flare texture, it works best to use an image that includes alpha transparency. Often a simple circular gradient will do. It is also important to make sure the lamp flare's gradient reaches 100% transparency before it reaches the edge of your image, or else your lamp flares will have abrupt edges and look "cropped" or square-ish in-game. Information on how to create this texture is specific to your chosen image editing software, and should be easily found when looking for lamp flare texture tutorials for that software.

For your lamp flare to work correctly, make sure to always move it by moving the parent empty object, the rest of the flare will move with it. If you wish to adjust the distance from the center of rotation after creation, be sure to move the "Flare_Visible" child object only along its local Y axis.

Technical Information

These lamp flares work by using several of Plasma's special effects and modifiers together. This section describes how the auto-generated Lamp Flare works, which is useful for modifying them or creating your own should you need a custom effect.

The Lamp Flare consists of an empty situated at the center of the "lamp" which can be either the true light source, or more often, the object that "appears" to be the light (such as the fixture emitting the light). This empty has a Swivel modifier applied to it, set to Sprite, and it is rotated so that it always faces the player's camera no matter the angle they approach from.

Parented to this empty is a plane. This plane is the visible object that the player will see as the flare itself, and due to being parented to the empty, it will swivel. Instead of swiveling at its own center, it will swivel around the empty at the distance set by the artist, allowing it to clear the geometry and not appear to be inside the lamp or fixture. On this plane is set an Opacity Fader modifier set to Line-of-Sight, which causes it to vanish or appear with a quick half-second fade out or in when its center is occluded by other objects. This is important, due to the Plasma Layer options...

The FLAREGEN material and texture have important options pre-set for the artist that ensure the flare will not cause unsightly edges of transparency around other semi-transparent objects (such as trellises, railings, plants, and other lamps) nor obscure others entirely. The FLAREGEN material is set Shadeless, because it wouldn't make sense for a light source to be affected by shadows, and the FLAREGEN texture has three important options set: Skip Depth Write, Skip Depth Test, and Z-Bias. These are described more fully on the Textures page; in summary Skip Depth Write makes sure the flare doesn't hide or cut into other transparent objects behind it, Skip Depth Test makes sure that it isn't partially obscured but instead properly "bleeds over" as an over-bright lamp should, and Z-Bias prevents Z-fighting should it be placed too close to another object.