Jump to content
  • Advertisement

Archived

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

Dr Pain

pure procedural texture

This topic is 6123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!