Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Using different textures depending on the vertex height

Author
Message
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 1st Dec 2017 07:27
Hey guys,

let's say I create a terrain using a memblock mesh.
Is it possible to use different textures, depending on the vertex heights of the mesh?
For example, if the vertex height is <5, a grass texture is used.
If the vertex height is >=5 and <10, a rock texture is used.
If the vertex height is >=10, a snow texture is used.



PSY LABS Games
Coders don't die, they just gosub without return
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Dec 2017 08:00
I would suggest a shader is the best way to achieve this. You could transition between textures smoothly too.
Using AppGameKit V2 Tier 1
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Dec 2017 08:27 Edited at: 1st Dec 2017 10:23
the other way around you can make one texture from water,grass ,rock ,snow and mix them together by code.
a small terrain plus image texture you can also paint ways, streets or static tree shadows.
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.2) Radeon R7 265 : Mac mini OS High Sierra (10.13)
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 1st Dec 2017 08:44 Edited at: 1st Dec 2017 09:09
I guess you actually want a slope shader.
There is one in my Water shader demo, I did't create the shader (maybe it was the default terrain shader) but I can help you to change it to your needs if you like ?
Actually in that shader there are examples of slope based and height based color blending.
I think there is a shader doing what you need somewhere in the forums.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Dec 2017 09:26
There are definitely examples of this on the forums. Game Guru and DBP terrain have this ability.
Don't forget you will probably want to consider steepness too. - Shallow gradient = grass or snow. Steep gradient = rock.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 2nd Dec 2017 20:40
Doesn't the supplied terrain demo use a shader to for the height textures?
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 3rd Dec 2017 21:40
Thanks alot guys,

Seems I really have to start dealing with shaders.
I really appreciate your offer janbo. I'm totally new to the shader stuff, so if you don't mind I'll toss you a message from time to time asking stuff

Again, thank you all for the great info!!


PSY LABS Games
Coders don't die, they just gosub without return
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 4th Dec 2017 21:26
As nz0 said:
Quote: " Doesn't the supplied terrain demo use a shader to for the height textures?"


Yes it does:

Login to post a reply

Server time is: 2024-11-24 06:52:44
Your offset time is: 2024-11-24 06:52:44