Core (shader): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (envmaps will are force drawn)
(Changed to use Shader and MatParam templates)
Line 1: Line 1:
[[Image:Citadel_core_shader.jpg|thumb|right|200px|The Citadel Core, which uses this shader.]]
[[Image:Citadel_core_shader.jpg|thumb|right|200px|The Citadel Core, which uses this shader.]]
'''<code>Core</code>''' is a [[material]] [[shader]] introduced in [[Episode One]]. It is used to create a unstable, reflecting and refracting core of energy, used exclusively for the Core reactor in the Citadel in Episode One.
{{shader|Core|since=Half-Life 2: Episode One}} It is used to create a unstable, reflecting and refracting core of energy, used exclusively for the Core reactor in the Citadel in Episode One.
{{note|In order for this shader to work properly, it must be used with a <code>prop_coreball</code> at the position of (2688,12139,5170). This value is hardcoded into the shader.}}
{{note|In order for this shader to work properly, it must be used with a <code>prop_coreball</code> at the position of (2688,12139,5170). This value is hardcoded into the shader.}}
{{note|This shader does not exist in engine branches after the [[Orange Box]].}}
{{note|This shader does not exist in engine branches after the [[Orange Box]].}}


==Shader Parameters==
==Shader Parameters==
; <code>$corecolortexture <[[texture]]></code>
{{MatParam|$corecolortexture|texture|The texture to use for the colors that get dynamically modified by the shader. The alpha channel of the <code>$corecolortexture</code> determines the translucency of the core.}}
: The texture to use for the colors that get dynamically modified by the shader. The alpha channel of the <code>$corecolortexture</code> determines the translucency of the core.
{{MatParam|$corecolortextureframe|texture|The frame to start an animated <code>$corecolortexture</code> on.}}
; <code>$corecolortextureframe <texture></code>
{{MatParam|$normalmap|texture}}
: The frame to start an animated <code>$corecolortexture</code> on.
{{MatParam|$dudvmap|texture|The pattern of refraction is defined by a normal map (DX9+) or DUDV map (DX8-). May be animated.|dx8=1}}
; <code>$normalmap <texture></code>
{{MatParam|$bumpframe|int|The frame to start an animated bumpmap on. {{Todo|This may not work with the proxy required for the effect.}}}}
; <code>$dudvmap <texture></code> {{dx8}}
{{MatParam|$bumptransform|matrix|Transforms the bump map texture.
: The pattern of refraction is defined by a normal map (DX9+) or DUDV map (DX8-). May be animated.
{{VMT UVtransform}}}}
; <code>$bumpframe <[[int]]></code>
{{MatParam|[[$envmap]]|texture|Adds a cubemap reflection on top of the refraction.
: The frame to start an animated bumpmap on. {{Todo|This may not work with the proxy required for the effect.}}
: {{note|Specular reflections for this shader will be drawn even if <code>mat_specular</code> is set to 0.}}}}
; <code>$bumptransform <[[matrix]]></code>
{{MatParam|$envmapframe|int|The frame to start an animated cubemap on.}}
: Transforms the bump map texture.
{{MatParam|$envmaptint|RGB matrix|Controls the intensity of the reflection's [[RGB|red, green and blue]] color channels. Any positive number can be used. Default is <code>"[1 1 1]"</code>, which means 100% intensity. {{note|You ''must'' use quotemarks, as there are space characters within the value.}}}}
{{VMT UVtransform}}
{{MatParam|$envmapcontrast|normal|Controls the [[Wikipedia:Contrast (vision)|contrast]] of the reflection. 0 is natural contrast, while 1 is the full squaring of the color (i.e. color*color).}}
; <code>[[$envmap]] <texture></code>
{{MatParam|$envmapsaturation|normal|Controls the colour saturation of the reflection. 0 is greyscale, while 1 is natural saturation.}}
: Adds a cubemap reflection on top of the refraction.
{{MatParam|$refractamount|float|Controls the strength of the refraction by multiplying the normal map intensity.}}
: {{note|Specular reflections will be drawn even if <code>mat_specular</code> is set to 0}}
{{MatParam|$refracttint|RGB matrix|Tints the color of the refraction.}}
; <code>$envmapframe <int></code>
{{MatParam|[[Flowmap|$flowmap]]|texture|Flowmap to scroll the normal map, which affects the refraction.}}
: The frame to start an animated cubemap on.
{{MatParam|$flowmapframe|int|The frame to start an animated flowmap on.}}
; <code>$envmaptint <[[RGB]] matrix></code>
{{MatParam|$flowmapscrollrate|vector2|The rate at which the normal map scrolls along the flowmap.}}
: Controls the intensity of the reflection's [[RGB|red, green and blue]] color channels. Any positive number can be used. Default is <code>"[1 1 1]"</code>, which means 100% intensity. {{note|You ''must'' use quotemarks, as there are space characters within the value.}}
{{MatParam|$flowmaptexcoordoffset|float|{{Todo|Texture offset for the flowmap? Modified by proxies, as seen below.}}}}
; <code>$envmapcontrast <[[normal]]></code>
: Controls the [[Wikipedia:Contrast (vision)|contrast]] of the reflection. 0 is natural contrast, while 1 is the full squaring of the color (i.e. color*color).
; <code>$envmapsaturation <normal></code>
: Controls the colour saturation of the reflection. 0 is greyscale, while 1 is natural saturation.
; <code>$refractamount <[[float]]></code>
: Controls the strength of the refraction by multiplying the normal map intensity.
; <code>$refracttint <RGB matrix></code>
: Tints the color of the refraction.
; <code>[[Flowmap|$flowmap]] <texture></code>
: Flowmap to scroll the normal map, which affects the refraction.
; <code>$flowmapframe <int></code>
: The frame to start an animated flowmap on.
; <code>$flowmapscrollrate <vector2></code>
: The rate at which the normal map scrolls along the flowmap.
; <code>$flowmaptexcoordoffset <float></code>
: {{Todo|Texture offset for the flowmap? Modified by proxies, as seen below.}}


==Example==
==Example==
Line 95: Line 79:
  }
  }
  }
  }
