Jump to content

Round Render Target


LLIEPLLIEHb

Recommended Posts

Hello SKYNET174,

it does not make sense to ask about round render targets because they are merely color buffers and those are stored as 2D memory arrays. Instead you want to ask how to draw a render-target with a round cut-out. For that you can utilize a special pixel shader (PS) in combination with the dxDrawImage function. Simply attach the render-target as texture to the PS and use custom math that clips the pixels outside of the circle using the HLSL clip function.

In the PS you obtain texture coordinates ranging from inclusive 0 to exclusive 1 for each dimension. We want to put a circle with radius 0.5 at the texture coordinate (0.5, 0.5) which is the middle. Thus in the PS we calculate the euler distance ED from the middle coordinate to the current texture coordinate of the drawing pixel.

clip_x = 0.5 - ED

Then we call the HLSL clip function with clip_x as parameter. Since clip_x is smaller than 0 for every coordinate outside of the circle the pixels outside of the circle will not be rendered. Thus we display the render-target in a very finely approximated circular shape!

Hints:

  • Make sure to pass quadratic width and height parameters to the dxDrawImage call which should render the circle shape using the PS. Otherwise your circle might look wonky.

Good luck. ?

Edited by The_GTA
Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...