Cg shaders

Cg shaders
master
motorsep 2016-04-21 19:55:29 -05:00
parent f0f00473e0
commit fc57af51d0
137 changed files with 8636 additions and 0 deletions

View File

@ -0,0 +1,46 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // Y
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
result.color.xyz = tex2D( samp0, fragment.texcoord0.xy ).xyz;
result.color.w = 1.0;
result.color *= rpColor;
}

View File

@ -0,0 +1,51 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0 = vertex.texcoord;
}

View File

@ -0,0 +1,55 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // Y
uniform sampler2D samp1 : register(s1); // Cr
uniform sampler2D samp2 : register(s2); // Cb
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 binkImage;
binkImage.xyz = tex2D( samp0, fragment.texcoord0.xy ).xyz;
binkImage.w = 1.0;
float4 color = ( binkImage * fragment.color ) + fragment.texcoord1;
result.color.xyz = color.xyz * color.w;
result.color.w = color.w;
result.color *= rpColor;
}

View File

@ -0,0 +1,57 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0.xy = vertex.texcoord.xy;
result.texcoord1 = ( swizzleColor( vertex.color2 ) * 2 ) - 1;
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( swizzleColor( vertex.color ) );
}

View File

@ -0,0 +1,46 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
uniform sampler2D samp1 : register(s1);
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float2 texcoord1 : TEXCOORD1_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
result.color = idtex2Dproj( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * rpColor;
}

View File

@ -0,0 +1,59 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 binormal : BINORMAL;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0.x = dot4( vertex.position, rpTexGen0S );
result.texcoord0.y = dot4( vertex.position, rpTexGen0T );
result.texcoord0.z = 0.0;
result.texcoord0.w = dot4( vertex.position, rpTexGen0Q );
result.texcoord1.x = dot4( vertex.position, rpTexGen1S );
result.texcoord1.y = 0.5;
}

View File

@ -0,0 +1,52 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); //_accum
uniform sampler2D samp1 : register(s1); //_currentRender
uniform sampler2D samp2 : register(s2); //mask
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float2 texcoord1 : TEXCOORD1_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 accumSample = tex2D( samp0, fragment.texcoord0 );
float4 maskSample = tex2D( samp2, fragment.texcoord1 );
float4 currentRenderSample = tex2D( samp1, fragment.texcoord1 );
result.color = lerp( accumSample, currentRenderSample, maskSample.a );
}

View File

@ -0,0 +1,59 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform float4 rpUser0 : register( c128 ); //rpCenterScale
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
//center scale
const float4 centerScale = rpUser0;
result.texcoord0 = CenterScale( vertex.texcoord, centerScale.xy );
// pass through texcoords
result.texcoord1 = vertex.texcoord;
}

View File

@ -0,0 +1,58 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); //_accum
uniform sampler2D samp1 : register(s1); //_currentRender
uniform sampler2D samp2 : register(s2); //mask
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float2 texcoord1 : TEXCOORD1_centroid;
float2 texcoord2 : TEXCOORD2_centroid;
//float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 redTint = float4( 1, 0.98, 0.98, 1 );
float4 accumSample = tex2D( samp0, fragment.texcoord0 ) * redTint;
float4 maskSample = tex2D( samp2, fragment.texcoord1 );
float4 tint = float4( 1.0, 0.8, 0.8, 1 );
float4 currentRenderSample = tex2D( samp1, fragment.texcoord2 ) * tint;
result.color = lerp( accumSample, currentRenderSample, maskSample.a );
}

View File

@ -0,0 +1,69 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform float4 rpUser0 : register( c128 ); //rpCenterScaleTex0
uniform float4 rpUser1 : register( c129 ); //rpRotateTex0
uniform float4 rpUser2 : register( c130 ); //rpCenterScaleTex1
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
float2 texcoord2 : TEXCOORD2;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
const float4 centerScaleTex0 = rpUser0;
const float4 rotateTex0 = rpUser1;
const float4 centerScaleTex1 = rpUser2;
//center scale and rotate for _accum
float2 tc0 = CenterScale( vertex.texcoord, centerScaleTex0.xy );
result.texcoord0 = Rotate2D( tc0, rotateTex0.xy );
//center scale for mask
result.texcoord1 = CenterScale( vertex.texcoord, centerScaleTex1.xy );
// pass through for currentrender
result.texcoord2 = vertex.texcoord;
}

View File

@ -0,0 +1,70 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); //_accum
uniform sampler2D samp1 : register(s1); //_currentRender
uniform sampler2D samp2 : register(s2); //mask
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float2 texcoord1 : TEXCOORD1_centroid;
float2 texcoord2 : TEXCOORD2_centroid;
float2 texcoord3 : TEXCOORD3_centroid;
float2 texcoord4 : TEXCOORD4;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float colorFactor = fragment.texcoord4.x;
float4 color0 = float4( 1.0f - colorFactor, 1.0f - colorFactor, 1.0f, 1.0f );
float4 color1 = float4( 1.0f, 0.95f - colorFactor, 0.95f, 0.5f );
float4 color2 = float4( 0.015f, 0.015f, 0.015f, 0.01f );
float4 accumSample0 = tex2D( samp0, fragment.texcoord0 ) * color0;
float4 accumSample1 = tex2D( samp0, fragment.texcoord1 ) * color1;
float4 accumSample2 = tex2D( samp0, fragment.texcoord2 ) * color2;
float4 maskSample = tex2D( samp2, fragment.texcoord3 );
float4 tint = float4( 0.8, 0.5, 0.5, 1 );
float4 currentRenderSample = tex2D( samp1, fragment.texcoord3 ) * tint;
// blend of the first 2 accumulation samples
float4 accumColor = lerp( accumSample0, accumSample1, 0.5f );
// add thrid sample
accumColor += accumSample2;
accumColor = lerp( accumColor, currentRenderSample, maskSample.a );
result.color = accumColor;
}

View File

@ -0,0 +1,76 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform float4 rpUser0 : register( c128 ); //rpCenterScaleTex
uniform float4 rpUser1 : register( c129 ); //rpRotateTex
uniform float4 rpUser2 : register( c130 ); //rpColorFactor
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
float2 texcoord2 : TEXCOORD2;
float2 texcoord3 : TEXCOORD3;
float2 texcoord4 : TEXCOORD4;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
//_accum 1
const float4 centerScaleTex = rpUser0;
const float4 rotateTex = rpUser1;
float2 tc0 = CenterScale( vertex.texcoord, centerScaleTex.xy );
result.texcoord0 = Rotate2D( tc0, rotateTex.xy );
// accum 2
result.texcoord1 = Rotate2D( tc0, float2( rotateTex.z, -rotateTex.w ) );
// accum 3
result.texcoord2 = Rotate2D( tc0, rotateTex.zw );
// pass through for currentrender
result.texcoord3 = vertex.texcoord;
// pass through the color fator
const float4 colorFactor = rpUser2;
result.texcoord4 = colorFactor.xx;
}

View File

@ -0,0 +1,51 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); //_accum
uniform sampler2D samp1 : register(s1); //_currentRender
uniform sampler2D samp2 : register(s2); //mask
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 accumSample = tex2D( samp0, fragment.texcoord0 );
float4 currentRenderSample = tex2D( samp1, fragment.texcoord0 );
float4 maskSample = tex2D( samp2, fragment.texcoord0 );
result.color = lerp( accumSample, currentRenderSample, maskSample.a );
}

View File

@ -0,0 +1,52 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
// pass through texcoords
result.texcoord0 = vertex.texcoord;
}

View File

@ -0,0 +1,82 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
uniform float4 rpUser0 : register(c128); // x = deform scale, y = blur scale
uniform float4 rpUser1 : register(c129); // RGB = tint color, A = tint lerp
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
// texture 0 takes the texture coordinates unmodified
result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 );
result.texcoord1 = rpUser0;
result.texcoord1.z = dot4( vertex.position, rpMVPmatrixW );
result.texcoord2 = rpUser1;
float4 normal = vertex.normal * 2.0 - 1.0;
float4 tangent = vertex.tangent * 2.0 - 1.0;
float3 binormal = cross( normal.xyz, tangent.xyz ) * tangent.w;
result.texcoord3.x = dot3( tangent, rpMVPmatrixX );
result.texcoord3.y = dot3( binormal, rpMVPmatrixX );
result.texcoord3.z = dot3( normal, rpMVPmatrixX );
result.texcoord4.x = dot3( tangent, rpMVPmatrixY );
result.texcoord4.y = dot3( binormal, rpMVPmatrixY );
result.texcoord4.z = dot3( normal, rpMVPmatrixY );
result.texcoord5.x = dot3( tangent, rpMVPmatrixZ );
result.texcoord5.y = dot3( binormal, rpMVPmatrixZ );
result.texcoord5.z = dot3( normal, rpMVPmatrixZ );
}

View File

@ -0,0 +1,95 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _scratch (mirror render)
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
const float2 poisson[12] = float2[12](
float2( -0.326212, -0.405810 ),
float2( -0.840144, -0.073580 ),
float2( -0.695914, 0.457137 ),
float2( -0.203345, 0.620716 ),
float2( 0.962340, -0.194983 ),
float2( 0.473434, -0.480026 ),
float2( 0.519456, 0.767022 ),
float2( 0.185461, -0.893124 ),
float2( 0.507431, 0.064425 ),
float2( 0.896420, 0.412458 ),
float2( -0.321940, -0.932615 ),
float2( -0.791559, -0.597710 )
);
void main( PS_IN fragment, out PS_OUT result ) {
float4 mask = tex2D( samp2, fragment.texcoord0.xy );
// load the filtered normal map and convert to -1 to 1 range
float4 bumpMap = tex2D( samp1, fragment.texcoord0.xy ) * 2.0f - 1.0f;
float3 viewNormal;
viewNormal.x = dot3( bumpMap.wyz, fragment.texcoord3 );
viewNormal.y = dot3( bumpMap.wyz, fragment.texcoord4 );
viewNormal.z = dot3( bumpMap.wyz, fragment.texcoord5 );
viewNormal.xy *= mask.xy;
float2 scale = min( fragment.texcoord1.xy / fragment.texcoord1.zz, float2( 0.05, 0.01 ) );
// calculate the screen texcoord in the 0.0 to 1.0 range
float2 mins = float2( rpWindowCoord.xy * 4 );
float2 maxs = float2( 1 - rpWindowCoord.xy * 4 );
float2 screenTexCoord = vposToScreenPosTexCoord( fragment.position.xy );
screenTexCoord += ( viewNormal.xy * scale.xx );
screenTexCoord = max( min( screenTexCoord, maxs ), mins );
float4 color = tex2D( samp0, screenTexCoord );
for ( int i = 0; i < 12; i++ ) {
float2 uv = screenTexCoord + poisson[ i ].xy * scale.yy;
color += tex2D( samp0, max( min( uv, maxs ), mins ) );
}
color = color / 13;
float3 tint = dot( color.xyz, float3( 0.212671f, 0.715160f, 0.072169f ) ) * fragment.texcoord2.xyz;
color.xyz = lerp( color.xyz, tint.xyz, fragment.texcoord2.w );
result.color = color;
}

View File

@ -0,0 +1,102 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _scratch (mirror render)
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
float4 texcoord3 : TEXCOORD3_centroid;
float4 texcoord4 : TEXCOORD4_centroid;
float4 texcoord5 : TEXCOORD5_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
const float2 poisson[16] = float2[16](
float2( -0.94201624, -0.39906216 ),
float2( 0.94558609, -0.76890725 ),
float2( -0.09418410, -0.92938870 ),
float2( 0.34495938, 0.29387760 ),
float2( -0.91588581, 0.45771432 ),
float2( -0.81544232, -0.87912464 ),
float2( -0.38277543, 0.27676845 ),
float2( 0.97484398, 0.75648379 ),
float2( 0.44323325, -0.97511554 ),
float2( 0.53742981, -0.47373420 ),
float2( -0.26496911, -0.41893023 ),
float2( 0.79197514, 0.19090188 ),
float2( -0.24188840, 0.99706507 ),
float2( -0.81409955, 0.91437590 ),
float2( 0.19974126, 0.78641367 ),
float2( 0.14383161, -0.14100790 )
);
void main( PS_IN fragment, out PS_OUT result ) {
// load the mask texture
float4 mask = tex2D( samp2, fragment.texcoord0.xy );
// load the filtered normal map and convert to -1 to 1 range
float4 bumpMap = tex2D( samp1, fragment.texcoord0.xy ) * 2.0f - 1.0f;
float3 viewNormal;
viewNormal.x = dot3( bumpMap.wyz, fragment.texcoord3 );
viewNormal.y = dot3( bumpMap.wyz, fragment.texcoord4 );
viewNormal.z = dot3( bumpMap.wyz, fragment.texcoord5 );
viewNormal.xy *= mask.xy;
float2 scale = min( fragment.texcoord1.xy / fragment.texcoord1.zz, float2( 0.05, 0.01 ) );
// calculate the screen texcoord in the 0.0 to 1.0 range
float2 mins = float2( rpWindowCoord.xy * 4 );
float2 maxs = float2( 1 - rpWindowCoord.xy * 4 );
float2 screenTexCoord = vposToScreenPosTexCoord( fragment.position.xy );
screenTexCoord += ( viewNormal.xy * scale.xx );
screenTexCoord = max( min( screenTexCoord, maxs ), mins );
float4 color = tex2D( samp0, screenTexCoord );
for ( int i = 0; i < 16; i++ ) {
float2 uv = screenTexCoord + poisson[ i ].xy * scale.yy;
color += tex2D( samp0, max( min( uv, maxs ), mins ) );
}
color = color / 17;
float3 tint = dot( color.xyz, float3( 0.212671f, 0.715160f, 0.072169f ) ) * fragment.texcoord2.xyz;
color.xyz = lerp( color.xyz, tint.xyz, fragment.texcoord2.w );
result.color = color;
}

View File

@ -0,0 +1,150 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _scratch (mirror render)
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
float4 texcoord3 : TEXCOORD3_centroid;
float4 texcoord4 : TEXCOORD4_centroid;
float4 texcoord5 : TEXCOORD5_centroid;
float4 texcoord6 : TEXCOORD6_centroid;
float4 texcoord7 : TEXCOORD7_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
const float2 poisson8[8] = float2[8](
float2( 0.100000, 0.300000 ),
float2( 0.527837, -0.085868 ),
float2( -0.040088, 0.536087 ),
float2( -0.170445, -0.179949 ),
float2( -0.419418, -0.616039 ),
float2( 0.440453, -0.639399 ),
float2( -0.757088, 0.349334 ),
float2( 0.574619, 0.685879 )
);
// const float2 poisson12[12] = float2[12](
// float2( -0.326212, -0.405810 ),
// float2( -0.840144, -0.073580 ),
// float2( -0.695914, 0.457137 ),
// float2( -0.203345, 0.620716 ),
// float2( 0.962340, -0.194983 ),
// float2( 0.473434, -0.480026 ),
// float2( 0.519456, 0.767022 ),
// float2( 0.185461, -0.893124 ),
// float2( 0.507431, 0.064425 ),
// float2( 0.896420, 0.412458 ),
// float2( -0.321940, -0.932615 ),
// float2( -0.791559, -0.597710 )
// );
//const float2 poisson16[16] = float2[16](
// float2( -0.94201624, -0.39906216 ),
// float2( 0.94558609, -0.76890725 ),
// float2( -0.09418410, -0.92938870 ),
// float2( 0.34495938, 0.29387760 ),
// float2( -0.91588581, 0.45771432 ),
// float2( -0.81544232, -0.87912464 ),
// float2( -0.38277543, 0.27676845 ),
// float2( 0.97484398, 0.75648379 ),
// float2( 0.44323325, -0.97511554 ),
// float2( 0.53742981, -0.47373420 ),
// float2( -0.26496911, -0.41893023 ),
// float2( 0.79197514, 0.19090188 ),
// float2( -0.24188840, 0.99706507 ),
// float2( -0.81409955, 0.91437590 ),
// float2( 0.19974126, 0.78641367 ),
// float2( 0.14383161, -0.14100790 )
//);
void main( PS_IN fragment, out PS_OUT result ) {
// load the mask texture
float4 mask = tex2D( samp2, fragment.texcoord0.xy );
// load the filtered normal map and convert to -1 to 1 range
float4 normalVec = tex2D( samp1, fragment.texcoord0.xy ) * 2.0f - 1.0f;
normalVec.xyz = normalize( normalVec.wyz );
// Fresnel
float Fresnel = 1.0 - saturate( dot3( normalVec.xyz, -normalize( fragment.texcoord4.xyz ) ) );
Fresnel = pow( Fresnel, fragment.texcoord2.x ) * fragment.texcoord2.y + fragment.texcoord2.z;
float2 viewNormal;
viewNormal.x = dot3( normalVec.xyz, fragment.texcoord5 );
viewNormal.y = dot3( normalVec.xyz, fragment.texcoord6 );
// viewNormal.z = dot3( normalVec.xyz, fragment.texcoord7 );
// calculate the screen texcoord in the 0.0 to 1.0 range
float2 scale = min( fragment.texcoord1.xy / fragment.texcoord1.ww, float2( 0.05, 0.01 ) );
float2 mins = float2( rpWindowCoord.xy * 4 );
float2 maxs = 1 - mins;
float2 screenTC = vposToScreenPosTexCoord( fragment.position.xy );
screenTC += ( viewNormal.xy * scale.xx );
screenTC = max( min( screenTC, maxs ), mins );
float4 color = tex2D( samp0, screenTC );
// if ( fragment.texcoord1.z > 2 ) {
// for ( int i = 0; i < 16; i++ ) {
// float2 uv = screenTC + poisson16[ i ].xy * scale.yy;
//color += tex2D( samp0, max( min( uv, maxs ), mins ) );
//}
//color = color / 17;
// } else if ( fragment.texcoord1.z > 1 ) {
// for ( int i = 0; i < 12; i++ ) {
// float2 uv = screenTC + poisson12[ i ].xy * scale.yy;
// color += tex2D( samp0, max( min( uv, maxs ), mins ) );
// }
// color = color / 13;
// } else
if ( fragment.texcoord1.z > 0 ) {
for ( int i = 0; i < 8; i++ ) {
float2 uv = screenTC + poisson8[ i ].xy * scale.yy;
color += tex2D( samp0, max( min( uv, maxs ), mins ) );
}
color = color / 9;
}
float3 tint = dot3( color.xyz, float3( 0.212671f, 0.715160f, 0.072169f ) ) * fragment.texcoord3.xyz;
color.xyz = lerp( color.xyz, tint.xyz, fragment.texcoord3.w ) * mask.xyz * Fresnel;
// color.w = lerp( 0.0, Fresnel, fragment.texcoord2.w );
result.color = color;
// result.color.xyz = normalVec.xyz;//color;
// result.color.w = dot3( color.xyz, float3( 0.212671f, 0.715160f, 0.072169f ) );
}

View File

@ -0,0 +1,91 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
uniform float4 rpUser0 : register(c128); // x = deform scale, y = blur scale
uniform float4 rpUser1 : register(c129); // x = Fresnel exponent, y = Fresnel scale, z = Fresnel bias, w = reflection blend
uniform float4 rpUser2 : register(c130); // RGB = tint color, A = tint lerp
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
float4 texcoord6 : TEXCOORD6;
float4 texcoord7 : TEXCOORD7;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
// texture 0 takes the texture coordinates unmodified
result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 );
result.texcoord1 = rpUser0;
result.texcoord1.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord2 = rpUser1;
result.texcoord3 = rpUser2;
float4 normal = vertex.normal * 2.0 - 1.0;
float4 tangent = vertex.tangent * 2.0 - 1.0;
float3 binormal = cross( normal.xyz, tangent.xyz ) * tangent.w;
float4 viewVec = rpLocalViewOrigin - vertex.position;
result.texcoord4.x = dot3( viewVec, tangent );
result.texcoord4.y = dot3( viewVec, binormal );
result.texcoord4.z = dot3( viewVec, normal );
result.texcoord5.x = dot3( tangent, rpMVPmatrixX );
result.texcoord5.y = dot3( binormal, rpMVPmatrixX );
result.texcoord5.z = dot3( normal, rpMVPmatrixX );
result.texcoord6.x = dot3( tangent, rpMVPmatrixY );
result.texcoord6.y = dot3( binormal, rpMVPmatrixY );
result.texcoord6.z = dot3( normal, rpMVPmatrixY );
result.texcoord7.x = dot3( tangent, rpMVPmatrixZ );
result.texcoord7.y = dot3( binormal, rpMVPmatrixZ );
result.texcoord7.z = dot3( normal, rpMVPmatrixZ );
}

View File

@ -0,0 +1,67 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map
uniform sampler2D samp1 : register(s1); // normal map
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float3 texcoord1 : TEXCOORD1_centroid;
float3 texcoord2 : TEXCOORD2_centroid;
float3 texcoord3 : TEXCOORD3_centroid;
float3 texcoord4 : TEXCOORD4_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 bump = tex2D( samp1, fragment.texcoord0 ) * 2.0f - 1.0f;
float3 localNormal = float3( bump.wy, 0.0f );
localNormal.z = sqrt( 1.0f - dot3( localNormal, localNormal ) );
float3 globalNormal;
globalNormal.x = dot3( localNormal, fragment.texcoord2 );
globalNormal.y = dot3( localNormal, fragment.texcoord3 );
globalNormal.z = dot3( localNormal, fragment.texcoord4 );
float3 globalEye = normalize( fragment.texcoord1 );
float3 reflectionVector = globalNormal * dot3( globalEye, globalNormal );
reflectionVector = ( reflectionVector * 2.0f ) - globalEye;
float4 envMap = ConvertYCoCgToRGBFull( texCUBE( samp0, reflectionVector ) );
result.color = float4( envMap.xyz, 1.0f ) * fragment.color;
}

View File

@ -0,0 +1,81 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float3 texcoord1 : TEXCOORD1;
float3 texcoord2 : TEXCOORD2;
float3 texcoord3 : TEXCOORD3;
float3 texcoord4 : TEXCOORD4;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
float4 normal = vertex.normal * 2.0 - 1.0;
float4 tangent = vertex.tangent * 2.0 - 1.0;
float3 binormal = cross( normal.xyz, tangent.xyz ) * tangent.w;
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0 = vertex.texcoord.xy;
float4 toEye = rpLocalViewOrigin - vertex.position;
result.texcoord1.x = dot3( toEye, rpModelMatrixX );
result.texcoord1.y = dot3( toEye, rpModelMatrixY );
result.texcoord1.z = dot3( toEye, rpModelMatrixZ );
result.texcoord2.x = dot3( tangent, rpModelMatrixX );
result.texcoord3.x = dot3( tangent, rpModelMatrixY );
result.texcoord4.x = dot3( tangent, rpModelMatrixZ );
result.texcoord2.y = dot3( binormal, rpModelMatrixX );
result.texcoord3.y = dot3( binormal, rpModelMatrixY );
result.texcoord4.y = dot3( binormal, rpModelMatrixZ );
result.texcoord2.z = dot3( normal, rpModelMatrixX );
result.texcoord3.z = dot3( normal, rpModelMatrixY );
result.texcoord4.z = dot3( normal, rpModelMatrixZ );
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( rpColor );
}

View File

@ -0,0 +1,67 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map
uniform sampler2D samp1 : register(s1); // normal map
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float3 texcoord1 : TEXCOORD1_centroid;
float3 texcoord2 : TEXCOORD2_centroid;
float3 texcoord3 : TEXCOORD3_centroid;
float3 texcoord4 : TEXCOORD4_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 bump = tex2D( samp1, fragment.texcoord0 ) * 2.0f - 1.0f;
float3 localNormal = float3( bump.wy, 0.0f );
localNormal.z = sqrt( 1.0f - dot3( localNormal, localNormal ) );
float3 globalNormal;
globalNormal.x = dot3( localNormal, fragment.texcoord2 );
globalNormal.y = dot3( localNormal, fragment.texcoord3 );
globalNormal.z = dot3( localNormal, fragment.texcoord4 );
float3 globalEye = normalize( fragment.texcoord1 );
float3 reflectionVector = globalNormal * dot3( globalEye, globalNormal );
reflectionVector = ( reflectionVector * 2.0f ) - globalEye;
float4 envMap = ConvertYCoCgToRGBFull( texCUBE( samp0, reflectionVector ) );
result.color = float4( envMap.xyz, 1.0f ) * fragment.color;
}

View File

@ -0,0 +1,138 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float3 texcoord1 : TEXCOORD1;
float3 texcoord2 : TEXCOORD2;
float3 texcoord3 : TEXCOORD3;
float3 texcoord4 : TEXCOORD4;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
float4 vNormal = vertex.normal * 2.0 - 1.0;
float4 vTangent = vertex.tangent * 2.0 - 1.0;
float3 vBinormal = cross( vNormal.xyz, vTangent.xyz ) * vTangent.w;
//--------------------------------------------------------------
// GPU transformation of the normal / binormal / bitangent
//
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
//--------------------------------------------------------------
const float w0 = vertex.color2.x;
const float w1 = vertex.color2.y;
const float w2 = vertex.color2.z;
const float w3 = vertex.color2.w;
float4 matX, matY, matZ; // must be float4 for vec4
float joint = vertex.color.x * 255.1 * 3;
matX = matrices[int(joint+0)] * w0;
matY = matrices[int(joint+1)] * w0;
matZ = matrices[int(joint+2)] * w0;
joint = vertex.color.y * 255.1 * 3;
matX += matrices[int(joint+0)] * w1;
matY += matrices[int(joint+1)] * w1;
matZ += matrices[int(joint+2)] * w1;
joint = vertex.color.z * 255.1 * 3;
matX += matrices[int(joint+0)] * w2;
matY += matrices[int(joint+1)] * w2;
matZ += matrices[int(joint+2)] * w2;
joint = vertex.color.w * 255.1 * 3;
matX += matrices[int(joint+0)] * w3;
matY += matrices[int(joint+1)] * w3;
matZ += matrices[int(joint+2)] * w3;
float3 normal;
normal.x = dot3( matX, vNormal );
normal.y = dot3( matY, vNormal );
normal.z = dot3( matZ, vNormal );
normal = normalize( normal );
float3 tangent;
tangent.x = dot3( matX, vTangent );
tangent.y = dot3( matY, vTangent );
tangent.z = dot3( matZ, vTangent );
tangent = normalize( tangent );
float3 binormal;
binormal.x = dot3( matX, vBinormal );
binormal.y = dot3( matY, vBinormal );
binormal.z = dot3( matZ, vBinormal );
binormal = normalize( binormal );
float4 modelPosition;
modelPosition.x = dot4( matX, vertex.position );
modelPosition.y = dot4( matY, vertex.position );
modelPosition.z = dot4( matZ, vertex.position );
modelPosition.w = 1.0;
result.position.x = dot4( modelPosition, rpMVPmatrixX );
result.position.y = dot4( modelPosition, rpMVPmatrixY );
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
result.position.w = dot4( modelPosition, rpMVPmatrixW );
result.texcoord0 = vertex.texcoord.xy;
float4 toEye = rpLocalViewOrigin - modelPosition;
result.texcoord1.x = dot3( toEye, rpModelMatrixX );
result.texcoord1.y = dot3( toEye, rpModelMatrixY );
result.texcoord1.z = dot3( toEye, rpModelMatrixZ );
result.texcoord2.x = dot3( tangent, rpModelMatrixX );
result.texcoord3.x = dot3( tangent, rpModelMatrixY );
result.texcoord4.x = dot3( tangent, rpModelMatrixZ );
result.texcoord2.y = dot3( binormal, rpModelMatrixX );
result.texcoord3.y = dot3( binormal, rpModelMatrixY );
result.texcoord4.y = dot3( binormal, rpModelMatrixZ );
result.texcoord2.z = dot3( normal, rpModelMatrixX );
result.texcoord3.z = dot3( normal, rpModelMatrixY );
result.texcoord4.z = dot3( normal, rpModelMatrixZ );
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( rpColor );
}

View File

@ -0,0 +1,39 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_OUT {
float4 color : COLOR;
};
void main( out PS_OUT result ) {
result.color = rpColor;
}

View File

@ -0,0 +1,48 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
}

View File

@ -0,0 +1,47 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_IN {
float4 position : VPOS;
float4 color : COLOR;
float3 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 src = tex2D( samp0, fragment.texcoord0.xy );
float4 target = fragment.color * dot3( float3( 0.333, 0.333, 0.333 ), src );
result.color = lerp( src, target, fragment.texcoord0.z );
}

View File

@ -0,0 +1,61 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform float4 rpUser0 : register(c128); //rpFraction
uniform float4 rpUser1 : register(c129); //rpTargetHue
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float4 color : COLOR0;
float3 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.color = rpUser1; // targetHue
result.texcoord0.x = vertex.texcoord.x;
result.texcoord0.y = 1.0f - vertex.texcoord.y;
result.texcoord0.z = rpUser0.x; // fraction
}

View File

@ -0,0 +1,38 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_OUT {
float4 color : COLOR;
};
void main( out PS_OUT result ) {
result.color = float4( 0.0, 0.0, 0.0, 1.0 );
}

View File

@ -0,0 +1,44 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
};
struct VS_OUT {
float4 position : POSITION;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
}

View File

@ -0,0 +1,38 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_OUT {
float4 color : COLOR;
};
void main( out PS_OUT result ) {
result.color = float4( 0.0, 0.0, 0.0, 1.0 );
}

View File

