0
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ Are you wanting to apply completely different lighting calculations to a specific set of vertices? What is the "emission level" effect you are wanting? \$\endgroup\$
    – Evan
    Sep 19, 2013 at 19:48
  • \$\begingroup\$ 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. \$\endgroup\$
    – Paul Wade
    Sep 19, 2013 at 19:53

1 Answer 1

0
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ 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. \$\endgroup\$
    – Paul Wade
    Sep 19, 2013 at 21:20
  • \$\begingroup\$ 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. \$\endgroup\$
    – Paul Wade
    Sep 19, 2013 at 21:31
  • \$\begingroup\$ 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. \$\endgroup\$
    – Evan
    Sep 19, 2013 at 21:41
  • \$\begingroup\$ 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. \$\endgroup\$
    – Paul Wade
    Oct 1, 2013 at 15:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .