Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 1,353 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
blurring terrain multitex at a distance... #42428
03/11/05 11:44
03/11/05 11:44
Joined: Jan 2003
Posts: 47
Oklahoma
Blackberry Offline OP
Newbie
Blackberry  Offline OP
Newbie

Joined: Jan 2003
Posts: 47
Oklahoma
I wrote this simple terrain multitex shader a while ago and I can not seem to figure out how to blur the terrain at a distance...

Code:
 Texture entSkin1;
Texture mtlSkin1;
Texture mtlSkin2;
Texture mtlSkin3;

sampler2D tcolormap = sampler_state
{
Texture = (mtlSkin4);
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};

sampler2D tgrass = sampler_state
{
Texture = (mtlSkin1);
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};

sampler2D tdirt = sampler_state
{
Texture = (mtlSkin2);
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};

sampler2D twater = sampler_state
{
Texture = (mtlSkin3);
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};

struct PS_INPUT_STRUCT
{
float2 Tex : TEXCOORD0;
float3 light_angle : TEXCOORD1;
};

struct PS_OUTPUT_STRUCT
{
float4 c : COLOR0;
};

float4 veccycle;
PS_OUTPUT_STRUCT MyShader( PS_INPUT_STRUCT psInStruct, float4 inPos : POSITION)
{
PS_OUTPUT_STRUCT Color;
float4 Grass;
float4 Dirt;
float4 Water;

Color.c = tex2D( tcolormap, psInStruct.Tex.xy);

Grass = mul(tex2D( tgrass, mul(psInStruct.Tex.xy,800)),Color.c.g);
Dirt = mul(tex2D( tdirt, mul(psInStruct.Tex.xy,500)),Color.c.r);
Water = mul(tex2D( twater, mul(psInStruct.Tex.xy,120)),Color.c.b);

Color.c=Grass+Dirt+Water;

return Color;
}

technique PostProcess
{
pass p0
{
PixelShader = compile ps_2_0 MyShader();
}
}


Does anyone have any clue how I might go about doing this? You can use this if you want...

Thanks,
Brian

Re: blurring terrain multitex at a distance... [Re: Blackberry] #42429
03/11/05 16:16
03/11/05 16:16
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Quote:

I can not seem to figure out how to blur the terrain at a distance...




What do you mean 'blur'? are you talking about mip mapping? or fogging? please clarify what you want.

Re: blurring terrain multitex at a distance... [Re: Matt_Aufderheide] #42430
03/12/05 07:04
03/12/05 07:04
Joined: Jan 2003
Posts: 47
Oklahoma
Blackberry Offline OP
Newbie
Blackberry  Offline OP
Newbie

Joined: Jan 2003
Posts: 47
Oklahoma
Not really fogging or mipmapping, but more of a simple gaussian blur at a distance. Plain mipmapping would probably work just as well, but I think blurring would look better. Now that I think about it, if the mipmaps could be custom defined, then blurring wouldn't be needed. Also, is there a way to make a pixel daker as the camera gets further away? That would help me alot, too.

Thanks,
Brian

Re: blurring terrain multitex at a distance... [Re: Blackberry] #42431
03/12/05 08:11
03/12/05 08:11
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
I dont see why you'd want to blur it a distance, mip maps work fine.

As for making a pixel darker depending on distance try something like this:
in the vertex shader:
float dist=distance(PositionWorld, vecViewPos);
Out.dist.xyzw=dist*0.005;

in the pixel shader:
finalcolor.rgb*=In.dist;

you wil need to play around with the numbers to bias it correctly so it does what you want. basically all this does is convert the distance from the view to the pixel to a biased greyscale color value that you multiply against your current color. This technique can also be use to lighten pixels, and to change alpha for fading out pixels.
obviously you will need to chnage the names of variables to fit in your shader, also when you declare the vertex output make sure you declare the dist variable as COLOR:
float4 dist: COLOR0;

and your pixel input should have it the same way..

Re: blurring terrain multitex at a distance... [Re: Matt_Aufderheide] #42432
03/12/05 12:04
03/12/05 12:04
Joined: Jan 2003
Posts: 47
Oklahoma
Blackberry Offline OP
Newbie
Blackberry  Offline OP
Newbie

Joined: Jan 2003
Posts: 47
Oklahoma
Thanks! That distance thing is something I've been trying to do for a long time. But how would I create custom mipmaps? Is it through the engine or through the shader?.

Thanks,
Brian

Re: blurring terrain multitex at a distance... [Re: Blackberry] #42433
03/12/05 18:30
03/12/05 18:30
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
If you want you material skins to have mip maps you need to generate them like so in a starter function:

bmap_to_mipmap(mat_terrain_multi.skin1);
bmap_to_mipmap(mat_terrain_multi.skin2);
etc...


this makes mip map chains for each material skin.

Re: blurring terrain multitex at a distance... [Re: Matt_Aufderheide] #42434
03/13/05 03:10
03/13/05 03:10
Joined: Jan 2003
Posts: 47
Oklahoma
Blackberry Offline OP
Newbie
Blackberry  Offline OP
Newbie

Joined: Jan 2003
Posts: 47
Oklahoma
Thanks, but how could I use mipmaps that I create externally? Or is this even possible? Thanks for all your help...

Brian

Re: blurring terrain multitex at a distance... [Re: Blackberry] #42435
03/13/05 04:15
03/13/05 04:15
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
sure it would be, but you have to define them first, and not call them in between brackets.


bmap tile_1 = <tiled_1.bmp>;

bmap_to_mipmap(tile_1);


that should work.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: blurring terrain multitex at a distance... [Re: Blackberry] #42436
03/13/05 05:48
03/13/05 05:48
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
The ony way to do this is to wait until the next version of A6 is out, so you can use DDS textures. You can define your own mip maps in a DDS texture.

But I wonder why you want to use custom mipmaps.. what are you trying to achieve?

Re: blurring terrain multitex at a distance... [Re: Matt_Aufderheide] #42437
03/13/05 13:27
03/13/05 13:27
Joined: Jan 2003
Posts: 47
Oklahoma
Blackberry Offline OP
Newbie
Blackberry  Offline OP
Newbie

Joined: Jan 2003
Posts: 47
Oklahoma
Ok, Thanks. I'm just trying to achieve a simple way to only use one mipmap set for the grass, dirt, and rocks(or water). This way, in theory, it would take less gpu useage and increase performance. Just a theory, and probably won't work.

Thanks again,
Brian

Page 1 of 2 1 2

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