• Content count

  • Joined

  • Last visited

Community Reputation

635 Good

About cebugdev

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

8864 profile views
  1. hi guys, are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well. Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic let me know if you guys have recommendations. Thank you in advance!
  2. oh god youre correct, silly me, i originally thought that the last parameter is for the number of data. Thanks man!
  3. im trying to test GL_Line strip by drawing line strips between points and it always starts at 0,0 even i start to draw at the middle of the screen. i simplified my test data to just draw two points but still the same. the result is the line is drawn from 0,0 to any points in my vertices. Im using orthographic projection and pases 2D vectors to my shaders to draw it on 3D, but that is not the concern. here is my non simplified testing: im trying to draw linestrips using mouse, but it always starts at 0,0 Here is the code (the simplified version/first image) float vertices[] = { SCR_WIDTH/2,SCR_HEIGHT/2, SCR_WIDTH,SCR_HEIGHT, }; unsigned int VBO = 0; unsigned int VAO = 0; glGenBuffers(1, &VBO); glGenVertexArrays(1, &VAO); glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(float), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0); glEnableVertexAttribArray(0); glDrawArrays(GL_LINE_STRIP, 0, 4); Im using OpenGL 3.1 right now on desktop as i am writing a code that will be ported to OpenGL ES 2.0 after i write it in desktop, (android studio is slow so i do my opengl coding in Visual Studio)
  4. the project im working now is not a game, originally everything is rendered in 2D using opengl orthographic projection, inputs are specified a 2D X, Y coordinates in screen space, and it will be positioned there like how UI are positioned in games, it is just lately that they want to put a 3D rotation feature on those 2D elements without breaking the original specification that the user must specify a 2D coordinates to place an object in the screen, since you cannot perform the full rotation specially rotating in Y axis in an orthographic projection, i "enabled" the 3D mode by providing the view and projection matrix while gettinga 2D coordinates as input. hope i explained it clear.
  5. Nevermind, solved it. i set my near clipping plane to 1.0f instead of 0.1f, my old clipping plane is just too close that the object is not visible anymore, everything works fine!
  6. Hi all, a little background, our current opengl based system uses 2D orthographic projection to draw 2D elements into screen like adding images, texts, etc. When adding objects, coordinates are specified in screen coordinates (top left is 0,0 and bottom right is width, height), for the upcoming upgrade, we want to add rotation feature to these objects, however we cant do that using orthographic projection, so what i did is to add a perspective as well as a camera matrix to draw the object in 3D and add rotation, but if we do it in 3D then it takes a 3D coordinate and not the screen space coordinate which is not the specification, so what i did is, accept the 2D X,Y coordinate as input, unProject it and use the result as my new base X, Y coordinate for my object, my problem is i cannot seem to make to make it work here is the code (stripped down for simplicty): // Projection matrix 4:3 ratio glm::mat4 projectionMatrix = glm::perspective(glm::radians(45.0f), 4.0f / 3.0f, 0.1f, 100.0f); // Camera matrix glm::mat4 viewMatrix = glm::lookAt( glm::vec3(0, 0, 5), // Camera is at 0,0,5 in World Space, our triangle is at 0 z axis glm::vec3(0, 0, 0), // and looks at the origin glm::vec3(0, 1, 0) // Head is up (set to 0,-1,0 to look upside-down) ); glm::mat4 model = glm::mat4(1.0f); //identity // sample Rectangle input (X, Y, X2,Y2) in screen space is (0,0,100,100) i set 0 for Z as screen space does not have a Z glm::vec3 un = glm::unProject(glm::vec3(0, 0, 0), viewMatrix, projectionMatrix, viewport); glm::vec3 un_2 = glm::unProject(glm::vec3(100, 100, 0), viewMatrix, projectionMatrix, viewport); // Result // un : un = {x=-0.0552284457 y=-0.0414213315 z=4.90000010 ...} // un_2: un_2 = {x=-0.0414213352 y=-0.0276142210 z=4.90000010 ...} So the plan here is to use the unprojected result to construct a triangle and apply transformation such as rotation without breaking the existing code that accepts 2D space as coordinate. so in summary is accept 2D coordinates and draw a 3D object on that area with transformation. on the above code, it looks like the result is in the near clipping plane and when i draw a rectangle using those points, it is not visible on the screen (camera is at Z=5 position). any idea on how to do this? i know that Z is a player here somewhere but i dont know how. like the Z on the above result is on the near clipping plane, i just want it to be visible on the screen and appear on the specific 2D spot. let me know if you have any ideas on how to work on this black magic of a problem, Thank you in advance
  7. Hi again, thanks to the good advise from the guys on this thread thanks guys! I have my basic 2D GUI working now, buttons, windows/dialogs and sliders are working, now i want to port my scrollbox, listview controls to OpenGL, unfortunately i dont have an idea on how 'clipping' a rendered object works, in 2D canvas such as in 2D SDL or javascript canvas, what i did is for example on listview/listbox control, i draw all items in an offscreen canvas, and just Blit copy the visible area to screen based on the amount it was scrolled. Since i dont think OpenGL has the BlitBlk style of partial rendering a texture/canvas, how should i approach implementing a control such as listview control? Background, i want a 2D GUI control where there will be items inside (like a listview) that hides/clip when scrolled based on scroll value, any tips on how to do this on OpenGL?
  8. hi all, i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only), i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse. now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about. 1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection? 2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension. 3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question). lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free, Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework. IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work. thank you, and looking forward to positive replies.
  9. @norrischiu Thank you for that detailed explnation, ive got a question, the Tangent (T) and bi-Tangent(B) vectors in the equation are expressed in object/local/model space and not tangent space correct?
  10. same thing, the article jumps directly to using the formula without explaining why the formula is like that. deltaPos1 = deltaUV1.x * T + deltaUV1.y * B deltaPos2 = deltaUV2.x * T + deltaUV2.y * B and as you can see from the formula on the article you shared and the ones on my original post, it is the same one.
  11. THanks for replying but unfortunately its far from the question i asked the one you posted is using DirectX and uses DirectX builtin function to compute tangent in a D3D Mesh. What i was asking is related to the math behind it.
  12. hi all, i have been trying to understand how to build the TBN matrix for normal mapping to change the space from tangent space to local/world space using TBN matrix, i have been to countless opengl sites but all i can see is the follow a standard formula described in similar fashion as to this link Archived version: which is the same formula pointed to by this book: Mathematics for 3D Game Programming and Computer Graphics which is more or less the same formula as described in tutorial for normal mapping:!Advanced-Lighting/Normal-Mapping The formula in question is: Q − P0 = (u − u0)T + (v − v0)B, or on some other site expressed as: E1=ΔU1T+ΔV1B E2=ΔU2T+ΔV2B or What i want to understand is HOW is that formula formulated and the reason/explanation behind it, i want to understand why the formula looks that way. All i see from these sites or even in youtube tutorials starts from that formula and derived the TBN Matrix from the above formula. I want to understand why the derivation of TBN matrix started from that formula and why. What is that formula and how was it formed. Is there anything math/calculus/linear algebra related things i need to understand on why that formula existed. (I'm sorry for asking questions like this, unlike other people i'd like to know the reason behind things and not just take whatever i read and follow with it. i want to learn ) Please do enlighten my innocent mind, Thank you in advance!
  13. hi math experts, i have a question and i need deep understanding of normal map TBN matrix generation formula. I see from lots of tutorials such as in or in ogldev!Advanced-Lighting/Normal-Mapping that the formula goes something like this. E1=ΔU1T+ΔV1B E2=ΔU2T+ΔV2B U1, U2, V1, V2 are texture coordinates T and B are Tangent and Bitangent vectors >> But i just dont understand how the above formula was created and why is the formula like that? I understand we need to get two vectors that is why the difference of U and V vectors are computed to form a vector, but i dont understand why it needs to be dot products to T and added to difference of V vectors and dot product to B. in summary, i dont fully understand the formula itself.. I need elementary explanation please
  14. Hi all, (i have not placed any tags or topic prefix coz i am asking in a general game dev point of view and not platform specific), we are planning to have monsters with tentacles or roots that will strike the current location/position of the player, my question is, how to handle such attack? does the strike animation will be exported together with the model and then just rotate the tentacle in the engine pointing to the position of the character and just play the animation? or does the actual attack animation is done in the engine itself? what ideas you guys have for this?   the game is in 3D.
  15. hi all, i have seen this video; and there is that sort of cinematic in 0:50 in the video, where a black rectangle swipe in and camera move to certain targen and swipe out type of 'cinematic', any suggestions/idea on how to do this in Unity? are there any resource, tutorials or any resources that discuss this subject?