# Setting diffuse color as RenderState or sthg. like that ?

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

## Recommended Posts

Hi guys ! I have a damn problem: I have a lot of "billboard"/bitmap-graphics to draw in my game. I have a lot of frames of 2d-troopers running around, and i cache them in realtime into a texture when they are needed. Then when i want to display them i use calculate the right texture-coordinates to get the right part of the caching texture and simple draw a quad with DrawPrimitive. I also have a lot of smoke effects and stuff like that, that work the same way. So far so good. Applying a diffuse color to these objects (troopers, smoke particels, aso.) is no problem when I'm drawing it with DrawPrimitive only. But now i want to use vertex buffers to speed things up. These vertex buffers should ofcourse not include any color information, because the color should still be dynamically changable ? So is there any possibility to just define a FVF like the below one, filling vertex buffers at one initial time with vertices of that type, and then just switch diffuse color of it before DrawPrimitiveVB () ??
#define D3DFVF_SAVERTEX ( D3DFVF_XYZRHW | D3DFVF_TEX1 )

typedef struct
{
D3DVALUE    sx;
D3DVALUE    sy;
D3DVALUE    sz;
float	rhw;
D3DVALUE    tu;             /* Texture coordinates */
D3DVALUE    tv;
} D3DSAVERTEX;


ah yeah, here's a screen: Cheers, Roman

##### Share on other sites
It looks beautiful [smile].

I'd like to hear what others have to say before I make my pledge.

##### Share on other sites
Hmm. I'm not sure if I understand - is this for changing the trooper colors? I wonder if you couldn't use some quick way of operating on the textures themselves?
I remember from using diffuse materials from before, it seemed that diffuse color really only showed up if the texture was not used.
Sorry, I'm trying to be helpfull, but I'm dumb.

##### Share on other sites
Blend with TFACTOR?

##### Share on other sites

renman29: Yeah i want the possibility to do a color modulation of the troopers, or whatever => e.g. i have a greyscale smoke particle - texture, and i want to render
it out modulated with RGBA(0,0,255,255) = blue only.

XiotexStudios: ahh, TFACTOR could work. i thought its just a float value to fade down colors. hmmm. have to try that....

##### Share on other sites
ok, yeah, worx.
Thanx guys [smile]
shame on me.

• 9
• 9
• 13
• 41
• 15