Custom Shader Guide

jRocketjRocket Pixel PunisherPVKII Team
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"
	}
}



Using basetexture tinting requires the addition of some proxies to your texture file as follows (It is best to setup this way as the model will then default to the basetintcolor_base if the mapper does not specify a color to use in the map):

"$basetintcolor_choice" "[0 0 0]"
"$basetintcolor_base" "[0.80 0.05 0.05]"

"Proxies"
{
	"GetTintColor"
	{
		"resultVar" "$basetintcolor_choice"
	}

	"SelectFirstIfNonZero"
	{
		"srcVar1" "$basetintcolor_choice"
		"srcVar2" "$basetintcolor_base"
		"resultVar" "$color2"
	}
}

Comments

  • SpirrwellSpirrwell That Guy That Knows Things About a Lot of Things PVKII Team, Authorized Creator
    edited 2:46AM
    About the $bloodframe and $bloodeffectstrength for controlling the frame number, how exactly does that work? I fiddled around with it for over a day trying to get an animated blood texture to change frames for El Negro, but I couldn't.
    5GY1DFV.png


    ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░██████░░░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░░░████░░█████░░░██
    ░░░░░░███░░░░░░░░░░░░░░████░░█████░░░███
    ░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░████░░█████░░░████
    ░░░░░░░░░░░░░░░░░░░█████████░░███████████░░████
    ░░░░░░░░░░░░███████████████████████████░░░░░░██
    ░░░░░░░░░██████████████████████████████░░░░░░██
    ░░░░░░░█████████████████████████████████░░░░░░██
    ░░░░░██████████████████████████████████░░░░░░███
    ░░░░░███████████████████████████████████░░░░░████
    ░░░░████████████████████████████████████░░░░░████░░
    ░░░░███████████████████████████████████░░░░█████░░░
    ░░░░█████░░░░░░░░████████████████████░░░░██████░░░░
    ░░░░░██░░░░░░░░░░████████████████████████████░░░░░░
    ░░░░░░░░░░░░░░░░░██████████████████████████░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░████████████████████░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░█████████████░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░██░░░░░░░███████░░░░░░█████████░░░░░░░░░
    ░░░░░░███░░░███████░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░███████████░░░░░░░░░░░░░░░░░███░░░░░░░░░░░░░
    ░░░████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░████░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░

    yP71cHI.gif

    Xxkr2il.jpg
    56JtqQq.jpg
    kJFRh1a.png
    MOBO: MSI Z87M GAMING
    CPU: Intel® Core™ i7-4770K OC'd @ 3.7 GHz
    GPU: EVGA GTX 660 Ti
    RAM: Ripjaws X 8GB (2 x 4GB) DDR3 2133MHz
    OS: Windows 10 Technical Preview

  • CrazytalkCrazytalk Terminator PVKII Team
    edited 2:46AM
    IIRC the blood frame is for having different blood placements based on attack direction. For example, frame 0 could have blood mostly around the tip of the blade for stabbing attacks, whereas frame 1 would have blood along the edge. You then assign frame 0 to the stab attack direction, and frame 1 to the slash attack direction.

    badass.jpg

  • SpirrwellSpirrwell That Guy That Knows Things About a Lot of Things PVKII Team, Authorized Creator
    edited 2:46AM
    Well yeah, that's what I thought. I tried changing the attack_down to 1, which would correspond to frame 1 on an animated texture but it showed no change. Where does $bloodframe itself come into play?
    5GY1DFV.png


    ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░██████░░░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░░░████░░█████░░░██
    ░░░░░░███░░░░░░░░░░░░░░████░░█████░░░███
    ░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░████░░█████░░░████
    ░░░░░░░░░░░░░░░░░░░█████████░░███████████░░████
    ░░░░░░░░░░░░███████████████████████████░░░░░░██
    ░░░░░░░░░██████████████████████████████░░░░░░██
    ░░░░░░░█████████████████████████████████░░░░░░██
    ░░░░░██████████████████████████████████░░░░░░███
    ░░░░░███████████████████████████████████░░░░░████
    ░░░░████████████████████████████████████░░░░░████░░
    ░░░░███████████████████████████████████░░░░█████░░░
    ░░░░█████░░░░░░░░████████████████████░░░░██████░░░░
    ░░░░░██░░░░░░░░░░████████████████████████████░░░░░░
    ░░░░░░░░░░░░░░░░░██████████████████████████░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░████████████████████░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░█████████████░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░░░░██░░░░░░░███████░░░░░░█████████░░░░░░░░░
    ░░░░░░███░░░███████░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░░░███████████░░░░░░░░░░░░░░░░░███░░░░░░░░░░░░░
    ░░░████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    ░░████░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░

    yP71cHI.gif

    Xxkr2il.jpg
    56JtqQq.jpg
    kJFRh1a.png
    MOBO: MSI Z87M GAMING
    CPU: Intel® Core™ i7-4770K OC'd @ 3.7 GHz
    GPU: EVGA GTX 660 Ti
    RAM: Ripjaws X 8GB (2 x 4GB) DDR3 2133MHz
    OS: Windows 10 Technical Preview

Sign In or Register to comment.