UV rotation through adjacent pixels?

Wie schreibt man ein Phenomenon, bzw. einen Shader?

UV rotation through adjacent pixels?

Postby Victor on Wed Nov 18, 2009 20:13 pm

First of all is excuse me for writting in English but I can't speak German. I really think that this is maybe the best forum to ask for help about MR issues.

I can acces to the UV position of one texture in this way:

state->tex_list[0].x;

But I need the orientation too, it could be easy if I could get the .x coordinate of the adjacent pixels, it is trivial using pixel shaders:

Code: Select all
// (red channel of the texture sampler represents the u coordinate)
currentU=Tex2D(mySampler, float2(myCoords.x, myCoords.y));
nextU=Tex2D(mySampler, float2(myCoords.x+1/widthOfImage, myCoords.y));
previousU=Tex2D(mySampler, float2(myCoords.x-1/widthOfImage, myCoords.y));
upperU=Tex2D(mySampler, float2(myCoords.x, myCoords.y+1/heightOfImage));
lowerU=Tex2D(mySampler, float2(myCoords.x, myCoords.y-1/heightOfImage));


Is there any way to access to other pixels? Is there anyway to detect the orientation?

Thanks in advance, Víctor.
Victor
Neuankömmling
 
Posts: 5
Joined: Wed Nov 18, 2009 20:07 pm

Re: UV rotation through adjacent pixels?

Postby Seeda on Wed Nov 18, 2009 23:51 pm

Hi Victor.

First of all you are Welcome here on GMR.
Sorry I cant help you, but i am sure others here can do, I.e Hotchip.
I hope he will help you soon.
Regards Seeda.
User avatar
Seeda
Admin
 
Posts: 3784
Joined: Sun Nov 12, 2006 20:25 pm

Re: UV rotation through adjacent pixels?

Postby haggi on Thu Nov 19, 2009 13:52 pm

The problem here is that you dont deal with pixels but with samples. In adaptive sampling you dont know how many samples you will have per pixel, it depends on contrast and min/max settings.

The only way to get a fixed sampling is to use the rasterizer or fixed adaptive sampling. But this will result in a bad antialiased image.

Lets imgine you have a fixed one pixel sampling.
One way to get the neighbour values would be to transform the current point in raster space. Then go one pixel further and send your own ray into the scene. But this could result in an error because you dont know which objects will be hitten by the ray. Maybe you get the coordinates of a complete different object.
haggi
Admin
 
Posts: 752
Joined: Wed Jan 10, 2007 0:56 am

Re: UV rotation through adjacent pixels?

Postby Victor on Thu Nov 19, 2009 18:04 pm

Thanks for the answer haggi.
Code: Select all
But this could result in an error because you dont know which objects will be hitten by the ray. Maybe you get the coordinates of a complete different object.


That's not a problem i really don't need a extreme precision but an aproximate one (some pixel could be wrong and is not a real problem)
Victor
Neuankömmling
 
Posts: 5
Joined: Wed Nov 18, 2009 20:07 pm

Return to Writing Shader and Phenomena®

Who is online

Users browsing this forum: No registered users and 1 guest

cron