Results 1 to 10 of 10

Thread: 3D Texturing and Lighting

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    24

    3D Texturing and Lighting

    More 3D texturing fun! Now I'd like to see if I can add more of a 3D effect to my program. Specifically, I'd like it to get darker with depth. Does anybody have any ideas about what the best way to do this might be?

    Just for reference, here's my program (for as long as my IP address remains the same...):
    http://64.165.70.131/orbital.exe

    This is essentially a view of one of the P-orbitals of a hydrogen atom (an excited electron state for this atom). You can use the arrow keys and the delete/insert keys to rotate the orbital. There will be a delay at load time while the program calculates the probability distribution for the orbital. Additionally, this program will crash if your video card doesn't support glTexImage3D. I've only tested it on my GeForce4, so I would only recommend attempting it if you have a GeForce3 or GeForce4 (though it *should* work on any Radeon as well).

    Any ideas on the best way to create the effect of depth?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: 3D Texturing and Lighting

    That's pretty cool looking! When I first started the program, and was looking at it sitting there with no movement, I got the illusion that it was moving away into the screen.

    Incidentally, I ran it on my Radeon 8500 with no problems, and it didn't take any noticeable time to load (1.1 ghz Athlon).

    I've never tried 3d textures before, so I'm afraid I don't have any input about your question, sorry. I enjoyed trying your app, though! Thanks!

    Edit: Maybe light attenuation would give the desired effect? I'm not sure how that works with 3d textures...

    [This message has been edited by yakuza (edited 11-05-2002).]

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    SWEDEN
    Posts
    601

    Re: 3D Texturing and Lighting

    The standard OpenGL way to color things based on their depth (in eye space) is fog. Look it up in the spec, it's pretty simple. I'm sure you can find tutorials on OpenGL fog via google if you find the spec a bit hard to read.

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    24

    Re: 3D Texturing and Lighting

    Well, light attenuation shouldn't work any differently on a 3D texture than it does on a 2D texture. You always apply a 3D texture as a 2D cross section of the texture onto a 2D polygon.

    [This message has been edited by Chalnoth (edited 11-06-2002).]

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    24

    Re: 3D Texturing and Lighting

    Well, after a little bit of playing around with various settings, I can't get the fog to look very good. While it's obvious that with the fog enabled, the scene is darker, depth is not very apparent.

    I'd like to try light attenuation. How would I accomplish this?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: 3D Texturing and Lighting

    I'm sure there are a ton of resources out there for info on light attenuation, here's one of the first links that turned up doing a Google search on "opengl light attenuation":
    http://tc1.chemie.uni-bielefeld.de/d...e/glLight.html

  7. #7
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    24

    Re: 3D Texturing and Lighting

    Hrm, still having a hard time.

    For some reason, with fog, I can't get any sense of depth. And I can't seem to get the standard OpenGL lights to light my surface. Here is my current lighting code:

    Code :
    	float difcolor[4] = {0.0, 0.0, 1.0, 1.0};
    	float difpos[4] = {0.0, 0.0, 2.0, 1.0};
    	float ambient[4] = {0.0, 1.0, 0.0, 1.0};
    	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);		
    	glLightfv(GL_LIGHT1, GL_DIFFUSE, difcolor);
    	glLightfv(GL_LIGHT1, GL_POSITION, difpos);
    	glEnable(GL_LIGHT1);
    Since most of this is the same as seen in Nehe's tutorials, I really don't see why it wouldn't work. I tried to use colorful lights to be certain whether or not I was getting any lighting...

    Any ideas?

  8. #8
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: 3D Texturing and Lighting

    Well, you don't have a glEnable(GL_LIGHTING) in there, perhaps a typo?

  9. #9
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    24

    Re: 3D Texturing and Lighting

    Argh. Geez...

  10. #10
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: 3D Texturing and Lighting

    Hehe, I take it by your comment that you had forgotten that. Did enabling lighting get the results you were looking for? I'd like to take a look at the demo if/when you update it.

Similar Threads

  1. Problem with lighting & texturing
    By kiattisak in forum OpenGL: Advanced Coding
    Replies: 12
    Last Post: 01-29-2016, 01:31 PM
  2. Lighting and Texturing
    By Furrage in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-13-2002, 12:09 AM
  3. Lighting and Texturing Problems
    By King Fuzzy in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-23-2001, 05:01 PM
  4. Lighting & Texturing not working despite using GL_MODULATE
    By Tod Baudais in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 03-02-2001, 08:05 PM
  5. texturing and lighting
    By hoshi55 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-19-2001, 05:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean