Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mai 23, 2024 05:38

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Autor Nachricht
 Betreff des Beitrags: VBSP 19(HL2) - Lightmaps
BeitragVerfasst: Fr Sep 02, 2005 10:09 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Im having problems loading lightmaps... or converting the data.

Bild
Bild

As u can see from the pics the lightmaps unity makes (there is no colours or anything applyed other than a lightmap) are screwed.

Code:
  1. for x := 0 to NumFaces-1 do
  2. begin
  3. If Faces[x].LightOffset < 0 then
  4. begin
  5. Lightmaps[x].TextureId := 0;
  6. continue;
  7. end;
  8.  
  9. Seek(f, Header.lumps[VBSP_LUMP_LIGHTMAPS].fileofs + Faces[x].LightOffset);
  10.  
  11. SetLength(ALightmap[0],(Faces[x].LightmapTextureSizeInLuxels[0]+1) * (Faces[x].LightmapTextureSizeInLuxels[1]+1));
  12.  
  13. BlockRead(F,ALightmap[0][0],(Faces[x].LightmapTextureSizeInLuxels[0]+1) * (Faces[x].LightmapTextureSizeInLuxels[1]+1)*SizeOf(TColorRGBExp32));
  14.  
  15. SetLength(Lightmaps[x].Data[0],(Faces[x].LightmapTextureSizeInLuxels[0]+1) * (Faces[x].LightmapTextureSizeInLuxels[1]+1));
  16.  
  17. for y := 0 to (Faces[x].LightmapTextureSizeInLuxels[0]+1) * (Faces[x].LightmapTextureSizeInLuxels[1]+1)-1 do
  18. begin
  19. Temp := Power(2,ALightmap[0][y].Exponent);
  20. Lightmaps[x].Data[0][y] := SetVector(ALightmap[0][y].r*Temp,ALightmap[0][y].g*Temp,ALightmap[0][y].b*Temp);
  21. end;
  22. //Lightmaps[x].Data[0][y] := SetVector(Power(ALightmap[0][y].r,ALightmap[0][y].Exponent),Power(ALightmap[0][y].g,ALightmap[0][y].Exponent),Power(ALightmap[0][y].b,ALightmap[0][y].Exponent));
  23.  
  24. CreateLightmapTexture(Lightmaps[x].TextureId,Lightmaps[x],(Faces[x].LightmapTextureSizeInLuxels[0]),(Faces[x].LightmapTextureSizeInLuxels[1]));
  25. WorkOutPercentage(TotalPer,x,CurrentPer,Percentage,Step);
  26. end;
  27.  
  28.  
  29. Procedure TVBSPMap.CreateLightmapTexture(var texture:GLUINT; pImageBits:TVBSPLightmap; width,height:integer);
  30. begin
  31.   // Generate a texture with the associative texture ID stored in the array
  32.   glGenTextures(1, @texture);
  33.   // This sets the alignment requirements for the start of each pixel row in memory.
  34.   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  35.   // Bind the texture to the texture arrays index and init the texture
  36.   glBindTexture(GL_TEXTURE_2D, texture);
  37.   // Change the lightmap gamma values by our desired gamma
  38.  // ChangeGammaLightmap(pImageBits, width,height, Engine.Map.Gamma);
  39.  
  40.   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  41.  
  42.   //Assign the mip map levels
  43.   glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  44.   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  45.  
  46.   // Build Mipmaps (builds different versions of the picture for distances - looks better)
  47.   gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_FLOAT, @pImageBits.data[0][0].X);
  48.  
  49. end;
  50.  


Each colour is stored in the following

Code:
  1.  
  2. struct ColorRGBExp32
  3. {
  4.     byte r, g, b;
  5.     signed char exponent;
  6. };
  7.  


Zitat:
Standard RGB format can be obtained from this by multiplying each colour component by 2^(exponent).


Code:
  1. Temp := Power(2,ALightmap[0][y].Exponent);
  2. Lightmaps[x].Data[0][y] := SetVector(ALightmap[0][y].r*Temp,ALightmap[0][y].g*Temp,ALightmap[0][y].b*Temp);


Im assuming the Power function acts like ^ in maths.

Currently im only loading one out of a possible 4 "styles" (each face can have what i guess to be 4 different lightmaps effecting it) but even if some have more styles, the colours im getting are a tad off for other styles to be the cause.

The offset seems to be correctly done

Zitat:
Each face gives a byte offset into the lighting lump in its lightofs member (if no lighting information is used for this face e.g. faces with skybox, nodraw and invisible textures, lightofs is -1.) There are (number of lightstyles)*(number of luxels) lightmap samples for each face, where each sample is a 4-byte ColorRGBExp32 structure

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.007s | 14 Queries | GZIP : On ]