PaintBlob: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (bug description)
 
(17 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{lang}} [[Category:Shaders]]
[[File:Paintblob ice.png|thumb|An ice surface using the PaintBlob shader]]
[[File:Paintblob ice.png|thumb|An ice surface using the PaintBlob shader]]
{{stub}}
{{stub}}
{{shader|PaintBlob|game=Counter-Strike: Global Offensive}} Despite the odd name, its purpose is to create realistic hollow ice surfaces by piercing light through it using normal mapping, and calculating light reflection from its inner layer(backface) onto the outer layer (front face). The final output color of the surface is computed by combining various lighting terms. Also supports fresnel translucency when viewing the surface through itself, creating the illusion of a hollow ice material. Furthermore, a bounding box min and max value can be set to define how "hollow" or "thick" the material surface should be.
{{this is a|pixel shader|name=PaintBlob|game=Counter-Strike: Global Offensive}} Despite the odd name, its purpose is to create realistic hollow ice surfaces by piercing light through it using normal mapping, and calculating light reflection from its inner layer(backface) onto the outer layer (front face). The final output color of the surface is computed by combining various lighting terms. Also supports fresnel translucency when viewing the surface through itself, creating the illusion of a hollow ice material. Furthermore, a bounding box min and max value can be set to define how "hollow" or "thick" the material surface should be.
{{Note|{{ent|$nocull}} is not needed for this shader to function properly, however, can be used to visualize the $interior effects on the backface.}}
{{Note|{{ent|$nocull}} is not needed for this shader to function properly, however, can be used to visualize the $interior effects on the backface.}}


Line 17: Line 16:
== Supported Parameters ==
== Supported Parameters ==
===Textures & Masks===
===Textures & Masks===
;{{ent|$basetexture}}
{{MatParamDef|$basetexture|texture|text=Diffuse texture.}}
: Diffuse texture.
{{MatParamDef|$normalmap|texture|text=Normal map.}}
;{{ent|$normalmap}}
{{MatParamDef|$envmap|string|text=Specular reflection.}}
: Normal map.
{{MatParamDef|$lightwarptexture|texture|text=1D ramp texture for tinting scalar diffuse term.}}
;{{ent|$envmap}}
{{MatParamDef|$backsurface|bool|text=Specify that this is the back surface of the ice.{{bug|Results in a pixel shader crash if true.}}}}
: Specular reflection.
{{MatParamDef|$specmasktexture|texture|text=Mask texture for specular reflection.}}
;{{ent|$lightwarptexture}}
{{MatParamDef|$fresnelwarptexture|texture|text=1D ramp texture for controlling fresnel falloff}}
: 1D ramp texture for tinting scalar diffuse term.
{{MatParamDef|$opacitytexture|texture|text=Typically, a grayscale texture that defines the opaque and translucent parts of the texture. {{tip|Extremely useful in creating realistic scratches on an ice surface.}}}}
 
 
; {{MatParam|$backsurface|bool}}
: Specify that this is the back surface of the ice.{{bug|Results in a pixel shader crash if true.}}
 
; {{MatParam|$specmasktexture|texture}}
: Mask texture for specular reflection.
; {{MatParam|$fresnelwarptexture|texture}}
: 1D ramp texture for controlling fresnel falloff
; {{MatParam|$opacitytexture|texture}}
: Typically, a grayscale texture that defines the opaque and translucent parts of the texture. {{tip|Extremely useful in creating realistic scratches on an ice surface.}}


== Outer Layer Parameters ==
== Outer Layer Parameters ==
; {{MatParam|$diffusescale|float}}
{{MatParamDef|$diffusescale|float|text=Scales the output color. {{tip|Can be used to brighten the textures.}}}}
: Scales the output color. {{tip|Can be used to brighten the textures.}}
{{MatParamDef|$phongexponent|and=$phonexponent2|float|text=Specular exponent values.}}
; {{MatParam|$phongexponent|and=$phonexponent2|float}}
{{MatParamDef|$phongboost|and=$phongboost2|float|text=Specular boost values.}}
: Specular exponent values.
{{MatParamDef|$rimlightexponent|float|text=Rim light exponent.}}
; {{MatParam|$phongboost|and=$phongboost2|float}}
{{MatParamDef|$rimlightboost|float|text=Rim light boost.}}
: Specular boost values.
{{MatParamDef|$basecolortint|vector3|text=Base texture tint. {{todo|Figure out why this doesn't work.}}}}
; {{MatParam|$rimlightexponent|float}}
: Rim light exponent.
; {{MatParam|$rimlightboost|float}}
: Rim light boost.
; {{MatParam|$basecolortint|vector3}}
: Base texture tint. {{todo|Figure out why this doesn't work.}}


== Interior Volume Parameters ==
== Interior Volume Parameters ==
; {{MatParam|$interior|bool}}
{{MatParamDef|$interior|bool|text=Enable interior layer.}}
: Enable interior layer.
{{MatParamDef|$interiorfogstrength|float|text=Fog strength (scales with thickness of the interior volume).}}
; {{MatParam|$interiorfogstrength|float}}
{{MatParamDef|$interiorbackgroundboost|float|text=Boosts the brightness of bright background pixels.}}
: Fog strength (scales with thickness of the interior volume).
{{MatParamDef|$interiorambientscale|float|text=Scales the ambient light in the interior volume.}}
; {{MatParam|$interiorbackgroundboost|float}}
{{MatParamDef|$interiorbacklightscale|float|text=Scales backlighting in the interior volume.}}
: Boosts the brightness of bright background pixels.
{{MatParamDef|$interiorrefractstrength|float|text=Strength of bumped refract of the background seen through the interior.}}
; {{MatParam|$interiorambientscale|float}}
: Scales the ambient light in the interior volume.
; {{MatParam|$interiorbacklightscale|float}}
: Scales backlighting in the interior volume.
; {{MatParam|$interiorrefractstrength|float}}
: Strength of bumped refract of the background seen through the interior.


== Additional Parameters ==
== Additional Parameters ==
; {{MatParam|$uvscale|float}}
{{MatParamDef|$uvscale|float|text=UV projection scale. Default: 0.02.}}
: UV projection scale. Default: 0.02.
{{MatParamDef|$bumpstrength|float|text=Bump map strength.}}
; {{MatParam|$bumpstrength|float}}
{{MatParamDef|$fresnelbumpstrength|float|text=Bump map strength for the fresnel term.}}
: Bump map strength.
{{MatParamDef|$translucentfresnelminmaxexp|vector3|text=Fresnel range parameters for the opacity texture.}}
; {{MatParam|$fresnelbumpstrength|float}}
{{MatParamDef|$uvprojoffset|vector3|text=Center for UV projection.}}
: Bump map strength for the fresnel term.
{{MatParamDef|$bbmin|and=$bbmax|vector3|text={{todo|Functional?}}}}
; {{MatParam|$translucentfresnelminmaxexp|vector3}}
{{MatParamDef|$contactshadows|bool|text=Darkens the shading of the ice region in areas where it is in contact with a surface.}}
: Fresnel range parameters for the opacity texture.
{{MatParamDef|$bumpframe|integer|text=Bump frame.}}
; {{MatParam|$uvprojoffset|vector3}}
{{MatParamDef|$alphatest|bool|text={{tip|Has no effect on the alpha, but effects shadow casting}}}}
: Center for UV projection.
{{MatParamDef|$translucent|bool|text={{tip|Has no effect on the alpha, but effects shadow casting}}}}
; {{MatParam|$bbmin|and=$bbmax|vector3}}
{{MatParamDef|$surfaceprop|string}}
: {{todo|Functional?}}
{{MatParamDef|$nocull|bool}}
; {{MatParam|$contactshadows|bool}}
 
: Darkens the shading of the ice region in areas where it is in contact with a surface.
[[Category:Shaders]]
;{{ent|$bumpframe}}
: Bump frame.
;{{ent|$alphatest}}
{{tip|Has no effect on the alpha, but effects shadow casting}}
;{{ent|$translucent}}
{{tip|Has no effect on the alpha, but effects shadow casting}}
;{{ent|$surfaceprop}}
;{{ent|$nocull}}

Latest revision as of 12:05, 23 August 2025

An ice surface using the PaintBlob shader

Stub

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

PaintBlob is a Pixel shader available in Counter-Strike: Global Offensive Counter-Strike: Global Offensive. Despite the odd name, its purpose is to create realistic hollow ice surfaces by piercing light through it using normal mapping, and calculating light reflection from its inner layer(backface) onto the outer layer (front face). The final output color of the surface is computed by combining various lighting terms. Also supports fresnel translucency when viewing the surface through itself, creating the illusion of a hollow ice material. Furthermore, a bounding box min and max value can be set to define how "hollow" or "thick" the material surface should be.

Note.pngNote:$nocull is not needed for this shader to function properly, however, can be used to visualize the $interior effects on the backface.
Todo: Report anomalies and bugs
Icon-Bug.pngBug:Non-functional in Source Filmmaker  [todo tested in ?]

Ice Interior Shading Algorithm

Sphere on the left has $interiorlayer 0. Sphere on the right has $interiorlayer 1

The code implements an ice interior shading algorithm to simulate the appearance of ice as a translucent material. The algorithm takes inputs such as the world normal, eye direction, and screen position and uses them to create the illusion of light passing through the surface. The final result is a composite of the blurred enviroment map, the interior color and ambient lighting.

Todo: Add images displaying screen position based fresnel refraction, can't seem to get this to work anymore.

Supported Parameters

Textures & Masks

Diffuse texture.
Normal map.
Specular reflection.
1D ramp texture for tinting scalar diffuse term.
Specify that this is the back surface of the ice.
Icon-Bug.pngBug:Results in a pixel shader crash if true.  [todo tested in ?]
Mask texture for specular reflection.
1D ramp texture for controlling fresnel falloff
Typically, a grayscale texture that defines the opaque and translucent parts of the texture.
Tip.pngTip:Extremely useful in creating realistic scratches on an ice surface.

Outer Layer Parameters

Scales the output color.
Tip.pngTip:Can be used to brighten the textures.
Specular exponent values.
Specular boost values.
Rim light exponent.
Rim light boost.
Base texture tint.
Todo: Figure out why this doesn't work.

Interior Volume Parameters

Enable interior layer.
Fog strength (scales with thickness of the interior volume).
Boosts the brightness of bright background pixels.
Scales the ambient light in the interior volume.
Scales backlighting in the interior volume.
Strength of bumped refract of the background seen through the interior.

Additional Parameters

UV projection scale. Default: 0.02.
Bump map strength.
Bump map strength for the fresnel term.
Fresnel range parameters for the opacity texture.
Center for UV projection.
Todo: Functional?
Darkens the shading of the ice region in areas where it is in contact with a surface.
Bump frame.
Tip.pngTip:Has no effect on the alpha, but effects shadow casting
Tip.pngTip:Has no effect on the alpha, but effects shadow casting
Todo: This material shader parameter has not been described.
Todo: This material shader parameter has not been described.