diff --git a/src/d3d/d3d9matfx.cpp b/src/d3d/d3d9matfx.cpp index 927f70b..ebcb319 100644 --- a/src/d3d/d3d9matfx.cpp +++ b/src/d3d/d3d9matfx.cpp @@ -3,6 +3,7 @@ #include #include +#define WITH_D3D #include "../rwbase.h" #include "../rwerror.h" #include "../rwplg.h" @@ -10,6 +11,7 @@ #include "../rwobjects.h" #include "../rwanim.h" #include "../rwengine.h" +#include "../rwrender.h" #include "../rwplugins.h" #include "rwd3d.h" #include "rwd3d9.h" @@ -18,9 +20,239 @@ namespace rw { namespace d3d9 { using namespace d3d; +static void *matfx_env_amb_VS; +static void *matfx_env_amb_dir_VS; +static void *matfx_env_all_VS; +static void *matfx_env_PS; +static void *matfx_env_tex_PS; + +enum +{ + VSLOC_texMat = VSLOC_afterLights, + + PSLOC_shininess = 0, + PSLOC_colorClamp = 1 +}; + +void +matfxRender_Default(InstanceDataHeader *header, InstanceData *inst, int32 lightBits) +{ + Material *m = inst->material; + + // Pick a shader + if((lightBits & VSLIGHT_MASK) == 0) + setVertexShader(default_amb_VS); + else if((lightBits & VSLIGHT_MASK) == VSLIGHT_DIRECT) + setVertexShader(default_amb_dir_VS); + else + setVertexShader(default_all_VS); + + SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 255); + + if(inst->material->texture){ + d3d::setTexture(0, m->texture); + setPixelShader(default_color_tex_PS); + }else + setPixelShader(default_color_PS); + + drawInst(header, inst); +} + +static Frame *lastEnvFrame; + +static RawMatrix normal2texcoord = { + { 0.5f, 0.0f, 0.0f }, 0.0f, + { 0.0f, -0.5f, 0.0f }, 0.0f, + { 0.0f, 0.0f, 1.0f }, 0.0f, + { 0.5f, 0.5f, 0.0f }, 1.0f +}; + +void +uploadEnvMatrix(Frame *frame) +{ + Matrix invMat; + if(frame == nil) + frame = engine->currentCamera->getFrame(); + + // cache the matrix across multiple meshes + if(frame == lastEnvFrame) + return; + lastEnvFrame = frame; + + RawMatrix envMtx, invMtx; + Matrix::invert(&invMat, frame->getLTM()); + convMatrix(&invMtx, &invMat); + RawMatrix::mult(&envMtx, &invMtx, &normal2texcoord); + d3ddevice->SetVertexShaderConstantF(VSLOC_texMat, (float*)&envMtx, 4); +} + +void +matfxRender_EnvMap(InstanceDataHeader *header, InstanceData *inst, int32 lightBits, MatFX::Env *env) +{ + Material *m = inst->material; + + if(env->tex == nil || env->coefficient == 0.0f){ + matfxRender_Default(header, inst, lightBits); + return; + } + + d3d::setTexture(1, env->tex); + uploadEnvMatrix(env->frame); + + d3ddevice->SetPixelShaderConstantF(PSLOC_shininess, &env->coefficient, 1); + + SetRenderState(SRCBLEND, BLENDONE); + + static float zero[4]; + static float one[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; + d3ddevice->SetPixelShaderConstantF(PSLOC_shininess, &env->coefficient, 1); + // This clamps the vertex color below. With it we can achieve both PC and PS2 style matfx + if(MatFX::modulateEnvMap) + d3ddevice->SetPixelShaderConstantF(PSLOC_colorClamp, zero, 1); + else + d3ddevice->SetPixelShaderConstantF(PSLOC_colorClamp, one, 1); + + // Pick a shader + if((lightBits & VSLIGHT_MASK) == 0) + setVertexShader(matfx_env_amb_VS); + else if((lightBits & VSLIGHT_MASK) == VSLIGHT_DIRECT) + setVertexShader(matfx_env_amb_dir_VS); + else + setVertexShader(matfx_env_all_VS); + + bool32 texAlpha = PLUGINOFFSET(D3dRaster, env->tex->raster, nativeRasterOffset)->hasAlpha; + + if(inst->material->texture){ + d3d::setTexture(0, m->texture); + setPixelShader(matfx_env_tex_PS); + }else + setPixelShader(matfx_env_PS); + + SetRenderState(VERTEXALPHA, texAlpha || inst->vertexAlpha || m->color.alpha != 255); + + drawInst(header, inst); + + SetRenderState(SRCBLEND, BLENDSRCALPHA); +} + +void +matfxRenderCB_Shader(Atomic *atomic, InstanceDataHeader *header) +{ + int vsBits; + d3ddevice->SetStreamSource(0, (IDirect3DVertexBuffer9*)header->vertexStream[0].vertexBuffer, + 0, header->vertexStream[0].stride); + d3ddevice->SetIndices((IDirect3DIndexBuffer9*)header->indexBuffer); + d3ddevice->SetVertexDeclaration((IDirect3DVertexDeclaration9*)header->vertexDeclaration); + + lastEnvFrame = nil; + + vsBits = lightingCB_Shader(atomic); + uploadMatrices(atomic->getFrame()->getLTM()); + + bool normals = !!(atomic->geometry->flags & Geometry::NORMALS); + + float surfProps[4]; + surfProps[3] = atomic->geometry->flags&Geometry::PRELIT ? 1.0f : 0.0f; + + InstanceData *inst = header->inst; + for(uint32 i = 0; i < header->numMeshes; i++){ + Material *m = inst->material; + + rw::RGBAf col; + convColor(&col, &inst->material->color); + d3ddevice->SetVertexShaderConstantF(VSLOC_matColor, (float*)&col, 1); + + surfProps[0] = m->surfaceProps.ambient; + surfProps[1] = m->surfaceProps.specular; + surfProps[2] = m->surfaceProps.diffuse; + d3ddevice->SetVertexShaderConstantF(VSLOC_surfProps, surfProps, 1); + + MatFX *matfx = MatFX::get(m); + if(matfx == nil) + matfxRender_Default(header, inst, vsBits); + else switch(matfx->type){ + case MatFX::ENVMAP: + if(normals) + matfxRender_EnvMap(header, inst, vsBits, &matfx->fx[0].env); + else + matfxRender_Default(header, inst, vsBits); + break; + case MatFX::NOTHING: + case MatFX::BUMPMAP: + case MatFX::BUMPENVMAP: + case MatFX::DUAL: + case MatFX::UVTRANSFORM: + case MatFX::DUALUVTRANSFORM: + // not supported yet + matfxRender_Default(header, inst, vsBits); + break; + } + + inst++; + } + + d3d::setTexture(1, nil); + + setVertexShader(nil); + setPixelShader(nil); +} + +#define VS_NAME g_vs20_main +#define PS_NAME g_ps20_main + +void +createMatFXShaders(void) +{ + { + static +#include "shaders/matfx_env_amb_VS.h" + matfx_env_amb_VS = createVertexShader((void*)VS_NAME); + assert(matfx_env_amb_VS); + } + { + static +#include "shaders/matfx_env_amb_dir_VS.h" + matfx_env_amb_dir_VS = createVertexShader((void*)VS_NAME); + assert(matfx_env_amb_dir_VS); + } + { + static +#include "shaders/matfx_env_all_VS.h" + matfx_env_all_VS = createVertexShader((void*)VS_NAME); + assert(matfx_env_all_VS); + } + + + { + static +#include "shaders/matfx_env_PS.h" + matfx_env_PS = createPixelShader((void*)PS_NAME); + assert(matfx_env_PS); + } + { + static +#include "shaders/matfx_env_tex_PS.h" + matfx_env_tex_PS = createPixelShader((void*)PS_NAME); + assert(matfx_env_tex_PS); + } + +} + +void +destroyMatFXShaders(void) +{ + destroyVertexShader(matfx_env_PS); + matfx_env_PS = nil; + + destroyVertexShader(matfx_env_tex_PS); + matfx_env_tex_PS = nil; +} + static void* matfxOpen(void *o, int32, int32) { + createMatFXShaders(); + matFXGlobals.pipelines[PLATFORM_D3D9] = makeMatFXPipeline(); return o; } @@ -28,6 +260,8 @@ matfxOpen(void *o, int32, int32) static void* matfxClose(void *o, int32, int32) { + destroyMatFXShaders(); + return o; } @@ -44,7 +278,7 @@ makeMatFXPipeline(void) ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9); pipe->instanceCB = defaultInstanceCB; pipe->uninstanceCB = defaultUninstanceCB; - pipe->renderCB = defaultRenderCB_Shader; + pipe->renderCB = matfxRenderCB_Shader; pipe->pluginID = ID_MATFX; pipe->pluginData = 0; return pipe; diff --git a/src/d3d/d3drender.cpp b/src/d3d/d3drender.cpp index 51bfe3d..4a0b177 100644 --- a/src/d3d/d3drender.cpp +++ b/src/d3d/d3drender.cpp @@ -56,7 +56,6 @@ createDefaultShaders(void) default_color_PS = createPixelShader((void*)PS_NAME); assert(default_color_PS); } - { static #include "shaders/default_color_tex_PS.h" @@ -296,10 +295,14 @@ lightingCB_Shader(Atomic *atomic) lightData.locals = locals; lightData.numLocals = 8; - int lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT); - if(lighting){ + if(atomic->geometry->flags & rw::Geometry::LIGHT){ ((World*)engine->currentWorld)->enumerateLights(atomic, &lightData); d3ddevice->SetVertexShaderConstantF(VSLOC_ambLight, (float*)&lightData.ambient, 1); + if(!(atomic->geometry->flags & rw::Geometry::PRELIT) == 0){ + // Get rid of lights that need normals when we don't have any + lightData.numDirectionals = 0; + lightData.numLocals = 0; + } return uploadLights(&lightData); }else{ static const float zeroF[4]; diff --git a/src/d3d/shaders/defaultVS.hlsl b/src/d3d/shaders/default_VS.hlsl similarity index 100% rename from src/d3d/shaders/defaultVS.hlsl rename to src/d3d/shaders/default_VS.hlsl diff --git a/src/d3d/shaders/make.cmd b/src/d3d/shaders/make_default.cmd similarity index 75% rename from src/d3d/shaders/make.cmd rename to src/d3d/shaders/make_default.cmd index 01898c1..98c90a2 100644 --- a/src/d3d/shaders/make.cmd +++ b/src/d3d/shaders/make_default.cmd @@ -1,7 +1,7 @@ @echo off -"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /Fh default_amb_VS.h defaultVS.hlsl -"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /DDIRECTIONALS /Fh default_amb_dir_VS.h defaultVS.hlsl -"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /DDIRECTIONALS /DPOINTLIGHTS /DSPOTLIGHTS /Fh default_all_VS.h defaultVS.hlsl +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /Fh default_amb_VS.h default_VS.hlsl +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /DDIRECTIONALS /Fh default_amb_dir_VS.h default_VS.hlsl +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /DDIRECTIONALS /DPOINTLIGHTS /DSPOTLIGHTS /Fh default_all_VS.h default_VS.hlsl "%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T ps_2_0 /Fh default_color_PS.h default_color_PS.hlsl "%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T ps_2_0 /Fh default_color_tex_PS.h default_color_tex_PS.hlsl diff --git a/src/d3d/shaders/make_matfx.cmd b/src/d3d/shaders/make_matfx.cmd new file mode 100644 index 0000000..5659169 --- /dev/null +++ b/src/d3d/shaders/make_matfx.cmd @@ -0,0 +1,7 @@ +@echo off +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /Fh matfx_env_amb_VS.h matfx_env_VS.hlsl +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /DDIRECTIONALS /Fh matfx_env_amb_dir_VS.h matfx_env_VS.hlsl +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T vs_2_0 /DDIRECTIONALS /DPOINTLIGHTS /DSPOTLIGHTS /Fh matfx_env_all_VS.h matfx_env_VS.hlsl + +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T ps_2_0 /Fh matfx_env_PS.h matfx_env_PS.hlsl +"%DXSDK_DIR%\utilities\bin\x86\fxc.exe" /T ps_2_0 /DTEX /Fh matfx_env_tex_PS.h matfx_env_PS.hlsl diff --git a/src/d3d/shaders/matfx_env_PS.h b/src/d3d/shaders/matfx_env_PS.h new file mode 100644 index 0000000..5e37c8f --- /dev/null +++ b/src/d3d/shaders/matfx_env_PS.h @@ -0,0 +1,105 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// fxc /T ps_2_0 /Fh matfx_env_PS.h matfx_env_PS.hlsl +// +// +// Parameters: +// +// float4 colorClamp; +// sampler2D envTex; +// float shininess; +// +// +// Registers: +// +// Name Reg Size +// ------------ ----- ---- +// shininess c0 1 +// colorClamp c1 1 +// envTex s1 1 +// + + ps_2_0 + dcl t1.xy + dcl v0 + dcl_2d s1 + texld r0, t1, s1 + max r1.xyz, v0, c1 + mul r1.xyz, r1, c0.x + mul r0.xyz, r0, r1 + mad r0.xyz, v0, v0.w, r0 + mov r0.w, v0.w + mov oC0, r0 + +// approximately 7 instruction slots used (1 texture, 6 arithmetic) +#endif + +const BYTE g_ps20_main[] = +{ + 0, 2, 255, 255, 254, 255, + 57, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 175, 0, + 0, 0, 0, 2, 255, 255, + 3, 0, 0, 0, 28, 0, + 0, 0, 0, 1, 0, 0, + 168, 0, 0, 0, 88, 0, + 0, 0, 2, 0, 1, 0, + 1, 0, 6, 0, 100, 0, + 0, 0, 0, 0, 0, 0, + 116, 0, 0, 0, 3, 0, + 1, 0, 1, 0, 6, 0, + 124, 0, 0, 0, 0, 0, + 0, 0, 140, 0, 0, 0, + 2, 0, 0, 0, 1, 0, + 2, 0, 152, 0, 0, 0, + 0, 0, 0, 0, 99, 111, + 108, 111, 114, 67, 108, 97, + 109, 112, 0, 171, 1, 0, + 3, 0, 1, 0, 4, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 101, 110, 118, 84, + 101, 120, 0, 171, 4, 0, + 12, 0, 1, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 115, 104, 105, 110, + 105, 110, 101, 115, 115, 0, + 171, 171, 0, 0, 3, 0, + 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 112, 115, 95, 50, 95, 48, + 0, 77, 105, 99, 114, 111, + 115, 111, 102, 116, 32, 40, + 82, 41, 32, 72, 76, 83, + 76, 32, 83, 104, 97, 100, + 101, 114, 32, 67, 111, 109, + 112, 105, 108, 101, 114, 32, + 57, 46, 50, 57, 46, 57, + 53, 50, 46, 51, 49, 49, + 49, 0, 31, 0, 0, 2, + 0, 0, 0, 128, 1, 0, + 3, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 144, 31, 0, 0, 2, + 0, 0, 0, 144, 1, 8, + 15, 160, 66, 0, 0, 3, + 0, 0, 15, 128, 1, 0, + 228, 176, 1, 8, 228, 160, + 11, 0, 0, 3, 1, 0, + 7, 128, 0, 0, 228, 144, + 1, 0, 228, 160, 5, 0, + 0, 3, 1, 0, 7, 128, + 1, 0, 228, 128, 0, 0, + 0, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 1, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 228, 144, + 0, 0, 255, 144, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 144, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0 +}; diff --git a/src/d3d/shaders/matfx_env_PS.hlsl b/src/d3d/shaders/matfx_env_PS.hlsl new file mode 100644 index 0000000..67936cd --- /dev/null +++ b/src/d3d/shaders/matfx_env_PS.hlsl @@ -0,0 +1,32 @@ +struct VS_out { + float4 Position : POSITION; + float2 TexCoord0 : TEXCOORD0; + float2 TexCoord1 : TEXCOORD1; + float4 Color : COLOR0; +}; + +sampler2D diffTex : register(s0); +sampler2D envTex : register(s1); + +float shininess : register(c0); +float4 colorClamp : register(c1); + +float4 main(VS_out input) : COLOR +{ + float4 pass1 = input.Color; +#ifdef TEX + pass1 *= tex2D(diffTex, input.TexCoord0.xy); +#endif + + float4 envColor = max(pass1, colorClamp); + float4 pass2 = envColor*shininess*tex2D(envTex, input.TexCoord1.xy); + + // We simulate drawing this in two passes. + // First pass with standard blending, second with addition + // We premultiply alpha so render state should be one. + float4 color; + color.rgb = pass1.rgb*pass1.a + pass2.rgb; + color.a = pass1.a; + + return color; +} diff --git a/src/d3d/shaders/matfx_env_VS.hlsl b/src/d3d/shaders/matfx_env_VS.hlsl new file mode 100644 index 0000000..d180e3a --- /dev/null +++ b/src/d3d/shaders/matfx_env_VS.hlsl @@ -0,0 +1,78 @@ +float4x4 combinedMat : register(c0); +float4x4 worldMat : register(c4); +float3x3 normalMat : register(c8); +float4 matCol : register(c12); +float4 surfProps : register(c13); +float4 ambientLight : register(c14); + +#define surfAmbient (surfProps.x) +#define surfSpecular (surfProps.y) +#define surfDiffuse (surfProps.z) +#define surfPrelight (surfProps.w) + +#include "lighting.h" + +int numDirLights : register(i0); +int numPointLights : register(i1); +int numSpotLights : register(i2); +int4 firstLight : register(c15); +Light lights[8] : register(c16); + +float4x4 texMat : register(c40); + +#define firstDirLight (firstLight.x) +#define firstPointLight (firstLight.y) +#define firstSpotLight (firstLight.z) + +struct VS_in +{ + float4 Position : POSITION; + float3 Normal : NORMAL; + float2 TexCoord : TEXCOORD0; + float4 Prelight : COLOR0; +}; + +struct VS_out { + float4 Position : POSITION; + float2 TexCoord0 : TEXCOORD0; + float2 TexCoord1 : TEXCOORD1; + float4 Color : COLOR0; +}; + + +VS_out main(in VS_in input) +{ + VS_out output; + + output.Position = mul(combinedMat, input.Position); + float3 Vertex = mul(worldMat, input.Position).xyz; + float3 Normal = mul(normalMat, input.Normal); + + output.TexCoord0 = input.TexCoord; + output.TexCoord1 = mul(texMat, float4(Normal, 1.0)).xy; + + output.Color = float4(0.0, 0.0, 0.0, 1.0); + if(surfPrelight > 0.0) + output.Color = input.Prelight; + + output.Color.rgb += ambientLight.rgb * surfAmbient; + + int i; +#ifdef DIRECTIONALS + for(i = 0; i < numDirLights; i++) + output.Color.xyz += DoDirLight(lights[i+firstDirLight], Normal)*surfDiffuse; +#endif +#ifdef POINTLIGHTS + for(i = 0; i < numPointLights; i++) + output.Color.xyz += DoPointLight(lights[i+firstPointLight], Vertex.xyz, Normal)*surfDiffuse; +#endif +#ifdef SPOTLIGHTS + for(i = 0; i < numSpotLights; i++) + output.Color.xyz += DoSpotLight(lights[i+firstSpotLight], Vertex.xyz, Normal)*surfDiffuse; +#endif + // PS2 clamps before material color + output.Color = clamp(output.Color, 0.0, 1.0); + output.Color *= matCol; + + return output; +} diff --git a/src/d3d/shaders/matfx_env_all_VS.h b/src/d3d/shaders/matfx_env_all_VS.h new file mode 100644 index 0000000..7cd0b6d --- /dev/null +++ b/src/d3d/shaders/matfx_env_all_VS.h @@ -0,0 +1,508 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// fxc /T vs_2_0 /DDIRECTIONALS /DPOINTLIGHTS /DSPOTLIGHTS /Fh +// matfx_env_all_VS.h matfx_env_VS.hlsl +// +// +// Parameters: +// +// float4 ambientLight; +// float4x4 combinedMat; +// int4 firstLight; +// +// struct +// { +// float4 color; +// float4 position; +// float4 direction; +// +// } lights[8]; +// +// float4 matCol; +// float3x3 normalMat; +// int numDirLights; +// int numPointLights; +// int numSpotLights; +// float4 surfProps; +// float4x4 texMat; +// float4x4 worldMat; +// +// +// Registers: +// +// Name Reg Size +// -------------- ----- ---- +// numDirLights i0 1 +// numPointLights i1 1 +// numSpotLights i2 1 +// combinedMat c0 4 +// worldMat c4 4 +// normalMat c8 3 +// matCol c12 1 +// surfProps c13 1 +// ambientLight c14 1 +// firstLight c15 1 +// lights c16 24 +// texMat c40 4 +// + + vs_2_0 + def c11, 3, 0, 0, 0 + def c44, 0, -0, -1, 1 + dcl_position v0 + dcl_normal v1 + dcl_texcoord v2 + dcl_color v3 + mul r0, v0.y, c1 + mad r0, c0, v0.x, r0 + mad r0, c2, v0.z, r0 + mad oPos, c3, v0.w, r0 + mul r0.xyz, v0.y, c5 + mad r0.xyz, c4, v0.x, r0 + mad r0.xyz, c6, v0.z, r0 + mad r0.xyz, c7, v0.w, r0 + mul r1.xyz, v1.y, c9 + mad r1.xyz, c8, v1.x, r1 + mad r1.xyz, c10, v1.z, r1 + mov r2.xw, c44 + slt r0.w, r2.x, c13.w + add r3, v3, c44.yyyz + mad r3, r0.w, r3, c44.xxxw + mov r2.x, c13.x + mad r2.xyz, c14, r2.x, r3 + mov r4.xyz, r2 + mov r0.w, c44.x + rep i0 + add r1.w, r0.w, c15.x + mul r1.w, r1.w, c11.x + mova a0.x, r1.w + dp3 r1.w, r1, -c18[a0.x] + max r1.w, r1.w, c44.x + mul r5.xyz, r1.w, c16[a0.x] + mad r4.xyz, r5, c13.z, r4 + add r0.w, r0.w, c44.w + endrep + mov r2.xyz, r4 + mov r0.w, c44.x + rep i1 + add r1.w, r0.w, c15.y + mul r1.w, r1.w, c11.x + mova a0.x, r1.w + add r5.xyz, r0, -c17[a0.x] + dp3 r1.w, r5, r5 + rsq r1.w, r1.w + mul r5.xyz, r1.w, r5 + dp3 r4.w, r1, -r5 + max r4.w, r4.w, c44.x + mul r5.xyz, r4.w, c16[a0.x] + rcp r1.w, r1.w + rcp r4.w, c16[a0.x].w + mad r1.w, r1.w, -r4.w, c44.w + max r1.w, r1.w, c44.x + mul r5.xyz, r1.w, r5 + mad r2.xyz, r5, c13.z, r2 + add r0.w, r0.w, c44.w + endrep + mov r3.xyz, r2 + mov r0.w, c44.x + rep i2 + add r1.w, r0.w, c15.z + mul r1.w, r1.w, c11.x + mova a0.x, r1.w + add r4.xyz, r0, -c17[a0.x] + dp3 r1.w, r4, r4 + rsq r1.w, r1.w + mul r4.xyz, r1.w, r4 + dp3 r4.w, r1, -r4 + dp3 r4.x, r4, c18[a0.x] + max r4.y, r4.w, c44.x + add r4.x, r4.x, c17[a0.x].w + add r4.z, r2.w, c17[a0.x].w + rcp r4.z, r4.z + mul r4.x, r4.z, r4.x + slt r4.z, r4.x, c44.x + mad r4.y, r4.z, -r4.y, r4.y + max r4.x, r4.x, c18[a0.x].w + mul r4.x, r4.x, r4.y + mul r4.xyz, r4.x, c16[a0.x] + rcp r1.w, r1.w + rcp r4.w, c16[a0.x].w + mad r1.w, r1.w, -r4.w, c44.w + max r1.w, r1.w, c44.x + mul r4.xyz, r1.w, r4 + mad r3.xyz, r4, c13.z, r3 + add r0.w, r0.w, c44.w + endrep + max r0, r3, c44.x + min r0, r0, c44.w + mul oD0, r0, c12 + mul r0.xy, r1.y, c41 + mad r0.xy, c40, r1.x, r0 + mad r0.xy, c42, r1.z, r0 + add oT1.xy, r0, c43 + mov oT0.xy, v2 + +// approximately 97 instruction slots used +#endif + +const BYTE g_vs20_main[] = +{ + 0, 2, 254, 255, 254, 255, + 158, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 66, 2, + 0, 0, 0, 2, 254, 255, + 12, 0, 0, 0, 28, 0, + 0, 0, 0, 1, 0, 0, + 59, 2, 0, 0, 12, 1, + 0, 0, 2, 0, 14, 0, + 1, 0, 58, 0, 28, 1, + 0, 0, 0, 0, 0, 0, + 44, 1, 0, 0, 2, 0, + 0, 0, 4, 0, 2, 0, + 56, 1, 0, 0, 0, 0, + 0, 0, 72, 1, 0, 0, + 2, 0, 15, 0, 1, 0, + 62, 0, 84, 1, 0, 0, + 0, 0, 0, 0, 100, 1, + 0, 0, 2, 0, 16, 0, + 24, 0, 66, 0, 176, 1, + 0, 0, 0, 0, 0, 0, + 192, 1, 0, 0, 2, 0, + 12, 0, 1, 0, 50, 0, + 28, 1, 0, 0, 0, 0, + 0, 0, 199, 1, 0, 0, + 2, 0, 8, 0, 3, 0, + 34, 0, 212, 1, 0, 0, + 0, 0, 0, 0, 228, 1, + 0, 0, 1, 0, 0, 0, + 1, 0, 2, 0, 244, 1, + 0, 0, 0, 0, 0, 0, + 4, 2, 0, 0, 1, 0, + 1, 0, 1, 0, 6, 0, + 244, 1, 0, 0, 0, 0, + 0, 0, 19, 2, 0, 0, + 1, 0, 2, 0, 1, 0, + 10, 0, 244, 1, 0, 0, + 0, 0, 0, 0, 33, 2, + 0, 0, 2, 0, 13, 0, + 1, 0, 54, 0, 28, 1, + 0, 0, 0, 0, 0, 0, + 43, 2, 0, 0, 2, 0, + 40, 0, 4, 0, 162, 0, + 56, 1, 0, 0, 0, 0, + 0, 0, 50, 2, 0, 0, + 2, 0, 4, 0, 4, 0, + 18, 0, 56, 1, 0, 0, + 0, 0, 0, 0, 97, 109, + 98, 105, 101, 110, 116, 76, + 105, 103, 104, 116, 0, 171, + 171, 171, 1, 0, 3, 0, + 1, 0, 4, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 99, 111, 109, 98, 105, 110, + 101, 100, 77, 97, 116, 0, + 3, 0, 3, 0, 4, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 102, 105, + 114, 115, 116, 76, 105, 103, + 104, 116, 0, 171, 1, 0, + 2, 0, 1, 0, 4, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 108, 105, 103, 104, + 116, 115, 0, 99, 111, 108, + 111, 114, 0, 171, 171, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 112, 111, + 115, 105, 116, 105, 111, 110, + 0, 100, 105, 114, 101, 99, + 116, 105, 111, 110, 0, 171, + 107, 1, 0, 0, 116, 1, + 0, 0, 132, 1, 0, 0, + 116, 1, 0, 0, 141, 1, + 0, 0, 116, 1, 0, 0, + 5, 0, 0, 0, 1, 0, + 12, 0, 8, 0, 3, 0, + 152, 1, 0, 0, 109, 97, + 116, 67, 111, 108, 0, 110, + 111, 114, 109, 97, 108, 77, + 97, 116, 0, 171, 171, 171, + 3, 0, 3, 0, 3, 0, + 3, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 110, 117, + 109, 68, 105, 114, 76, 105, + 103, 104, 116, 115, 0, 171, + 171, 171, 0, 0, 2, 0, + 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 110, 117, 109, 80, 111, 105, + 110, 116, 76, 105, 103, 104, + 116, 115, 0, 110, 117, 109, + 83, 112, 111, 116, 76, 105, + 103, 104, 116, 115, 0, 115, + 117, 114, 102, 80, 114, 111, + 112, 115, 0, 116, 101, 120, + 77, 97, 116, 0, 119, 111, + 114, 108, 100, 77, 97, 116, + 0, 118, 115, 95, 50, 95, + 48, 0, 77, 105, 99, 114, + 111, 115, 111, 102, 116, 32, + 40, 82, 41, 32, 72, 76, + 83, 76, 32, 83, 104, 97, + 100, 101, 114, 32, 67, 111, + 109, 112, 105, 108, 101, 114, + 32, 57, 46, 50, 57, 46, + 57, 53, 50, 46, 51, 49, + 49, 49, 0, 171, 81, 0, + 0, 5, 11, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 81, 0, + 0, 5, 44, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 0, 128, 0, 0, 128, 191, + 0, 0, 128, 63, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 3, 0, 0, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 0, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 10, 0, 0, 128, + 3, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 85, 144, 1, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 15, 128, 0, 0, + 228, 160, 0, 0, 0, 144, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 15, 128, + 2, 0, 228, 160, 0, 0, + 170, 144, 0, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 15, 192, 3, 0, 228, 160, + 0, 0, 255, 144, 0, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 85, 144, 5, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 4, 0, 228, 160, + 0, 0, 0, 144, 0, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 6, 0, + 228, 160, 0, 0, 170, 144, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 7, 128, + 7, 0, 228, 160, 0, 0, + 255, 144, 0, 0, 228, 128, + 5, 0, 0, 3, 1, 0, + 7, 128, 1, 0, 85, 144, + 9, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 8, 0, 228, 160, 1, 0, + 0, 144, 1, 0, 228, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 10, 0, 228, 160, + 1, 0, 170, 144, 1, 0, + 228, 128, 1, 0, 0, 2, + 2, 0, 9, 128, 44, 0, + 228, 160, 12, 0, 0, 3, + 0, 0, 8, 128, 2, 0, + 0, 128, 13, 0, 255, 160, + 2, 0, 0, 3, 3, 0, + 15, 128, 3, 0, 228, 144, + 44, 0, 149, 160, 4, 0, + 0, 4, 3, 0, 15, 128, + 0, 0, 255, 128, 3, 0, + 228, 128, 44, 0, 192, 160, + 1, 0, 0, 2, 2, 0, + 1, 128, 13, 0, 0, 160, + 4, 0, 0, 4, 2, 0, + 7, 128, 14, 0, 228, 160, + 2, 0, 0, 128, 3, 0, + 228, 128, 1, 0, 0, 2, + 4, 0, 7, 128, 2, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 128, 44, 0, + 0, 160, 38, 0, 0, 1, + 0, 0, 228, 240, 2, 0, + 0, 3, 1, 0, 8, 128, + 0, 0, 255, 128, 15, 0, + 0, 160, 5, 0, 0, 3, + 1, 0, 8, 128, 1, 0, + 255, 128, 11, 0, 0, 160, + 46, 0, 0, 2, 0, 0, + 1, 176, 1, 0, 255, 128, + 8, 0, 0, 4, 1, 0, + 8, 128, 1, 0, 228, 128, + 18, 32, 228, 161, 0, 0, + 0, 176, 11, 0, 0, 3, + 1, 0, 8, 128, 1, 0, + 255, 128, 44, 0, 0, 160, + 5, 0, 0, 4, 5, 0, + 7, 128, 1, 0, 255, 128, + 16, 32, 228, 160, 0, 0, + 0, 176, 4, 0, 0, 4, + 4, 0, 7, 128, 5, 0, + 228, 128, 13, 0, 170, 160, + 4, 0, 228, 128, 2, 0, + 0, 3, 0, 0, 8, 128, + 0, 0, 255, 128, 44, 0, + 255, 160, 39, 0, 0, 0, + 1, 0, 0, 2, 2, 0, + 7, 128, 4, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 128, 44, 0, 0, 160, + 38, 0, 0, 1, 1, 0, + 228, 240, 2, 0, 0, 3, + 1, 0, 8, 128, 0, 0, + 255, 128, 15, 0, 85, 160, + 5, 0, 0, 3, 1, 0, + 8, 128, 1, 0, 255, 128, + 11, 0, 0, 160, 46, 0, + 0, 2, 0, 0, 1, 176, + 1, 0, 255, 128, 2, 0, + 0, 4, 5, 0, 7, 128, + 0, 0, 228, 128, 17, 32, + 228, 161, 0, 0, 0, 176, + 8, 0, 0, 3, 1, 0, + 8, 128, 5, 0, 228, 128, + 5, 0, 228, 128, 7, 0, + 0, 2, 1, 0, 8, 128, + 1, 0, 255, 128, 5, 0, + 0, 3, 5, 0, 7, 128, + 1, 0, 255, 128, 5, 0, + 228, 128, 8, 0, 0, 3, + 4, 0, 8, 128, 1, 0, + 228, 128, 5, 0, 228, 129, + 11, 0, 0, 3, 4, 0, + 8, 128, 4, 0, 255, 128, + 44, 0, 0, 160, 5, 0, + 0, 4, 5, 0, 7, 128, + 4, 0, 255, 128, 16, 32, + 228, 160, 0, 0, 0, 176, + 6, 0, 0, 2, 1, 0, + 8, 128, 1, 0, 255, 128, + 6, 0, 0, 3, 4, 0, + 8, 128, 16, 32, 255, 160, + 0, 0, 0, 176, 4, 0, + 0, 4, 1, 0, 8, 128, + 1, 0, 255, 128, 4, 0, + 255, 129, 44, 0, 255, 160, + 11, 0, 0, 3, 1, 0, + 8, 128, 1, 0, 255, 128, + 44, 0, 0, 160, 5, 0, + 0, 3, 5, 0, 7, 128, + 1, 0, 255, 128, 5, 0, + 228, 128, 4, 0, 0, 4, + 2, 0, 7, 128, 5, 0, + 228, 128, 13, 0, 170, 160, + 2, 0, 228, 128, 2, 0, + 0, 3, 0, 0, 8, 128, + 0, 0, 255, 128, 44, 0, + 255, 160, 39, 0, 0, 0, + 1, 0, 0, 2, 3, 0, + 7, 128, 2, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 128, 44, 0, 0, 160, + 38, 0, 0, 1, 2, 0, + 228, 240, 2, 0, 0, 3, + 1, 0, 8, 128, 0, 0, + 255, 128, 15, 0, 170, 160, + 5, 0, 0, 3, 1, 0, + 8, 128, 1, 0, 255, 128, + 11, 0, 0, 160, 46, 0, + 0, 2, 0, 0, 1, 176, + 1, 0, 255, 128, 2, 0, + 0, 4, 4, 0, 7, 128, + 0, 0, 228, 128, 17, 32, + 228, 161, 0, 0, 0, 176, + 8, 0, 0, 3, 1, 0, + 8, 128, 4, 0, 228, 128, + 4, 0, 228, 128, 7, 0, + 0, 2, 1, 0, 8, 128, + 1, 0, 255, 128, 5, 0, + 0, 3, 4, 0, 7, 128, + 1, 0, 255, 128, 4, 0, + 228, 128, 8, 0, 0, 3, + 4, 0, 8, 128, 1, 0, + 228, 128, 4, 0, 228, 129, + 8, 0, 0, 4, 4, 0, + 1, 128, 4, 0, 228, 128, + 18, 32, 228, 160, 0, 0, + 0, 176, 11, 0, 0, 3, + 4, 0, 2, 128, 4, 0, + 255, 128, 44, 0, 0, 160, + 2, 0, 0, 4, 4, 0, + 1, 128, 4, 0, 0, 128, + 17, 32, 255, 160, 0, 0, + 0, 176, 2, 0, 0, 4, + 4, 0, 4, 128, 2, 0, + 255, 128, 17, 32, 255, 160, + 0, 0, 0, 176, 6, 0, + 0, 2, 4, 0, 4, 128, + 4, 0, 170, 128, 5, 0, + 0, 3, 4, 0, 1, 128, + 4, 0, 170, 128, 4, 0, + 0, 128, 12, 0, 0, 3, + 4, 0, 4, 128, 4, 0, + 0, 128, 44, 0, 0, 160, + 4, 0, 0, 4, 4, 0, + 2, 128, 4, 0, 170, 128, + 4, 0, 85, 129, 4, 0, + 85, 128, 11, 0, 0, 4, + 4, 0, 1, 128, 4, 0, + 0, 128, 18, 32, 255, 160, + 0, 0, 0, 176, 5, 0, + 0, 3, 4, 0, 1, 128, + 4, 0, 0, 128, 4, 0, + 85, 128, 5, 0, 0, 4, + 4, 0, 7, 128, 4, 0, + 0, 128, 16, 32, 228, 160, + 0, 0, 0, 176, 6, 0, + 0, 2, 1, 0, 8, 128, + 1, 0, 255, 128, 6, 0, + 0, 3, 4, 0, 8, 128, + 16, 32, 255, 160, 0, 0, + 0, 176, 4, 0, 0, 4, + 1, 0, 8, 128, 1, 0, + 255, 128, 4, 0, 255, 129, + 44, 0, 255, 160, 11, 0, + 0, 3, 1, 0, 8, 128, + 1, 0, 255, 128, 44, 0, + 0, 160, 5, 0, 0, 3, + 4, 0, 7, 128, 1, 0, + 255, 128, 4, 0, 228, 128, + 4, 0, 0, 4, 3, 0, + 7, 128, 4, 0, 228, 128, + 13, 0, 170, 160, 3, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 8, 128, 0, 0, + 255, 128, 44, 0, 255, 160, + 39, 0, 0, 0, 11, 0, + 0, 3, 0, 0, 15, 128, + 3, 0, 228, 128, 44, 0, + 0, 160, 10, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 44, 0, 255, 160, + 5, 0, 0, 3, 0, 0, + 15, 208, 0, 0, 228, 128, + 12, 0, 228, 160, 5, 0, + 0, 3, 0, 0, 3, 128, + 1, 0, 85, 128, 41, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 128, 40, 0, + 228, 160, 1, 0, 0, 128, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 3, 128, + 42, 0, 228, 160, 1, 0, + 170, 128, 0, 0, 228, 128, + 2, 0, 0, 3, 1, 0, + 3, 224, 0, 0, 228, 128, + 43, 0, 228, 160, 1, 0, + 0, 2, 0, 0, 3, 224, + 2, 0, 228, 144, 255, 255, + 0, 0 +}; diff --git a/src/d3d/shaders/matfx_env_amb_VS.h b/src/d3d/shaders/matfx_env_amb_VS.h new file mode 100644 index 0000000..293bc96 --- /dev/null +++ b/src/d3d/shaders/matfx_env_amb_VS.h @@ -0,0 +1,191 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// fxc /T vs_2_0 /Fh matfx_env_amb_VS.h matfx_env_VS.hlsl +// +// +// Parameters: +// +// float4 ambientLight; +// float4x4 combinedMat; +// float4 matCol; +// float3x3 normalMat; +// float4 surfProps; +// float4x4 texMat; +// +// +// Registers: +// +// Name Reg Size +// ------------ ----- ---- +// combinedMat c0 4 +// normalMat c8 3 +// matCol c12 1 +// surfProps c13 1 +// ambientLight c14 1 +// texMat c40 4 +// + + vs_2_0 + def c4, 0, -0, -1, 1 + dcl_position v0 + dcl_normal v1 + dcl_texcoord v2 + dcl_color v3 + mul r0, v0.y, c1 + mad r0, c0, v0.x, r0 + mad r0, c2, v0.z, r0 + mad oPos, c3, v0.w, r0 + mul r0.xyz, v1.y, c9 + mad r0.xyz, c8, v1.x, r0 + mad r0.xyz, c10, v1.z, r0 + mul r0.yw, r0.y, c41.xxzy + mad r0.xy, c40, r0.x, r0.ywzw + mad r0.xy, c42, r0.z, r0 + add oT1.xy, r0, c43 + mov r0.x, c4.x + slt r0.x, r0.x, c13.w + add r1, v3, c4.yyyz + mad r0, r0.x, r1, c4.xxxw + mov r1.x, c13.x + mad r0.xyz, c14, r1.x, r0 + max r0, r0, c4.x + min r0, r0, c4.w + mul oD0, r0, c12 + mov oT0.xy, v2 + +// approximately 21 instruction slots used +#endif + +const BYTE g_vs20_main[] = +{ + 0, 2, 254, 255, 254, 255, + 81, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 12, 1, + 0, 0, 0, 2, 254, 255, + 6, 0, 0, 0, 28, 0, + 0, 0, 0, 1, 0, 0, + 5, 1, 0, 0, 148, 0, + 0, 0, 2, 0, 14, 0, + 1, 0, 58, 0, 164, 0, + 0, 0, 0, 0, 0, 0, + 180, 0, 0, 0, 2, 0, + 0, 0, 4, 0, 2, 0, + 192, 0, 0, 0, 0, 0, + 0, 0, 208, 0, 0, 0, + 2, 0, 12, 0, 1, 0, + 50, 0, 164, 0, 0, 0, + 0, 0, 0, 0, 215, 0, + 0, 0, 2, 0, 8, 0, + 3, 0, 34, 0, 228, 0, + 0, 0, 0, 0, 0, 0, + 244, 0, 0, 0, 2, 0, + 13, 0, 1, 0, 54, 0, + 164, 0, 0, 0, 0, 0, + 0, 0, 254, 0, 0, 0, + 2, 0, 40, 0, 4, 0, + 162, 0, 192, 0, 0, 0, + 0, 0, 0, 0, 97, 109, + 98, 105, 101, 110, 116, 76, + 105, 103, 104, 116, 0, 171, + 171, 171, 1, 0, 3, 0, + 1, 0, 4, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 99, 111, 109, 98, 105, 110, + 101, 100, 77, 97, 116, 0, + 3, 0, 3, 0, 4, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 109, 97, + 116, 67, 111, 108, 0, 110, + 111, 114, 109, 97, 108, 77, + 97, 116, 0, 171, 171, 171, + 3, 0, 3, 0, 3, 0, + 3, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 115, 117, + 114, 102, 80, 114, 111, 112, + 115, 0, 116, 101, 120, 77, + 97, 116, 0, 118, 115, 95, + 50, 95, 48, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 81, 0, 0, 5, + 4, 0, 15, 160, 0, 0, + 0, 0, 0, 0, 0, 128, + 0, 0, 128, 191, 0, 0, + 128, 63, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 144, 31, 0, 0, 2, + 3, 0, 0, 128, 1, 0, + 15, 144, 31, 0, 0, 2, + 5, 0, 0, 128, 2, 0, + 15, 144, 31, 0, 0, 2, + 10, 0, 0, 128, 3, 0, + 15, 144, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 85, 144, 1, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 15, 128, 0, 0, 228, 160, + 0, 0, 0, 144, 0, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 15, 128, 2, 0, + 228, 160, 0, 0, 170, 144, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 15, 192, + 3, 0, 228, 160, 0, 0, + 255, 144, 0, 0, 228, 128, + 5, 0, 0, 3, 0, 0, + 7, 128, 1, 0, 85, 144, + 9, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 7, 128, + 8, 0, 228, 160, 1, 0, + 0, 144, 0, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 7, 128, 10, 0, 228, 160, + 1, 0, 170, 144, 0, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 10, 128, 0, 0, + 85, 128, 41, 0, 96, 160, + 4, 0, 0, 4, 0, 0, + 3, 128, 40, 0, 228, 160, + 0, 0, 0, 128, 0, 0, + 237, 128, 4, 0, 0, 4, + 0, 0, 3, 128, 42, 0, + 228, 160, 0, 0, 170, 128, + 0, 0, 228, 128, 2, 0, + 0, 3, 1, 0, 3, 224, + 0, 0, 228, 128, 43, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 1, 128, 4, 0, + 0, 160, 12, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 13, 0, 255, 160, + 2, 0, 0, 3, 1, 0, + 15, 128, 3, 0, 228, 144, + 4, 0, 149, 160, 4, 0, + 0, 4, 0, 0, 15, 128, + 0, 0, 0, 128, 1, 0, + 228, 128, 4, 0, 192, 160, + 1, 0, 0, 2, 1, 0, + 1, 128, 13, 0, 0, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 14, 0, 228, 160, + 1, 0, 0, 128, 0, 0, + 228, 128, 11, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 4, 0, 0, 160, + 10, 0, 0, 3, 0, 0, + 15, 128, 0, 0, 228, 128, + 4, 0, 255, 160, 5, 0, + 0, 3, 0, 0, 15, 208, + 0, 0, 228, 128, 12, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 3, 224, 2, 0, + 228, 144, 255, 255, 0, 0 +}; diff --git a/src/d3d/shaders/matfx_env_amb_dir_VS.h b/src/d3d/shaders/matfx_env_amb_dir_VS.h new file mode 100644 index 0000000..d59aedf --- /dev/null +++ b/src/d3d/shaders/matfx_env_amb_dir_VS.h @@ -0,0 +1,286 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// fxc /T vs_2_0 /DDIRECTIONALS /Fh matfx_env_amb_dir_VS.h matfx_env_VS.hlsl +// +// +// Parameters: +// +// float4 ambientLight; +// float4x4 combinedMat; +// int4 firstLight; +// +// struct +// { +// float4 color; +// float4 position; +// float4 direction; +// +// } lights[8]; +// +// float4 matCol; +// float3x3 normalMat; +// int numDirLights; +// float4 surfProps; +// float4x4 texMat; +// +// +// Registers: +// +// Name Reg Size +// ------------ ----- ---- +// numDirLights i0 1 +// combinedMat c0 4 +// normalMat c8 3 +// matCol c12 1 +// surfProps c13 1 +// ambientLight c14 1 +// firstLight c15 1 +// lights c16 24 +// texMat c40 4 +// + + vs_2_0 + def c4, 3, 0, 0, 0 + def c5, 0, -0, -1, 1 + dcl_position v0 + dcl_normal v1 + dcl_texcoord v2 + dcl_color v3 + mul r0, v0.y, c1 + mad r0, c0, v0.x, r0 + mad r0, c2, v0.z, r0 + mad oPos, c3, v0.w, r0 + mul r0.xyz, v1.y, c9 + mad r0.xyz, c8, v1.x, r0 + mad r0.xyz, c10, v1.z, r0 + mov r1.x, c5.x + slt r0.w, r1.x, c13.w + add r1, v3, c5.yyyz + mad r1, r0.w, r1, c5.xxxw + mov r2.x, c13.x + mad r2.xyz, c14, r2.x, r1 + mov r1.xyz, r2 + mov r0.w, c5.x + rep i0 + add r2.w, r0.w, c15.x + mul r2.w, r2.w, c4.x + mova a0.x, r2.w + dp3 r2.w, r0, -c18[a0.x] + max r2.w, r2.w, c5.x + mul r3.xyz, r2.w, c16[a0.x] + mad r1.xyz, r3, c13.z, r1 + add r0.w, r0.w, c5.w + endrep + max r1, r1, c5.x + min r1, r1, c5.w + mul oD0, r1, c12 + mul r0.yw, r0.y, c41.xxzy + mad r0.xy, c40, r0.x, r0.ywzw + mad r0.xy, c42, r0.z, r0 + add oT1.xy, r0, c43 + mov oT0.xy, v2 + +// approximately 36 instruction slots used +#endif + +const BYTE g_vs20_main[] = +{ + 0, 2, 254, 255, 254, 255, + 134, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 224, 1, + 0, 0, 0, 2, 254, 255, + 9, 0, 0, 0, 28, 0, + 0, 0, 0, 1, 0, 0, + 217, 1, 0, 0, 208, 0, + 0, 0, 2, 0, 14, 0, + 1, 0, 58, 0, 224, 0, + 0, 0, 0, 0, 0, 0, + 240, 0, 0, 0, 2, 0, + 0, 0, 4, 0, 2, 0, + 252, 0, 0, 0, 0, 0, + 0, 0, 12, 1, 0, 0, + 2, 0, 15, 0, 1, 0, + 62, 0, 24, 1, 0, 0, + 0, 0, 0, 0, 40, 1, + 0, 0, 2, 0, 16, 0, + 24, 0, 66, 0, 116, 1, + 0, 0, 0, 0, 0, 0, + 132, 1, 0, 0, 2, 0, + 12, 0, 1, 0, 50, 0, + 224, 0, 0, 0, 0, 0, + 0, 0, 139, 1, 0, 0, + 2, 0, 8, 0, 3, 0, + 34, 0, 152, 1, 0, 0, + 0, 0, 0, 0, 168, 1, + 0, 0, 1, 0, 0, 0, + 1, 0, 2, 0, 184, 1, + 0, 0, 0, 0, 0, 0, + 200, 1, 0, 0, 2, 0, + 13, 0, 1, 0, 54, 0, + 224, 0, 0, 0, 0, 0, + 0, 0, 210, 1, 0, 0, + 2, 0, 40, 0, 4, 0, + 162, 0, 252, 0, 0, 0, + 0, 0, 0, 0, 97, 109, + 98, 105, 101, 110, 116, 76, + 105, 103, 104, 116, 0, 171, + 171, 171, 1, 0, 3, 0, + 1, 0, 4, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 99, 111, 109, 98, 105, 110, + 101, 100, 77, 97, 116, 0, + 3, 0, 3, 0, 4, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 102, 105, + 114, 115, 116, 76, 105, 103, + 104, 116, 0, 171, 1, 0, + 2, 0, 1, 0, 4, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 108, 105, 103, 104, + 116, 115, 0, 99, 111, 108, + 111, 114, 0, 171, 171, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 112, 111, + 115, 105, 116, 105, 111, 110, + 0, 100, 105, 114, 101, 99, + 116, 105, 111, 110, 0, 171, + 47, 1, 0, 0, 56, 1, + 0, 0, 72, 1, 0, 0, + 56, 1, 0, 0, 81, 1, + 0, 0, 56, 1, 0, 0, + 5, 0, 0, 0, 1, 0, + 12, 0, 8, 0, 3, 0, + 92, 1, 0, 0, 109, 97, + 116, 67, 111, 108, 0, 110, + 111, 114, 109, 97, 108, 77, + 97, 116, 0, 171, 171, 171, + 3, 0, 3, 0, 3, 0, + 3, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 110, 117, + 109, 68, 105, 114, 76, 105, + 103, 104, 116, 115, 0, 171, + 171, 171, 0, 0, 2, 0, + 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 115, 117, 114, 102, 80, 114, + 111, 112, 115, 0, 116, 101, + 120, 77, 97, 116, 0, 118, + 115, 95, 50, 95, 48, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 57, + 46, 50, 57, 46, 57, 53, + 50, 46, 51, 49, 49, 49, + 0, 171, 171, 171, 81, 0, + 0, 5, 4, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 81, 0, + 0, 5, 5, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 0, 128, 0, 0, 128, 191, + 0, 0, 128, 63, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 3, 0, 0, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 0, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 10, 0, 0, 128, + 3, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 85, 144, 1, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 15, 128, 0, 0, + 228, 160, 0, 0, 0, 144, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 15, 128, + 2, 0, 228, 160, 0, 0, + 170, 144, 0, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 15, 192, 3, 0, 228, 160, + 0, 0, 255, 144, 0, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 85, 144, 9, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 8, 0, 228, 160, + 1, 0, 0, 144, 0, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 10, 0, + 228, 160, 1, 0, 170, 144, + 0, 0, 228, 128, 1, 0, + 0, 2, 1, 0, 1, 128, + 5, 0, 0, 160, 12, 0, + 0, 3, 0, 0, 8, 128, + 1, 0, 0, 128, 13, 0, + 255, 160, 2, 0, 0, 3, + 1, 0, 15, 128, 3, 0, + 228, 144, 5, 0, 149, 160, + 4, 0, 0, 4, 1, 0, + 15, 128, 0, 0, 255, 128, + 1, 0, 228, 128, 5, 0, + 192, 160, 1, 0, 0, 2, + 2, 0, 1, 128, 13, 0, + 0, 160, 4, 0, 0, 4, + 2, 0, 7, 128, 14, 0, + 228, 160, 2, 0, 0, 128, + 1, 0, 228, 128, 1, 0, + 0, 2, 1, 0, 7, 128, + 2, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 128, + 5, 0, 0, 160, 38, 0, + 0, 1, 0, 0, 228, 240, + 2, 0, 0, 3, 2, 0, + 8, 128, 0, 0, 255, 128, + 15, 0, 0, 160, 5, 0, + 0, 3, 2, 0, 8, 128, + 2, 0, 255, 128, 4, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 1, 176, 2, 0, + 255, 128, 8, 0, 0, 4, + 2, 0, 8, 128, 0, 0, + 228, 128, 18, 32, 228, 161, + 0, 0, 0, 176, 11, 0, + 0, 3, 2, 0, 8, 128, + 2, 0, 255, 128, 5, 0, + 0, 160, 5, 0, 0, 4, + 3, 0, 7, 128, 2, 0, + 255, 128, 16, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 4, 1, 0, 7, 128, + 3, 0, 228, 128, 13, 0, + 170, 160, 1, 0, 228, 128, + 2, 0, 0, 3, 0, 0, + 8, 128, 0, 0, 255, 128, + 5, 0, 255, 160, 39, 0, + 0, 0, 11, 0, 0, 3, + 1, 0, 15, 128, 1, 0, + 228, 128, 5, 0, 0, 160, + 10, 0, 0, 3, 1, 0, + 15, 128, 1, 0, 228, 128, + 5, 0, 255, 160, 5, 0, + 0, 3, 0, 0, 15, 208, + 1, 0, 228, 128, 12, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 10, 128, 0, 0, + 85, 128, 41, 0, 96, 160, + 4, 0, 0, 4, 0, 0, + 3, 128, 40, 0, 228, 160, + 0, 0, 0, 128, 0, 0, + 237, 128, 4, 0, 0, 4, + 0, 0, 3, 128, 42, 0, + 228, 160, 0, 0, 170, 128, + 0, 0, 228, 128, 2, 0, + 0, 3, 1, 0, 3, 224, + 0, 0, 228, 128, 43, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 3, 224, 2, 0, + 228, 144, 255, 255, 0, 0 +}; diff --git a/src/d3d/shaders/matfx_env_tex_PS.h b/src/d3d/shaders/matfx_env_tex_PS.h new file mode 100644 index 0000000..819b6ce --- /dev/null +++ b/src/d3d/shaders/matfx_env_tex_PS.h @@ -0,0 +1,125 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// fxc /T ps_2_0 /DTEX /Fh matfx_env_tex_PS.h matfx_env_PS.hlsl +// +// +// Parameters: +// +// float4 colorClamp; +// sampler2D diffTex; +// sampler2D envTex; +// float shininess; +// +// +// Registers: +// +// Name Reg Size +// ------------ ----- ---- +// shininess c0 1 +// colorClamp c1 1 +// diffTex s0 1 +// envTex s1 1 +// + + ps_2_0 + dcl t0.xy + dcl t1.xy + dcl v0 + dcl_2d s0 + dcl_2d s1 + texld r0, t1, s1 + texld r1, t0, s0 + mul r1, r1, v0 + max r2.xyz, r1, c1 + mul r2.xyz, r2, c0.x + mul r0.xyz, r0, r2 + mad r1.xyz, r1, r1.w, r0 + mov oC0, r1 + +// approximately 8 instruction slots used (2 texture, 6 arithmetic) +#endif + +const BYTE g_ps20_main[] = +{ + 0, 2, 255, 255, 254, 255, + 68, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 219, 0, + 0, 0, 0, 2, 255, 255, + 4, 0, 0, 0, 28, 0, + 0, 0, 0, 1, 0, 0, + 212, 0, 0, 0, 108, 0, + 0, 0, 2, 0, 1, 0, + 1, 0, 6, 0, 120, 0, + 0, 0, 0, 0, 0, 0, + 136, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 2, 0, + 144, 0, 0, 0, 0, 0, + 0, 0, 160, 0, 0, 0, + 3, 0, 1, 0, 1, 0, + 6, 0, 168, 0, 0, 0, + 0, 0, 0, 0, 184, 0, + 0, 0, 2, 0, 0, 0, + 1, 0, 2, 0, 196, 0, + 0, 0, 0, 0, 0, 0, + 99, 111, 108, 111, 114, 67, + 108, 97, 109, 112, 0, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 100, 105, + 102, 102, 84, 101, 120, 0, + 4, 0, 12, 0, 1, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 101, 110, + 118, 84, 101, 120, 0, 171, + 4, 0, 12, 0, 1, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 115, 104, + 105, 110, 105, 110, 101, 115, + 115, 0, 171, 171, 0, 0, + 3, 0, 1, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 112, 115, 95, 50, + 95, 48, 0, 77, 105, 99, + 114, 111, 115, 111, 102, 116, + 32, 40, 82, 41, 32, 72, + 76, 83, 76, 32, 83, 104, + 97, 100, 101, 114, 32, 67, + 111, 109, 112, 105, 108, 101, + 114, 32, 57, 46, 50, 57, + 46, 57, 53, 50, 46, 51, + 49, 49, 49, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 31, 0, + 0, 2, 0, 0, 0, 144, + 1, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 1, 8, + 228, 160, 66, 0, 0, 3, + 1, 0, 15, 128, 0, 0, + 228, 176, 0, 8, 228, 160, + 5, 0, 0, 3, 1, 0, + 15, 128, 1, 0, 228, 128, + 0, 0, 228, 144, 11, 0, + 0, 3, 2, 0, 7, 128, + 1, 0, 228, 128, 1, 0, + 228, 160, 5, 0, 0, 3, + 2, 0, 7, 128, 2, 0, + 228, 128, 0, 0, 0, 160, + 5, 0, 0, 3, 0, 0, + 7, 128, 0, 0, 228, 128, + 2, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 1, 0, 228, 128, 1, 0, + 255, 128, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0 +}; diff --git a/src/matfx.cpp b/src/matfx.cpp index ffc83c9..919d0b9 100644 --- a/src/matfx.cpp +++ b/src/matfx.cpp @@ -24,6 +24,8 @@ namespace rw { +bool32 MatFX::modulateEnvMap; + // Atomic static void* diff --git a/src/rwplugins.h b/src/rwplugins.h index 1f2b972..b26046a 100644 --- a/src/rwplugins.h +++ b/src/rwplugins.h @@ -157,6 +157,8 @@ struct MatFX static void enableEffects(Atomic *atomic); static void disableEffects(Atomic *atomic); static bool32 getEffects(Atomic *atomic); + + static bool32 modulateEnvMap; }; struct MatFXGlobals