Search Unity

Question Cut (clip) a uniform circle through the level.

Discussion in 'Shaders' started by cosmologosaurusrex, Jun 18, 2020.

  1. cosmologosaurusrex

    cosmologosaurusrex

    Joined:
    Jul 1, 2015
    Posts:
    50
    EDIT: I solved it. just do
    float2 coords = (IN.screenPos.xy / IN.screenPos.w) * _ScreenParams.xy;
    float2 mid = _ScreenParams.xy/2;
    float circle = -(100 - distance(coords, (mid)));
    clip(circle);
    To get a 100 pixel radius circle

    hole.png

    Code (CSharp):
    1.  void surf(Input IN, inout SurfaceOutputStandard o) {
    2. ...
    3. ...
    4. float2 coords= IN.screenPos.xy / IN.screenPos.w;
    5. planeDist = 0.5 - distance(coords, (0.5,0.5));
    6. clip(-planeDist);
    7. }
    Hey. So i want to make this circle not streched and lets say it reaches all the way up or half the way up in height regardless of screen resolution, then i would want it to adapt its width to not stretch all the way but rather become a uniform circle. Any other way i should go about this? I know stencil masks work but i would ultimately want to only ignore pixels from the camera up to the main character in a circle around the camera. And I could do that with clip. But maybe not with stencil im thinking. Thx :)
     
    Last edited: Jun 18, 2020