Jump to content

[SOLVED] Dynamic diffuse texture; unwanted fade out


photo

Recommended Posts

Posted (edited)

I am working on in-game screens, where I take an image from a WidgetSpriteViewport and use imageTextureImage() to set the diffuse texture of an ObjectMeshDynamic. When the object is close to the screen it works as expected. However when the camera moves a short distance from the object the texture fades out and is replaced with a static texture. 

 

I would like to not fade out.

 

I have tried .setMaxFadeDistance(9999.0f,0) and .setMaxVisibleDistance(9999.0f, 0) but they do not seem to have any effect.

 
 
The code that sets the texture in update() is 
 
  image = new Image();
  wsv.renderImage(image);

  mat = omd.getMaterialInherit(0);
  index = mat.findTexture("diffuse");
  mat.setImageTextureImage(index, image, 1);

 

Edit: it appears that the texture size is a key factor. Larger textures fade to static more quickly than smaller textures do.

Edited by angus.wood
Posted

Thanks, Angus!

 

I'll have a look and report back. Also, try to use .setMaxFadeDistance(INFINITY,0) instead of .setMaxFadeDistance(9999.0f,0) and the same for setMaxVisibleDistance.

Posted

Hey Angus,

 

Looks like "meshes/Plane-mesh.mesh" is missing in your archive. Could you please add it to your test scene and upload it again?

Posted

Hey Angus,

 

Looks like "meshes/Plane-mesh.mesh" is missing in your archive. Could you please add it to your test scene and upload it again?

 

 

Sorry about that. An updated .ZIP is attached.

mup2p.zip

Posted

Solved!

 

The issue is related to mipmaps. The "fade out" that I was seeing is (we think) a lower resolution mipmap taking the place of the dynamically created texture. So by adding the line 

 

image.createMipmaps(IMAGE_FILTER_BOX, 1.0f);

to the code means that the texture is now all correct.

 

 

×
×
  • Create New...