青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

高級紋理映射技術(1)

紋理映射在三維圖形程序設計中具有非常重要的作用,三維場景中的許多特殊效果都是通過紋理映射來實現的。例如通過紋理映射模擬復雜的光照效果,物體表面對周圍環境的反射效果等。

 

多層紋理映射

Direct3D最多支持8層紋理,也就是說,在一個三維物體的表面可以同時擁有1~8張不同的紋理貼圖。Direct3D能夠在一個渲染過程中把這些紋理顏色依次混合,渲染到同一個物體的表面。每一個紋理層對應0~7的索引序號,多層紋理映射能夠模擬更為真實的三維世界。例如,要顯示具有周圍景物倒影的光滑大理石地板,可以把大理石地板貼圖設置為紋理層0,把具有周圍景物倒影的貼圖設置為紋理層1,然后通過設置Direct3D多層紋理混合操作,把紋理層0和紋理層1相混合,這時繪制出的三維物體就同時具有大理石地板和景物倒影的紋理顏色。利用Direct3D多達8層的紋理混合,可以在圖形顯示系統中顯示豐富多彩的圖像。Direct3D多層紋理混合過程如下圖所示:

從上圖可以看出8層紋理是逐層混合然后輸出的,也就是說,最對需要8個階段完成紋理映射,而且每一階段都是獨立進行的,針對每一階段都需要設置相應的顏色和alpha混合方法。所以一個紋理層就相當于一個紋理階段,多層紋理映射有時也稱為多階段紋理混合。其中,是否應用紋理層0~7,即是否進行0~7紋理階段的操作,可由應用程序指定,但它們的選擇必須是順序的。也就是說,在沒有使用第n層的情況下,第n+1層不能使用。

默認情況下,第一個紋理階段操作(階段0)的默認操作是D3DTOP_MODULATE,其他紋理操作階段的默認操作是D3DTOP_DISABLE。即默認情況下Direct3D使用單層紋理映射繪制圖形,除紋理層0外,紋理層1~7都是禁用的。

在使用多層紋理映射之前,應先查詢當前設備是否支持紋理混合,以及最多能支持幾層紋理混合:

// check whether device support multi textures render
if(pCaps->MaxTextureBlendStages <= 1)
    return false;

MaxTextureBlendStages
Maximum number of texture-blending stages supported in the fixed function pipeline. This value is the number of blenders available. In the programmable pixel pipeline, this corresponds to the number of unique texture registers used by pixel shader instructions.

為了將多層紋理映射到物體表面,需要為每層紋理指定使用的紋理坐標,各層紋理可以使用相同的紋理坐標,也可以使用不同的紋理坐標。紋理坐標包含在頂點數據中,如果需要使用不同的紋理坐標,那么在頂點數據中就需要包括多組紋理坐標,然后通過索引為每層紋理指定使用哪組紋理坐標:

pd3dDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
pd3dDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);

D3DTSS_TEXCOORDINDEX
Index of the texture coordinate set to use with this texture stage. You can specify up to eight sets of texture coordinates per vertex. If a vertex does not include a set of texture coordinates at the specified index, the system defaults to the u and v coordinates (0,0).

When rendering using vertex shaders, each stage's texture coordinate index must be set to its default value. The default index for each stage is equal to the stage index. Set this state to the zero-based index of the coordinate set for each vertex that this texture stage uses.

Additionally, applications can include, as logical OR with the index being set, one of the constants to request that Direct3D automatically generate the input texture coordinates for a texture transformation. For a list of all the constants, see D3DTSS_TCI.

With the exception of D3DTSS_TCI_PASSTHRU, which resolves to zero, if any of the following values is included with the index being set, the system uses the index strictly to determine texture wrapping mode. These flags are most useful when performing environment mapping.

這里指定了兩組紋理坐標:

struct sCustomVertex
{
float x, y, z;
DWORD color;
float u0, v0;
float u1, v1;
};
#define D3DFVF_CUSTOM_VERTEX	(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2)
sCustomVertex vertices[] = 	
{
{ -3.0f, -3.0f, 0.0f, 0xffffffff, 0.0f, 1.0f, 0.0f, 1.0f},
{ -3.0f, 3.0f, 0.0f, 0xffffffff, 0.0f, 0.0f, 0.0f, 0.0f},
{ 3.0f, -3.0f, 0.0f, 0xffffffff, 1.0f, 1.0f, 1.0f, 1.0f},
{ 3.0f, 3.0f, 0.0f, 0xffffffff, 1.0f, 0.0f, 1.0f, 0.0f}
};

