faiface/pixel

Canvas Triangles with their own Shader

Closed this issue · 3 comments

While looking through the Canvas, glShader, and GLTriangles code, I noticed that while we can create GLTriangles the shader seemingly isn't ever used.

It could be used by the canvas triangles since they're GLTriangles, but their Draw method uses the Canvas's shader. It could be useful to have Canvas.MakeTriangles additionally take GLTriangles (similar to Canvas.MakePicture) and update the Canvas.Draw method to reference the triangles shader instead of the Canvas's. If someone puts normal triangles into Canvas.MakeTriangles, it still makes the GLTriangles with the Canvas shader.

If this is an acceptable idea, I think the glShader structure would need to be exported and GLTriangles updated to accept glShader instead of glhf.Shader during creation since Canvas.Draw accesses uniform information from its glShader.

I'm happy to put a PR together for these changes, but I wanted to check to see if this functionality is even wanted/expected in Pixel. Please let me know if more explanation is needed.

delp commented

I'm not very familiar with that part of the library yet but I'm happy to look at any code you write from a maintainer's perspective!

Maybe @faiface can weigh in on this

After thinking about this some more, I'm not convinced that the glShader structure would need to be fully exported; an exported version/interface could be made that the canvas's shader could implement (so the user wouldn't have access to overwrite some of the more sensitive portions of the canvas' shader) while still allowing the user to have their own shader, with easy uniform mounting etc, to be put on the GLTriangles for drawing.

This was handled by #246, closing