Some water rendering help..

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
pinkman
Posts: 25
Joined: Sun Dec 10, 2006 3:04 am

Some water rendering help..

Post by pinkman »

I got this code from another code(the water shading class)


s32 dmat = irr::video::EMT_SOLID;
dmat = gpu->addHighLevelShaderMaterial(WATER_VERTEX_GLSL, "main", video::EVST_VS_1_1,
WATER_FRAGMENT_GLSL, "main", video::EPST_PS_1_1, this , video::EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
waterNode->setMaterialType((video::E_MATERIAL_TYPE)dmat);

I am trying to get it to work with...

// Add some water >.>
IAnimatedMesh * WaterMesh = smgr->getMesh( "media/water.obj" );
ISceneNode * waterNode = smgr->addWaterSurfaceSceneNode( WaterMesh->getMesh(0),2.0f, 150.0f, 10.0f);
waterNode->setMaterialTexture(0, driver->getTexture("media/water.jpg"));
//waterNode->setMaterialType(EMT_TRANSPARENT_REFLECTION_2_LAYER );
waterNode->setPosition(core::vector3df(0,100,0));
waterNode->setScale(core::vector3df(25.0f, 2.5f, 25.0f));

but the param 'this' wich is stating the class its in, well, my script isnt in a class, its just in main() so, what would I replace the 'this' param with in

s32 dmat = irr::video::EMT_SOLID;
dmat = gpu->addHighLevelShaderMaterial(WATER_VERTEX_GLSL, "main", video::EVST_VS_1_1,
WATER_FRAGMENT_GLSL, "main", video::EPST_PS_1_1, this , video::EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
waterNode->setMaterialType((video::E_MATERIAL_TYPE)dmat);

to make it work?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You got the code from somewhere right, and in that case it was used within a class, so what was that class? Then you know what "this" has to be :)
Image Image Image
pinkman
Posts: 25
Joined: Sun Dec 10, 2006 3:04 am

Post by pinkman »

I am not using that class though, cause the water shader they made, compiles fine, but I see no animation, its just a polygon, and the shader I dont think is showing correctly either when I use it.. so I just made a ater node, and planned on adding the shader to it, im not using the class in my project so this cannot be that class, it would have to be something else right?
pinkman
Posts: 25
Joined: Sun Dec 10, 2006 3:04 am

Post by pinkman »

Sorry for the double post, but I got it, it was 0 :P although the shader still dont look right.. but ill figure it out ;_;

[ Edit ]

What do I need to do, to have the water reflect everything in the world? Sky, Hegihtmap, Models, Shadows perhaps... does anyone know? o.o the c++ shader code looks really nice, but when I place nito my prohect, doesnt look the same as in the screenshot o_o problems?
Last edited by pinkman on Tue Dec 12, 2006 10:54 pm, edited 1 time in total.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

There is a magical file included to Irrlicht called "Irrlicht.chm" !!! ;)
Look for "addHighLevelShaderMaterial" and you'll see what this is for and what to set it to...
Well, for lazy people:

Code: Select all

callback,:  Pointer to an implementation of IShaderConstantSetCallBack in which you can set the needed vertex and pixel shader program constants. Set this to 0 if you don't need this 
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
pinkman
Posts: 25
Joined: Sun Dec 10, 2006 3:04 am

Post by pinkman »

I already said I fixed it.. worried on making it reflect nice though, cause it isnt working out o.o
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Well, take it as a hint for the next time you have such a problem... :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
pinkman
Posts: 25
Joined: Sun Dec 10, 2006 3:04 am

Post by pinkman »

So does anyone have a nice water shader? That well blend in nicely with a terrain heigtmap? o.o

reflection the heightmap I think would work perfectly how I want..
Post Reply