C++ - Updating texture data
we're currently updating a texture every frame and I was wondering if there was a faster form of this bit of code here:
We're running this bit of code several times a frame (depending on how many textures we need to update) and I'm curious as to whether or not:
a) moved to another thread (from what I understand, updating UObjects is not to be done outside of the main rendering thread
b) whether there's a faster / more efficient form of this code. Basically assigning an array of bytes to a texture.
asked Aug 03 '16 at 02:27 AM in Rendering
I would setup a texture like this:
setup with a dynamic material instance using UMaterialInstanceDynamic::SetTextureParameterValue, then update it like this:
Hope it helps!
answered Aug 04 '16 at 08:52 PM
1) The address mode tells how the textures is sampled outside 0..1 texture coordinate range. The valid values are TA_WRAP, TA_CLAMP & TA_MIRROR. If you're not familiar with texture addressing don't bother with them. I bet the default values will work just fine.
2 & 3) Add the ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER into your tick function. It will schedule a command to run on the rendering thread for avoiding CPU/GPU synchronizations. Because of this, you can't use the same pData for each frame (the rendering thread might lag behind).
It's best to do something like:
Follow this question
Once you sign in you will be able to subscribe for any updates here