Texture on terrain texture?

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Texture on terrain texture?

Post by LunaRebirth »

Hey so I've come across another problem.
Okay so what I'm trying to do is use my terrain texture as a grass terrain.
But I want to place a road image on the terrain at specific coordinates.

Is this possible to do??
I tried using a plane, but I want the road to go over hills and other ground bumps, not a straight line.

Thanks!!
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Texture on terrain texture?

Post by CuteAlien »

Simplest solution - let he road be it's own meshbuffer (not saying it's simple, just probably easier than other solutions). You will need vertices at the road-borders anyway to have good uv-coordinates (as you don't want the road to bleed all over the map).
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Texture on terrain texture?

Post by LunaRebirth »

I can't find anything on this Via google or the irrlicht search button.

How would I go about even doing that?
I'm trying to add them to a heightmap terrain
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Texture on terrain texture?

Post by CuteAlien »

You would have to work directly on the meshbuffers. Meaning you have to code it yourself. Or draw the road directly into the texture. That is actually easier I suppose.
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
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Texture on terrain texture?

Post by ent1ty »

Why not a separate mesh (not just a beshbuffer) for some kind of a road model? A simple 2D plane that floats a bit above the ground would be the simplest one, or you can make a nice road with kerbs (or whatever are those called) and such:

Image


Then again, I don't now what art style are you going for :)
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Texture on terrain texture?

Post by CuteAlien »

Yeah, good idea. With curbs/kerbs you can increase enough to avoid z-buffer flickering.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Texture on terrain texture?

Post by LunaRebirth »

In your photo, the ground has grass and gravel and diet and stuff, but I can't get that working either.
But I want the image to move onto the surface of the the heightmap.
With all the trouble finding a topic on this, i'm assuming that's not possible??

I'm going for a cartoon style.
Maybe tiles.
But if I add like, a road onto the texture itself, i'm scaling the heightmap so the texture scales also and it looks really bad
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Texture on terrain texture?

Post by CuteAlien »

We gave you 3 different approaches to this already. So obviously it's possible. It's just not trivial - you will have to put in some work to code this. And you need an understanding of how meshes, meshbuffers and materials do work. This is not an easy problem - it's far easier to create the whole map in a 3D tool like blender, export it and load it completely. But what you want to do is probably something like an editor - and that always means lot's of coding.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Texture on terrain texture?

Post by LunaRebirth »

Because I don't want to make a terrain, then make a complete road that I have to manually curve in blender to match the hill.

And I can't use blender for terrains, because I'm using terrain->getHeight for my collision. And I plan to use blender for my terrain in the future, but I don't know how to use the getCollisionNode feature, it isn't working.
That's why.

Not only that, This is my first week using Irrlicht at all. There's no way I know how to use any of those approaches yet.
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Texture on terrain texture?

Post by CuteAlien »

Sorry, the problem is as hard as it is. If you want to tackle this you will need some in-depth knowledge of 3D. There might be more solutions than the 3 we mentioned - but I doubt any of them will be easier. I wish I could help you more, but I don't have the time to write a longer tutorial. Maybe google around for other solutions. This stuff works more or less similar independent of the engine so you might find more info on the web about how to approach this.

Using another way to find a collision in a map is not so hard to code. For that you would have to create a triangleselector for your mesh. That can then be passed to the collision animator - and even has some collision functions itself.

Making the map in Blender or using a heightmap can both make sense depending on the type of game you are writing. Heightmaps are first of all a speed optimization to allow using larger terrains. They are also sometimes a little easier to work with for some case - but ... that's hard to generalize. On the other hand with maps in Blender (or a similar tool) you have a lot more flexibility (but might have a harder time with collisions if you abuse that freedom too much).
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
Neirdan
Posts: 39
Joined: Tue Aug 14, 2012 10:29 pm

Re: Texture on terrain texture?

Post by Neirdan »

http://irrlicht.sourceforge.net/forum// ... hp?t=26702

You could code a shader.


Getting your terrain height isn't that hard.
Cast a ray from a very high point in the sky in a straight down line (like from irr::core::vector3df(0.f,4096.f,0.f)to irr::core::vector3df(0.f,-1024.f,0.f) ), and get the point where that line collide with your terrain.
See the collision tutorial to get the example.
Post Reply