Skip to main content
gamedev.net
🔒 Locked

Bump mapped planet

Started by laci84 Oct 19, 2008 at 3:01 PM 5 replies 1.4k views
Original Post
laci84
laci84
I'm new in OpenGL programming. I want to make a bump mapped planet, but all tutorial that I have found on the web is using cube or torus as object. How can I bump map a sphere? I use GL_TRIANGLE_STRIP to draw it. My project is derived from a tutorial named 'ogl_dot3_bump_mapping'(http://www.codesampler.com/source/ogl_dot3_bump_mapping.zip). It uses cube rendered by GL_QUADS. I think the tricky part is here: void computeTangentsMatricesForEachVertex(void) { ... v1 = vector3f(vertices.x,vertices.y,vertices.z); v2 = vector3f(vertices[i+2].x,vertices[i+2].y,vertices[i+2].z); v3 = vector3f(vertices[i+1].x,vertices[i+1].y,vertices[i+1].z); createTangentSpaceVectors( &v1,&v2,&v3, vertices.tu, vertices.tv, vertices[i+2].tu, vertices[i+2].tv, vertices[i+1].tu, vertices[i+1].tv, &vTangent, &vBiNormal, &vNormal ); g_vTangents = vTangent; g_vBiNormals = vBiNormal; g_vNormals = vNormal; ... } How can I use it for GL_TRIANGLE_STRIPs? Thank!
Corn_Dog
Corn_Dog
Hi laci84, I'd like to give you a sample of my old bump mapping source code but I seem to have lost it. So I'll try to help you in another way, I'm quit sure you can use the same code for bump maping a cube as you can a sphere so the code that your using now should work.

But I'd advice you upgrade to using shaders since you will find many more people who can help you and much better documentation. Is there any reason not to use shaders for your project?
swiftcoder
swiftcoder
Quote:
Original post by laci84
How can I bump map a sphere?

I think the tricky part is here:

void computeTangentsMatricesForEachVertex(void)
Unfortunately, it is not possible to generate tangents to a sphere. At some point you must have a discontinuity. You can use an object-space or world-space normal map instead of a tangent-space normal map, to avoid this problem.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
laci84
laci84
Hi Corn_Dog, swiftcoder

Thank you for your replies!
Can you give me some examples how can I use word space maps or shaders to bump map a sphere?
laci84
laci84
Does anybody have a bump mapper shader for sphere?
NineYearCycle
NineYearCycle
If you only have examples of bump-mapping cubes then how about turning a cube into a sphere and bump-mapping that ;)

It gives a better distribution of vertices anyway and has the advantage that you can calculate the tangent space normals.

Andy
"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile" "Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."
zedz
zedz
as swiftcoder saiz I wouldnt worry about tangents etc
but just create your bumpmap in objectspace (see my journal all rocks are created in objectspace)
A/ its faster,less momory + visually better ie its a win/win

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.