📄 d3dfixedfuncshaders.fx
字号:
/*----------------------------------------------------------------------------*\|| Module Details:|| Name: D3DFixedFuncShaders.fx|| Purpose: Effect file containing all techniques to do fixed functionality | in Direct3D 10.|| History:|| Date Release Name Ver. Comments| --------- ------- ----- ----- --------------------------------------------| 17-Jan-08 L-03-01 wgs $$1 Created| 07-Mar-08 L-03-04 wgs $$2 Updated for user defined clipping.| 21-Mar-08 L-03-05 wgs $$3 Implemented s-transparency.| 04-Apr-08 L-03-06 wgs $$4 Implemented technique10 Tristrip_VS_PSBitmap| 03-Apr-08 L-03-06 PPB Implemented multi/single pass texturing| 21-Apr-08 L-03-07 PPB $$5 Texturing code updated.| 21-Apr-08 rds Texturing code updated. Added support for| projected texture| 22-Apr-08 L-03-08 wgs $$6 Add texture-based Bitmap, cosmetic changes| 30-Apr-08 L-03-08 rds XOR mode support added.| 15-May-08 L-03-09 wgs $$7 Added functions for section planes, screen| transparency; XOR LogicOp emulation; Changed| names of some effect variables| 16-May-08 rds Added cubic environment mapping code| 30-Apr-09 L-03-31 rds $$8 Restoring changes made between 3rd June| and 13th Feb.|| 03-Jun-08 L_03_11 wgs Remove obsolete version of bitmap PS| 05-Jun-08 rds Don't divide by w in pixel shaders. Don't do| XOR for surfaces.| 26-Jun-08 L_03_13 wgs Modified PS_Bitmap_s to deal with 1-bit texels| 05-Aug-08 L_03_15 rds Re-enable XOR for surfaces. We use them for| displaying wide lines/points.| 14-Aug-08 L_03_16 wgs Introduce ModulateByDefaultColor functionality| 04-Sep-08 L_03_17 wgs Changes for bitmap text| 28-Aug-08 rds Projected texture code updated for shadow| color.| 05-Sep-08 rds Added spherical environment map support.| 23-Sep-08 L_03_18 rds Apply stipple transparency even in texturing| pass.| 29-Sep-08 L_03_19 wgs Cosmetic removal of BitmapTexelWidth, Height| 13-Feb-09 L_03_27 rds Bitmap display updated.| 30-Apr-09 L-03-31 rds Add comments after this line.|\*----------------------------------------------------------------------------*/// PGL DEFINE DATA CONVENTIONS// IMPORTANT BIT-MASK VALUES#define FRONT_FACE 0x1#define BACK_FACE 0x2#define OAMB_VERTEX_AND_NORMAL 0x2#define OAMB_VERTEX_UV_FRONT 0x8/* Since at most one FRONT or BACK set of UVs is passed to VS at a time,presence of tex data is signalled by using only OAMB_VERTEX_UV_FRONT */#define OAMB_VERTEX_ECOLOR 0x20#define OAMB_VERTEX_ECOLOR_BACK 0x40#define D3D_TEXTURE_TYPE_COLOR 0x1#define D3D_TEXTURE_TYPE_BUMP 0x2#define D3D_TEXTURE_TYPE_DECAL 0x4#define D3D_TEXTURE_TYPE_ENVMAP_CUBIC 0x8#define D3D_TEXTURE_TYPE_ENVMAP_SPHERICAL 0x10#define D3D_TEXTURE_TYPE_UNLIT 0x20#define D3D_TEXTURE_TYPE_PROJECTED 0x40// SUPPORTING STRUCTURES FOR EFFECT VARIABLESstruct _pgl_d3d_light{ float4 position; /* Used only by point, spot Position relative to D3D eye space */ float3 direction; /* Used only by directional, spot Direction relative to D3D eye space of uniform light travel for directional light and light travel for ray along cone axis for spot *//* Following member not supported by PGL or used by any D3D10 or shader code */ float range; /* Used only by point, spot Associated with following kC, kL, kQ members Set range to 0.0 if want no attenuation effects Otherwise, 1/(kC+kL*dist+kQ*dist*dist) attenuation factor used As used by default D3D9, range is distance at which mesh no longer receives light */ float4 color; /* Used by all light types Only RGB used */ /* NOTE: 4th component of light colors are set 1 because lighting has no inherent opacity */ float4 color_specular; /* Used only by directional, point, spot Only RGB used PGL has no independent color for specular, so member color_specular is a copy of above member color */ uint enabled; /* boolean datatype: 0 - disabled; !0 - enabled Shaders bypass lights that are not enabled */ int type; /* 0 - ambient; 1 - directional; 2 - point; 3 - spot; 4 - sky (not yet supported); 5 - HDRI (not yet supported) *//* Following member not supported by PGL or used by any D3D10 or shader code */ float kC; /* Used only by point, spot Constant attenuation coefficient Good default value is 1.0 *//* Following member not supported by PGL or used by any D3D10 or shader code */ float kL; /* Used only by point, spot Linear attenuation coefficient (kL * dist) Good default value is 0.0 *//* Following member not supported by PGL or used by any D3D10 or shader code */ float kQ; /* Used only by point, spot Quadratic attenuation coefficient (kL * dist*dist) Good default value is 0.0 *//* Following member not supported by PGL or used by any D3D10 or shader code */ float cos_inner_cone; /* Used only by spot cosine of angle from axis to inner cone Intensity is full inside inner cone Good default value is 10.0*3.1416/180.0 */ float cos_outer_cone; /* Used only by spot cosine of angle from axis to outer cone Intensity is 0 outside outer cone Angular fade effect between inner and outer cones If both cones have same angle, intensity drops discontinuously from full to 0 Good default value is 90.0*3.1416/180.0 */ int dummy;};struct _pgl_d3d_material{/* NOTE: Alpha components of 4 following properties are set 1 *//* Following member not supported by PGL or used by any D3D10 or shader code */ float4 emissive; float4 ambient; float4 diffuse; float4 specular; float power; /* power of specular_angle_dropoff term (from PGL shininess) */ float alpha; /* Combined with final RGB from lighting equations */ int dummy_1; int dummy_2;};#if 0/* TODO - For future Geometry Shaders */struct _pgl_d3d_vertex_structure{ float4 position; float3 normal; float2 tex; // for use by front, back, or front_and_back float4 rgba_front; float4 rgba_back;};_pgl_d3d_vertex_structure v_str_array[9];_pgl_d3d_vertex_structure mod_v_str_array[9];#endif// EFFECT VARIABLES/* NOTE - To promote ease of understanding, names of these variables arerequired to be identical to names of corresponding variables used inPGL files in pgl_d3d directory *//* Transform matrices */matrix MatrixWorldView;matrix MatrixProj;matrix MatrixWorldViewProj;/* Section planes */int NumSectionPlanes;float4 SectionPlanes[6];// uint zone_mask; may be used in future if performance can be improved/* Lights */uint LightingEnabled; /* boolean datatype: 0 - disabled; !0 - enabled */int NumLights;_pgl_d3d_light Lights[8];/* Surface material lighting response properties */_pgl_d3d_material Materials[2];/* Single color used when flat color applies to entire primitive */float4 DefaultColor = (1,1,1,1);/* Controls whether or not DefaultColor is used to modulate (multiply)fragment RGBA */uint ModulateByDefaultColor = 0; /* boolean datatype: 0 - disabled; !0 - enabled *//* Controls which face of surface is processed */uint FacesMask; /* bit FRONT_FACE enables front face; bit BACK_FACE enables back face *//* Specifies degree of opacity to use for surfaces when screening transparency(skipping some pixels) is used instead of lighting effects */int STransparencyIndex; /* Index into STransparencies look-up array. Allowed range is [-1, 15]: -1 represents completely opaque - write the pixel; 15 represents completely transparent - skip writing the pixel; only [0, 14] is used to access STransparencies *//* Texture-Related Variables - NOTE: Need more documentation for these */uint TextureType; /* PglMask32: OR of the appropriate D3D_TEXTURE_TYPE_* values to convey which types of texture are being employed */// Replace name by TextureBoundaryTransparent;uint TextureTransparentBoundary; /* PglMask32: OR of the appropriate D3D_TEXTURE_TYPE_* values to convey which types of texture have transparent boundary */// Replace name by MatrixTxColor;matrix mTextureTransform;// Replace name by MatrixTxBump;matrix mBumpTransform; // currently limited to experimental use// Replace name by MatrixTxDecal;matrix mDecalTransform; // currently limited to experimental use// Replace name by TxColorTexture2D TxDiffuse;Texture2D TxBump; // currently limited to experimental useTexture2D TxDecal; // currently limited to experimental useTextureCube TxCubeEnvMap; /* Use by cubic environment mapping *//* Legacy support for XOR LogicOp to achieve dynamic write/erase behavior byrendering primitive and then rendering same primitive a second time */uint XOR_Enabled;// Replace name by TxFramebufferTexture2D txXOR_frame_buffer;Texture2D <unorm float> TxBitmap;// TEXTURE SAMPLERSSamplerState SamplerLinear{ Filter = MIN_MAG_MIP_LINEAR; AddressU = WRAP; AddressV = WRAP;};SamplerState SamplerTransparent{ Filter = MIN_MAG_MIP_LINEAR; AddressU = BORDER; AddressV = BORDER; // default border color is 0,0,0,0 - hence transparent};SamplerState SamplerCube{ Filter = ANISOTROPIC; AddressU = CLAMP; AddressV = CLAMP;};SamplerState SamplerBitmap{#if 0// TODO - Might be ultimate goal Filter = TEXT_1BIT;#else Filter = MIN_MAG_MIP_POINT;#endif AddressU = BORDER; AddressV = BORDER;};// FIXED DATA RESOURCES// Replace name by STransparencies[15][4] = uint STransparencies[15][4] = /*15 banks of opacity data, each bank of which contains 4*32 bits of datarepresenting a rectangular 4 pixel (vertical) * 32 pixel (horizontal) screentransparency pattern: bit value of 0 indicates an opacity hole (i.e., completely transparent) that should cause the rendering of the pixel currently being processed by the pixel shader to be aborted, resulting in no change to color, depth, stencil, etc; bit value of 1 should cause further rendering of the pixel along the pipeline.*/ { /* bank 0 - almost completely opaque */ { 0x77777777, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, /* bank 1 */ { 0x77777777, 0xFFFFFFFF, 0xDDDDDDDD, 0xFFFFFFFF }, /* bank 2 */ { 0x55555555, 0xFFFFFFFF, 0x77777777, 0xFFFFFFFF }, /* bank 3 */ { 0x55555555, 0xFFFFFFFF, 0x55555555, 0xFFFFFFFF }, /* bank 4 */ { 0x55555555, 0xBBBBBBBB, 0x55555555, 0xFFFFFFFF }, /* bank 5 */ { 0x55555555, 0xBBBBBBBB, 0x55555555, 0xEEEEEEEE }, /* bank 6 */ { 0x55555555, 0xAAAAAAAA, 0x55555555, 0xEEEEEEEE }, /* bank 7 */ { 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA }, /* bank 8 */ { 0x55555555, 0xAAAAAAAA, 0x44444444, 0xAAAAAAAA }, /* bank 9 */ { 0x55555555, 0x88888888, 0x55555555, 0x22222222 }, /* bank 10 */ { 0xAAAAAAAA, 0x11111111, 0xAAAAAAAA, 0x00000000 }, /* bank 11 */ { 0xAAAAAAAA, 0x00000000, 0xAAAAAAAA, 0x00000000 }, /* bank 12 */ { 0xAAAAAAAA, 0x00000000, 0x88888888, 0x00000000 },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -