Page 1 of 1

ETS2: Mesh light and shadow tutorial.

Posted: Fri Feb 08, 2013 11:40 pm
by Oleg
The ETS2 game use a common lighting technique for an object geometry, when the mesh is lit by any light source. It uses vertices normal directions to determine the level of shading, it produces smooth shading across polygons using normals of respective vertices.

But what happens when the object is not lit because of an obstacle casting a shadow to surface? The game engine will not compute lighting at all, assuming the light does not reach the surface. The ambient light (very dark) is used as an overal scene lighting, and the shadowed polygons appears like they are flat or look like 2D sprite on your screen. Unlit polygons shaded this way are complete unreal since this kind of shading does not reflect in real life experience. Most of the objects inside a shadow of the shadow-caster object are about to be lit by reflected light from other neighbour surfaces. Even an object casting shadows to itself will generally reflect some light to itself too. As a result, some areas of an object would get light even been in a shadow of an obstacle-object. And some areas (hard to reach) would not get any reflected light.

Image
The reflected light is hard to compute in realtime, and nearly impossible for dynamic or moving parts. The consideration made is to compute reflected light on a mesh to be static, or literally "precomputed". The volume of light that could reach the surface is generally the brightness of the object in shadow. In other words, the less direct or reflected light could reach the surface - the darker the surface will be in a shadow. The technique is well known as "ambient occlusion". It is a precomputed shading that adds some darkening to surfaces in areas where light will barely reach the surface, even reflected.

The technique is computation expensive and barely used in realtime. Instead, a static computation used. ETS, GTS, ETS2 models store precomputed surface ambient occlusion on a diffuse map (also known as "baked" shading) and (the most important) it stores shading on per-vertex level. Literally, each vertex has a color from dark-gray to bright-gray in order to emulate ambient occlusion shading. This is a very fast for rendering in game at almost no cost, so each mesh in ETS has a precomuted shading.
What will happen if you don't use prelit vertices color? The vertex color will remain bright white (the default color) assuming the vertex is potentially easily reachable by reflected light. Such a model will appear to be much brighter in shadows than the rest of scene, and the model will be kinda a horse of another colour.

You can enable Diffuse color in format of a vertices on your models, but you don't need to paint this color. Instead, ZModeler tools will do the computation and paint vertices respectively.

The video guide will show you an easy way to create per-vertex prelt color for a model in ZModeler. The first part will prelt the truck model:
-0eKj-loZmU

The second part is for interior model and uses mostly the same methods as the first one:
T5Q7428h9AY

Complexity level: Intermediate.
Time required: 5-30 minutes.

Re: ETS2: Mesh light and shadow tutorial.

Posted: Fri Feb 22, 2013 3:51 am
by xxGRIZLIxx
good

Re: ETS2: Mesh light and shadow tutorial.

Posted: Sun Mar 31, 2013 7:17 am
by Mike3D
Thanks man, it really worked :) Now start to build a better pc 'cause its very heavy ;)

Re: ETS2: Mesh light and shadow tutorial.

Posted: Tue Apr 15, 2014 11:17 am
by Kotton
is this Zm3 specific? ..or can we achieve the same/similar results in Zm2?

regardless, VERY nice Oleg, exemplary work on Zm3!

Re: ETS2: Mesh light and shadow tutorial.

Posted: Fri Jul 19, 2019 11:17 pm
by rustydog666
how do i remove vertex paint and prelit colors??

Re: ETS2: Mesh light and shadow tutorial.

Posted: Sat Jul 20, 2019 1:36 pm
by Oleg
paint vertices manually to a color of your choice.

Re: ETS2: Mesh light and shadow tutorial.

Posted: Sat Jul 20, 2019 10:06 pm
by rustydog666
thanks Oleg, i had tried this but it seemed to not work. maybe i have missed something. selected all vertices i wanted to repaint and hit the fill selected but nothing was happening. will give it another go when i get on computer

Re: ETS2: Mesh light and shadow tutorial.

Posted: Sun Jul 21, 2019 8:31 am
by Oleg
The material type assigned onto an object should be "Shader Material" (with any shader applied). An option "Ignore vertices color" (Advanced color options rollup page) should be toggled off.

Object's properties (Mesh->Vertices->Format) should contain "Primary color" option toggled.