Jump to content

  • Log In with Google      Sign In   
  • Create Account

Does anyone implemented the Gouraud shading algorithm in C# Directx ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 aravind   Members   -  Reputation: 120

Like
0Likes
Like

Posted 06 May 2014 - 06:10 AM

Hi, i am strucked in Lighting.. i need to implement the Gouraud's Shading algorithm in my project but i am beginner in directx so i didnt have any idea about how to implement ..! can anyone suggest some option for me..!!! i am currently working with directx9 in C#.

 



Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2514

Like
0Likes
Like

Posted 06 May 2014 - 06:38 AM

Gouraud shading is pretty basic ... it is the default lighting model for D3D9 as far as I know. So, you'll just calculate the lighting values per vertex (using what ever lighting model desired such as blinn-phong) and then output the interpolated lighting value for each pixel (instead of recalculating the light for each pixel). 

 

Cheers!



#3 aravind   Members   -  Reputation: 120

Like
0Likes
Like

Posted 06 May 2014 - 06:51 AM

but i am so much confused and not having much knowledge about it my question seems to be silly so please bare with me,,how we can give the ambient,specular,diffuse color for each pixels in our object?, in other word how can we calculate the color value for per vertex?



#4 kauna   Crossbones+   -  Reputation: 2514

Like
0Likes
Like

Posted 06 May 2014 - 12:29 PM

Well you should maybe give a bit more information : what have you tried - what doesn't work. Have you looked into any examples? In the DXSDK there is plenty of simple examples how to draw a triangle, how to light a triangle etc. 

 

Since you are using DX9, you may even start without using any shaders - the fixed function pipeline does all that you need for drawing gouraud shaded objects with ambient, diffuse and specular lighting. No need even for a lighting model or anything.

 

Typically to attain that objective you'll need (assuming that you are using fixed function pipeline) :

 

- vertex buffer (+index buffer) containing a 3d mesh with at least position and normal data

- vertex format declaration or FVF which matches the vertex buffer data

- a material description with desired ambient, diffuse, specular values

- a light structure with required lighting information (position, diffuse, direction)

- a view matrix describing your camera location and orientation

- a projection matrix to describe your view port form and znear and zfar planes

- a world matrix for the object orientation and location

- well of course a back buffer and z-buffer a required too ... and a window 

 

 

Anyway, take a look in to the examples of the DXSDK or google. You'll find source which does more and less exactly what you need.

 

Cheers!

 

[edit] when using the fixed function pipeline, you'll have less control over the lighting calculations. You'll need to use a vertex shader and a pixel shader to implement some specific lighting formulas. Once again, there are samples using VS/PS so it is pointless to write an exact answer for your question.


Edited by kauna, 06 May 2014 - 12:30 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS