Jump to content

  • Log In with Google      Sign In   
  • Create Account

rafciok_6

Member Since 27 Mar 2013
Offline Last Active Jun 24 2014 02:46 PM

Topics I've Started

Web History Information

22 March 2014 - 04:01 PM

Hello guys.

I would like to ask you about any book title or online resources where I can find information about history of the scripting languages and server-sidde technologies from the early days.

Thanks for any sugestions.


GLSL Lighting

26 February 2014 - 10:14 PM

I have a problem with my per vertex diffuse lighting implementation. I cannot find the problem. tried everything. Maybe someone can help.

Here is the code.

 

Here is how I calculate normals for every point and store it in vbo 


 

 

 
//Normals
glGenBuffers(1, &m_vbo_normals); 
glBindBuffer(GL_ARRAY_BUFFER, m_vbo_normals); 
for (int i = 0; i < 24; i += 3)
{
 
glm::vec3 normal = glm::normalize(glm::cross(glm::vec3(corners[indices[i + 1]]) -
glm::vec3(corners[indices[i]]), glm::vec3(corners[indices[i + 2]]) -
glm::vec3(corners[indices[i]])));
 
normals[i] = normal.x; 
normals[i + 1] = normal.y; 
normals[i + 2] = normal.z;
}
glBufferData(GL_ARRAY_BUFFER, 24 * sizeof(float), normals, GL_STATIC_DRAW); 
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(2);

 

Vertex.vert


 

#version 150 core
 

uniform mat4 modelview, projection;

uniform mat3 normalMatrix;
uniform vec3 lightPos;
uniform vec3 lambient;
uniform vec3 ldiffuse;
 
in vec4 position;
in vec3 normal;
in vec3 inColour; 
 
out vec3 outColour;
 
 
void main()
{
gl_Position = projection*modelview*position;
vec3 ambient = inColour * lambient;
 
//current position of the vertex 
vec3 pos =  vec3(modelview * position);
vec3 n = normalize(normalMatrix * normal);
 
//vector to pointing to the light pos 
vec3 I = normalize(lightPos - pos);
 
float dcont = max(0.0, dot(n, I));
vec3 diffuse = dcont * inColour * ldiffuse;
 
 
 
outColour = diffuse;
}
 

 

fragmet.frag


 

#version 150 core
 

in vec3 outColour;

  
out vec3 outFrag;
 
void main()
{
outFrag =  outColour;
}
 

and here is how I calculate normalMatrix and send uniform variables


 

glTranslatef( 0.0, 0.0, -2.0 );

glRotatef( m_euler[0], 1.0, 0.0, 0.0 );
glRotatef( m_euler[1], 0.0, 1.0, 0.0 );
glRotatef( m_euler[2], 0.0, 0.0, 1.0 );
 
glGetFloatv( GL_MODELVIEW_MATRIX, modelview );
glGetFloatv( GL_PROJECTION_MATRIX, projection);
 
glUniformMatrix4fv( m_uniform_modelview, 1, GL_FALSE, modelview );
glUniformMatrix4fv( m_uniform_projection, 1, GL_FALSE, projection );
glm::mat3* MV = new glm::mat3 (modelview[16]);
setUniform(m_shader, "normalMatrix", -glm::transpose(glm::inverse(*MV)));
 
 
glUniform3f(glGetUniformLocation(m_shader->GetProgramHandle(), "lambient"), 1.0, 1.0, 1.0);
glUniform3f(glGetUniformLocation(m_shader->GetProgramHandle(), "ldiffuse"), 1.0, 1.0, 1.0);
glUniform3f(glGetUniformLocation(m_shader->GetProgramHandle(), "lightPos"), 1.0, 1.0, 1.0);
glUniform3f(glGetUniformLocation(m_shader->GetProgramHandle(), "direction"), 1.0, 1.0, 0.0);

 

Thank you for help. 


GLSL

25 February 2014 - 10:04 AM

Hello 

I am using GLSL 1.5 trying to calculate per vertex lighting, and my problem is I do not really know how to calculate the normal for every vertex. Should I do it in vertex shader or I should do it in main OpenGL program and pass this value into the shader. In previous version there was gl_Normal defined value which is deprecated in 1.5 version. I will be very happy if someone can explain me this.  

Thank you for help. 


Changing stat in game XNA

30 April 2013 - 09:39 AM

Hello 

I am working on my 2D game in XNA but I stuck in one point. When I lose all lives in the game Game Over screen appear than I go back to the Main Menu, but when I want to start game again I go back to the point in the game when I lost. My question is maybe you guys know if XNA provide any function which will allows reset  everything ( all objects) to the start position. I mean to the position where was created on the beginning.

Thank You for any suggestion    


XNA Collision Detection Help

21 April 2013 - 11:46 AM

Hello 

I need help with my code. I am just a beginner  . I try to find if two object are collide and change position one of them, if someone know what I do wrong  please help .


PARTNERS