Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actualrocklobster

Posted 04 December 2012 - 02:38 AM

Ok I've changed my normal matrix to

m_graphics->SetUniform(id, "u_NormalMatrix", 1, false,
	glm::inverse(glm::transpose(glm::mat3(glm::vec3(viewMatrix[0]), g	lm::vec3(viewMatrix[1]), glm::vec3(viewMatrix[2])))));

and the light is

glm::vec4 lightPosViewSpace = glm::inverse(g->GetViewMatrix()) * glm::vec4(-50.0f, 150.0f, 30.0f, 1.0f);
g->SetUniform(id, "Light.Position", lightPosViewSpace);

Perhaps I should multiply the position in my frag shader by model view matrix such as:

vec3 s = normalize(vec3(Light.Position) - (u_ModelViewMatrix * vec4(pos, 1.0)));

Because I'm just passing it through my geom buffer shader unchanged:

Position = in_Position;

EDIT: The shading still changes when the camera moves. If I turn around from origin in the scene and start tilting down, the floor and everything just turns black. And actually i think putting the inverse after the transpose didn't actually change a thing.

#3rocklobster

Posted 04 December 2012 - 02:34 AM

Ok I've changed my normal matrix to

m_graphics->SetUniform(id, "u_NormalMatrix", 1, false,
	glm::inverse(glm::transpose(glm::mat3(glm::vec3(viewMatrix[0]), g	lm::vec3(viewMatrix[1]), glm::vec3(viewMatrix[2])))));

and the light is

glm::vec4 lightPosViewSpace = glm::inverse(g->GetViewMatrix()) * glm::vec4(-50.0f, 150.0f, 30.0f, 1.0f);
g->SetUniform(id, "Light.Position", lightPosViewSpace);

Perhaps I should multiply the position in my frag shader by model view matrix such as:

vec3 s = normalize(vec3(Light.Position) - (u_ModelViewMatrix * vec4(pos, 1.0)));

Because I'm just passing it through my geom buffer shader unchanged:

Position = in_Position;

EDIT: The shading still changes when the camera moves. If I turn around from origin in the scene and start tilting down, the floor and everything just turns black.

#2rocklobster

Posted 04 December 2012 - 02:32 AM

Ok I've changed my normal matrix to

m_graphics->SetUniform(id, "u_NormalMatrix", 1, false,
	glm::inverse(glm::transpose(glm::mat3(glm::vec3(viewMatrix[0]), g	lm::vec3(viewMatrix[1]), glm::vec3(viewMatrix[2])))));

and the light is

glm::vec4 lightPosViewSpace = glm::inverse(g->GetViewMatrix()) * glm::vec4(-50.0f, 150.0f, 30.0f, 1.0f);
g->SetUniform(id, "Light.Position", lightPosViewSpace);

Perhaps I should multiply the position in my frag shader by model view matrix such as:

vec3 s = normalize(vec3(Light.Position) - (u_ModelViewMatrix * vec4(pos, 1.0)));

Because I'm just passing it through my geom buffer shader unchanged:

Position = in_Position;

#1rocklobster

Posted 04 December 2012 - 02:17 AM

Ok I've changed my normal matrix to

m_graphics->SetUniform(id, "u_NormalMatrix", 1, false,
    glm::inverse(glm::transpose(glm::mat3(glm::vec3(viewMatrix[0]), g    lm::vec3(viewMatrix[1]), glm::vec3(viewMatrix[2])))));

and the light is

glm::vec4 lightPosViewSpace = g->GetViewMatrix() * glm::vec4(-50.0f, 150.0f, 30.0f, 1.0f);
g->SetUniform(id, "Light.Position", lightPosViewSpace);

Perhaps I should multiply the position in my frag shader by model view matrix such as:

vec3 s = normalize(vec3(Light.Position) - (u_ModelViewMatrix * vec4(pos, 1.0)));

Because I'm just passing it through my geom buffer shader unchanged:

Position = in_Position;

PARTNERS