pixel_shader.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <html>
  2. <head>
  3. <title>Bitmap Font Generator - Documentation</title>
  4. </head>
  5. <body>
  6. <h1>Bitmap Font Generator - Documentation</h1>
  7. <p><a href="../documentation.html">Back to main page</a></p>
  8. <h2>Pixel shader example</h2>
  9. <p>This pixel shader shows how to decode the color from a font texture with characters packed
  10. into all 4 channels, and each channel using special encoding to store the character with the
  11. outline. The texture is also allowed to store full 32bit images for some characters.</p>
  12. <pre>
  13. // DirectX 9 pixel shader
  14. float4 PixScene( float4 color : COLOR0,
  15. int4 chnl : TEXCOORD1,
  16. float2 tex0 : TEXCOORD0 ) : COLOR0
  17. {
  18. float4 pixel = tex2D(g_samScene, tex0);
  19. if( dot(vector(1,1,1,1), chnl) )
  20. {
  21. float val = dot(pixel, chnl);
  22. pixel.rgb = val > 0.5 ? 2*val-1 : 0;
  23. pixel.a = val > 0.5 ? 1 : 2*val;
  24. }
  25. return pixel * color;
  26. }
  27. </pre>
  28. <p>The chnl texture coordinate is a 4D vector that shows which channel the character should be read
  29. from. If this is (0,0,0,0) the character is interpreted as a 32 bit image. The texture coordinate
  30. can be stored in a UBYTE4 type, so it doesn't require much bandwidth when being sent to the video card.</p>
  31. </body>
  32. </html>