Search Unity

Heatmap (as a texture or is it possible to use a shader ?)

Discussion in 'Shaders' started by Aero, Apr 22, 2009.

  1. Aero

    Aero

    Joined:
    Apr 22, 2009
    Posts:
    4
    Hi all :D

    I am evaluating using unity as part of a project and i would like to visualise where mouseclicks has occured on a 3D geometry as a heatmap texture (color decoded)

    Basically i have been searching this forum and read some suggestions and problems in storing data in textures and develop a finite-element look-alike shader but is it still possible to find other solutions ?

    One would be to use somthing like google analytics tools or clickheat or similar tools that are meant to visualize clicks on webpages.

    I would store the user mouse values using raycasting into a database and then pass it to a php that generates a texture/png which can be downloded using www and then finally append it to the geometry.

    A couple of problems.

    -I need to map the 3D coordinates on the geometry to a 2D picture (i guess this is..well..UV mapping..but i have no idea on how to do this). Even if i use something like screenCoordinate from the raycasting it wouldn't show the colord decoded texture correct,right ?

    -There wont be any color decoding gradient between the hotspots(mouseclicks) on the texture.

    Is it possible to pass any values to a shader that color decode vertexes depending on number of mouseclicks? I have been looking at the turorial showing the shader program with the color-decoded normals and how to pass a matrix to the program..but i have no idea on how to actually build such a shader.

    Any idea is welcome, i am totally new to shaders!

    Thanks!
     
  2. Aero

    Aero

    Joined:
    Apr 22, 2009
    Posts:
    4
    Hi,

    Was it a bad description of my question or am i just confused about the possibilities of programming a shader? :)

    So, again, anyone knows how i can affect a part of the geometry by color-decod a group of vertex by passing values to the shader. It doesn't need to be visualised in real time.

    Thanks
     
  3. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I've also been watching this thread hoping someone had some cool ideas on how to do this. This is similar to something I would like to do, but unfortunately I haven't any idea how to accomplish it through shaders. My approach would be to somehow do it with UV mapping and textures, but I haven't actually tried it yet.
     
  4. Aero

    Aero

    Joined:
    Apr 22, 2009
    Posts:
    4
    bigkahuna,

    yepp that would be great to have a shader doing that, but after you mentioned the UV mapping and textures again i was looking into raycasting..and i wasn't aware of that it actually could return the UV coordinates and apply a 2Dtexture onto that position.

    http://unity3d.com/support/documentation/ScriptReference/RaycastHit-textureCoord2.html


    So i guesss you only need to program the setPixel logics so it becomes more of a brush tool that paints onto the 3Dbody and then develop a shader that has a RGB decoder of the texture color.

    Well..instead of using setPixel on a larger texture one might want to use the GD-library or something similar in order to make the drawing off-unity so the drawing not being updated every frame. Then import the texture as a "bumpmap"..kind of...

    i will try and make some effect out of it! :)

    thanks