Decals: Difference between revisions
m (→See also) |
TomEdwards (talk | contribs) (tweaked) |
||
Line 3: | Line 3: | ||
Creating decals is fairly straightforward: they are simply materials generally having an ''alpha channel mask'' of some sort, and also often using the ''mod2x'' shader. Before reading this document, please refer to the [[Material Creation]] document for the basics of material creation. | Creating decals is fairly straightforward: they are simply materials generally having an ''alpha channel mask'' of some sort, and also often using the ''mod2x'' shader. Before reading this document, please refer to the [[Material Creation]] document for the basics of material creation. | ||
== | == Standard decals == | ||
The most simple type of decal is one that simply acts like a true decal or stencil: source art | The most simple type of decal is one that simply acts like a true decal or stencil: source art is clipped and projected on to the world within some mask, specified via the material's alpha channel (centre): | ||
[[Image:decal04.jpg | | <div style="text-align:center;">[[Image:decal04.jpg|128px|Source color channels]] [[Image:decal05.jpg|128px|Source alpha channel]] [[Image:Decal06.jpg|128px|Decal in the world]]</div> | ||
A decal's [[material]] looks something like this: | |||
[[LightmappedGeneric]] | |||
{ | { | ||
[[$basetexture]] decals/mydecal | |||
[[$decal]] 1 | |||
[[$decalscale]] 0.1 | |||
[[$translucent]] 1 | |||
} | } | ||
*<code>$decal</code> marks the material as a decal. Without it, the decal will not be clipped or projected onto the world properly. | |||
*<code>$decalscale</code> is important because its default is one pixel to one inch. If the source texture for this decal is 128 pixels, a value of <code>0.1</code> will cause it to be 12.8 inches in size in the engine (about a foot). | |||
*<code>$translucent</code> specifies that the material should use the alpha channel of the [[albedo]] to mask transparent sections of the material. | |||
== Application == | |||
Once the material has been created the decal can be placed in Hammer with the '''[[Hammer Overlay Tool|Overlay]]''' or '''[[Hammer Decal Tool|Decal]]''' tools. | |||
Decals can be created in C++ via {{todo|the decal code}}. | |||
{{note|For decals placed in code that are meant to be applied to models (such as blood), the <code>[[VertexLitGeneric]]</code> shader should be used instead of <code>LightmappedGeneric</code>. <code>LightmappedGeneric</code> is used for decals applied to world geometry.}} | |||
== Using modulation == | == Using modulation == | ||
For decals intended to mimic the look of pock marks or dents in a surface, the ''mod2x'' material shader is especially suitable. This shader lightens any destination pixels for every source pixel that is over mid-range gray (128). Likewise, it will darken any destination pixels for every source pixel that is below mid-range gray. This effect can be used to give the impression of depth when applied to a surface | For decals intended to mimic the look of pock marks or dents in a surface, the ''mod2x'' material shader is especially suitable. This shader lightens any destination pixels for every source pixel that is over mid-range gray (128). Likewise, it will darken any destination pixels for every source pixel that is below mid-range gray. This effect can be used to give the impression of depth when applied to a surface. | ||
To begin, create a source image whose color channel will be used for the modulation's source values | To begin, create a source image whose color channel will be used for the modulation's source values. Again, light values will lighten pixels they're drawn over, while dark values will darken the destination pixels. Mid-gray values will be treated as translucent. | ||
Next, create an alpha channel that defines a mask for the decal. Because modulation cannot have an exact middle value currently, the mask is necessary to prevent "bordering" from occurring around the decal | Next, create an alpha channel that defines a mask for the decal. Because modulation cannot have an exact middle value currently, the mask is necessary to prevent "bordering" from occurring around the decal. | ||
[[Image:decal01.jpg| | <div style="text-align:center;">[[Image:decal01.jpg|128px|Source color channels]] [[Image:decal02.jpg|128px|Source alpha channel]] [[Image:decal03.jpg|128px|Decal in the world]]</div> | ||
Finally, you must create a | Finally, you must create a material that uses the <code>[[DecalModulate]]</code> shader. Neither <code>$translucent</code> nor <code>$decal</code> are needed this time. | ||
== See also == | == See also == |
Revision as of 13:57, 12 July 2008
When the player shoots his or her weapon into a wall, the marks left by the bullet impacts are called "decals". These are most easily thought of as materials that are applied to a surface and remain there as an indelible mark on the world. Posters, scorch marks, and stenciled letters can all be created using this type of graphic. Decals will clip their extents to whatever surface they are placed on to. For example, a decal applied to a staircase would cascade down on to each stair surface instead of hanging out into space. You can also think of this as how a stencil would apply a mark to the world.
Creating decals is fairly straightforward: they are simply materials generally having an alpha channel mask of some sort, and also often using the mod2x shader. Before reading this document, please refer to the Material Creation document for the basics of material creation.
Standard decals
The most simple type of decal is one that simply acts like a true decal or stencil: source art is clipped and projected on to the world within some mask, specified via the material's alpha channel (centre):
A decal's material looks something like this:
LightmappedGeneric { $basetexture decals/mydecal $decal 1 $decalscale 0.1 $translucent 1 }
$decal
marks the material as a decal. Without it, the decal will not be clipped or projected onto the world properly.$decalscale
is important because its default is one pixel to one inch. If the source texture for this decal is 128 pixels, a value of0.1
will cause it to be 12.8 inches in size in the engine (about a foot).$translucent
specifies that the material should use the alpha channel of the albedo to mask transparent sections of the material.
Application
Once the material has been created the decal can be placed in Hammer with the Overlay or Decal tools.
Decals can be created in C++ via
.

VertexLitGeneric
shader should be used instead of LightmappedGeneric
. LightmappedGeneric
is used for decals applied to world geometry.Using modulation
For decals intended to mimic the look of pock marks or dents in a surface, the mod2x material shader is especially suitable. This shader lightens any destination pixels for every source pixel that is over mid-range gray (128). Likewise, it will darken any destination pixels for every source pixel that is below mid-range gray. This effect can be used to give the impression of depth when applied to a surface.
To begin, create a source image whose color channel will be used for the modulation's source values. Again, light values will lighten pixels they're drawn over, while dark values will darken the destination pixels. Mid-gray values will be treated as translucent.
Next, create an alpha channel that defines a mask for the decal. Because modulation cannot have an exact middle value currently, the mask is necessary to prevent "bordering" from occurring around the decal.
Finally, you must create a material that uses the DecalModulate
shader. Neither $translucent
nor $decal
are needed this time.