@ -0,0 +1,85 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
};
void main( VS_IN vertex, out VS_OUT result ) {
//--------------------------------------------------------------
// GPU transformation of the normal / binormal / bitangent
//
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
//--------------------------------------------------------------
const float w0 = vertex.color2.x;
const float w1 = vertex.color2.y;
const float w2 = vertex.color2.z;
const float w3 = vertex.color2.w;
float4 matX, matY, matZ; // must be float4 for vec4
float joint = vertex.color.x * 255.1 * 3;
matX = matrices[int(joint+0)] * w0;
matY = matrices[int(joint+1)] * w0;
matZ = matrices[int(joint+2)] * w0;
joint = vertex.color.y * 255.1 * 3;
matX += matrices[int(joint+0)] * w1;
matY += matrices[int(joint+1)] * w1;
matZ += matrices[int(joint+2)] * w1;
joint = vertex.color.z * 255.1 * 3;
matX += matrices[int(joint+0)] * w2;
matY += matrices[int(joint+1)] * w2;
matZ += matrices[int(joint+2)] * w2;
joint = vertex.color.w * 255.1 * 3;
matX += matrices[int(joint+0)] * w3;
matY += matrices[int(joint+1)] * w3;
matZ += matrices[int(joint+2)] * w3;
float4 modelPosition;
modelPosition.x = dot4( matX, vertex.position );
modelPosition.y = dot4( matY, vertex.position );
modelPosition.z = dot4( matZ, vertex.position );
modelPosition.w = 1.0;
result.position.x = dot4( modelPosition, rpMVPmatrixX );
result.position.y = dot4( modelPosition, rpMVPmatrixY );
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
result.position.w = dot4( modelPosition, rpMVPmatrixW );
}

View File

@ -0,0 +1,57 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
struct PS_IN {
float4 position : VPOS;
float2 texcoord : TEXCOORD0_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float2 screenTexCoord = fragment.texcoord;
// compute warp factor
float4 warpFactor = 1.0 - ( tex2D( samp1, screenTexCoord.xy ) * fragment.color );
screenTexCoord -= float2( 0.5, 0.5 );
screenTexCoord *= warpFactor.xy;
screenTexCoord += float2( 0.5, 0.5 );
// load the screen render
result.color = tex2D( samp0, screenTexCoord );
}

View File

@ -0,0 +1,62 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// User Renderparms start at 128 as per renderprogs.h
uniform float4 rpUser0 : register(c128); // rpScroll
uniform float4 rpUser1 : register(c129); // rpDeformMagnitude
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 color : COLOR;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord = vertex.texcoord.xy;
const float4 deformMagnitude = rpUser1;
result.color = deformMagnitude;
}

View File

@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map
struct PS_IN {
float4 position : VPOS;
float3 texcoord0 : TEXCOORD0_centroid;
float3 texcoord1 : TEXCOORD1_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float3 globalNormal = normalize( fragment.texcoord1 );
float3 globalEye = normalize( fragment.texcoord0 );
float3 reflectionVector = _float3( dot3( globalEye, globalNormal ) );
reflectionVector *= globalNormal;
reflectionVector = ( reflectionVector * 2.0f ) - globalEye;
float4 envMap = ConvertYCoCgToRGBFull( texCUBE( samp0, reflectionVector ) );
result.color = float4( envMap.xyz, 1.0f ) * fragment.color;
}

View File

@ -0,0 +1,60 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float4 normal : NORMAL;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float3 texcoord0 : TEXCOORD0;
float3 texcoord1 : TEXCOORD1;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
float4 vNormal = vertex.normal * 2.0 - 1.0;
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
float4 toEye = rpLocalViewOrigin - vertex.position;
result.texcoord0 = toEye.xyz;
result.texcoord1 = vNormal.xyz;
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( rpColor );
}

View File

@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map
struct PS_IN {
float4 position : VPOS;
float3 texcoord0 : TEXCOORD0_centroid;
float3 texcoord1 : TEXCOORD1_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float3 globalNormal = normalize( fragment.texcoord1 );
float3 globalEye = normalize( fragment.texcoord0 );
float3 reflectionVector = _float3( dot3( globalEye, globalNormal ) );
reflectionVector *= globalNormal;
reflectionVector = ( reflectionVector * 2.0f ) - globalEye;
float4 envMap = ConvertYCoCgToRGBFull( texCUBE( samp0, reflectionVector ) );
result.color = float4( envMap.xyz, 1.0f ) * fragment.color;
}

View File

@ -0,0 +1,106 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float3 texcoord0 : TEXCOORD0;
float3 texcoord1 : TEXCOORD1;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
float4 vNormal = vertex.normal * 2.0 - 1.0;
//--------------------------------------------------------------
// GPU transformation of the normal / binormal / bitangent
//
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
//--------------------------------------------------------------
const float w0 = vertex.color2.x;
const float w1 = vertex.color2.y;
const float w2 = vertex.color2.z;
const float w3 = vertex.color2.w;
float4 matX, matY, matZ; // must be float4 for vec4
float joint = vertex.color.x * 255.1 * 3;
matX = matrices[int(joint+0)] * w0;
matY = matrices[int(joint+1)] * w0;
matZ = matrices[int(joint+2)] * w0;
joint = vertex.color.y * 255.1 * 3;
matX += matrices[int(joint+0)] * w1;
matY += matrices[int(joint+1)] * w1;
matZ += matrices[int(joint+2)] * w1;
joint = vertex.color.z * 255.1 * 3;
matX += matrices[int(joint+0)] * w2;
matY += matrices[int(joint+1)] * w2;
matZ += matrices[int(joint+2)] * w2;
joint = vertex.color.w * 255.1 * 3;
matX += matrices[int(joint+0)] * w3;
matY += matrices[int(joint+1)] * w3;
matZ += matrices[int(joint+2)] * w3;
float3 vNormalSkinned;
vNormalSkinned.x = dot3( matX, vNormal );
vNormalSkinned.y = dot3( matY, vNormal );
vNormalSkinned.z = dot3( matZ, vNormal );
vNormalSkinned = normalize( vNormalSkinned );
float4 modelPosition;
modelPosition.x = dot4( matX, vertex.position );
modelPosition.y = dot4( matY, vertex.position );
modelPosition.z = dot4( matZ, vertex.position );
modelPosition.w = 1.0;
result.position.x = dot4( modelPosition, rpMVPmatrixX );
result.position.y = dot4( modelPosition, rpMVPmatrixY );
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
result.position.w = dot4( modelPosition, rpMVPmatrixW );
float4 toEye = rpLocalViewOrigin - modelPosition;
result.texcoord0 = toEye.xyz;
result.texcoord1 = vNormalSkinned.xyz;
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( rpColor );
}

View File

@ -0,0 +1,47 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
uniform sampler2D samp1 : register(s1);
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float2 texcoord1 : TEXCOORD1_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * rpColor;
}

View File

@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0.x = dot4( vertex.position, rpTexGen0S );
result.texcoord0.y = dot4( vertex.position, rpTexGen0T );
result.texcoord1.x = dot4( vertex.position, rpTexGen1S );
result.texcoord1.y = dot4( vertex.position, rpTexGen1T );
}

View File

@ -0,0 +1,47 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
uniform sampler2D samp1 : register(s1);
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float2 texcoord1 : TEXCOORD1_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * rpColor;
}

View File

@ -0,0 +1,96 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
void main( VS_IN vertex, out VS_OUT result ) {
//--------------------------------------------------------------
// GPU transformation of the normal / binormal / bitangent
//
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
//--------------------------------------------------------------
const float w0 = vertex.color2.x;
const float w1 = vertex.color2.y;
const float w2 = vertex.color2.z;
const float w3 = vertex.color2.w;
float4 matX, matY, matZ; // must be float4 for vec4
float joint = vertex.color.x * 255.1 * 3;
matX = matrices[int(joint+0)] * w0;
matY = matrices[int(joint+1)] * w0;
matZ = matrices[int(joint+2)] * w0;
joint = vertex.color.y * 255.1 * 3;
matX += matrices[int(joint+0)] * w1;
matY += matrices[int(joint+1)] * w1;
matZ += matrices[int(joint+2)] * w1;
joint = vertex.color.z * 255.1 * 3;
matX += matrices[int(joint+0)] * w2;
matY += matrices[int(joint+1)] * w2;
matZ += matrices[int(joint+2)] * w2;
joint = vertex.color.w * 255.1 * 3;
matX += matrices[int(joint+0)] * w3;
matY += matrices[int(joint+1)] * w3;
matZ += matrices[int(joint+2)] * w3;
float4 modelPosition;
modelPosition.x = dot4( matX, vertex.position );
modelPosition.y = dot4( matY, vertex.position );
modelPosition.z = dot4( matZ, vertex.position );
modelPosition.w = 1.0;
// end of skinning
// start of fog portion
result.position.x = dot4( modelPosition, rpMVPmatrixX );
result.position.y = dot4( modelPosition, rpMVPmatrixY );
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
result.position.w = dot4( modelPosition, rpMVPmatrixW );
result.texcoord0.x = dot4( modelPosition, rpTexGen0S );
result.texcoord0.y = dot4( modelPosition, rpTexGen0T );
result.texcoord1.x = dot4( modelPosition, rpTexGen1S );
result.texcoord1.y = dot4( modelPosition, rpTexGen1T );
}

110
base/renderprogs/fxaa.pixel Normal file
View File

@ -0,0 +1,110 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
#define FXAA_GREEN_AS_LUMA 1
#define FXAA_EARLY_EXIT 0
#include "Fxaa3_11.h"
uniform sampler2D samp0 : register(s0);
uniform sampler2D samp1 : register(s1); // exponent bias -1
uniform sampler2D samp2 : register(s2); // exponent bias -2
uniform float4 rpUser0 : register( c128 );
uniform float4 rpUser1 : register( c129 );
uniform float4 rpUser2 : register( c130 );
uniform float4 rpUser3 : register( c131 );
uniform float4 rpUser4 : register( c132 );
uniform float4 rpUser5 : register( c133 );
uniform float4 rpUser6 : register( c134 );
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
const float4 FXAAQualityRCPFrame = rpUser0;
const float4 FXAAConsoleRcpFrameOpt = rpUser1;
const float4 FXAAConsoleRcpFrameOpt2 = rpUser2;
const float4 FXAAConsole360RcpFrameOpt2 = rpUser3;
const float4 FXAAQualityParms = rpUser4;
const float4 FXAAConsoleEdgeParms = rpUser5;
const float4 FXAAConsole360ConstDir = rpUser6;
// Inputs - see more info in fxaa3_11.hfile
FxaaFloat2 fxaaPos = fragment.texcoord0;
FxaaFloat4 fxaaConsolePos;
float2 halfPixelOffset = float2( 0.5, 0.5 ) * FXAAQualityRCPFrame.xy;
fxaaConsolePos.xy = fxaaPos.xy - ( halfPixelOffset );
fxaaConsolePos.zw = fxaaPos.xy + ( halfPixelOffset );
FxaaFloat2 fxaaQualityRcpFrame = FXAAQualityRCPFrame.xy;
FxaaFloat4 fxaaConsoleRcpFrameOpt = FXAAConsoleRcpFrameOpt;
FxaaFloat4 fxaaConsoleRcpFrameOpt2 = FXAAConsoleRcpFrameOpt2;
FxaaFloat4 fxaaConsole360RcpFrameOpt2 = FXAAConsole360RcpFrameOpt2;
// Quality parms
FxaaFloat fxaaQualitySubpix = FXAAQualityParms.x;
FxaaFloat fxaaQualityEdgeThreshold = FXAAQualityParms.y;
FxaaFloat fxaaQualityEdgeThresholdMin = FXAAQualityParms.z;
// Console specific Parms
FxaaFloat fxaaConsoleEdgeSharpness = FXAAConsoleEdgeParms.x;
FxaaFloat fxaaConsoleEdgeThreshold = FXAAConsoleEdgeParms.y;
FxaaFloat fxaaConsoleEdgeThresholdMin = FXAAConsoleEdgeParms.z;
// 360 specific parms these have to come from a constant register so that the compiler
// does not unoptimize the shader
FxaaFloat4 fxaaConsole360ConstDir = FXAAConsole360ConstDir;
float4 colorSample = FxaaPixelShader( fxaaPos,
fxaaConsolePos,
samp0,
samp1,
samp2,
fxaaQualityRcpFrame,
fxaaConsoleRcpFrameOpt,
fxaaConsoleRcpFrameOpt2,
fxaaConsole360RcpFrameOpt2,
fxaaQualitySubpix,
fxaaQualityEdgeThreshold,
fxaaQualityEdgeThresholdMin,
fxaaConsoleEdgeSharpness,
fxaaConsoleEdgeThreshold,
fxaaConsoleEdgeThresholdMin,
fxaaConsole360ConstDir );
result.color = colorSample;
}

View File

@ -0,0 +1,47 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position = vertex.position;
result.texcoord0 = vertex.texcoord;
}

283
base/renderprogs/global.inc Normal file
View File

