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; }