Advertisement Jump to content
  • Advertisement

Herr_O

Member
  • Content Count

    264
  • Joined

  • Last visited

Community Reputation

184 Neutral

About Herr_O

  • Rank
    Member
  1. Herr_O

    Distance line - plane

    oh, I was not clear enough.. i meant a segment, not a ray. Two ends and an infinte plane.
  2. Herr_O

    Distance line - plane

    I've searched for an explanation on how to get the closest distance between a line and a plane but can't find any good information. Some help would be much appreciated.
  3. Hi! I'm trying to cull my shadowmapped scene with the frustum. I thought it would be a good idea to make bounding capsules for each segment of the heightmap/objects. The capsule is sweept in the same direction as the shadow is falling (inverse light direction). So if the capsule comes into the view cone it would be rendred and the shadow is cast onto the visible world. With this I could also have different resolutions of the depth texture depending on where the object is in the frustum cone. I tried to implent this in my existing project but got a huge frame drop, I think it might be my frustum/capsule intersection that is the cause.. but i'm not sure, haven't tested it. Has anyone else thought of a solution for shadowmapping? Does this sound like a sane idea?
  4. Herr_O

    FBO depth buffer

    I've got the depth buffer working now, sorry for the late reply. Regarding PCF, I can turn on and off linear filtering in my app. When I have it turned on I get a strange artifact on one texels edge. Is it supposed to look like this or is there some work-around. Is it "bad" to use linear filtering on the shadows because of this? Red arrows pointing at problem.
  5. Be sure to set your orthogonal view to hold your entire scene. I had that problem a long time without realizing it. glOrtho(-20, 20, -20, 20, -100.0, 100.0); I just picked a number, maybe 20 is still too small... Anyway, after that just shrink the view to a size that fits your world.
  6. Hi! I've decided to render my shadow map with the help of a FBO instead of using the window. I think I have set up my framebuffer and depthbuffer right, but it doesn't want to work. My code looks like this: Setup:____________________________________________________________________ // Create depth texture glGenTextures(1, &textureArray[0]); glBindTexture(GL_TEXTURE_2D, textureArray[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 512, 512, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0); // Filter and clamp glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); // Create frame buffer object and depth buffer glGenFramebuffersEXT(1, &frameBuffer); glGenRenderbuffersEXT(1, &depthRenderBuffer); // initialize depth renderbuffer glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthRenderBuffer); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT24, depthWidth, depthHeight); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT, depthRenderBuffer); checkFBOStatus(); Rendering:________________________________________________________________ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthRenderBuffer); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texture[0], 0); /* Render stuff to texture */ ... /* Go back to window rendering */ glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); I can't figure out what's wrong, I've used the examples #3 & #7 at oss.sgi.com. If I understand this the right way.. I shouldn't need to copy my frame to texture[0] with glCopyTexSubImage2D since im rendering directly to the fbo? I think my depth buffer becomes empty because my scene gets shadowed all over. Thanks in advance! [Edited by - Herr_O on October 5, 2006 8:16:54 AM]
  7. Herr_O

    Strange lighting problem

    GLfloat light_position[] = { -2.991, -25.599, 52.613 }; GLfloat light_pos_follow[] = { 0,0,0 }; looks a little bit odd to me. The light array should have a size of 4. One component for each axis and a value for describing what type of light opengl is dealing with. If the last parameter is omitted you can't tell if it is a directional light or a point/spot-light. Directional lights are defined by 0, spot and point lights are 1. Further reading... Jouvieje OpenGL lighting tutorials NeHe light tutorial
  8. Thanks for explaining, i've read it in the OGL reference too, but it didn't sink in like it does now.
  9. Herr_O

    glsl lighting problem

    Looks to me that your last color computation is wrong. I would use the texture as the diffuse component and leave out the ordinary diffuse color. i.e. if (NdotL > 0.0) {   ...   color += tex * NdotL; } gl_FragColor = color;
  10. I've heard about this problem before, and I think it is common. I've created a directional light but the direction must be inversed before it is used, otherways it lights where it shouldn't. This vector should point down... {-0.5f, -0.5f, 0.5f, 0.0f}, but my opengl code wants it to point upward. I have to "correct" it with this in order to have it light as I want it to: tmpdirection=-lightDir; glLightfv( GL_LIGHT0, GL_POSITION, tempLight); Thank you! [Edited by - Herr_O on October 2, 2006 2:39:22 AM]
  11. Herr_O

    Ambient shadows in glsl

    Ah thanks, that sounds like it could work. I'll try it out when I get home from work. :))
  12. Herr_O

    Ambient shadows in glsl

    Thanks, but the result is about the same. The shadow gets a little bit lighter but it is still darker than the ambient component.
  13. Hello! I've got a shadowmap which range from 0-1 per fragment. If I multiply that shadowmap with my existing light model I get nice shadows, but the shadowed pixels become darker than the ambient... not good. I've asked google on this topic but haven't been able to get a good answer. How do I get ambient shadows? my fragment program looks like this, sort of... // Get shadow value to "red" component vec4 shadowShade.r=shadow2D(shadowMap, shadowUV.xyz + vec3( 0, 0, 0)).r; // Copy value to green, blue and set alpha shadowShade.g=shadowShade.b=shadowShade.r; shadowShade.a=1.0; // Calculate attenuation att = 1.0 / (gl_LightSource[0].constantAttenuation + gl_LightSource[0].linearAttenuation * dist + gl_LightSource[0].quadraticAttenuation * dist * dist); // Put it all together color += att * (texture2D(tex,gl_TexCoord[0].st) * NdotL)+ambient; color *= shadowShade; // Calculate specular value halfV = normalize(halfVector); NdotHV = max(dot(n,halfV),0.0); color += att * (gl_FrontMaterial.specular*shadowShade) * (gl_LightSource[0].specular*shadowShade) * pow(NdotHV,gl_FrontMaterial.shininess); gl_FragColor = color; Easier to illustrate the problem with a picture Thanks in advance!
  14. Something like this... // Initialization GLUquadricObj *quadric; quadric=gluNewQuadric(); gluQuadricNormals(quadric, GLU_SMOOTH); gluQuadricTexture(quadric, GL_TRUE); // Render glPushMatrix(); glTranslated(0,0,-3); gluSphere(quadric,1,16,16); glPopMatrix(); Quadrics can make discs, cones and cylinders too.
  15. Herr_O

    Learning GLSL or CG

    I've stoped searching and ordered the orange book from amazon. OpenGL(R) Shading Language (2nd Edition) (Paperback) I've heard good things about it.
  • 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!