Sprite: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(formatting + clarification)
 
(32 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{LanguageBar}}
{{split|This page is for sprites in general, as they apply to all Valve games.
<br>• Move Source engine-specific shader stuff to [[Sprite (shader)]] and [[$spriteorientation]]. See also [[Shaders in Sprites\]].
<br>• GoldSrc-specific engine stuff likely belongs in [[SPR]].}}


In source, a '''[http://en.wikipedia.org/wiki/Sprite_%28computer_graphics%29#Move_to_3D Sprite]''' is a rendered world object with some very special geometrickery. The sprite itself is a (static or animated) 2D image that looks 3D when viewed ''Normally'' (ie perpendicular to its surface). The trick is to make sure the player always views the sprite ''normally''; which usually means rotating the sprite about its origin so it is always facing the Player. Obviously in multiplayer this rotation in World would not work, so the sprite is rotated only in the [[Player View]].
In {{gldsrc|2}} and {{source|2}}, a '''sprite''' is a rendered world object with some very special geometrickery. The sprite itself is a (static or animated) 2D image that looks 3D when viewed ''Normally'' (ie perpendicular to its surface). The trick is to make sure the player always views the sprite ''normally''; which usually means rotating the sprite about its origin so it is always facing the Player. Obviously in multiplayer this rotation in World would not work, so the sprite is rotated only in the [[Player View]].


Although their usefulness is severely limited, ''sprites'' are significantly "cheaper" to render than models or brushwork, and can also achieve convincing effects that would be impractical to model in 3D.
Although their usefulness is severely limited, ''sprites'' are significantly [[cheap]]er to render than models or brushwork, and can also achieve convincing effects that would be impractical to model in 3D.
* '''Lighting:''' Sprites cannot cast or receive any kind of [[shadow]]s, nor reflect [[cubemap]]s.<!--compare [[viewmodel]]s-->
* '''Lighting:''' Sprites cannot cast or receive any kind of [[shadow]]s, nor reflect [[cubemap]]s.<!--compare [[viewmodel]]s-->
* '''Physics:''' Sprites cannot be [[Solid]] to anything.
* '''Physics:''' Sprites cannot be [[Solid]] to anything {{note|In {{gldsrc|4}}, {{ent|cycler_sprite}} entities '''can''' have collision (simple bounding box), but this entity is buggy and not meant for final distributables. Use a {{mono|CLIP}} brush and/or an [[MDL (GoldSrc)|MDL]] instead.}}
 
{{bug|hidetested=1|In {{src|4}}, reloading the game materials has no effect on sprite textures loaded in a game session. If a sprite material is changed after the game has already loaded the VMT on a sprite, the game must be restarted.}}


==Sprite entities==
==Sprite entities==
* [[env_sprite]]
{| <!-- class="wikitable" -->
* [[env_sprite_oriented]]
|-
* [[env_fire]]
| {{gldsrc|4}}
* [[env_lightglow]]
| {{src|4}}
* [[env_steam]]
|-
* [[prop_detail_sprite]]<!-- note: very different to behaviour env_sprites-->
|
* {{ent|env_sprite|eng=goldsrc}}
* {{ent|env_glow|eng=goldsrc}}
* {{ent|env_laser|eng=goldsrc}}
* {{ent|env_beam|eng=goldsrc}}
* {{ent|env_shooter|eng=goldsrc}}
* {{ent|cycler_sprite|eng=goldsrc}}
* {{ent|env_spritetrain|eng=goldsrc}}{{only|{{hlop4}} and {{Sven}}}}
|
* {{ent|env_sprite}}
* {{ent|env_sprite_clientside}}
* {{ent|env_sprite_oriented}}
* {{ent|prop_detail_sprite}}
 
|}


==Placement==
==Placement==
Line 23: Line 43:


==Creation==
==Creation==
{{TODO|...guidelines/checklist for designing & implementing sprites.}}
{{todo|guidelines/checklist for designing & implementing sprites.}}


* Design guidelines.
* Design guidelines.
Line 34: Line 54:
* If using a texture that is intended to be transparent, be sure to close Hammer and restart it before compiling.  Hammer likes to only half-load new sprite textures and won't display them as transparent.
* If using a texture that is intended to be transparent, be sure to close Hammer and restart it before compiling.  Hammer likes to only half-load new sprite textures and won't display them as transparent.
* Sprite textures may also have any shade of gray (red, green, and blue values identical) interpreted as being transparent.  Have not extensively tested, but it has worked in at least two cases (light_glow01 and a custom one).
* Sprite textures may also have any shade of gray (red, green, and blue values identical) interpreted as being transparent.  Have not extensively tested, but it has worked in at least two cases (light_glow01 and a custom one).
* VTF: [[Vtex compile parameters]] "clamps", "clampt". note: [[env_sprite_oriented]] #angles ...
* VTF: [[Vtex compile parameters]] "clamps", "clampt". note: {{ent|env_sprite_oriented}} #angles ...
* VMT: [[Shaders_in_Sprites\]]
* VMT: [[Shaders_in_Sprites\]]


