well i read the dx9 docs about shaders and effects and HLSL yesterday.
set stream, set constants, set shaders (pre-compileld, already loaded), DIP. that seems to be what it boils down to.
i use d3dx meshes for loading, but copy them into a vb and ib, then release the d3dxmesh. so i have buffers ready to go already.
i think the skinned mesh code in Caveman 3.0 already does this, via simple shaders and a fx file.
i'm not really doing a lot of fancy special effects, animated vegetation, alpha blended flames and smoke.
depth of field seems to be the only post processing effect that's appropriate for a scene as seen by the human eye as opposed to a camera lens. IE the human eye doesn't have lens flare, etc. corona effects, but that's a little different. the problem with DOF is - how do you let the player control the focus distance? in real life its automatic, whatever you "look at", your brain automatically adjusts the eye muscles to focus the lens at that range. rolling the middle mouse wheel is all i can think of.
Snow and three days of lows of 15F ( -9C ) have come to the Washington DC area. In-between dealing with that - getting into the sample code is the next thing on the todo list for today / tomorrow.
It also looks like i can keep the game mostly fixed function, and just use shaders where and as needed, the way i do now for skinned meshes. in fact i've already figured out what you have to save and restore when switching from fixed function to shaders and back again. I did that when I got skinned meshes working.
' draws a caveperson using the specified textures and animation
fn v draw_skinmesh_caveman_nohair i sex i bodT i eyeT i clothT i ani i ctrl double dt D3DXMATRIX *mWorld i topT i cloakT i braT
' sex: 0=male 1=female
' bodT is body mesh texture ID
' eyeT is eye texture ID
' clothT is clothing texture ID
' ani is which ani should be playing
' ctrl is the index of the character`s controller
i a
' a is the skinned_mesh_pool index of the body mesh
= a controller_pool[ctrl].mesh_index
' 1. set textures in the skinned mesh pool
= skinned_mesh_pool[a].body->texID bodT
= skinned_mesh_pool[a].loincloth->texID clothT
== sex 1
= skinned_mesh_pool[a].bra->texID braT
.
= skinned_mesh_pool[a].top->texID topT
= skinned_mesh_pool[a].cloak->texID cloakT
' 2. set animation
c controller_pool_setani ctrl ani
' 3. draw instance ( controllerID, dt, mWorld )
c draw_skinned_mesh_instance ctrl dt mWorld
' set z3d state manager current mesh to none...
= Zcurrentmesh -1
' reset FVF back to z3d FVF...
c Zd3d_device_ptr->SetFVF ZFVF
' 4. draw eyes
c draw_eyeballs2 a eyeT
.
As you can see, the FVF is all you really need to restore. I set the "current mesh" to NONE just to be safe.
apparently set_FVF and set_shader are the two calls that actually do the switch from fixed function to porgramnmable pipeline and back.
so it could be as simple as:
set stream
set shaders
set constants
DIP // draw animated grass
set FVF // back to normal operating mode for the game's "graphics engine".
And that means i can use d3dx9 AND shaders! have my cake AND eat it too! Something which is definitely not against my religion! <g>.
I should know in a day or two.
time to hit the books! <g>.
never stop learning.
and you gotta break a few eggs to make a real mayonnaise