@ -0,0 +1,283 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __RENDERPROGS_GLOBAL_INC_
#define __RENDERPROGS_GLOBAL_INC_ 1
uniform float4 rpScreenCorrectionFactor : register(c0);
uniform float4 rpWindowCoord : register(c1);
uniform float4 rpDiffuseModifier : register(c2);
uniform float4 rpSpecularModifier : register(c3);
uniform float4 rpLocalLightOrigin : register(c4);
uniform float4 rpLocalViewOrigin : register(c5);
uniform float4 rpLightProjectionS : register(c6);
uniform float4 rpLightProjectionT : register(c7);
uniform float4 rpLightProjectionQ : register(c8);
uniform float4 rpLightFalloffS : register(c9);
uniform float4 rpBumpMatrixS : register(c10);
uniform float4 rpBumpMatrixT : register(c11);
uniform float4 rpDiffuseMatrixS : register(c12);
uniform float4 rpDiffuseMatrixT : register(c13);
uniform float4 rpSpecularMatrixS : register(c14);
uniform float4 rpSpecularMatrixT : register(c15);
uniform float4 rpVertexColorModulate : register(c16);
uniform float4 rpVertexColorAdd : register(c17);
uniform float4 rpColor : register(c18);
uniform float4 rpViewOrigin : register(c19);
uniform float4 rpGlobalEyePos : register(c20);
uniform float4 rpMVPmatrixX : register(c21);
uniform float4 rpMVPmatrixY : register(c22);
uniform float4 rpMVPmatrixZ : register(c23);
uniform float4 rpMVPmatrixW : register(c24);
uniform float4 rpModelMatrixX : register(c25);
uniform float4 rpModelMatrixY : register(c26);
uniform float4 rpModelMatrixZ : register(c27);
uniform float4 rpModelMatrixW : register(c28);
uniform float4 rpProjectionMatrixX : register(c29);
uniform float4 rpProjectionMatrixY : register(c30);
uniform float4 rpProjectionMatrixZ : register(c31);
uniform float4 rpProjectionMatrixW : register(c32);
uniform float4 rpModelViewMatrixX : register(c33);
uniform float4 rpModelViewMatrixY : register(c34);
uniform float4 rpModelViewMatrixZ : register(c35);
uniform float4 rpModelViewMatrixW : register(c36);
uniform float4 rpTextureMatrixS : register(c37);
uniform float4 rpTextureMatrixT : register(c38);
uniform float4 rpTexGen0S : register(c39);
uniform float4 rpTexGen0T : register(c40);
uniform float4 rpTexGen0Q : register(c41);
uniform float4 rpTexGen0Enabled : register(c42);
uniform float4 rpTexGen1S : register(c43);
uniform float4 rpTexGen1T : register(c44);
uniform float4 rpTexGen1Q : register(c45);
uniform float4 rpTexGen1Enabled : register(c46);
uniform float4 rpWobbleSkyX : register(c47);
uniform float4 rpWobbleSkyY : register(c48);
uniform float4 rpWobbleSkyZ : register(c49);
uniform float4 rpOverbright : register(c50);
uniform float4 rpEnableSkinning : register(c51);
uniform float4 rpAlphaTest : register(c52);
uniform float4 rpAmbientColor : register(c53);
uniform float4 rpGlobalLightOrigin : register(c54);
uniform float4 rpJitterTexScale : register(c55);
uniform float4 rpJitterTexOffset : register(c56);
uniform float4 rpCascadeDistances : register(c57);
uniform float4 rpShadowMatrix0X : register(c58);
uniform float4 rpShadowMatrix0Y : register(c59);
uniform float4 rpShadowMatrix0Z : register(c60);
uniform float4 rpShadowMatrix0W : register(c61);
uniform float4 rpShadowMatrix1X : register(c62);
uniform float4 rpShadowMatrix1Y : register(c63);
uniform float4 rpShadowMatrix1Z : register(c64);
uniform float4 rpShadowMatrix1W : register(c65);
uniform float4 rpShadowMatrix2X : register(c66);
uniform float4 rpShadowMatrix2Y : register(c67);
uniform float4 rpShadowMatrix2Z : register(c68);
uniform float4 rpShadowMatrix2W : register(c69);
uniform float4 rpShadowMatrix3X : register(c70);
uniform float4 rpShadowMatrix3Y : register(c71);
uniform float4 rpShadowMatrix3Z : register(c72);
uniform float4 rpShadowMatrix3W : register(c73);
uniform float4 rpShadowMatrix4X : register(c74);
uniform float4 rpShadowMatrix4Y : register(c75);
uniform float4 rpShadowMatrix4Z : register(c76);
uniform float4 rpShadowMatrix4W : register(c77);
uniform float4 rpShadowMatrix5X : register(c78);
uniform float4 rpShadowMatrix5Y : register(c79);
uniform float4 rpShadowMatrix5Z : register(c80);
uniform float4 rpShadowMatrix5W : register(c81);
uniform float4 rpGlossMatrixS : register(c82);
uniform float4 rpGlossMatrixT : register(c83);
uniform float4 rpCubemapColorSpace : register(c84); // motorsep 05-18-2015
static float dot2( float2 a, float2 b ) { return dot( a, b ); }
static float dot3( float3 a, float3 b ) { return dot( a, b ); }
static float dot3( float3 a, float4 b ) { return dot( a, b.xyz ); }
static float dot3( float4 a, float3 b ) { return dot( a.xyz, b ); }
static float dot3( float4 a, float4 b ) { return dot( a.xyz, b.xyz ); }
static float dot4( float4 a, float4 b ) { return dot( a, b ); }
static float dot4( float2 a, float4 b ) { return dot( float4( a, 0, 1 ), b ); }
// ----------------------
// YCoCg Color Conversion
// ----------------------
static const half4 matrixRGB1toCoCg1YX = half4( 0.50, 0.0, -0.50, 0.50196078 ); // Co
static const half4 matrixRGB1toCoCg1YY = half4( -0.25, 0.5, -0.25, 0.50196078 ); // Cg
static const half4 matrixRGB1toCoCg1YZ = half4( 0.0, 0.0, 0.0, 1.0 ); // 1.0
static const half4 matrixRGB1toCoCg1YW = half4( 0.25, 0.5, 0.25, 0.0 ); // Y
static const half4 matrixCoCg1YtoRGB1X = half4( 1.0, -1.0, 0.0, 1.0 );
static const half4 matrixCoCg1YtoRGB1Y = half4( 0.0, 1.0, -0.50196078, 1.0 ); // -0.5 * 256.0 / 255.0
static const half4 matrixCoCg1YtoRGB1Z = half4( -1.0, -1.0, 1.00392156, 1.0 ); // +1.0 * 256.0 / 255.0
static const float4 matrixCoCg1YtoRGB1XFull = float4( 1.0, -1.0, 0.0, 1.0 );
static const float4 matrixCoCg1YtoRGB1YFull = float4( 0.0, 1.0, -0.50196078, 1.0 ); // -0.5 * 256.0 / 255.0
static const float4 matrixCoCg1YtoRGB1ZFull = float4( -1.0, -1.0, 1.00392156, 1.0 ); // +1.0 * 256.0 / 255.0
static half3 ConvertYCoCgToRGB( half4 YCoCg ) {
half3 rgbColor;
YCoCg.z = ( YCoCg.z * 31.875 ) + 1.0; //z = z * 255.0/8.0 + 1.0
YCoCg.z = 1.0 / YCoCg.z;
YCoCg.xy *= YCoCg.z;
rgbColor.x = dot4( YCoCg, matrixCoCg1YtoRGB1X );
rgbColor.y = dot4( YCoCg, matrixCoCg1YtoRGB1Y );
rgbColor.z = dot4( YCoCg, matrixCoCg1YtoRGB1Z );
// rgbColor.xyz = pow(rgbColor.xyz, 2.4); // foresthale 2014-02-20: r_useSRGB needs this addition
return rgbColor;
}
static float4 ConvertYCoCgToRGBFull( float4 YCoCg ) {
float4 rgbColor;
YCoCg.z = ( YCoCg.z * 31.875 ) + 1.0; //z = z * 255.0/8.0 + 1.0
YCoCg.z = 1.0 / YCoCg.z;
YCoCg.xy *= YCoCg.z;
rgbColor.x = dot4( YCoCg, matrixCoCg1YtoRGB1XFull );
rgbColor.y = dot4( YCoCg, matrixCoCg1YtoRGB1YFull );
rgbColor.z = dot4( YCoCg, matrixCoCg1YtoRGB1ZFull );
rgbColor.w = 1.0;
// rgbColor.xyz = pow(rgbColor.xyz, 2.4); // foresthale 2014-02-20: r_useSRGB needs this addition
return rgbColor;
}
static float2 CenterScale( float2 inTC, float2 centerScale ) {
float scaleX = centerScale.x;
float scaleY = centerScale.y;
float4 tc0 = float4( scaleX, 0, 0, 0.5 - ( 0.5f * scaleX ) );
float4 tc1 = float4( 0, scaleY, 0, 0.5 - ( 0.5f * scaleY ) );
float2 finalTC;
finalTC.x = dot4( inTC, tc0 );
finalTC.y = dot4( inTC, tc1 );
return finalTC;
}
static float2 Rotate2D( float2 inTC, float2 cs ) {
float sinValue = cs.y;
float cosValue = cs.x;
float4 tc0 = float4( cosValue, -sinValue, 0, ( -0.5f * cosValue ) + ( 0.5f * sinValue ) + 0.5f );
float4 tc1 = float4( sinValue, cosValue, 0, ( -0.5f * sinValue ) + ( -0.5f * cosValue ) + 0.5f );
float2 finalTC;
finalTC.x = dot4( inTC, tc0 );
finalTC.y = dot4( inTC, tc1 );
return finalTC;
}
// better noise function available at https://github.com/ashima/webgl-noise
float rand( float2 co ) {
return frac( sin( dot( co.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 );
}
#ifndef PI
#define PI 3.14159265358979323846
#endif
#define DEG2RAD( a ) ( ( a ) * PI / 180.0f )
#define RAD2DEG( a ) ( ( a ) * 180.0f / PI )
// ---> sikk - Linear Space Lighting
half3 SrgbToLinear( half3 val ) {
half3 ret = val;
// half scale = max( max( max( val.x, val.y ), val.z ), 1.0 );
// ret *= ( 1.0 / scale );
if ( ret.x <= 0.0f ) ret.x = 0.0f;
else if ( ret.x <= 0.04045f ) ret.x = ret.x / 12.92f;
else ret.x = pow( ( ret.x + 0.055f ) / 1.055f, 2.4f );
if ( ret.y <= 0.0f ) ret.y = 0.0f;
else if ( ret.y <= 0.04045f ) ret.y = ret.y / 12.92f;
else ret.y = pow( ( ret.y + 0.055f ) / 1.055f, 2.4f );
if ( ret.z <= 0.0f ) ret.z = 0.0f;
else if ( ret.z <= 0.04045f ) ret.z = ret.z / 12.92f;
else ret.z = pow( ( ret.z + 0.055f ) / 1.055f, 2.4f );
// ret *= scale;
return ret;
}
half3 LinearToSrgb( half3 val ) {
half3 ret = val;
if ( val.x <= 0.0f ) ret.x = 0.0f;
else if ( val.x <= 0.0031308f ) ret.x = val.x * 12.92f;
else ret.x = pow( val.x, 0.41666f ) * 1.055f - 0.055f;
if ( val.y <= 0.0f ) ret.y = 0.0f;
else if ( val.y <= 0.0031308f ) ret.y = val.y * 12.92f;
else ret.y = pow( val.y, 0.41666f ) * 1.055f - 0.055f;
if ( val.z <= 0.0f ) ret.z = 0.0f;
else if ( val.z <= 0.0031308f ) ret.z = val.z * 12.92f;
else ret.z = pow( val.z, 0.41666f ) * 1.055f - 0.055f;
return ret;
}
// <--- sikk - Linear Space Lighting
#define _half2( x ) half2( x )
#define _half3( x ) half3( x )
#define _half4( x ) half4( x )
#define _float2( x ) float2( x )
#define _float3( x ) float3( x )
#define _float4( x ) float4( x )
#define VPOS WPOS
static float4 idtex2Dproj( sampler2D samp, float4 texCoords ) { return tex2Dproj( samp, texCoords.xyw ); }
static float4 swizzleColor( float4 c ) { return c; }
static float2 vposToScreenPosTexCoord( float2 vpos ) { return vpos.xy * rpWindowCoord.xy + rpWindowCoord.zw; }
#define BRANCH
#define IFANY
#endif

View File

@ -0,0 +1,48 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 color = ( tex2D( samp0, fragment.texcoord0 ) * fragment.color ) + fragment.texcoord1;
result.color.xyz = color.xyz * color.w;
result.color.w = color.w;
}

View File

@ -0,0 +1,57 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0.xy = vertex.texcoord.xy;
result.texcoord1 = ( swizzleColor( vertex.color2 ) * 2 ) - 1;
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( swizzleColor( vertex.color ) );
}

View File

@ -0,0 +1,48 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-02-21: HDR blit to screen with dithering (based on postProcess.pixel)
#include "global.inc"
uniform sampler2D samp0 : register(s0);
uniform sampler2D samp1 : register(s1);
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float2 tCoords = fragment.texcoord0;
result.color = tex2D( samp0, tCoords ) + tex2D( samp1, gl_FragCoord.xy * vec2(0.25, 0.25)) * float4(1.0 / 128.0, 1.0 / 128.0, 1.0 / 128.0, 0.0);
}

View File

@ -0,0 +1,54 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-02-21: HDR blit to screen with dithering (based on postProcess.vertex)
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position = vertex.position;
//result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );
//result.position.y = dot4( vertex.position, rpMVPmatrixY );
//result.position.z = dot4( vertex.position, rpMVPmatrixZ );
//result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0 = vertex.texcoord * rpScreenCorrectionFactor.xy + rpScreenCorrectionFactor.zw;
}

View File

@ -0,0 +1,51 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-04-08: HDR blit to screen with dithering and glow (based on hdrDither.pixel)
#include "global.inc"
uniform sampler2D samp0 : register(s0);
uniform sampler2D samp1 : register(s1);
uniform sampler2D samp2 : register(s2);
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float2 tCoords = fragment.texcoord0.xy;
float2 tCoordsGlow = fragment.texcoord0.zw;
float3 glow = tex2D( samp2, tCoordsGlow ).xyz * rpDiffuseModifier.x;
result.color = tex2D( samp0, tCoords ) + float4(glow, 0.0) + tex2D( samp1, gl_FragCoord.xy * vec2(0.25, 0.25)) * float4(1.0 / 128.0, 1.0 / 128.0, 1.0 / 128.0, 0.0);
}

View File

@ -0,0 +1,55 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-02-21: HDR blit to screen with dithering (based on postProcess.vertex)
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position = vertex.position;
//result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );
//result.position.y = dot4( vertex.position, rpMVPmatrixY );
//result.position.z = dot4( vertex.position, rpMVPmatrixZ );
//result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0.xy = vertex.texcoord * rpScreenCorrectionFactor.xy + rpScreenCorrectionFactor.zw;
result.texcoord0.zw = vertex.texcoord * rpLightProjectionS.xy + rpLightProjectionS.zw;
}

View File

@ -0,0 +1,68 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-04-21: directional blur (based on hdrGlowDownscale.pixel)
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
float4 texcoord3 : TEXCOORD3_centroid;
float4 texcoord4 : TEXCOORD4_centroid;
float4 texcoord5 : TEXCOORD5_centroid;
float4 texcoord6 : TEXCOORD6_centroid;
float4 texcoord7 : TEXCOORD7_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float4 tCoords0 = fragment.texcoord0;
float4 tCoords1 = fragment.texcoord1;
float4 tCoords2 = fragment.texcoord2;
float4 tCoords3 = fragment.texcoord3;
float4 tCoords4 = fragment.texcoord4;
float4 tCoords5 = fragment.texcoord5;
float4 tCoords6 = fragment.texcoord6;
float4 tCoords7 = fragment.texcoord7;
result.color = ((tex2D( samp0, tCoords0.xy ) + tex2D( samp0, tCoords0.zw )) * 1.6
+ (tex2D( samp0, tCoords1.xy ) + tex2D( samp0, tCoords1.zw )) * 1.1
+ (tex2D( samp0, tCoords2.xy ) + tex2D( samp0, tCoords2.zw )) * 0.8
+ (tex2D( samp0, tCoords3.xy ) + tex2D( samp0, tCoords3.zw )) * 0.6
+ (tex2D( samp0, tCoords4.xy ) + tex2D( samp0, tCoords4.zw )) * 0.5
+ (tex2D( samp0, tCoords5.xy ) + tex2D( samp0, tCoords5.zw )) * 0.3
+ (tex2D( samp0, tCoords6.xy ) + tex2D( samp0, tCoords6.zw )) * 0.2
+ (tex2D( samp0, tCoords7.xy ) + tex2D( samp0, tCoords7.zw )) * 0.1) * 0.17857;
}

View File

@ -0,0 +1,71 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-04-21: directional blur (based on hdrGlowDownscale.vertex)
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
float4 texcoord6 : TEXCOORD6;
float4 texcoord7 : TEXCOORD7;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position = vertex.position;
// foresthale: pack the positions we'll be fetching into texcoords
// rpDiffuseModifier.xy is the positive direction, rpDiffuseModifier.zw is
// the negative direction, the same pixel stepping works for both, so we
// do it all as float4 math, we could calculate these in the pixel shader
// but interpolants generally have better texture fetch latency
float2 tCoords = vertex.texcoord * rpScreenCorrectionFactor.xy + rpScreenCorrectionFactor.zw;
float4 tCoords4 = tCoords.xyxy;
result.texcoord0 = tCoords4 + rpDiffuseModifier * 1.0;
result.texcoord1 = tCoords4 + rpDiffuseModifier * 2.5;
result.texcoord2 = tCoords4 + rpDiffuseModifier * 4.5;
result.texcoord3 = tCoords4 + rpDiffuseModifier * 6.5;
result.texcoord4 = tCoords4 + rpDiffuseModifier * 8.5;
result.texcoord5 = tCoords4 + rpDiffuseModifier * 10.5;
result.texcoord6 = tCoords4 + rpDiffuseModifier * 12.5;
result.texcoord7 = tCoords4 + rpDiffuseModifier * 14.5;
}

View File

@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-04-21: downscale to make the glow image (based on hdrDither.pixel)
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
float2 texcoord1 : TEXCOORD1_centroid;
float2 texcoord2 : TEXCOORD2_centroid;
float2 texcoord3 : TEXCOORD3_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float2 tCoords0 = fragment.texcoord0;
float2 tCoords1 = fragment.texcoord1;
float2 tCoords2 = fragment.texcoord2;
float2 tCoords3 = fragment.texcoord3;
result.color = (tex2D( samp0, tCoords0 )
+ tex2D( samp0, tCoords1 )
+ tex2D( samp0, tCoords2 )
+ tex2D( samp0, tCoords3 )) * 0.25;
}

View File

@ -0,0 +1,57 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// foresthale 2014-04-21: downscale to make the glow image (based on hdrDither.vertex)
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
float2 texcoord2 : TEXCOORD2;
float2 texcoord3 : TEXCOORD3;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position = vertex.position;
float2 tCoords = vertex.texcoord * rpScreenCorrectionFactor.xy + rpScreenCorrectionFactor.zw;
result.texcoord0 = tCoords + rpDiffuseModifier.xy;
result.texcoord1 = tCoords + rpDiffuseModifier.zy;
result.texcoord2 = tCoords + rpDiffuseModifier.xw;
result.texcoord3 = tCoords + rpDiffuseModifier.zw;
}

View File

@ -0,0 +1,57 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
// load the filtered normal map and convert to -1 to 1 range
float4 bumpMap = ( tex2D( samp1, fragment.texcoord0.xy ) * 2.0f ) - 1.0f;
float2 localNormal = bumpMap.wy;
// calculate the screen texcoord in the 0.0 to 1.0 range
float2 screenTexCoord = vposToScreenPosTexCoord( fragment.position.xy );
screenTexCoord += ( localNormal * fragment.texcoord1.xy );
screenTexCoord = saturate( screenTexCoord );
// load the screen render
result.color = tex2D( samp0, screenTexCoord.xy );
}

View File

@ -0,0 +1,82 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// User Renderparms start at 128 as per renderprogs.h
uniform float4 rpUser0 : register(c128); // rpScroll
uniform float4 rpUser1 : register(c129); // rpDeformMagnitude
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
//texture 0 takes the texture coordinates and adds a scroll
const float4 textureScroll = rpUser0;
result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 ) + textureScroll;
//texture 1 takes the deform magnitude and scales it by the projection distance
float4 vec = float4( 0, 1, 0, 1 );
vec.z = dot4( modelPosition, rpModelViewMatrixZ ); // this is the modelview matrix
// magicProjectionAdjust is a magic scalar that scales the projection since we changed from
// using the X axis to the Y axis to calculate x. It is an approximation to closely match
// what the original game did
const float magicProjectionAdjust = 0.43f;
float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
float w = dot4( vec, rpProjectionMatrixW );
//don't let the recip get near zero for polygons that cross the view plane
w = max( w, 1.0 );
x /= w;
//x = x * ( 1.0f / w );
// clamp the distance so the the deformations don't get too wacky near the view
x = min( x, 0.02 );
const float4 deformMagnitude = rpUser1;
result.texcoord1 = x * deformMagnitude;
}

View File

@ -0,0 +1,66 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
// load the distortion map
float4 mask = tex2D( samp2, fragment.texcoord0.xy );
// kill the pixel if the distortion wound up being very small
mask.xy -= 0.01f;
clip( mask );
// load the filtered normal map and convert to -1 to 1 range
float4 bumpMap = ( tex2D( samp1, fragment.texcoord1.xy ) * 2.0f ) - 1.0f;
float2 localNormal = bumpMap.wy;
localNormal *= mask.xy;
// calculate the screen texcoord in the 0.0 to 1.0 range
float2 screenTexCoord = vposToScreenPosTexCoord( fragment.position.xy );
screenTexCoord += ( localNormal * fragment.texcoord2.xy );
screenTexCoord = saturate( screenTexCoord );
result.color = tex2D( samp0, screenTexCoord );
}

View File

@ -0,0 +1,84 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
uniform float4 rpUser0 : register(c128); // rpScroll
uniform float4 rpUser1 : register(c129); // rpDeformMagnitude
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
// texture 0 takes the texture coordinates unmodified
result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 );
// texture 1 takes the texture coordinates and adds a scroll
const float4 textureScroll = rpUser0;
result.texcoord1 = float4( vertex.texcoord.xy, 0, 0 ) + textureScroll;
// texture 2 takes the deform magnitude and scales it by the projection distance
float4 vec = float4( 0, 1, 0, 1 );
vec.z = dot4( modelPosition, rpModelViewMatrixZ );
// magicProjectionAdjust is a magic scalar that scales the projection since we changed from
// using the X axis to the Y axis to calculate R1. It is an approximation to closely match
// what the original game did
const float magicProjectionAdjust = 0.43f;
float x = dot4 ( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
float w = dot4 ( vec, rpProjectionMatrixW );
// don't let the recip get near zero for polygons that cross the view plane
w = max( w, 1.0 );
x /= w;
//x = x * ( 1.0f / ( w + 0.00001f ) );
// clamp the distance so the the deformations don't get too wacky near the view
x = min( x, 0.02 );
const float4 deformMagnitude = rpUser1;
result.texcoord2 = x * deformMagnitude;
}

View File

@ -0,0 +1,88 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture
uniform sampler2D samp3 : register(s3); // texture 3 is the _current Depth
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
// load the distortion map
float4 mask = tex2D( samp2, fragment.texcoord0.xy );
// kill the pixel if the distortion wound up being very small
mask.xy *= fragment.color.xy;
mask.xy -= 0.01f;
clip( mask );
// load the filtered normal map and convert to -1 to 1 range
float4 bumpMap = ( tex2D( samp1, fragment.texcoord1.xy ) * 2.0f ) - 1.0f;
float2 localNormal = bumpMap.wy;
localNormal *= mask.xy;
// calculate the screen texcoord in the 0.0 to 1.0 range
float2 screenTexCoord = vposToScreenPosTexCoord( fragment.position.xy );
float2 origCoord = screenTexCoord;
screenTexCoord += ( localNormal * fragment.texcoord2.xy );
screenTexCoord = saturate( screenTexCoord );
float2 altCoord = screenTexCoord - origCoord;
altCoord = origCoord - altCoord;
// load the distorted color
result.color = tex2D( samp0, origCoord.xy );
//load the depth
float4 d = tex2D( samp3, altCoord.xy );
if(d.x > fragment.position.z)
{
result.color = tex2D( samp0, altCoord.xy );
}
d = tex2D( samp3, screenTexCoord.xy );
if(d.x > fragment.position.z)
{
result.color = tex2D( samp0, screenTexCoord.xy );
}
}

View File

@ -0,0 +1,87 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
uniform float4 rpUser0 : register(c128); // rpScroll
uniform float4 rpUser1 : register(c129); // rpDeformMagnitude
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
// texture 0 takes the texture coordinates unmodified
result.texcoord0 = float4( vertex.texcoord, 0 , 0 );
// texture 1 takes the texture coordinates and adds a scroll
const float4 textureScroll = rpUser0;
result.texcoord1 = float4( vertex.texcoord, 0, 0 ) + textureScroll;
// texture 2 takes the deform magnitude and scales it by the projection distance
float4 vec = float4( 0, 1, 0, 1 );
vec.z = dot4( modelPosition, rpModelViewMatrixZ );
// magicProjectionAdjust is a magic scalar that scales the projection since we changed from
// using the X axis to the Y axis to calculate x. It is an approximation to closely match
// what the original game did
const float magicProjectionAdjust = 0.43f;
float x = dot4 ( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
float w = dot4( vec, rpProjectionMatrixW );
// don't let the recip get near zero for polygons that cross the view plane
w = max( w, 1.0f );
x /= w;
//x = x * ( 1.0f / w );
// clamp the distance so the the deformations don't get too wacky near the view
x = min( x, 0.02f );
const float4 deformMagnitude = rpUser1;
result.texcoord2 = x * deformMagnitude;
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( swizzleColor( vertex.color ) );
}

View File

@ -0,0 +1,76 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
uniform sampler2D samp2 : register(s2); // texture 2 is the _current Depth
struct PS_IN {
float4 position : VPOS;
float4 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
// load the filtered normal map and convert to -1 to 1 range
float4 bumpMap = ( tex2D( samp1, fragment.texcoord0.xy ) * 2.0f ) - 1.0f;
float2 localNormal = bumpMap.wy;
// calculate the screen texcoord in the 0.0 to 1.0 range
float2 screenTexCoord = vposToScreenPosTexCoord( fragment.position.xy );
float2 origCoord = screenTexCoord;
screenTexCoord += ( localNormal * fragment.texcoord1.xy );
screenTexCoord = saturate( screenTexCoord );
float2 altCoord = screenTexCoord - origCoord;
altCoord = origCoord - altCoord;
// load the distorted color
result.color = tex2D( samp0, origCoord.xy );
//load the depth
float4 d = tex2D( samp2, altCoord.xy );
if(d.x > fragment.position.z)
{
result.color = tex2D( samp0, altCoord.xy );
}
d = tex2D( samp2, screenTexCoord.xy );
if(d.x > fragment.position.z)
{
result.color = tex2D( samp0, screenTexCoord.xy );
}
}

View File

@ -0,0 +1,82 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// User Renderparms start at 128 as per renderprogs.h
uniform float4 rpUser0 : register(c128); // rpScroll
uniform float4 rpUser1 : register(c129); // rpDeformMagnitude
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
//texture 0 takes the texture coordinates and adds a scroll
const float4 textureScroll = rpUser0;
result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 ) + textureScroll;
//texture 1 takes the deform magnitude and scales it by the projection distance
float4 vec = float4( 0, 1, 0, 1 );
vec.z = dot4( modelPosition, rpModelViewMatrixZ ); // this is the modelview matrix
// magicProjectionAdjust is a magic scalar that scales the projection since we changed from
// using the X axis to the Y axis to calculate x. It is an approximation to closely match
// what the original game did
const float magicProjectionAdjust = 0.43f;
float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
float w = dot4( vec, rpProjectionMatrixW );
//don't let the recip get near zero for polygons that cross the view plane
w = max( w, 1.0 );
x /= w;
//x = x * ( 1.0f / w );
// clamp the distance so the the deformations don't get too wacky near the view
x = min( x, 0.02 );
const float4 deformMagnitude = rpUser1;
result.texcoord1 = x * deformMagnitude;
}

View File

@ -0,0 +1,118 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D depthImage : register(s0); // texture 0 is _currentDepth
struct PS_IN {
float4 position : VPOS;
float4 genParms0 : TEXCOORD0_centroid;
float4 genParms1 : TEXCOORD1_centroid;
float4 genParms2 : TEXCOORD2_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
float linearizeDepth( float inDepth ) {
float
zNear = 3.0,
zFar = 3000.0;
float
zN = 2.0 * inDepth - 1.0;
return 2.0 * zNear * zFar / ( zFar + zNear - zN * (zFar - zNear));
}
float
GetDepth( sampler2D tex, float2 uv ) {
return tex2D( tex, uv ).x;
}
float
GetLinearDepth( sampler2D tex, float2 uv ) {
return linearizeDepth( GetDepth( tex, uv ));
}
float
InkTestSimple3( float sample1, float sample2, float sample3 ) {
return saturate( ( sample3 - sample2 ) - ( sample2 - sample1 ));
}
float
inkSimple( float2 basePos, float3 inkParms ) {
float3
sampleDir = float3( 1.0, 0.0, -1.0 );
float
baseSample = GetDepth( depthImage, basePos );
float2
sampleSize = rpWindowCoord.xy * inkParms.x; // rpWindowCoord essentially holds pixel-extents
float
samples[8];
// get samples
samples[0] = GetDepth( depthImage, sampleDir.xx * sampleSize + basePos );
samples[1] = GetDepth( depthImage, sampleDir.xy * sampleSize + basePos );
samples[2] = GetDepth( depthImage, sampleDir.xz * sampleSize + basePos );
samples[3] = GetDepth( depthImage, sampleDir.yx * sampleSize + basePos );
samples[4] = GetDepth( depthImage, sampleDir.yz * sampleSize + basePos );
samples[5] = GetDepth( depthImage, sampleDir.zx * sampleSize + basePos );
samples[6] = GetDepth( depthImage, sampleDir.zy * sampleSize + basePos );
samples[7] = GetDepth( depthImage, sampleDir.zz * sampleSize + basePos );
// simple naive ink
float
s1 = InkTestSimple3( samples[6], baseSample, samples[1] ),
s2 = InkTestSimple3( samples[3], baseSample, samples[4] ),
s3 = InkTestSimple3( samples[5], baseSample, samples[2] ),
s4 = InkTestSimple3( samples[7], baseSample, samples[0] );
return 1.0 - saturate((( s1 + s2 + s3 + s4 ) * 0.25 ) * inkParms.y + inkParms.z );
}
void main( PS_IN fragment, out PS_OUT result ) {
float2
basePos = vposToScreenPosTexCoord( fragment.position.xy );
float
linDepth = GetLinearDepth( depthImage, basePos ),
parmLerp = saturate( linDepth * fragment.genParms0.y + fragment.genParms0.z );
float3
iParms = lerp( fragment.genParms1.xyz, fragment.genParms2.xyz, parmLerp );
float
inkValue = lerp( 1.0, inkSimple( basePos, iParms ), fragment.genParms0.x );
float4
outColor;
outColor.xyz = float3( inkValue );
outColor.a = 1.0;
result.color = outColor;
}

View File

@ -0,0 +1,61 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// User Renderparms start at 128 as per renderprogs.h
uniform float4 rpUser0 : register(c128);
uniform float4 rpUser1 : register(c129);
uniform float4 rpUser2 : register(c130);
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 genParms0 : TEXCOORD0;
float4 genParms1 : TEXCOORD1;
float4 genParms2 : TEXCOORD2;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
result.genParms0 = rpUser0; // inkAmount, rangeScale, rangeBias
result.genParms1 = rpUser1; // inkSize, inkScale, inkBias (near)
result.genParms2 = rpUser2; // inkSize, inkScale, inkBias (far)
}

