Announcement

Collapse
No announcement yet.

How to project an overlay on top of existing mesh?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to project an overlay on top of existing mesh?

    Hi guys. I'm looking for pointers on how to do the following 3 things:

    1. Display/project an overlay on top of a hex tile (mesh).
    2. Ability to toggle this overlay on and off.
    3. Ability to customize it (mainly color and opacity)


    I read about Decal and it sounds like something that would work but I didnt entirely get the result that I want. The geometry of decal is always a cube and Im not sure if I can change it to another shape that would match with the target face of my mesh: a hexagon. From what I see if the decal is bigger than the target face then it would also project onto faces perpendicular to the target face.
    Click image for larger version

Name:	hextile.PNG
Views:	51
Size:	211.6 KB
ID:	1765502

    Also some background of my end goal: I want to recreate this scene from a childhood game, basically a turn based rpg.

    Click image for larger version

Name:	eoa3.jpg
Views:	26
Size:	79.4 KB
ID:	1765503

    When a character is clicked, the game shows an overlay on top of tiles the character can move to. I figure this is 2D so the developer might have just built the grid separately, layered it on top of the background and toggle the overlay on or off.


    #2
    You can use an alpha mask to make the decal whatever shape you want.
    However, the decal will apply to everything, not just the hexagonal base. You would have to disable decals for things above it which means you can't use effects like blood splatters or burns for it anymore. (or make a very thin decal that slips between the base and the object above it, but it's prone to artifacting)

    I think a better approach is to make the the hexagonical graphics you want to apply a part of your material. You can toggle and blend layers/attributes through blueprint or c++.
    Last edited by Graylord; 05-23-2020, 05:11 AM.

    Comment


      #3
      Originally posted by Graylord View Post
      You can use an alpha mask to make the decal whatever shape you want.
      However, the decal will apply to everything, not just the hexagonal base. You would have to disable decals for things above it which means you can't use effects like blood splatters or burns for it anymore. (or make a very thin decal that slips between the base and the object above it, but it's prone to artifacting)

      I think a better approach is to make the the hexagonical graphics you want to apply a part of your material. You can toggle and blend layers/attributes through blueprint or c++.
      Thank you for your input. I will look into blending materials.

      Last night, I ended up creating a new texture + material, using toosl like Blender and Illustrator. Here's the steps:

      - Unwrap the hex tile 3d Model in Blender and export UV map .
      - Export the material that comes with StarterContent pack into a png file.
      - Create a new texture via Illustrator.
      - Import it to UE4 and create a new material based on this.
      - Setup onclick for the actor (hextile) and switch the material via c++.

      Click image for larger version

Name:	hexAI.PNG
Views:	40
Size:	420.5 KB
ID:	1765729

      Click image for larger version

Name:	hexMove.PNG
Views:	19
Size:	518.0 KB
ID:	1765730


      I think this will do it for now.
      I also read about Material-Layer/Layered-Material, but they are rather complex and still in Beta so I didn't want to try that yet. Granted I don't have much background in 3d modelling or creating texture either.
      This is just a prototype so I simply want something functional at minimum. Will definitely revisit this though once I have the basics down.

      Comment


        #4
        You could also put a plane with the masked overlay material on it on top of the hexagon, then make the plane visible or invisible. It sounds like a dirty and ineffective workaround, but planes with masked materials are often used for things like that in particle systems.

        Comment


          #5
          Originally posted by ThiloN1987 View Post
          You could also put a plane with the masked overlay material on it on top of the hexagon, then make the plane visible or invisible. It sounds like a dirty and ineffective workaround, but planes with masked materials are often used for things like that in particle systems.
          Thank you. That totally makes sense.
          Theoretically speaking, I believe that would double the mesh required for a map of n by n right? A plane in this case could simply be another hex mesh but scaled and positioned right above a regular tile and can be toggled on/off visibility wise, or change the material on the fly.

          Comment


            #6
            No, this would be unnecessarily expensive. Just use a simple plane like it's already included in the engine or starter content and place it above the hexagon. Like this, but as a separate mesh of course:
            Click image for larger version

Name:	plane.jpg
Views:	27
Size:	193.1 KB
ID:	1765831

            Then use a translucent or masked material with a 2D-hexagon and apply it to the plane with an alpha channel like this (illustration):

            Click image for larger version

Name:	hexagon.jpg
Views:	19
Size:	14.7 KB
ID:	1765832

            The plane just acts as a display of the material, it don't needs to be more complex.

            Comment


              #7
              Originally posted by ThiloN1987 View Post
              No, this would be unnecessarily expensive. Just use a simple plane like it's already included in the engine or starter content and place it above the hexagon. Like this, but as a separate mesh of course:
              Click image for larger version

Name:	plane.jpg
Views:	27
Size:	193.1 KB
ID:	1765831

              Then use a translucent or masked material with a 2D-hexagon and apply it to the plane with an alpha channel like this (illustration):

              Click image for larger version

Name:	hexagon.jpg
Views:	19
Size:	14.7 KB
ID:	1765832

              The plane just acts as a display of the material, it don't needs to be more complex.
              Thank you!
              I tried your approach and it also works as I wanted. I went ahead and convert it to static mesh so I can spawn it and attach it as a component to my hex tile actor in C++.

              The only difference here would be the addition of a plane mesh in your solution or more textures in my solution. Either way I have to switch the texture/basecolor of the material during run time.

              Click image for larger version

Name:	hexmat.PNG
Views:	23
Size:	91.9 KB
ID:	1765872

              Click image for larger version

Name:	hexcompare.PNG
Views:	14
Size:	394.9 KB
ID:	1765873


              Comment

              Working...
              X