[HLSL] Understanding 3D coordinates and global-local conversion


hi there

i want understand how calculate 3d coordinates in hlsl (or in c# matter)

let's say i have 3d positioned light source @ 200, 100, -500 (assuming -500 away camera , scene)

let's have flat surface this: border{ width: 100, height: 100, rotationx: 45, rotationy: -45} located @ -100, -100, -200

basically have scene in 3d space surface "reflecting" som of light lightsource

q1: how calculate different angles/positions in pixel shader ?

q2: how calculate phong pixel shader lighting ?

q3: how convert between world coordinates , object coordinates , screen coordinates ?

- samples / algorithms find, require use of view_projection_matrix , having view_position

- samples have uses normalise function, ?

- dot product used ?

- possible live without vertex shader ? (how manage to do stuff without ? - how convert vertex shader stuff silverlight stuff ?)

i've had 3d imaging courses years ago, long gone in memory...

so inputs / links , not :)

well, i'll give shot ;)

first, should take consideration rendering mesh on screen, have go through 3 sets of coordinates in 3 respective 3d spaces. first start object space (local), coordinates read mesh file example. then, multiply these world space matrix, coordinates of mesh vertices in 3d world space (global). have multiply coordinates have far view , projection matrices in order coordinates respectively in camera , screen space, coordinates relative camera , on screen vertices projected.

and that's how coordinates can calculated. calculate angles, go dot product of 2 normalized vectors, gives cosine of angle between them (that's dot product used for). if need angle in radians badly, can doing inverse trigonometry arccosine (acos). normalize function "sets" vector's length equal 1.0.

calculating phong lighting in pixel shader, , lighting whole new subject, should search specialized article for. in basics, amount of lighting of surface angle between surface's normal , light vector. however, it's wide topic, there different types of lighting such diffuse , specular , different types of lights, such point , directional light sources. lighting shaders about.

that refreshing! hope of ;)



Silverlight  >  Game Development with Silverlight



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........