C# - DirectX 11 - SharpDx - 3D Lines (vertex Colored)

Started by
2 comments, last by Rockmover 6 years, 6 months ago

I am really stuck with something that should be very simple in DirectX 11. 

1. I can draw lines using a PC (position, colored) vertices and a simple shader just fine.

2. I can draw 3D triangles using PCN (position, colored, normal) vertices just fine (even transparency and SpecularBlinnPhong shaders).

 

However, if I'm using my 3D shader, and I want to draw my PC lines in the same scene how can I do that?

 

If I change my lines to PCN and pass them to the 3D shader with my triangles, then the lighting screws them all up.  I only want the lighting for the 3D triangles, but no SpecularBlinnPhong/Lighting for the lines (just PC). 

I am sure this is because if I change the lines to PNC there is not really a correct "normal" for the lines.  

I assume I somehow need to draw the 3D triangles using one shader, and then "switch" to another shader and draw the lines?  But I have no clue how to use two different shaders in the same scene.  And then are the lines just drawn on top of the triangles, or vice versa (maybe draw order dependent)?  

I must be missing something really basic, so if anyone can just point me in the right direction (or link to an example showing the implementation of multiple shaders) that would be REALLY appreciated.

 

I'm also more than happy to post my simple test code if that helps as well!

 

THANKS SO MUCH IN ADVANCE!!!

Advertisement

Switching shaders will do the trick. DeviceContext->VSSetShader and DeviceContext->PSSetShader will do that.

Rendering is done in the order you specify. Everything you render is rendered with the currently set shader. Once you switch shader everything will use that other shader.

 

 

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Thank you! 

I knew I was missing something very simple!!  The "big" picture looks a lot clearer to me now!

This topic is closed to new replies.

Advertisement