Jump to content
  • Advertisement
Sign in to follow this  

Custom shadow transformation trouble

This topic is 2934 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font="Arial,"][size="4"]This is a cross post of mine from Stackoverlfow:

[size="4"]I am trying to cast a shadow with a projection transformation. But it seems that OpenGL doesn't like my matrix as it does not draw anything after glMultMatrix. After I pop my matrix everything's ok. I'm also using JOGL, maybe the problem's with that, but I doubt it since my custom translation and rotation matrices work fine.

[size="4"]The matrix looks like this:

lightPosition = {x, y, z, 1}
planeEquation = {a, b, c, d}
pl = a*x + b*y + c*z + d

a*x-pl b*x c*x d*x
a*y b*y-pl c*y d*y
a*z b*z c*z-pl d*z
a b c d-pl

[size="4"]Now this is a matrix which I calculated, but I also used two other flavors I searched for on the internet; one a bit different, and another which is exactly like mine times -1. Is this enough information? Or should I submit code also?

[size="4"]Maybe it's my plane equation?

three points on plane = p0, p1, p2

v0 = p1 - p0
v1 = p2 - p0

n = {a, b, c} = v0 (cross) v1
d = -(n (dot) p0)

planeEquation = {a, b, c, d}

[/font][font="Arial,"][/font][font="Arial,"][size="4"]Does it sound familiar to anyone? Or it's just a code thing?

[size="4"][font="Arial,"]There's this test that I'm trying to do, and that to draw a single vertex point with and without the matrix (for an x-z plane and a {0, 20, 0} spot light), and with an orthogonal projection matrix. Also, I'm trying to calculate myself the normalized device coordinates of that vertex by getting OpenGL's projection and model view matrices and multiplying it with them, and normalizing with the w coordinate.[/font][/font]
[font="Arial,"] [/font]
[font="Arial,"][size="4"]What I get is that without my "shadow matrix" it displays the point nicely and it seems my calculations of the vertex match what I'm seeing. But with my "shadow matrix" I get nothing, although the vertex's coordinates lie within the [-1,1] range on all axes.

[size="4"]This is just too strange...

[size="4"]added test program here: https://gist.github....d5ab3cbc92dffe6

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!