Announcement

Collapse
No announcement yet.

Canvas Render Target 2D draw without remove old texture

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Canvas Render Target 2D draw without remove old texture

    I got a problem with the Canvas Render Target 2D I need paint in the ground but adding all the time to the texture, the problem when I add and update the old texture is gone and I need keep the old changes and the new ones, someone knows how to do this ?



    I call the bottom function to draw a texture (to add)
    Hevedy - Instance Tools: https://hevedy.itch.io/hevedyinstances
    Hevedy - Image Tools: https://hevedy.itch.io/imagetools

    #2
    Create multiple CanvasRenderTarget2Ds, use one to update the other. I'm working on something that requires this. I'll show you my setup so far.

    I created a CanvasRenderTarget2D blueprint called MatRT that will draw either a static material, or a material instance dynamic.
    Click image for larger version

Name:	MatRTMain.png
Views:	1
Size:	315.6 KB
ID:	1102000

    If the CanvasRenderTarget2D is given a material instance dynamic, it updates any texture, vector or scalar parameters with this function.
    Click image for larger version

Name:	MatRTParamSet.png
Views:	1
Size:	390.7 KB
ID:	1102001

    Instances of MatRT are created in another blueprint that I'm using to test. This function creates an instance with a static material.
    Click image for larger version

Name:	MatRTConstCreate.png
Views:	1
Size:	260.6 KB
ID:	1102002

    This function creates an instance with a dynamic material.
    Click image for larger version

Name:	MatRTDynCreate.png
Views:	1
Size:	382.0 KB
ID:	1102004

    This function updates an instance with a dynamic material.
    Click image for larger version

Name:	MatRTDynUpdate.png
Views:	1
Size:	359.6 KB
ID:	1102005

    Here's the main blueprint.
    Click image for larger version

Name:	MatRTTesterMain.png
Views:	1
Size:	621.3 KB
ID:	1102009

    To walk you through the spaghetti, a dynamic instances of the material RMLayers is created.
    Two instances of MatRT are created to draw LatLongMat and DistGrid.
    A new instance of MatRT is created to draw the dynamic instance of RMlayers, with the MatRTs that draw LatLongMat and DistGrid passed as texture parameters.
    An instance of MatRT is created to draw NextStep.
    A dynamic instance of the material LayerCombiner is created. The MatRTs that draw RMLayers and Nextstep are set as texture parameters.
    The MatRT that draws RMLayers is updated every few ticks with a dummy camera position.
    Attached Files
    Last edited by xnihil0zer0; 03-07-2016, 06:34 PM.

    Comment


      #3
      Thanks you for the reply and help, I will try this, but this looks too heavy no ?
      Hevedy - Instance Tools: https://hevedy.itch.io/hevedyinstances
      Hevedy - Image Tools: https://hevedy.itch.io/imagetools

      Comment


        #4
        What I'm using it for is a bit heavy, but a lot lighter than the alternative. It can be used to ray march, without having to update the rayfield at all distances at the same time, and distant rayfields can be rendered at lower resolutions. I haven't added the asynchronous rendering yet, cause I still have some texture seam glitches to work out, but this only adds 2-4ms to my frame. Most of that is due to the instruction count on my materials, not the render targets.


        You could use a setup more like this.
        Click image for larger version

Name:	MazeRT.png
Views:	1
Size:	302.9 KB
ID:	1102046

        It renders at 120 fps for me, no difference from the base project.

        Comment


          #5
          Hey,

          Would it be possible to use this approach and render to a texture instead of a new dynamic material, so that it can be used in a previously made material? I'm trying to figure out how to grab multiple actor locations in a scene, and update and add to a mask similarly to what is being done here.

          Any help would be great!

          Comment


            #6
            [MENTION=474005]Austin P.[/MENTION] 4.13 has DrawMaterialToRenderTarget which draws to a render target asset. This can be used like a texture in a non-dynamic material.

            Comment

            Working...
            X