Quantcast
Channel: Questions in topic: "hlsl"
Viewing all articles
Browse latest Browse all 206

Point cloud selection via pixel color

$
0
0
I currently have a custom point cloud shader for Unity. The point clouds are represented as a collection of meshes, each point being a vertex in a mesh. The shader displays a billboard/quad with transparent texture at each vertex location. This is what one of our point clouds looks like with the shader: ![alt text][1] ![alt text][2] You can see in the close-up view that each point is a quad with a kind of gradient circle texture. I have developed the ability for the user to select a point by indexing all the points in an octree structure and traversing it based on camera/mouse input. This method is rather heavy though, both for indexing and for traversing, and I believe it would be possible to instead develop a shader to record the positions of vertices in a texture buffer (placing XYZ world positions into the buffer instead of RGB vertex values). Then we could simply reference the XYZ buffer texture at Input.mousePosition and retrieve the color, which we would interpret as XYZ, and we would have the world position of the point where the user clicked. The issues I'm having in implementing this idea are numerous, it seems to require shader knowledge much deeper than I have. I am able to color pixels based on world coordinates using: float4 frag(VertexOutput o) : COLOR { float4 worldPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)); float4 returnCol = float4(worldPos.rgb * _Scaler, 1.0); return returnCol; } But I am having no success getting it to color based on the vertex positions, only polygons. All vertex pixels are colored black. Even if that portion would work, I then still have the problem of trying to integrate it into the existing shader, which I'm assuming would somehow need to output the XYZ values to a separate buffer, and continue sending the the regular RGB values for rendering. I'm very unsure how to best structure this and then how to execute. Please let me know if my issue makes sense, if not I can try to explain more. [1]: /storage/temp/207365-image.png [2]: /storage/temp/207366-image2.png

Viewing all articles
Browse latest Browse all 206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>