CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2007
    Location
    Bangalore,India
    Posts
    164

    Smile shading lighting

    Dear Friends
    I have created surface using QUADS in opengl. Now I have shaded the object suing two lights, light0 and light1 with some values for -z and +z. I have also calculated the normals during the vertex calculation for QUAD points. So my shading is coming somewhat ok. But I want more brightness. How can I achieve more brightness. Please any help would be highly appreciated. Thanks Sujan

    This is my shading algorithms
    [code]
    void CRevolutionProjView::OnViewShade()
    {
    // TODO: Add your command handler code here
    CDC* pDC = GetDC();
    wglMakeCurrent(pDC->m_hDC, m_hrc);
    glMatrixMode(GL_MODELVIEW);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
    GLfloat ambientLight0[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    GLfloat diffuseLight0[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    GLfloat specularLight0[] = { 0.0f, 0.0f, 1.0f, 1.0f };
    GLfloat emissionLight0[] = {0.0f, 0.0f, 0.0f, 1.0f};
    GLfloat position0[] = {0.0f,0.0f,-1000.0f,1.0f};
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight0);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight0);
    glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight0);
    glLightfv(GL_LIGHT0, GL_EMISSION, emissionLight0);
    glLightfv(GL_LIGHT0, GL_POSITION, position0);

    GLfloat ambientLight1[] = { 0.4f, 0.4f, 0.4f, 1.0f };
    GLfloat diffuseLight1[] = { 0.3f, 0.3f, 0.3f, 1.0f };
    GLfloat specularLight1[] = { 0.0f, 0.0f, 1.0f, 1.0f };
    GLfloat emissionLight1[] = {0.0f, 0.0f, 0.0f, 1.0f};
    GLfloat position1[] = {0.0f,0.0f,1000.0f,1.0f};
    glLightfv(GL_LIGHT1, GL_AMBIENT, ambientLight1);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuseLight1);
    glLightfv(GL_LIGHT1, GL_SPECULAR, specularLight1);
    glLightfv(GL_LIGHT1, GL_EMISSION, emissionLight1);
    glLightfv(GL_LIGHT1, GL_POSITION, position1);

    Invalidate();
    wglMakeCurrent(NULL,NULL);
    }
    [\code]

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: shading lighting

    Increase the values for GL_SPECULAR.
    See http://www.codeguru.com/forum/showthread.php?t=518697

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured