Team Fortress 2/Pyrovision: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (It also needs a screenshot)
(Trying to split the article.)
Line 1: Line 1:
{{Split-apart}}
{{screenshot}}
{{screenshot}}
Pyro vision is an effect applied in the game Team Fortress 2. It allows the player to enter the imaginary world featured in the "Meet the Pyro" animated short.
It works by using a material replacement list and a custom developed shader.
== Material replacement ==
When a material is loaded, it attempts to find a replacements.vmt file in that directory.  If it doesn’t find one in that immediate directory, it will attempt to find one going up in the directory hierarchy through the materials directory.  Both the original material and the replacement material are fully loaded, so you should be cautious about how many new textures are introduced via the replaced material.
When a material is loaded, it attempts to find a replacements.vmt file in that directory.  If it doesn’t find one in that immediate directory, it will attempt to find one going up in the directory hierarchy through the materials directory.  Both the original material and the replacement material are fully loaded, so you should be cautious about how many new textures are introduced via the replaced material.


The replacements.vmt file is split into two sections: patterns and templates.  Patterns represent a partial material name match.  If a match is found, the template specified will point to a name in the template section for the alternate material.  Within each template, you must specify a sub section which represents the original source shader type.  Under that, you specify the replaced shader type and the parameters associated with it.
The replacements.vmt file is split into two sections: patterns and templates.  Patterns represent a partial material name match.  If a match is found, the template specified will point to a name in the template section for the alternate material.  Within each template, you must specify a sub section which represents the original source shader type.  Under that, you specify the replaced shader type and the parameters associated with it.
=== Patterns ===


Patterns represent a sequence list of starting name matches.  The replacement system will sequentially scan down the list until a name pattern matches.  Thus, you can put very specific material name matches higher up in the list and general name matches later on.  For example:
Patterns represent a sequence list of starting name matches.  The replacement system will sequentially scan down the list until a name pattern matches.  Thus, you can put very specific material name matches higher up in the list and general name matches later on.  For example:
Line 26: Line 34:


A material named "concretewall001d" or "concretewall001dnew" would get mapped to "peach02", "concretewall012d" would to mapped to "pink01" and anything else that begins with "concretewall" would get matched to "blue01".
A material named "concretewall001d" or "concretewall001dnew" would get mapped to "peach02", "concretewall012d" would to mapped to "pink01" and anything else that begins with "concretewall" would get matched to "blue01".
=== Templates ===


Templates specify the replacement definition for the material.  Under each template name you specify the shader type that is replaced.  This allows you to have one template which can handle multiple shader sources, such as both VertexLitGeneric and LightmappedGeneric.  Under each shader type, you specify a brand new shader definition.  For Pyrovision,  most new shaders are of type pyro_vision, though in reality it can be an type of shader that can handle the incoming vertex format from the source shader.
Templates specify the replacement definition for the material.  Under each template name you specify the shader type that is replaced.  This allows you to have one template which can handle multiple shader sources, such as both VertexLitGeneric and LightmappedGeneric.  Under each shader type, you specify a brand new shader definition.  For Pyrovision,  most new shaders are of type pyro_vision, though in reality it can be an type of shader that can handle the incoming vertex format from the source shader.
Line 76: Line 86:
</source>
</source>


==== Pyro Vision Shader ====
== See Also ==
The Pyro vision shader has 4 effect modes controlled by $EFFECT
[[Pyro vision (shader)]]
 
0: An R&D stage which is not finished<br>
1: Handles most of the world and model rendering in pyro land<br>
2: Depth of Field blending<br>
3: Pyro vignette drawing<br>
 
For this discussion, we will only be talking about effect #1.  Effect #1 essentially takes the diffuse result of your base texture(s), converts it to gray scale and uses that gray scale as a texture coordinate in a 1d color bar image to get the final result.  You have various controls to indicate how much detail you want to get from the original diffuse or lighting components, as well as to control the gray scale results.  There is also an optional striping texture which allows you to apply the same strip seamlessly over multiple geometric shapes in the world.  While it is called stripes, you could easily create any pattern which smoothly repeats, such as dots.
 
Standard Fields found in other shaders:
 
<source lang="cpp">
$BASETEXTURE ""
Your diffuse texture
 
For two way blends
$BASETEXTURE2 ""
Second diffuse texture
 
$BLENDMODULATETEXTURE ""
Optional modulate texture
 
$BLENDMASKTRANSFORM "center .5 .5 scale 1 1 rotate 0 translate 0 0"
The transform parameters for blending


General Fields:
$EFFECT 1
Used to specify the effect type.
$VERTEX_LIT 0
0 if lightmap based, 1 if vertex lit based
Effect #1 Fields
$DIFFUSE_BASE 0.0
Value from 0.0 to 1.0 to blend the diffuse towards solid white
$DIFFUSE_WHITE 0.0
Value from 0.0 to 1.0 to blend the lightmap towards solid white
$GRAY_POWER 1.0
Raises the gray scale result to this value
$GRAY_STEP "[ 0.0 1.0 ]"
Peforms a smooth step between the two values supplied.  Think of this as the min/max sliders on a histogram chart.
$LIGHTMAP_GRADIENTS 255.0
Values from 1.0 to 255.0.  Downscales the result into this many categories.  May be provide some cartooning effects if you use low values.
$COLORBAR ""
Specifies a 1D Texture ( we used 512x1 ).  The resultant gray scale is used as a texture coordinate into this image to get the final color.  We generally used the image as a color gradient, but try different patterns or smoothness of gradients for different results.
$SELFILLUMTINT "[ 1.0 1.0 1.0 ]"
If self illumination is specified, this is the tint color for the self illumination.
Optional Stripes
$STRIPETEXTURE ""
The texture used to specify the stripe or any other pattern.  It uses standard alpha translucency to blend this texture.
$STRIPE_SCALE "[ 0.002 0.002 0.2 ]"
Specifies the x y z world scaling to compute the seamless texture coordinate of the stripe texture.
$STRIPE_COLOR "[ 1.0 1.0 1.0 ]"
The color modulated against the strip texture’s RGB.  If you make your strip texture as gray scale, then you can have greater color control by using this field, as well as only needing one texture to create many colors.
$STRIPE_LM_SCALE 0.0
Interpolates between the lighting intensity of the pixel to full bright based upon this value.
</source>
== See Also ==
[http://www.teamfortress.com/post.php?id=8502 Dreams of Chronic and Sustained Cruelty] A blog post about how the pyro vision effect was developed.
[http://www.teamfortress.com/post.php?id=8502 Dreams of Chronic and Sustained Cruelty] A blog post about how the pyro vision effect was developed.


[[Category:Material System]]
[[Category:Material System]]
[[Category:Shaders]]
[[Category:Shaders]]

Revision as of 19:21, 12 August 2012

Nuvola apps ksnapshot.png
This article or section needs a screenshot to help visually convey the subject.
You can upload screenshots at Special:Upload. For help, see Help:Images.

Pyro vision is an effect applied in the game Team Fortress 2. It allows the player to enter the imaginary world featured in the "Meet the Pyro" animated short.

It works by using a material replacement list and a custom developed shader.

Material replacement

When a material is loaded, it attempts to find a replacements.vmt file in that directory. If it doesn’t find one in that immediate directory, it will attempt to find one going up in the directory hierarchy through the materials directory. Both the original material and the replacement material are fully loaded, so you should be cautious about how many new textures are introduced via the replaced material.

The replacements.vmt file is split into two sections: patterns and templates. Patterns represent a partial material name match. If a match is found, the template specified will point to a name in the template section for the alternate material. Within each template, you must specify a sub section which represents the original source shader type. Under that, you specify the replaced shader type and the parameters associated with it.

Patterns

Patterns represent a sequence list of starting name matches. The replacement system will sequentially scan down the list until a name pattern matches. Thus, you can put very specific material name matches higher up in the list and general name matches later on. For example:

patterns
{
	concretewall001d	// matches concretewall001d*
	{
		template	"peach02"
	}
	concretewall012d	// matches concretewall012d*
	{
		template	"pink01"
	}
	concretewall		// matches concretewall* ( except if matched by what is above )
	{
		template	"blue01"
	}
}

A material named "concretewall001d" or "concretewall001dnew" would get mapped to "peach02", "concretewall012d" would to mapped to "pink01" and anything else that begins with "concretewall" would get matched to "blue01".

Templates

Templates specify the replacement definition for the material. Under each template name you specify the shader type that is replaced. This allows you to have one template which can handle multiple shader sources, such as both VertexLitGeneric and LightmappedGeneric. Under each shader type, you specify a brand new shader definition. For Pyrovision, most new shaders are of type pyro_vision, though in reality it can be an type of shader that can handle the incoming vertex format from the source shader.

Parameters that you specify can both be your own custom values. If you specify a value that starts with a dollar sign, it will attempt to use that as a source field to copy over the value from the original material definition. Finally, if you specify a key of "$copyall" with any value, it will copy all source material parameters down.

templates
{		
peach02	// template name
	{
		"LightmappedGeneric"	// source shader type for LightmappedGeneric
		{
			pyro_vision		// new replaced shader type and material definition
			{
				$basetexture			$basetexture
				$vertexcolor			$vertexcolor

				$EFFECT				1
				$COLORBAR				"rj/colorbar_peach02"
					
				$DIFFUSE_WHITE			0.5
				$GRAY_POWER				0.8
				$GRAY_STEP				"[ 0.0 1.0 ]"
				$LIGHTMAP_GRADIENTS		255
			}
		}
		"VertexLitGeneric"	// source shader type for VertexLitGeneric
		{
			pyro_vision
			{
				$EFFECT				1
				$VERTEX_LIT				1
					
				$basetexture			"pyroconcretewall"
				$vertexcolor			$vertexcolor

				$EFFECT				1
				$COLORBAR				"rj/colorbar_patch02"

				$DIFFUSE_WHITE			0.5
				$DIFFUSE_BASE			0.1
				$GRAY_POWER				0.4
				$GRAY_STEP				"[ 0.0 1.0 ]"
				$LIGHTMAP_GRADIENTS		255
			}
		}
	}
}

See Also

Pyro vision (shader)

Dreams of Chronic and Sustained Cruelty A blog post about how the pyro vision effect was developed.