Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes to FS contain NaN #10

Open
kf6kjg opened this issue Jul 22, 2021 · 8 comments
Open

Attributes to FS contain NaN #10

kf6kjg opened this issue Jul 22, 2021 · 8 comments

Comments

@kf6kjg
Copy link
Contributor

kf6kjg commented Jul 22, 2021

From my research it it looks like the FROM and TWO are somehow getting the same value:
image
This result in a div/0 error that results in the attributes getting NaN as a value.

This is based off of master at 7702efb

@theproadam
Copy link
Owner

Is this happening for every pixel or just some pixels (ie, the ones on the left side of the screen)?

@kf6kjg
Copy link
Contributor Author

kf6kjg commented Jul 29, 2021

I've not determined. Been trying to build a version of the demos that shows the problem.

@kf6kjg
Copy link
Contributor Author

kf6kjg commented Jul 30, 2021

I've been unable thus far to build a demo that shows the issue, but I did modify my shader:

		public unsafe void TerrainShaderFS(byte* bgr, float* attributes, int faceIndex)
		{
			// UVZ
			// 012
			var u = renderX.Clamp01(attributes[0]);
			var v = renderX.Clamp01(attributes[1]);
			var terrainHeight = attributes[2];

			if (float.IsNaN(u) || float.IsNaN(v) || float.IsNaN(terrainHeight))
			{
				bgr[0] = 0;
				bgr[1] = 0;
				bgr[2] = 255;

				return;
			}
...

And yes, it's only the ones on the left side of the screen. EDIT: Whoops, just realized that I had the patch from #5 (comment) applied when I got this result.

@kf6kjg
Copy link
Contributor Author

kf6kjg commented Jul 30, 2021

Running without the patch from #5 I still get errors. However they are not all on the leftmost pixel: they are scattered.
map-1-998-996-objects
And it changes pattern in every file it renders.

@theproadam
Copy link
Owner

Can you try running it with the patch, however comment out these two lines in the patch:

FROM[0] = roundf(FROM[0]);
TO[0] = roundf(TO[0]);

They can be found right after the if (ScanLinePLUS(i, VERTEX_DATA, BUFFER_SIZE, Intersects)) call.

kf6kjg added a commit to kf6kjg/renderXF that referenced this issue Aug 2, 2021
@kf6kjg
Copy link
Contributor Author

kf6kjg commented Aug 2, 2021

I got my demo variation showing the problem: https://github.com/kf6kjg/renderXF/tree/issue_10

And commenting out the roundf lines didn't fix it.

Here's a screenshot using GL.Blit() to do the rendering since there's an additional problem with blitting to the bitmap for some reason:
image
Be sure to zoom in: the blue dots along the left edge are where the attributes ae NaN due to the slope being 0.

kf6kjg added a commit to kf6kjg/renderXF that referenced this issue Aug 2, 2021
@theproadam
Copy link
Owner

Okay excellent, I will check it out.

@theproadam
Copy link
Owner

Okay, I have fixed the problem, however I will have to reexamine the scanline algorithm as some issues have emerged while testing it in XFDraw. I have created a pull request for issue_10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants