How to draw solid material, wireframe and point cloud at the same time?

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
mitras1
Posts: 26
Joined: Mon Jan 29, 2024 8:02 am

How to draw solid material, wireframe and point cloud at the same time?

Post by mitras1 »

Hi, if you didn't understand what I am talking about, here's the image:
Image
CuteAlien
Admin
Posts: 9745
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to draw solid material, wireframe and point cloud at the same time?

Post by CuteAlien »

On OpenGL you can do it by rendering the model 3 times. First time as usual. Second time with a material which has material.Wireframe true and a bigger has material.Thickness. And third time with material.PointCloud true and even bigger Thickness.
But it's unlikely to work well on other renderers as OpenGL is the only one which cares about line thickness. And even there it's arguably if vertices look good as they are rects and not round. You also have to make sure the extra materials have different colors (can be done by enabling lighting and using high emissive colors and disabling other colors).

If you use Irrlicht svn trunk you can maybe get that effect a bit with Direct3D (but only with thin lines) by setting material.PolygonOffsetDepthBias to some negative value like -0.5 or so. Or maybe material.PolygonOffsetSlopeScale does the trick (I don't have much experience with that one).
Irrlicht 1.8 did have PolygonOffsetFactor, but I think that only ever worked on D3D8.

If you want to see the effect you can modify Irrlicht example 03.CustomSceneNode by adding those to the render() function:

Code: Select all

		irr::video::SMaterial lineMat;
		lineMat.Lighting = true;
		lineMat.Wireframe = true;
		lineMat.Thickness = 2.f;
		lineMat.EmissiveColor = irr::video::SColor(255, 255, 50, 50);
		driver->setMaterial(lineMat);
		driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 4, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);

		irr::video::SMaterial pointMatMat;
		pointMatMat.Lighting = true;
		pointMatMat.PointCloud = true;
		pointMatMat.Thickness = 15.f;
		pointMatMat.EmissiveColor = irr::video::SColor(255, 255, 255, 255);
		driver->setMaterial(pointMatMat);
		driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 4, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
There are probably better options to do this somehow with shaders, but I never coded one like this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply