I created that DLL. I need it to pass more than one custom matrix to shaders.
It is actually very simple but I plan to expand it to help me with some other stuff as well
You can use it for everything you want to.
You have to use it like that:
-Put the dll in your plugindir.
-Place these lines on top of your scripts:
Code:
dllfunction SetCustomMatrix(char *Name, float *Matrix); //passes a custom matrix to a shader
dllfunction SetCustomVector(char *Name, float *Vector); //passes a custom matrix to a shader
-Call the function you want to use in the event of the material you want to pass the matrix to:
Code:
SetCustomMatrix("MatName", ArrayWith16Values);
SetCustomVector("VecName", ArrayWith4Values);
-You can than acces the Vector and the Matrix in the Shader like this:
Code:
float4x4 MatName;
float4 VecName;
This is the sourcecode of the dll:
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <math.h.>
// engine specific header file
#define DLL_USE // always define before including adll.h
#include "adll.h"
#include <d3dx9.h>
// DLL main entry point - normally this needs not to be changed
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
// make sure the library is linked
engine_bind();
return TRUE;
}
LPD3DXEFFECT *A7_eff;
DLLFUNC void SetCustomMatrix(char *Name, float *Matrix)
{
D3DXMATRIX matCustom = (D3DXMATRIX)Matrix;
A7_eff = (LPD3DXEFFECT*)ev->render_d3dxeffect;
if(A7_eff)
{
LPD3DXEFFECT(A7_eff)->SetMatrix(Name,&matCustom);
}
}
DLLFUNC void SetCustomVector(char *Name, float *Vector)
{
D3DXVECTOR4 vecCustom = (D3DXVECTOR4)Vector;
A7_eff = (LPD3DXEFFECT*)ev->render_d3dxeffect;
if(A7_eff)
{
LPD3DXEFFECT(A7_eff)->SetVector(Name,&vecCustom);
}
}
The problem for the errors is that this dll doesn´t get loaded on many computers (it works fine on my computer...)... -_-
Here is a short clip of the shadows until I solve the problem with the dll:
http://www.youtube.com/watch?v=JL8NIaTpGTo
Thanks for all those comments