6
코덱스 비주얼 연구실 511. 프로세스 워크샵 작성/이정표 실장.

코덱스 비주얼 연구실

Embed Size (px)

Citation preview

Page 1: 코덱스 비주얼 연구실

코덱스 비주얼 연구실

5월 11일. 프로세스 워크샵

작성/이정표 실장.

Page 2: 코덱스 비주얼 연구실

코덱스 비주얼 연구실

5월 11일. 프로세스 워크샵

• NVIDIA PhyX

– Wall Destruction.

– RAG Doll

• Shader.

– Dissolve FX Shader.

• Real Time Shadow for

Smart device.

Page 3: 코덱스 비주얼 연구실

코덱스 비주얼 연구실

5월 11일. 프로세스 워크

• Wall Destruction

– 목표 : 스마트폰 에서 Distruction 을 PhyX

사용.

– 포멧1 : 강체 오브젝트를 실시간으로

Distruction 알고리즘을 사용 하여 붕괘 시

키는 것이 아님.

– 포멧2 : Instantiate 로 데이터 교체 타입.

function Start() {

rigidbody.Sleep();

}

===========================

var health : int = 100;

yield WaitForFixedUpdate();

health -= Mathf.Round(chunkAngVelocity.magnitude * twistMultiplier);

조건문에 의한 제어.

if (health < 1) {}

: 강체 노드 그룹의 health 가 1 보다 작다면 노드 그룹은 참조 하는 프리

펩 개체 바로 호출 하여 spawned 한다.

NVIDIA PhyX

Wall Destruction.

RAG Doll

강체 노드 그룹 : GameObject

하위 강체 노드 집합 : GameObject

rigidbody.Sleep();

var health : int = 100;

충돌체 :

GameObject

/ Force

Instantiate : Prefabs

Behave Collision

Page 4: 코덱스 비주얼 연구실

코덱스 비주얼 연구실

5월 11일. 프로세스 워크

• RAG Doll

– 목표1 : 효율적인 RAGDOLL 셋팅과 결과물 도출.

– 목표2 : PhyX 의 고질적 RAGDOLL 후 2차 충돌체와의 지속적인 떨림 현상 제거.

– 포멧1 : 유니티 내장 RAG DOLL 설정자사용 하지 않음.

– 활용 모듈 : 얼티밋 레그돌 디벨롭 에디션

떨림 현상(대상: 팔이나 발 등…)이 심하게 발견 되는 레그돌 노드를 선별.

팔이나 발의 질량 값이 낮게 설정 되어 있는 이유가 선행 이유 이고 이 값을 높혀 주면서 다시 Drag 값을 함께 조정 하여 최종값으로 보정.

RigidBody 프로퍼티의 Drag 값을 높이면서 노드의 Mass 값을 함께 수정하여 적당 한 목표점(조합 값)을 찾는다.

통상적으로 Drag 값을 높이면 무중력 상태와 같은 현상이 발생 한다.

다시 말하면 외부 충돌체와 지속적인 충돌이 일어 나도 그 반응이 아주 느리기 때문에 시각적으로 떨림 현상이 완화 된 것 처럼 보인다.

이후 보강 목표 : Drag 값 보다는 코루틴과 .Spleep 함수의 활용.

NVIDIA PhyX

Wall Destruction.

RAG Doll

RAG DOLL NODE

일부 떨림 현상 (팔 , 머리 등)

MASS

DRAG

보정 값 적용.

시각적 안정화

Page 5: 코덱스 비주얼 연구실

코덱스 비주얼 연구실

5월 11일. 프로세스 워크

• Dissolve FX Shader

– 목표 : 모바일용 쉐이더가 아닌 복잡한 구조의 쉐이더를 최적화.

– 기존 쉐이더의 프로퍼티스.Shader "Dissolve/Dissolve_TexturCoords" {

Properties {

_Color ("Main Color", Color) = (1,1,1,1)

_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)

_Shininess ("Shininess", Range (0.03, 1)) = 0.078125

_Amount ("Amount", Range (0, 1)) = 0.5

_StartAmount("StartAmount", float) = 0.1

_Illuminate ("Illuminate", Range (0, 1)) = 0.5

_Tile("Tile", float) = 1

_DissColor ("DissColor", Color) = (1,1,1,1)

_ColorAnimate ("ColorAnimate", vector) = (1,1,1,1)

_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}

_BumpMap ("Normalmap", 2D) = "bump" {}

_DissolveSrc ("DissolveSrc", 2D) = "white" {}