這里指定的兩組紋理坐標值完全相同,你可以改變其中任何一組坐標,使兩層紋理使用不同的紋理坐標。

設置紋理層混合方法的代碼如下:

// set color blend operation and texture coordinate index for texture stage 0
pd3dDevice->SetTexture(0, g_texture_0);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
pd3dDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

// set color blend operation and texture coordinate index for texture stage 1
pd3dDevice->SetTexture(1, g_texture_1);
pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD);
pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
pd3dDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
pd3dDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
pd3dDevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

這里先將物體的漫反射顏色和紋理層0的紋理顏色相乘,得到的結果再與紋理層1的紋理顏色相加后輸出。

該示例將物體紋理和光照紋理相混合后輸出:

物體紋理

光照紋理

運行效果圖如下:

我們可以修改頂點的紋理坐標為:

sCustomVertex vertices[] = 	
{
{ -3.0f, -3.0f, 0.0f, 0xffffffff, 0.0f, 1.0f, 1.0f, 0.0f},
{ -3.0f, 3.0f, 0.0f, 0xffffffff, 0.0f, 0.0f, 1.0f, 1.0f},
{ 3.0f, -3.0f, 0.0f, 0xffffffff, 1.0f, 1.0f, 0.0f, 0.0f},
{ 3.0f, 3.0f, 0.0f, 0xffffffff, 1.0f, 0.0f, 0.0f, 1.0f}
};

這時的運行效果圖如下:



主程序:

#include "dxstdafx.h"
#include 
"resource.h"

#pragma warning(disable : 
4127)

#define IDC_TOGGLE_FULLSCREEN        1
#define IDC_TOGGLE_REF                2
#define IDC_CHANGE_DEVICE            3

#define release_com(p)    do { if(p) { (p)->Release(); (p) = NULL; } } while(0)

struct sCustomVertex
{
    
float x, y, z;
    DWORD color;
    
float u0, v0;
    
float u1, v1;
};

#define D3DFVF_CUSTOM_VERTEX    (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2)

ID3DXFont
*        g_font;
ID3DXSprite
*    g_text_sprite;
bool            g_show_help = true;

CDXUTDialogResourceManager    g_dlg_resource_manager;
CD3DSettingsDlg                g_settings_dlg;
CDXUTDialog                    g_button_dlg;

IDirect3DVertexBuffer9
*        g_vertex_buffer;
IDirect3DTexture9
*            g_texture_0;
IDirect3DTexture9
*            g_texture_1;

//--------------------------------------------------------------------------------------
// Rejects any devices that aren't acceptable by returning false
//--------------------------------------------------------------------------------------
bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, 
                                  D3DFORMAT BackBufferFormat, 
bool bWindowed, void* pUserContext )
{
    
// Typically want to skip backbuffer formats that don't support alpha blending

    IDirect3D9
* pD3D = DXUTGetD3DObject(); 

    
if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, 
                    D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat ) ) )
        
return false;

    
// check whether device support multi textures render
    if(pCaps->MaxTextureBlendStages <= 1)
        
return false;

    
return true;
}


//--------------------------------------------------------------------------------------
// Before a device is created, modify the device settings as needed.
//--------------------------------------------------------------------------------------
bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext )
{
    
// If video card does not support hardware vertex processing, then uses sofaware vertex processing.
    if((pCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0)
        pDeviceSettings
->BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

    
static bool is_first_time = true;

    
if(is_first_time)
    {
        is_first_time 
= false;

        
// if using reference device, then pop a warning message box.
        if(pDeviceSettings->DeviceType == D3DDEVTYPE_REF)
            DXUTDisplaySwitchingToREFWarning();
    }

    
return true;
}


//--------------------------------------------------------------------------------------
// Create any D3DPOOL_MANAGED resources here 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, 
                                 
const D3DSURFACE_DESC* pBackBufferSurfaceDesc, 
                                 
void* pUserContext )
{
    HRESULT    hr;

    V_RETURN(g_dlg_resource_manager.OnCreateDevice(pd3dDevice));
    V_RETURN(g_settings_dlg.OnCreateDevice(pd3dDevice));

    D3DXCreateFont(pd3dDevice, 
180, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
                   DEFAULT_PITCH 
| FF_DONTCARE, L"Arial"&g_font);

    V_RETURN(D3DXCreateTextureFromFile(pd3dDevice, L
"Wall.bmp",  &g_texture_0));
    V_RETURN(D3DXCreateTextureFromFile(pd3dDevice, L
"light.jpg"&g_texture_1));

    
// create vertex buffer and fill data

    sCustomVertex vertices[] 
=     
    {
        { 
-3.0f-3.0f,  0.0f,  0xffffffff0.0f1.0f0.0f1.0f},
        { 
-3.0f,  3.0f,  0.0f,  0xffffffff0.0f0.0f0.0f0.0f},
        {  
3.0f-3.0f,  0.0f,  0xffffffff1.0f1.0f1.0f1.0f},
        {  
3.0f,  3.0f,  0.0f,  0xffffffff1.0f0.0f1.0f0.0f}
        
        
/*
        { -3.0f, -3.0f,  0.0f,  0xffffffff, 0.0f, 1.0f, 1.0f, 0.0f},
        { -3.0f,  3.0f,  0.0f,  0xffffffff, 0.0f, 0.0f, 1.0f, 1.0f},
        {  3.0f, -3.0f,  0.0f,  0xffffffff, 1.0f, 1.0f, 0.0f, 0.0f},
        {  3.0f,  3.0f,  0.0f,  0xffffffff, 1.0f, 0.0f, 0.0f, 1.0f}
        
*/
    };

    pd3dDevice
->CreateVertexBuffer(sizeof(vertices), 0, D3DFVF_CUSTOM_VERTEX, D3DPOOL_MANAGED, &g_vertex_buffer, NULL);

    
void* ptr;
    g_vertex_buffer
->Lock(0sizeof(vertices), (void**)&ptr, 0);
    memcpy(ptr, vertices, 
sizeof(vertices));
    g_vertex_buffer
->Unlock();

    
return S_OK;
}


//--------------------------------------------------------------------------------------
// Create any D3DPOOL_DEFAULT resources here 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, 
                                
const D3DSURFACE_DESC* pBackBufferSurfaceDesc, 
                                
void* pUserContext )
{
    HRESULT hr;

    V_RETURN(g_dlg_resource_manager.OnResetDevice());
    V_RETURN(g_settings_dlg.OnResetDevice());
    V_RETURN(g_font
->OnResetDevice());
    V_RETURN(D3DXCreateSprite(pd3dDevice, 
&g_text_sprite));

    
// set dialog position and size

    g_button_dlg.SetLocation(pBackBufferSurfaceDesc
->Width - 1700);
    g_button_dlg.SetSize(
170170);

    
// setup view matrix

    D3DXMATRIX mat_view;
    D3DXVECTOR3 eye(
0.0f0.0f-8.0f);
    D3DXVECTOR3  at(
0.0f0.0f,  0.0f);
    D3DXVECTOR3  up(
0.0f1.0f,  0.0f);

    D3DXMatrixLookAtLH(
&mat_view, &eye, &at, &up);
    pd3dDevice
->SetTransform(D3DTS_VIEW, &mat_view);

    
// set projection matrix
    D3DXMATRIX mat_proj;
    
float aspect = (float)pBackBufferSurfaceDesc->Width / pBackBufferSurfaceDesc->Height;
    D3DXMatrixPerspectiveFovLH(
&mat_proj, D3DX_PI/4, aspect, 1.0f100.0f);
    pd3dDevice
->SetTransform(D3DTS_PROJECTION, &mat_proj);

    
// set color blend operation and texture coordinate index for texture stage 0
    pd3dDevice->SetTexture(0, g_texture_0);
    pd3dDevice
->SetTextureStageState(0, D3DTSS_COLOROP,        D3DTOP_MODULATE);
    pd3dDevice
->SetTextureStageState(0, D3DTSS_COLORARG1,    D3DTA_TEXTURE);
    pd3dDevice
->SetTextureStageState(0, D3DTSS_COLORARG2,    D3DTA_DIFFUSE);
    pd3dDevice
->SetTextureStageState(0, D3DTSS_ALPHAOP,        D3DTOP_DISABLE);
    pd3dDevice
->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX,    0);
    pd3dDevice
