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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Dynamic Hole in the Wall help.

Discussion in 'General Graphics' started by Cynikal, Dec 17, 2015.

  1. Cynikal

    Cynikal

    Joined:
    Oct 29, 2012
    Posts:
    122
    Hello,

    I've been researching a simple way to do this, and have exhausted my knowledge on coming to an answer.

    My problem:

    I am wanting to add windows to a wall (a dynamically placed cube, shaped like a wall). I thought maybe some form of shader could do this. To dynamically add a hole, so if needed, they can delete the window, and the wall will still be in tact.

    Does anyone have any info, or an example shader I could go off of? or a type of shader?

    Thank you.
     
  2. StevenGerrard

    StevenGerrard

    Joined:
    Jun 1, 2015
    Posts:
    97
    Consider use a dynamic texture represent "window".
    Then apply this dynamic texture as alpha map when render wall.
    For example:
    float3 wallColor = tex2D(_MainTex, uv).rgb;
    float wallAlpha = tex2D(_AlphaTex, uv).r;
    return float4(wallColor, wallAlpha);
     
    Cynikal likes this.
  3. Cynikal

    Cynikal

    Joined:
    Oct 29, 2012
    Posts:
    122
    Thanks StevenGerrard, i'll give that a go.