specularenable = true?

Started by
1 comment, last by Christian Johansson 18 years, 5 months ago
Okey i have this line in my code and i know exactly what it does: Device->SetRenderState(D3DRS_SPECULARENABLE, true); However, i DON'T gets any specular on my textures! =/ Yes i'm using a lightsource (pointlight) and it's enabled! Any suggestions? Oh btw, i also have shadow (stencil buffer), could that be a reason? Kind regards, Christian.
Q: How does a UNIX Guru do sex? A: unzip; strip; touch; finger; mount; fschk; more; yes; umount; sleep " -- Martin Kahlert
Advertisement
Assuming you're talking about Direct3D 9 and the fixed function pipeline...

Sorry if some of these are obvious questions, but you didn't give much detail in your post:

1. What is the Specular member of your D3DMATERIAL9 set to?
If it's set to 0 (or not set...), when the specular light is multiplied by that colour, 0*N=0 so you get black which gives you no specular.


2. What's the Power member of your D3DMATERIAL9 set to?
It shouldn't be 0, the Blinn-Phong specular equation used by the D3D FFP exponentiates the specular contribution by the power (aka "shininess") which controls how sharp the specular highlights are.


3. What's the Specular member of your D3DLIGHT9 set to?
As with the Specular member of your material, this gets multiplied by the specular intensity and the material; if it's 0 you won't see any specular.


4. What's in your vertex format?

a) a normal? If you're seeing correct diffuse, then I'll assume you have, if not, then you'll need one or Mr Blinn's magic N.H aint gonna work.

b) a RHW? If you have, pre-transformed vertices and the fixed function pipeline don't mix very well; use one or the other if you are.

c) a D3DFVF_SPECULAR (or declaration using COLOR1)? If you have, then you'll need to make your intentions clear to D3D's FFP using the D3DRS_SPECULARMATERIALSOURCE render state.
Even then, beware that there's only one specular iterator available on most hardware (COLOR1) so don't expect to be able to interpolate more than 2 non-texture colours per vertex.


5. What's in your SetTextureStageState() calls? Anything involving D3DTA_SPECULAR?
If so, bear in mind that D3DRS_SPECULARENABLE=TRUE enables the post pixel processing specular addition so any use (or abuse) of specular during pixel processing can interfere with the result you get.


6. Have you set the D3DRS_LOCALVIEWER render state to TRUE at all (or not set it to a decent default)?

a) If so, how have you set your projection matrix up? Orthogonal won't work; "W-friendly" is preferable.

b) If so, do you set your view matrix separately from your world and projection matrices? If not, try doing so.


7. Do you use any form of frame buffer blending for what's being rendered? Multiplactive blends in particular aren't going to show much of white specular highlights...


8. Are you using fog? If so, which settings?
Fog and specular are often applied in the same part of the graphics chip - older chips sometimes share stuff between them so things like alpha in the specular colour can interfere with the fog and vice versa.


BTW: the stencil buffer operations shouldn't affect anything with specular on its own - but it depends on the particular flavour of shadow technique you're using (there are lots of variations on the plain stencil shadow!).

If you're using a method that performs a dark/unlit or bright/lit pass separately based on what's in the stencil, then it is worth checking that one isn't causing the other to be rejected. Z buffer occlusion for multipass techniques is also an issue with stencil shadows - though usually shows up as Z fighting when the camera gets close rather than nothing appearing at all.

Simple way to tell though... disable your shadows and see if your specular highlights come back [smile] divide and conquer debugging is sometimes the only way!

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

Quote:Original post by S1CA
Assuming you're talking about Direct3D 9 and the fixed function pipeline...

Sorry if some of these are obvious questions, but you didn't give much detail in your post:

1. What is the Specular member of your D3DMATERIAL9 set to?
If it's set to 0 (or not set...), when the specular light is multiplied by that colour, 0*N=0 so you get black which gives you no specular.


2. What's the Power member of your D3DMATERIAL9 set to?
It shouldn't be 0, the Blinn-Phong specular equation used by the D3D FFP exponentiates the specular contribution by the power (aka "shininess") which controls how sharp the specular highlights are.


3. What's the Specular member of your D3DLIGHT9 set to?
As with the Specular member of your material, this gets multiplied by the specular intensity and the material; if it's 0 you won't see any specular.


4. What's in your vertex format?

a) a normal? If you're seeing correct diffuse, then I'll assume you have, if not, then you'll need one or Mr Blinn's magic N.H aint gonna work.

b) a RHW? If you have, pre-transformed vertices and the fixed function pipeline don't mix very well; use one or the other if you are.

c) a D3DFVF_SPECULAR (or declaration using COLOR1)? If you have, then you'll need to make your intentions clear to D3D's FFP using the D3DRS_SPECULARMATERIALSOURCE render state.
Even then, beware that there's only one specular iterator available on most hardware (COLOR1) so don't expect to be able to interpolate more than 2 non-texture colours per vertex.


5. What's in your SetTextureStageState() calls? Anything involving D3DTA_SPECULAR?
If so, bear in mind that D3DRS_SPECULARENABLE=TRUE enables the post pixel processing specular addition so any use (or abuse) of specular during pixel processing can interfere with the result you get.


6. Have you set the D3DRS_LOCALVIEWER render state to TRUE at all (or not set it to a decent default)?

a) If so, how have you set your projection matrix up? Orthogonal won't work; "W-friendly" is preferable.

b) If so, do you set your view matrix separately from your world and projection matrices? If not, try doing so.


7. Do you use any form of frame buffer blending for what's being rendered? Multiplactive blends in particular aren't going to show much of white specular highlights...


8. Are you using fog? If so, which settings?
Fog and specular are often applied in the same part of the graphics chip - older chips sometimes share stuff between them so things like alpha in the specular colour can interfere with the fog and vice versa.


BTW: the stencil buffer operations shouldn't affect anything with specular on its own - but it depends on the particular flavour of shadow technique you're using (there are lots of variations on the plain stencil shadow!).

If you're using a method that performs a dark/unlit or bright/lit pass separately based on what's in the stencil, then it is worth checking that one isn't causing the other to be rejected. Z buffer occlusion for multipass techniques is also an issue with stencil shadows - though usually shows up as Z fighting when the camera gets close rather than nothing appearing at all.

Simple way to tell though... disable your shadows and see if your specular highlights come back [smile] divide and conquer debugging is sometimes the only way!


Oh NO... What a shame... forgot to add light.Specular.r ,g ,b ,a... Oops..

Anyway, Thank so much for ur offer and will.

Great regards,

Christian.
Q: How does a UNIX Guru do sex? A: unzip; strip; touch; finger; mount; fschk; more; yes; umount; sleep " -- Martin Kahlert

This topic is closed to new replies.

Advertisement