[SOLVED] rendermonkey shader causes access violation

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
thespecial1
Posts: 135
Joined: Thu Oct 30, 2008 11:56 am
Location: UK
Contact:

[SOLVED] rendermonkey shader causes access violation

Post by thespecial1 »

Hi Guys

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
Last edited by thespecial1 on Tue May 11, 2010 4:16 pm, edited 1 time in total.
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

So, did you manage to put the 3D texture on your mesh? :shock:
thespecial1
Posts: 135
Joined: Thu Oct 30, 2008 11:56 am
Location: UK
Contact:

Post by thespecial1 »

certainly did mate, worked nicely on glitter ;0)
used this one http://irrlicht.sourceforge.net/phpBB2/ ... hlight=dds have also got a basic ogre style material loader working, needs more work thou, zip in ur mail including the compiled dds loader lib ;0)




**** solved
this appears to only be a problem on my ATI HD3000 in my laptop, the nvidia at work and my nvidia linux desktop compile the shader fine thou output is screwed in a funny matter so i presume when i learn to convert it properly for irrlicht it wont kill itself anymore.

i am learning GLSL from the orange book but i am trying to get some of the rendermonkey ones working as it seems a shame to re write the wheel completly.
Post Reply