- Home /
Iterate pixels of texture exactly once
Question: Given a triangle with UVs, is there a way to iterate the pixels of the texture across that triangle exactly once? This is not a rendering, screen space, or shader question specifically, this is something I need to do computationally when modifying a texture. You can assume no UV or texture sharing.
Background: I have a visualization tool written in Unity that displays some geometry sent to it by another app(such as a game). This tool also receives real time events that one might be interested in visualizing, such as weapon fired events, deaths, etc. These events could number in the tens of thousands over the lifetime of a match or analysis period. I'm using a single channel float shader to accumulate arbitrary event influence values on a texture, sort of like a floating point lightmap texture, and I have a shader that re-maps those values to a cool-hot gradient map at render time using the known min/max accumulated values that it can keep track of while incrementally modifying the textures. The missing piece is that I need to convert these world events(which will be points and/or lines in world space), down to triangle texture space, so that I can basically calculate the distance from that texel in world space to the event, and add the appropriate influence to that pixel. I know that I will need to gather the list of triangles that are within the influence distance of the event initially, and then on that list of triangles, in theory use the UVs and the texture size to iterate the texels exactly once(so as not to double accumulate influence), convert them to world space, and then compute the appropriate influence to apply to that pixel by its distance to the event.
Any ideas for handling this last part would be much appreciated.
Your answer
Follow this Question
Related Questions
Why can't I animate texture offset? 1 Answer
Calculate UV coordinates of 3D point on plane of mesh's triangle 1 Answer
What's the Unity shader equivalent of gl_FragCoord? 0 Answers
remapping cube UVs 1 Answer
Problem with UV maps and textures 2 Answers