Jump to content

WebGL: Polygon with tiling texture


wayfinder
 Share

Recommended Posts

Hi! 

 

Here's what I want to achieve in WebGL:

 

v3EIl9c.png

 

 

What would be the way to do that? TilingSprite with polygon mask? Feasible for large polygons? Build a mesh with a Strip and do custom UVs? 

 

 

How would you do it?

 

Link to comment
Share on other sites

I've meanwhile also noticed that the polgyons flip between upside down and correct depending on the vertex positions when the points of a 4-vertex poly are in counter-clockwise order.... but only when the shape is convex! This is perhaps the weirdest thing I've seen so far

Link to comment
Share on other sites

Following the bug, I've now ended up in PIXI.WebGLGraphics.updateGraphics, where there's a switch between PIXI.WebGLGraphics.buildPoly with webGLDate.mode = 0 and PIXI.WebGLGraphics.buildComplexPoly with webGLData.mode = 1. If the latter is used, the y-axis is inverted, apparently. The switch is based on the number of vertices and the canDrawUsingSimple flag, so that explains why the number if vertices plays a role. 

Link to comment
Share on other sites

The random flipping in the GIF is explained by another switch that goes to buildComplexPoly if buildPoly doesn't work (i.e. returns false), which seems to happen sometimes and not at other times based on minuscule differences in the vertex positions, due to the PolyK triangulation routine

Link to comment
Share on other sites

...and I've worked around the flipped axis when using the stencil buffer by seriously upping the threshold after which a poly is considered so complex that it needs to be rendered using buildComplexPoly. Not ideal, and I don't know if the stencil buffer always flips y or only in my specific case and if so why (perhaps because I'm rendering to a renderTexture?

Link to comment
Share on other sites

this is, by the way, a use case for tileSprites larger than the viewport—a thing that's heavily discouraged in the docs! it's my impression though that the performance impact of huge tilesprites only happens in canvas, right?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...