SlideShare a Scribd company logo
1 of 9
RAIN in Karon2.0 김정희 최유표
Simple Flow VertexBuffer미리 생성 RainAdvance.fx Texture(128*128, ARGB16)에 위치 기록 RainShade.fx 1에서 만들어진 Buffer가 VS In으로 들어옴 2에서 만들어진 Texture 접근하여 빌보드 DeferredShade.fx 섭동과 Splash
VertexBuffer VertexFormat Short : Texture Index (0000, 1111, 2222, …) Short : Vertex Index (0123, 0123, …) # of Particle = 128 * 128 = 16384 # of Vertices = Particle * 4 = 65536 # of Indices = Particle * 6 = 98304
RainAdvance.fx float4 RainPS( OUTPUT_VS In) : COLOR { float4 position = tex2D(Position_Sampler, In.tex); // 비의 Position float3 seed = tex2D(Seed_Brightness_Sampler, In.tex).xyz; // 비가 새로 내리기 시작하는 위치 float3 speed = tex2D(Speed_Type_Sampler, In.tex).xyz; // 비가 내리는 속도 float3 move = Wind; move.y -= 1; // 아래 방향으로 내리도록 float3 totalMove = (speed + move * 20) * elapsedTime; position.xyz += totalMove; if (position.y <=  eyePos.y - 40 ) { float x = seed.x + eyePos.x; float z = seed.z + eyePos.z; float y = seed.y + eyePos.y; position.xyz = float3(x,y,z); } return float4(position.xyz, 1); }
RainShade.fx OUTPUT_VS RainVs(INPUT_VS In) { int texIndex = In.index[0]; int vertIndex = In.index[1]; int y =texIndex/128; int x = texIndex - y*128; float4 positionUV = float4(float2(x,y)/128.0f, 0, 0); float4 position = tex2Dlod(Position_Sampler, positionUV); float3 speed = tex2Dlod(Speed_Type_Sampler, positionUV).xyz; float3 move = Wind; move.y -= 1; float3 totalMove = (speed + move * 20) * elapsedTime; float3 pos[4]; GenRainSpriteVertices(position.xyz, totalMove, relativeEyePos, pos); // 빌보드 만드는 함수 OUTPUT_VS output; output.pos = mul(float4(pos[vertIndex], 1.0f), WorldViewProjMatrix); output.tex = g_texcoords[vertIndex]; // (0, 0), (0, 1), (1, 0), (1, 1) return output; }
DeferredShade.fx float4 DeferredShadePS( OUTPUT_VS In, uniform bool usedSSAO, uniform bool usedSpecular,  uniform bool usedShadow, uniform bool usedRain) : COLOR { // 비 float3 splashDiffuse = 0; if (usedRain) { 	float4 baseGeometry = tex2D(MRTSampler1, In.tex); 	float3 baseViewNormal = baseGeometry.xyz; 	float baseDepth = baseGeometry.a; // ViewZ 	float4 baseViewPosition = GetViewPosition4(In.tex, baseDepth, InvProjectionM11M22); 	float2 positionXZ = float2(dot(baseViewPosition, transposeInvViewMat[0]),  					dot(baseViewPosition, transposeInvViewMat[2])); 	float normalY = dot(baseViewNormal, transposeInvViewMat[1]); 	float wetSurf = saturate(normalY - baseDepth * 0.05f); // 기울기, 멀어지면 감쇠 	In.tex += wetSurf * tex3D(rainSampler, float3(positionXZ*0.5f, g_timeCycle*2)).r * 0.05f; // 섭동 	splashDiffuse = wetSurf * tex3D(rainSampler, float3(positionXZ, g_timeCycle*2)); // Splash 	} … 생략…
Performance ,[object Object],vs Instancing 98FPS  vs Pre-made104FPS ,[object Object],구현 사항은 콘솔창에“option rain true/false로 확인 가능”
Future Work CenterMap이 바뀔 때 건물 안에서도 비가 옴 경사면에서의 Splash 물체에 흐르는 빗물 내리는 빗물과 물방울 일치(?)
?

More Related Content

What's hot

Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objectsyong gyun im
 
Unity Surface Shader for Artist 02
Unity Surface Shader for Artist 02Unity Surface Shader for Artist 02
Unity Surface Shader for Artist 02SangYun Yi
 
Unity Surface Shader for Artist 03
Unity Surface Shader for Artist 03Unity Surface Shader for Artist 03
Unity Surface Shader for Artist 03SangYun Yi
 
1.4.4 입력과 출력
1.4.4 입력과 출력1.4.4 입력과 출력
1.4.4 입력과 출력Park Min Wook
 
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05Seok-joon Yun
 
밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05HyeonSeok Choi
 
Doing mathwithpython.ch02
Doing mathwithpython.ch02Doing mathwithpython.ch02
Doing mathwithpython.ch02Seok-joon Yun
 
[Swift] Higher order function
[Swift] Higher order function[Swift] Higher order function
[Swift] Higher order functionBill Kim
 
딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04HyeonSeok Choi
 
[ES6] 5. Destructuring
[ES6] 5. Destructuring[ES6] 5. Destructuring
[ES6] 5. DestructuringHan JaeYeab
 
Convolutional neural networks
Convolutional neural networksConvolutional neural networks
Convolutional neural networksHyunjinBae3
 
밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05HyeonSeok Choi
 
Effective c++ item27
Effective c++ item27Effective c++ item27
Effective c++ item27진화 손
 
[1106 조진현] if you( batch rendering )
[1106 조진현] if you( batch rendering )[1106 조진현] if you( batch rendering )
[1106 조진현] if you( batch rendering )진현 조
 

What's hot (17)

Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objects
 
Unity Surface Shader for Artist 02
Unity Surface Shader for Artist 02Unity Surface Shader for Artist 02
Unity Surface Shader for Artist 02
 
[데브루키] FOG
[데브루키] FOG[데브루키] FOG
[데브루키] FOG
 
Unity Surface Shader for Artist 03
Unity Surface Shader for Artist 03Unity Surface Shader for Artist 03
Unity Surface Shader for Artist 03
 
1.4.4 입력과 출력
1.4.4 입력과 출력1.4.4 입력과 출력
1.4.4 입력과 출력
 
D2 Havok
D2 HavokD2 Havok
D2 Havok
 
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05
 
밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05
 
Doing mathwithpython.ch02
Doing mathwithpython.ch02Doing mathwithpython.ch02
Doing mathwithpython.ch02
 
Week9 quicksort
Week9 quicksortWeek9 quicksort
Week9 quicksort
 
[Swift] Higher order function
[Swift] Higher order function[Swift] Higher order function
[Swift] Higher order function
 
딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04
 
[ES6] 5. Destructuring
[ES6] 5. Destructuring[ES6] 5. Destructuring
[ES6] 5. Destructuring
 
Convolutional neural networks
Convolutional neural networksConvolutional neural networks
Convolutional neural networks
 
밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05
 
Effective c++ item27
Effective c++ item27Effective c++ item27
Effective c++ item27
 
[1106 조진현] if you( batch rendering )
[1106 조진현] if you( batch rendering )[1106 조진현] if you( batch rendering )
[1106 조진현] if you( batch rendering )
 

Similar to D2 Rain (2/2)

Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)fefe7270
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스noerror
 
Bs webgl소모임002
Bs webgl소모임002Bs webgl소모임002
Bs webgl소모임002Seonki Paik
 
Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)fefe7270
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술henjeon
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayYEONG-CHEON YOU
 
Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)민웅 이
 
Unity Surface Shader for Artist 04
Unity Surface Shader for Artist 04Unity Surface Shader for Artist 04
Unity Surface Shader for Artist 04SangYun Yi
 
[0312 조진현] good bye dx9
[0312 조진현] good bye dx9[0312 조진현] good bye dx9
[0312 조진현] good bye dx9진현 조
 
Blockchain 3rd smart contract programming
Blockchain 3rd smart contract programmingBlockchain 3rd smart contract programming
Blockchain 3rd smart contract programmingihpark92
 
Reflective Shadow Maps
Reflective Shadow MapsReflective Shadow Maps
Reflective Shadow MapsBongseok Cho
 
Hello Swift 4/5 : Closure and Enum
Hello Swift 4/5 : Closure and EnumHello Swift 4/5 : Closure and Enum
Hello Swift 4/5 : Closure and EnumCody Yun
 

Similar to D2 Rain (2/2) (12)

Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스
 
Bs webgl소모임002
Bs webgl소모임002Bs webgl소모임002
Bs webgl소모임002
 
Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture Array
 
Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)
 
Unity Surface Shader for Artist 04
Unity Surface Shader for Artist 04Unity Surface Shader for Artist 04
Unity Surface Shader for Artist 04
 
[0312 조진현] good bye dx9
[0312 조진현] good bye dx9[0312 조진현] good bye dx9
[0312 조진현] good bye dx9
 
Blockchain 3rd smart contract programming
Blockchain 3rd smart contract programmingBlockchain 3rd smart contract programming
Blockchain 3rd smart contract programming
 
Reflective Shadow Maps
Reflective Shadow MapsReflective Shadow Maps
Reflective Shadow Maps
 
Hello Swift 4/5 : Closure and Enum
Hello Swift 4/5 : Closure and EnumHello Swift 4/5 : Closure and Enum
Hello Swift 4/5 : Closure and Enum
 

D2 Rain (2/2)

  • 1. RAIN in Karon2.0 김정희 최유표
  • 2. Simple Flow VertexBuffer미리 생성 RainAdvance.fx Texture(128*128, ARGB16)에 위치 기록 RainShade.fx 1에서 만들어진 Buffer가 VS In으로 들어옴 2에서 만들어진 Texture 접근하여 빌보드 DeferredShade.fx 섭동과 Splash
  • 3. VertexBuffer VertexFormat Short : Texture Index (0000, 1111, 2222, …) Short : Vertex Index (0123, 0123, …) # of Particle = 128 * 128 = 16384 # of Vertices = Particle * 4 = 65536 # of Indices = Particle * 6 = 98304
  • 4. RainAdvance.fx float4 RainPS( OUTPUT_VS In) : COLOR { float4 position = tex2D(Position_Sampler, In.tex); // 비의 Position float3 seed = tex2D(Seed_Brightness_Sampler, In.tex).xyz; // 비가 새로 내리기 시작하는 위치 float3 speed = tex2D(Speed_Type_Sampler, In.tex).xyz; // 비가 내리는 속도 float3 move = Wind; move.y -= 1; // 아래 방향으로 내리도록 float3 totalMove = (speed + move * 20) * elapsedTime; position.xyz += totalMove; if (position.y <= eyePos.y - 40 ) { float x = seed.x + eyePos.x; float z = seed.z + eyePos.z; float y = seed.y + eyePos.y; position.xyz = float3(x,y,z); } return float4(position.xyz, 1); }
  • 5. RainShade.fx OUTPUT_VS RainVs(INPUT_VS In) { int texIndex = In.index[0]; int vertIndex = In.index[1]; int y =texIndex/128; int x = texIndex - y*128; float4 positionUV = float4(float2(x,y)/128.0f, 0, 0); float4 position = tex2Dlod(Position_Sampler, positionUV); float3 speed = tex2Dlod(Speed_Type_Sampler, positionUV).xyz; float3 move = Wind; move.y -= 1; float3 totalMove = (speed + move * 20) * elapsedTime; float3 pos[4]; GenRainSpriteVertices(position.xyz, totalMove, relativeEyePos, pos); // 빌보드 만드는 함수 OUTPUT_VS output; output.pos = mul(float4(pos[vertIndex], 1.0f), WorldViewProjMatrix); output.tex = g_texcoords[vertIndex]; // (0, 0), (0, 1), (1, 0), (1, 1) return output; }
  • 6. DeferredShade.fx float4 DeferredShadePS( OUTPUT_VS In, uniform bool usedSSAO, uniform bool usedSpecular, uniform bool usedShadow, uniform bool usedRain) : COLOR { // 비 float3 splashDiffuse = 0; if (usedRain) { float4 baseGeometry = tex2D(MRTSampler1, In.tex); float3 baseViewNormal = baseGeometry.xyz; float baseDepth = baseGeometry.a; // ViewZ float4 baseViewPosition = GetViewPosition4(In.tex, baseDepth, InvProjectionM11M22); float2 positionXZ = float2(dot(baseViewPosition, transposeInvViewMat[0]), dot(baseViewPosition, transposeInvViewMat[2])); float normalY = dot(baseViewNormal, transposeInvViewMat[1]); float wetSurf = saturate(normalY - baseDepth * 0.05f); // 기울기, 멀어지면 감쇠 In.tex += wetSurf * tex3D(rainSampler, float3(positionXZ*0.5f, g_timeCycle*2)).r * 0.05f; // 섭동 splashDiffuse = wetSurf * tex3D(rainSampler, float3(positionXZ, g_timeCycle*2)); // Splash } … 생략…
  • 7.
  • 8. Future Work CenterMap이 바뀔 때 건물 안에서도 비가 옴 경사면에서의 Splash 물체에 흐르는 빗물 내리는 빗물과 물방울 일치(?)
  • 9. ?