Gradients tiling problem

Using photoshop or a spread of colours would be nice for creating more elaborate gradients, so I added texture support. But now there’s this seam where the texture wraps that I can’t seem (no pun intended ;) to get rid of.

I know next to nothing about the details of texturing in shaders :(

Any pointers? (See the file below)

Regards, Ernst Hot

grrrrrrrrr.rar (2.7 kB)

hi
it is a problem that there are no sampler state pins within the effect nodes. a quad e.g. has a Sampler State pin with which you can connect an Address (EX9.SamplerState) node.
since we didn’t manage to implement this feature yet there are only some complicated workarounds.

in the effect you have those lines at the top of the shader

sampler Samp = sampler_state //sampler for doing the texture-lookup
{
Texture = (Tex); //apply a texture to the sampler
MipFilter = LINEAR; //sampler states
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};

AddressU and V describe how the texture should be repeated in horizontal and vertical direction.

i think there are the modes
wrap
clamp
mirror
border

so these modes describe how a sampler should work with texture coordinates outside the rectangle (0,0)…(1,1). should the picture be repeated or just the last pixel at the border, should it be mirrored or should there be a constant border colour.

then there is also a line within the pass description:

technique Gradients
{
pass P0
{
//Wrap0 = U; // useful when mesh is round like a sphere
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_2_0 PS();
}
}

Wrap0=U states that even texture coordinates within (0,0)…(1,1) can be interpreted in a special way. the best example is when you are rendering closed objects (which are round like a sphere).

a sphere can be constructed in a way that there is a seam and that all points on this seam are doubled: once they all have texture coordinates for the left border of the image (0,x) and then for closing this object htere are points for the right border of the image ontop of the first ones with texture coordinates (1,x)…
if your object is constructed this way you don’t need these Wrap modes.

but if the sphere doesn’t have a seam and has no doubled points, then these points should work once for the left image border and also for the right image border.
so this line Wrap0=U says how to interpolate texture coordinates within a trinagle.
so if you have a triangle with U texture coordinates
0.9, 0.9, 0
then the texture will be drawn as if the texture coord would be
0.9, 0.9, 1

if you want to be able to choose from outside how the sampler should behave then you have to create several techniques dealing with several smaplers…

hope that helps
greg

Thanks greg, that cleared up some things for me, however the problem it seems was elsewhere.

More specificly here:

{CODE(ln=>0)}val = frac(val+Phase);^
which isn’t necessary as the texturelookup can deal with out of bounds coordinates by itself, so after changing this to:

{CODE(ln=>0)}val += Phase;^
it works fine and is faster too :)
There are some other minor problems now, but I hope I can deal with those.