Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

A tricky hlsl problem positional vrapping on the vertex shader.

$
0
0

@willmotil wrote:

Ok i have been working on a 360 degree depth buffer for 2d lighting.

So far conceptually it works but i have one big problem i can't think of how to tackle.

atan2 is used to find the x plotting position however this must be done on the vertex shader in order to warp the positions into place.

but the problem with that is that a vertex that atan2 returns a value of can be interpolated incorrectly across the 0 and 360 degree boundry.
For example say one vertex is at bering of 5 degrees and a connected triangles next vertex has a bering at 345 degrees. The way atan2 figures this is fine but i cant wrap positional coordinats so that instead of 0 to 5 degrees and 345 to 360 degrees i end up filling the entire space from 5 to 345 degrees.

The below gif shows the problem.

if this were a texture i could set the sampler to wrap but this operation must be performed on the vertices.

Im thinking i need to somehow cut these off or clip them and draw twice. somehow but i can't quite see how to do it.

I build a polygon outline of a image that extends into the z depth by generating it from a image.
Its drawn were the image would be i change the view direction to look down the y plane from the y height towards 0 y. So in this way i have pulled the camera back to have a sandbox view of the work space. I start drawing into it for the light i calculated the x z - light x z direction and distance. The x is the assigned value of the atan2 direction result constrained as a unit value spanning the viewport width, that is passed in. The z value is the distance and the y value is untouched. The depth stencil state is set to less than. So that all passed z positional values are checked against the z buffer check for the one dimensional line per light.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles