Glowing textures (Source): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎$selfillum: Irregardless is not a word)
m (updated language bar.)
Line 1: Line 1:
{{otherlang2
{{lang|Glowing Textures}}[[Category:Lighting]][[Category:Material System]][[Category:VMT Lighting]]
|fr=Glowing Textures:fr
}}
A '''glowing texture''' is one that does not require another form of light to be lit up. It can create its own [[lightmap]] independent of all lighting sources and may even create light itself. This does not mean that the surface will appear pure white, just that the face will ignore any light it would receive. This is a key feature as a "glowing" black stays black and does not get brighter. The face achieves what is called fullbright, where the texture's pixels appear exactly the same color as they were saved.
A '''glowing texture''' is one that does not require another form of light to be lit up. It can create its own [[lightmap]] independent of all lighting sources and may even create light itself. This does not mean that the surface will appear pure white, just that the face will ignore any light it would receive. This is a key feature as a "glowing" black stays black and does not get brighter. The face achieves what is called fullbright, where the texture's pixels appear exactly the same color as they were saved.


Line 10: Line 8:
#{{ent|UnlitGeneric}} shader, specified in a [[material]]'s [[VMT]] - Does not emit light, forces face to ignore all lighting, making it [[fullbright]].
#{{ent|UnlitGeneric}} shader, specified in a [[material]]'s [[VMT]] - Does not emit light, forces face to ignore all lighting, making it [[fullbright]].
#{{ent|$detail}} parameter with <code>$detailblendmode</code> value of 5 or 6, specified in a [[material]]'s [[VMT]] - Same as <code>$selfillum</code>, but more rudimentary and compatible with transparency.
#{{ent|$detail}} parameter with <code>$detailblendmode</code> value of 5 or 6, specified in a [[material]]'s [[VMT]] - Same as <code>$selfillum</code>, but more rudimentary and compatible with transparency.
#Using [[info_lighting]] to fool a model into thinking it is brightly illuminated.
#Using {{ent|info_lighting}} to "fool" a model into "thinking" it is brightly illuminated.
For glowing textures on '''brush faces''' only:
For glowing textures on '''brush faces''' only:
# Using <code>Minimum Light Level</code> [[entity]] keyvalue.
# Using the Minimum Light Level [[entity]] keyvalue.
# .rad file, mainly used for glowing textures on brushes. '''rad files are the only form of glowing textures that generate any map light.''' The file is processed line per line; on each line is simply the name of the texture, the RGB value of the light, and then the brightness of the light.
# <code>.rad</code> file, mainly used for glowing textures on brushes. '''RAD files are the only form of glowing textures that generate any map light.''' The file is processed line-by-line; each line is simply the name of the texture, the RGB value of the light, and then the brightness of the light.


Common selfillum textures can be found in [[White]].
Common selfillum textures can be found in [[White]].


==$selfillum==
==<code>$selfillum</code>==
Self illumination applies "fake" light to a surface, regardless of the true light that the surface receives from the environment. This is useful for parts of a model that emit their own visible light, like the filament in a light bulb or a glowing LED on a control panel. The self illumination effect can be masked with a texture.
Self illumination applies "fake" light to a surface, regardless of the true light that the surface receives from the environment. This is useful for parts of a model that emit their own visible light, like the filament in a light bulb or a glowing LED on a control panel. The self illumination effect can be masked with a texture.


Line 41: Line 39:
Mask values below 1.0 apply a minimum brightness effect to the surface, while still allowing it to receive light from the environment. This threshold effect is useful for objects like computer screens, which should be visible in darkness but become overwhelmed in bright sunlight.
Mask values below 1.0 apply a minimum brightness effect to the surface, while still allowing it to receive light from the environment. This threshold effect is useful for objects like computer screens, which should be visible in darkness but become overwhelmed in bright sunlight.


===Additional parameters===
===Additional Parameters===
 
{{MatParam|$selfillumtint|RGB matrix|Adjusts the color of the self-illumination effect. Default value is "[1 1 1]".}}
{{MatParam|$selfillumtint|RGB matrix|Adjusts the color of the self-illumination effect. Default value is "[1 1 1]".}}
{{MatParam|$selfillummaskscale|normal|Scales the self-illumination effect strength. Default value is 1.0.}}
{{MatParam|$selfillummaskscale|normal|Scales the self-illumination effect strength. Default value is 1.0.}}
{{MatParam|$selfillummask|texture|A dedicated mask texture for the effect. Might not work in Source 2006.
{{MatParam|$selfillummask|texture|A dedicated mask texture for the effect. Might not work in {{src06|2}}.
: {{bug|Doesn't work on brushes, use the alpha channel of the <code>$basetexture</code> instead. (<code>$selfillum 1</code> only)}}
: {{bug|Doesn't work on brushes, use the alpha channel of the <code>$basetexture</code> instead. (<code>$selfillum 1</code> only)}}
: {{bug|Doesn't work on overlays in {{csgo}}.}}
: {{bug|Doesn't work on overlays in {{csgo|4}}.}}
: {{Warning|Source 2007 MUST use this!}}}}
: {{Warning|{{src07|4}} MUST use this!}}}}
{{MatParam|$selfillum_envmapmask_alpha|bool|Has the material derive its self-illumination mask from the alpha channel of the {{ent|$envmapmask}}.|dx9=1}}
{{MatParam|$selfillum_envmapmask_alpha|bool|Has the material derive its self-illumination mask from the alpha channel of the {{ent|$envmapmask}}.|dx9=1}}
: {{Note|<code>$selfillum_envmapmask_alpha</code> replaces the original <code>$selfillum</code> command, so they cannot be used together.}}
: {{Note|<code>$selfillum_envmapmask_alpha</code> replaces the original <code>$selfillum</code> command, so they cannot be used together.}}
{{MatParam|$selfillumtexture|texture|Use a selfillum texture.
{{MatParam|$selfillumtexture|texture|Use a selfillum texture.
: {{Note|Deprecated since Source 2007.}}
: {{Note|Deprecated since {{src07|4}}.}}
: {{Note|use {{ent|$emissiveblend}} instead}}}}
: {{Note|use {{ent|$emissiveblend}} instead}}}}
{{MatParam|$selfIllumFresnel|bool|Allows the material to use Fresnel ranges.
{{MatParam|$selfIllumFresnel|bool|Allows the material to use Fresnel ranges.
Line 60: Line 57:
[[Image:glow_selfillum.jpg|thumb|256px|left|A selfillum mask texture.]]{{clr}}
[[Image:glow_selfillum.jpg|thumb|256px|left|A selfillum mask texture.]]{{clr}}


==$detail==
==<code>$detail</code>==
If <code>$selfillum</code> is not a viable option, a <code>$detail</code> texture can be used instead. It can bypass the sv_consistency check on some games, such as in {{css}} or {{l4d2}}, to allow glowing textures where textures with <code>$selfillum</code> would cause you to be kicked from the server.  
If <code>$selfillum</code> is not a viable option, a <code>$detail</code> texture can be used instead. It can bypass the <code>sv_consistency</code> check on some games, such as in {{css|4}} or {{l4d2|4}}, to allow glowing textures where textures with <code>$selfillum</code> would cause you to be kicked from the server.  


VMT lines required for a <code>$detail</code> glow:
VMT lines required for a <code>$detail</code> glow:
Line 69: Line 66:
         $detailblendmode 5    //6 also works.
         $detailblendmode 5    //6 also works.


The detail texture itself must be completely black with the parts that should be glowing colored. Dark colors will glow less. You can not make a black glowing texture this way.
The detail texture itself must be completely black with the parts that should be glowing colored. Dark colors will glow less. You cannot make a black glowing texture this way.
[[Image:Detail glow briefcase.png|thumb|223px|left|The [[TF2|Team Fortress 2]] briefcase detail glow texture]]{{clr}}
[[Image:Detail glow briefcase.png|thumb|223px|left|The [[TF2|Team Fortress 2]] briefcase detail glow texture]]{{clr}}


==Using envmaps for a solid color glow==
==Using <code>envmap</code>s for a Solid-Color Glow==
If for some reason you can't use $selfillum and can't do glow with $detail, you can still do a solid color glow on the material. As reflections are not affected by lighting, and appear to glow in the dark, specular reflections using cubemaps can be used.
If for some reason you can't use <code>$selfillum</code> and can't do glow with <code>$detail</code>, you can still do a solid-color glow on the material. As reflections are not affected by lighting and appear to glow in the dark, specular reflections using cubemaps can be used.
Unlike $selfillum, you can only make pixels glow in a color, additively, ie you can't make part of a texture glow, but add single color glow over it. Can be done using a white cubemap, and making the cubemap reflection visible only in some places per-pixel through an [[$envmapmask]]. You can also tint the cubemap glow to any color by [[$envmaptint]]
Unlike <code>$selfillum</code>, you can only make pixels glow in a color additively, i.e., you can't make part of a texture glow, only add a single-color glow over it. Can be done using a white cubemap and making the cubemap reflection visible only in some places per-pixel through an {{ent|$envmapmask}}. You can also tint the cubemap glow to any color by {{ent|$envmaptint}}.


==.rad files==
==<code>.rad</code> files==
{{Warning| This method will only work on world brushes}}
{{Warning| This method will only work on world brushes}}
  example\exampletexture 128 192 96 400
  example\exampletexture 128 192 96 400
Line 82: Line 79:
Unlike <code>$selfillum</code> or the <code>UnlitGeneric</code> shader, lights of the specified color and brightness are generated in front of the world brush's face during VRAD complation. The brightness of the created lights is also affected by the density of the lightmap. Higher densities will produce a greater effect. The texture itself does not become fullbright, but the lights in front often make it seem so.  
Unlike <code>$selfillum</code> or the <code>UnlitGeneric</code> shader, lights of the specified color and brightness are generated in front of the world brush's face during VRAD complation. The brightness of the created lights is also affected by the density of the lightmap. Higher densities will produce a greater effect. The texture itself does not become fullbright, but the lights in front often make it seem so.  


If a texture is specified in multiple places, it will be overridden by the latest information, for example: If both lights.rad and <game>.rad specified the same texture but <game>.rad was brighter, the light emitted in the compiled map would be the brighter <game>.rad version.
If a texture is specified in multiple places, it will be overridden by the latest information. If both {{ent|lights.rad}} and <code><game>.rad</code> specified the same texture, but <code><game>.rad</code> was brighter, the light emitted in the compiled map would be the brighter <code><game>.rad</code> version.
[[Image:glow_rad.jpg|thumb|256px|left|A .rad texture in use]]{{clr}}
[[Image:glow_rad.jpg|thumb|256px|left|A .rad texture in use]]{{clr}}


==UnlitGeneric textures==
=={{ent|UnlitGeneric}} Textures==
The <code>UnlitGeneric</code> [[shader]] forces the entire face to be full bright. The surface does not emit light, and light has no visible effect on the surface. Mainly used when the texture should appear to be a light source without forcing any light into creation. All that is required for the effect is to specify the materials shader as unlit generic. Because <code>UnlitGeneric</code>s are their own shader they can be applied to both models and world brushes.
The <code>UnlitGeneric</code> [[shader]] forces the entire face to be fullbright. The surface does not emit light, and light has no visible effect on the surface. Mainly used when the texture should appear to be a light source without forcing any light into creation. All that is required for the effect is to specify the materials shader as <code>UnlitGeneric</code>. Because <code>UnlitGeneric</code>s are their own shader, they can be applied to both models and world brushes.


  UnlitGeneric
  UnlitGeneric
Line 95: Line 92:
A common use is that of [[skybox]] textures, the sky is always bright and the face the texture will appear on has no form of lighting itself.
A common use is that of [[skybox]] textures, the sky is always bright and the face the texture will appear on has no form of lighting itself.


{{warning|You need to include the command <code>[[$model]] 1</code> in your .vmt if you're using an <code>UnlitGeneric</code> on a model, otherwise the surface may not show up.}}
{{warning|You need to include the command {{ent|$model|1}} in your <code>.vmt</code> if you're using an <code>UnlitGeneric</code> on a model, otherwise the surface may not show up.}}


[[Image:glow_unlit.jpg|thumb|256px|left|A unlitgeneric texture in use]]{{clr}}
[[Image:glow_unlit.jpg|thumb|256px|left|A unlitgeneric texture in use]]{{clr}}


==Minimum Light Level values==
==Minimum Light Level Values==
 
This is not strictly a glowing texture ''per se'' but another way that a texture can be made to ''appear'' to glow (without shedding any actual light). By placing it on certain entities, you will be able to set the Minimum Light Level float value to control the minimum amount of ambient light the surface will reflect. The most common of these is {{ent|func_brush}}. Setting the Minimum Light Level high (from 5 to 50 or more, depending on how light the texture is) will result in the textures on the brush glowing brightly.
This is not strictly a glowing texture ''per se'', but another way that a texture can be made to ''appear'' to glow (without shedding any actual light) is by placing it on a surface that allows you to set the Minimum Light Level float value to control the minimum amount of ambient light the surface will reflect. The most common of these is {{ent|func_brush}}. Setting the Minimum Light Level high (from 5 to 50 or more, depending on how light the texture is) will result in the textures on the brush glowing brightly.


{{warning|Increasing the Minimum Light Level can have a disproportionate effect on cubemap sampling, causing the scene to compile too brightly.}}
{{warning|Increasing the Minimum Light Level can have a disproportionate effect on cubemap sampling, causing the scene to compile too brightly.}}
Line 107: Line 103:
[[Image:minimum_light_level_manipulation.jpg|thumb|256px|left|Minimum Light Level changes. From left to right: 0, 0.5, 2, 10, 25, and 50]]{{clr}}
[[Image:minimum_light_level_manipulation.jpg|thumb|256px|left|Minimum Light Level changes. From left to right: 0, 0.5, 2, 10, 25, and 50]]{{clr}}


==Use of [[info_lighting]]==
==Use of {{ent|info_lighting}}==
 
Models can be made to glow brightly (though they do not actually emit any light) if their '''lighting origin''' key value is set to the name of an <code>info_lighting</code> that is placed in a lightbox isolated from the rest of the map. In the illustration below, the model to the right has been linked to an <code>info_lighting</code> placed in a small hollow cube with nine {{ent|light}} entities, each set to a brightness of 5000.  
Models and {{ent|prop_static}} entities can be made to glow brightly (though they do not actually emit any light) if their '''lighting origin''' key value is set to the name of an <code>info_lighting</code> that is placed in a lightbox isolated from the rest of the map. In the illustration below, the model to the right has been linked to an <code>info_lighting</code> placed in a small hollow cube with nine {{ent|light}} entities, each set to a brightness of 5000.  


One possibly useful feature of this method of manipulating lighting is that it dynamically updates in real time. That is, if the lights in the lightbox are linked to a switch or trigger, or pre-set to pulse, flicker, or so on, the lighting on the model or <code>prop_static</code> will reflect these changes immediately. This might be used, for instance, to slowly darken modeled terrain to simulate the coming of evening.
One possibly-useful feature of this method of manipulating lighting is that it dynamically updates in real time. That is, if the lights in the lightbox are linked to a switch or trigger, or pre-set to pulse, flicker, or so on, the lighting on the model will reflect these changes immediately. This might be used, for instance, to slowly darken modeled terrain to simulate the coming of evening.


[[Image:lightsource_manipulation.jpg|left|Effect of linking a model to an info_lighting in a lightbox]]{{clr}}
[[Image:lightsource_manipulation.jpg|left|Effect of linking a model to an info_lighting in a lightbox]]{{clr}}
[[Category:Material System]]
[[Category:Lighting]]

Revision as of 16:34, 9 May 2022

English (en)Français (fr)中文 (zh)Translate (Translate)

A glowing texture is one that does not require another form of light to be lit up. It can create its own lightmap independent of all lighting sources and may even create light itself. This does not mean that the surface will appear pure white, just that the face will ignore any light it would receive. This is a key feature as a "glowing" black stays black and does not get brighter. The face achieves what is called fullbright, where the texture's pixels appear exactly the same color as they were saved.

There are several different ways to create this effect available in the Source engine.

For glowing textures on models or brush faces:

  1. $selfillum parameter, specified in a material's VMT. - Use this for most purposes, not compatible with transparency.
  2. UnlitGeneric shader, specified in a material's VMT - Does not emit light, forces face to ignore all lighting, making it fullbright.
  3. $detail parameter with $detailblendmode value of 5 or 6, specified in a material's VMT - Same as $selfillum, but more rudimentary and compatible with transparency.
  4. Using info_lighting to "fool" a model into "thinking" it is brightly illuminated.

For glowing textures on brush faces only:

  1. Using the Minimum Light Level entity keyvalue.
  2. .rad file, mainly used for glowing textures on brushes. RAD files are the only form of glowing textures that generate any map light. The file is processed line-by-line; each line is simply the name of the texture, the RGB value of the light, and then the brightness of the light.

Common selfillum textures can be found in White.

$selfillum

Self illumination applies "fake" light to a surface, regardless of the true light that the surface receives from the environment. This is useful for parts of a model that emit their own visible light, like the filament in a light bulb or a glowing LED on a control panel. The self illumination effect can be masked with a texture.

Warning.pngWarning:$selfillum cannot be used with $translucent or $alphatest on models. Use the UnlitGeneric shader instead or the $detail workaround.
LightmappedGeneric
{
    $basetexture props/tvscreen005a
    $selfillum 1
}

By default, $selfillum uses the alpha channel of the base texture as a mask. If the alpha channel of your base texture is used for something else, you can specify a separate $selfillummask texture.

LightmappedGeneric
{    
    $basetexture props/tvscreen005a
    $selfillum 1
    $selfillummask <texture>
}

With an opaque mask, $selfillum effectively works like UnlitGeneric. The surface will ignore all light from the environment and appear fullbright.

Mask values below 1.0 apply a minimum brightness effect to the surface, while still allowing it to receive light from the environment. This threshold effect is useful for objects like computer screens, which should be visible in darkness but become overwhelmed in bright sunlight.

Additional Parameters

$selfillumtint $selfillummaskscale $selfillummask $selfillum_envmapmask_alpha

Note.pngNote:$selfillum_envmapmask_alpha replaces the original $selfillum command, so they cannot be used together.

$selfillumtexture $selfIllumFresnel $selfIllumFresnelMinMaxExp

A selfillum mask texture.

$detail

If $selfillum is not a viable option, a $detail texture can be used instead. It can bypass the sv_consistency check on some games, such as in Counter-Strike: Source Counter-Strike: Source or Left 4 Dead 2 Left 4 Dead 2, to allow glowing textures where textures with $selfillum would cause you to be kicked from the server.

VMT lines required for a $detail glow:

       $detail models\weapons\pose\briefcase/briefcase_pickedup_red
       $detailscale 1        //scales the detail texture to same size as diffuse.
       $detailblendfactor 1  //lower values make the texture less visible. 0.0 - 1.0
       $detailblendmode 5    //6 also works.

The detail texture itself must be completely black with the parts that should be glowing colored. Dark colors will glow less. You cannot make a black glowing texture this way.

The Team Fortress 2 briefcase detail glow texture

Using envmaps for a Solid-Color Glow

If for some reason you can't use $selfillum and can't do glow with $detail, you can still do a solid-color glow on the material. As reflections are not affected by lighting and appear to glow in the dark, specular reflections using cubemaps can be used. Unlike $selfillum, you can only make pixels glow in a color additively, i.e., you can't make part of a texture glow, only add a single-color glow over it. Can be done using a white cubemap and making the cubemap reflection visible only in some places per-pixel through an $envmapmask. You can also tint the cubemap glow to any color by $envmaptint.

.rad files

Warning.pngWarning: This method will only work on world brushes
example\exampletexture 128 192 96 400

Unlike $selfillum or the UnlitGeneric shader, lights of the specified color and brightness are generated in front of the world brush's face during VRAD complation. The brightness of the created lights is also affected by the density of the lightmap. Higher densities will produce a greater effect. The texture itself does not become fullbright, but the lights in front often make it seem so.

If a texture is specified in multiple places, it will be overridden by the latest information. If both lights.rad and <game>.rad specified the same texture, but <game>.rad was brighter, the light emitted in the compiled map would be the brighter <game>.rad version.

A .rad texture in use

UnlitGeneric Textures

The UnlitGeneric shader forces the entire face to be fullbright. The surface does not emit light, and light has no visible effect on the surface. Mainly used when the texture should appear to be a light source without forcing any light into creation. All that is required for the effect is to specify the materials shader as UnlitGeneric. Because UnlitGenerics are their own shader, they can be applied to both models and world brushes.

UnlitGeneric
{
	$basetexture example\exampletexture
}

A common use is that of skybox textures, the sky is always bright and the face the texture will appear on has no form of lighting itself.

Warning.pngWarning:You need to include the command $model 1 in your .vmt if you're using an UnlitGeneric on a model, otherwise the surface may not show up.
A unlitgeneric texture in use

Minimum Light Level Values

This is not strictly a glowing texture per se but another way that a texture can be made to appear to glow (without shedding any actual light). By placing it on certain entities, you will be able to set the Minimum Light Level float value to control the minimum amount of ambient light the surface will reflect. The most common of these is func_brush. Setting the Minimum Light Level high (from 5 to 50 or more, depending on how light the texture is) will result in the textures on the brush glowing brightly.

Warning.pngWarning:Increasing the Minimum Light Level can have a disproportionate effect on cubemap sampling, causing the scene to compile too brightly.
Minimum Light Level changes. From left to right: 0, 0.5, 2, 10, 25, and 50

Use of info_lighting

Models can be made to glow brightly (though they do not actually emit any light) if their lighting origin key value is set to the name of an info_lighting that is placed in a lightbox isolated from the rest of the map. In the illustration below, the model to the right has been linked to an info_lighting placed in a small hollow cube with nine light entities, each set to a brightness of 5000.

One possibly-useful feature of this method of manipulating lighting is that it dynamically updates in real time. That is, if the lights in the lightbox are linked to a switch or trigger, or pre-set to pulse, flicker, or so on, the lighting on the model will reflect these changes immediately. This might be used, for instance, to slowly darken modeled terrain to simulate the coming of evening.

Effect of linking a model to an info_lighting in a lightbox