Jump to content

  • Log In with Google      Sign In   
  • Create Account

Modify pixel position


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Forcecast   Members   -  Reputation: 102

Like
0Likes
Like

Posted 23 October 2012 - 04:37 AM

Hi,

I'm in the process of writing a shader using HLSL and I stumbled upon a dilemma.
The purpose of the shader is to create a splitscreen view by shifting the pixel position.
So you got a pixel with position x,y and it needs to be translate to x'y' and x"y" which should simulate a splitscreen.

In theory this should be possible but since I'm planning to use it as a PP effect (since the shader should only affect the pixels and not the vertices), the fragment shader can't modify the pixel position (except for the depth value) since x&y get fixed after the rasterizer.

The dilemma is whether or not I should drop the idea of the PP effect and make it a complete shader meaning that I can use the vertex shader as well to give me more options in terms of modifiy the pixel position before the rasterizer. Or is there another option which I overlooked?

Thanks in progress

Forcecast

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2565

Like
0Likes
Like

Posted 23 October 2012 - 04:48 AM

You would need the source to duplicate, and a target, and you would just do simething similiar to how texture wrapping works in the pixel shader (drawing to texture and then putting that on a quad, duplicated using wrapping might br faster and/or easier tho)

Can you use the modulus function in shaders?

So you have have the pixels 0.0-1.0 in the target, the source has 0.0-0.5, and you get the pixel to copy by doing something like source=targetPixelPos%0.5

o3o


#3 ginkgo   Members   -  Reputation: 294

Like
0Likes
Like

Posted 23 October 2012 - 05:28 AM

This is something that is not usually done using shaders.

Instead you just set the viewport to the split-screen area and update the scissor rectangle accordingly. (At least with OpenGL; I guess it's pretty much the same with D3D, though)

Afterwards you just render using the standard shaders.

#4 Forcecast   Members   -  Reputation: 102

Like
0Likes
Like

Posted 23 October 2012 - 07:44 AM

Thank you both for your input.

I understand that using a render target is the way to go for splitscreen but for my case this doesn't apply.
The pixels need to be remapped spherically, both on the left and the right part of the screen.

Initially I used the word splitscreen to cover the principal but it doesn't apply for it like you would expect.
The viewport doesn't get divided, physically there should only be one buffer to where the data gets draw on to.

Thanks in progress

Forcecast

Edited by Forcecast, 24 October 2012 - 02:50 AM.


#5 phil_t   Crossbones+   -  Reputation: 3927

Like
0Likes
Like

Posted 23 October 2012 - 05:15 PM

Like you said in your first post, the xy is fixed. You can change where you sample from though.

You can render your scene in the normal way to a render target, then do a second pass which that samples from that in whatever way you want.

#6 rdragon1   Crossbones+   -  Reputation: 1200

Like
0Likes
Like

Posted 23 October 2012 - 05:19 PM

If you really need to 'scatter' data then your best bet is probably a compute shader

#7 CryZe   Members   -  Reputation: 768

Like
0Likes
Like

Posted 24 October 2012 - 10:30 AM

He could still do it in a pixel shader by writing the results to an Unordered Access View at the modified positions instead of to a Render Target. I would recommend a gather approach instead of scatter approach, though, as it might synchronisation of the individual threads, while all the threads are independent when implementing a gather based approach.

Edited by CryZe, 24 October 2012 - 10:33 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS