PaintSurface vs Sprite texturing

Blitz3D Forums/Blitz3D Beginners Area/PaintSurface vs Sprite texturing

ervin(Posted 2007) [#1]
Hi all.

I've finally got myself into gear to create my first B3D program.

I've learnt a heck of a lot so far from searching the forums and finding the help I've needed, but for my current problem I need to ask for help.





In the first image, I've created a mesh with one surface, added 4 vertices and then 2 triangles. The usual stuff. It looks like this in wireframe:

It all displays fine, except for one little anomaly, which I'll come to in a moment.

In the second image, I've simply created a sprite and applied a texture to it. This method shows the image perfectly.

The anomaly in the first image is very subtle and quite hard to see - in fact I only noticed it when flicking between the two images in an image viewer.

In the first image, the line between the two triangles in the mesh becomes apparent.

Have a close look at the word "the" on the 4th line from the bottom in the left hand pane of each image. You'll notice that in the first picture, the "t" is a little bit closer to the "h" than it is in the second image, as if it is tipping towards it.

It's as though there is a tiny bit of overlap along the common edge between the two triangles making up the surface.

I hope I've explained this well enough.
Is this something that can be "fixed" somehow?

Thanks very much for any help.


Stevie G(Posted 2007) [#2]
For quads make sure you offset the uv coords by + .5/Texturewidth and .5/TextureHeight.

This may resolve the issue.


ervin(Posted 2007) [#3]
Thanks for the suggestion.

I changed the code which is commented out below to the code which isn't.
Have I done it the right way?
It doesn't seem to have made a difference unfortunately.

;vert(i,0)=AddVertex(surf(i),-1+(2*i),1,0,0,0)
;vert(i,1)=AddVertex(surf(i),1+(2*i),1,0,1,0)
;vert(i,2)=AddVertex(surf(i),1+(2*i),-1,0,1,1)
;vert(i,3)=AddVertex(surf(i),-1+(2*i),-1,0,0,1)

vert(i,0)=AddVertex(surf(i),-1+(2*i),1,0,0+(0.5/TextureWidth(tex(i))),0+(0.5/TextureHeight(tex(i))))
vert(i,1)=AddVertex(surf(i),1+(2*i),1,0,1-(0.5/TextureWidth(tex(i))),0+(0.5/TextureHeight(tex(i))))
vert(i,2)=AddVertex(surf(i),1+(2*i),-1,0,1-(0.5/TextureWidth(tex(i))),1-(0.5/TextureHeight(tex(i))))
vert(i,3)=AddVertex(surf(i),-1+(2*i),-1,0,0+(0.5/TextureWidth(tex(i))),1-(0.5/TextureHeight(tex(i))))



Stevie G(Posted 2007) [#4]
Like this ...

tu# = .5 / float( TextureWidth( tex(i) ))
tv# = .5 / float( TextureHeight( tex(i) ))
vert(i,0)=AddVertex(surf(i),-1+(2*i),1,0,0+tu,0+tv )
vert(i,1)=AddVertex(surf(i),1+(2*i),1,0,1+tu,0+tv )
vert(i,2)=AddVertex(surf(i),1+(2*i),-1,0,1+tu,1+tv )
vert(i,3)=AddVertex(surf(i),-1+(2*i),-1,0,0+tu,1+tv )


p.s. I still can't see your issue in the images above.


RogueM(Posted 2007) [#5]
how close are the words going to be to the camera, because if it's not going to be seen close up, does a VERY tiny slant really matter?


ervin(Posted 2007) [#6]
Thanks for your help so far guys.
Unfortunately offsetting the uv coords didn't fix the problem.

However, I've been doing some more research and testing, and the slight skewing along the common line between the two triangles only seems to happen when the camera is positioned very close to the quad.

So I guess a tiny slant doesn't really matter, as it is indeed tiny.
It's still *REALLY* annoying though, because the fact that the image isn't perfect will always be in the back of my mind, poking me with a big stick and laughing at me.

If anyone is interested in seeing this in action, paste these 2 blocks of code into your IDE, run them both, and then flick between the runtime windows. The subtle skewing should become apparent in the quad version.

If anyone has found a way to get around this, I'd love to know how!






big10p(Posted 2007) [#7]
I can't see any difference between the two.

This doesn't surprise me TBH, because sprites are just quads, anyway. They're just rebuilt every time RenderWorld is called.


ervin(Posted 2007) [#8]
Sprites are just quads?
I didn't know that... it makes sense I guess.

Ah well, time to move on from this problem.
It's definitely not my imagination (maybe it's a directx "thing"), but it looks like I'll just have to accept it.

Anyway - it IS only a VERY minor issue.
If most people can't notice it anyway, then I'll ignore it from now on.


big10p(Posted 2007) [#9]
I'm intrigued about this. I believe you must be seeing something but I just can't see it myself. Like Stevie G, I can't see what you're talking about in the screenies you posted - maybe I'm looking in the wrong place. Can you circle the areas you're talking about?


ervin(Posted 2007) [#10]
It's only really noticeable if you paste relevant code into two code windows in a blitz IDE (IDEAL is excellent), and then run both bits of code at the same time.

Try the "sprite version" and "quad version" code snippets I posted above.

Switch between them using alt-tab, and you'll see the difference.
If you don't see the difference, change the z parameter of the PositionEntity commands in both programs from 0.3 to 0.2 (or something even smaller).

Then you'll see it.
(I hope)

EDIT: I just discovered that it's only visible at very high resolutions (I'm running 1680 by 1050).
I changed my display to low resolution to make it clearer, but the problem wasn't visible!
I know I'm not crazy, so I need to find some way to prove this is for real... more soon.

The positive to all of this is that I now know that as it only seems visible at high resolutions, it will indeed be invisible to most users.
Phew, eh?


ervin(Posted 2007) [#11]
For anyone that's still interested in this problem, I have finally managed to produce proof that it happens.

However, it only happens when using a high-res display, and only when zoomed in very close to the quad.
So I'm not worrying about it anymore.

Anyway - the strange banding effect visible in the picture below only happens along the join between the two triangles making up the quad. Everywhere else, the white vertical bar will be perfectly straight and won't have the banding.

(This image is taken from a screenshot of white vertical bars on a black background, produced using the "quad version" of the code I posted above. When zoomed in of course, you get the anti-aliased effect on the white bars due to the 3D filtering, which is why most of the image below is grey (the image is only of the edge along a white bar). I brightened the image a bit in photoshop to make the skew points more visible).

If you look really closely, you can see that the white bar skews one pixel to the right about a third of the way up, and then another pixel to the right two thirds of the way up.

Anyway - I'm done with this issue.
It's obviously something that is pretty much totally unnoticeable, so no more research on this from me!