Skip to content

Texture offset and repeat settings in Material #10490

@brianchirls

Description

@brianchirls

Right now, there are two ways to adjust the positioning of a texture on an object:

  • UV coordinates in geometry
  • .offset and .repeat properties on Texture

It would be useful to also have .offset and .repeat properties on Material as well, so that these values could be varied on different objects without having to allocate additional geometries or texture resources.

I'm considering an interesting use case: breaking down sky spheres/domes into smaller components. Rather than create a single, large, solid sphere, imagine a fraction of an icosahedron (subdivided) and repeated as multiple meshes to construct a sphere out of pieces. It would cost a few extra draw calls, but provide at least two benefits:

  1. Significantly reduce the number of vertices computed by excluding the ones that are off camera, which is well more than half. Spheres can have hundreds of vertices, depending on the level of detail. This is not such a big deal on desktop, but I suspect it could make a big difference on mobile devices with tiled GPU architectures that would cause the vertex shader to be run many times.
  2. Reduce overdraw by fixing z-sorting. If an entire sky sphere is positioned at [0, 0, 0], it will almost certainly be sorted incorrectly and drawn first every time, even though it should be drawn last. By positioning individual sphere components far away, they should be correctly sorted last.

Implementing this approach today would require duplicating either the geometry (for different UV coordinates) or the texture (for different offsets) for each piece of the sky. If we could set the offset on the material, each piece would use the same geometry, shader and sampler, only varying the uniform values between draw calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions