Jump to content
  • Advertisement
Rockmover

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

Recommended Posts

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!!!

Edited by Rockmover

Share this post


Link to post
Share on other sites
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.

 

 

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!