JOGL - GLSL Bump Mapping (Please Help!)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JOGL - GLSL Bump Mapping (Please Help!)

leolol
I've been spending the better half of the last 2 weeks trying to get bump-mapping working, however I seem to be having a problem when combining a normal map with a texture.

Bump mapping seems to work fine, when I apply only the normal map, however when I try to also apply the colour map (regular texture) the results are somewhat strange. I am using GLSL shaders borrowed from existing tutorials, which seem to work fine and other users have reported that all is working well.

I suspect there is something wrong with my JOGL code, however I cant see what exactly.

Screenshots: (First is with just normal Map, other 2 are with normal map and texture)

http://imgur.com/a/ceDpg

Link to my shader and GL code snippets:

http://pastebin.com/9mPmSNX3


Any help would be greatly appreciated, I am only posting here as a last resort after trawling through pages of threads/tutorials over the last few weeks with no joy.

Hope someone out there can help.

Leo
Reply | Threaded
Open this post in threaded view
|

Re: JOGL - GLSL Bump Mapping (Please Help!)

Demoscene Passivist
Administrator
By "somewhat strange" u mean what ? At first sight the bumpmapped screenshot looks ok to me.  What exactly is wrong there ?
Reply | Threaded
Open this post in threaded view
|

Re: JOGL - GLSL Bump Mapping (Please Help!)

leolol
Hi There,

Thanks for replying,

Well initially the textures weren't rendering properly (I could get the bumpmap with no texture (that blue screenshot) or the regular texture without bumpmap but not both) I have since found that this was a problem with setting the textures to the right numbers, which brings me to my current problem:

gl.glActiveTexture(GL2.GL_TEXTURE1);
                        texture.enable(gl);
                        texture.bind(gl);
                        setUniform1i(gl,shaderID,"colorMap",texture.getTextureObject(gl));
                        texture.disable(gl);

gl.glActiveTexture(GL2.GL_TEXTURE2);
                        normalMap.enable(gl);
                        normalMap.bind(gl);
                        setUniform1i(gl,shaderID,"normalMap",normalMap.getTextureObject(gl));
                        normalMap.disable(gl);


This works great, and I now get a bump-mapped colour textured model. However the new problem arises when I try to draw numerous objects, as they all override GL_TEXTURE1 and GL_TEXTURE2.

EDIT: For example, the skybox I am rendering now renders the same texture as the spaceship, when obviously I want it to render its own texture.

How would I go about making this implementation work for multiple objects? Something to do with GenTextures perhaps?

Sorry if I sound vague, my brain is somewhat confused at this point.

Leo
Reply | Threaded
Open this post in threaded view
|

Re: JOGL - GLSL Bump Mapping (Please Help!)

Demoscene Passivist
Administrator
>How would I go about making this implementation work for multiple objects?

Simply load multiple texture objects to an array and bind them in ur draw-loop ?!

Stg like this:

for (int i=0; i<10; i++) {
gl.glActiveTexture(GL2.GL_TEXTURE1);
                        texture[i].enable(gl);
                        texture[i].bind(gl);
                        setUniform1i(gl,shaderID,"colorMap",texture[i].getTextureObject(gl));
                        texture[i].disable(gl);
gl.glActiveTexture(GL2.GL_TEXTURE2);
                        normalMap[i].enable(gl);
                        normalMap[i].bind(gl);
                        setUniform1i(gl,shaderID,"normalMap",normalMap[i].getTextureObject(gl));
                        normalMap[i].disable(gl);

//... ur draw code here ...

}