->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
    pd3dDevice
->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

    
// set color blend operation and texture coordinate index for texture stage 1
    pd3dDevice->SetTexture(1, g_texture_1);
    pd3dDevice
->SetTextureStageState(1, D3DTSS_COLOROP,        D3DTOP_ADD);
    pd3dDevice
->SetTextureStageState(1, D3DTSS_COLORARG1,    D3DTA_TEXTURE);
    pd3dDevice
->SetTextureStageState(1, D3DTSS_COLORARG2,    D3DTA_CURRENT);
    pd3dDevice
->SetTextureStageState(1, D3DTSS_ALPHAOP,        D3DTOP_DISABLE);
    pd3dDevice
->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX,    1);
    pd3dDevice
->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
    pd3dDevice
->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

    pd3dDevice
->SetRenderState(D3DRS_LIGHTING, FALSE);

    
return S_OK;
}

//--------------------------------------------------------------------------------------
// Release resources created in the OnResetDevice callback here 
//--------------------------------------------------------------------------------------
void CALLBACK OnLostDevice( void* pUserContext )
{
    g_dlg_resource_manager.OnLostDevice();
    g_settings_dlg.OnLostDevice();
    g_font
->OnLostDevice();

    release_com(g_text_sprite);
}


//--------------------------------------------------------------------------------------
// Release resources created in the OnCreateDevice callback here
//--------------------------------------------------------------------------------------
void CALLBACK OnDestroyDevice( void* pUserContext )
{
    g_dlg_resource_manager.OnDestroyDevice();
    g_settings_dlg.OnDestroyDevice();    

    release_com(g_font);
    release_com(g_vertex_buffer);
    release_com(g_texture_0);
    release_com(g_texture_1);
}

//--------------------------------------------------------------------------------------
// Handle updates to the scene
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
}

//--------------------------------------------------------------------------------------
// Render the helper information
//--------------------------------------------------------------------------------------
void RenderText()
{
    CDXUTTextHelper text_helper(g_font, g_text_sprite, 
20);
    
    text_helper.Begin();

    
// show frame and device states
    text_helper.SetInsertionPos(55);
    text_helper.SetForegroundColor( D3DXCOLOR(
1.0f0.475f0.0f1.0f) );
    text_helper.DrawTextLine( DXUTGetFrameStats(
true) );
    text_helper.DrawTextLine( DXUTGetDeviceStats() );

    
// show other simple information
    text_helper.SetForegroundColor( D3DXCOLOR(1.0f1.0f1.0f1.0f) );
    text_helper.DrawTextLine(L
"Multi Texture Blending");

    
// show helper information
    
    
const D3DSURFACE_DESC* surface_desc = DXUTGetBackBufferSurfaceDesc();

    
if(g_show_help)
    {
        text_helper.SetInsertionPos(
10, surface_desc->Height - 15 * 6);
        text_helper.SetForegroundColor( D3DXCOLOR(
1.0f0.475f0.0f1.0f) );
        text_helper.DrawTextLine(L
"Controls (F1 to hide):");
        
        text_helper.SetInsertionPos(
40, surface_desc->Height - 15 * 4);
        text_helper.DrawTextLine(L
"Quir: ESC");
    }
    
else
    {
        text_helper.SetInsertionPos(
10, surface_desc->Height - 15 * 4);
        text_helper.SetForegroundColor( D3DXCOLOR(
1.0f1.0f1.0f1.0f) );
        text_helper.DrawTextLine(L
"Press F1 for help");
    }

    text_helper.End();
}

//--------------------------------------------------------------------------------------
// Render the scene 
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    HRESULT hr;

    
if(g_settings_dlg.IsActive())
    {
        g_settings_dlg.OnRender(fElapsedTime);
        
return;
    }

    
// Clear the render target and the zbuffer 
    V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0000), 1.0f0) );

    
// Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        pd3dDevice
->SetStreamSource(0, g_vertex_buffer, 0sizeof(sCustomVertex));
        pd3dDevice
->SetFVF(D3DFVF_CUSTOM_VERTEX);
        pd3dDevice
->DrawPrimitive(D3DPT_TRIANGLESTRIP, 02);

        RenderText();

        V(g_button_dlg.OnRender(fElapsedTime));

        V( pd3dDevice
->EndScene() );
    }
}


//--------------------------------------------------------------------------------------
// Handle messages to the application 
//--------------------------------------------------------------------------------------
LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, 
                          
bool* pbNoFurtherProcessing, void* pUserContext )
{
    
*pbNoFurtherProcessing = g_dlg_resource_manager.MsgProc(hWnd, uMsg, wParam, lParam);
    
if(*pbNoFurtherProcessing)
        
return 0;

    
if(g_settings_dlg.IsActive())
    {
        g_settings_dlg.MsgProc(hWnd, uMsg, wParam, lParam);
        
return 0;
    }

    
*pbNoFurtherProcessing = g_button_dlg.MsgProc(hWnd, uMsg, wParam, lParam);
    
if(*pbNoFurtherProcessing)
        
return 0;

    
return 0;
}


//--------------------------------------------------------------------------------------
// Handle keybaord event
//--------------------------------------------------------------------------------------
void CALLBACK OnKeyboardProc(UINT charater, bool is_key_down, bool is_alt_down, void* user_context)
{
    
if(is_key_down)
    {
        
switch(charater)
        {
        
case VK_F1:
            g_show_help 
= !g_show_help;
            
break;
        }
    }
}

//--------------------------------------------------------------------------------------
// Handle events for controls
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent(UINT eventint control_id, CDXUTControl* control, void* user_context)
{
    
switch(control_id)
    {
    
case IDC_TOGGLE_FULLSCREEN:
        DXUTToggleFullScreen();
        
break;

    
case IDC_TOGGLE_REF:
        DXUTToggleREF();
        
break;

    
case IDC_CHANGE_DEVICE:
        g_settings_dlg.SetActive(
true);
        
break;
    }
}

//--------------------------------------------------------------------------------------
// Initialize dialogs
//--------------------------------------------------------------------------------------
void InitDialogs()
{
    g_settings_dlg.Init(
&g_dlg_resource_manager);
    g_button_dlg.Init(
&g_dlg_resource_manager);

    g_button_dlg.SetCallback(OnGUIEvent);

    
int x = 35, y = 10, width = 125, height = 22;

    g_button_dlg.AddButton(IDC_TOGGLE_FULLSCREEN, L
"Toggle full screen", x, y,         width, height);
    g_button_dlg.AddButton(IDC_TOGGLE_REF,          L
"Toggle REF (F3)",     x, y += 24, width, height);
    g_button_dlg.AddButton(IDC_CHANGE_DEVICE,      L
"Change device (F2)", x, y += 24, width, height, VK_F2);    
}

//--------------------------------------------------------------------------------------
// Initialize everything and go into a render loop
//--------------------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
    
// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF 
| _CRTDBG_LEAK_CHECK_DF );
#endif

    
// Set the callback functions
    DXUTSetCallbackDeviceCreated( OnCreateDevice );
    DXUTSetCallbackDeviceReset( OnResetDevice );
    DXUTSetCallbackDeviceLost( OnLostDevice );
    DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );
    DXUTSetCallbackMsgProc( MsgProc );
    DXUTSetCallbackFrameRender( OnFrameRender );
    DXUTSetCallbackFrameMove( OnFrameMove );
    DXUTSetCallbackKeyboard(OnKeyboardProc);
   
    
// TODO: Perform any application-level initialization here
    InitDialogs();

    
// Initialize DXUT and create the desired Win32 window and Direct3D device for the application
    DXUTInit( truetruetrue ); // Parse the command line, handle the default hotkeys, and show msgboxes
    DXUTSetCursorSettings( truetrue ); // Show the cursor and clip it when in full screen
    DXUTCreateWindow( L"AddControl" );
    DXUTCreateDevice( D3DADAPTER_DEFAULT, 
true640480, IsDeviceAcceptable, ModifyDeviceSettings );

    
// Start the render loop
    DXUTMainLoop();

    
// TODO: Perform any application-level cleanup here

    
return DXUTGetExitCode();
}

 

在DirectX 6.0引入多紋理單元時,其中最有趣的一項特征便是它可以通過多次渲染將多張紋理映射到同一個多邊形上,因為這是通過多次渲染不同的紋理來實現的,所以該技術稱為多通道渲染(multipass rendering)。這里講的是多重紋理渲染,是指將多張紋理在一次渲染中映射到同一個多邊形上,而多通道渲染是指分多次將多張紋理映射到同一個多邊形上,前者更快,多通道渲染技術目前已經很少使用了。

 

下載示例工程


posted on 2008-05-19 18:30 lovedday 閱讀(3942) 評論(2)  編輯 收藏 引用

評論

# re: 高級紋理映射技術(1) 2008-11-10 21:03 深藍色

你好,我再看你的博客學習中,再第一層紋理用D3DTOP_MODULATE還得到顏色,不是會是黑色的嗎?兩個小于1的FLOAT相乘,不是很小,怎么會是那面墻的顏色,我用D3DTOP_ADD,就是你例子中得到的結果,這是怎么回事??  回復  更多評論   

# re: 高級紋理映射技術(1) 2013-05-03 01:05 seamanj

兄弟,貌似你第二步寫反了,經過0號紋理單元處理過后應該作為arg2而不是arg1