[[Category:Level Design]]
=={{mono|$spriteorientation}} Shader parameter==
 
{{important|When using {{code|preset==1|$spriteorientation}} on a material that ''doesn't'' use the {{mono|Sprite}} shader, you must use the number written next to them (for instance 1) instead of the text (for instance "facing_upright").}}
----
[[Category:$spriteorientation parameters for .vmt creation]]
 
=="$spriteorientation" parameters for .vmt==
 
''parallel_upright''
* Not mentioned in the Edit Life article.
! fire1, fire2, fire, fireburst, flame01, flame03, flame04, floorfire4_, floorflame2, parallel_upright, physbeam


''facing_upright''
;{{code|parallel_upright (0)}}
* Invalid (?) Unused (?)
: Like parallel, but doesn't rotate around Z axis
* (The Edit Life article mentions "vp_facing_upright"; is it invalid? Something else?)
:: Used in : fire1, fire2, fire, fireburst, flame01, flame03, flame04, floorfire4_, floorflame2, parallel_upright, physbeam


''vp_parallel''
;{{code|facing_upright (1)}}
* This always faces the player.  
: Like parallel upright, but rotated based on world origin, rather than camera.
! Most popular.
:: Unused {{confirm}}


''oriented''
;{{code|vp_parallel}} (2)
* Oriented to the world (does not face player)
: Rotates to always face the camera.
! flatframe, lamphalo1, lamphalo
:: Most popular. <small>{{todo|find actual examples.}}</small>


''vp_parallel_oriented''
;{{code|oriented (3)}}
* If the sprite entity is rotated, the sprite will match the rotation.
: Rotated in map editor to face a specific direction
* Not mentioned in the Edit Life article.
:: Used in : flatframe, lamphalo1, lamphalo
! plasma, smoke, steam1


Reference:  
{{code|vp_parallel_oriented (4)}}
http://www.editlife.net/tutorial.php?tutid=54
: Combination of parallel and oriented.
:: Used in : plasma, smoke, steam1


E.G. of Stock HL2 Sprite
'''Example : {{path|icon=image|sprites/glow_test02|vmt}} from {{hl2|4}}'''
<syntaxhighlight>
<source>
"Sprite"
"Sprite"
{
{
Line 83: Line 95:
}
}
}  
}  
</syntaxhighlight>
</source>


Reference: materials/sprites/glow_test02
Reference: materials/sprites/glow_test02
Line 89: Line 101:
E.G. of Custom Sprite
E.G. of Custom Sprite


<syntaxhighlight>
<source>
"Sprite"
"Sprite"
{
{
Line 98: Line 110:
"$nocull" "1"
"$nocull" "1"
"$vertexcolor" "1"
"$vertexcolor" "1"
"$vertexalpha" "1"
"$vertexalpha" "1"  
        "%keywords" "turret .spr"     
}
}
</syntaxhighlight>
</source>
 