View File

@ -0,0 +1,118 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D depthImage : register(s0); // texture 0 is _currentDepth
struct PS_IN {
float4 position : VPOS;
float4 genParms0 : TEXCOORD0_centroid;
float4 genParms1 : TEXCOORD1_centroid;
float4 genParms2 : TEXCOORD2_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
float linearizeDepth( float inDepth ) {
float
zNear = 3.0,
zFar = 3000.0;
float
zN = 2.0 * inDepth - 1.0;
return 2.0 * zNear * zFar / ( zFar + zNear - zN * (zFar - zNear));
}
float
GetDepth( sampler2D tex, float2 uv ) {
return tex2D( tex, uv ).x;
}
float
GetLinearDepth( sampler2D tex, float2 uv ) {
return linearizeDepth( GetDepth( tex, uv ));
}
float
InkTestSimple3( float sample1, float sample2, float sample3 ) {
return saturate( ( sample3 - sample2 ) - ( sample2 - sample1 ));
}
float
inkSimple( float2 basePos, float3 inkParms ) {
float3
sampleDir = float3( 1.0, 0.0, -1.0 );
float
baseSample = GetDepth( depthImage, basePos );
float2
sampleSize = rpWindowCoord.xy * inkParms.x; // rpWindowCoord essentially holds pixel-extents
float
samples[8];
// get samples
samples[0] = GetDepth( depthImage, sampleDir.xx * sampleSize + basePos );
samples[1] = GetDepth( depthImage, sampleDir.xy * sampleSize + basePos );
samples[2] = GetDepth( depthImage, sampleDir.xz * sampleSize + basePos );
samples[3] = GetDepth( depthImage, sampleDir.yx * sampleSize + basePos );
samples[4] = GetDepth( depthImage, sampleDir.yz * sampleSize + basePos );
samples[5] = GetDepth( depthImage, sampleDir.zx * sampleSize + basePos );
samples[6] = GetDepth( depthImage, sampleDir.zy * sampleSize + basePos );
samples[7] = GetDepth( depthImage, sampleDir.zz * sampleSize + basePos );
// simple naive ink
float
s1 = InkTestSimple3( samples[6], baseSample, samples[1] ),
s2 = InkTestSimple3( samples[3], baseSample, samples[4] ),
s3 = InkTestSimple3( samples[5], baseSample, samples[2] ),
s4 = InkTestSimple3( samples[7], baseSample, samples[0] );
return 1.0 - saturate((( s1 + s2 + s3 + s4 ) * 0.25 ) * inkParms.y + inkParms.z );
}
void main( PS_IN fragment, out PS_OUT result ) {
float2
basePos = vposToScreenPosTexCoord( fragment.position.xy );
float
linDepth = GetLinearDepth( depthImage, basePos ),
parmLerp = saturate( linDepth * fragment.genParms0.y + fragment.genParms0.z );
float3
iParms = lerp( fragment.genParms1.xyz, fragment.genParms2.xyz, parmLerp );
float
inkValue = lerp( 1.0, inkSimple( basePos, iParms ), fragment.genParms0.x );
float4
outColor;
outColor.xyz = float3( inkValue );
outColor.a = 1.0;
result.color = outColor;
}

View File

@ -0,0 +1,61 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// User Renderparms start at 128 as per renderprogs.h
uniform float4 rpUser0 : register(c128);
uniform float4 rpUser1 : register(c129);
uniform float4 rpUser2 : register(c130);
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 genParms0 : TEXCOORD0;
float4 genParms1 : TEXCOORD1;
float4 genParms2 : TEXCOORD2;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
result.genParms0 = rpUser0; // inkAmount, rangeScale, rangeBias
result.genParms1 = rpUser1; // inkSize, inkScale, inkBias (near)
result.genParms2 = rpUser2; // inkSize, inkScale, inkBias (far)
}

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
//#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
//#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// tweak to adjust the simple ambient shading ( both values should normally add up to 1.0 )
const half ambientScale = 0.4;
const half ambientBias = 0.6;
uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map
uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture
uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture
uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map
uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map
struct PS_IN {
half4 position : VPOS;
half4 texcoord1 : TEXCOORD1_centroid;
half4 texcoord2 : TEXCOORD2_centroid;
half4 texcoord3 : TEXCOORD3_centroid;
half4 texcoord4 : TEXCOORD4_centroid;
half4 texcoord5 : TEXCOORD5_centroid;
half4 texcoord6 : TEXCOORD6_centroid;
half4 color : COLOR0;
};
struct PS_OUT {
half4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );
half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );
half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );
half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
half3 localNormal;
localNormal.xy = bumpMap.wy - 0.5;
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
localNormal = normalize( localNormal );
half vDotN = saturate( dot3( normalize( fragment.texcoord6.xyz ), localNormal ));
half3 diffuseColor = diffuseMap * rpDiffuseModifier.xyz;
half ambientShade = vDotN * ambientScale + ambientBias;
half3 lightColor = ambientShade * lightProj.xyz * lightFalloff.xyz;
result.color.xyz = ( diffuseColor ) * lightColor * fragment.color.xyz;
result.color.w = 1.0;
}

View File

@ -0,0 +1,108 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
float4 texcoord6 : TEXCOORD6;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
float4 normal = vertex.normal * 2.0 - 1.0;
float4 tangent = vertex.tangent * 2.0 - 1.0;
float3 binormal = cross( normal.xyz, tangent.xyz ) * tangent.w;
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
//calculate vector to light in R0
float4 toLight = rpLocalLightOrigin - vertex.position;
//textures 1 takes the base coordinates by the texture matrix
result.texcoord1 = defaultTexCoord;
result.texcoord1.x = dot4( vertex.texcoord.xy, rpBumpMatrixS );
result.texcoord1.y = dot4( vertex.texcoord.xy, rpBumpMatrixT );
//# texture 2 has one texgen
result.texcoord2 = defaultTexCoord;
result.texcoord2.x = dot4( vertex.position, rpLightFalloffS );
//# texture 3 has three texgens
result.texcoord3.x = dot4( vertex.position, rpLightProjectionS );
result.texcoord3.y = dot4( vertex.position, rpLightProjectionT );
result.texcoord3.z = 0.0f;
result.texcoord3.w = dot4( vertex.position, rpLightProjectionQ );
//# textures 4 takes the base coordinates by the texture matrix
result.texcoord4 = defaultTexCoord;
result.texcoord4.x = dot4( vertex.texcoord.xy, rpDiffuseMatrixS );
result.texcoord4.y = dot4( vertex.texcoord.xy, rpDiffuseMatrixT );
//# textures 5 takes the base coordinates by the texture matrix
result.texcoord5 = defaultTexCoord;
result.texcoord5.x = dot4( vertex.texcoord.xy, rpSpecularMatrixS );
result.texcoord5.y = dot4( vertex.texcoord.xy, rpSpecularMatrixT );
//# texture 6's texcoords will be the halfangle in texture space
//# calculate normalized vector to viewer in R1
float4 toView = rpLocalViewOrigin - vertex.position;
//# put into texture space
result.texcoord6.x = dot3( tangent, toView );
result.texcoord6.y = dot3( binormal, toView );
result.texcoord6.z = dot3( normal, toView );
result.texcoord6.w = 1.0f;
//# generate the vertex color, which can be 1.0, color, or 1.0 - color
//# for 1.0 : env[16] = 0, env[17] = 1
//# for color : env[16] = 1, env[17] = 0
//# for 1.0-color : env[16] = -1, env[17] = 1
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd );
}

View File

@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// tweak to adjust the simple ambient shading ( both values should normally add up to 1.0 )
const half ambientScale = 0.4;
const half ambientBias = 0.6;
uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map
uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture
uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture
uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map
uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map
struct PS_IN {
half4 position : VPOS;
half4 texcoord1 : TEXCOORD1_centroid;
half4 texcoord2 : TEXCOORD2_centroid;
half4 texcoord3 : TEXCOORD3_centroid;
half4 texcoord4 : TEXCOORD4_centroid;
half4 texcoord5 : TEXCOORD5_centroid;
half4 texcoord6 : TEXCOORD6_centroid;
half4 color : COLOR0;
};
struct PS_OUT {
half4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );
half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );
half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );
half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
half3 localNormal;
localNormal.xy = bumpMap.wy - 0.5;
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
localNormal = normalize( localNormal );
half vDotN = saturate( dot3( normalize( fragment.texcoord6.xyz ), localNormal ));
half3 diffuseColor = diffuseMap * rpDiffuseModifier.xyz;
half ambientShade = vDotN * ambientScale + ambientBias;
half3 lightColor = ambientShade * lightProj.xyz * lightFalloff.xyz;
result.color.xyz = ( diffuseColor ) * lightColor * fragment.color.xyz;
result.color.w = 1.0;
}

View File

@ -0,0 +1,161 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
float4 texcoord6 : TEXCOORD6;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
float4 vNormal = vertex.normal * 2.0 - 1.0;
float4 vTangent = vertex.tangent * 2.0 - 1.0;
float3 vBinormal = cross( vNormal.xyz, vTangent.xyz ) * vTangent.w;
//--------------------------------------------------------------
// GPU transformation of the normal / binormal / bitangent
//
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
//--------------------------------------------------------------
const float w0 = vertex.color2.x;
const float w1 = vertex.color2.y;
const float w2 = vertex.color2.z;
const float w3 = vertex.color2.w;
float4 matX, matY, matZ; // must be float4 for vec4
float joint = vertex.color.x * 255.1 * 3;
matX = matrices[int(joint+0)] * w0;
matY = matrices[int(joint+1)] * w0;
matZ = matrices[int(joint+2)] * w0;
joint = vertex.color.y * 255.1 * 3;
matX += matrices[int(joint+0)] * w1;
matY += matrices[int(joint+1)] * w1;
matZ += matrices[int(joint+2)] * w1;
joint = vertex.color.z * 255.1 * 3;
matX += matrices[int(joint+0)] * w2;
matY += matrices[int(joint+1)] * w2;
matZ += matrices[int(joint+2)] * w2;
joint = vertex.color.w * 255.1 * 3;
matX += matrices[int(joint+0)] * w3;
matY += matrices[int(joint+1)] * w3;
matZ += matrices[int(joint+2)] * w3;
float3 normal;
normal.x = dot3( matX, vNormal );
normal.y = dot3( matY, vNormal );
normal.z = dot3( matZ, vNormal );
normal = normalize( normal );
float3 tangent;
tangent.x = dot3( matX, vTangent );
tangent.y = dot3( matY, vTangent );
tangent.z = dot3( matZ, vTangent );
tangent = normalize( tangent );
float3 binormal;
binormal.x = dot3( matX, vBinormal );
binormal.y = dot3( matY, vBinormal );
binormal.z = dot3( matZ, vBinormal );
binormal = normalize( binormal );
float4 modelPosition;
modelPosition.x = dot4( matX, vertex.position );
modelPosition.y = dot4( matY, vertex.position );
modelPosition.z = dot4( matZ, vertex.position );
modelPosition.w = 1.0;
result.position.x = dot4( modelPosition, rpMVPmatrixX );
result.position.y = dot4( modelPosition, rpMVPmatrixY );
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
result.position.w = dot4( modelPosition, rpMVPmatrixW );
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
//textures 1 takes the base coordinates by the texture matrix
result.texcoord1 = defaultTexCoord;
result.texcoord1.x = dot4( vertex.texcoord.xy, rpBumpMatrixS );
result.texcoord1.y = dot4( vertex.texcoord.xy, rpBumpMatrixT );
//# texture 2 has one texgen
result.texcoord2 = defaultTexCoord;
result.texcoord2.x = dot4( modelPosition, rpLightFalloffS );
//# texture 3 has three texgens
result.texcoord3.x = dot4( modelPosition, rpLightProjectionS );
result.texcoord3.y = dot4( modelPosition, rpLightProjectionT );
result.texcoord3.z = 0.0f;
result.texcoord3.w = dot4( modelPosition, rpLightProjectionQ );
//# textures 4 takes the base coordinates by the texture matrix
result.texcoord4 = defaultTexCoord;
result.texcoord4.x = dot4( vertex.texcoord.xy, rpDiffuseMatrixS );
result.texcoord4.y = dot4( vertex.texcoord.xy, rpDiffuseMatrixT );
//# textures 5 takes the base coordinates by the texture matrix
result.texcoord5 = defaultTexCoord;
result.texcoord5.x = dot4( vertex.texcoord.xy, rpSpecularMatrixS );
result.texcoord5.y = dot4( vertex.texcoord.xy, rpSpecularMatrixT );
//# texture 6's texcoords will be the halfangle in texture space
//# calculate vector to viewer in R1
float3 toView = rpLocalViewOrigin.xyz - modelPosition.xyz;
//# put into texture space
result.texcoord6.x = dot3( tangent, toView );
result.texcoord6.y = dot3( binormal, toView );
result.texcoord6.z = dot3( normal, toView );
result.texcoord6.w = 1.0f;
// for joint transformation of the tangent space, we use color and
// color2 for weighting information, so hopefully there aren't any
// effects that need vertex color...
result.color = float4( 1.0f, 1.0f, 1.0f, 1.0f );
}

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
#define SHADOW_MAPPING
#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
#define SHADOW_MAPPING
#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
#define SHADOW_MAPPING
#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
#define SHADOW_MAPPING
#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
//#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,9 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
//#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.pixel"

View File

@ -0,0 +1,8 @@
// Copyright (C) 2014 Forest Wroncy-Hale
// this file is just glue to reference the ubershader with appropriate flags
#define USE_GPU_SKINNING
//#define SHADOW_MAPPING
//#define LIGHT_PARALLEL
//#define LIGHT_POINT
//#define LIGHT_SPOT
#include "interaction_uber.vertex"

View File

@ -0,0 +1,366 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2013-2014 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
#define SAMPLE_COUNT 12
const half diffuseScale = 5.2; // 8.1
const half diffuseBias = -0.5; // -0.1 -1.5
const half softScale = 0.55; // 0.4
const half softBias = 0.3; // 0.6
uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map
uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture
uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture
uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map
uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map
uniform sampler2DArrayShadow samp5 : register(s5); // texture 6 is the shadowmap array
uniform sampler2D samp6 : register(s6); // texture 7 is the jitter texture
uniform sampler2D samp7 : register(s7); // texture 8 is the per-surface gloss map
struct PS_IN
{
half4 position : VPOS;
half4 texcoord0 : TEXCOORD0_centroid;
half4 texcoord1 : TEXCOORD1_centroid;
half4 texcoord2 : TEXCOORD2_centroid;
half4 texcoord3 : TEXCOORD3_centroid;
half4 texcoord4 : TEXCOORD4_centroid;
half4 texcoord5 : TEXCOORD5_centroid;
half4 texcoord6 : TEXCOORD6_centroid;
half4 texcoord7 : TEXCOORD7_centroid;
half4 texcoord8 : TEXCOORD8_centroid;
half4 texcoord9 : TEXCOORD9_centroid;
half4 texcoord10 : TEXCOORD10_centroid;
half4 color : COLOR0;
};
struct PS_OUT
{
half4 color : COLOR;
};
#ifdef SHADOW_MAPPING
float Shadowmap_Sample(sampler2DArrayShadow Texture_Shadowmap, float4 shadowmaptc, float4 TexelScale)
{
# define texval(u, v) texture(Texture_Shadowmap, float4((center.x + u) * TexelScale.x, (center.y + v) * TexelScale.y, center.z, center.w))
float4 center = shadowmaptc.xyzw + float4(-0.5, -0.5, 0.0, 0.0);
//return texval(0.0, 0.0);
float2 offset = fract(center.xy);
center.xy = floor(center.xy);
float4 row1 = float4(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0), texval( 2.0, -1.0));
float4 row2 = float4(texval(-1.0, 0.0), texval( 0.0, 0.0), texval( 1.0, 0.0), texval( 2.0, 0.0));
float4 row3 = float4(texval(-1.0, 1.0), texval( 0.0, 1.0), texval( 1.0, 1.0), texval( 2.0, 1.0));
float4 row4 = float4(texval(-1.0, 2.0), texval( 0.0, 2.0), texval( 1.0, 2.0), texval( 2.0, 2.0));
float4 cols = row2 + row3 + mix(row1, row4, offset.y);
return dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
}
#endif
void main( PS_IN fragment, out PS_OUT result )
{
half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );
half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );
half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );
half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );
half4 specMap = tex2D( samp4, fragment.texcoord5.xy );
half4 glossMap = tex2D( samp7, fragment.texcoord10.xy );
half3 lightVector = normalize( fragment.texcoord0.xyz );
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
half3 localNormal;
localNormal.xy = bumpMap.wy - 0.5;
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
localNormal = normalize( localNormal );
const half specularPower = glossMap.x * 32; // default value comes out to be pow(n,15) this way
half hDotN = saturate( dot3( normalize( fragment.texcoord6.xyz ), localNormal ) );
half3 specularContribution = _half3( pow( hDotN, specularPower ) ) ;
half3 diffuseColor = diffuseMap.xyz * rpDiffuseModifier.xyz;
half3 specularColor = specMap.xyz * specularContribution * rpSpecularModifier.xyz;
half mainShade = saturate( dot3( lightVector, localNormal ));
half softShade = saturate( mainShade * softScale + softBias );
half finalShade = saturate( mainShade * diffuseScale + diffuseBias ) * softShade;
half3 lightColor = finalShade * lightProj.xyz * lightFalloff.xyz;
#if defined( SHADOW_MAPPING )
//
// shadow mapping
//
const float bias = 0.000035;
//const float bias = 0.0000;
float4 shadowMatrixX;
float4 shadowMatrixY;
float4 shadowMatrixZ;
float4 shadowMatrixW;
float4 shadowTexcoord;
float4 modelPosition = float4( fragment.texcoord7.xyz, 1.0 );
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix0X ),
dot4( modelPosition, rpShadowMatrix0Y ),
dot4( modelPosition, rpShadowMatrix0Z ) ) /
dot4( modelPosition, rpShadowMatrix0W );
shadowTexcoord.w = 0.0f;
#if defined( LIGHT_POINT )
float3 toLightGlobal = normalize( fragment.texcoord8.xyz );
float axis[6];
axis[0] = -toLightGlobal.x;
axis[1] = toLightGlobal.x;
axis[2] = -toLightGlobal.y;
axis[3] = toLightGlobal.y;
axis[4] = -toLightGlobal.z;
axis[5] = toLightGlobal.z;
float best = axis[0];
if( best < axis[1] )
{
best = axis[1];
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix1X ),
dot4( modelPosition, rpShadowMatrix1Y ),
dot4( modelPosition, rpShadowMatrix1Z ) ) /
dot4( modelPosition, rpShadowMatrix1W );
shadowTexcoord.w = 1.0f;
}
if( best < axis[2] )
{
best = axis[2];
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix2X ),
dot4( modelPosition, rpShadowMatrix2Y ),
dot4( modelPosition, rpShadowMatrix2Z ) ) /
dot4( modelPosition, rpShadowMatrix2W );
shadowTexcoord.w = 2.0f;
}
if( best < axis[3] )
{
best = axis[3];
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix3X ),
dot4( modelPosition, rpShadowMatrix3Y ),
dot4( modelPosition, rpShadowMatrix3Z ) ) /
dot4( modelPosition, rpShadowMatrix3W );
shadowTexcoord.w = 3.0f;
}
if( best < axis[4] )
{
best = axis[4];
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix4X ),
dot4( modelPosition, rpShadowMatrix4Y ),
dot4( modelPosition, rpShadowMatrix4Z ) ) /
dot4( modelPosition, rpShadowMatrix4W );
shadowTexcoord.w = 4.0f;
}
if( best < axis[5] )
{
best = axis[5];
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix5X ),
dot4( modelPosition, rpShadowMatrix5Y ),
dot4( modelPosition, rpShadowMatrix5Z ) ) /
dot4( modelPosition, rpShadowMatrix5W );
shadowTexcoord.w = 5.0f;
}
#endif // #if defined( POINTLIGHT )
#if defined( LIGHT_PARALLEL )
float viewZ = -fragment.texcoord9.z;
if( viewZ < rpCascadeDistances[0] )
{
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix0X ),
dot4( modelPosition, rpShadowMatrix0Y ),
dot4( modelPosition, rpShadowMatrix0Z ) ) /
dot4( modelPosition, rpShadowMatrix0W );
shadowTexcoord.w = 0.0f;
}
else if( viewZ < rpCascadeDistances[1] )
{
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix1X ),
dot4( modelPosition, rpShadowMatrix1Y ),
dot4( modelPosition, rpShadowMatrix1Z ) ) /
dot4( modelPosition, rpShadowMatrix1W );
shadowTexcoord.w = 1.0f;
}
else if( viewZ < rpCascadeDistances[2] )
{
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix2X ),
dot4( modelPosition, rpShadowMatrix2Y ),
dot4( modelPosition, rpShadowMatrix2Z ) ) /
dot4( modelPosition, rpShadowMatrix2W );
shadowTexcoord.w = 2.0f;
}
else if( viewZ < rpCascadeDistances[3] )
{
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix3X ),
dot4( modelPosition, rpShadowMatrix3Y ),
dot4( modelPosition, rpShadowMatrix3Z ) ) /
dot4( modelPosition, rpShadowMatrix3W );
shadowTexcoord.w = 3.0f;
}
else
{
shadowTexcoord.xyz =
float3( dot4( modelPosition, rpShadowMatrix4X ),
dot4( modelPosition, rpShadowMatrix4Y ),
dot4( modelPosition, rpShadowMatrix4Z ) ) /
dot4( modelPosition, rpShadowMatrix4W );
shadowTexcoord.w = 4.0f;
}
#endif
#if 0
result.color.xyz = saturate( float3( shadowTexcoord.z, texture( samp5, shadowTexcoord.xywz ), 0.0 ) );
result.color.w = 1.0;
return;
#endif
#if 0
result.color.xyz = saturate( float3( shadowTexcoord.z, shadowTexcoord.z, shadowTexcoord.z ) );
//result.color.xyz = saturate( float3( shadowTexcoord.x, shadowTexcoord.y, shadowTexcoord.z ) );
//result.color.xyz = saturate( modelPosition.xyz * 0.005 + float3( 0.5, 0.5, 0.5 ) );
//result.color.xyz = saturate( float3 (
// dot4( modelPosition, rpShadowMatrix0X ) * 0.5 + 0.5,
// dot4( modelPosition, rpShadowMatrix0Y ) * 0.5 + 0.5,
// dot4( modelPosition, rpShadowMatrix0Z ) * 0.5 + 0.5 ) );
result.color.w = 1.0;
return;
#endif
shadowTexcoord.z -= bias;
float shadow = 0.0;
float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale.x;
#if 0
// single tap
shadow = texture( samp5, shadowTexcoord.xywz * 1.0 );
//shadow = saturate(shadowTexcoord.z);
#endif
#if 0
// 16-tap PCF (Lee Salzman's method)
float4 texelScale = float4( shadowTexelSize, shadowTexelSize, 1.0, 1.0 );
float4 invTexelScale = float4( 1.0 / shadowTexelSize, 1.0 / shadowTexelSize, 1.0, 1.0 );
shadow = Shadowmap_Sample( samp5, shadowTexcoord.xywz * invTexelScale, texelScale );
#endif
#if 0
// 16-tap jittered
float4 base = shadowTexcoord;
base.xy += rpJitterTexScale.xy * -0.5;
//float stepSize = 1.0 / 16.0;
float numSamples = rpScreenCorrectionFactor.w;
float stepSize = 1.0 / numSamples;
float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;
for( float i = 0.0; i < numSamples; i += 1.0 )
{
float4 jitter = base + tex2D( samp6, jitterTC.xy ) * rpJitterTexScale;
jitter.zw = shadowTexcoord.zw;
shadow += texture( samp5, jitter.xywz );
jitterTC.x += stepSize;
}
shadow *= stepSize;
#endif
#if 1
// 12-tap poisson disc
const float2 poissonDisk[12] = float2[](
float2(0.6111618, 0.1050905),
float2(0.1088336, 0.1127091),
float2(0.3030421, -0.6292974),
float2(0.4090526, 0.6716492),
float2(-0.1608387, -0.3867823),
float2(0.7685862, -0.6118501),
float2(-0.1935026, -0.856501),
float2(-0.4028573, 0.07754025),
float2(-0.6411021, -0.4748057),
float2(-0.1314865, 0.8404058),
float2(-0.7005203, 0.4596822),
float2(-0.9713828, -0.06329931) );
// RB: casting a float to int and using it as index can really kill the performance ...
float numSamples = SAMPLE_COUNT; //int(rpScreenCorrectionFactor.w);
float stepSize = 1.0 / numSamples;
float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ); // + rpJitterTexOffset; // enable/disable + rpJitterTexOffset to have poisson disk rotating/be static
float4 random = tex2D( samp6, jitterTC.xy * 1.0 ) * PI;
//float4 random = fragment.position;
float2 rot;
rot.x = cos( random.x );
rot.y = sin( random.x );
for( int i = 0; i < SAMPLE_COUNT; i++ )
{
float2 jitter = poissonDisk[i];
float2 jitterRotated;
jitterRotated.x = jitter.x * rot.x - jitter.y * rot.y;
jitterRotated.y = jitter.x * rot.y + jitter.y * rot.x;
float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w );
shadow += texture( samp5, shadowTexcoordJittered.xywz * 1.0);
}
shadow *= stepSize;
#endif
#if defined( LIGHT_PARALLEL )
if(shadowTexcoord.x * 1 <= 0.01 || shadowTexcoord.x * 1 >= 0.99 || shadowTexcoord.y * 1 <= 0.01 || shadowTexcoord.y * 1 >= 0.99)
{
shadow = 1;
}
#endif
result.color.xyz = ( diffuseColor + specularColor ) * lightColor * fragment.color.xyz * shadow;
#else
result.color.xyz = ( diffuseColor + specularColor ) * lightColor * fragment.color.xyz;
#endif
result.color.w = 1.0;
}

View File

