simple tile effect ?

Posted By: Hades2

simple tile effect ? - 05/03/07 17:36

Hello,

I have to admit that I'm not so good with shaders, but perhaps some good soul can help me on this issue.

It's quite simple, I'm doing a Golf game, I made a function to place the grid, that stays on the ground to show better the terrain curves.

The function is okay, I have transformed a terrain to mdl, and then I adjust each mdl vertex according to the ground height.

My problem is the texture, I'm using a wireframe shader, but then the diagonals are visible, and this is undesirable.

I'm looking for a shader where I can use a transparent skin, and simple define it's texture scale to tile it as I want. Perhaps it's more easy than I think, but some tries I made didn't work as I wish.

Help is welcome.

thanks.
Posted By: alphaindigo

Re: simple tile effect ? - 05/03/07 20:22

you may not even need a shader at all , try using a grid with brg 0,0,0 in the cntre of the squares and then use my.overlay = on;
Posted By: Hades2

Re: simple tile effect ? - 05/03/07 20:44

of course I thought on this using a grid texture, but I would need a very big texture to have the grid I want, so if possible, a simple tile function should be very better.

That's what I have:



thanks
Posted By: lostclimate

Re: simple tile effect ? - 05/03/07 21:00

you could draw the lines manually using vec_for_vertex and draw_line commands :/
Posted By: Hades2

Re: simple tile effect ? - 05/03/07 21:22

Can be a solution. But, I still think that a simple shader could be used easily. The problem is that I don't know to much about shaders..

I tried to adapt some shaders, as the multi-texture terrain shader, but I had no success.

I think the scheme is simple, like two textures, first black, to be transparent, second a simple grid - small, tiled according to the scale set (as the multi-texture terrain).

The point is, how I translate this sentence to a shader code...

Anyway, thanks for helping.
Posted By: Zapan@work

Re: simple tile effect ? - 05/04/07 10:25

With this material you can display the wireframe of the assignt model:
Code:
  
material mat_modelWire
{
effect = "
DWORD wfcolor = 0xFFFEFFFF;

technique wireframe
{
pass p0
{

TextureFactor = <wfcolor>;
CullMode = None;
FillMode = Wireframe;
ColorOp[0] = SelectArg1;
ColorArg1[0] = TFactor;
}
}";
}


Posted By: ello

Re: simple tile effect ? - 05/04/07 12:01

thats exactly what he doesnot want.

but , you could try to overlay a a grid texture using the multitexture shader and a grid texture as a detailmap
Posted By: lostclimate

Re: simple tile effect ? - 05/04/07 15:17

thats what i was thinking but he'll have a lot of pixel/texel math to do
Posted By: xXxGuitar511

Re: simple tile effect ? - 05/04/07 15:48

This should be really easy to do. Just use the "wireframe" overlay's alpha channel for blending.

ex: (HLSL pixel shader)

float4 inColor = tex2D(mapSkin1, In.tex);
float4 inGrid = tex2D(mapSkin2, In.Tex * oScale);
float4 outColor;
outColor.rgb = lerp(inColor.rgb, inGrid.rgb, inGrid.a);
outColor.a = inColor.a;

Of course some of the variable names will need to be renamed, but this is the concept for it...
Posted By: Hades2

Re: simple tile effect ? - 05/07/07 14:04

Thanks for all help.

I'm almost having what I want. I used some shaders examples found in the Forum, and I made some tries. Here is what I got:



here is the shader I'm using - two skins, the second is a simple grid with alpha - TGA.

>>
//SHADER - teste

//this is the only matrix you need for this shader.. world*view*projection
float4x4 matWorldViewProj;
float4 Color;

//here is the vertex shader outputstruct
struct VS_OUTPUT {
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
};

//simple vertex shader calculates the vertex position and tex coords
VS_OUTPUT mainVS( float4 Pos : POSITION, float2 Tex : TEXCOORD0 ) {
VS_OUTPUT Out = (VS_OUTPUT) 0;
Out.Pos = mul(Pos,matWorldViewProj );
Out.Tex = Tex;
return Out;
}

texture entSkin1; //define the sampler for the entity skin
texture entSkin2; //define the sampler for the entity skin

sampler basemap = sampler_state {
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = clamp;
AddressV = clamp;
};
sampler detailmap = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap; //you want it wrap because it will be scaled smaller
AddressV = wrap;
};

// Simple pixel shader samples the entity skin according to Tex.xy coords
//float4 mainPS(float2 Tex: TEXCOORD0) : COLOR {
// Color = tex2D( basemap, Tex.xy);
// return Color;
// }
// pixel shader that does detail mapping
float4 mainPS(float2 Tex: TEXCOORD0) : COLOR
{
Color = //sample base color
tex2D( basemap, Tex.xy) * //multiply with the detail texture and scale the texture coords
tex2D( detailmap,(Tex.xy * 60));
return Color;

//float4 inColor = tex2D(mapSkin1, In.tex);
//float4 inGrid = tex2D(mapSkin2, In.Tex * oScale);
//float4 outColor;
//outColor.rgb = lerp(inColor.rgb, inGrid.rgb, inGrid.a);
//outColor.a = inColor.a;
}

technique blur {
pass Object {
//alphablendenable=false;
ZENABLE = TRUE;
//VertexShader = compile vs_1_1 mainVS();
VertexShader = NULL;
PixelShader = compile ps_2_0 mainPS();
}
}
>>

The last tip I'm looking for is how to let the second texture, the grid, more visible indifferent to the distance.

Anyway, it's much better now - thanks.
Posted By: vartan_s

Re: simple tile effect ? - 05/07/07 18:52

Sorry for going offtopic... but that's a great looking game! Why don't you make a post in the showcase forum (or maybe you already have, I dunno). Well, anyways, the last screenshot looks good. I'd say let it blur and get less visible as it goes into the distance - it looks better. The wireframe shader starts to look bad with distance because the lines are still as thick as up-close.
Posted By: mk_1

Re: simple tile effect ? - 05/09/07 13:22

This is caused by mipmapping so remove the mipmaps (in MED).
Posted By: Hades2

Re: simple tile effect ? - 05/10/07 15:02

thanks. you are right, removing the mipmaps the blur is off. the lines color becomes intense, and some flickering effect happened. I'll let the blur (mipmaps), and I'm considering it done.

thanks by all help.

ab
Posted By: Joey

Re: simple tile effect ? - 05/10/07 20:38

you could draw your own mipmaps in a dds texture
Posted By: Matt_Aufderheide

Re: simple tile effect ? - 05/11/07 10:26

To sharpen it a bit but still have the mip mappping, try this in the sahder...

in the texture sampler, add this line "mipmaplodbias=-0.5;"..

sampler detailmap = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap; //you want it wrap because it will be scaled smaller
AddressV = wrap;
mipmaplodbias=-0.5; //add this line, can play with the number
};
Posted By: Hades2

Re: simple tile effect ? - 05/14/07 14:11

Thanks Matt, this variable really controls the mipmap use. Annotated.
© 2024 lite-C Forums