-
i was looking at the procedural mesh sample and noticed that the mesh shader has a prepass pixel shader output id (vec4) that helps alter dramatically the line render, what is this ID and how does it help influence what gets outlined in the line render stage? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Beta Was this translation helpful? Give feedback.
-
Hi @pragma37! So sorry for the rookie questions but I was trying to recreate this same exercise using the new nodes and I thought I knew how ID's and edge detection worked but I seem to be completely lost. I have a very simple scene with a plane, a cube, and a light source for shadows. In your previous explanation you mentioned that the background, by default, has an ID of (0, 0, 0, 0). For my plane, I am trying to set the ID to (x, 0, 0, 0) in the lit areas and (x, 1, 0, 0) in the dark areas but for some reason both the outer and the inner edges of the plane have an outline. This was my first attempt with no edges in the inner shadow: This was my second attempt where I was able to get outlines on the shadows but failed to remove the outer outline between the background / plane: Do ID's work differently now? I noticed in your new example shaders file you are using a I also couldn't find the Luma node so i'm using a convert RGB to HSV to be able to use the value for shadow edge detection, is this the right approach to take or should I be using something else? One last question, and apologies if this is common knowledge, but, is there a way to view the values of each object's Ids? I feel like I'm trying to figure this out in the dark. |
Beta Was this translation helpful? Give feedback.
The ID is just a unique identifier. By default, the first channel (ID.x) is a unique number for each object, and the other 3 channels are just 0.
The line_width function can detect id boundaries for each channel:
It's best to avoid changing the value of the first channel, since it's used for detecting self shadows too.
Keep in mind that, since it's a uvec4, it stores values as unsigned integer numbers, so it doesn't take decimals into account.