Hi,
I’m trying to achieve some piecewise affine warping from a 2d image. I know how to do it with OpenCV, but in UE4 my guess would be that something with materials would be way more efficient since GPU are pretty good at doing stuff with textures.
I have two distinct problems in here :
- Data acquisition: I have a set of destination points fixed for the whole execution that I already know. I have a set of origin points computed in real time which will need to be passed to the material.
- Triangle warping: The process is pretty clear for me, you take a bunch of origin triangles, and distort the underlying texture to match another set of triangles one at each time (like here: Warp one triangle to another using OpenCV ( C++ / Python ) | LearnOpenCV # ). I couldn’t find anything for triangle deformation in the material editor. It should be pretty straightforward to do with the vertex->fragment interpolation of the graphic pipeline. Am I missing something ?
The state of my reflection for each is:
- For the data, some material parameter collection dynamically changed with c++ for each frame might work.
- For the warping, the basic for each texel, check if it’s in an origin triangle, and lerp to the destination triangle with barycentric coordinates.
im interested in this subject too,
i use to work with opencv and its warping methods
my guesses are
method1 : we should try to use UV coordinates to modify the texture appearence in the material
method2 : try to modify the texture itself on the material
I dont know if method 1 would work but i’ve seen how people use random UV images to what players see using post process so my guess
is it could somehow modify the rendering of pixels of the texture.
For method 2 i think it requires a bunch of coding , some months ago i worked with a kinect plugin wich was generating a new texture on each update to show the RGB camera as a material so i know that creating a new texture for each render tick is posible, the missing part would be to get the texture send it to a custom function (there is a special node in the material graph) warp the texture and return the new texture.
i will keep reading on the subject i would prefer to use native functions of the engine but as you mention i could not find any of them to change textures.
Well i got something working, but is a workaround i don like because is using a sceneCapture2d instead of the main player camera.
Looking for a freelancer who can help me do it with a better approach to directly modify a Texture