@ -0,0 +1,229 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2014 Robert Beckebans
Copyright (C) 2014 Forest Wroncy-Hale
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "renderprogs/global.inc"
#if defined( USE_GPU_SKINNING )
uniform matrices_ubo { float4 matrices[408]; };
#endif
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
float4 texcoord6 : TEXCOORD6;
float4 texcoord7 : TEXCOORD7;
float4 texcoord8 : TEXCOORD8;
float4 texcoord9 : TEXCOORD9;
float4 texcoord10 : TEXCOORD10;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
float4 vNormal = vertex.normal * 2.0 - 1.0;
float4 vTangent = vertex.tangent * 2.0 - 1.0;
float3 vBitangent = cross( vNormal.xyz, vTangent.xyz ) * vTangent.w;
#if defined( USE_GPU_SKINNING )
//--------------------------------------------------------------
// GPU transformation of the normal / tangent / bitangent
//
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
//--------------------------------------------------------------
const float w0 = vertex.color2.x;
const float w1 = vertex.color2.y;
const float w2 = vertex.color2.z;
const float w3 = vertex.color2.w;
float4 matX, matY, matZ; // must be float4 for vec4
float joint = vertex.color.x * 255.1 * 3;
matX = matrices[int(joint+0)] * w0;
matY = matrices[int(joint+1)] * w0;
matZ = matrices[int(joint+2)] * w0;
joint = vertex.color.y * 255.1 * 3;
matX += matrices[int(joint+0)] * w1;
matY += matrices[int(joint+1)] * w1;
matZ += matrices[int(joint+2)] * w1;
joint = vertex.color.z * 255.1 * 3;
matX += matrices[int(joint+0)] * w2;
matY += matrices[int(joint+1)] * w2;
matZ += matrices[int(joint+2)] * w2;
joint = vertex.color.w * 255.1 * 3;
matX += matrices[int(joint+0)] * w3;
matY += matrices[int(joint+1)] * w3;
matZ += matrices[int(joint+2)] * w3;
float3 normal;
normal.x = dot3( matX, vNormal );
normal.y = dot3( matY, vNormal );
normal.z = dot3( matZ, vNormal );
normal = normalize( normal );
float3 tangent;
tangent.x = dot3( matX, vTangent );
tangent.y = dot3( matY, vTangent );
tangent.z = dot3( matZ, vTangent );
tangent = normalize( tangent );
float3 bitangent;
bitangent.x = dot3( matX, vBitangent );
bitangent.y = dot3( matY, vBitangent );
bitangent.z = dot3( matZ, vBitangent );
bitangent = normalize( bitangent );
float4 modelPosition;
modelPosition.x = dot4( matX, vertex.position );
modelPosition.y = dot4( matY, vertex.position );
modelPosition.z = dot4( matZ, vertex.position );
modelPosition.w = 1.0;
#else
float4 modelPosition = vertex.position;
float3 normal = vNormal.xyz;
float3 tangent = vTangent.xyz;
float3 bitangent = vBitangent.xyz;
#endif
result.position.x = dot4( modelPosition, rpMVPmatrixX );
result.position.y = dot4( modelPosition, rpMVPmatrixY );
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
result.position.w = dot4( modelPosition, rpMVPmatrixW );
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
//calculate vector to light
float4 toLightLocal = rpLocalLightOrigin - modelPosition;
//--------------------------------------------------------------
//result.texcoord0 is the direction to the light in tangent space
result.texcoord0.x = dot3( tangent, toLightLocal );
result.texcoord0.y = dot3( bitangent, toLightLocal );
result.texcoord0.z = dot3( normal, toLightLocal );
result.texcoord0.w = 1.0f;
//textures 1 takes the base coordinates by the texture matrix
result.texcoord1 = defaultTexCoord;
result.texcoord1.x = dot4( vertex.texcoord.xy, rpBumpMatrixS );
result.texcoord1.y = dot4( vertex.texcoord.xy, rpBumpMatrixT );
//# texture 2 has one texgen
result.texcoord2 = defaultTexCoord;
result.texcoord2.x = dot4( modelPosition, rpLightFalloffS );
//# texture 3 has three texgens
result.texcoord3.x = dot4( modelPosition, rpLightProjectionS );
result.texcoord3.y = dot4( modelPosition, rpLightProjectionT );
result.texcoord3.z = 0.0f;
result.texcoord3.w = dot4( modelPosition, rpLightProjectionQ );
//# textures 4 takes the base coordinates by the texture matrix
result.texcoord4 = defaultTexCoord;
result.texcoord4.x = dot4( vertex.texcoord.xy, rpDiffuseMatrixS );
result.texcoord4.y = dot4( vertex.texcoord.xy, rpDiffuseMatrixT );
//# textures 5 takes the base coordinates by the texture matrix
result.texcoord5 = defaultTexCoord;
result.texcoord5.x = dot4( vertex.texcoord.xy, rpSpecularMatrixS );
result.texcoord5.y = dot4( vertex.texcoord.xy, rpSpecularMatrixT );
//# texture 6's texcoords will be the halfangle in texture space
//# calculate normalized vector to light in R0
toLightLocal = normalize( toLightLocal );
//# calculate normalized vector to viewer in R1
float4 toView = normalize( rpLocalViewOrigin - modelPosition );
//# add together to become the half angle vector in object space (non-normalized)
float4 halfAngleVector = toLightLocal + toView;
//# put into texture space
result.texcoord6.x = dot3( tangent, halfAngleVector );
result.texcoord6.y = dot3( bitangent, halfAngleVector );
result.texcoord6.z = dot3( normal, halfAngleVector );
result.texcoord6.w = 1.0f;
result.texcoord7 = modelPosition;
float4 worldPosition;
worldPosition.x = dot4( modelPosition, rpModelMatrixX );
worldPosition.y = dot4( modelPosition, rpModelMatrixY );
worldPosition.z = dot4( modelPosition, rpModelMatrixZ );
worldPosition.w = dot4( modelPosition, rpModelMatrixW );
float4 toLightGlobal = rpGlobalLightOrigin - worldPosition;
result.texcoord8 = toLightGlobal;
float4 viewPosition;
viewPosition.x = dot4( modelPosition, rpModelViewMatrixX );
viewPosition.y = dot4( modelPosition, rpModelViewMatrixY );
viewPosition.z = dot4( modelPosition, rpModelViewMatrixZ );
viewPosition.w = dot4( modelPosition, rpModelViewMatrixW );
result.texcoord9 = viewPosition;
//# textures 10 takes the base coordinates by the texture matrix
result.texcoord10 = defaultTexCoord;
result.texcoord10.x = dot4( vertex.texcoord.xy, rpGlossMatrixS );
result.texcoord10.y = dot4( vertex.texcoord.xy, rpGlossMatrixT );
#if defined( USE_GPU_SKINNING )
// for joint transformation of the tangent space, we use color and
// color2 for weighting information, so hopefully there aren't any
// effects that need vertex color...
result.color = float4( 1.0f, 1.0f, 1.0f, 1.0f );
#else
//# generate the vertex color, which can be 1.0, color, or 1.0 - color
//# for 1.0 : env[16] = 0, env[17] = 1
//# for color : env[16] = 1, env[17] = 0
//# for 1.0-color : env[16] = -1, env[17] = 1
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd );
#endif
}

View File

@ -0,0 +1,103 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // view color
uniform sampler2D samp1 : register(s1); // view depth
struct PS_IN {
float2 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
float depth : DEPTH;
};
void main( PS_IN fragment, out PS_OUT result ) {
#if 0
if ( fragment.texcoord0.x < 0.5 ) {
// only draw on half the screen for comparison
discard;
}
#endif
// don't motion blur the hands, which were drawn with alpha = 0
if ( tex2D( samp0, fragment.texcoord0 ).w == 0.0 ) {
discard;
}
// derive clip space from the depth buffer and screen position
float windowZ = tex2D( samp1, fragment.texcoord0 ).x;
float3 ndc = float3( fragment.texcoord0 * 2.0 - 1.0, windowZ * 2.0 - 1.0 );
float clipW = -rpProjectionMatrixZ.w / ( -rpProjectionMatrixZ.z - ndc.z );
float4 clip = float4( ndc * clipW, clipW );
// convert from clip space this frame to clip space previous frame
float4 reClip;
reClip.x = dot( rpMVPmatrixX, clip );
reClip.y = dot( rpMVPmatrixY, clip );
reClip.z = dot( rpMVPmatrixZ, clip );
reClip.w = dot( rpMVPmatrixW, clip );
// convert to NDC values
float2 prevTexCoord;
prevTexCoord.x = ( reClip.x / reClip.w ) * 0.5 + 0.5;
prevTexCoord.y = ( reClip.y / reClip.w ) * 0.5 + 0.5;
// sample along the line from prevTexCoord to fragment.texcoord0
float2 texCoord = prevTexCoord; //fragment.texcoord0;
float2 delta = ( fragment.texcoord0 - prevTexCoord );
float3 sum = float3( 0.0 );
float goodSamples = 0;
float samples = rpOverbright.x;
for ( float i = 0 ; i < samples ; i = i + 1 ) {
// sikk - only sample in one direction
// float2 pos = fragment.texcoord0 + delta * ( ( i / ( samples - 1 ) ) - 0.5 );
float2 pos = fragment.texcoord0 + delta * ( i / ( samples - 1 ) );
float4 color = tex2D( samp0, pos );
// sikk - discard samples outside the view
if ( pos.x < 0 || pos.y < 0 || pos.x > 1 || pos.y > 1 ) {
color.w = 0;
}
// only take the values that are not part of the weapon
sum += color.xyz * color.w;
goodSamples += color.w;
}
float invScale = 1.0 / goodSamples;
result.color = float4( sum * invScale, 1.0 );
result.depth = 1.0f; // sikk - this is so noBlur surfaces that draw after
// the motion blur pass will not be culled
}

View File

@ -0,0 +1,44 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position = vertex.position;
result.texcoord0 = vertex.texcoord;
}

View File

@ -0,0 +1,34 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#define SO_BlendMode 2 // 1 = Blend, 2 = Add, 3 = Filter
#define SO_UseZFeather
#define SO_UseDistanceFade
#define SO_UseFogging
#include "particleBase.pixel"

View File

@ -0,0 +1,29 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "particleBase.vertex"

View File

@ -0,0 +1,152 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
/*
This file ( particleBase.pixel and .vertex ) is not meant to be used directly in a material, instead it gets #include'd into the actual
shader file along with some #define switches before the #include, driving which type of shader combination will be created.
Shading Option Switches, use these to create different types of specialized shaders if needed.
See "particleBlend_SoftDistFog.pixel" or similar files for examples.
#define SO_BlendMode 0 // Sets Blending Mode the shader will be used in. 1 = Blend, 2 = Add, 3 = Filter
#define SO_UseZFeather // Enable Z Feathering ( parms in vertexParm 0 )
#define SO_UseDistanceFade // Enable Distance Fading ( parms in vertexParm 1 )
#define SO_UseFogging // Enable Pseudo Fogging ( parms in vertexParm 2 )
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0); // texture 0 is _currentDepth
uniform sampler2D samp1 : register(s1); // texture 1 is main texture
struct PS_IN {
float4 position : VPOS;
float2 texCoord : TEXCOORD0;
float4 genParms0 : TEXCOORD1;
float4 genParms1 : TEXCOORD2;
float4 genParms2 : TEXCOORD3;
float4 color : COLOR0;
};
struct PS_OUT {
float4 color : COLOR;
};
// Depth / Fade related functions
static float LinearizeDepth( float inDepth ) {
float
zNear = 5.0,
zFar = 3000.0;
float
zN = 2.0 * inDepth - 1.0;
return 2.0 * zNear * zFar / ( zFar + zNear - zN * (zFar - zNear));
}
static float GetDepth( sampler2D tex, float2 uv ) {
return tex2D( tex, uv ).x;
}
static float GetLinearDepth( sampler2D tex, float2 uv ) {
return LinearizeDepth( GetDepth( tex, uv ));
}
static float GetDistanceFalloff( float baseDist, float start, float range ) {
return saturate( ( baseDist - start ) / range );
}
static float ZFeather( sampler2D depthSampler, float2 depthSamplePos, float fragmentDepth, float featherAmount ) {
float
d = GetLinearDepth( depthSampler, depthSamplePos ),
d2 = LinearizeDepth( fragmentDepth );
return saturate( ( d - d2 ) * featherAmount );
}
void main( PS_IN fragment, out PS_OUT result ) {
float4
texSample = tex2D( samp1, fragment.texCoord );
float4
outColor;
outColor = texSample * fragment.color;
#ifdef SO_UseZFeather
float2
screenPos = vposToScreenPosTexCoord( fragment.position.xy );
#endif
#if defined( SO_UseDistanceFade ) || defined( SO_UseFogging )
float
fragDepth = fragment.position.z / fragment.position.w;
#endif
#if SO_BlendMode == 1
#ifdef SO_UseZFeather
outColor.a *= ZFeather( samp0, screenPos, fragment.position.z, fragment.genParms0.x );
#endif
#ifdef SO_UseDistanceFade
outColor.a *= GetDistanceFalloff( fragDepth, fragment.genParms1.x, fragment.genParms1.y );
#endif
#ifdef SO_UseFogging
outColor.rgb = lerp( outColor.rgb, fragment.genParms2.rgb, saturate( fragDepth * fragment.genParms2.a ));
//outColor.a *= 1.0 - saturate( fragDepth * fragment.genParms2.a );
#endif
#endif
#if SO_BlendMode == 2
#ifdef SO_UseZFeather
outColor.rgb *= ZFeather( samp0, screenPos, fragment.position.z, fragment.genParms0.x );
#endif
#ifdef SO_UseDistanceFade
outColor.rgb *= GetDistanceFalloff( fragDepth, fragment.genParms1.x, fragment.genParms1.y );
#endif
#ifdef SO_UseFogging
// Additive blending can't reliably fade to a fog color - maybe this approach should be used in general ?
outColor.rgb *= saturate( 1.0 - ( fragDepth * fragment.genParms2.a ));
#endif
#endif
#if SO_BlendMode == 3
float
fadeValue = fragment.color.a;
#ifdef SO_UseZFeather
fadeValue *= ZFeather( samp0, screenPos, fragment.position.z, fragment.genParms0.x );
#endif
#ifdef SO_UseDistanceFade
fadeValue *= GetDistanceFalloff( fragDepth, fragment.genParms1.x, fragment.genParms1.y );
#endif
#ifdef SO_UseFogging
fadeValue *= saturate( 1.0 - ( fragDepth * fragment.genParms2.a ));
#endif
outColor.rgb = lerp( float3( 1.0 ), outColor.rgb, fadeValue );
#endif
result.color = outColor;
}

View File

@ -0,0 +1,65 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
// User Renderparms start at 128 as per renderprogs.h
uniform float4 rpUser0 : register( c128 );
uniform float4 rpUser1 : register( c129 );
uniform float4 rpUser2 : register( c130 );
uniform matrices_ubo { float4 matrices[408]; };
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
float4 color2 : COLOR1;
};
struct VS_OUT {
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float4 genParms0 : TEXCOORD1;
float4 genParms1 : TEXCOORD2;
float4 genParms2 : TEXCOORD3;
float4 color : COLOR0;
};
void main( VS_IN vertex, out VS_OUT result ) {
#include "skinning.inc"
result.texCoord = vertex.texcoord;
result.genParms0 = rpUser0;
result.genParms1 = rpUser1;
result.genParms2 = rpUser2;
// foresthale 2014-03-29: because we no longer use gl_Color, the intrinsic saturate is gone, apply it ourselves in case there are colors or alpha values out of bounds
result.color = saturate( vertex.color );
}

View File

@ -0,0 +1,34 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#define SO_BlendMode 1 // 1 = Blend, 2 = Add, 3 = Filter
#define SO_UseZFeather
#define SO_UseDistanceFade
#define SO_UseFogging
#include "particleBase.pixel"

View File

@ -0,0 +1,29 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "particleBase.vertex"

View File

@ -0,0 +1,34 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#define SO_BlendMode 3 // 1 = Blend, 2 = Add, 3 = Filter
#define SO_UseZFeather
#define SO_UseDistanceFade
#define SO_UseFogging
#include "particleBase.pixel"

View File

@ -0,0 +1,29 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "particleBase.vertex"

View File

@ -0,0 +1,45 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
uniform sampler2D samp0 : register(s0);
struct PS_IN {
float4 position : VPOS;
float2 texcoord0 : TEXCOORD0_centroid;
};
struct PS_OUT {
float4 color : COLOR;
};
void main( PS_IN fragment, out PS_OUT result ) {
float2 tCoords = fragment.texcoord0;
result.color = tex2D( samp0, tCoords );
}

View File

@ -0,0 +1,52 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "global.inc"
struct VS_IN {
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float4 normal : NORMAL;
float4 tangent : TANGENT;
float4 color : COLOR0;
};
struct VS_OUT {
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
};
void main( VS_IN vertex, out VS_OUT result ) {
result.position = vertex.position;
//result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );
//result.position.y = dot4( vertex.position, rpMVPmatrixY );
//result.position.z = dot4( vertex.position, rpMVPmatrixZ );
//result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0 = vertex.texcoord;
}

Some files were not shown because too many files have changed in this diff Show More