Archived

This topic is now archived and is closed to further replies.

Dr Pain

pure procedural texture

Recommended Posts

I need to make a pure procedural texture (not loading from a file). Referring to the code below, if I use the PR_LoadTexture section, everything works. If I use the PR_AddTexture32D3D section, all I get is a black screen (the CreateTexture call locks the image and paints on it). I looked at LS_InitializeTerrainMaterials() for clues, but saw nothing. What am I missing??
  
   PR_MATERIAL       textureMaterial;
   char              name[30];
   unsigned char *   textureData;

   PR_SetTextureFormat(TEXTURE_NORMAL);
   PR_SetTextureStage (0);
   textureData = (unsigned char *)PR_malloc (texturePatchWidth * texturePatchWidth * sizeof (PR_UDWORD));  
#if 0
   sprintf (name, "tile%i", patchIndex);
   terrainTexture = PR_AddTexture32D3D(name, (unsigned char *)textureData, texturePatchWidth, texturePatchWidth);
#else
   strcpy(name, "T_00_00.tga");
   terrainTexture = PR_LoadTexture(name);
#endif
   PR_SetMaterialName(&textureMaterial, name);
   PR_SetMaterialMethod(&textureMaterial, 72);
   PR_SetMaterialColor(&textureMaterial, 255, 255, 255);
   PR_SetMaterialTexture(&textureMaterial, terrainTexture);
   PR_SetMaterialEnvironmentMap(&textureMaterial, 0);
   PR_SetMaterialAlpha(&textureMaterial, 255);
   PR_SetMaterialMethod(&textureMaterial, T_TEXTURED);
   PR_SetMaterialColor(&textureMaterial, 255, 255, 255);
   PR_SetMaterialAlpha(&textureMaterial, 255);
   PR_SetMaterialSpecular(&textureMaterial, 0, 0, 0, 0);
   terrainMaterial = PR_AddMaterial(&textureMaterial);

   CreateTexture(patchIndex);
  

Share this post


Link to post
Share on other sites
I don''t know if this is the problem but you should always memset the material to 0 before using it. There might be some bad values in the structure that are preventing the materials from doing what you expect.

Share this post


Link to post
Share on other sites
I think I''ve found the problem, I had to add the line:


PR_Globals.PR_Materials[terrainMaterial].texture_number[0] = terrainTexture;


I would have thought that the PR_SetMaterialTexture call would have taken care of that. Things that make you go hmmmm....

Share this post


Link to post
Share on other sites