Jump to content
  • Advertisement
Sign in to follow this  
Drakex

Setting D3DRS_LIGHTING to false sets diffuse to (1,1,1,1)?

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to disable lighting for one object, so I set D3DRS_LIGHTING to false before rendering it. This has the strange side effect of making it as if the diffuse color of the object's material is (1,1,1,1); that is, it turns bright white and loses any alpha. Is this supposed to happen, or is this some kind of weird interaction of states? I'm just using the normal SRCALPHA/INVSRCALPHA for my SRC/DESTBLEND and ADD for the COLOROP.

Share this post


Link to post
Share on other sites
Advertisement
If you were relying of D3DMATERIAL9 for color and alpha, then yup, it's gone. That structure is part of the lighting system. You can stuff colors in vertices, TFACTOR, per stage CONSTANT (if supported), vertex and/or shader constants, the border color of a stage with UVs outside the valid range, from a texture, from a second vertex stream, or some other place I'm likely forgetting where you can get color information.

Share this post


Link to post
Share on other sites
Quote:
If you were relying of D3DMATERIAL9 for color and alpha, then yup, it's gone


Well there it is. Thanks.

As this is for a fixed-function pipeline, shaders are kind of out of the question; coloring every vertex seems overkill; border color isn't even supported on my card (radeon 9500); and per-stage constant doesn't seem like it's very widely supported either. So, that leaves the D3DRS_TEXTUREFACTOR. Looking at the DX7 docs, it seems that this renderstate has been around for a while, which leads me to believe that it will be the most well-supported. Do you have any experience with this?

Share this post


Link to post
Share on other sites
Yeah, it's fairly well supported. Some older cards (ie: ATI XPert98/RagePro) handle it quite badly, but these cards are getting quite rare. If you *must* target such old cards, there are a few things you can try.

Try leaving lighting on, with ambient cranked up to the color you want, and no lights.

A vertex shader will be emulated in software. Cards this old are doing software T&L anyway, so there likely won't be a performance change, and you can easily make all sorts of new effects. Transforming the vertex and setting a constant diffuse output, (possibly with a texture coordinate output copied from the input) should be fairly quick and painless to get up and running. It solves your problem, gets your foot into programmable effects, and should be easy.

The only downside to going with shader emulation for this is hardware T&L pre-shader cards, ie: GeForce256 and GeForce2/4MX cards. Now, if your software cards run your game just fine, then dropping an early GeForce into software mode is still going to be faster, just not as fast as it could be. If you really want, you can make two paths. If you detect HW T&L, use TFACTOR, otherwise use software shader emulation. This should be just a dozen extra lines of code to support TFACTOR, which isn't a big deal, and gets you not only the feature you want, but optimal performance on all cards.

Share this post


Link to post
Share on other sites
Wow, I write a reply this afternoon and must have forgotten to post it!

As this is a fairly minor feature, and since I'm not really aiming to target cards that are quite as old as a Rage Pro (bleeeagh! huuaggh!), I'll probably just go with the TFACTOR. Thanks for your help!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!