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.

DarkBASIC Professional Discussion / Shaders / texturing & graphical options available for terrain objects

Author
Message
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 14th Oct 2011 23:35
I'm working hard on a nice terrain system for my schmup's level editor, since i've recently realized manually making dozens of giant levels in MAX just won't do it efficiently neither on my and the computer's end.

The pictures are about my current state, right now rendered in 3dsMax, but i hope the next progress upload can finally be an ingame shot. It already could have been, but i don't have shadows applied yet in DBPro. (and this is what this thread is about, read the questions after the line!)

TestTerrainShotA
TestTerrainShotB


I have discovered that having hexagon shaped tiles makes it a lot easier to make more diverse, and practically more natural looking ground. These tiles will be instanced / deleted real time as the camera goes forward on its path, making up a segment of a computer screen sized mesh at a time.


-------------



The mesh building part is (still can't say 'was', but i'm close) just the tip of the iceberg, now i would need to know, what are the overall options for achieving something which is the closest as possible to a terrain for example in Starcraft 2 or Red Alert 3, on the texturing side?


The most hot question here is that should i be bothered by the built in availability of multi-texturing at all? Can that be executed with normal maps, and self shadow casting, running just fine at the same time?

If yes, how many layers of textures can i activate on a polygon at once?


...or the built in multi-texturing is for using diffuse maps (the standard single texture we usually apply to any object) only?

...in that case, what shader / solution should i use for the task?


Should i use the built in shadow casting shader, or are there faster, or nicer solutions? I only need self casting for terrain only, this will be a fast paced game, nobody cares of an enemy tank casting shadows onto itself.


I would also want to put alpha mapped tank tracks / explosion decals onto the terrain and things like that, is it possible for these type of objects to receive the shadow of the terrain, but not to cast shadows themselves ONTO the terrain object?


Thank you all for any help.

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Oct 2011 00:51
You could have a look at this:

blend mapped terrain

Quote: "If yes, how many layers of textures can i activate on a polygon at once?"


There are eight texture blending stages available if that's what you mean.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 15th Oct 2011 13:02
Really nice demo Gandalf! Had some problems to run it like the other guy on that thread, but managed to see it in the end.

My only question for it: can these four blended textures have their own, separate normal maps?

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Oct 2011 13:22
Thanks.

Quote: "can these four blended textures have their own, separate normal maps?"


I doubt it. It was rather awkward using the blend mapping commands in that demo. I believe KisTech posted a demo showing how to achieve normal mapping with the blend mapping commands but my suspicion is that you'd need too many blending stages to add that here. I could be wrong though.

My preferred solution would use a shader and you can do more or less whatever you like then as long as you stay within 8 textures overall (and within the shader instruction count limits).

Have you checked out this thread:

Shaders for Advanced Terrain

Most of those can be used, with perhaps some minor changes, with other types of terrain too.

I have another terrain shader which uses triplanar texturing and an ambient occlusion effect. Perhaps it's time I posted a demo?

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 16th Oct 2011 19:37
Wow you mean you have a shader which makes the ground parts darker as they get less sunlight from all the different angles? I've been jealously watching that effect in many Starcraft 2 clips recently...

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Oct 2011 12:56 Edited at: 17th Oct 2011 12:57
Quote: "Wow you mean you have a shader which makes the ground parts darker as they get less sunlight from all the different angles?"


Yes - and no.

I precalculate the ambient occlusion per vertex when I create the terrain and store the result in a UV stage. The shader then uses that data to create the ambient occlusion effect.

Here's a screenshot. Notice how the landscape is somewhat darker at the base of cliffs and in hollows etc. It's a rather subtle effect but should be visible.



This is still work in progress and I haven't finished adding extra features.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 17th Oct 2011 14:23
Very cool looking stuff!

You are right, precalculation is the way to go.

Though in my case i have to do it real time cause of the nature of my real-time building / destructing terrain system. But i guess one or two ground element per a frame is not such a shock with ~10-30 poly elements.

---

Got any suggestions how could i average the normals at the edges where two ground pieces meet? There tend to appear seams here and there revealing that the ground is built of many small objects...

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2011 13:26
Quote: "Got any suggestions how could i average the normals at the edges where two ground pieces meet? There tend to appear seams here and there revealing that the ground is built of many small objects..."


There are at least two ways of doing that. Either precalculate all the normals for the whole terrain in one go and then copy them into the vertices of the different component objects or limbs when you construct them (that's what I do). Or just work along the seams and average the normals of the two sides (remembering to renormalize after averaging). If there are not too many vertices you could probably do that in real time as well - especially if the different sections have a simple structure such as high poly plains.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 18th Oct 2011 14:18
'Precalculation / storing the data' needs to be avoided since i already have hundreds of UDTs and giant arrays all over the game. And the level can be almost infinite in length.

I think i'm gonna be fine with detecting the vertex pairs efficiently real time which are in need of averaging.

But how exactly the method for getting their average angle looks like?

Important note, that these are vertices all over the place in 3d space, it is not a heightmap based ground.

If i remember correctly normals are stored as numbers ranging from 0 to 1... or -1 to +1?... which exactly?

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2011 14:43
Quote: "But how exactly the method for getting their average angle looks like?"


Why do you need that?

Example

First normal: (Nx, Ny, Nz) = (-0.107832773, 0.970494959, 0.215665546)
Second normal: (Nx, Ny, Nz) = (0.104115841, 0.989100492, 0.104115841)
Average of above: (-0.001858466, 0.979797725, 0.159890694)

Renormalized: (Nx, Ny, Nz) = (-0.00187202, 0.986943368, 0.161056773)

Quote: "I think i'm gonna be fine with detecting the vertex pairs efficiently real time which are in need of averaging."


Sounds like that's the way to go.

Quote: "which exactly?"


The second. Each component is a number in the range -1 to 1 - and the vector has length 1 (the renormalization step above is a refinement to ensure that).
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Oct 2011 18:09
You can normalize the normals (lol?) using vectors very easily:



TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2011 19:18
Yep. But make sure Nx, etc, are floats first.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 18th Oct 2011 20:16
Thank you guys very much!

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%

Login to post a reply

Server time is: 2026-07-11 04:43:36
Your offset time is: 2026-07-11 04:43:36