Skip to main content
gamedev.net
🔒 Locked

D3DFVF_NORMAL and D3DFVF_DIFFUSE

Started by NotTaxes Aug 7, 2002 at 7:25 AM 12 replies 900+ views
Original Post
NotTaxes
NotTaxes
I''m using vertex normal and the vertex diffuse color to light my terrain. I''m doing this to try and get a light-source shaded terrain, but with arbitrary color applied to certain points(so I can shade an area greenish or blueish or avacadoish, but still see the lighting effect). This works great, but on shaded sides of the terrain, the Diffuse coloring doesn''t come through at all (it''s just shadow color, no matter how bright I make the diffuse). I''m setting the FVF like this: D3DFVF_XYZ Or D3DFVF_NORMAL Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE Is there a way to get the vertex shader pipeline to attach more or less importance to one of these parameters?
'Doing the impossible is kind of fun' - Walt Disney
RapidStunna
RapidStunna
When using d3d''s lighting, the diffuse doesn''t matter. In order to use diffuse, specular, ambient, and emmisive color values also, you must set a material. See the SDK for more details.

---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
Pipo DeClown
Pipo DeClown
have you tried taking out xyz?
D3DFVF_XYZ i maen
.lick

[edited by - pipo declown on August 7, 2002 8:42:33 AM]
NotTaxes
NotTaxes
RapidStunna: - Sorry, but you can use lighting and diffuse. That's what the FVF is all about. It works fine, except for the shadows.

PipoDeClown: - If I leave out the XYZ, then the vertex just gets drawn at the origin, so it doesn't really help matters much.

Basically, the technique works quite fine, except for the full shadow areas. This is a problem because I may have a light source (not a DX light, just a light source... like a Torch) in the shadow of a hill, but it won't light the shadows.

And I only want to do this because using a light map is a pain in the neck, and I can't use more than 8 DX light sources.

[edited by - NotTaxes on August 7, 2002 11:27:28 AM]
'Doing the impossible is kind of fun' - Walt Disney
Pipo DeClown
Pipo DeClown
errrr....edit the nicknames, and have you tried w/o D3DFVF_XYZ?
just try it, then tell me if it worked.

.lick
NotTaxes
NotTaxes
Done the nicks :-)

I tried without XYZ, and it doesn''t work... I just get big black nothing on the screen.
'Doing the impossible is kind of fun' - Walt Disney
RapidStunna
RapidStunna
Whoops, NotTaxes, ur right. . I havn''t really used fixed function lighting in a long time and must have gotten confused. Sorry for the wrong advice.

---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
dorix
dorix
NotTaxes: What''s your scene''s ambient light colour? If you set it to a dark gray, say 20% or so, do your colours show through? The default ambient light colour is 0.


  
lpD3DDev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50, 50, 50));


Disclaimer: I''m a beginner, and I''m not in front of my own workstation at the moment, so I have no idea if this would help.

Cheers, John
Pipo DeClown
Pipo DeClown
just dont put it in your D3DFVF.
const int D3DFVF_myfvf = /*not XYZ*/

JUST DO IT!! like i said, have you tried it? no. just try it!


[edited by - pipo declown on August 7, 2002 2:58:21 PM]
NotTaxes
NotTaxes
OK Pipo, just tried it. Is that weird or what! The last time I took it out of the VB as well, so no wonder I got the black screen.

Totally freaked the terrain out. I''ve got shadows where there shouldn''t be, terrain where there can''t possibly be any and strange shining lights in the sky :-)

Nice one.
'Doing the impossible is kind of fun' - Walt Disney
don
don
You''ve got a few options.

1) If any of those other 8 D3D lights you''re using aren''t dynamic, then consider precomputing the lighting values for one of the lights and adding that color in the vertex to store for your mesh. This will allow you to use a D3D light for your torch.

2) The diffuse color is being shunted by the lighting equation. It doesn''t matter what color you set the diffuse to if the vertex normal is pointing away from the light source it will be forced to black. The only way to add more color is by pointing the vertex normal toward a light source, or by adding in an ambient or emissive color value.

3) You can change the texture blending cascade to add a constant color value (TEXTUREFACTOR) before modulating with the diffuse color.

The method you choose above would depend on whether or not you want to modify the contents of the vertex buffer each frame, or choose to render a subset of the vertices in the buffer (using an index buffer) and vary the material or texture blending between multiple DP calls. If it were me, I''d lean toward using method #1 above if possible.



NotTaxes
NotTaxes
Ah Don... thank''s a lot. You have answered my question quite nicely.
'Doing the impossible is kind of fun' - Walt Disney

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.