Jump to content
  • Advertisement
Sign in to follow this  

Pixel shader question

This topic is 4884 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 have a question about pixel shaders: I have set 8 texture stages (0 - 7) in my program. I want to have a final texture on the screen that displays image data of all the 8 textures, a bit scrambled. I have a 8x12 lookup matrix that tells me for a specific position where I need to get the color from. The matrix is the following: [[1, 4, 7, 2, 5, 8, 3, 6], [2, 5, 8, 3, 6, 1, 4, 7], [2, 5, 8, 3, 6, 1, 4, 7], [3, 6, 1, 4, 7, 2, 5, 8], [4, 7, 2, 5, 8, 3, 6, 1], <-- 5 [4, 7, 2, 5, 8, 3, 6, 1], [5, 8, 3, 6, 1, 4, 7, 2], [6, 1, 4, 7, 2, 5, 8, 3], [6, 1, 4, 7, 2, 5, 8, 3], [7, 2, 5, 8, 3, 6, 1, 4], [8, 3, 6, 1, 4, 7, 2, 5], [8, 3, 6, 1, 4, 7, 2, 5]] ^ | 3 This means that for the pixel at position (3, 5) I need to get the color from stage 2. Now my question is: how can I make a shader like this? Is this possible with a pixel shader? I can't enter my matrix because only 4x4 matrices are supported and I use the full 8 texture stages so having a lookup-table in a texture isn't possible... I must say that the textures are all the same rendered 3D scenes with a different camera position. I use render to textures to make this work in my program. If someone is more interested in the details I've made a PDF with some more details. http://www.poison.be/pixelshader/X3D.pdf Thank you very much in advance!!!!! Nicolas

Share this post


Link to post
Share on other sites
Advertisement
Somebody might be able to come up with a clever way to accomplish what you are trying to do on the GPU, but it seems to me that it would be easier to do it on the CPU.

Share this post


Link to post
Share on other sites
won't that be slow as hell?

I think I found a formula to generate the matrix


for (int y = 0; y < 12; y++)
{
for (int x = 0; x < 8; x++)
{
int result = (x * 3 + y - (int)round(y / 3.)) % 8;
printf ("%d ", result);
}
printf ("\n");
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!