Turning Shadows Off

From The DarkMod Wiki
Jump to navigationJump to search

written by Springheel

You can turn the shadows on a model or entity off in the editor by adding the spawnarg "noshadows" "1". This article deals with shadows in material shaders.

There are two basic kinds of shadows when dealing with models and material shaders--"shadows" and "self-shadows".

Self Shadows

Self shadows are shadows that a model casts upon itself. For example, If a light is above a table, the top of the table will cast a shadow down onto the legs.

Normally, self shadows are good. On some models, however, especially rounded ones like vases or AI, the shadows create ugly jagged triangles of black. For a good explanation of why this happens, see here: http://www.geocities.com/vi_pr/self_shadowing_problem/self_shadowing_problem.htm

In these cases, you should add "noselfshadows" to the material entry for the object's texture.

Adding this means that the object will no longer cast shadows on itself. It also won't cast shadows on OTHER objects with "noselfshadow" on, so use it only when necessary. If you make a table "noselfshadow" and put a vase with "noselfshadow" on top, then the vase will not cast a shadow on the table, which would look odd.


Shadows are what objects cast onto the world around them. Normally shadows are good, and you wouldn't want them off by default. There are two cases where you might want to add "noshadows" to an object: One is to increase performance (rendering shadows takes processing time, so turning them off can significantly increase the FPS of your map), and the other is if your object has transparent textures.

Increasing Performance

In general, very complex objects create very complex shadows, requiring more rendering power. If objects are going to be placed somewhere that a shadow wouldn't really be seen, it is generally worth turning them off. For basically cube-shaped objects (like bookshelves) you can create a simple brush encompassing the model and texture the brush with the common/shadow texture to create a dynamic, simple shadow. A static shadow can also be faked with a decal.

Turning off shadows in this way shouldn't be done by altering the material entry, but by adding the spawnarg "noshadows" "1" to the entity in the editor.

Transparent Textures

D3 does not calculate transparencies when rendering shadows. If you have a rectangular model with the image of a feather on a transparent background, the engine will make a rectangular shadow (see the feather's shadow on the wall is actually a rectangle)


In cases like this, it might look better if there were no shadow at all, rather than an awkward blocky one. Adding "noshadows" to the material entry would be appropriate in these cases.


A shadowmesh is a simplified version of a model that is textured with "textures/common/shadow". This makes it invisible to the player, but it casts a shadow. Shadowmeshes have to be built with modelling software, but are very useful for complex models. The mesh of the actual object is set to "noshadows", and the shadowmesh casts a simplified shadow instead, using less processing power.

A simple test, using 40 high poly objects with "noselfshadow" on, being hit by three different lights:

outside of pov: 60 FPS

inside pov: 20 FPS

Then, when a lowpoly shadowmesh was added and the shadows on the visible mesh were turned off:

outside of pov: 60 FPS

inside pov: 30 FPS

A significant increase was noticed when shadowmeshes were used.

In general, objects that are more than 400 polys could benefit from a shadowmesh (often a shadowmesh can be made with 25% of the polys used for the actual mesh, though this depends on the object). Be aware that a shadowmesh will cast shadows onto the visible part of the object, so in general the shadowmesh should be slightly smaller than the visible mesh.