{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} Rounded Polygon 노드 | Shader Graph | 10.8.0
docs.unity3d.com
"{0}"의 검색 결과

    목차 표시/숨기기

    Rounded Polygon 노드

    설명

    Width 및 Height 입력에서 지정된 크기의 UV 입력을 기반으로 둥근 폴리곤 셰이프를 생성합니다. Sides 입력이 면 개수를 지정하고, **Roundness **입력이 각 모서리의 둥근 정도를 정의합니다.

    Tiling And Offset 노드를 오프셋에 연결하거나 셰이프를 타일링할 수 있습니다. UV 공간 내에서 셰이프를 오프셋하는 기능을 유지하기 위해 타일링 시 셰이프가 자동으로 반복되지 않습니다. 반복되는 둥근 폴리곤 효과를 구현하려면 먼저 Fraction 노드를 통해 UV 입력을 연결하십시오.

    프래그먼트 셰이더 단계에서만 Rounded Polygon 노드를 사용할 수 있습니다.

    포트

    이름 방향 Type 바인딩 설명
    UV 입력 벡터 2 UV 입력 UV 값
    Width 입력 플로트 None 둥근 폴리곤 너비
    높이 입력 플로트 None 둥근 폴리곤 높이
    Sides 입력 플로트 None 폴리곤의 면 개수
    Roundness 입력 플로트 None 모서리의 둥근 정도
    Out 출력 플로트 None 출력 값

    생성된 코드 예제

    다음 예제 코드는 이 노드의 가능한 결과 중 하나입니다.

    void RoundedPolygon_Func_float(float2 UV, float Width, float Height, float Sides, float Roundness, out float Out)
    {
        UV = UV * 2. + float2(-1.,-1.);
        float epsilon = 1e-6;
        UV.x = UV.x / ( Width + (Width==0)*epsilon);
        UV.y = UV.y / ( Height + (Height==0)*epsilon);
        Roundness = clamp(Roundness, 1e-6, 1.);
        float i_sides = floor( abs( Sides ) );
        float fullAngle = 2. * PI / i_sides;
        float halfAngle = fullAngle / 2.;
        float opositeAngle = HALF_PI - halfAngle;
        float diagonal = 1. / cos( halfAngle );
        // Chamfer values
        float chamferAngle = Roundness * halfAngle; // Angle taken by the chamfer
        float remainingAngle = halfAngle - chamferAngle; // Angle that remains
        float ratio = tan(remainingAngle) / tan(halfAngle); // This is the ratio between the length of the polygon's triangle and the distance of the chamfer center to the polygon center
        // Center of the chamfer arc
        float2 chamferCenter = float2(
            cos(halfAngle) ,
            sin(halfAngle)
        )* ratio * diagonal;
        // starting of the chamfer arc
        float2 chamferOrigin = float2(
            1.,
            tan(remainingAngle)
        );
        // Using Al Kashi algebra, we determine:
        // The distance distance of the center of the chamfer to the center of the polygon (side A)
        float distA = length(chamferCenter);
        // The radius of the chamfer (side B)
        float distB = 1. - chamferCenter.x;
        // The refence length of side C, which is the distance to the chamfer start
        float distCref = length(chamferOrigin);
        // This will rescale the chamfered polygon to fit the uv space
        // diagonal = length(chamferCenter) + distB;
        float uvScale = diagonal;
        UV *= uvScale;
        float2 polaruv = float2 (
            atan2( UV.y, UV.x ),
            length(UV)
        );
        polaruv.x += HALF_PI + 2*PI;
        polaruv.x = fmod( polaruv.x + halfAngle, fullAngle );
        polaruv.x = abs(polaruv.x - halfAngle);
        UV = float2( cos(polaruv.x), sin(polaruv.x) ) * polaruv.y;
        // Calculate the angle needed for the Al Kashi algebra
        float angleRatio = 1. - (polaruv.x-remainingAngle) / chamferAngle;
        // Calculate the distance of the polygon center to the chamfer extremity
        float distC = sqrt( distA*distA + distB*distB - 2.*distA*distB*cos( PI - halfAngle * angleRatio ) );
        Out = UV.x;
        float chamferZone = ( halfAngle - polaruv.x ) < chamferAngle;
        Out = lerp( UV.x, polaruv.y / distC, chamferZone );
        // Output this to have the shape mask instead of the distance field
        Out = saturate((1 - Out) / fwidth(Out));
    }
    
    문서 개요
    맨 위로
    Copyright © 2023 Unity Technologies — 상표 및 이용약관
    • 법률정보
    • 개인정보처리방침
    • 쿠키
    • 내 개인정보 판매 금지
    • Your Privacy Choices (Cookie Settings)