Shaders

From PVKII Wiki
Revision as of 09:56, 4 August 2023 by Crazytalk (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The following is some documentation on the custom shaders and material parameters available in PVKII

VertexLitBeckman (Fallback: PVK2_VertexLitGeneric, any parameters for it are available to this as well)

Improved specularity model using Cook and Torrance model with a Beckman distribution. Is far superior at rendering metals and plastics compared to phong, works well in general as well. This only is supported on ps20b and higher hardware. (Will be adding some additional shading models in this that will be managed by a texture channel lookup. I've freed quite a few texture registers. Minnaert for more realistic cloth diffuse lighting in particular)

  • $cooklighting - Turns on the cook/torrance specular calculations. Is kinda redundant so will be phased out some point. If you didn't want this than might as well be using the PVK2_VertexLitGeneric with $phong 0
  • $specroughness - Can be used to set a global roughness factor for the whole texture. Will override the RTNL lookup if not set to 0 which is helpful for quickly testing different values for authoring the RTNL
  • $RTNLtexture - Texture that contains a Roughness map in the red channel, a Albedo tint mask in the green channel, a Reflectance at normal incidence map in the blue channel, and a lightwarp mask in the alpha channel
  • $specboost - How much to boost or weaken the overall specular term
  • $specfresnelranges - Fresnel ranges for the specular term
  • $specalbedotint - Enables/Disables the specular being tinted by the base texture. Uses the green channel of the RTNLTexture as a mask
  • $spectint - Color to tint the specular term

PVK2_VertexLitGeneric (Fallback: VertexLitGeneric_DX8)

Uses the normal phong specularity calculations, but supports the albedo tinting effects for ps20, ps20b, and higher

  • $basetintmask - Defines a mask texture which is used for tinting the base texture. Red channel is the only channel used in this texture currently. White means fully tint that pixel, black means apply no tinting and inbetween values will interpolate between fully tinting it and using the default pixel color of the base texture map.
  • $subsurfaceenabled - Enables the cheap translucency approximation diffuse lighting code to be run
  • $subsurfacepower - The power applied to the subsurface term. A higher power tightens the subsurface term and a lower power makes it more diffuse and spread out.
  • $subsurfacedistortion - This is similar to a rim lighting effect except for the subsurface lighting term
  • $subsurfaceambient - Ambient translucency light level of the object regardless of the direction to the light for that pixel.
  • $subsurfacethicknesstexture - A texture map where white means the object is thinner in that area and black means the object is thicker in that area. The easiest way to author is to take your model, flip the normals, and then render an Ambient occlusion bake. I've used XNormal to do this as well as I am not familiar with the process in 3d modelling packages.

Weapon Blood Pass (For use in either of our shaders. Easily setup to fallback to the detail texture method as the same texture is used with an alpha map added, I need to setup the new proxy to handle this though. Currently the old proxy exists for supporting weapons until they get their blood textures updated. You can use debug_blood_pass_shader 1 to force the effect to be on always for testing)

  • $BloodPassEnabled - Enables the blood pass. Only actually renders the pass if the effect strength is greater than 0.
  • $BloodBaseTexture - Diffuse map for the blood. Alpha channel is the effect mask.
  • $BloodNormalTexture - Normal map for the blood. Alpha is specular mask if needed for both envmap and the cook/torrance specular.
  • $BloodCubeTexture - Cubemap texture to use for envmap specular
  • $BloodLightwarpTexture - Disabled because currently broken
  • $BloodEnvMapBoost - How strong or weak to boost the envmap effect
  • $BloodSpecRoughness - Roughness scalar for the blood specular
  • $BloodSpecReflectAtNormal - Reflectance at normal incidence scalar for the blood specular
  • $BloodSpecTint - Tint color for both the envmap and the cook/torrance specular
  • $BloodSpecBoost - How strong or weak to boost the cook/torrance specular
  • $BloodSpecFresnelRanges - Specular fresnel ranges for the cook/torrance specular
  • $BloodRimLight - Whether to apply standard valve rim lighting or not
  • $BloodRimLightPower - Essentially the exponent similar to phong of the rim lighting
  • $BloodRimLightBoost - How strong or weak to make the rim lighting term

Using the blood pass also requires to update the material's proxy to use the new proxy, It manages the internal $BloodEffectStrength and the $BloodFrame variable which controls the frame for the base texture and the the normal map:

"Proxies" { "BloodPassHelper" { "attack_up" "0" "attack_down" "0" "attack_left" "0" "attack_right" "0" "attack_special" "0" "attack_bash" "0" } }