shader idea is much faster, but you need to know how to write and implement shaders

Code: Select all
//CGridSceneNode* grid = new CGridSceneNode(scnMgr->getRootSceneNode(), scnMgr);
EDE_GridSceneNode* gridS = new EDE_GridSceneNode(scnMgr->getRootSceneNode(), scnMgr);
Code: Select all
ITerrainSceneNode* scnNode = scnMgr->addTerrainSceneNode(
"heightmap.bmp",
scnMgr->getRootSceneNode(),
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(4.f, 1.0f, 4.f), // scale
video::SColor ( 255, 255, 255, 255 ), // vertexColor
5, // maxLOD
scene::ETPS_17, // patchSize
4 // smoothFactor
);
scnNode->setMaterialFlag(video::EMF_LIGHTING, false);
scnNode->setMaterialTexture(0, videoDrv->getTexture("free-grass-texture-013.jpg"));
vector3d<f32> *ed = new vector3d<f32>[8];
for (int i = 0; i < 8; i++)
{
ed[i] = vector3d<f32>((f32) 0);
}
scnNode->getTransformedBoundingBox().getEdges(ed);
int w = floor(ed[4].X - ed[0].X);
int h = floor(ed[2].Z - ed[0].Z);
//ITriangleSelector* triSel = scnNode->getTriangleSelector();
//CGridSceneNode* grid = new CGridSceneNode(scnMgr->getRootSceneNode(), scnMgr);
EDE_GridSceneNode* gridS = new EDE_GridSceneNode(scnNode, scnMgr);
gridS->init(w, h, SColor(255, 255, 255, 255), vector3df(0.0f, 0.0f, 0.0f), 10.0f);
gridS->createGridOnTerrain(scnNode);
Unforuniently I dont have a clue how to use or write shaders.hendu wrote:The shader approach would have only a small performance hit over rendering the terrain as is - less than 5% slower would be a decent guess.
No additional draw calls, no memory overhead.
Thank you for constantly helping me out by expaining stuff to me I should have learned before picking up Irrlicht, i mean it.STTrife wrote:vertices != triangles.
If you call drawvertexprimitivelist, you can specify what type of primive you want to draw. triangles is just one of them. the vertices you pass are just the points of your heightgrid, and the indices are references (array-indexes) to those vertices, and depending on what type of primitive type you draw the indices are read in a certain way.
if you use line-strips, it will treat each index in the indices (referencing to a vertex) as a next point on the line. sort of connect the dots. so if you pass it all the vertices of for example a horizontal line in your grid, and you pass an array of [0,1,2,3,4,5...] as indices, it will draw a line trough all the vertices you given.
So basically, in the vertices you specify: these are the points that my 'object' is made out of, and the indices are a way of telling the graphics card/driver how to connect those vertices to form the drawing you want. in the case of traingles. if you follow/read the documention on the drawvertexprimitivelist, it will tell you how the different types of primitives work. it's quite understandable.