Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Dot3 Bump Mapping (little) problem  (Read 1676 times)
0 Members and 1 Guest are viewing this topic.
Offline Chman

Junior Member




Nothing more that... Java games are cool !


« Posted 2004-04-23 11:24:39 »

Hi again Smiley

I've made a little lwjgl application which use Dot3 bump mapping (3 extensions needed : EXTTextureEnvCombine, EXTTextureEnvDot3, ARBMultitexture) but I've got a little problem.

The bump mappig process works, but textures colors are very strange...

Hum I think the best way is to show you some screenshots :





Ok so as you can see, the bump mapping works except on the strange color problem...

Here is my rendering code :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
private final void render()
{
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glLoadIdentity();

            glTranslatef(0.0f,0.0f,-5.0f);
            glRotatef(rotY, 0.0f, 1.0f, 0.0f);

            glActiveTextureARB(GL_TEXTURE0_ARB);
            glBindTexture(GL_TEXTURE_2D, texture2.id);
            glEnable(GL_TEXTURE_2D);

            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
            glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT);
            glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
            glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
            glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
            glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
            
            glActiveTextureARB(GL_TEXTURE1_ARB);
            glBindTexture(GL_TEXTURE_2D, texture.id);
            glEnable(GL_TEXTURE_2D);

            glBegin(GL_QUADS);
                glNormal3f( 0.0f, 0.0f, 1.0f);
                glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  0.0f);
                glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  0.0f);
                glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  0.0f);
                glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  0.0f);
            glEnd();

            glActiveTextureARB(GL_TEXTURE1_ARB);
            glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
            glDisable(GL_TEXTURE_2D);

            glActiveTextureARB(GL_TEXTURE0_ARB);
            glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
            glDisable(GL_TEXTURE_2D);
      }


Edit: "texture" is the base texture and "texture2" is the bump map.

Can someone help me ? If you want more coding part, simply ask but I think the bug is in this part...
Thanks in advance Smiley

Chman
Offline Chman

Junior Member




Nothing more that... Java games are cool !


« Reply #1 - Posted 2004-04-23 14:48:37 »

Ok I've fixed the problem... It was just a stupid error in texture coordinates...

Chman

(and once again, an unuseful post Lips Sealed)
Offline karatemarkel

Junior Member





« Reply #2 - Posted 2004-09-20 20:18:20 »

I've been playing around with multitexturing recently and I thought I'd try out the example above, doesn't seem to work right for me. Is there anything else that has to be added to the above code to get bump mapping working as the code above just adds highlights to the texture, rather than a light reactive bump map?

Also, I've been browsing the net looking for none shader bump mapping techniques and a common one I've found is this : http://www.paulsprojects.net/tutorials/simplebump/simplebump.html, (nehe#20 links to this tut) Its uses a normalized cube map to calculate the, err, magic:)

However I'm having trouble converting this bit of C code to java.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
      GL11.glGenTextures(textureId);
      glBindTexture(GL_TEXTURE_CUBE_MAP, texid);

      unsigned char* data = new unsigned char[size*size*3];

      float offset = 0.5f;
      float halfSize = size * 0.5f;
      float[] temp = {0f, 0f, 0f};
      int bytePtr = 0;

      for(int j=0; j<size; j++)
      {
            for(int i=0; i<size; i++)
            {
                  temp[0] = halfSize;
                  temp[1] = (j+offset-halfSize);
                  temp[2] = -(i+offset-halfSize);
                  scale_to_01(temp);//i think this method multiplies the vector by 0.5 than adds 0.5 to it.

                  data[bytePtr] = (unsigned char)(temp[0] * 255.0f);
                  data[bytePtr+1] = (unsigned char)(temp[1] * 255.0f);
                  data[bytePtr+2] = (unsigned char)(temp[2] * 255.0f);

                  bytePtr+=3;
            }
      }
      glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X,
                  0, GL_RGB8, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, data);


The part I'm having trouble with is the unsigned char parts, I guess this needs to be a byteBuffer but (being rubbish with byteBuffers) I have no idea how to get this bit of code working with them. Can someone point me in the right direction?

Also are there other more straight forward ways for creating the bump mapping effect, preferably with openGL doing all the work Smiley

Cheers all


[edit], I think I've sorted it out, wont be able to test it tomorrow though.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline karatemarkel

Junior Member





« Reply #3 - Posted 2004-09-28 18:02:07 »

Has anyone converted this tutorial to LWJGL yet ?
http://nehe.gamedev.net/data/articles/article.asp?article=20

If not I've got it working so if anyone wants just pop me a message, only got it working on a quad though, cant get it working an a mesh.

Might be of use to someone, never know.
Offline jimdaddy

Junior Newbie





« Reply #4 - Posted 2006-03-23 03:32:02 »

An old bump (no pun intended!), but just wondering if anyone here has any working Dot3 bump mapping JOGL code. Im really struggling trying to convert the C from this article to JOGL.

Cheers,
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (12 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!