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 / GGs terrain shader not working

Author
Message
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 25th Oct 2010 01:05
So I made a function that creates a rgb map from a heightmap for textures. So I used GG's rgb map terrain shader, TerrainFXv2.fx, to texture my terrain. When I use it with a heightmap on a simple plane it works fine but when I use it on a high poly terrain object, It just shades the entire object green. I heard that the shade only works on lower poly objects, is that true or is it another reason?

My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Oct 2010 01:53
Quote: "I heard that the shade only works on lower poly objects, is that true or is it another reason?"


It should work on any object except that you need to make sure that it has suitable UV coordinates. The shader assumes that the stage 0 UV coords range from 0 for the left hand and top edges of the terrain up to 1 for the right hand and bottom edges.

I remember spending ages struggling with a similar problem recently. I finally realised that the person's object didn't even have UV coordinates. Have you checked?
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 25th Oct 2010 03:17 Edited at: 25th Oct 2010 15:48
How do I check? I haven't used the vertex data commands yet. Would this set UV data for a plane?

EDIT: Actually it does because I textured it with the rgb map and it worked. P.S. Also the object was made using the advanced terrain commands if that has anything to do with it.


My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Oct 2010 14:02
Quote: "P.S. Also the object was made using the advanced terrain commands if that has anything to do with it."


Quite possibly. I'm busy till later today. I'll look into it then. In the meantime you could try changing the terrain's stage 0 UV data using something similar to your code.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 26th Oct 2010 04:31
Tried setting the texture stage to 0, it didn't work.

My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Oct 2010 15:28
I see what you mean. The problem is connected with the FVF format used by Advanced Terrain objects. I didn't think it would cause problems here, but it does. The problem is the diffuse vertex component. You don't need to change the stage 0 UV coordinates.

I've attached a demo showing how to use the shader with Advanced Terrain.

If you use the blurred version of the rgb map you get a better transition between the different textures. A simple way to start is to make your rgb map using solid colours then use an image editor like Texture Maker to blur it.

I think I've used the same version of the shader that you were using. Let me know how you get on.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 26th Oct 2010 16:22
IT WORKS!
Well not quite, changing the fvf format fixed it but also got rid of the shading. Is it possible to use your shader with the shadows on the terrain?
Anyways here's a screenshot of what I accomplished (with your help of course).



My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Oct 2010 16:56 Edited at: 26th Oct 2010 16:57
That shader doesn't include lighting code.

Quote: "Is it possible to use your shader with the shadows on the terrain?"


Yes. The obvious solution is to add normals and do the usual lighting calculations in the shader. But there might be a simpler faster way using the diffuse component which my demo removed. I'll see what I can do. It'll probably be tomorrow as I'm supposed to be doing something else right now (but as you can see I'm procrastinating at the moment ).

Edit Removed a somewhat misleading sentence.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 26th Oct 2010 17:23 Edited at: 26th Oct 2010 17:23
Quote: "That shader doesn't include lighting code."

I meant that without changing the fvf format or using your shader, the terrain is automatically shaded.
Quote: "It'll probably be tomorrow"

Thats okay, I'll try my best to figure something out in the meantime.

My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Oct 2010 19:26
Quote: "I meant that without changing the fvf format or using your shader, the terrain is automatically shaded."


Yes, I know. The default shading for Advanced Terrain uses the diffuse vertex component which unfortunately interferes with shaders in DBPro. Hopefully this will be fixed one day. In the meantime we have to find workarounds.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 26th Oct 2010 19:51
So do you have a basic self shadowing shader that would work with the fvf format converted?

My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Oct 2010 14:25
You could look at this:

Shaders for Advanced Terrain

I've tried to find a simple workaround for your problem but failed. The best solution is to do what I've done in some of those demos: remove diffuse and add normals to the FVF format and then add the usual lighting stuff to the shader and DBPro code. You should then get good results - and dynamic lighting too.

[Some of those demos need a bit of tweaking - post back here if you have problems.]
Dia
21
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 27th Oct 2010 15:22 Edited at: 27th Oct 2010 15:23
a low tech, but manually intensive way of doing things is to use a gray shaded terrain to modulate the r,g and b intensities of the texture maps (see attached img for one I was playing around with). The dark shaded bits show up quite nicely as shadow on the terrain

I am trying to figure out a way to get my 3d modelling program to correctly merge the two images so that I can get it all exported automatically, but so far the best results have happened when I have fiddled with the maps by hand

the major headache comes when you want to use two colour maps to reference 6 different terrain textures, since you need to ensure that the second map r,g and b values don't override the first map values. If they do you either tend to get very bright sections (where the two maps combine to >255) or mutant coloured dark sections

This is not the Sig you are looking for....
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 28th Oct 2010 02:23
Hey GG, I found your example a little... complex. I found a simpler (Not as efficient) way. Just make 2 terrains, use the shader on one and ghost the other, It works great! I got around 70-90 fps uncapped.

My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th Oct 2010 02:44
Quote: "I found your example a little... complex"


It is. I've decided it's time to simplify the code. Hopefully I'll have something up and running this week. I'll post it on this thread (if I think it really is simpler ).

Quote: "Just make 2 terrains, use the shader on one and ghost the other, It works great! I got around 70-90 fps uncapped"


Well done. Getting something working in the first place is half the battle.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 28th Oct 2010 05:01 Edited at: 28th Oct 2010 05:03
Okay, here's a screenshot.
Poly count is a tad hight (over 1000,000)


My computer surpasses all the technologies of the day. What computer do I have?

Mugen Wizardry
User Banned
Posted: 28th Oct 2010 05:04
um, why not use blitzterrain? It blows advanced terrain out of the water. Combine it with smaas' landscape gen and it's unstoppable!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 28th Oct 2010 05:32 Edited at: 28th Oct 2010 05:34
Because this was for learning purposes. I wanted to create a challenging algorithm solving program that could be used as an educational standpoint. Sure I can go off to Blender and make a brilliant landscape but that wasn't the point. This was just dealing with a possible result from use of the diamond square algorithm.

My computer surpasses all the technologies of the day. What computer do I have?

Login to post a reply

Server time is: 2026-07-22 02:47:49
Your offset time is: 2026-07-22 02:47:49