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.

78 lines
2.8 KiB

  1. //========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "worldvertextransition_dx8_helper.h"
  8. #include "BaseVSShader.h"
  9. #include "WorldVertexTransition.inc"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. void InitParamsWorldVertexTransitionEditor_DX8( IMaterialVar** params, WorldVertexTransitionEditor_DX8_Vars_t &info )
  13. {
  14. SET_FLAGS2( MATERIAL_VAR2_LIGHTING_LIGHTMAP );
  15. }
  16. void InitWorldVertexTransitionEditor_DX8( CBaseVSShader *pShader, IMaterialVar** params, WorldVertexTransitionEditor_DX8_Vars_t &info )
  17. {
  18. if ( params[info.m_nBaseTextureVar]->IsDefined() )
  19. {
  20. pShader->LoadTexture( info.m_nBaseTextureVar );
  21. }
  22. if ( params[info.m_nBaseTexture2Var]->IsDefined() )
  23. {
  24. pShader->LoadTexture( info.m_nBaseTexture2Var );
  25. }
  26. }
  27. void DrawWorldVertexTransitionEditor_DX8( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, WorldVertexTransitionEditor_DX8_Vars_t &info )
  28. {
  29. SHADOW_STATE
  30. {
  31. // This is the dx8 worldcraft version (non-bumped always.. too bad)
  32. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  33. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  34. pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
  35. int fmt = VERTEX_POSITION | VERTEX_COLOR;
  36. pShaderShadow->VertexShaderVertexFormat( fmt, 2, 0, 0 );
  37. worldvertextransition_Static_Index vshIndex;
  38. pShaderShadow->SetVertexShader( "WorldVertexTransition", vshIndex.GetIndex() );
  39. pShaderShadow->SetPixelShader( "WorldVertexTransition_Editor" );
  40. pShader->FogToFogColor();
  41. }
  42. DYNAMIC_STATE
  43. {
  44. pShader->BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, info.m_nBaseTextureVar, info.m_nBaseTextureFrameVar );
  45. pShader->BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, info.m_nBaseTexture2Var, info.m_nBaseTexture2FrameVar );
  46. // Texture 3 = lightmap
  47. pShaderAPI->BindStandardTexture( SHADER_SAMPLER2, TEXTURE_BINDFLAGS_NONE, TEXTURE_LIGHTMAP );
  48. pShader->EnablePixelShaderOverbright( 0, true, true );
  49. // JasonM - Gnarly hack since we're calling this legacy shader from DX9
  50. int nTextureTransformConst = VERTEX_SHADER_SHADER_SPECIFIC_CONST_0;
  51. int nTextureTransformConst2 = VERTEX_SHADER_SHADER_SPECIFIC_CONST_2;
  52. nTextureTransformConst -= 10;
  53. nTextureTransformConst2 -= 10;
  54. pShader->SetVertexShaderTextureTransform( nTextureTransformConst, info.m_nBaseTextureTransformVar );
  55. pShader->SetVertexShaderTextureTransform( nTextureTransformConst2, info.m_nBaseTexture2TransformVar );
  56. worldvertextransition_Dynamic_Index vshIndex;
  57. vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
  58. pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() );
  59. }
  60. pShader->Draw();
  61. }