# SetsudanHana

Member

10

1. ## opengl camera direction calculation for lookat

The way i'm doing lookat for my camera: void Camera::update() { double sinAlfa = glm::sin(m_alfa * DAG2RAD); double sinBeta = glm::sin(m_beta * DAG2RAD); double cosAlfa = glm::cos(m_alfa * DAG2RAD); double cosBeta = glm::cos(m_beta * DAG2RAD); m_viewMatrix = glm::lookAt( m_position, glm::vec3(m_position.x + sinAlfa*cosBeta, m_position.y - sinBeta, m_position.z - cosAlfa*cosBeta), glm::vec3(0.0f, 1.0f, 0.0f)); } just counting sin and cos function for each of angles of your camera, and with little math you can count point your camera is looking at. DAG2RAD is just pi/180 to convert my angle to radiants. I dont know if it solves your problem, but i hope it will help.
2. ## OpenGL Problem with Deffered Rendering

So i'm trying to implement deffered rendering in my first "graphic engine" using this tutorial: http://ogldev.atspace.co.uk/www/tutorial35/tutorial35.html . And got some issues with drawing my position and normal to the texture. I think i'm sending everything alright, cause before it worked normally with forward rendering. This is how it looks. Position: Normal:   Texture coords, diffuse and depth buffer are looking fine.   Here are my shaders for model geometry (for terrain it is similar, just with additional calculation)   VS: #version 400 layout(location = 1) in vec3 vertex_position; layout(location = 2) in vec2 vertex_texture; layout(location = 3) in vec3 vertex_normals; uniform mat4 pvw_matrix; uniform mat4 world; layout(location = 0) out vec2 texture_coords; layout(location = 1) out vec3 normals; layout(location = 2) out vec3 world_pos; void main() { vec4 tmp = (world * vec4(vertex_normals, 0.0)); normals = tmp.xyz; tmp = (world * vec4(vertex_position, 1.0)); world_pos = tmp.xyz; texture_coords = vertex_texture; gl_Position = pvw_matrix * vec4( vertex_position, 1.0 ); } FS: #version 400 layout(location = 0) in vec2 TexCoord; layout(location = 1) in vec3 Normal; layout(location = 2) in vec3 WorldPos; layout (location = 0) out vec3 WorldPosOut; layout (location = 1) out vec3 DiffuseOut; layout (location = 2) out vec3 NormalOut; layout (location = 3) out vec3 TexCoordOut; uniform sampler2D sampler; void main() { vec4 texel = texture(sampler, TexCoord); WorldPosOut = WorldPos; DiffuseOut = texel.xyz; NormalOut = normalize(Normal); TexCoordOut = vec3(TexCoord, 0.0); } Thanks for any clues, that will help me solve this riddle. I will paste more code if necessary. Link to my repo is here: https://github.com/SetsudanHana/Tsukuyomi---OpenGL-engine
3. ## Problem with Deffered Rendering

Sry i didnt answer, timezone...   But what about texture initializing, i did everything according to the tutorial and there was no line about setting any TexParameter. I checked out values in CodeX and you may be right about this filtering, i will try to save those textures as an image from my code and check results there.   And yeah i will have to think about optimalization, but now it is my least problem.

5. ## GLSL weird '<' syntax error in vertex shader

it works, i knew that it is something so simple... I'm just dumb
6. ## GLSL weird '<' syntax error in vertex shader

loadTextFile function: std::string ResourceManager::loadTextFile(const std::string& path) { std::ifstream file(path); if(!file.good()) { OutputDebugStringA("File not found"); return nullptr; } std::stringstream stream ; stream << file.rdbuf(); file.close(); return stream.str(); } i cant use cout, becuase i dont have console, but OutputDebugStringA on each of them gives this:     last line dont have '\n', thats why they looked merged   EDIT:   changing to multibyte, didnt do anything
7. ## GLSL weird '<' syntax error in vertex shader

Yeah, it is faster to ask on few sites.   Yes, i found this suggestion on stackoverflow, but it changed nothing
8. ## GLSL weird '<' syntax error in vertex shader

@mhagain   yes it is set up to unicode   @Ectara   i added '\0' by myself, and now it throws this one:       EDIT:   i changed every 1.0 to 1.0f in my shaders, and i'm back to my previous error
9. ## GLSL weird '<' syntax error in vertex shader

length() function is giving me valid value so i do think, they do have null terminator