Page 1 of 1

Textured Custom SceneNode

Posted: Tue Jun 21, 2005 6:22 pm
by OemmeS
Hi all!

I've been playing around with Irrlicht for some time now, and I started a little project of mine. Well, in the distant future I hope it becomes something like Frontier: First Encounters (yeah I know I'm not the only one trying this ;-) )

For now, it is nothing more than a "Planet Simulator", wich means that I am able to display a Planet (no random Planet at the Moment, I'm still working with an Earth Texture) at different Levels of Detail regarding to the distance to the ground.

Everything works fine, and I am pretty pleased with the results (I used this http://www.gamedev.net/reference/articl ... le2074.asp algorithm and with a few modifications it looks really promising)

Anyways, at the moment I don't use any textures on the Mesh, just colours for the corners that I pick from the Earth Texture and the Earth BumpMap from the PerPixel Lightning Demo for the geometric detail

For more detail I add some random noise to the colors and the heighmap.


It would look much better if I were able to apply textures to the triangles, but I don't know how to do that. Applying one Texture to the whole Mesh is no option, because the Mesh is highly dynamic and changes quite often.

I have searched the API for some time, but I could not find any function to draw a texture to a single triangle. Does Irrlicht support this? Or if it does not, could I use some OpenGL functions?

Posted: Tue Jun 28, 2005 1:09 pm
by OemmeS
No idea?

Posted: Tue Jun 28, 2005 1:55 pm
by Guest
How about:
http://irrlicht.sourceforge.net/docu/cl ... r.html#a56

PS: I've looked at that link, and I get the impression that there are going to be masses of T-junctions. So you may get pixel-sized artifacts.

Posted: Tue Jun 28, 2005 2:14 pm
by Thulsa Doom
Nice article about tesselation, but seems like massive work to implement.
Just two ideas:
1) Pick the color from textures with different static resolution (dynamic scaling) depending on your mesh resolution or distance to the viewpoint.
2) Calculate a 2D-projection of your vertices on a texture to get the u,v coords and color. This will also ensure to get the correct curvature effect of the sphere's texture.

With good hope for some nice screenshots soon,
:)

Posted: Wed Jun 29, 2005 6:51 pm
by OemmeS
Thanks for the replies!

@ Guest: I don't think that setMaterial would work. This way I could apply one texture to the whole mesh, but I would like to set the texture for every triangle seperately because they all have a different LOD.

You are right about the t-junctions and the resulting artifacts, but I think I can live with it. Also, I have thought of a very simple solution: I just set a sphere with a similar texture but much less polys inside the planet-mesh, so all I would see through these artifacts would be a pixel with almost the right color, wich shouldn't be too disturbing


@ Thulsa Doom: The idea with the different textures is really nice, because I could save VERY much memory. At the moment I need about 350 mb :oops:(two 16384*8192*24 bit textures + unoptimized data structure)

Your second point is already implemented :) It is exactly the way I do it, but of course the ground detail is limited to the triangle size. With textures it could be much higher


Btw, the implementing was not that hard (except for bugfixing - one wrong return statement can really ruin your day :wink: )


Screenshots will have to wait until I get some webspace :?

Posted: Wed Jun 29, 2005 8:32 pm
by Phenix
Currently I am using in my game 6 runtime-generated textures for a planet when the player is quite far to that (some km from the surface), and another (just one, maybe I'll correct it in the future) when the camera is near to the surface. It's just a grey scale texture, I use vertex colors to paint it.
Results are quite ugly, the runtime generated texture isn't realistic and the switch between the generated texture and the grey scale one isn't completely seamless, but I'm too lazy to change it :)
I just hope Thargoids won't hurt me if their planet is ugly :(