$emissiveblend: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added a tip about adding $emissiveblend to other shaders)
mNo edit summary
Line 9: Line 9:
{{tip|While it is normally used only on '''<code>VertexLitGeneric</code>''', <code>$emissiveblend</code> can be plugged into custom shaders as well (or the SDK counterparts of the standard shaders), as it renders in a separate pass on top of things.  
{{tip|While it is normally used only on '''<code>VertexLitGeneric</code>''', <code>$emissiveblend</code> can be plugged into custom shaders as well (or the SDK counterparts of the standard shaders), as it renders in a separate pass on top of things.  


An instruction on how to do it is included in the [[Source 2007]]'s source code]], as well as the [[Alien Swarm SDK]], in <code>materialsystem/stdshaders/emissive_scroll_blended_pass_helper.cpp</code> (although it may require minor tweaks to make it fully compatible with your platform).  
An instruction on how to do it is included in the [[Source 2007]]'s source code, as well as the [[Alien Swarm SDK]], in <code>materialsystem/stdshaders/emissive_scroll_blended_pass_helper.cpp</code> (although it may require minor tweaks to make it fully compatible with your platform).  


Because these files aren't shipped with [[Source SDK 2013]], you will need to copy the related <code>.cpp, .h</code> and <code>.fxc</code> files for it from either 2007 or ASW SDK.
Because these files aren't shipped with [[Source SDK 2013]], you will need to copy the related <code>.cpp, .h</code> and <code>.fxc</code> files for it from either 2007 or ASW SDK.

Revision as of 03:14, 6 December 2023

English (en)Translate (Translate)
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.

Template:Shaderparam It provides advanced self-illumination that can be flowed using a flowmap. It is used for the Vortigaunts in Half-Life 2: Episode Two Half-Life 2: Episode Two and succeeds the VortWarp shader from Half-Life 2: Episode One Half-Life 2: Episode One. All parameters must be specified except for $emissiveblendstrength in order for the effect to work properly.

Confirm:EyeRefract appears to include it as well. Verify if it properly works on it.

Template:ModernNote

Tip.pngTip:While it is normally used only on VertexLitGeneric, $emissiveblend can be plugged into custom shaders as well (or the SDK counterparts of the standard shaders), as it renders in a separate pass on top of things.

An instruction on how to do it is included in the Source 2007's source code, as well as the Alien Swarm SDK, in materialsystem/stdshaders/emissive_scroll_blended_pass_helper.cpp (although it may require minor tweaks to make it fully compatible with your platform).

Because these files aren't shipped with Source SDK 2013, you will need to copy the related .cpp, .h and .fxc files for it from either 2007 or ASW SDK.

Confirm: Check which shaders can be supplemented with it. So far had it work with SDK_LightmappedGeneric and SDK_Refract.

Parameters

$emissiveblendenabled $emissiveblendtexture $emissiveblendbasetexture $emissiveblendflowtexture $emissiveblendtint $emissiveblendstrength $emissiveblendscrollvector

Time Proxy

For any reason, you may want to modulate time by scale it. The below material proxy is a simple sample to work properly.

Note.pngNote: you don't need to declare "CurrentTime" Proxie in cases where you don't need to relative modify time scale.
	"$time" "0.0"
	"$CurrentTime" "0.0" // declare a custom VMT Parameter to "CurrentTime" Proxie output
	"$timeMult" "0.5"    // declare a custom VMT Parameter to use at "Multiply" Proxie

	"Proxies"
	{
		"CurrentTime"
		{
			// It pass CurrentTime Proxie to "$CurrentTime" variable to scale materials effects such $emissiveblendscrollvector.
			"resultVar" "$CurrentTime" 
		}
		"Multiply"
		{
			"srcVar1" "$CurrentTime" // get $CurrentTime VMT parameter to multiply with srcVar2
			"srcVar2" "$timeMult"    // get $timeMult VMT parameter to multiply with srcVar1
			"resultVar" "$time"      // writes multiplication product into $time, scaling "CurrentTime" 
		}
	}

Example

Static

This is an example of a static $emissiveblend texture. It will appear just like $selfillum does.

Tip.pngTip:Because $emissiveblend effectively doubles the draw calls of a model it is applied to, using it for static glow can be unnecessarily expensive, especially on meshes with high polygon count. Consider either using $selfillum if you can, or $detail with $detailblendmode 5 (if you're not already using $detail for something else.
$EmissiveBlendEnabled 		1					// Enable EmissiveBlend. Like $selfillum 1	
$EmissiveBlendStrength 		1 					// how strong the entire glow effect is.
$EmissiveBlendTexture 		vgui/white			// This will be useless, but is required.
$EmissiveBlendBaseTexture 	Glow_texture_color	// this is the glowing texture.vtf
$EmissiveBlendFlowTexture 	vgui/white	 		// EmmisiveBlend can "flow" or move. But ours is static, so a white texture is used.
$EmissiveBlendTint 			" [ 1 1 1 ] "		// RGB glow intensity. Leave at 1 1 1. This can be used to change how strong each color should glow. So instead of using a darker red color, you may use [.5 1 1] to have red glow half as strong.
$EmissiveBlendScrollVector 	" [ 0 0 ] " 		// makes the EmmissiveBlend flow in either direction if a proper EmissiveBlendFlowTexture were set. But ours is static, so leave at 0 0

Flowing

This is an example of a flowing $emissiveblend texture. It will appear like as if water is flowing across a model.

$EmissiveBlendEnabled 		1						// Enable EmissiveBlend. Like $selfillum 1	
$EmissiveBlendStrength 		1 						// how strong the entire glow effect is.
$EmissiveBlendTexture 		Glow_texture_color		// this is the glowing texture.vtf
$EmissiveBlendBaseTexture 	Glow_texture_mask		// This is the glowing texture's mask, like $selfillummask.  SHOULD BE VTF i8 FORMAT, NOT DXT5!!!
$EmissiveBlendFlowTexture 	Glow_texture_mask_flow	// EmmisiveBlend can "flow" or move. This here is the flowmap used, just like water.
$EmissiveBlendTint 			" [ 1 1 1 ] "			// RGB glow intensity. Leave at 1 1 1. This can be used to change how strong each color should glow. So instead of using a darker red color, you may use [.5 1 1] to have red glow half as strong.
$EmissiveBlendScrollVector 	" [ 0 0 ] " 			// makes the EmmissiveBlend flow in either direction if a proper EmissiveBlendFlowTexture were set. But ours is static, so leave at 0 0

The only known material using this shader parameter, found in Half-Life 2: Episode Two Half-Life 2: Episode Two, materials/models/vortigaunt/vortigaunt_blue.vmt

"VertexLitGeneric"
{
	"$surfaceprop" "default"
	"$basetexture" "Models/vortigaunt/vortigaunt_base"
	"$bumpmap" "Models/vortigaunt/vortigaunt_normal"
	"$phong" "1"
	"$phongboost" "10"
	"$phongexponenttexture" "Models/vortigaunt/vortigaunt_exponent"
	"$phongalbedotint" "1"
	"$phongfresnelranges" "[.18 .4 1]"
	"$halflambert" "1"
	"$nodecal" "1"

	// Rim lighting parameters
	"$rimlight" "1"												// To enable rim lighting (requires phong)
	"$rimlightexponent" "10"										// Exponent for phong component of rim lighting	
	"$rimlightboost" "3"										// Boost for ambient cube component of rim lighting


	// Blend between color textures
	"$detail" "Models/Vortigaunt/vortigaunt_blue"
	"$detailblendmode" "3"
	"$detailblendfactor" "0.0"
	"$detailScale" "1.0"

	// Emissive Scroll Pass
	"$emissiveBlendEnabled"     "1" // Enables effect
	"$emissiveBlendTexture"     "models/vortigaunt/vortigaunt_illum"
	"$emissiveBlendBaseTexture" "Models/Vortigaunt/vortigaunt_blue"
	"$emissiveBlendFlowTexture" "models/vortigaunt/vortigaunt_flow"
	"$emissiveBlendTint"        "[1 1 1]"
	"$emissiveBlendScrollVector" "[0.11 0.124]"
	"$time" "0"
	"Proxies"
	{
		"VortEmissive"
		{
		}
		"MaterialModify"
		{
		}
		"CurrentTime"
		{
			"resultVar" "$time"
		}
	}
}

See Also