• 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.

Ashaira

Members
  • Content count

    26
  • Joined

  • Last visited

Community Reputation

105 Neutral

About Ashaira

  • Rank
    Member
  1. Well it seems i am lacking some very basic knowledge regarding c++ and a friend of mine told me i seem to not understand the hardware part of how programming and memory works and that understanding how the assembler works would help me cement and connect what i already know. (consider that when i saw square(3++); i thought 4 would be sent as a parameter i tend to agree with him) so does anyone know where i could learn about how assembler works? i dont want to learn to code in it just understand the principles of how it does things.
  2. so i thought i understood how FBO work but it seems not. ive been trying to render to a FBO and then using the texture to render a quad that i will use for post processing effects. I went through several tutorials and everything "seems" right but then again it always does. This is how i implemented my FBO in the scene manager constructor [CODE] glGenRenderbuffers(1, &RBO); // Generate one render buffer and store the ID in fbo_depth glBindRenderbuffer(GL_RENDERBUFFER, RBO); // Bind the fbo_depth render buffer glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 1024, 780); // Set the render buffer storage to be a depth component, with a width and height of the window glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, RBO); // Set the render buffer of this buffer to the depth buffer glBindRenderbuffer(GL_RENDERBUFFER, 0); // Unbind the render buffer glGenTextures(1, &FBO_Texture); // Generate one texture glBindTexture(GL_TEXTURE_2D, FBO_Texture); // Bind the texture fbo_texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 780, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); // Create a standard texture with the width and height of our window // Setup the basic texture parameters glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Unbind the texture glBindTexture(GL_TEXTURE_2D, 0); glGenFramebuffers(1, &FBO); // Generate one frame buffer and store the ID in fbo glBindFramebuffer(GL_FRAMEBUFFER, FBO); // Bind our frame buffer glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, FBO_Texture, 0); // Attach the texture fbo_texture to the color buffer in our frame buffer glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, RBO); // Attach the depth buffer fbo_depth to our frame buffer /*switch (glCheckFramebufferStatus(GL_FRAMEBUFFER)){ case GL_FRAMEBUFFER_COMPLETE: std::cout << "Complete." << std::endl; break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: std::cout << "Incomplete Attachment" << std::endl; break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: std::cout << "Incomplete Missing Attachment" << std::endl; break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: std::cout << "Not all attached images have the same width and height." << std::endl; break; case GL_FRAMEBUFFER_UNSUPPORTED: std::cout << "Framebuffer Unsupported" << std::endl; break; }*/ glBindFramebuffer(GL_FRAMEBUFFER, 0); [/CODE] this should be ok as i have used glCheckFramebufferStatus and it didnt return any errors. now for the rendering. This is the draw call in my scene manager (which works fine if i remove the FBO so the error cant be in a diff place) [CODE] glViewport ( 0, 0, esContext->width, esContext->height ); // Clear the color buffer glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); for(int j=0; j<Resources->ShaderNum ; j++) { userData->programObject = Resources->Programs[j]; glUseProgram ( Resources->Programs[j] ); for(int i=0; i<ObjectsLoaded; i++) { if(GameObjects[i]->shader == j+1) { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); if(Resources->Shaders[j].Culling && Culling == false) { glEnable(GL_CULL_FACE); glCullFace(GL_BACK); Culling = true; } if(Resources->Shaders[j].Blending && Blending == false) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Blending = true; } glBindFramebuffer(GL_FRAMEBUFFER, FBO); GameObjects[i]->Draw(esContext); if(Culling == true) { glDisable(GL_CULL_FACE); Culling = false; } if(Blending == true) { glDisable(GL_BLEND); Blending = false; } } } } eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); glBindFramebuffer(GL_FRAMEBUFFER, 0); // unbind // Clear the color buffer glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); userData->programObject = Resources->PostProcessingPrograms[0]; Quad->Draw(esContext); [/CODE] and this is what the post processing quad draw call looks like [CODE] GLfloat vVertices[] = { 512.0f, 390.0f, 0.0f, -512.0f, 390.0f, 0.0f, -512.0f, -390.0f, 0.0f, 512.0f, -390.0f, 0.0f}; GLfloat vTexCoord[] = { 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}; // Use the program object glUseProgram ( userData->programObject ); glBindAttribLocation ( userData->programObject, 0, "vPosition" ); glBindAttribLocation ( userData->programObject, 1, "a_texCoord" ); glActiveTexture(GL_TEXTURE0 + 1); Texture_Uniform_Loc = glGetUniformLocation ( userData->programObject, "texture1" ); glBindTexture(GL_TEXTURE_2D, Scene->FBO_Texture); glUniform1i(Texture_Uniform_Loc, 1); // Load the vertex data glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices ); glEnableVertexAttribArray ( 0 ); glVertexAttribPointer ( 1, 3, GL_FLOAT, GL_FALSE, 0, vTexCoord ); glEnableVertexAttribArray ( 1 ); glDrawArrays ( GL_TRIANGLES, 0, 3 ); eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); [/CODE] there are no errors but everything on the screen is just black. i tried making the quad smaller reversing the vertex order (Clockwise and CounterClockwise) i tried using the perspective matrix and rotated around to try and find the quad in case i misplaced it but nothing works the screen just stays black. im pretty sure im simply not rendering to the FBO right or im not applying the texture to the quad right but im not sure what i did wrong. Any help would be greatly appreciated.
  3. Im fairly new to this as well but when i was messing around with lighting in opengl es everything was messed up because i was doing calculations for the normals in diff space. so i made sure that everything was in the same space (i used worldspace for mine). try to go through ur shader and make sure ur calculations are done in the same space and make sure u normalize in the vertex shader AND in the fragment shader. hope it helps. EDIT: upon further consideration i think u may be rotating the light together with the cube which is why the light stays on the same face (used to happen to me all the time as i kept messing up the push pop matrix order)
  4. EDIT: NVM i figured it out during the weekend.
  5. [quote name='pcmaster' timestamp='1333715147' post='4928755'] Frame Buffer Object really represents just a view of a texture (or a part of a texture). A texture is an array of texels. Not only in DirectX it is called "Render Target" and it really is the same concept. All rendering always DOES go into "textures". Forget about the concept of a "screen", think the way the card thinks: "Give me some rectangular target array and I'll happily apply a pixel shader to each of its fragments". Your application can then present this texture to the user ("send it to screen", which usually DOES involve copying it via "CPU" into a widget or window canvas or whatever, automatically (swap-chain) or manually), or do some more processing, or store it to disk, or whatever. The OpenGL terminology actually is way more complicated than what I've just presented, study it thoroughly here: [url="http://www.opengl.org/wiki/Framebuffer_Object"]http://www.opengl.or...mebuffer_Object[/url] [url="http://www.songho.ca/opengl/gl_fbo.html"]http://www.songho.ca...ngl/gl_fbo.html[/url] A short answer to the difference between GL FBO and RBO: There is one active FBO that is the target of all rendering output and it might "contain" several target textures - a colour, another colour texture, maybe yet another texture to store anything auxiliary, a depth (all these are called FB attachments)... You can attach basically "any" number of any textures or RBOs to a FBO at once. A RBO is a single texture and is one of attachments to a FBO. A RBO content can be modified exclusively by rendering to it while attached to a FBO (possibly with other RBOs or textures or not). RBO content can then be copied to another texture (so called "unpacking"). RBO doesn't have mip-maps. RBO cannot be pre-initialised with any pixel data. I'd use a RBO as a depth buffer (Z-buffer). An ordinary OpenGL texture can have mip-maps and any of its mip-slices can indeed serve the very same purpose as a RBO, that is serve as a render target. Also, ordinary textures can serve as "sources" of data in your shaders (actual surface-modifying colour data, normals or anything at all). RBOs are "destination-only". And FBOs, again, encapsulate various textures and/or RBOs and as such don't posses any own data. Complicated, huh? [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] [/quote] im starting to get the "picture" now if u know what i mean but one more question. most of the examples i find are in linear programing so my question is should i make an FBO for each texture the same way you make a VBO for each model or make one for all the textures?(which thinking about it makes no sense but just to be sure)
  6. I need to add frame buffer objects and render buffer objects to my engine but i am having trouble understanding how they work. Ive done some image processing at university which was basically applying algorithms on the image loaded. I thought at first that FBO basically meant rendering to it first applying said post processing algorithm then send the result to the screen. I think i am missunderstanding how post processing effects work. i looked at a few FBO tutorials and basically only the textures are sent to it not the actual "screen" as an image. Does that mean that the effects are applied to the textures and then the textures are sent to the objects from the FBO? and what are the render buffer objects for then if the texture is sent to the FBO?
  7. [quote name='Martins Mozeiko' timestamp='1333696244' post='4928693'] Doesn't the error log mention line number in shader source where the error is? [/quote] mine always says line 1 so.......
  8. [quote name='RobinsonUK' timestamp='1333643756' post='4928524'] [color=#000000]vec3 lightPos [/color][color=#666600]=[/color][color=#000000] [/color][color=#666600]([/color][color=#000000]matWorld [/color][color=#666600]*[/color][color=#000000] vec4[/color][color=#666600]([/color][color=#006666]0.0[/color][color=#666600],[/color][color=#006666]1000.0[/color][color=#666600],[/color][color=#006666]1000.0[/color][color=#666600],[/color][color=#006666]1.0[/color][color=#666600]).[/color][color=#000000]xyz[/color] [color=#000000]I'm sure you need another closed bracket there.[/color] [/quote] "facepalm.jpg" um im just go over to that corner and hang myself. ty for the help.
  9. I'm working on adding normal map lighting to my terrain shader and for some reason i get a syntax error when it compiles but i cant find whats wrong with it. i added a total of nor more than 15 lines from the previous ver which compiled and worked fine. this is what it looks like with the modifications for the normal map. [code]# Vertex Shader Start uniform mat4 u_MVP; attribute vec3 aPosition; varying vec3 vPosition; attribute vec2 a_texCoord; varying vec2 v_texCoord; attribute vec3 a_Tangents; varying vec3 v_Tangents; attribute vec3 a_Bitangents; varying vec3 v_Bitangents; uniform mat4 matWorld; uniform vec3 CameraPos; varying float v_eyeDist; uniform sampler2D texture5; attribute vec3 a_Normals; varying vec3 v_Normals; varying vec3 v_viewDirection; varying vec3 v_lightDirection; void main() { vPosition = aPosition; v_texCoord = a_texCoord; v_Normals = normalize(vec3(matWorld * vec4(a_Normals, 0.0))); vec4 tmp5 = texture2D(texture5,v_texCoord); vPosition.y = vPosition.y + ((tmp5.r + tmp5.g*2.0 + tmp5.b*3.0)/10.0) * 20.0; vec4 vWorldPos = matWorld * vec4(vPosition,1.0); v_eyeDist = sqrt( (vWorldPos.x - CameraPos.x) * (vWorldPos.x - CameraPos.x) + (vWorldPos.y - CameraPos.y) * (vWorldPos.y - CameraPos.y) + (vWorldPos.z - CameraPos.z) * (vWorldPos.z - CameraPos.z) ); vec3 viewDirectionWorld = vWorldPos.xyz - vPosition; vec3 lightPos = (matWorld * vec4(0.0,1000.0,1000.0,1.0).xyz; vec3 lightDirection = lightPos - vPosition; mat3 tangentMat = mat3(a_Tangents,a_Bitangents,a_Normals); v_viewDirection = viewDirectionWorld * tangentMat; v_lightDirection = lightDirection * tangentMat; gl_Position = u_MVP * vec4(vPosition,1.0); } # Vertex Shader End # Fragment Shader Start precision highp float; varying vec2 v_texCoord; uniform sampler2D texture1; uniform sampler2D texture2; uniform sampler2D texture3; uniform sampler2D texture4; uniform sampler2D texture6; varying vec3 v_Normals; varying vec3 v_viewDirection; varying vec3 v_lightDirection; varying float v_eyeDist; float computeLinearFogFactor() { float u_fogMaxDist = 10.0; float u_fogMinDist = 1.0; float factor; factor = (v_eyeDist - u_fogMinDist) /(u_fogMaxDist - u_fogMinDist ); factor = clamp(factor, 0.0, 1.0); return factor; } void main() { vec4 u_fogColor = vec4(0.7,0.7,0.7,1.0); float fogFactor = computeLinearFogFactor(); vec4 tmp1 = texture2D(texture1,v_texCoord*32.0); vec4 tmp2 = texture2D(texture2,v_texCoord*32.0); vec4 tmp3 = texture2D(texture3,v_texCoord*32.0); vec4 tmp4 = texture2D(texture4,v_texCoord); float factor = 1.0 / ( tmp4.x + tmp4.y + tmp4.z ); vec4 tmp = vec4( (tmp1.rgb * tmp4.x + tmp2.rgb * tmp4.y + tmp3.rgb * tmp4.z) * factor, 1.0 ); vec4 lightColor = vec4(1.0,1.0,1.0,1.0); vec4 normal = texture2D(texture6, v_texCoord); normal = normalize(normal * 2.0 - 1.0); vec3 lightDirection = normalize(v_lightDirection); vec3 viewDirection = normalize(v_viewDirection); float nDotL = dot(normal.xyz, lightDirection); vec3 reflection = (2.0 * normal.xyz * nDotL) - lightDirection; float rDotV = max(0.0, dot(reflection, viewDirection)); vec4 ambient = lightColor * tmp; vec4 diffuse = lightColor * nDotL * tmp; vec4 specular = lightColor * pow(rDotV, 2.0); vec4 FinalColor = diffuse + specular + ambient; gl_FragColor = fogFactor * u_fogColor + (1.0 - fogFactor) * FinalColor; } # Fragment Shader End [/code] and these are the lines that where added and are probably causing the error. [code] vec3 viewDirectionWorld = vWorldPos.xyz - vPosition; vec3 lightPos = (matWorld * vec4(0.0,1000.0,1000.0,1.0).xyz; vec3 lightDirection = lightPos - vPosition; mat3 tangentMat = mat3(a_Tangents,a_Bitangents,a_Normals); v_viewDirection = viewDirectionWorld * tangentMat; v_lightDirection = lightDirection * tangentMat;[/code] [code] vec4 lightColor = vec4(1.0,1.0,1.0,1.0); vec4 normal = texture2D(texture6, v_texCoord); normal = normalize(normal * 2.0 - 1.0); vec3 lightDirection = normalize(v_lightDirection); vec3 viewDirection = normalize(v_viewDirection); float nDotL = dot(normal.xyz, lightDirection); vec3 reflection = (2.0 * normal.xyz * nDotL) - lightDirection; float rDotV = max(0.0, dot(reflection, viewDirection)); vec4 ambient = lightColor * tmp; vec4 diffuse = lightColor * nDotL * tmp; vec4 specular = lightColor * pow(rDotV, 2.0); vec4 FinalColor = diffuse + specular + ambient; [/code] can anyone see where the problem might be? or at least hint me as to what exactly the error is about cause i sure as hell checked all the ;
  10. sry to bring this up again but ive been looking at some examples. are the Normals in my model file the same thing as the normals obtained throught the cross product of the tangent and bitangent?
  11. [quote name='doeme' timestamp='1333617433' post='4928427'] [quote name='Ashaira' timestamp='1333616975' post='4928425'] right and then u can go ahead and face my boss when she sees i used stl again. [/quote] I will gladly do that, because I think your boss needs some pretty good arguments for this [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] But let's keep the STL-yes-or-no-discussion aside. I meant no offense to you, I just trying to keep people from reinventing the wheel. [/quote] no worries. i uped ur solution anyway as it is good just not in my case currently. EDIT. btw one funny thing i heard regarding STL. someone did a check on one of the projects and it had 12000 buffers set out of which 7000 were 4 bytes big. )
  12. Well i hope this is the right section. I need to calculate the tangent and bitangent for my models and i have found an algorithm to do it but i havent been able to fully understand on what to apply the algorithm. in some places it says to do it for each face others to go through all the verts of the model and do it. so which is the right way? do it for the 3 verts of each face? and if that is the case what happens when one vert is in more than one face?
  13. [quote name='doeme' timestamp='1333616773' post='4928424'] Why don't you use std::vectors (or any other STLcontainer)? With it you easily can achieve the same and if you preallocate space the objects will most likely stored in the same way as your array. [/quote] right and then u can go ahead and face my boss when she sees i used stl again.
  14. Well since you've all been so helpfull might as well ask for ur help once again. Until yesterday i was using a fixed array of pointers for loading game objects but now i wanted to make it dynamic. I searched how to do it and found a way which should be correct however something happens and the pointers lose their data. I made sure to run step by step when they are filled with data and that is done right, during loading everything seems to be fine but when accessing the objects update function it crashed with an access violation error. I put in a break point and to my surprise the objects were empty. none of the variables had any values. this is how i used the array of pointers before when it was working. [code]CGameObject *GameObjects[50]; GameObjects[tmpID-1] = new CGameObject(vec3(tmpPosX,tmpPosY,tmpPosZ),vec3(tmpRotX,tmpRotY,tmpRotZ),vec3(tmpScaleX,tmpScaleY,tmpScaleZ),tmpModel,tmpTexture1,tmpTexture2,tmpTexture3,tmpTexture4,tmpShader,Resources->Models[tmpModel-1].model);[/code] but now i used this [code]CGameObject **GameObjects; GameObjects = new CGameObject *[ObjectsLoaded]; GameObjects[tmpID-1] = new CGameObject(vec3(tmpPosX,tmpPosY,tmpPosZ),vec3(tmpRotX,tmpRotY,tmpRotZ),vec3(tmpScaleX,tmpScaleY,tmpScaleZ),tmpModel,tmpTexture1,tmpTexture2,tmpTexture3,tmpTexture4,tmpShader,Resources->Models[tmpModel-1].model);[/code] i cant understand how it can load the data to the objects corectly but lose it somewhere along the line. i even removed any code that was deleting the objects just to make sure. Did i implement the pointer array wrong? EDIT: well this is embaressing. i had the memory alocation in the same loops as the object constructing so i was overwriting the pointers...... hehe sry about the bother.
  15. oh. riiiiiiiiiiight. thnx a lot. forgot i had to define them without the extern. i was just constructing them in the cpp without defining them. thnx a lot. works perfectly. "Dam whoever invented singleton"