Terrain

Started by
6 comments, last by boxdot3 21 years, 6 months ago
I have two questions for my terrain project I am working on: 1) When I put a detail texture over my terrain, what texture stage states should I use? Right now i have:

m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP,  D3DTOP_MODULATE);
m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
 
But it cause a big framerate drop. I was thinking it could be that I dont use mipmapping, or im just setting the states wrong. 2) How do you setup/enable mipmapping? Thanks Simon
Advertisement
1. Not using mipmapped textures _can_ certainly cause a big performance hit. What''s in your stage 0 and stage 2? Your setup assumes that stage 0 is something like SELECTARG1, ARG1 = TEXTURE, and stage 2 is DISABLE.

2. How are you creating your textures? After you''ve created mipmaps for your textures, you should set appropriate min/mag/mip filters using SetTextureStageState(stage, D3DTSS_MIN/MAG/MIPFILTER, filtertype).

-meZ
quote:I was thinking it could be that I dont use mipmapping


*VERY* likely. Extra texture blending stages shouldn''t really cause a big performance drop - on most hardware having an 8 stage blend is no different speed wise to 1 stage (the blend units are hardwired and always on, the "disable" simply changes the hardwired units to do a "no-op").

Mipmapping helps massively for minification since the texture cache doesn''t get accessed repeatedly by the filtering for texels which never get seen.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

m_pD3DDevice->SetTexture(0, m_pTexture);m_pD3DDevice->SetTexture(1, detailtex);m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);		m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP,  D3DTOP_MODULATE);m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);m_pD3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE); 

Here is my code for setting up the Texture stage states.
And to load textures:
D3DXCreateTextureFromFile(m_pD3DDevice, path, &detailtex) 


>>After you''ve created mipmaps for your textures...

How do I create mipmaps? Is there a simple D3DXcreatemipmaps type function I can call or do I need to do it myself?

Sorry if these questions are pretty basic but im fairly new.

Thank you for the help so far

Simon
hi, i think D3DXCreateTextureFromFile(...) handles the creation of mipmaps for you and by default, it also handles wbich mipmaps to display,

[edited by - mickey on November 10, 2002 8:46:13 PM]
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
boxdot, I do not understand your stage 0.
You are modulating the texture with current.

What the heck is current in stage 0 anyway?

why not simply

m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);

?

( and no changes to your stage 1 code )
boxdot, I do not understand your stage 0.
You are modulating the texture with current.

What the heck is current in stage 0 anyway?

why not simply

m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);

?

( and no changes to your stage 1 code )
bratsj:
The 0 stage is a texture stretched across the entire terrain, and the 1 stage is the detail texture.

mickey:
I looked into D3DXCreateTextureFromFile, and D3DXCreateTextureFromFileEx can create mipmaps, and I figured it out from there. thank you.

C ya

Simon

This topic is closed to new replies.

Advertisement