Shadow Blade
Morrowland Presents Apron Tutorials
game - design - multimedia - web - programming - tutorials - There are currently viewers visiting Apron Tutorials.
   
 
TECHNICAL
GRAPHICAL
SOUND
GAME
WEB
ARTICLE
TOOL
PROJECT
 
 NEWS

  news

  history


 TECHNICAL TUTORIALS

  opengl

  direct3d

  c/c++

  visual basic

  java

  c#


 WEB TUTORIALS

  html

  dhtml

  asp

  php


 IMAGE EDITING

  photoshop

  draw sketch


 3D MODELING

  3d studio


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 DEMOS

  win32 api


 ARTICLES

  general

  opengl


 COMMUNITY

  about us

  credit

  contact






 LIGHTMAP 14.10.02  


The use of static Lightmaps and Multitextureing, are nice ways to make a 3D world look more realistic.
A lightmap is just a normal texture, but we use it different. Lets say we have a normal floor texture and a
black and white lightmap, when we blend them the black part will have a shadow effect, and the white part
will seem like light. Just like in the pictures below.


Ronny André Reierstads's Easy Baking Recipe..
How to do it step by step...


INSTRUCTIONS:


GENERAL:
---------------------------------------------------------------
1. Start with a project that can load texture

2. Add the header file "glext.h" to your project

3. Decleare two new function pointers with "NULL" as inital value.

PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;

4. Declare a texture array that can hold two textures.

UINT TextureArray[2];



INIT:
---------------------------------------------------------------
5. Activate multitexturing, and define the new function pointers.

 glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
 glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB");

6. Load the textures (ID 0 = normal texture, ID 1 = lightmap)

BMP_Texture(TextureArray, "texture/image1.bmp", 0); // Here we load a normal texture
BMP_Texture(TextureArray, "texture/lightmap.bmp", 1); // Here we load a lightmap



RENDER:
---------------------------------------------------------------
7. Assign our texture ID, to a new Multitexture ID.

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextureArray[0]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextureArray[1]);

8. We draw our object and set the UV texture coordinates for our texture, we also
pass in the new Multitexture ID and it's texture coordinates to glMultiTexCoord2fARB.
Notice, that we use both textures on each vertex, this is Multitexturing!

glBegin(GL_QUADS);
// top left vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f);
glVertex3f(-1, 1, 0);
// bottom left vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);
glVertex3f(-1, -1, 0);
// bottom right vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f);
glVertex3f(1, -1, 0);
// top right vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f);
glVertex3f(1, 1, 0);
glEnd();


---------------------------------------------------------------
The End


Regards.
Ronny André Reierstad

 LINKS

  morrowland home



 GAME DEVELOPEMENT

  nvidia

  gamedev

  polycount


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 MATH AND PHYSICS

  mathworld

  physicsworld







PLEASE LINK TO


  All rights reserved Morrowland © 2017  
Ronny André Reierstad