I'm trying to figure out how to get object's information pixel in screen is rendering in shader.
I'm trying to make a 3d pixelation shader. And this is done by
1.getting the render texture from camera. 2.and pixelate that using shader graph
and it works fine.
I've also managed make a pixel outline.
But the problem is when the two objects are overlayed, the outline just gets drawn as if those were the same object.
I'm not exactly sure how to get over this but my idea is to,
1.Somehow get the object information the pixel in render texture in shader. 2.And draw outlines seperately based on that info
But even after days of researching. I couldn't get it working.
If you have any documents or information about accessing object in shader, or just have another way of doing this instead of this method. I would be glad to hear it. Thanks.
These are what i've tried and thought of so far
1.Google "Unity get access to object of pixel camera is rendering" (but couldn't find anything useful)
2.Just give object outline before pixelating(It sort of works but it is jittery)
3.Get the object information based on its depth value using depth texture(It kind of works but it's unstable because if two objects stay close, there's no way to distinguish them)
4.Get the object information by giving raycast on every single position pixel will render. (But it'll have to have 100k+ raycasts and use GetComponent 100k+ times every frame, which will be expensive)