[[Category:Shaders|C]]

Revision as of 15:33, 6 June 2019

The Citadel Core, which uses this shader.

Shader-ball.png Core It is used to create a unstable, reflecting and refracting core of energy, used exclusively for the Core reactor in the Citadel in Episode One.

Note.pngNote:In order for this shader to work properly, it must be used with a prop_coreball at the position of (2688,12139,5170). This value is hardcoded into the shader.
Note.pngNote:This shader does not exist in engine branches after the Orange Box.

Shader Parameters

$corecolortexture $corecolortextureframe $normalmap $dudvmap $bumpframe $bumptransform [[$envmap|$envmap]] $envmapframe $envmaptint $envmapcontrast $envmapsaturation $refractamount $refracttint [[$flowmap|$flowmap]] $flowmapframe $flowmapscrollrate $flowmaptexcoordoffset

Example

The Core material used in Episode One, materials/models/props_combine/core_sheet.vmt

"Core"
{
	"$normalmap" "Models/props_combine/core_normal"
	"$dudvmap"  "Models/props_combine/core_dudv"

	"$corecolortexture" "models/props_combine/corewarpcolor"
	"$flowmap" "models/props_combine/core_flow"

	"$model" 1
	"$REFRACTAmOUNT" "0.15"
	"$FLOWMAPSCROLLRATE" "[.0475 .133]"
//	"$envmap" "CustomCubeMaps/core"
	"$envmap" "env_cubemap"
	"$refracttint" "[0.7 0.7 0.6]"
	"$envmaptint" "[0.8 0.6 0.6]"
	"$FLOWMAPTEXCOORDOFFSET" "1.0"
	"$TempMin" 0
	"$TempMax" 1

	
	"core_dx70"
	{
		"$fallbackmaterial" "models/props_combine/coredx70"
	}

	"core_dx80"
	{
		"$normalmap" "dev/water_normal"
		"$dudvmap"  "dev/water_dudv"
		"$bumptransform" "center .5 .5 scale 5 5 rotate 0 translate 0 0"
		"$envmapcontrast" "1.0"
	}

	"Proxies"
	{

		"Sine"
		{
			"resultVar" "$FLOWMAPTEXCOORDOFFSET"
			"sineperiod" 4
			"sinemin" "$TempMin"
			"sinemax" "$TempMax"
		}
		"AnimatedTexture"
		{
			"animatedtexturevar" "$normalmap" 
			"animatedtextureframenumvar" "$bumpframe"
			"animatedtextureframerate" 29.00
		}
	}
}