Download Reference: [[http://forum.tsgk.com/viewtopic.php?t=4699]]
*File Name Reference: {{path|icon=file|gtamikes_custom_turrets_V3_Final.rar}}
** {{path|icon=image|turret_rebel|vmt}}, {{path|icon=image|turret_rebel|vtf}}
** {{path|icon=image|turret_combine|vmt}}, {{path|icon=image|turret_combine|vtf}}
 
[[File:Gtamikes_custom_sprite.jpg|thumb|right|Rebel and Combine Custom Sprite For {{hl2dm|4|}} CTF Mode]]
 
[[Category:Glossary]]
[[Category:Level Design]]


Download Reference: http://forum.tsgk.com/viewtopic.php?t=4699
*File Name Reference: gtamikes_custom_turrets_V3_Final.rar
** turret_rebel.vmt, turret_rebel.vtf
**turret_combine.vmt, turret_combine.vtf


[[Image:Gtamikes_custom_sprite.jpg|thumb|left|Rebel and Combine Custom Sprite For HL2DM CTF Mode]]
{{stub}}

Latest revision as of 14:44, 21 June 2025

English (en)中文 (zh)Translate (Translate)

Split-arrows.png Split

It has been suggested that this article or section be split into multiple articles: This page is for sprites in general, as they apply to all Valve games.
• Move Source engine-specific shader stuff to Sprite (shader) and $spriteorientation. See also Shaders in Sprites\.
• GoldSrc-specific engine stuff likely belongs in SPR.. (Discuss)


In GoldSrc GoldSrc and Source Source, a sprite is a rendered world object with some very special geometrickery. The sprite itself is a (static or animated) 2D image that looks 3D when viewed Normally (ie perpendicular to its surface). The trick is to make sure the player always views the sprite normally; which usually means rotating the sprite about its origin so it is always facing the Player. Obviously in multiplayer this rotation in World would not work, so the sprite is rotated only in the Player View.

Although their usefulness is severely limited, sprites are significantly cheaper to render than models or brushwork, and can also achieve convincing effects that would be impractical to model in 3D.

  • Lighting: Sprites cannot cast or receive any kind of shadows, nor reflect cubemaps.
  • Physics: Sprites cannot be Solid to anything
    Note.pngNote:In GoldSrc GoldSrc, cycler_sprite entities can have collision (simple bounding box), but this entity is buggy and not meant for final distributables. Use a CLIP brush and/or an MDL instead.
Icon-Bug.pngBug:In Source Source, reloading the game materials has no effect on sprite textures loaded in a game session. If a sprite material is changed after the game has already loaded the VMT on a sprite, the game must be restarted.

Sprite entities

GoldSrc GoldSrc Source Source

Placement

Todo: ... general usage guidelines ... configuring sprite entities in Hammer.

Creation

Todo: guidelines/checklist for designing & implementing sprites.
  • Design guidelines.
    • the image inside the sprite already depicts a three dimensional object;
    • the animation is constantly changing or depicts rotation;
    • the depicted object has a similar appearance from many common viewing angles (such as something spherical);
    • the viewer accepts that the depicted object only has one perspective (such as small plants or leaves).
    • the sprite exists only briefly, is NotSolid, ... player cannot inspect it too closely.
  • SPR file format...
  • If using a texture that is intended to be transparent, be sure to close Hammer and restart it before compiling. Hammer likes to only half-load new sprite textures and won't display them as transparent.
  • Sprite textures may also have any shade of gray (red, green, and blue values identical) interpreted as being transparent. Have not extensively tested, but it has worked in at least two cases (light_glow01 and a custom one).
  • VTF: Vtex compile parameters "clamps", "clampt". note: env_sprite_oriented #angles ...
  • VMT: Shaders_in_Sprites\

$spriteorientation Shader parameter

Icon-Important.pngImportant:When using $spriteorientation on a material that doesn't use the Sprite shader, you must use the number written next to them (for instance 1) instead of the text (for instance "facing_upright").
parallel_upright (0)
Like parallel, but doesn't rotate around Z axis
Used in : fire1, fire2, fire, fireburst, flame01, flame03, flame04, floorfire4_, floorflame2, parallel_upright, physbeam
facing_upright (1)
Like parallel upright, but rotated based on world origin, rather than camera.
Unused [confirm]
vp_parallel (2)
Rotates to always face the camera.
Most popular.
Todo: find actual examples.
oriented (3)
Rotated in map editor to face a specific direction
Used in : flatframe, lamphalo1, lamphalo

vp_parallel_oriented (4)

Combination of parallel and oriented.
Used in : plasma, smoke, steam1

Example : 🖼Imagesprites/glow_test02.vmt from Half-Life 2 Half-Life 2

"Sprite"
{
	"$spriteorientation" "vp_parallel"
	"$spriteorigin" "[ 0.50 0.50 ]"
	"$basetexture" "sprites/glow_test02"

	"Proxies"
	{
		"lampbeam"
		{
		}
	}
}

Reference: materials/sprites/glow_test02

E.G. of Custom Sprite

"Sprite"
{
	"$basetexture" "sprites/turret_rebel"
	"$spriteorientation" "vp_parallel"
	"$spriteorigin" "[ 0.50 0.50 ]"
	"$translucent" "1"
	"$nocull" "1"
	"$vertexcolor" "1"
	"$vertexalpha" "1"   
}

Download Reference: [[1]]

  • File Name Reference: Filegtamikes_custom_turrets_V3_Final.rar
    • 🖼Imageturret_rebel.vmt, 🖼Imageturret_rebel.vtf
    • 🖼Imageturret_combine.vmt, 🖼Imageturret_combine.vtf
Rebel and Combine Custom Sprite For Half-Life 2: Deathmatch Half-Life 2: Deathmatch CTF Mode


Stub

This article or section is a stub. You can help by expanding it.