• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


  • Content count

  • Joined

  • Last visited

Community Reputation

117 Neutral

About ChobitsTheZero

  • Rank

Personal Information

  • Interests
  1. OpenGL

    Okey so, I did what you said but it seems that there is also another problem which I can't really figure out what it is. So now there are shadows, but they dont seem to be at the correct position. Instead of being behind the models they are instead infront of them and slightly above them. I was thinking that maybe I had to multiple the vec4(vertexPos, 1) with model, but that also gave a weird result. #Edit: Nevermind I was able to solve it, appearantly the lightspacematrix had some issues with it.
  2. OpenGL

    I see! That really helps! I have kinda been short on time and really stressed due to exams so I basically has to rush through it all. But I shouldn't try to make excuses, I guess i'm just bad at understanding how excatly 3D programming works.
  3. I have been trying to implement shadows with the use of Shadowmapping in OpenGL. I sorta followed this tutorial https://learnopengl.com/#Advanced-Lighting/Shadows/Shadow-Mapping I have implemented the depthmap and have gotten it to render the depthmap. The problem I am having is when implementing the shadows. Now since this is part of a bigger project that uses Deferred Rendering, the code does not match the code in the tutorial but I am using the same concept. LightVertex shader:   #version 440 layout (location = 0) in vec3 vertexPos; layout (location = 1) in vec2 texCoords; out vec2 TexCoords; out vec4 FragPosLightSpace; uniform mat4 model; uniform sampler2D gPosition; uniform mat4 lightSpaceMatrix; void main() { gl_Position = vec4(vertexPos, 1.0f); TexCoords = texCoords; vec3 FragmentPos = vec3(model * texture(gPosition, texCoords)); FragPosLightSpace = lightSpaceMatrix * vec4(FragmentPos, 1.0); } LightFragment shader: #version 440 out vec4 FragColor; in vec2 TexCoords; in vec4 FragPosLightSpace; uniform sampler2D gPosition; uniform sampler2D gNormal; uniform sampler2D gAlbedoSpec; uniform sampler2D depthMap; struct Light { vec3 Position; vec3 Color; float Linear; float Quadratic; }; const int NR_LIGHTS = 32; uniform Light lights[NR_LIGHTS]; uniform vec3 viewPos; float ShadowCalculation(vec4 fragPosLightSpace) { //Perform perspective divide vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; //Transform to [0,1] range projCoords = projCoords * 0.5 + 0.5; //Get closest depth value from light's perspective (using [0,1] range fragPosLight as coords) float closestDepth = texture(depthMap, projCoords.xy).r; //Get depth of current fragment from light's perspective float currentDepth = projCoords.z; //Check wheter current frag pos is in shadow float shadow = 0.0; if(currentDepth > closestDepth) { shadow = 1.0; } return shadow; } void main() { // Retrieve data from G-buffer vec3 FragPos = texture(gPosition, TexCoords).rgb; vec3 Normal = texture(gNormal, TexCoords).rgb; vec3 color = texture(gAlbedoSpec, TexCoords).rgb; float Specular = texture(gAlbedoSpec, TexCoords).a; float shadow = ShadowCalculation(FragPosLightSpace); vec3 lighting = vec3(0.1 + (1.0-shadow),0.1 + (1.0-shadow),0.1 + (1.0-shadow)); vec3 viewDir = normalize(viewPos - FragPos); for(int i = 0; i < NR_LIGHTS; ++i) { vec3 lightDir = normalize(lights[i].Position - FragPos); vec3 diffuse = max(dot(Normal, lightDir), 0.0) * color * lights[i].Color; // Specular vec3 halfwayDir = normalize(lightDir + viewDir); float spec = pow(max(dot(Normal, halfwayDir), 0.0), 16.0); vec3 specular = lights[i].Color * spec * Specular; // Attenuation float distance = length(lights[i].Position - FragPos); float attenuation = 1.0 / (1.0 + lights[i].Linear * distance + lights[i].Quadratic * distance * distance); diffuse *= attenuation; specular *= attenuation; lighting += diffuse + specular; } lighting * color; FragColor = vec4(lighting, 1.0f); float depthValue = texture(depthMap,TexCoords).r; // Test depthmap //FragColor = vec4(vec3(depthValue),1.0); } The ShadowCalculation is the function that calculates if a position is in shadows or not. And it pretty much follows the same concept as the tutorial does. Now if I run all this, all I get is a white screen, I thought it might be because I had the setting of shadow wrong so I tried setting float shadow = 1.0 and then in the if-statement setting shadows to 0.0. Now I dont get a completly white screen but the shadows are not showing. I feel like I am close to a solution but have kinda gotten stuck right now and would appreciate if someone could tell me what the problem is or could be.
  4.   How would I determine which triangle of the quad the camera is in?
  5. So I have rendered a terrain based on a heightmap. It's based on this tutorial that I followed - http://www.mbsoftworks.sk/index.php?page=tutorials&series=1&tutorial=8   Now I want to have my camera to be able to "walk" on the terrain. The getY() function gets the x and z coordinates of the camera, and I understand that with those I have to find the closest vertices of the terrain to decide which triangle the camera is over. The thing is i'm unsure of how to actually do that, I have looked for a lot of examples on google but haven't been able to find any concrete answers for it. Currently my code looks like this: HM_SIZE_X and HM_SIZE_Y are both 6       float Terrain::getY(int x, int z)     {          //return     }          void Terrain::createTerrain()     {     glClearColor(0.0f, 0.0f, 0.0f, 1.0f);          // Setup heightmap          glGenVertexArrays(1, &uiVAOHeightmap); // Create one VAO     glGenBuffers(1, &uiVBOHeightmapData); // One VBO for data     glGenBuffers(1, &uiVBOIndices); // And finally one VBO for indices          glBindVertexArray(uiVAOHeightmap);     glBindBuffer(GL_ARRAY_BUFFER, uiVBOHeightmapData);          float fHeights[HM_SIZE_X*HM_SIZE_Y] =     {     10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f,     5.0f, 5.0f,5.0f, 10.0f, 10.0f, 10.0f,     5.0f, 5.0f, 5.0f, 10.0f, 10.0f, 10.0f,     5.0f, 5.0f, 10.0f, 10.0f, 10.0f, 10.0f,     10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f,     10.0f, 5.0f, 5.0f, 5.0f, 5.0f, 10.0f,     };          float fSizeX = 100.0f, fSizeZ = 100.0f;          for (int i = 0; i<HM_SIZE_X*HM_SIZE_Y;i++)     {     for (int j = 0; j < HM_SIZE_X*HM_SIZE_Y; j++)     {     float column = float(i%HM_SIZE_X), row = float(i / HM_SIZE_X);     vHeightmapData[i] = glm::vec3(     -fSizeX / 2 + fSizeX*column / float(HM_SIZE_X - 1), // X Coordinate     fHeights[i], // Y Coordinate (it's height)     -fSizeZ / 2 + fSizeZ*row / float(HM_SIZE_Y - 1) // Z Coordinate     );     }     }          glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3)*HM_SIZE_X*HM_SIZE_Y, vHeightmapData, GL_STATIC_DRAW);     glEnableVertexAttribArray(0);     glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);          glGenBuffers(1, &uiVBOIndices);     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, uiVBOIndices);     int iIndices[] =     {     0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 36,     6, 12, 7, 13, 8, 14, 9, 15, 10, 16, 11, 17, 36,     12, 18, 13, 19, 14, 20, 15, 21, 16, 22, 17, 23, 36,     18, 24, 19, 25, 20, 26, 21, 27, 22, 28, 23, 29, 36,     24, 30, 25, 31, 26, 32, 27, 33, 28, 34, 29, 35     };     glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(iIndices), iIndices, GL_STATIC_DRAW);     glEnable(GL_PRIMITIVE_RESTART);     glPrimitiveRestartIndex(HM_SIZE_X*HM_SIZE_Y);     }