I have got quite a few of rendermonkeys samples working in irrlicht, this one is using the same 3d texture NoiseVolume that was required by the glitter shader (so I am sure that the textures are loaded correctly). However, I get no issue adding the shader below, but smgr->endScene crashes after the material is used on any mesh:
callback function
Code: Select all
class MyShaderCallBack : public video::IShaderConstantSetCallBack
{
public:
IrrlichtDevice *device;
virtual void OnSetConstants(video::IMaterialRendererServices* services,s32 userData)
{
f32 flamability = 0.34;
f32 pressure = 0.60;
f32 powerBoost = 0.16;
f32 intensity = 1.0;
f32 speed = 0.15;
f32 noisiness = 0.5;
f32 time = device->getTimer()->getTime()/200.0;
f32 explositivity = 0.449550;
f32 Noise = 0;
f32 Flame = 1;
services->setPixelShaderConstant("flamability", reinterpret_cast<f32*>(&flamability), 1);
services->setPixelShaderConstant("pressure", reinterpret_cast<f32*>(&pressure), 1);
services->setPixelShaderConstant("powerBoost", reinterpret_cast<f32*>(&powerBoost), 1);
services->setPixelShaderConstant("intensity",reinterpret_cast<f32*>(&intensity),1);
services->setPixelShaderConstant("speed", reinterpret_cast<f32*>(&speed), 1);
services->setPixelShaderConstant("noisiness", reinterpret_cast<f32*>(&noisiness), 1);
services->setPixelShaderConstant("time_0_X", reinterpret_cast<f32*>(&time), 1);
services->setPixelShaderConstant("explositivity",reinterpret_cast<f32*>(&explositivity),1);
services->setPixelShaderConstant("Noise",reinterpret_cast<f32*>(&Noise),1);
services->setPixelShaderConstant("Flame",reinterpret_cast<f32*>(&Flame),1);
}
};
vert shader
Code: Select all
varying vec2 vTexCoord;
void main(void) {
gl_Position = ftransform();
vTexCoord = vec2(sign(gl_Vertex));
}
frag shader
Code: Select all
uniform float flamability;
uniform float pressure;
uniform float powerBoost;
uniform float intensity;
uniform float speed;
uniform float noisiness;
uniform float time;
uniform float explosivity;
uniform sampler2D Flame;
uniform sampler3D Noise;
varying vec2 vTexCoord;
void main(void)
{
float t = fract(time * speed);
t = pow(t, explosivity);
float size = intensity * 3.75 * t * (t * (t - 2.0) + 1.0);
float dist = length(vTexCoord) / (0.1 + size);
float n = texture3D(Noise, vec3(noisiness * vTexCoord, flamability * time - pressure * dist)).r;
vec4 flame = texture2D(Flame, vec2(size * powerBoost + size * (2.0 * n - dist), 0.0));
gl_FragColor = flame;
}
to make sure that the shader worked properly I copied irrSpintz explosion shader from his project but get the same crash on meshes and a straight cubeSceneNode, not sure the best way to debug access violation in smgr, anyone see something wrong with the callback mayb?
thanks
Rob