Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2 KiB

  1. //========= Copyright � 1996-2008, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Parallax Occlusion Mapping test shader
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #include "BaseVSShader.h"
  9. #include "convar.h"
  10. #include "parallaxtest_vs30.inc"
  11. #include "parallaxtest_ps30.inc"
  12. ConVar mat_parallaxmapsamplesmin( "mat_parallaxmapsamplesmin", "12" );
  13. ConVar mat_parallaxmapsamplesmax( "mat_parallaxmapsamplesmax", "50" );
  14. BEGIN_VS_SHADER( ParallaxTest,
  15. "Help for ParallaxTest" )
  16. BEGIN_SHADER_PARAMS
  17. SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "bump map" )
  18. SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" )
  19. END_SHADER_PARAMS
  20. SHADER_FALLBACK
  21. {
  22. return 0;
  23. }
  24. // Set up anything that is necessary to make decisions in SHADER_FALLBACK.
  25. SHADER_INIT_PARAMS()
  26. {
  27. }
  28. SHADER_INIT
  29. {
  30. LoadTexture( BASETEXTURE );
  31. LoadTexture( BUMPMAP );
  32. }
  33. SHADER_DRAW
  34. {
  35. SHADOW_STATE
  36. {
  37. unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_TANGENT_S | VERTEX_TANGENT_T;
  38. int numTexCoords = 1;
  39. pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 );
  40. // base
  41. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  42. // normal + height
  43. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  44. DECLARE_STATIC_VERTEX_SHADER( parallaxtest_vs30 );
  45. SET_STATIC_VERTEX_SHADER( parallaxtest_vs30 );
  46. DECLARE_STATIC_PIXEL_SHADER( parallaxtest_ps30 );
  47. SET_STATIC_PIXEL_SHADER( parallaxtest_ps30 );
  48. }
  49. DYNAMIC_STATE
  50. {
  51. // base texture
  52. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, FRAME );
  53. // normal + height
  54. BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, BUMPMAP, BUMPFRAME );
  55. DECLARE_DYNAMIC_VERTEX_SHADER( parallaxtest_vs30 );
  56. SET_DYNAMIC_VERTEX_SHADER( parallaxtest_vs30 );
  57. DECLARE_DYNAMIC_PIXEL_SHADER( parallaxtest_ps30 );
  58. SET_DYNAMIC_PIXEL_SHADER( parallaxtest_ps30 );
  59. Vector4D c0( mat_parallaxmapsamplesmin.GetFloat(), mat_parallaxmapsamplesmax.GetFloat(), 0.0f, 0.0f );
  60. pShaderAPI->SetPixelShaderConstant( 0, c0.Base(), 1 );
  61. }
  62. Draw();
  63. }
  64. END_SHADER