Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Game Development
  4. model, shade, looksRealistic OpenGL

model, shade, looksRealistic OpenGL

Scheduled Pinned Locked Moved Game Development
graphicsgame-devhelpworkspace
2 Posts 2 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    appollosputnik
    wrote on last edited by
    #1

    Dear Friends I am successfully able to generate a 3D surface by revolving the profiles by 360 degree. Now my 3d model is in red color so the color is so shining I am not able to distinguish various parts in the model. For this I am trying to use some lighting but I am not successful. Can u help me someone what kind of lighting should I use so that my model looks realistics and I would be able to visualize various parts on the model . Check my snippet I am trying to use this kind of lighting but finding black shadows on the sides not able to visualize properly. Thanks a lot for any help. [code] void CRevolutionProjView::OnViewShade() { // TODO: Add your command handler code here // TODO: Add your command handler code here CDC* pDC = GetDC(); wglMakeCurrent(pDC->m_hDC, m_hrc); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST); // Enable light and setup 2 light sources (GL_LIGHT0 and GL_LIGHT1) glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glColor3f(1.0f, 0.0f, 0.0f); // We're setting up twolight sources. One of them is located // on the left side ofthe model (x = -1.5f) and emits white light. The // second light sourceis located on the right side of the model (x = 1.5f) // emitting red light. // GL_LIGHT0: the whitelight emitting light source // Create lightcomponents for GL_LIGHT0 GLfloat emissionLight0[] = {0.2f, 0.0f, 0.0f, 1.0f}; GLfloat ambientLight0[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat diffuseLight0[] = { 0.8f, 0.8f, 0.8, 1.0f }; GLfloat specularLight0[] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat position0[] = { -1.5f, 1.0f, -4.0f, 1.0f }; // Assign createdcomponents to GL_LIGHT0 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); // GL_LIGHT1: the redlight emitting light source // Create lightcomponents for GL_LIGHT1 float ambientLight1[] = { 0.2f, 0.2f, 0.2f, 1.0f }; float diffuseLight1[] = { 0.8f, 0.8f, 0.8f, 1.0f }; float specularLight1[] = { 0.5f, 0.5f, 0.5f, 1.0f }; float emissionLight1[] = { 0.2f, 0.0f, 0.0f, 1.0f }; float position1[

    L 1 Reply Last reply
    0
    • A appollosputnik

      Dear Friends I am successfully able to generate a 3D surface by revolving the profiles by 360 degree. Now my 3d model is in red color so the color is so shining I am not able to distinguish various parts in the model. For this I am trying to use some lighting but I am not successful. Can u help me someone what kind of lighting should I use so that my model looks realistics and I would be able to visualize various parts on the model . Check my snippet I am trying to use this kind of lighting but finding black shadows on the sides not able to visualize properly. Thanks a lot for any help. [code] void CRevolutionProjView::OnViewShade() { // TODO: Add your command handler code here // TODO: Add your command handler code here CDC* pDC = GetDC(); wglMakeCurrent(pDC->m_hDC, m_hrc); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST); // Enable light and setup 2 light sources (GL_LIGHT0 and GL_LIGHT1) glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glColor3f(1.0f, 0.0f, 0.0f); // We're setting up twolight sources. One of them is located // on the left side ofthe model (x = -1.5f) and emits white light. The // second light sourceis located on the right side of the model (x = 1.5f) // emitting red light. // GL_LIGHT0: the whitelight emitting light source // Create lightcomponents for GL_LIGHT0 GLfloat emissionLight0[] = {0.2f, 0.0f, 0.0f, 1.0f}; GLfloat ambientLight0[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat diffuseLight0[] = { 0.8f, 0.8f, 0.8, 1.0f }; GLfloat specularLight0[] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat position0[] = { -1.5f, 1.0f, -4.0f, 1.0f }; // Assign createdcomponents to GL_LIGHT0 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); // GL_LIGHT1: the redlight emitting light source // Create lightcomponents for GL_LIGHT1 float ambientLight1[] = { 0.2f, 0.2f, 0.2f, 1.0f }; float diffuseLight1[] = { 0.8f, 0.8f, 0.8f, 1.0f }; float specularLight1[] = { 0.5f, 0.5f, 0.5f, 1.0f }; float emissionLight1[] = { 0.2f, 0.0f, 0.0f, 1.0f }; float position1[

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I'm not so familiar with OpenGL, but perhaps you should take a look at your model again. Lighting will not work properly if the normal vectors of your vertices are not calculated properly and make sure that they have a length of exactly 1. As a test, you could also load any model and render it with your lighting. This way you can find out wether the model or the lighting is wrong.

      And from the clouds a mighty voice spoke:
      "Smile and be happy, for it could come worse!"

      And I smiled and was happy
      And it came worse.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups