Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 527 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
FoW Shader (deutsch/engl.) #126949
04/28/07 10:11
04/28/07 10:11
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Gordon_Shumway Offline OP
Member
Gordon_Shumway  Offline OP
Member

Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Hi !!!

Ich habe mal eine Frage an die Shadercommunity:
Ich möchte bei meinem RTS Fog of War installieren. Beim Suchen bzgl. FoW bin ich darüber gestolpert, dass man FoW ja auch sehr gut mit Shadern realisieren kann und diese Idee finde ich gar nicht schlecht.
Jetzt meine Frage(n):
1. Ich habe die Com-Version. Benötige ich hierfür Render-to-texture oder lässt sich das auch anders realisieren ?
2. Hat jemand dieses in 3DGS schon einmal verwendet oder gibt es irgendwelche wichtigen Infos, die ich wissen sollte?
3. Wie würdet ihr am besten vorgehen ?

Vielen Dank im Vorraus für eure Hinweise,

G.S.


engl.:
Hi !!!
I like to use Fog of War in my RTS-game. I found out, that shader might be a good way to realize it.
So, I have some questions how to realize:
1. I have the Com-Version. Do I need render-to-texture (Pro) or is there another way using shaders for FoW ?
2. Has anybody done FoW with shaders ? Are there some informations I should know?
3. How would you do this ?

Thanks for your help,
Bye G.S.


***Neue Webseite!! Mit vielen neuen Infos! http://www.2662-thegame.de.vu***
Re: FoW Shader (deutsch/engl.) [Re: Gordon_Shumway] #126950
04/28/07 10:20
04/28/07 10:20
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
ich denke es würde gehen, wenn du nen bmp nehmen würdest, das am anfang ganz schwarz ist und immer wenn deine truppen irgendwohin kommen weiß zeichnest...sobald sie nciht mehr da sind grau...

bei deinem terrain fügst du das als matSkin ein und multipliziert die heliigkeit damit
bei den einzelnen objekten musst du die worldcoord vergleichen, und aus der fow-map lesen

Das meiste passiert dann immer ncoh in c-script, aber es wäre ne möglichkeit

Re: FoW Shader (deutsch/engl.) [Re: Scorpion] #126951
04/28/07 16:18
04/28/07 16:18
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
?What...

Could you post an example of this shader?


xXxGuitar511
- Programmer
Re: FoW Shader (deutsch/engl.) [Re: xXxGuitar511] #126952
04/29/07 09:42
04/29/07 09:42
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
ich kann mal verscuhen ihn ready to use hinzukriegen...also zumindest das terrain..mit den modellen bin ich mir nciht sicher wie/ob das geht

Re: FoW Shader (deutsch/engl.) [Re: Scorpion] #126953
05/01/07 12:35
05/01/07 12:35
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
naja, ich habs versucht, aber es klappt nicht so ganz..irgendwo ist immer noch ein fehler im script(jaa..arrays...)

Re: FoW Shader (deutsch/engl.) [Re: Scorpion] #126954
05/01/07 23:31
05/01/07 23:31
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
there are a number of ways to do fog of war, the most "correct" way is to make a projection matrix that covers the whole playing area, then project your fog map on top of everything, including terrain, models, etc.

if you dont know what that means, then you may want to do something different, like just blend your fog map over the terrain texture, and fade out your models seperately, though this can be hard.

or, if you deciede to have a very narrow field of view setting, like almost orthographic, you can simply overlay a large rectanlge above everything else, like a sqaure sprite, this would be mapped with the fog texture.

As far as making the fog texture, you can use pixel to bitmap to draw white pixels to a black texture, just use a proportion formula to find the pixel regions..


Sphere Engine--the premier A6 graphics plugin.
Re: FoW Shader (deutsch/engl.) [Re: Matt_Aufderheide] #126955
05/03/07 10:36
05/03/07 10:36
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Gordon_Shumway Offline OP
Member
Gordon_Shumway  Offline OP
Member

Joined: Feb 2004
Posts: 217
Wennigsen, Germany
@all: Thanks a lot, for your help.


***Neue Webseite!! Mit vielen neuen Infos! http://www.2662-thegame.de.vu***
Re: FoW Shader (deutsch/engl.) [Re: Gordon_Shumway] #126956
05/03/07 20:19
05/03/07 20:19
Joined: May 2007
Posts: 1
A
akabane Offline
Guest
akabane  Offline
Guest
A

Joined: May 2007
Posts: 1
So did you realize a way for doing it? If yes, can you share? I'm also REALLY interested in that!
Thanks

Re: FoW Shader (deutsch/engl.) [Re: akabane] #126957
05/03/07 20:56
05/03/07 20:56
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
Here is that what i have already done, but somewhere inthe deep of this script is a mistake i made and do not find...if someone of u do i would be really happy

script:
Code:
//definitions
bmap tertex1 = <veg065.pcx>;
bmap tertex2 = <ground018.pcx>;
bmap TerMap = <terrain_map.tga>;

define belongTo,skill5;
define friend,1;
define enemy,2;

define visibleRange,skill6;

entity* fowTer;
bmap* tempMap;

var fowMapArray[16384];//128x128
var oldFowMapArray[16384];
var fowMapSize = 128;
var terrainPxSize;
////////////////////////////////
material matFowTer
{
skin1 = tertex1;
skin2 = tertex2;
skin3 = TerMap;
effect="fowt.fx";
}

panel just_a_test
{
flags=visible;
}

function painMap
{
var tempPos[2];
var pixel;
var format;
tempMap=bmap_for_entity(fowTer,4);
format = bmap_lock(tempMap,0);
while(tempPos.y<fowMapSize)
{
if(fowMapArray[(fowMapSize-1)*tempPos.y+tempPos.x]!=oldFowMapArray[(fowMapSize-1)*tempPos.y+tempPos.x])
{
temp=255*((fowMapSize-1)*tempPos.y+tempPos.x);
pixel = pixel_for_vec(vector(temp,temp,temp),100,format);
pixel_to_bmap(tempMap,tempPos.x,tempPos.y,pixel);
}
tempPos.x+=1;
if(tempPos.x>fowMapSize)
{
tempPos.x=0;
tempPos.y+=1;
}
}
bmap_unlock(tempMap);
just_a_test.bmap = tempMap;
}

function check_fow
{
var tempPos[2];
var targetPos[2];
var tempRange;
while(1)
{
you=ent_next(null);
while(you!=null)
{
if(your.belongTo == friend)
{
if(your.visibleRange==0)
{
vec_Set(camera.x,your.x);
camera.z+=200;
camera.tilt=-90;
your.light = on;
your.red=255;
your.green=0;
your.blue=0;
your.scale_x = 2;
your.scale_y = 2;
your.scale_z = 2;
error("unit don't have a visibleRange");
freeze_mode=2;

}
tempRange = int(your.visibleRange/terrainPxSize+0.5);
targetPos.x = (your.x-fowTer.min_x)/terrainPxSize-tempRange;//xpos
targetPos.y = (your.y-fowTer.min_y)/terrainPxSize-tempRange;//y
while(tempPos.y<=tempRange*2)
{
temp.x=targetPos.x+tempPos.x;
temp.y=targetPos.y+tempPos.y;
breakpoint;
if(vec_dist(vector(tempRange.x,tempRange.y,0),vector(temp.x,temp.y,0))<=tempRange)
{
fowMapArray[fowMapSize*temp.y+temp.x]=1;
}
tempPos.x+=1;
if(tempPos.x>tempRange*2)
{
tempPos.x=0;
tempPos.y+=1;
}
}
}
you = ent_next(you);
}
painMap();
wait(1);
}
}

action fow_terrain
{
fowTer=me;
terrainPxSize = (my.max_x-my.min_x)/fowMapSize;//now u have the size of a pixel in quants
my.material = matFowTer;
check_fow();
}



shader:
Code:
float4x4 matWorldViewProj;

texture entSkin1;
texture entSkin2;
texture entSkin3;
texture entSkin4;
texture mtlSkin1;
texture mtlSkin2;
texture mtlSkin3;

sampler2D textur1 = sampler_state {Texture=<entSkin1>;};
sampler2D textur2 = sampler_state {Texture=<entSkin2>;};
sampler2D textur3 = sampler_state {Texture=<entSkin3>;};
sampler2D textur4 = sampler_state {Texture=<mtlSkin1>;};
sampler2D textur5 = sampler_state {Texture=<mtlSkin2>;};
sampler2D terrainMap = sampler_state {Texture=<mtlSkin3>;};
sampler2D fowMap = sampler_state {Texture=<entSkin4>;};

void terrainVS( in float4 pos :POSITION,
in float2 Tex :TEXCOORD0,
out float4 opos :POSITION,
out float2 texcrd :TEXCOORD0)
{
opos=mul(pos,matWorldViewProj);
texcrd=Tex;
}

float4 terrainPS(in float2 texcrd:TEXCOORD0):COLOR
{
float4 tex1 = tex2D(textur1,texcrd*20);
float4 tex2 = tex2D(textur2,texcrd*20);
float4 tex3 = tex2D(textur3,texcrd*20);
float4 tex4 = tex2D(textur4,texcrd*20);
float4 tex5 = tex2D(textur5,texcrd*20);
float4 visible = tex2D(terrainMap,texcrd);
float4 fow = tex2D(fowMap,texcrd);
tex1 = lerp(tex1,tex2,visible.r);
tex1 = lerp(tex1,tex3,visible.g);
tex1 = lerp(tex1,tex4,visible.b);
tex1 = lerp(tex1,tex5,1-visible.w);
return tex1*fow;
}

technique
{
pass p0
{
vertexShader = compile vs_2_0 terrainVS();
pixelShader = compile ps_2_0 terrainPS();
}
}




Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1