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 / Blend mapping for Fog of war effect

Author
Message
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 2nd Oct 2010 19:03
I'm working on my RTS's fog of war effect, and came up with the idea of using blend mapping instead of cloning the terrain and putting the fog of war texture into it while turning on negative ghosting, because it was just insanely not efficient AND i struggled much to get the effect properly, and however i finally succeded in that, i'm afraid it won't look good on some machines. (flickering / random lines may come up etc...)

So now i'm using blend mapping to get the alpha fog of war effect onto the ground, which is, for speed reasons, is divided into a 10x10 grid, so only the ones onscreen are shown / included, and have frequently updated textures. The Fog texture is updated through Memblocks, which i found to be faster AND MUCH MORE FLUID to turn into image by doing it many times at small resolutions other than doing it delayed at one big resolution. This dividing up was also necessary for future plan of LOD.

First i had the problem of the terrain texture itself producing not seamless effects, but i used this line: "set object texture object_number,3,0" and the problem was solved.

But now came the blended second texture. And nope, it god knows why, doesn't obey the object's texture adjustments. This wouldn't be a reason to hit the screen with my head several times if there was some command to set the new texture's properties...

So now the fog of war layer has the ugly texture repetition problems at the edges. Especially ugly, since the Fog is at a much less resolution. (again speed issues.. and not needed any higher really, especially as soon as i manage to do some fast real time blurring on it...)


SO, THE MAIN QUESTION, sorry you had to read all that... maybe you were lucky and didn't:

How can i make 'set object texture' kinda adjustments to the blended-on texture?


(sorry, but i'm a very old DBP version user due to still being unable to get the latest to compile on my machine for some reason, which reason could be the most pathetic in history since nothing is different with my machine, like with the two other PCs i tried, where DBPro 7.5 runs with no errors... SO, Please if this issue is not: a problem, bug, challenge, whatever in future - should i say current... - versions, just let me know i will be able to fix this easily when i FINALLY get to 7.5 ... just to let you know that i don't want you to remember how the command list of v5.9 was )
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Oct 2010 01:01
Okay, now i have been crying here about the compiling error i get with the new DBP release, and have been trying to reinstall and maybe make it working for the same amount of time. And TODAY, it works. This just doesn't make any sense.

Anyway, i see there has been quite a lot of work put into the blending topic, will be a nice time to get to know it better. Just a statement, i am studying it hard and don't want any of you write snippets for me, but all help is highly appreciated from you guys as well, so if someone could show me which part of the new blend mapping command will give me the ability to adjust: unique texture settings and also unique UV data to each blended layer, just made me a very happy person!
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Oct 2010 11:53
Hi Quel,

I feel like I'm starting to over-promote my stuff, but you might be interested in Image Kit V2.
By using this plugin, you can avoid converting an image to a memblock, which will result in a greater speed. You can obtain an even greater speed if you use target images, which allow you to use the GPU to alter your images. If normal alpha blending is not enough for you, you can even use shaders to fully customize how the new image should look like. Shaders will probably allow you to render the Fog of War effect in one step (though that depends on the complexity of the effect).

Cheers!
Sven B

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Oct 2010 12:57
Of course, your plugin! Now i can for the very least check it out with the latest DBP version!

Though i would like to believe it is not impossible to do this simple task of adjusting optional UV data to each blend layers. If someone knows how to do it, don't hold it back!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Oct 2010 13:12 Edited at: 3rd Oct 2010 13:32
Quote: "Though i would like to believe it is not impossible to do this simple task of adjusting optional UV data to each blend layers. If someone knows how to do it, don't hold it back! "


From the Help file:

Quote: "TexCoordMode

Integer
Tex Coord Mode specifies what the UV data should be
"


and a bit later you'll see the strangely worded:

Quote: "Texture Coord Mode:
0 - Regular UV Stage Match
1 - Sphere Mapping UV Data
2 - Cube Mapping UV Data
3 - Steal UV Data From Stage Zero
10-17 - Take UV Data From Stage Mode Value minus 10"


Use mode 0 if the blend stage matches the UV coord stage, i.e. blend stage 0 has to use UV stage 0, blend stage 1 has to use UV stage 1, etc.

Use mode 3 if the stage uses UV stage 0.

Use modes 10-17 if there's an irregular match between blend stage and UV stage. For example, if you had three blending stages and you wanted them to use UV stages 0, 1 and 1 respectively, then for blending stages 0 and 1 you could use mode 0 (or modes 10 and 11 if you want to be complicated), but for blend stage 2 you would need to use mode 11 (i.e. the UV stage is 11-10 = 1, i.e. UV stage 1).

Edit Corrected confusing error in final sentence.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Oct 2010 16:34
Thank you Gandalf, now i finally know what's that stage index thingy for. And also managed to use it to set the texture behavior of the newly blended-on fog texture, so the ugly edge is gone.

Though this is just a temporary solution since this new situation also produces some annoying little issues, like circled on the picture.

So my idea is to add one pixel row to each side of the texture of a tile, and fill those additional pixels up of content so they make these errors go away. But this would need precisely adjusted new UV coordinates for the Fog layer...

...which i still can't figure out how to assign the desired UV coordinates to those UV stages explained...
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Oct 2010 16:49
Hi Quel,

Using the vertexdata commands, I think you can edit the UV values for higher stages:

From the help files:
Quote: "SET VERTEXDATA UV Vertex Index, U, V
SET VERTEXDATA UV Vertex Index, Index, U, V

An optional parameter will allow UV data in the secondary stages of the vertexdata to be edited."


Cheers!
Sven B

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Oct 2010 18:50
Yes, that's the one - but you need to make sure the object has the extra UV stage coords. By default objects have only stage 0. You can add extra ones with the convert object FVF command. You need to include the appropriate FVF_TEX value, for example, for two UV stages, i.e. stages 0 and 1, you'd need FVF_TEX2.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Oct 2010 20:22
Thank you all very much guys

Login to post a reply

Server time is: 2026-07-22 03:51:20
Your offset time is: 2026-07-22 03:51:20