Window tiling shader

I came up with an idea to save some texture space by mirroring the corner of a window texture to make the whole window. Now, I could do this using four nested gameobjects, but I wondered if it is possible that I could write a shader that can do this automatically?

So, using this texture…

…I could create this result in the renderer:

Anyone think this might be possible?

You might be better off with a mesh of 3x3 quads and ensuring the UVs and outside polygons are set up to capture just the corners and the edges.

Then you can move around the edge quads and it’ll work properly.

The second from bottom on the left here, if you imagine the whole mesh is UV mapped to the image, then your loops are where the green lines are.

Hmm… That actually sounds like a pretty cool solution…

But would I be able to resize the mesh in Unity without distorting the corner quads?

No, this would be a procedurally generated mesh. It’s up to you to keep the corners the same size when you regenerate it or modify it via script.

Also note that you would need all nine sections of the texture (no mirroring) in order to create the original example, since the edges and corners are all different.

You can procedurally generate meshes?? Oh man… That just leads to a bunch more questions.

I may just have to revisit this later. Thanks for the info. :slight_smile:

Yeah it’s pretty awesome.