Page 1 of 1

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

Posted: Sun Mar 17, 2024 10:46 am
by mitras1
Hi, if you didn't understand what I am talking about, here's the image:
Image

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

Posted: Sun Mar 17, 2024 11:50 am
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.