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 / Ultimate Terrain/Landscapes

Author
Message
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Mar 2007 19:11
I've now managed to do something with AT - not quite sure which was the vital step . Here's a screenshot of the present version of the shader in action. There's obviously room for improvement on several grounds:

1. The terrain itself is too smooth (I'll try to find a rougher one).

2. Not enough variation in types of terrain - the auto-blending in the shader needs tweaking somehow - or perhaps more contrast in the textures used?

3. The bump mapping is not very obvious - could be an A.T. quirk that I haven't resolved yet or it could be the textures I'm using. (Or even a bug in my code ...)

4. The fps is painful!

On the plus side, the shader does all the blending and lighting for you - i.e. no rgb blending map needed. This - or a variation of it - could be used as a "default" technique when you don't have an rgb blending map handy.

Still need to write a shader for use with an rgb map plus bump mapping.

A simple way of improving fps would be to use just one normal map for the whole terrain - might try that to see how it looks.

Quote: "sounds like you got it nailed"


I wouldn't go that far yet.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Mar 2007 19:46 Edited at: 8th Mar 2007 19:51
Progress. Here's another screenshot using a tweaked version of the shader on the same terrain. Changes:

1. A "tweakable" in the shader that allows you to adjust the contrast used in the blending.

2. A different rock texture.

You could adjust the contrast in real-time to see what effect it has.

I still need to think about the bump mapping - not convinced it adds anything other than a big hit on fps.

I'll post the code and media later tonight when I've cleaned the code and done a few more tests.

Edit:

@Van B

We were talking yesterday about starting a new thread devoted to this stuff. There's no point really - this one's title is spot on already (I was probably thinking about the other thread which didn't mention terrains in the title). What do you think?

Oh yes, the Newsletter idea is a good one.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 8th Mar 2007 21:28 Edited at: 8th Mar 2007 21:30
I honestly dont think we need any bumpmapping, your right in that its only gonna eat up the fps.


@van b. How I am doing it is I make 1 memblock object, 100 x 100 and I define what the split value is, so it makes a single object 100 x 100 x20. Then save it as a "chunk.x" or some name like that. Then I open it in 3d exploration. "fix it", so it works right. I dont know all the boxes I have checked off hand, but I can look. Then I load it up clone it, line it all up, grab a section of a texture that corosponds with its location and then blamo, its all textured properly. Now I just use the vertex data commands and adjust the hieght from the heightmap that I have loaded into a memblock. Use sparkys collision and blamo, you can now walk on it, no big deal. Its actually not even that many lines of code, its nothing special really. Just effective.

@gg. Can you post an your latest shader so that I can test it out with my terrain. also dont do away with the bump map support quite yet.
Thank you.
Xenocythe
20
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Mar 2007 21:33
Wow! This is really amazing!

Great job David

I can't wait until I can program good enough to be able to do that

-Mansoor S.

(Formerly Xenocythe)
TinTin
19
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 8th Mar 2007 21:43
FPS 259
Load 2.578
System AMD 64 X2 2Ghz, 2Gb Ram WinXP Pro SP2 GeForce 7600GT

Silky Smooth, made me feel all warm and fuzzy inside. Great Job,,

Only. the water was a letdown, it had no refraction or reflection? Guess that could be easily fixed. DBP has an exelent shader that can do this already.

Idea..
How about a static mesh for the landscape that decreases in density the further away it gets from the camera..
i.e. up close the grid is say 0.25m square - at 1km distance it could be say 25m sqare.

This would keep the grid points down and FPS and detail up.

I've been thinking about a surface material system.
that depending on distance from camera
uses bumpmapping, shaders for close up and single textures for distant objects.

I've also been trying to do terrains generated in real time, (see comment on Rigid Multifractals) for every 1m I tgravel in any direction the Grid resets and the height map is recalculated on the fly, this makes for neverending landscapes and clever use of fog hides the edges.

If its ideas you wan't, I've got loads.....

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Mar 2007 21:45
Here's the demo.

I've included a second technique which doesn't include the bumpmapping so you can see the difference (there is a difference, but not much - might be more obvious if the light was moving around ). At least you have a choice.

You can adjust the contrast between the textures and a variable which affects how altitude affects the blending, and also switch between the two shader techniques. I get an fps of about 6 with bumpmapping, and about 20 without.

Since this demo uses Advanced Terrain, I'd be interested in how the demo performs on various machines.

You should be able to use the shader on any standard object.

Advanced Terrain enthusiasts might like to note that I had to fiddle with the terrain structure by adding the following after the terrain was built:



This seems to be necessary to access the normals and UV data correctly.

The effect can then be loaded in the usual way, i.e. without the new "don't calculate tangents" flag.
Omen
18
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 8th Mar 2007 22:08
@david:

One thing that helped a lot with the image quality in the shaders I'm using for terrain is to use multiple UV scales for the texture depending on the _distance_ of the pixel from the CameraPosition. Doing this eliminates the "pixelating" effect that you can get if very high detail is used across your entire terrain.

How you do it is to lerp between the original texture (the diffuse color texture) and the high-uv texture (which can optionally have detail and normal mapping combined with it).

Take a look at this shader code and I think you'll see how I'm doing this:

Alquerian
19
Years of Service
User Offline
Joined: 29th Mar 2006
Location: Reno Nevada
Posted: 8th Mar 2007 22:18 Edited at: 8th Mar 2007 22:37
@gg - I was attempting the same thing last night when I was working with the shader and AT. I wasn't sure if I needed to use 768 or 530 on the fvf, am I right in assuming that by using 768 would allow for an additional texture layer?

Edit:
I was getting 75 fps with the bumpmapping off and about 35 with it on. I wasn't too impressed with the difference between the two, you can barely even tell that bumpmapping is on. It looks great either way.

I am looking at implementing this in my current project: http://www.fantasymultimedia.com

Quit planning to make a game and make a game.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Mar 2007 22:47
Quote: "am I right in assuming that by using 768 would allow for an additional texture layer?"


I believe so. From the Help files we see that we need, for 1 set of UV coords:

FVF_XYX = 0x002 = 2
FVF_NORMAL = 0x010 = 16
FVF_TEX1 = 0x100 = 256

i.e. FVF = 274 in total.

For two we need:

FVF_XYX = 0x002 = 2
FVF_NORMAL = 0x010 = 16
FVF_TEX2 = 0x200 = 512

i.e. 530 in total

and for three UV coords:

FVF_XYX = 0x002 = 2
FVF_NORMAL = 0x010 = 16
FVF_TEX3 = 0x100 = 768

i.e. 786 in total.

My previous post was slightly misleading - my demo only needs 1 set of UV coords, i.e. I could have used:



which also works.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Mar 2007 23:00
Quote: "I was getting 75 fps with the bumpmapping off and about 35 with it on. I wasn't too impressed with the difference between the two, you can barely even tell that bumpmapping is on."


My thoughts exactly. Bump mapping is more obvious if you include a specular reflection so that the lighting changes as you move around. I took that out here because I was already struggling with the FPS on my system. I suppose I could put it back for those with nuclear-powered, liqid nitrogen-cooled PCs and GFX cards (although it might get messy if I'm near an instruction count limit - haven't checked though).

Quote: "It looks great either way"


Thanks - and good luck with the project.
TinTin
19
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 9th Mar 2007 00:26
@GG have you tried to limit the bumpmapping and specularity to the close proximity of the camera?
Same sort of idea as 'Omens'

I've been playing around with your code, converted it all to functions.

1. Added detection of desktop resolution and aspect ratio for those who have wide monitors.(still to do FOV for camera)

2. Added Set Alpha Mapping On 400,30 and Set Object Transparency 400,5 to the sea plain (it looks better)

3. Moved the Graphics to GFX folder and Shader to SHD folder.

I'm getting 88FPS at 1680x1050 with the modified code..

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
TinTin
19
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 9th Mar 2007 00:30
OOP's forgot the instructions...
1. No Mouse control, Use Arrow Keys.
2. Space for Stats.
3. Esc to quit.

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 9th Mar 2007 01:20 Edited at: 9th Mar 2007 01:21
@gg I cant get it to work with my terrain object properly. Since you wrote the shader I was wondering if you would be able to give it a shot. Here is my code.

david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 9th Mar 2007 04:51
It appears that my terrain chunks are not exaclty compatable with this shader, I can get 2 layers to blend and thats it.. So what I did to test this shader out was just load a single terrain piece up that I made in bryce. here is what I got.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 9th Mar 2007 05:19 Edited at: 9th Mar 2007 05:20
here is another screen of it running, I think I got the settings down now for a terrain loaded from bryce. This one looks a ton better than the last one.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Mar 2007 11:52
@TinTin


Quote: "I'm getting 88FPS at 1680x1050 with the modified code.."


What do you get with the original code?

@david w

Quote: "It appears that my terrain chunks are not exaclty compatable with this shader, I can get 2 layers to blend and thats it.. So what I did to test this shader out was just load a single terrain piece up that I made in bryce. here is what I got."


That screenshot looks fine to me. What's the problem? [Just seen your second screenshot - very nice! And fps = 333! I'm jealous. I really must get a decent PC ... Looks like you don't need the following comments now - but I'll leave them in in case they help explain how the shader works.]

The amounts of each texture that you get depend on the joint distribution of altitude ("h" say) and the vertical, i.e. y, component ("n" say) of the normal vector. The altitude, h, is scaled, more or less, to the range 0 to 1 in the shader, and, as long as the normal is not pointing downwards n will also be in the range 0 to 1. So, every point on the terrain gives a pair of values (h, n), with the following combinations corresponding to one of the four textures:

(h,n) =(0,0) or (0,1) or (1,0) or (1,1).

Intermediate values will give you a weighted blend of the four textures. If certain textures are missing then it probably means that certain combinations of (h,n) are not represented in your terrain. The two tweakables, "contrast" and "vertScale", in the shader code give you some control over the amount of blending which may overcome this. Did you experiment with these?

@TinTin and david w

Thanks for your comments. I'll look at your code when I get home this evening.

That shader is a first draft and I'm certainly interested in improvements. I can see some advantages of using functions in shaders - but my experience is that shader code is usually so short that functions just make the shader harder to read. A matter of taste really. Anyway, I'll have another look later today.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 9th Mar 2007 12:00
@gg Ok now that makes sense with why I am getting fuzzy results. I am just going to have to set the normals of my terrain at the same time I change the vertex's,,,,so i just got to think on this problem and see how I can overcome it so that my terrain chunks get the right vert information. I think I know how it works, so......well see when I get home from work tonight.
TinTin
19
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 9th Mar 2007 14:27
@GG I havn't modified the shader, it's still the same, it was the rest of the code I cut-up and pasted into functions. I added a few of my own, none of which change how the main loop works.

The FPS with your original code wasn't noticably different to the functionised version.

I also found lowering the Y_Scale made the landscape more pleasing (IMHO)

I've got so many things on the go (DBP wise) strangely though, there all loosely linked, this forum topic is something I'd planed later in my project (but while were at it ) I must congratulate the rest of you for some stunning insights and results.
Keep up the great work guys.... my is off to ya'll

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Omen
18
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 9th Mar 2007 17:37
Some people have talked about dynamically "downsampling" the vertices as you get further from the camera -- effectively creating a LOD system within the shader.

While I don't think you'd want to add/remove vertices since this would create tremendous overhead in calculating the new triangles, you could dynamically increase the _size_ of the quads as you get further from the camera.

What you do is start with a relatively small vertice-count quad, say 64x64. In your vertex shader you'd multiply the x and z components of the vertice by some factor that equates to the distance from the camera. The further away you are, the greater the factor. You'd most likely have to do the same to the UV values - but I haven't thought much about that part.

You'd need a function,then, to calculate what the height of the vertice at the _new_ height and pass that all on to the pixel shader. The odd thing about this techique is that you end up with a radial grid instead of a square grid
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Mar 2007 17:37
@TinTin

Quote: "I must congratulate the rest of you for some stunning insights and results."


Thanks - but at least one of those insights was one of yours:

Quote: "Here's another idea for you, pre-calculate the following for each surface poly. A) the height above sea level. B) the angle from horizontal."


It was really that idea that I implemented in my shader (although I didn't precalculate it). Thanks for prompting me to try it - it worked better than I expected.
TinTin
19
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 9th Mar 2007 19:17
Thanks GG glad to know I was of use hehe

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 10th Mar 2007 14:52
Load time=1.8 secs
FPS=40-80

CPU=AMD AthlonXP 2400+
RAM=768Mb
GPU=Radeon 9600SE 128Mb

Looking very promising!

Oneka
21
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 10th Mar 2007 17:17

This is definetly something I would use in my game.


Making better games everday!
Oh yeah and just so you know its Oh-nek-a not One-ka!
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 12th Mar 2007 07:08
@gg....How hard would it be to make the light source/direction controlable....like say I have a sphere/plain going around the terrain as a sun. The light source would then update its position from that objects position. So, you would have real-time self shadowing on the terrain. This is almost implemented already because If I use

float4 lightDir = {0.707107f, -0.707107f, 0.0f, 1.0f};

then set it to move around then it kinda already does this.

what are your thoughts on this. I think it would be really neat/important to have this feature.

Thank you.
Catalyst
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 12th Mar 2007 10:11
Load time = 1.9 sec
FPS = 355-375

Athlon X2 4200
Radeon x1900xtx
2GB RAM
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Mar 2007 15:19
Quote: "@gg....How hard would it be to make the light source/direction controlable....like say I have a sphere/plain going around the terrain as a sun. The light source would then update its position from that objects position. So, you would have real-time self shadowing on the terrain. "


I have a demo somewhere which does exactly that.

However, all you need to do is to record the object's X, Y and Z coords in a vector4 (set the fourth entry to zero) and pass the vector4 to a constant vector in the shader. The shader could call this vector "LightPos" and then do the lighting calculations for you. I'll see if I can knock up a demo later today.
H4ck1d
19
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 12th Mar 2007 23:35
Load time: 2.563 sec
FPS: 32-37

Athlon 64 3200+
GeForce 6100SM-M Chipset
512 mb ram

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Mar 2007 00:16
@david w

Here's the demo I promised earlier. Just replace my earlier dba file with this code. I've annotated the revised lines with ` *** light so you can see what's changed. The shader didn't need changing. You may need to tweak the rate at which the light angle increments.



The light is a directional one and its direction is indicated by the direction from the light object to a reference point which, in the demo, is at position (384, 0, 384), i.e. ground 0 in the middle of the terrain. You can see the light's direction (but not the detailed bumpmapping) more clearly if you move the camera up into the sky and look down.

To see the effect on the bump mapping get close (not too close!) to a suitable part of the terrain, turn bump mapping on and wait.

Any queries, just ask.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 13th Mar 2007 00:57
@gg very nice, exactly what I was thinking. Sweet. This terrain stuff has definatly been a learning experience for me. Thank you for all the help. This stuff definatly looks as good/if not better than stuff professional studios put out. This is some of the best graphics I have seen out of dbp. Now If we can add some lights so if we have a fire, it will put out light that will show up on the terrain....something that advanced terrain doesnt have. It dont think it would be that hard to add support for like 3 lights, that the user can just recycle throught the map. What do you think.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Mar 2007 01:26
Quote: "Now If we can add some lights so if we have a fire, it will put out light that will show up on the terrain....something that advanced terrain doesnt have. It dont think it would be that hard to add support for like 3 lights, that the user can just recycle throught the map. What do you think. "


It can certainly be done. All you need are three point lights, each being controlled by two vector4's: one for the light's position and range, the other for it's colour. The shader would need to be changed to take account of these - but it can be done.

The extra shader code would make it rather slow on my machine.

Of course you'd need some fire objects as well. Perhaps a fire shader, also.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 13th Mar 2007 03:21
@gg You are like the shader master. Its to bad your machine isnt quite fast enough. I am trying to put togheter a small world demo. Something people can learn from. I am now just using bryce to make my mesh and then using your shader to texture it. Your shader is awesome. Thanks for all the help. Would a fire shader be faster than just using a particle system? Either way my game is gonna require shaders now. I was pretty much dedicated to using them after the nvidia compo anyways. Well if you get the chance to add lights let me know. I really got to get a better handle on this shader making stuff, its really awesome. I have learned alot about using them and how they are structured just from this. Thank you.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 13th Mar 2007 03:56 Edited at: 13th Mar 2007 03:59
ok here is one more question

I am trying to tie in the backdrop to color according to how much "light" there is

white = object position y(500)/4.5


if white > 255 then white = 255
if white < 0 then white = 0


color backdrop rgb(white/2,white/2,white)

I have changed your code to this so that the sphere rotates around the level


rotateLight: ` *** light (this subroutine has been added)
inc angle#, 0.05
LX# = terrain_size * sin(angle#) + refX#
LY# = terrain_size * cos(angle#) + refY#
LZ# = terrain_size
LDX# = refX# - LX#
LDY# = refY# - LY#
LDZ# = refZ# - LZ#
set vector4 2, LDX#, LDY#, LDZ#, 0
normalize vector4 2, 2
position object 500, LX#, LY#, LZ#
return


I want to be able to have the backdrop change so it looks like its changing with the light of the terrain.....day and night effect......This is very convincing so far. Do you think you can improve it any???? Thank you.
Ceashure
18
Years of Service
User Offline
Joined: 12th Mar 2007
Location:
Posted: 13th Mar 2007 04:57
How easy would it be to make the shader load textures based on a image map instead of height? For instance Orange color in the image map would equal sand, green for grass, etc. The image map would contain no blending of colors (instead hard edges), the shader would take care of the blending. I would need to be able to set which rgb color goes with which texture/bump map. Are there any tutorials you can point me toward?

This would be especially helpfull if you want to make a dirt/brick road go through a grass field.
Ceashure
18
Years of Service
User Offline
Joined: 12th Mar 2007
Location:
Posted: 13th Mar 2007 05:40
Disregard my previous post, I downloaded the wrong version the first time. I've been searching for something like this for a while now. Looking forward to its final release!
TinTin
19
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 13th Mar 2007 11:09
@David
Quote: "@gg You are like the shader master. Its to bad your machine isnt quite fast enough. "
Having a slow machine isn't that bad for development purposes, It means GG's code is going to be mean and lean, that impies it should be fast on every other machine, which is a good thing, (right?)

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Daniel San
19
Years of Service
User Offline
Joined: 22nd Dec 2005
Location:
Posted: 18th Mar 2007 07:43
Looks awesome, Maybe I can use this in the world editor I'm working on. Great work!

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Mar 2007 14:29
Hey David, What is it that you have to do to your .X models in 3DExploration to get them to work?

I have this LOD terrain object that I mould onto a heightmap array like you do, only it has less detail the further it goes out, but both the source colour texture shader and the slope shader are having none of it. I won't know until I can apply the shader to it, but it looks like it'll save a ton in performance, hope I can get it working. I thought it might be a vertice limit, but it only has 13000+odd verts.


Good guy, Good guy, Wan...
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Mar 2007 19:01
@Van B

Without having your X model to play with (or a description of the symptoms) I'm guessing - but could the problem be the texture stage that's used?

I haven't come across LOD terrain objects before. Are they just ordinary objects with several limbs in the same position - but the limbs are all the same except using different numbers of vertices and textures and only one limb is visible at any given moment? If so, you might have to use set limb effect for each limb rather than set object effect.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Mar 2007 21:16 Edited at: 19th Mar 2007 21:17
It's like a matrix (single mesh object), but the further out on the mesh you go, the less detail is used - so the far away terrain is shown using 1/4th the resolution as the closest poly's. So every so often you reposition the terrain and adjust the heights and you end up with more visible distance for less poly's.

I'll make a little demo with the mesh if you have time to take a look.


Good guy, Good guy, Wan...
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 19th Mar 2007 21:30
@van b. I was having a problem making a mesh in dbp and then having a shader work with it. Something isnt quite right with the normals when making a memblock mesh in dbp. Anyways, I dont know if this can be cleared up inside dbp. Everything I have tired, has failed. Anyways, I just decided to save it as a .x from dbp. Then I loaded it into 3d exploration. Anyways, the settings are. gereral tab: check_mark-texture coordinates, check_mark-save normals, {(On one occasion I had to check_mark-flip normals)}, check_mark-turn to left hand system, Do not check ascii,(this had the effect of adding a second limb, So instead of accessing limb 0, you now access limb 1. ascii seems buggy, it didnt take correctly to dbp. Anways, you can try ascii if you like. Also I always check_mark ceneter object. But thats optional cause it just changes the piviot point. Also I use max points in polygons = 4

If you post that mesh object I will take a look at it and let you know what I think. When I first tried to get my memblock mesh to work......only the very bottom would take one texture and the rest would be another.....I could only ever get 2 textures to work on it. very very bizarre.

Thank you.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Mar 2007 21:49
@Van B

Sounds interesting. If you could post a simple demo with not too many vertices I'll have a look. Do you think show/hiding limbs could be another way?

@david w

Quote: "Something isnt quite right with the normals when making a memblock mesh in dbp."


I've managed to get this working a few times now. The main thing to watch out for is the "winding number" of the 3 vertices for each poly in your mesh - i.e. the order "abc" would have the polygon facing one way and "acb" the other ("a", "b" and "c" represent the three vertices of a poly).

The way I'm working on at the moment proceeds roughly as follows:

1. Start with a simple plain.
2. Use NxN copies of the plain vertex data to make an NxN mesh of polys (the base limb).
3. Use MxM copies of the base limb to make a terrain.

Now that I've got that basic idea working (I needed to fiddle with normals, etc) I can probably improve it. I'm thinking of using three sets of UV coords - the first containing regular Stage 0 UV coords, the other two (i.e. four floats in total per vertex) to record other features of the terrain such as altitude, slope and curvature. The idea is to pre-compute as much as possible before throwing the object at a shader.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 19th Mar 2007 22:18 Edited at: 19th Mar 2007 22:20
@gg I played around with that same idea, when I first started working on this. The problem was I couldnt get the vertices to move where I wanted them to. I know I am no expert, so its probably just my lack of knowledge. But if you actually get that working I would really love to see it in action. But you right the more we can do before throwing it at the shader the better. pre-process as much as possible, and then let a lean mean shader take care of the rest.


Btw.....Also I dont even use the normal mapping feature, its kinda a waste, it really just slows everything down, and the visual difference isnt that drastic.......

Thank you.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Mar 2007 22:37
Here's that demo. When I try and apply the shader to it the .exe crashes, also for some reason it doesn't like having it's SET OBJECT NORMALS Obj thingy done. Press W to see the wireframe view.

Cheers, I'm sure it's an ascii .X file though, so I'm gonna try and get a binary .X version to try.


Good guy, Good guy, Wan...
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Mar 2007 01:12
david w

Quote: "Btw.....Also I dont even use the normal mapping feature, its kinda a waste, it really just slows everything down, and the visual difference isnt that drastic......."


I think it's a matter of having the right normal maps.

Hopefully the extra vertex info I'm going to use will give an effect similar to normal mapping - when I find time to do it.

@Van B

Thanks for the demo - I'll try it tomorrow evening. I prefer ascii .X files - you can actually look at them and see what they're doing (up to a point).
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 20th Mar 2007 01:38
@van B. Its gonna take me a minute to understand everything your doing. Its not much different than what I was doing, you just got a few more things going on that I didnt. I think we can make this work though. Everything I have tried has failed. The object is "funny". Something about it is just not right.

I tried to make a mesh from it. then save that mesh. It wont save it. Its like nothing is there. I turned it into a mesh then into a memblock, then tried to turn it into an object.....crash....

So I think something is just not quite right with your object. It looks good in 3d exploration though, but then again most things do. Well I like how your ground height function works. very nice. Better than mine. much faster.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Mar 2007 01:45
I'm gonna try and make another mesh in Max I think, that was made in Rhino 3D - there's also the possibility of doing something similar with a memblock mesh though.

I think that ground height function was by Kevil, it is pretty darn fast .

Thanks for taking the time to look over it, my codes real messy I know, you should see the state of it with the water shader and clouds in there as well.


Good guy, Good guy, Wan...
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2007 00:50 Edited at: 21st Mar 2007 01:22
@Van B

Had a quick look at your demo. I don't think the shader is the problem. When I comment out the "set object effect" command the demo still crashes. My guess is that it is something to do with the "LOD.x" object and perhaps the "convert object fvf" command.

I will have a clearer idea when I have checked the limb structure more carefully. At the moment, "make mesh from object" and "make memblock from mesh" are returning silly values.

I'm sure there's a simple explanation there somewhere ...

Edit: It's the "convert object fvf" command that causing the crash. Just try this:



Do you know the FVF format of your object?

Do you know whether "convert object fvf" works on objects with limbs?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Mar 2007 01:53 Edited at: 21st Mar 2007 01:54
It's doing it with a lower poly mesh as well, I'm thinking that I'll make a memblock mesh and use that next time, my memblock meshes work with the shader already, just really need to work out a bigger LOD version. Thanks for looking though, but I think it's my modelling software causing most of the issues.

Never tried converting or using a limbed object, probably worth a shot too. Will post my findings.


Good guy, Good guy, Wan...
TinTin
19
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 21st Mar 2007 11:45
Hi Van...
had a look at your code also...
Don't think this is whats causing your problem, but...
you have the following code

It suddenly occured to me that you were using a point light instead of a directional light as your sunlight.
I think it should be as follows... (IMHO)


I've managed to get my 'Procedural.dll' half working, I can now generate a scrolling heightmap generated using RigidMultifractal & HeteroTerrain functions. (Minimal delay of 10ms generating the new edge every so often). Maping this to a terrain object gives pleasing results (updating this is too slow though), I'm now working on a LOD grid thats denser around the player and gets sparser the farther away it is i.e first 10 grids are 1 unit apart next 10 are 2, next are 4, next are 8 and so on up to 128.
this gives a massive terrain with detail. (or it should)

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
david w
19
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 21st Mar 2007 12:01
I dont think the light has anything to do with it. I've been busy the past few days so I havent had much of a chance to do anthing but tonight I can have another crack at it. Thank you.

Login to post a reply

Server time is: 2025-08-09 02:06:22
Your offset time is: 2025-08-09 02:06:22