Texture shadows: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page)
 
No edit summary
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[File:Textureshadows portal2.jpg|thumb|right|Texture shadows in Portal 2]]
[[File:Textureshadows portal2.jpg|thumb|right|Texture shadows in Portal 2]]


Texture shadows allow transparent surfaces to cast baked lightmap shadows.
Texture shadows allow [[model]] surfaces (not brushes or displacements!) to cast baked lightmap shadows based upon translucency of the {{cmd|$basetexture}} of materials with {{cmd|$alphatest}} or {{cmd|$translucent}}.
 
To enable texture shadows, add <code>[[#Effects|-TextureShadows]]</code> to the VRAD parameters.


To enable model texture shadows, add {{code|-TextureShadows}} to the [[VRAD]] parameters.


{{only|{{slammin}}}} To enable brush and displacement texture shadows, add {{code|-worldtextureshadows}} (and optionally {{code|-translucentshadows}} for {{ent|$translucent}} material shadows) to the [[VRAD]] parameters.
{{Bug|{{slammin}} {{code|-worldtextureshadows}} and {{code|-translucentshadows}} don't work correctly if the top left pixel is completely opaque.|tested=newer versions of {{slammin}} VRAD}}
{{modernImportant|Only the alpha channels of the textures are used for shadow casting calculations. For example, stained glass windows using the {{ent|Refract}} shader will be treated as opaque, as will materials using {{cmd|$additive}} without {{cmd|$translucent}}.{{workaround|{{only|{{gmod}}{{mapbase}}}} Define a separate {{cmd|%alphatexture}} to use for casting shadows. This will work even without {{cmd|$translucent}} or {{cmd|$alphatest}}.}} }}
{{bug|tested={{hl2dm}}2021|VRAD is unable to calculate texture shadows for textures using DXT3 compression. Use DXT5 instead.}}
{{note|Texture shadows always use full translucency in VRAD, even if {{cmd|$alphatest}} is used. If binary opacity is desired, a sharp alpha channel should be used.}}


== Models ==
== Models ==


=== In QC ===
=== In QC ===
Add <code>$casttextureshadows</code> to the model's QC file to enable texture shadows.
Add {{ent|$casttextureshadows}} to the model's QC file to enable texture shadows.


Example:
Example:
Line 27: Line 31:


=== lights.rad ===
=== lights.rad ===
Textureshadows can be enabled on any prop without editing and recompiling the QC through the [[VRAD#Lights_files|lights.rad]] file
Texture shadows can be enabled on any prop without editing and recompiling the QC through the [[RAD file]].


Example
Example

Latest revision as of 08:19, 4 August 2025

Texture shadows in Portal 2

Texture shadows allow model surfaces (not brushes or displacements!) to cast baked lightmap shadows based upon translucency of the $basetexture of materials with $alphatest or $translucent.

To enable model texture shadows, add -TextureShadows to the VRAD parameters.

(only in Slammin' Source Map Tools) To enable brush and displacement texture shadows, add -worldtextureshadows (and optionally -translucentshadows for $translucent material shadows) to the VRAD parameters.

Icon-Bug.pngBug:Slammin' Source Map Tools -worldtextureshadows and -translucentshadows don't work correctly if the top left pixel is completely opaque.  (tested in: newer versions of Slammin' Source Map Tools VRAD)
Icon-Important.pngImportant:Only the alpha channels of the textures are used for shadow casting calculations. For example, stained glass windows using the Refract shader will be treated as opaque, as will materials using $additive without $translucent.
PlacementTip.pngWorkaround:(only in Garry's ModMapbase) Define a separate %alphatexture to use for casting shadows. This will work even without $translucent or $alphatest.
Icon-Bug.pngBug:VRAD is unable to calculate texture shadows for textures using DXT3 compression. Use DXT5 instead.  (tested in: Half-Life 2: Deathmatch2021)
Note.pngNote:Texture shadows always use full translucency in VRAD, even if $alphatest is used. If binary opacity is desired, a sharp alpha channel should be used.

Models

In QC

Add $casttextureshadows to the model's QC file to enable texture shadows.

Example:

$modelname "props_grate/metal_grate_64.mdl"
$model body "metal_grate_64.smd"
$staticprop

$cdmaterials "metal/"

$surfaceprop "metal"
$contents "grate"

$casttextureshadows

lights.rad

Texture shadows can be enabled on any prop without editing and recompiling the QC through the RAD file.

Example

forcetextureshadow props_underground/walkway_128a.mdl
forcetextureshadow props_underground/walkway_128b.mdl