It is currently Sun May 19, 2024 10:18 am
I'm trying to write a DOF shader for a machinima project that I'm working on. I'm just a bit too impatient to wait for the Source Filmmaker I guess.Armageddon wrote:Why are all these machinima dudes starting to come here?
Mystfit wrote:My vertex shader actually compiled properly this time but for some reason, my pixel shader is being skipped. There are no errors while I run buildsdkshaders.bat
Mystfit wrote:I'm trying to write a DOF shader for a machinima project that I'm working on.
#include "common_ps_fxc.h"
sampler TexSampler : register( s0 );
struct PS_INPUT
{
HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
};
float4 main( PS_INPUT i ) : COLOR
{
float4 pixel = tex2D( TexSampler, i.baseTexCoord );
float4 result = dot(float3(0.222, 0.707, 0.071), pixel);
//result.a = 1.0f;
return result; //FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
}
//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============//
// STATIC: "X360APPCHOOSER" "0..1" [= 0]
#include "common_vs_fxc.h"
struct VS_INPUT
{
float3 vPos : POSITION;
float2 vBaseTexCoord : TEXCOORD0;
#if X360APPCHOOSER
float4 vColor : COLOR0;
#endif
};
struct VS_OUTPUT
{
float4 projPos : POSITION;
float2 baseTexCoord : TEXCOORD0;
float2 ZeroTexCoord : TEXCOORD1;
float2 bloomTexCoord : TEXCOORD2;
#if X360APPCHOOSER
float4 vColor : TEXCOORD3;
#endif
};
float4 Texel_Sizes : register (SHADER_SPECIFIC_CONST_0);
VS_OUTPUT main( const VS_INPUT v )
{
VS_OUTPUT o = ( VS_OUTPUT )0;
o.projPos = float4( v.vPos, 1.0f );
o.baseTexCoord = v.vBaseTexCoord;
o.ZeroTexCoord=float2(0,0);
o.bloomTexCoord.x=v.vBaseTexCoord.x+Texel_Sizes.z;
o.bloomTexCoord.y=v.vBaseTexCoord.y+Texel_Sizes.w;
#if X360APPCHOOSER
o.vColor.rgba = v.vColor.rgba;
o.projPos.xyzw = mul( float4( v.vPos.xyz, 1.0f ), cModelViewProj );
#endif
return o;
}
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#include "BaseVSShader.h"
#include "SDK_screenspaceeffect_vs20.inc"
#include "post_sepia_ps20.inc"
BEGIN_VS_SHADER_FLAGS( post_sepia, "Help for Sepia", SHADER_NOT_EDITABLE )
BEGIN_SHADER_PARAMS
SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "" )
END_SHADER_PARAMS
SHADER_INIT
{
if( params[FBTEXTURE]->IsDefined() )
{
LoadTexture( FBTEXTURE );
}
}
SHADER_FALLBACK
{
// Requires DX9 + above
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
{
Assert( 0 );
return "Wireframe";
}
return 0;
}
SHADER_DRAW
{
SHADOW_STATE
{
pShaderShadow->EnableDepthWrites( false );
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
int fmt = VERTEX_POSITION;
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
// Pre-cache shaders
DECLARE_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
SET_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_STATIC_PIXEL_SHADER( post_sepia_ps20 );
SET_STATIC_PIXEL_SHADER( post_sepia_ps20 );
}
}
DYNAMIC_STATE
{
BindTexture( SHADER_SAMPLER0, FBTEXTURE, -1 );
DECLARE_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
SET_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_DYNAMIC_PIXEL_SHADER( post_sepia_ps20 );
SET_DYNAMIC_PIXEL_SHADER( post_sepia_ps20 );
}
}
Draw();
}
END_SHADER
Mystfit wrote:I'm just planning on grabbing the built in depth buffer and using it to blend between a downsampled gaussian blurred version of the frame buffer and the unblurred version.
-=Biohazard=- wrote:It only describes a range of about 200 units though.
"SDK_Bloom"
{
// Original shader: BaseTexture
"$fbtexture" "_rt_FullFrameFB"
}
Mystfit wrote:Oh. Guess that's why r_showdepthoverlay has such a limited range.
I think I've tracked down the problem to "post_sepia.cpp". If I put any other code in there whatsoever, even if it's from another shader it will still say that it can't find the shader ingame.
Mystfit wrote:Only other glitch ingame is that it can't seem to load the framebuffer texture, so I'm staring at a greyscale version of the pink checkerboard. Console is saying 'Requesting texture value from var "$fbtexture" which is not a texture value (material: post/post_sepia)'.
This is my current vmt file.
- Code: Select all
"SDK_Bloom"
{
// Original shader: BaseTexture
"$fbtexture" "_rt_FullFrameFB"
}
Mystfit wrote:Got it working at last! I think the problem was that I had my code in the wrong cpp file.
I attached my DoPostShaders function to the CViewRender class and moved everything into viewrender.cpp. Somehow this let it pick up on the framebuffer image (god knows how) and made a lovely little black and white image.
Mystfit wrote:Going back to the DOF shader issue, can't I just make a new shader to grab vertex depth values,scale them to a range, then dump them in the alpha channel of an texture before doing my blurs? I have no idea how to change the existing zdepth shader valve uses and it has an annoying habit of ignoring translucent objects anyway.
C:\Jacobsmod\src\materialsystem\stdshaders>buildsdkshaders
Setting environment for using Microsoft Visual Studio 2005 x86 tools.
07:57 PM
07:57 PM
Can't locate String/CRC32.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/li
b .) at ..\..\devtools\bin\updateshaders.pl line 1.
BEGIN failed--compilation aborted at ..\..\devtools\bin\updateshaders.pl line 1.
Building inc files, asm vcs files, and VMPI worklist for stdshader_dx9_20b...
NMAKE : U1052: file 'makefile.stdshader_dx9_20b' not found
Stop.
'xcopy' is not recognized as an internal or external command,
operable program or batch file.
07:57 PM
07:57 PM
Can't locate String/CRC32.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/li
b .) at ..\..\devtools\bin\updateshaders.pl line 1.
BEGIN failed--compilation aborted at ..\..\devtools\bin\updateshaders.pl line 1.
Building inc files, asm vcs files, and VMPI worklist for stdshader_dx9_30...
NMAKE : U1052: file 'makefile.stdshader_dx9_30' not found
Stop.
'xcopy' is not recognized as an internal or external command,
operable program or batch file.
07:57 PM
07:57 PM
Can't locate String/CRC32.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/li
b .) at ..\..\devtools\bin\updateshaders.pl line 1.
BEGIN failed--compilation aborted at ..\..\devtools\bin\updateshaders.pl line 1.
Building inc files, asm vcs files, and VMPI worklist for modshaders...
NMAKE : U1052: file 'makefile.modshaders' not found
Stop.
'xcopy' is not recognized as an internal or external command,
operable program or batch file.
07:57 PM
Press any key to continue . . .
Users browsing this forum: No registered users