1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2024-12-23 01:59:43 +08:00
hl2sdk/materialsystem/stdshaders/debugluxel.cpp

98 lines
2.5 KiB
C++
Raw Permalink Normal View History

2014-10-31 00:30:57 +08:00
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
2014-03-01 03:08:09 +08:00
//
// Purpose:
//
// $Header: $
// $NoKeywords: $
//===========================================================================//
2014-10-31 00:30:57 +08:00
#include "shaderlib/CShader.h"
2014-03-01 03:08:09 +08:00
2014-10-31 00:30:57 +08:00
#include "debugluxel_ps20b.inc"
#include "debugluxel_ps20.inc"
#include "debugluxel_vs20.inc"
2014-03-01 03:08:09 +08:00
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
BEGIN_SHADER_FLAGS( DebugLuxels, "Help for DebugLuxels", SHADER_NOT_EDITABLE )
BEGIN_SHADER_PARAMS
SHADER_PARAM( NOSCALE, SHADER_PARAM_TYPE_BOOL, "0", "fixme" )
END_SHADER_PARAMS
SHADER_INIT_PARAMS()
{
SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
SET_FLAGS2( MATERIAL_VAR2_LIGHTING_LIGHTMAP );
if( g_pHardwareConfig->GetDXSupportLevel() >= 90 )
{
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
}
2014-10-31 00:30:57 +08:00
}
2014-03-01 03:08:09 +08:00
2014-10-31 00:30:57 +08:00
SHADER_INIT
2014-03-01 03:08:09 +08:00
{
2014-10-31 00:30:57 +08:00
LoadTexture( BASETEXTURE );
}
2014-03-01 03:08:09 +08:00
2014-10-31 00:30:57 +08:00
SHADER_DRAW
{
SHADOW_STATE
2014-03-01 03:08:09 +08:00
{
2014-10-31 00:30:57 +08:00
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
2014-03-01 03:08:09 +08:00
2014-10-31 00:30:57 +08:00
DECLARE_STATIC_VERTEX_SHADER( debugluxel_vs20 );
SET_STATIC_VERTEX_SHADER( debugluxel_vs20 );
2014-03-01 03:08:09 +08:00
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
2014-10-31 00:30:57 +08:00
DECLARE_STATIC_PIXEL_SHADER( debugluxel_ps20b );
SET_STATIC_PIXEL_SHADER( debugluxel_ps20b );
2014-03-01 03:08:09 +08:00
}
else
{
2014-10-31 00:30:57 +08:00
DECLARE_STATIC_PIXEL_SHADER( debugluxel_ps20 );
SET_STATIC_PIXEL_SHADER( debugluxel_ps20 );
2014-03-01 03:08:09 +08:00
}
2014-10-31 00:30:57 +08:00
SetDefaultBlendingShadowState( BASETEXTURE );
DisableFog();
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 2, NULL, 0 );
2014-03-01 03:08:09 +08:00
}
2014-10-31 00:30:57 +08:00
DYNAMIC_STATE
2014-03-01 03:08:09 +08:00
{
2014-10-31 00:30:57 +08:00
BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
2014-03-01 03:08:09 +08:00
2014-10-31 00:30:57 +08:00
int texCoordScaleX = 1, texCoordScaleY = 1;
if (!params[NOSCALE]->GetIntValue())
{
pShaderAPI->GetLightmapDimensions( &texCoordScaleX, &texCoordScaleY );
}
DECLARE_DYNAMIC_VERTEX_SHADER( debugluxel_vs20 );
SET_DYNAMIC_VERTEX_SHADER( debugluxel_vs20 );
2014-03-01 03:08:09 +08:00
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
2014-10-31 00:30:57 +08:00
DECLARE_DYNAMIC_PIXEL_SHADER( debugluxel_ps20b );
SET_DYNAMIC_PIXEL_SHADER( debugluxel_ps20b );
2014-03-01 03:08:09 +08:00
}
else
{
2014-10-31 00:30:57 +08:00
DECLARE_DYNAMIC_PIXEL_SHADER( debugluxel_ps20 );
SET_DYNAMIC_PIXEL_SHADER( debugluxel_ps20 );
2014-03-01 03:08:09 +08:00
}
//texture scale transform
Vector4D transformation[2];
2014-10-31 00:30:57 +08:00
transformation[0].Init( texCoordScaleX, 0.0f, 0.0f, 0.0f );
transformation[1].Init( 0.0f, texCoordScaleY, 0.0f, 0.0f );
2014-03-01 03:08:09 +08:00
s_pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, transformation[0].Base(), 2 );
}
2014-10-31 00:30:57 +08:00
Draw();
2014-03-01 03:08:09 +08:00
}
END_SHADER