Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

ok so here is the problem I need to solve.

I have a known set of vertices that I need to "animate" the emission level of. Currently I have a vertex definition setup and RGB color data for each vertex. and I can animate that. but obviously that doesn't effect the lighting.

what would be ideal I think is if I could take the basic effect class and apply it to just a few vertices at a time but so far I cant find a way to use it on anything less than a mesh.

Update

Thanks to Evan I think the way to go is to get each of these indices and create a mesh that will overlay the existing model. This would make it easier to control transparency as well as the emission.

The question I have is lets say these indices do not make up a full triangle? Maybe after I find all of the vertices I also find that they don't divide out to 3.

I guess what I need now is what would a good way to pull this mesh apart be?

share|improve this question
    
Are you wanting to apply completely different lighting calculations to a specific set of vertices? What is the "emission level" effect you are wanting? –  Evan Sep 19 '13 at 19:48
    
so a specific area of the model will have a different color, highlighting a problem area. That area needs to "glow". But it is not its own mesh it might be five or six vertices out of 100 for the entire mesh. Outside of the highlighted vertices the mesh should have the normal light calculations. –  Paul Wade Sep 19 '13 at 19:53

1 Answer 1

up vote 0 down vote accepted

If you want alternative lighting calculations or shading effects (beyond color shift) you can do it in a few ways.

The first way would be to create a separate object that uses the vertices you want to be rendered, and either render the original object without these vertices, or simply overdraw the same vertices with the new effect. The overdraw is likely to be more efficient than the time it would take to sort out vertex buffer and index buffer organization. You may also need to remove z-testing for the effects pass.

The second way would be to modulate specific vertices color, and render them a very specific color that is not present in your game in any other fashion (such as a vibrant pink). After that, you could perform glow effects or whichever as a post processing step, that only acts on anything rendered using this particular color. The color of course is only being used as an obvious identifier. This method would likely be best if you are rendering many different objects in this way. Edit, also for this particular effect, you will have to avoid texture sampling in this situation one way or another, otherwise it will be blended with the modulated vertex color, producing inconsistent color variations.

The last way I could think would be to actually implement branching code in whichever shader is applied to objects that could have this effect. I highly advise against this, as branching code is problematic and generally much slower on GPU's, and you REALLY dont want a default shader to have branching code in it. You could perform a shader swap though whenever this effect is enabled, and test the performance characteristics of it. This would also require additional data overhead, as each vertex would need a flag indicating whether it is currently part of the desired effect, or rendered normally. This is the worst of the three by far, but it is an option.

share|improve this answer
    
Thanks for the ideas. It gives me a little validation im approaching this right. For option 1 I started down this route but but highlighted vertices don't necessarily make up a full triangle so I couldn't figure out how I would break the mesh apart. option 2 might work I will have to look into post processing steps. Can those be applied to vertices? Or since you said make it a unique color im guessing it would apply to anything with that color. –  Paul Wade Sep 19 '13 at 21:20
    
also I just realized I need these vertices to NOT allow transparency but the rest of the model should have it. I am leaning to overlaying these vertices but I'm not sure how. –  Paul Wade Sep 19 '13 at 21:31
    
You simply render the same vertices a second time using a different shader. Depending on your implementation, you may render this effect before, or after the transparency pass. Likely before. –  Evan Sep 19 '13 at 21:41
    
I ended up looping through every group of 3 vertex and if any point of the triangle had a matching color I stored that index to use later. –  Paul Wade Oct 1 '13 at 15:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.