Does draw a triangle?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Posts: 2
Joined: Sun Jun 21, 2020 1:05 am

Does draw a triangle?

Post by skarph »

I've been experimenting with 3d graphics stuff using shaders, and i've made a fair amount of progress. Recently, I tried to give my 3d shapes an outline. I've tried to use and then draw my shape on top of it (the lines were too thin), I've tried using with 3 points (produced weird effects), and I naively tried using with "line" instead of "fill" (produced even weirder effects).

Finally, I decided to draw a line using for each side of the shape I'm trying to outline, only giving 2 points this time. This produces a triangle with a white-to-black gradient, which surprised me because I thought I was only passing 2 vertices to my shader instead of 3. Maybe I'm doing this wrong, but here's my explanation: doesn't actually draw lines, but triangles, where the 3rd vertex cannot be seen. Applying certain transformations to these 3 points can allow you to see this 3rd vertex, as openGL will attempt to interpolate between the two given vertices and this 3rd vertex.
(1.26 KiB) Downloaded 47 times
Personal theories aside, is there any way to draw a line that's immune from being transformed this way?

Thanks for any help you can give.
User avatar
Party member
Posts: 225
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden

Re: Does draw a triangle?

Post by ReFreezed »

I don't have experience with 3D graphics, but here are some observations after some testing...
  • The gradient is from opaque white to transparent white - not to black.
  • Doing color.a=1; in the fragment shader gets rid of the gradient and makes the whole triangle opaque white.
  • Calling"rough") makes the triangle invisible.
I also did some testing to figure out how actually works and, as I suspected, single-segment lines are actually rectangles, i.e. two triangles or four vertices. With "rough" line style at least! With "smooth" line style there's one more wireframe line visible in the wireframe from the start of the drawn line to the end. You can also see a gradient effect even in the wireframe.
LÖVE lines.png
LÖVE lines.png (41.35 KiB) Viewed 1120 times
Anyway, to have full control over how your lines are drawn you should probably either draw rectangles or use your own meshes.
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests