Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Moving windows dynamically

Discussion in 'General Graphics' started by warmanw, Jun 21, 2016.

  1. warmanw

    warmanw

    Joined:
    Feb 2, 2015
    Posts:
    32
    Hi Guys,

    There is an empty room model in our Scene no doors no windows no interior.

    Here Player can buy Decor from the shop and place them in the room.

    In decor we also provide windows which can be dragged over the walls which means we can't have predefined place for windows and here comes the problem:

    We don't know how to lit the room through dynamic windows.

    Since our walls are solid boxes we need them to have a hole for windows which can be moved with window so the light can work properly.

    Player also should be able to add several windows on the wall.

    Any helpful links would be thankful.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,903
    some ideas,

    Could modify actual mesh vertices, but can get complicated with many windows (maybe can limit to 1 window per wall?)
    https://docs.unity3d.com/ScriptReference/Mesh-vertices.html
    Maybe some mesh boolean package from asset store could work also..

    Or maybe can try faking it with stencil portal "holes", probably wont help if needs real lights..
    (old link but shows the idea) http://forum.unity3d.com/threads/unity-4-2-stencils-for-portal-rendering.191890/
    http://answers.unity3d.com/questions/1191030/camera-possible-to-render-partial-skybox-with-no-b.html
     
  3. warmanw

    warmanw

    Joined:
    Feb 2, 2015
    Posts:
    32
    Thanks for the Links,

    I can add a hole in the alpha channel of the wall's material albedo and change rendering mode to cutout. This way I will have a hole in the wall

    But after that can I move this hole with code using tiling or some tricks in the shader?

    I know I sound like not professional but this is our first 3D game.
     
    Last edited: Jun 21, 2016
  4. TheAlmightyPixel

    TheAlmightyPixel

    Joined:
    Jun 21, 2014
    Posts:
    263
    Adding an alpha channel doesn't affect the actual 3D geometry. You most likely have to modify the geometry of the model via script (some sort of boolean operation.

    There's also Houdini, which allows for procedural modeling and tweaking your models even in Unity:
    http://www.sidefx.com/games/
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,903
    maybe it could work,
    add cutout as secondary texture, with its own UV position, and then move it around..

    Or you could also have 1 prefab for wall without windows,
    and other prefab with wall+window already cut, then you can move the wall window vertices easily,
    since you know which vertices they are..