diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /materialsystem/stdshaders/particlesphere.psh | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'materialsystem/stdshaders/particlesphere.psh')
| -rw-r--r-- | materialsystem/stdshaders/particlesphere.psh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/materialsystem/stdshaders/particlesphere.psh b/materialsystem/stdshaders/particlesphere.psh new file mode 100644 index 0000000..aecbeca --- /dev/null +++ b/materialsystem/stdshaders/particlesphere.psh @@ -0,0 +1,39 @@ +ps.1.1 + +;------------------------------------------------------------------------------ +; Sphere-lit particle pixel shader. +; +; The ParticleSphere lighting equation is: +; A + [[N dot |L - P|] * 0.5 + 0.5] * C * r / ||L - P|| +; +; where: +; A = ambient light color +; N = particle normal (stored in the texture) +; L = light position +; P = point on surface +; C = directional light color +; r = directional light intensity +; +; This shader takes as input: +; t0 = Normal map texture coordinates (N) +; t1 = Light vector Normalize(L - P) * 0.5 in range [0,1] +; v0 = Directional color (C * r / ||L - P||^2) * 0.5 +; t2 = Ambient light color (A) +; c0 = 0.5 +; +; and outputs [v1 + (sample(t0) dot t1) * 0.5f + 0.5f] +;------------------------------------------------------------------------------ + +tex t0 ; Get the 3-vector from the normal map +texcoord t1 ; Interpret tcoord t1 as color data. +texcoord t2 ; Ambient light color + +dp3 r1, t0_bx2, t1_bx2 ; r0 = sample(t0) dot t1 +add r0, r1, c0 ; + 0.5 + +mul r1, v0, r0 ; scale the dot product by the dirlight's actual color +add r0.rgb, r1, t2 ; add the ambient color in v1 + +mul r0.a, t0, v0 ; Alpha = normal map alpha * vertex alpha + + |