Page 1 of 1

Some water rendering help..

Posted: Tue Dec 12, 2006 10:40 pm
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?

Posted: Tue Dec 12, 2006 10:44 pm
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 :)

Posted: Tue Dec 12, 2006 10:46 pm
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?

Posted: Tue Dec 12, 2006 10:50 pm
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?

Posted: Tue Dec 12, 2006 10:54 pm
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 

Posted: Tue Dec 12, 2006 10:55 pm
by pinkman
I already said I fixed it.. worried on making it reflect nice though, cause it isnt working out o.o

Posted: Tue Dec 12, 2006 11:30 pm
by Acki
Well, take it as a hint for the next time you have such a problem... :lol:

Posted: Wed Dec 13, 2006 12:04 am
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..