0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Ways to send variables/locations to entity shaders
[Re: jumpman]
#473719
08/07/18 17:20
08/07/18 17:20
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
The effect compiler errors are always described in a prompt window. It does never crash. I don't know what could be happening Here goes a complete and tested example of the very same
#include <acknex.h>
#include <windows.h>
#include <d3d9.h>
#define skFloatArray skill20
function evnCamMtl () {
if (mtl->d3deffect == NULL)
return 1;
if (me == NULL)
return 0;
if (my->skFloatArray == 0)
return 0;
LPD3DXEFFECT _fx = mtl->d3deffect;
_fx->SetVector("myFloats", (float*)my->skFloatArray);
return 0;
}
MATERIAL *mtlCam = {
event = evnCamMtl;
flags = ENABLE_RENDER;
effect = "
const float4x4 matWorldViewProj;
float4 myFloats;
void VS (
in float4 inPos : POSITION,
out float4 outPos : POSITION) {
outPos = mul ( inPos, matWorldViewProj );
}
float4 PS () : COLOR0 {
return myFloats;
}
technique tech {
pass p0 {
ZWriteEnable = True;
AlphaBlendEnable = False;
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}
";
}
action actSphere () {
float *_fV = sys_malloc(sizeof(float) * 4);
memset(_fV, 0, sizeof(float) * 4);
my->skFloatArray = (var)_fV;
my->material = mtlCam;
while (!key_esc) {
_fV[0] = random(1);
_fV[1] = random(1);
_fV[2] = random(1);
_fV[3] = random(1);
wait(1);
}
sys_free(_fV);
ent_remove(me);
}
void main () {
wait(1);
level_load ("");
camera->x = -200;
int _count = 0;
for (; _count<5; _count+=1)
ENTITY *_ent = ent_create(SPHERE_MDL, vector(0, _count*50, 0), actSphere);
while (!key_esc) {
camera->pan = ang(camera->pan - mickey.x * 0.2);
camera->tilt = clamp(camera->tilt - mickey.y * 0.2, -90, 90);
wait(1);
}
wait(1);
sys_exit(NULL);
}
|
|
|
|