Search Unity

Creating A shader not rendering specific vertices

Discussion in 'Shaders' started by SgtOkiDoki, May 22, 2018.

?

Creating A shader not rendering specific vertices

  1. Shader

    100.0%
  2. Optimization

    0 vote(s)
    0.0%
  1. SgtOkiDoki

    SgtOkiDoki

    Joined:
    Sep 7, 2016
    Posts:
    12
    Hi, I am trying to create a shader does not render specific vertex Index's, I will put a uint[] in the shader and set them as 0 or 1.

    So how can I make the part of Skipping rendering the vertex?

    thank you
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    I replied to a similar question here:
    https://forum.unity.com/threads/sto...x-distance-to-the-camera.532922/#post-3509802

    The short version is you can't skip a specific vertex, not in a vertex shader at least. By the time you're at the vertex shader the decision to process it or not has already passed and there's no avoiding it. Also you don't really render vertices ever, you render the fragments (or pixels) of a tri that uses the position of three vertices. If you want to avoid rendering a specific tri by hiding one vertex, then something like a geometry shader, compute shader, or modifying the mesh before hand in script are your best options.