본문 바로가기
UE4/Niagara

Raymarching

by BroJune 2021. 8. 19.

- 참고 자료 : Udemy -

 

- Visual Studio Code

// Ray Marching

 

float4 res = float4(.0.0.0.0);

 

float t = .0;

 

for (int step_march = 0; step_march < 100; ++step_march)

{

    float3 p = ro + t * rd;

    float h = CustomExpression0(Parameters,p);

    if(h < .001)

    {

 

        float2 eps = float2(.0001.0);

        float3 N = normalize(float3(

            CustomExpression0(Parameters, p + eps.xyy) - CustomExpression0(Parameters, p - eps.xyy),

            CustomExpression0(Parameters, p + eps.yxy) - CustomExpression0(Parameters, p - eps.yxy),

            CustomExpression0(Parameters, p + eps.yyx) - CustomExpression0(Parameters, p - eps.yyx)

        ));

        res = float4(N, 1.f);

 

        break;

    }

    t += h;

}

 

return res;

 

// Map

 

struct Funcs

{

   float smin(float a, float b, float k)

    {

        float h = max(k - abs(a-b), .0) / k;

        return min(a, b) - h * h * k * (1./4.);

    }

 

};

 

Funcs f;

 

float iTime = View.GameTime;

 

float d1 = length(p - float3(30. * cos(iTime), .0.0)) - 40.;

 

float an = 2. * sin(iTime);

float2x2 rot = float2x2(

    cos(an), -sin(an), 

    sin(an), cos(an)

);

float3 q = p;

q.yz = mul(rot, q.yz);

    

float d2 = length(float2(q.y, length(q.xz) - 80.)) - 20.;

 

float d = f.smin(d1, d2, .5);

 

return d;

 

참고 자료

https://www.udemy.com/

 

온라인 강의 - 자신의 일정에 맞춰 뭐든지 배워 보세요 | Udemy

Udemy는 155,000개 이상의 강의와 4천만명 이상의 수강생이 있는 온라인 학습 및 교수 마켓플레이스입니다. 프로그래밍, 마케팅, 데이터 과학 및 그 밖의 분야에 대해 배워 보세요.

www.udemy.com

https://marketplace.visualstudio.com/items?itemName=TimGJones.hlsltools

 

HLSL Tools - Visual Studio Marketplace

Extension for Visual Studio Code - Rich HLSL language support for Visual Studio Code

marketplace.visualstudio.com



3D 레이 추적

https://www.khanacademy.org/computer-programming/program/6500474647871488/embedded?buttons=no&embed=yes&editor=no&author=no&width=500&height=400

 

3D Ray tracing exercise | Computer programming | Khan Academy

 

www.khanacademy.org

 

Ray Tracing in One Weekend

https://raytracing.github.io/

 

Ray Tracing in One Weekend Series

Ray Tracing in One Weekend—The Book Series Getting the Books The Ray Tracing in One Weekend series of books are now available to the public for free online. They are now released under the CC0 license. This means that they are as close to public domain a

raytracing.github.io

 

Transformation

https://learnopengl.com/Getting-started/Transformations

 

LearnOpenGL - Transformations

Transformations Getting-started/Transformations We now know how to create objects, color them and/or give them a detailed appearance using textures, but they're still not that interesting since they're all static objects. We could try and make them move by

learnopengl.com

 

Ray Marching

https://www.shadertoy.com/view/4dKyRz

 

Shadertoy

 

www.shadertoy.com

 

https://iquilezles.org/

 

Inigo Quilez

Articles on computer graphics, math and art

iquilezles.org

 

https://es.wikipedia.org/wiki/Matriz_de_rotaci%C3%B3n

 

Matriz de rotación - Wikipedia, la enciclopedia libre

De Wikipedia, la enciclopedia libre Ir a la navegación Ir a la búsqueda En álgebra lineal, una matriz de rotación es la matriz que representa una rotación en el espacio euclídeo. Por ejemplo, la matriz R ( θ ) = [ cos ⁡ θ − sin ⁡ θ sin ⁡

es.wikipedia.org

 

'UE4 > Niagara' 카테고리의 다른 글

Raymarching Test  (0) 2021.11.01