Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

148 Neutral

About stonehat

  • Rank
  1. stonehat


    XXxX refers to the size of the buffer in bytes. If your vertex is a vec3, use sizeof(vec3) * number of your vertices for that parameter. a single element in vec3 is a float which is 4 bytes, so 3 floats is 12.
  2. stonehat

    High Speed Collision Detection

    For the object that move so fast it tunnels, you check whether it intersects with the hit box(assumed only one) in the scene If it does, store the distance from the object to the intersection point. If your algorithm can't provide the contact point, simply get the length of the vector from the position of the object, to the position of the hit box. It may not be accurate, but your object gets faster the longer it travels. I think it won't make any difference.    In the next frame, do the same intersection test. If it doesn't intersect(the hit box moves away), discard the distance stored. But if it does, check if the current position of the object is greater than the intersection point. The concept is that if the object is beyond the hit box while the algorithm returns true(meaning the object hits the hit box), it not only intersects the box but also is already beyond it. This could possibly solve the tunneling problem.
  3. I have used Phong and Blinn-Phong models for quite a while. Just doubt those games nowadays use lighting model as simple as Phong Shading.
  4. The tutorials found online teaches Phong Shading model. Is that one of the oldest techniques? In modern games, what kind of lighting model do they use? Are diffuse, specular, reflection and ambient components still in the fragment shader?
  5.   That is what I was thinking until I saw that stonehat down voted a very relevant question. There would seem to be some confusion as to the purpose of down voting posts...   Can you tell me why that question is relevant? You called your way of referring to me a polite way of communicating with people? Why do people always see problem in my questions? People can downvote my questions or replies, but I can't do the same to others? You are nice and polite to other people but I'm an exception, because of what?
  6. Sorry this shouldn't posted here, but I'm trying to improve myself. English is not my language, so sorry if I offend anyone by saying something offensive. I have neverposted anything like this before. I have a question that is "titled" 'shadow mapping problem'. I included every details that ( i can't really say it is objectively, since this is just what i think it is) i think is irrvelent, and pictures/snapshots i think highlights where the problem is. I'm sure my question is really basic, and there must be professionals here. I know I'm not paying anyone money to answer my questions.   I know and I don't wish people to answer my question. I just would like to know why my reply to my question got a downvote, and is there something wrong in my original question. Thanks for your time and patience. Thanks.
  7. stonehat

    shadow mapping problem

    I've updated the question with the pictures where the problem is. it doesn't matter if it is gldrawbuffer(gl_none) or whatever, the result is the same. So I don't know what's point of asking about it. It really doesn't matter. If it does, it will surely change something. 
  8. I'm trying to render shadow using shadow mapping. But something is wrong. I think my shader could be wrongly written. What I've tried to do is the following. Generate the framebuffer for shadow map.   GLuint framebuffer; glGenFramebuffers(1, &framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);   glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE);   GLuint shadow; glGenTextures(1, &shadow); glBindTexture(GL_TEXTURE_2D, shadow); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT , 1366, 768, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadow, 0);   glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1366, 768, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);shadow, 0);   if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) cout << "framebuffer error" << endl; else cout << "framebuffer is complete" << endl;   glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0);   Use two shader programs. The first is used to render into the depth texture of the framebuffer. The second is used for normal rendering and shadow. The first shader program is like this.     /////////// first.program.vs   #version 330    in vec3 position;    uniform mat4 mM;  uniform mat4 mV;  uniform mat4 mP;    void main(){ gl_Position = mP * mV * mM * vec4(position, 1.0);      /////////////// first.program.fs   out vec4 fcolor;     void main() { fcolor = vec4(gl_FragCoord.z);      the second shader program is like the following.     ////////// second.program.vs   #version 330   in vec3 position;   in vec2 UV;  out vec2 uv;    // Matrix to get vertex position to clip space uniform mat4 mM;  uniform mat4 mV;  uniform mat4 mP;    // Proj-View-Model matrix for Light uniform mat4 mvp;     out vec4 ShadowCoord;    uniform vec3 lightPos;    out float dis;     void main(){  uv = UV;    ShadowCoord = mvp * vec4(position,1.0f);   gl_Position = mP * mV * mM * vec4(position, 1.0); }     ////// second.program.fs     #version 330    uniform sampler2D tex;  uniform sampler2D shadtex;    in vec2 uv; in vec3 normal;  in vec4 ShadowCoord;  out vec3 fcolor;    void main() {    fcolor = ( (texture(tex,uv).rgb));      float shadow = 1.0;         vec4 shadowcoord = (ShadowCoord / ShadowCoord.w);  shadowcoord = 0.5 * shadowcoord + 0.5;  if ((shadowcoord.x < 0 || shadowcoord.x > 1 || shadowcoord.y < 0 || shadowcoord.y > 1 || shadowcoord.z < 0 || shadowcoord.z > 1)){ shadow = 1.0; }  else {  float depth = texture2D(shadtex, vec2(shadowcoord.xy)).x; if ( dis > depth ) shadow = 0;}   fcolor *= shadow; }"; ///////     in the main loop i draw objects in this way:   1. bind framebuffer 2. use first shader program 3. draw the object that cast shadow   4  bind the default framebuffer 5. use second shader program 6. draw the objects that have the shadow casted on them   But the result is not as expected. Is there something wrong in the second program's shaders? Thanks in advance.   In the picture the red box is the light position. The little screen in upper right is what rendered into the framebuffer, what light sees.The blue plane in front of it is the shadow caster. I only rendered itto the shadow map framebuffer. I rendered the same blue plane in the exact position of the shadow caster, and ground beneath it. The shadow should be in front of the blue plane, not behind it. Also some online tutorial pointed out that glDrawBuffer(GL_NONE) means opengl will not draw to the color texture of the framebuffer, or similar meaning. So I wrote that.
  9. To load models such as characters and buildings into memory, I placed the model file in certain format such as .dae and had the program parse it before entering the main loop. I think it might be not the fastest way. What's the most efficient way to do that generally?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!