Sign in to follow this  

arbitrary texture coordinates

This topic is 669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying inside a loop accessing a texture color using arbitrary coodinates. 

 

My texture can map properly to a mesh but I can't seem to sample them without using the mesh uv coodinate. 

while (count <= size)
{
	int x = (int)(count % w);
	int y = (int)(count / w);
	float2 uv = float2(x, y);
			
	float3 = col.Sample(texturesampler, uv).rgb;
count++;
}

the color output is always wrong. like its only sampling one color

 

this is my sampler description 

SamplerStateDescription
            {
                AddressU = TextureAddressMode.Clamp,
                AddressV = TextureAddressMode.Clamp,
                AddressW = TextureAddressMode.Clamp,
                BorderColor = new Color4(0, 0, 0, 0),
                ComparisonFunction = Comparison.Never,
                Filter = Filter.MinLinearMagMipPoint,
                MaximumLod = float.MaxValue,
                MinimumLod = 0,
                MipLodBias = 0.0f
            }

so I'm wondering if there it can be done or if I have to use something like sampleGrad. 

 

 

 

Share this post


Link to post
Share on other sites
What exactly are you trying to do ?

There are several pitfalls in your shader code.
1. float3 = col.Sample(texturesampler, uv).rgb;
This will not compile, will it (ok, I'm not familiar with hlsl) ? Do you want to sum it up, average it or get the last color ?

2. float2 uv = float2(x, y);
This will always contains integers, that is 0,1,2,3...
So, using clamp this will always sample the border of the texture ! You should apply an offset/scale accordingly, depending on what your goal is.

Share this post


Link to post
Share on other sites

This topic is 669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this