map 과 unordered_map 의 검색 속도 비교 결과.

데이터 추가Map과 UnorderdMap 속도 비교 분홍색Map / 파란색UnorderdMap 

데이터 수 128 개를 넘어가며 map의 검색 속도가 크게 하락된다.

unordered_map 은 800만개 이상 까지 준수하게 좋은 검색 속도를 보여준다.

map은 binary tree 이고, unordered_map 은 hashtable.

unordered_set과 더불어 map 사용할 일이 있으면 unordered_map 사용 하기로..

 

http://supercomputingblog.com/windows/ordered-map-vs-unordered-map-a-performance-study/

 

Ordered map vs. Unordered map – A Performance Study

There comes a time in most complex programs where you want to ask a simple question like, ‘have I already processed a string with this id’? Linear searches through an array are easy to …

supercomputingblog.com

 

https://gracefulprograming.tistory.com/3

 

[C++] map vs hash_map(unordered_map)

개요 hash_map은 비표준 Container인데 반해(stdext namespace에 포함) unordered_map은 C++11에서 STL 표준 Container로 추가되었으며, (사실 TR1부터 추가되었지만 C++11에서 좀 더 최적화가 이루어졌다고 합..

gracefulprograming.tistory.com

 

[C++] map vs hash_map(unordered_map)

https://m.blog.naver.com/PostView.nhn?blogId=rapperkjm&logNo=221038507723&proxyReferer=https:%2F%2Fwww.google.co.kr%2F

 

map과 unordered_map의 속도 비교와 사용의 차이

C++ 11이 적용이 될 즈음부터 Unity를 사용하면서 C# 만 하다가 최근에 다시 C++을 하고 있습니다. 현...

blog.naver.com

 

map과 unordered_map의 속도 비교와 사용의 차이

http://lab.gamecodi.com/board/zboard.php?id=GAMECODILAB_QnA_etc&no=3392

 

unordered_map과 map과 multimap을 언제 사용하면 좋은가요?

대략 장단점은 생각해 보았는데, 실제 게임을 만들때 어떤 자료구조에 적합한지 예시를 떠오리려니 감이 잘 안오네요.혹시 이 부분에 대해서 아시는 분은 답변 부...

lab.gamecodi.com

 

 

게임에서 머신러닝이 이런식으로 활용될 수 있겠구나 식의 감 잡기에 좋은 내용이다.

유니티 머신러닝 툴킷은 2018년 오픈소스 프로젝트로 버전이 계속 0.x 이다가 2020년 5월에 정식 1.0이 되었다.

Unity ML-Agents Toolkit

https://github.com/Unity-Technologies/ml-agents

이미지 썸네일 삭제

Unity-Technologies/ml-agents

Unity Machine Learning Agents Toolkit. Contribute to Unity-Technologies/ml-agents development by creating an account on GitHub.

github.com

 

20개 정도 되는 머신러닝 샘플 들 소개.

Unity ML Samples (Example Learning Environments)

https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Learning-Environment-Examples.md

이미지 썸네일 삭제

Unity-Technologies/ml-agents

Unity Machine Learning Agents Toolkit. Contribute to Unity-Technologies/ml-agents development by creating an account on GitHub.

github.com

 

유니티 머신러닝 에이전트 라이브러리를 이용해서 테스트 샘플 로 주욱 따라 가며 배우기 좋은 내용.

펭귄 영역, 펭귄 에이전트, 펭귄 새끼, 물고기 어셋이 주어지고

펭귄 에이전트가 바다에 물고기를 가져다가 펭귄 새끼에게 많이 먹이는 게 목표.

펭귄 에이전트는 매 틱마다 목표 감지 센서를 돌리고

바다에서 물고기를 먹으면 Reward(1.0f) 올라가고 새끼에게 물고기를 내뱉어 먹이면

Reward(1.0f)로 올라가게 세팅 된다.

그럼 에이전트는 Reward가 가장 높게 행동 하는 방식.

https://www.immersivelimit.com/tutorials/unity-ml-agents-penguins

이미지 썸네일 삭제

Unity ML Agents | Penguins — Immersive Limit

In this Unity ML Agents tutorial you’ll learn how to use machine learning, specifically reinforcement learning in Unity to train penguins to find fish and feed their babies.

www.immersivelimit.com

 

펭귄 샘플 WorkThrough를 통해 배워가는 과정들을 개인 리파지토리.. ing.

초반 세팅으로 유니티 버전과 ML 라이브러리 버전을 맞추는 작업이 필요.

Unity version : 2019.4.6.f1 lts / Unity ML version : 0.8.2.

https://github.com/egoquat/MLTestUnity01

이미지 썸네일 삭제

egoquat/MLTestUnity01

Personal Unity ML Test Penguin samples. Unity version 2019.4.6f1 lts - egoquat/MLTestUnity01

github.com

 

'GameEngine > Unity' 카테고리의 다른 글

[link] Unity3D advanced references  (0) 2011.07.14

Siggraph 2010

http://advances.realtimerendering.com/s2010/index.html

Introduction: Graphics Feature Development for Games

 

Abstract: In this talk we cover the practical motivation for graphics feature development for games, describe the requirements for successful integration of visual elements into games and introduce the speakers for the rest of the course.

  

Affiliation:

Bungie

Materials
(Updated August 8th 2010)

PowerPoint Slides (8.29 MB)

PDF Slides (1.4 MB)

  

  

  

  

Rendering techniques in Toy Story 3

 

Abstract: We will talk about the evolution of the lighting and shadow techniques used in Toy Story 3.   We will discuss not only the technology behind those methods that ended up in the final game, but also some of the alternatives that were tried along the way and why these failed to meet our needs (either technically or from our artists' standpoint).  Among other subjects, we will discuss our approach to ambient lighting, screen space ambient occlusion, and shadows.

  

Affiliation:

Avalanche / Disney

Materials
(Updated August 8th 2010)

PowerPoint Slides (121 MB)

PDF Slides (16.8 MB)

Video (21 MB)

  

  

A Real-Time Radiosity Architecture for Video Game

 

Abstract: This talk focuses on an architecture and set of techniques for producing real-time radiosity in video games. We describe Enlighten, a middleware toolkit for computing real-time radiosity, and demonstrate how the technology is used in and was shaped by its integration into the Frostbite game engine. We describe Enlighten's architecture, covering its separation of direct and indirect lighting, mixed use of CPU/GPU resources, and Enlighten's target projection and relighting system. We will demonstrate how the workflow, content pipelines and run-time systems for Enlighten function in the Frostbite Engine to achieve real-time radiosity for use in video games.

Materials
(Updated August 7th 2010)

PDF Slides (3.15 MB)

Video (135 MB)


 

Real-Time Order Independent Transparency and Indirect Illumination using Direct3D 11

 

Abstract: This talk describes a fast method of constructing linked lists on the GPU using new features in Direct3D 11.  Two applications of linked lists are order independent transparency (OIT) and indirect shadowing.  For OIT, a linked list of fragments is constructed during rendering at each screen pixel location.  A post-pass sorts and resolves transparency.  By using Direct3D 11, construction is integrated in the graphics pipeline and can take advantage of standard hardware features such as depth buffers and MSAA.  The indirect shadowing technique stores scene triangles in a 3d grid structure and uses raytracing to determine if an indirect light is blocked by scene geometry.

Affiliation:

AMD

Materials
(Updated August 10th 2010)

PowerPoint Slides (11 MB)

PDF Slides (5 MB)

 

CryENGINE 3: Reaching the Speed of Light

 

Abstract: We present the expertise of making the generalized and balanced real-time rendering pipeline. The techniques in this course notes are carefully filtered to provide the most reusable concepts for real-time graphics. The problem of efficient and compact data representation is discussed for the majority of stages of the rendering pipeline in CryENGINE 3. The layered decomposition of the physically-based lighting model is discussed in details as well as the tools provided for complete artistic control over the image. The lighting consistency discussion of this chapter can be used as a checklist for design of an advanced real-time lighting pipeline.

The list of techniques and accurate approximations described in this course notes can serve as a cookbook for design of real-time visualization engine.

Affiliation:

Crytek

Materials
(Updated August 10th 2010)

PowerPoint Slides (103 MB)

PDF Slides (8.9 MB)

Video (78 MB)

Normals Fitting Texture (to be used w/ the shader code described in Appendix A)


 

Sample Distribution Shadow Maps

 

Abstract: In this session we present an extension to Z-partitioning (cascaded shadow maps) called Sample Distribution Shadow Maps (SDSMs). SDSMs optimize the placement and size of a fixed number of Z-partitions by analyzing the shadow sample distribution required by the current frame. They build on the advantages of current state of the art techniques, including predictable performance and constant memory usage, while removing tedious and ultimately suboptimal parameter tuning. We show that SDSMs run efficiently on modern graphics hardware and produce significantly higher quality shadows than static Z-partitioning schemes. Furthermore, SDSMs save development time since they avoid the manual placement and maintenance of shadow partitions that is typically required by other Z-partitioning schemes.

  

Affiliation:

Intel

Materials
(Updated August 7th 2010)

PowerPoint Slides (6.7 MB)

PDF Slides (3 MB)

Video (78 MB)

Additional links: Project pageDemo ZIP

 

Adaptive Volumetric Shadow Maps

 

Abstract: In this session we present Adaptive Volumetric Shadow Maps (AVSMs), a novel real-time volumetric shadow algorithm for high-quality shadowing from participating media such as hair and smoke. The key contribution of AVSMs is a new streaming compression algorithm that can generate an accurate but compact representation of light attenuation functions. AVSMs do not make assumptions about the type or spatial distribution of occluders, providing higher quality volumetric shadows than other real-time methods while performing competitively with existing solutions.

  

Affiliation:

Intel

Materials
(Updated August 10th 2010)

PowerPoint Slides (6.1 MB)

PDF Slides (1.8 MB)

Video (36 MB)

Additional links: Project PageDemo ZIP


Uncharted 2: Character Lighting and Shading

 

Abstract: This talk covers the shading models used for the characters in Uncharted 2.  This presentation will describe which lighting sources are used in which rendering passes.  Specific shaders will be discussed, including skin, hair, and cloth.

  

Affiliation:

Naughty Dog

Materials
(Updated August 7th 2010)

PowerPoint Slides (29 MB)

PDF Slides (7.9 MB)

 

Destruction Masking in Frostbite 2 using Volume Distance Fields

 

Abstract: Destructible environments have become increasingly common in games today, and is  a key area of focus for the Frostbite game engine. One important aspect of making destructible environments look believable is destruction masking - the technique of changing surface characteristics by compositing damaged materials onto the surface.

This talk describes the techniques used in Frostbite 2 to implement destruction masking. We discuss using Volume Distance Fields to mark damaged locations, different implementation alternatives are covered, and we review solutions for applying the masked destruction materials using deferred texturing.

  

Presenter:

Robert Kihl

Affiliation:

DICE

Bio:

Robert Kihl is a Software Engineer working on the Frostbite engine at EA DICE. His work covers different rendering systems such as fully destructible environments, sky and environment rendering, and particle effects. Robert is also involved in developing the content workflows and pipeline for Frostbite 2.

  

Materials
(Updated August 10th 2010)

PowerPoint Slides (10 MB)

PDF Slides (2.8 MB)

 

Water Flow in Portal 2

 

Abstract: This talk will describe Valve's real-time water flow shader and art pipeline used in Left 4 Dead 2and Portal 2 (due to ship later this year). Artists paint a 2D flow texture that describes direction and speed of the water at every texel. The texture is sampled in a shader to generate unconstrained flow of a normal map and dirt texture. A full description of the shader and the art pipeline used to generate the flow texture will be given.

  

Affiliation:

Valve

Materials
(Updated August 7th 2010)

PDF Slides (6.

1.InvalidOperationException: tree modified
-exception
1.Unitwalking die로 Collision list 삭제가 빈번한 상황에서 발생.
2.Error 내용 InvalidOperationException: tree modified.

-exception location
//@ If unit is null, Delete unit from collideList.

List<UnitWalking> listCollideCollect = new List<UnitWalking>();

ICollection<int> collectionID = listCollider.Keys;

 

foreach (int idunit in collectionID) { <-Error

UnitWalking unitWalking = unitpool[idunit] as UnitWalking;

if (null == unitWalking) {

listCollider.Remove(idunit); // <-InvalidOperationException: tree modified

}

else {

if (true == unitWalking.IsUnitDie())

listCollider.Remove(idunit); // <-InvalidOperationException: tree modified

else

listCollideCollect.Add(unitWalking);

}

 

-exception solution
//@ If unit is null, Delete unit from collideList.

List<UnitWalking> listCollideCollect = new List<UnitWalking>();

ICollection<int> collectionID = listCollider.Keys;

List<int> listcollideremove = new List<int>();

 

foreach (int idunit in collectionID)

{

UnitWalking unitWalking = unitpool[idunit] as UnitWalking;

if (null == unitWalking) {

listcollideremove.Add(idunit);

}

else {

if (true == unitWalking.IsUnitDie())

listcollideremove.Add(idunit);

else

listCollideCollect.Add(unitWalking);

}

}

 

//@ for safety elimination

foreach (int idunitremove in listcollideremove)

{

listCollider.Remove(idunitremove);

}

 

2. Shallow copy and destruct original data problem (얕은 복사와 원본 데이터 삭제 오류)

-exception

1.map save 시에 2번 이상 연속 호출 되는 경우 2번째 이후로 저장이 안됨.

2.내부 링크 참조된 list들이 clear()된 이후 접근 된 것.
-exception location

//@ Process : Save

void _SaveAll()

{

// MapSave

    Map.Release();

navigation_toCMapTemplate();

SaveBaseCore();

 

Map.Save();

} // void _SaveAll()

 

public void Release()

{

if (null != CoreList)

{

CoreList.Clear();        <-clear all lists as copy shallow

}

}

 

void _SaveBaseCore()

{

BaseInfo core = null;

foreach (CBASE__ arrBase in m_baseCoreCollector.m_listBase)

{

core = new BaseInfo();

core.Type = arrBase.getIdxType();

core.CellIndex = arrBase._listIdxTris;    <-list copy shallow

core.CoreTriPnt = arrBase._listv3Pnts;    <-list copy shallow

core.CoreTriPntSrc = arrBase._listv3PntsSrc;<-list copy shallow

core.CenterPos = arrBase._v3PositionCenter;

CoreList.Add(core);

}

}

 

-exception solution

1.Deep copy

void _SaveBaseCore()

{

BaseInfo core = null;

foreach (CBASE__ arrBase in m_baseCoreCollector.m_listBase)

{

core = new BaseInfo();

core.Type = arrBase.getIdxType();

core.CellIndex = new List<int>(arrBase._listIdxTris);

core.CoreTriPnt = new List<Vector3>(arrBase._listv3Pnts);

core.CoreTriPntSrc = new List<Vector3>(arrBase._listv3PntsSrc);

core.CenterPos = arrBase._v3PositionCenter;

CoreList. Add(core);

}

}

The Open-Closed Principle

1.OOP // Open-Closed Principle

객체 지향 디자인에 대한 일반적 지식들이 항상 옳을까?
All member variables should be private. 모든 멤버 변수들은 private 되어야만 한다.
Global variables should be avoided. 전역 변수는 피해야만 한다.
Using run time type identification is dangerous. RTTI는 위험하다.

모든 시스템은 그들의 생명 주기 동안 변하며, 오래 지속될 것을 예상하여 시스템 초기 개발에 염두 하여야 한다.

"SOFTWARE ENTITIES(CLASSES, MODULES, FUNCTIONS, ETC.)
SHOULD BE OPEN FOR EXTENSION, BUT CLOSED FOR MODIFICATION."

"소프트웨어 주요구성요소들은 확장에는 개방되어야 하지만, 변형에는 닫혀있어야 한다."

프로그램은 일반적으로 변형되기 쉽고, 외부 영향을 받으며 예측하기 어렵고, 재사용이 어렵다.
Open-Closed Principle 의 2가지 요소
1. Open for Extension 확장을 위한 개방
2. Closed for Modification 변동을 막는 패쇄

일반적으로 모듈의 동작을 확장하려면 모듈의 변화가 야기된다.

어떻게 두 가지 상반되는 요소를 풀수 있을까?
Abstraction is key
Abstraction 추상적 개념을 도입하면 구현이 가능하다.
Abstraction이란 Base 클래스를 추상화 하고 모든 상속 받는 클래스들에게 나타내어지는 경계선 없는 그룹이다.
Abstraction은 변형에 닫혀 있을 수 있고, 새로운 파생을 상속 하게 함으로 확장에는 열릴 수 있다.

OOD solution to Square/Circle problem. // open-closed principle

class Shape
{
public:
virtual void Draw() const = 0;
};

class Square : public Shape
{
public:
virtual void Draw() const;
};

class Circle : public Shape
{
public:
virtual void Draw() const;
};

void DrawAllShapes(Set<Shape*>& list)
{
for (Iterator<Shape*>i(list); i; i++)
(*i)->Draw();
}

2.Advanced Issue DrawAllShapes with Ordering Issue

DrawAllShapes with Ordering

Shape with ordering methods.

class Shape

{

public:

virtual void Draw() const = 0;

virtual bool Precedes(const Shape&) const = 0;

bool operator<(const Shape& s) {return Precedes(s);}

};


void DrawAllShapes(Set<Shape*>& list)

{

// copy elements into OrderedSet and then sort.

OrderedSet<Shape*> orderedList = list;

orderedList.Sort();

for (Iterator<Shape*> i(orderedList); i; i++)

(*i)->Draw();

}

Ordering a Circle

bool Circle::Precedes(const Shape& s) const

{

if (dynamic_cast<Square*>(s))

return true;

else

return false;

}

 

DrawAllShapes with Ordering - ocp

#include <typeinfo.h>

#include <string.h>

enum {false, true};

typedef int bool;

class Shape

{

public:

virtual void Draw() const = 0;

virtual bool Precedes(const Shape&) const;

bool operator<(const Shape& s) const

{

return Precedes(s);

}

private:

static char* typeOrderTable[];

};

 

char* Shape::typeOrderTable[] = { "Circle", "Square", 0 };

// This function searches a table for the class names.

// The table defines the order in which the

// shapes are to be drawn. Shapes that are not

// found always precede shapes that are found.

 

bool Shape::Precedes(const Shape& s) const

{

const char* thisType = typeid(*this).name();

const char* argType = typeid(s).name();

bool done = false;

int thisOrd = -1;

int argOrd = -1;

for (int i=0; !done; i++)

{

const char* tableEntry = typeOrderTable[i];

if (tableEntry != 0)

{

if (strcmp(tableEntry, thisType) == 0)

thisOrd = i;

if (strcmp(tableEntry, argType) == 0)

argOrd = i;

if ((argOrd > 0) && (thisOrd > 0))

done = true;

}

else // table entry == 0

{

done = true;

}

}

return thisOrd < argOrd;

}

 

3.Advanced Issue RTTI is Dangerous.


참고 1.

RTTI violating the open-closed principle.

class Shape {};

class Square : public Shape

{

private:

Point itsTopLeft;

double itsSide;

friend DrawSquare(Square*);

};

class Circle : public Shape

{

private:

Point itsCenter;

double itsRadius;

friend DrawCircle(Circle*);

};

void DrawAllShapes(Set<Shape*>& ss)

{

for (Iterator<Shape*>i(ss); i; i++)

{

Circle* c = dynamic_cast<Circle*>(*i); // violating open-closed principle

Square* s = dynamic_cast<Square*>(*i);

if (c)

DrawCircle(c);

else if (s)

DrawSquare(s);

}

}

 

The difference between these two is that the first, Listing 9, must be changed whenever a new type of Shape is derived.

 

Listing 10

RTTI that does not violate the open-closed Principle.

class Shape

{

public:

virtual void Draw() cont = 0;

};

class Square : public Shape

{

// as expected.

};

void DrawSquaresOnly(Set<Shape*>& ss)

{

for (Iterator<Shape*>i(ss); i; i++)

{

Square* s = dynamic_cast<Square*>(*i);

if (s)

s->Draw(); // not violating open-closed principle

}

}

 

if a use of RTTI does not violate the open-closed principle, it is safe.

+ Recent posts