Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Have each of the 3 verts of a triangle write to a single axis each of a variable of a surface shader

Discussion in 'Shaders' started by Guedez, Oct 16, 2017.

  1. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    In my ignorance on how graphics card vertex and surface shaders work, I managed to come up with a plausible solution to have up to 4294967296 textures on a texture without using a splat map, but what I ask for is probably not possible on any video card.

    My proposal is as follow.
    If triangle is composed of 3 vertexes and if each vertex have only a single texture associated with it, each triangle only needs to know 3 texture positions on a texture atlas to be able to blend the 3 textures.
    The each vertex would pass which texture it is associated with (for instance: vertex1 is associated with 0, vertex2 with 4 and vertex3 with 9)
    The ideal result would be a non-interpolated variable (int3) containing the associated textures ([vertex1.tex, vertex2.tex, vertex3.tex] or [0, 4, 9] in the example above) and for each pixel, another variable (float3) containing the barycentric coordinates for the current pixel.

    It does not matter in which order the vertexes' associated textures get filled in, so long the barycentric coordinates are filled in the same order, the blending would always happen corretly, but I don't think it's possible to have each vertex fill a axis of a non-interpolating variable, is it?