_DissolveSrcBump ("DissolveSrcBump", 2D) = "white" {}

}

변경 후 프로퍼티스.

Properties {

_Color ("Main Color", Color) = (1,1,1,1)

_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)

_Shininess ("Shininess", Range (0.03, 1)) = 0.078125

_Amount ("Amount", Range (0, 1)) = 0.5

_StartAmount("StartAmount", float) = 0.1

_DissColor ("DissColor", Color) = (1,1,1,1)

_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}

_BumpMap ("Normalmap", 2D) = "bump" {}

_DissolveSrc ("DissolveSrc", 2D) = "white" {}

}

Shader.

Dissolve FX Shader.

fixed4 _Color;

half4 _DissColor;

half _Shininess;

half _Amount;

static half3 Color = float3(1,1,1);

half4 _ColorAnimate;

half _Illuminate;

half _Tile;

half _StartAmount;

fixed4 _Color;

half _Shininess;

half _Amount;

static half3 Color = float3(1,1,1);

fixed4 _ColorAnimate;

half _StartAmount;

fixed4 _DissColor;

불필요 한 변수 제거.

변수 타입 제 정의.(연산 정밀도 다운)

http://unitykoreawiki.com/index.php?n=KrMain.SL-

ShaderPerformance

Precision of computations (연산 결정)

Cg/HLSL에서 쉐이더를 쓸 때, 3 가지의 기본 숫자 타입이 있습니다: float, half

그리고 fixed (vector & 그들의 matrix 변형 뿐만 아니라, 예. half3와float4x4):

float: 고도로 정밀한 부동 소수점. 일반적으로32 비트, 보통의 프로그래밍 언

어에서 float 타입처럼.

half: 중간 정도로 정밀한 부동 소수점. 일반적으로16 비트, -60000 과 +60000

사이이고 3.3 정확도의 자릿수.

fixed: 낮은 정도로 정밀한 부동 소수점. 일반적으로11 비트, -2.0과 +2.0사이이

고1/256정확도.

OPENGL ES 에서는

Precision of Qualifier 로 highp , mediump , lowp 로 선언 할 수 있는

키워드 가 있음.

원본 프라그먼트 쉐이더 : 27 fps +-3

수정 후 프라그먼트 쉐이더 : 42 fps +-5

Page 6: 코덱스 비주얼 연구실

코덱스 비주얼 연구실

5월 11일. 프로세스 워크

• Real Time Shadow Shader

– 목표 : 모바일용 실시간 쉐도우 적용.

– 포멧 : 케릭터 라이트 쉐도우 활용.

Shader.Real Time Shadow Shader

void LateUpdate()

{

if (!shadowmap) {

shadowmap = new RenderTexture( textureSize,

textureSize, 8 );

shadowmap.isPowerOfTwo = true;

child.camera.targetTexture = shadowmap;

Projector proj =

(Projector)child.GetComponent(typeof(Projector));

proj.material.SetTexture("_ShadowTex",

shadowmap);

}

OrientToEncloseTarget();

RTT 텍스쳐 셈플링 처리. 셈플링 값을 낮게 설정 하여 코스트 낮춤.

프로젝터 카메라에 블러 컴퍼넌트 적용 하여 이미지 블러링.

CharacterShadow

셋팅 프로젝션 카메라.

연결 개체에 차일드 컴퍼넌트 연결

savedPixelLightCount

쉐이더 데이터 바

인딩.

RTT(Render To Texture) 수행.

쉐도우 렌더링.

Post Blur Process

Shader.(implementation

is not Yet)

// create a child camera/projector object

child = new GameObject("ChildCamProjector", typeof(Camera),

typeof(Projector), typeof(CharacterShadowHelper), typeof(BlurEffect));

child.camera.clearFlags = CameraClearFlags.Color;

child.camera.backgroundColor = Color.white;

child.camera.cullingMask = (1<<privateLayer);

child.camera.isOrthoGraphic = true;

Projector proj = (Projector)child.GetComponent(typeof(Projector));

proj.isOrthoGraphic = true;

proj.ignoreLayers = (1<<targetLayer);

proj.material = projectorMaterial;

proj.material.SetTexture("_FalloffTex", fadeoutTexture);

child.transform.parent = transform;

child.transform.localPosition = Vector3.zero;

child.transform.localRotation = Quaternion.identity;

BlurEffect BlurFX = child.GetComponent<BlurEffect>();

BlurFX.iterations = 1;

BlurFX.blurSpread = 0.3f;

BlurFX.blurShader = Shader.Find("Hidden/BlurEffectConeTap");