D3DTSS_COLORARG1
The default argument is D3DTA_TEXTURE.
D3DTSS_COLORARG2
The default argument is D3DTA_CURRENT
  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国一区二区在线观看| 亚洲黄色成人网| 亚洲欧美日韩国产成人精品影院| 亚洲国产一区二区a毛片| 久久久久天天天天| 国产一区91精品张津瑜| 久久综合久久久久88| 久久综合九色综合久99| 亚洲精品视频在线看| 一区二区三区黄色| 国产美女精品人人做人人爽| 久久久99免费视频| 美女精品自拍一二三四| 亚洲日本aⅴ片在线观看香蕉| 亚洲精品一区二区三区四区高清| 欧美亚男人的天堂| 久久久av水蜜桃| 欧美激情aⅴ一区二区三区| 亚洲在线第一页| 欧美在线观看日本一区| 日韩亚洲视频| 午夜一区二区三区不卡视频| 亚洲精品女av网站| 蜜臀99久久精品久久久久久软件| 亚洲精品一品区二品区三品区| 亚洲免费观看高清完整版在线观看熊 | 亚洲一区欧美一区| 国产综合自拍| 亚洲精品国产欧美| 国外精品视频| 日韩一区二区精品视频| 激情欧美国产欧美| 99视频一区| 在线电影国产精品| 亚洲一区二区四区| 在线免费一区三区| 一区二区三区精品视频在线观看| 国产在线高清精品| 9人人澡人人爽人人精品| 悠悠资源网亚洲青| 在线中文字幕一区| 亚洲日韩欧美视频| 欧美一区二区三区在线观看视频 | 欧美国产第一页| 久久久999精品视频| 欧美日韩少妇| 欧美国产专区| 国内成人精品2018免费看| 亚洲人www| 亚洲国产精彩中文乱码av在线播放| 宅男66日本亚洲欧美视频| 亚洲精品你懂的| 久久精品人人爽| 性伦欧美刺激片在线观看| 欧美精品日本| 欧美成人资源| 在线观看视频免费一区二区三区| 亚洲一区二区三区成人在线视频精品| 亚洲黄色小视频| 久久高清国产| 久久九九精品99国产精品| 国产精品入口日韩视频大尺度| 欧美激情亚洲综合一区| 在线观看成人av| 久久久久在线观看| 理论片一区二区在线| 国产精品亚洲欧美| 亚洲欧美日韩精品久久久| 亚洲欧美日韩精品一区二区| 欧美日韩在线不卡| 亚洲精品五月天| 亚洲午夜羞羞片| 欧美性大战xxxxx久久久| 日韩午夜视频在线观看| 亚洲视频在线播放| 国产精品国产自产拍高清av王其| 日韩视频在线一区| 午夜精品国产| 国产色产综合产在线视频| 午夜亚洲性色视频| 蜜桃精品久久久久久久免费影院| 永久555www成人免费| 蜜臀av性久久久久蜜臀aⅴ| 亚洲国产99精品国自产| 在线视频精品一| 国产精品亚洲一区| 久久久蜜桃精品| 亚洲国产精品国自产拍av秋霞| 亚洲精品视频一区二区三区| 欧美日韩一区在线| 亚洲欧美视频在线观看视频| 久久婷婷国产麻豆91天堂| 亚洲第一精品久久忘忧草社区| 欧美风情在线| 亚洲欧美伊人| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲高清视频在线观看| 欧美午夜一区二区三区免费大片| 亚洲男人第一网站| 免费看精品久久片| 亚洲视频视频在线| 黄色在线成人| 欧美精品色网| 欧美在线高清| 99在线热播精品免费| 久久中文字幕一区二区三区| 99热在线精品观看| 国产在线精品一区二区中文 | 亚洲一区二区3| 毛片一区二区| 亚洲午夜久久久| 在线日韩欧美| 国产精品久久久久久久久久久久久久| 久久精品国产亚洲精品| 亚洲免费精彩视频| 蜜臀va亚洲va欧美va天堂| 亚洲一区二区免费在线| 亚洲第一福利视频| 国产日韩欧美在线观看| 欧美乱妇高清无乱码| 久久九九热re6这里有精品| 在线一区日本视频| 亚洲国产日韩欧美在线图片| 久久精品最新地址| 欧美亚洲日本国产| 亚洲小少妇裸体bbw| 亚洲激情亚洲| 在线精品国产欧美| 国产色产综合色产在线视频| 欧美午夜国产| 欧美精品午夜视频| 欧美黑人一区二区三区| 老司机精品视频一区二区三区| 欧美一区二区三区免费视频| 一区二区三区 在线观看视| 亚洲精品欧美激情| 亚洲国产精品悠悠久久琪琪| 蜜桃久久av| 久久综合给合久久狠狠狠97色69| 欧美在线免费播放| 性欧美xxxx大乳国产app| 亚洲一区二区av电影| 亚洲午夜免费视频| 亚洲欧美变态国产另类| 亚洲在线视频| 午夜在线观看免费一区| 欧美在线日韩在线| 久久精品国产在热久久 | 亚洲特级毛片| 亚洲一区二区三区乱码aⅴ| 亚洲一区二区精品在线| 亚洲一区二区三区乱码aⅴ| 亚洲一区日韩| 欧美一区成人| 久久精品盗摄| 美女图片一区二区| 亚洲高清在线| 亚洲免费av网站| 亚洲视频欧美在线| 先锋影音网一区二区| 久久精品国产精品亚洲| 久久综合狠狠综合久久激情| 免费视频久久| 欧美啪啪成人vr| 国产精品久久久久久久久久免费看| 国产精品福利片| 国产一区二区三区电影在线观看| 黄色一区二区三区| 亚洲精品国产无天堂网2021| 一区二区三区四区五区在线| 欧美一区二区高清| 麻豆九一精品爱看视频在线观看免费| 欧美国产日产韩国视频| a91a精品视频在线观看| 欧美亚洲一区| 欧美成人亚洲| 国产欧美亚洲视频| 亚洲国产精品成人| 亚洲欧美日韩天堂| 欧美91大片| 亚洲视频一区二区在线观看| 欧美一区二区视频在线观看2020| 另类春色校园亚洲| 国产精品亚洲美女av网站| 在线精品观看| 亚洲欧美在线磁力| 欧美v日韩v国产v| 亚洲一区二区三区激情| 蜜桃av一区二区在线观看| 国产精品vip| 91久久极品少妇xxxxⅹ软件| 午夜欧美精品| 亚洲国产婷婷香蕉久久久久久| 亚洲免费一区二区| 欧美日韩国产成人高清视频| 国产综合自拍| 亚洲欧美一区二区视频| 亚洲区免费影片| 久久久久国产精品人| 国产欧美一区二区精品忘忧草|