Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Adding second texture to surface

Discussion in 'General Graphics' started by schneidross, Jan 27, 2015.

  1. schneidross

    schneidross

    Joined:
    Sep 17, 2014
    Posts:
    8
    Hello everyone,

    I'm using uwebkit.com as a Unity extension to display websites as textures on surfaces. To achieve this, I have to append two scripts to the gameobject and everthing works just fine.

    Now, I want to add a mouse cursor floating "on top" (but in the very same layer) of the webtexture. The way I was trying to make this possible is to create a second texture which is allover transparent but the few pixels which represent my mouse cursor and putting it in front of my webtexture.

    The second texture (attached as a script) works just fine but I have no idea how to put it in front of any other texture.

    Can you provide me some hints on how to do this, or maybe some of you have another idea to get a cursor on my webtexture?

    Any help is much appreciated.

    Best
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Put it on a quad and move it closer to the camera?
     
  3. schneidross

    schneidross

    Joined:
    Sep 17, 2014
    Posts:
    8
    Hello,

    thanks for your reply!

    Unfortunately, what you suggested is not possible due to the following reasons:
    1) The surface I am attaching my webtexture to is a curved wall in 3D space rather than a flat rectangle or even a flat squad. Furthermore, even more complex shapes could also be considered in the future.
    2) The way I am looking at those textures resp. objects is through an Oculus Rift which renders two images seperately. To keep it simple, the cursor is supposed to lie in the very same layer as the texture does, I guess.

    Any further proposals are very welcome.

    Best
     
  4. schneidross

    schneidross

    Joined:
    Sep 17, 2014
    Posts:
    8
    Hello everyone,

    in case someone is interested, I achieved my goal doing the following in Unity3D:

    1) I increased the size of materials (in the Mesh Renderer tab) by one so that it can handle two of them.
    2) I added two Materials to the renderer:
    2a) Element 0 is a Material whose texture will be overwritten* by the webtexture. The webtexture I use (uWebKit plugin) seems address the first (in this case: 0th) material's texture by default. This material uses a Diffuse shader.
    2b) Element 1 is a Material whose texture will be overwritten* by the texture which contains the mouse cursor. This texture is overall transparent but the few black pixels representing the cursor. This material uses a Transparent/Diffuse shader.

    It seems to happen, that the renderer takes the different materials into account, according to their given order in the renderer's materials section.

    * by script

    Thanks to everyone who took some time thinking about my problem.

    Best