구름 애니메이션.....

2D, 3D, 다각형, 픽셀 등 게임의 그래픽 프로그래밍에 관한 포럼입니다.

Moderator: 류광

Locked
비회원

구름 애니메이션.....

Post by 비회원 »

구름이 흘러가는 효과를 구현 할려고 합니다.(실시간 3D 지형 엔진...책을 보고 있습니다.)
스카이 돔(x파일)과 구름 이미지, 그리고 simple_skydome.fx를 로드 해서 구현 하는거 같은데...

나름대로 열심히 따라 해봤지만.......구름이 흘러 가는 비슷한 느낌은 나지만...
기본적인 매핑이 안됩니다.(돔의 절반의 절반들은 좌우 대칭만 바껴서 매핑되고 나머지 절반은 완전 한색으로만 매핑이 됩니다.)

너무 기초적인 질문이라고 그냥 넘어가지 마시고 거지와 같은 마음으로 선배님들의 지식을 구걸 합니다T_T






simple_skydome.fx의 코드는 이렇습니다.

// transformations
float4x4 mWorldViewProj: WORLDVIEWPROJECTION;

// the cube map
texture tex0 : TEXTURE;
texture tex1 : TEXTURE;

float4 uv_data: uvScaleOffset = {1.0f,1.0f,0.0f,0.0f};

struct VS_INPUT
{
float4 Pos : POSITION;
};

struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 vTex0: TEXCOORD0;
float2 vTex1: TEXCOORD1;
float2 vTex2: TEXCOORD2;
};

VS_OUTPUT VS(const VS_INPUT v)
{
VS_OUTPUT Out = (VS_OUTPUT)0;

// transform the vert
float4 pos = mul(v.Pos, mWorldViewProj);

// output with z equal to w
// to force to farthest possible
// z value into the depth buffer
Out.Pos = pos.xyzw;

// a slight swizzle is nessesary
// along with normaliztion
// to convert the verts to
// 3D texture coords
Out.vTex0.xyz = normalize(v.Pos.yzx);
Out.vTex0.w=1.0f;

Out.vTex1 = v.Pos.xy + uv_data.zw;
Out.vTex2 = (v.Pos.xy + uv_data.xy) *3.7f;

return Out;
}

// cube map coordinates should not wrap
sampler LinearSamp0 = sampler_state
{
texture = <tex0>;
AddressU = clamp;
AddressV = clamp;
AddressW = clamp;
MIPFILTER = LINEAR;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};

sampler LinearSamp1 = sampler_state
{
texture = <tex1>;
AddressU = wrap;
AddressV = wrap;
AddressW = wrap;
MIPFILTER = LINEAR;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};

float4 CloudShader(VS_OUTPUT In) : COLOR
{
// sample the cube map and clouds
float4 background= tex3D(LinearSamp0, In.vTex0 );
float4 cloud0= tex2D(LinearSamp1, In.vTex1 );
float4 cloud1= tex2D(LinearSamp1, In.vTex2 );

// modulate the clouds together and
// mask with the background alpha
float4 cloud_layer = cloud1.a * background.a;

// sum and return the results
return background + cloud_layer;
}

technique BasicCubeMap
{
pass P0
{
//FILLMODE = WIREFRAME;
FILLMODE = SOLID;

// no culling
CULLMODE = NONE;

ZENABLE = TRUE;
ZWRITEENABLE = TRUE;
ZFUNC = always;

// also clear any stencil
StencilEnable = true;
StencilFunc = always;
StencilPass = replace;
StencilRef = 0;

AlphaBlendEnable = false;
AlphaTestEnable = false;

// shaders
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_1_1 CloudShader();
}
}

/////////////////////Rander()///////////////////////////////
g_pd3dDevice->SetFVF(D3DFVF_XYZ|D3DFVF_TEX1);

m = SkyWorldMat * CameraMat * Proj;
m = SkyScale * m;

m_pEffect->SetMatrix(m_hMatWVP, &m);

Mesh->DrawSubset(0);

m_pEffect->End();
Locked