Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
82 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:


The improvement of RacorX13 over RacorX12 is the use of a ps.1.4 pixel shader. With this pixel shader version you can reduce the number of passes to one. This example uses a vertex shader that combines all the functionality used in the two vertex shaders in RacorX12 and a pixel shader that combines all the functionality used in the two pixel shaders in RacorX12.

; t0 - coordinates color map
; t1 - light vector
; t2 - half vector
; t3 - unused
; t4 - coordinates 2D attenuation map
; t5 - coordinates 1D attenuation map
texld r1, t1 ; cube map
texld r0, t0 ; normal map
texcrd r3.rgb, t2 ; half angle vector

dp3 r1.rgb, r1_bx2, r0_bx2 ; diffuse
dp3 r4.rgb, r3, r0_bx2 ; specular


texld r2, t0 ; color map
texld r3, r4 ; samples specular value from specular map
texld r4, t4 ; attenuation 2D map
texld r5, t5 ; attenuation 1D map 
add r5, 1-r4, -r5.a ; (1.0 - 2Dvalue) - dest

mul r1.a, r2.a, r3.a ; (N dot H)^16 * gloss value
+mul r1.rgb, r1, r2 ; diffuse * color
add r0, r1.a, r1 ; ((N dot H)^16 * gloss value) + (diffuse * color)
mul r0, r0, r5 ; attenuation

This shader eats up all six texture stages provided by the ps.1.4 shader specification:

  • Normal map
  • Cube normalization map
  • Color map
  • Illumination Map
  • Point light texture
  • Point light texture

Because of the independance of the texture coordinate data from the texture data in ps.1.4, this pixel shader only uses five texture coordinate registers in the vertex shader. So the texture coordinate register oT3 and the color registers v0 and v1 are still available.



  Printable version
  Discuss this article

The Series
  Fundamentals of Vertex Shaders
  Programming Vertex Shaders
  Fundamentals of Pixel Shaders
  Programming Pixel Shaders
  Diffuse & Specular Lighting with Pixel Shaders