Sign in to follow this  
Temjin

Changing the colour of a mesh, material or vertexd colouring?

Recommended Posts

Temjin    168
Heya, At the moment, for every light in my 3D scene I have a .X mesh that can be rendered to phyisically show the origin/posistion of the DirectX light. Expanding on this, what I want to do now is colour the mesh appropiately so as to represent the basic colour of the light it represents. So far, I can think of two basic solutions but am intrested to know which of the two people think suitable (i.e, maybe one is more program efficent?) 1. Have a mesh use a material that has emissive values set to the colour of the light. 2. Access the vertices of the mesh and just vertex colour the mesh again to the values of the light Do these sound like plausable methods, or maybe there is a better one someone can suggest? :P Thanks, Pete

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Quote:
Original post by Temjin
1. Have a mesh use a material that has emissive values set to the colour of the light.

I would imagine this is the most efficient method. I assume that if you're modelling lights in this way that the rest of the geometry in the scene is lit by said lights, as a consequence your D3D pipeline is configured to use lighting. If you can use properties of the same configuration to express the colour of your light - great!

Quote:
Original post by Temjin
2. Access the vertices of the mesh and just vertex colour the mesh again to the values of the light

This would work quite nicely if the light colour was (fairly) static. But, for most implementations I've done you'd have to enable/disable D3DRS_LIGHTING when you came to render the light models which shouldn't pose a problem but at the same time reducing render-state/resource changes is a big goal for real-time graphics.

Quote:
Original post by Temjin
maybe there is a better one someone can suggest?

Are you using shaders (either vertex or pixel) ?? because you could probably pass in a constant so as to toggle a solid (or near solid) colour as appropriate... I can't think of any other obvious solutions.

hth
Jack

Share this post


Link to post
Share on other sites
Specchum    242
I dunno which one is better but I'll go for vertex colours that match the light colour. Although I suppose you may have to render the mesh with lighting disabled so that it is not affected by the lighting (it is a mesh with materials after all). That way you won't require normals either. The flip side being you will have to have at least two state changes (to disable/enable light).

EDIT: dang! Beaten to it by jolly and I see he is right on the ball. Again! Oh well, you live, you learn! :)

Share this post


Link to post
Share on other sites
Temjin    168
Thanks for the input :)

I'm not using Vertex/Pixel shaders yet (simply as I don't know how to us them) but I think I'll take a crack at using emissive materials to change the colour for now.

Quick question, when using a D3DMATERIAL9 structure, for example the emissive property, is the max 255.0f or 1.0f?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this