라벨이 Unity Dev인 게시물 표시

3 point Curve equation (bezier curve)

이미지
https://www.gpgstudy.com/forum/viewtopic.php?t=9715   두개의 끝점(P0, P2)과 하나의 콘트롤 포인트(P1)을 이용하여 quadratic Bezier spline 곡선을 그리는 매개변수 방정식은 다음과 같습니다. [1] P'(t) = (1-t)^2 * P0 + 2t(1-t)P1 + t^2 * P2 (0<= t <= 1) 그런데 이방정식을 이용하여 그려지는 곡선은 P1을 지나지 않으므로 이 방정식을 이용하여 아래와 같이 특정 t시간에 가운데점을 반드시 지나게하는 P1을 구한후 [1]식을 이용하여 곡선을 그리면 될듯 합니다. P1 = (P'(t) - (1-t)^2 * P0 - t^2 * P2) / 2t(1-t) 그리고 Bezier spline 곡선은 콘트롤 포인트가 많을수록 다양한 형태의 곡선을 만들수 있으니 점이 많을수록 부드러운 곡선을 그릴수 있다고 말할수도 있겠네요. https://blog.coderifleman.com/2017/03/19/bezier-curves-for-frontend-engineer-3/ 먼저 blender()는 점 A와 점 B 그리고 가중치 t를 전달받아 블랜딩한 결괏값을 반환하는 함수다. function blender ( A , B , t ) { if ( t === 0 ) { return A ; } if ( t === 1 ) { return B ; } return ( ( 1 - t ) * A ) + ( t * B ) ; // or A + t * (B - A) } 이때 blender()는 좌표 하나에 대한 연산만 책임지므로 x, y 좌표를 연산하기 위해 blend()를 작성한다. function blend ( x1 , x2 , y1 , y2 , t ) { const x = blender ( x1 , x2 , t ) ; const y = blender ...

frustum culling & GPU instancing examples

 https://github.com/Milk-Drinker01/Milk_Instancer01/blob/main/README.md https://github.com/miccall/Unity-GPU-Driven-Pipeline https://githubhot.com/index.php/repo/Milk-Drinker01/Milk_Instancer01 https://www.mpc-rnd.com/unity-gpu-culling-experiments/ https://github.com/ellioman/Indirect-Rendering-With-Compute-Shaders/blob/master/README.md https://github.com/ColinLeung-NiloCat/UnityURP-MobileDrawMeshInstancedIndirectExample https://youtu.be/dMreKTbQkcE https://youtu.be/e5WXx4PQXpU http://www.lighthouse3d.com/tutorials/view-frustum-culling/ https://github.com/tsherif/webgl2examples

GPU Instancing

이미지
 https://docs.unity3d.com/Manual/GPUInstancing.html GPU instancing GPU instancing is a  draw call optimization  method that renders multiple copies of a  mesh  with the same material in a single draw call. Each copy of the mesh is called an instance. This is useful for drawing things that appear multiple times in a  scene , for example, trees or bushes. GPU instancing renders identical meshes in the same draw call. To add variation and reduce the appearance of repetition, each instance can have different properties, such as  Color  or  Scale . Draw calls that render multiple instances appear in the  Frame Debugger  as  Draw Mesh (instanced) . Requirements and compatibility This section includes information about the platform, render pipeline, and SRP Batcher compatibility of GPU instancing. Platform compatibility GPU instancing is available on every platform except  WebGL  1.0. Render pipeline compatibility Feature Bu...

Universial render pipeline shadow calc

 https://github.com/Unity-Technologies/Graphics/blob/4ad03e7975af24c8e60c974edb24c696e74e39b3/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl#L158 https://cyangamedev.wordpress.com/2020/09/22/custom-lighting/ real SampleShadowmapFiltered ( TEXTURE2D_SHADOW_PARAM (ShadowMap, sampler_ShadowMap), float4 shadowCoord, ShadowSamplingData samplingData) { real attenuation; #if defined (SHADER_API_MOBILE) || defined (SHADER_API_SWITCH) // 4-tap hardware comparison real4 attenuation4; attenuation4.x = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingData.shadowOffset0.xyz); attenuation4.y = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingData.shadowOffset1.xyz); attenuation4.z = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingData.shadowOffset2.xyz); attenuation4.w = SAMPLE_TEXTURE2D_SHADOW (ShadowMap, sampler_ShadowMap, shadowCoord.xyz + samplingDa...