Podobne
- Strona startowa
- Van Roy Peter, Haridi Seif Concepts, Techniques, and Models of Computer Programming
- (ebook pdf) Teach Yourself Database Programming with Visual C in 21 days
- (ebook PDF) Schreiner Object oriented Programming With A
- Teach Yourself Database Programming with Visual C in 21 Da
- Program Swiatowej Polityki Zydo
- Programming Windows Games in Borland C
- Programowanie w Delphi i C Builder
- White Stephen Program (2)
- Nekritin Alex Binary Options. Strategies For Directional And Volatility Trading
- Szklarski Alfred 8 Tomek w Gran Chaco
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- beyblade.opx.pl
Cytat
Do celu tam się wysiada. Lec Stanisław Jerzy (pierw. de Tusch-Letz, 1909-1966)
A bogowie grają w kości i nie pytają wcale czy chcesz przyłączyć się do gry (. . . ) Bogowie kpią sobie z twojego poukładanego życia (. . . ) nie przejmują się zbytnio ani naszymi planami na przyszłość ani oczekiwaniami. Gdzieś we wszechświecie rzucają kości i przypadkiem wypada twoja kolej. I odtąd zwyciężyć lub przegrać - to tylko kwestia szczęścia. Borys Pasternak
Idąc po kurzych jajach nie podskakuj. Przysłowie szkockie
I Herkules nie poradzi przeciwko wielu.
Dialog półinteligentów równa się monologowi ćwierćinteligenta. Stanisław Jerzy Lec (pierw. de Tusch - Letz, 1909-1966)
[ Pobierz całość w formacie PDF ]
.* This performs the calculation we want:* u=n_x/2 + 0.5* v=-n_y/2 + 0.5*/matrix4 texMat;texMat.MakeIdent();texMat._11 = 0.5;texMat._41 = 0.5;texMat._22 = -0.5;texMat._42 = 0.5;pDevice->SetTransform( D3DTS_TEXTURE1, (D3DMATRIX*)&texMat );/*** Reflect lots of the diffuse light again*/sMaterial mat(0.f,color3(1.0f,1.0f,1.0f),color3(0.0f,0.0f,0.0f),color3(0.0f,0.0f,0.0f) );pDevice->SetMaterial(&mat);// Turn on that extra light we used in the glow pass too.pDevice->LightEnable(1, TRUE);/***set up add style blending609 */pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,m_earthVerts.size() - 2,&m_earthVerts[0],sizeof( sMTVertex ) );/*** Fix up all of our esoteric states*/pDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_DISABLE);pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE );pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0 );pDevice->LightEnable(1, FALSE);}Pass 5: Gloss MapThe fifth pass, which performs gloss mapping, uses two textures.The first texture is the gloss map, andit appears in Figure 10.37.To save texture space, this image hides in the alpha component of the glowmap texture.This is why I used the source alpha in the blending step: It essentially performs amodulation for you (the alpha, holding the gloss value, is modulated with the specular value).610Figure 10.37: The gloss map textureTo create the specular value, I used spherical environment mapping with a texture with a bright spot inthe upper-left corner.The original version of this application just used the interpolated specular value.The result of the operation is that you get really shiny looking water, especially at coastal regions, whilethe land doesn't reflect specularities at all.The image showing this appears in Figure 10.38.Figure 10.38: The base pass plus the gloss passThe code to draw the gloss pass appears in Listing 10.17.Listing 10.17: Code to draw the gloss passvoid cMultiTexApp::DoGlossPass()611 {LPDIRECT3DDEVICE9 pDevice = Graphics()->GetDevice();/*** The first color pass is just the diffuse color.* the first alpha pass uses the gloss map texture.* This will be modulated with the* final color before being alpha blended onto the* frame buffer.*/pDevice->SetTexture( 0, m_pTextures[1]->GetTexture() );SetColorStage(0,D3DTA_DIFFUSE,D3DTA_CURRENT,D3DTOP_SELECTARG1 );SetAlphaStage(0,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_SELECTARG1 );/*** The second pass is the specular map.It isn't even* close to being correct, but it looks good enough.*/pDevice->SetTexture( 1, m_pTextures[6]->GetTexture() );SetColorStage(1,D3DTA_TEXTURE,D3DTA_CURRENT,612 D3DTOP_SELECTARG1 );/*** Set up texture transformations.*/pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACENORMAL );pDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);/*** Set up the environment mapping matrix.* This performs the calculation we want:* u=n_x/2 + 0.5* v=-n_y/2 + 0.5*/matrix4 texMat;texMat.MakeIdent();texMat._11 = 0.5;texMat._41 = 0.5;texMat._22 = -0.5;texMat._42 = 0.5;pDevice->SetTransform( D3DTS_TEXTURE1, (D3DMATRIX*)&texMat );/*** Reflect lots of the diffuse light again*/sMaterial mat(0.f,color3(1.0f,1.0f,1.0f),color3(0.0f,0.0f,0.0f),color3(0.0f,0.0f,0.0f) );613 pDevice->SetMaterial(&mat);// Turn on that extra light we used in the glow pass too.pDevice->LightEnable(1, TRUE);/*** set up add style blending*/pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,m_earthVerts.size() - 2,&m_earthVerts[0],sizeof( sMTVertex ) );/*** Fix up all of our esoteric states*/pDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_DISABLE);pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE );pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0 );pDevice->LightEnable(1, FALSE);}Pass 6: Cloud Map614The final pass tries to simulate a cloud cover on the earth.The cloud map hides in the alpha componentof the base texture.It's modulated with the diffuse color using alpha blending and combined with thebackground using (SRCALPHA: INVSRCALPHA) blending.The cloud map appears in Figure 10.39.Figure 10.39: The cloud mapThe result of the pass when applied to the base map appears in Figure 10.40.Figure 10.40: Base pass plus cloud passThe code to draw the cloud pass appears in Listing 10.18.Listing 10.18: Code to draw the cloud passvoid cMultiTexApp::DoCloudPass(){LPDIRECT3DDEVICE9 pDevice = Graphics()->GetDevice();pDevice->SetTexture( 0, m_pTextures[0]->GetTexture() );615 SetColorStage(0,D3DTA_TEXTURE,D3DTA_DIFFUSE,D3DTOP_SELECTARG2 );SetAlphaStage(0,D3DTA_TEXTURE,D3DTA_DIFFUSE,D3DTOP_SELECTARG1 );/*** Reflect lots of the diffuse light again*/sMaterial mat(0.f,color3(1.0f,1.0f,1.0f),color3(0.0f,0.0f,0.0f),color3(0.3f,0.3f,0
[ Pobierz całość w formacie PDF ]