Announcement

Collapse
No announcement yet.

Infinite fluid simulation by render target blueprint tutorial!

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

    Infinite fluid simulation by render target blueprint tutorial!

    Hi community!
    Today i will show everyone how to make an infinite fluid simulation by unreal render target and blueprint, base on the fluid simulation in content example project (please download it at LEARN tab, for someone who dont know where it is).
    First, open all the render target, for HeigthMap RT, change 3 RT textures like this one:
    Click image for larger version

Name:	RTHeigthMap.png
Views:	24
Size:	117.0 KB
ID:	1640565

    and for NormalHeigthMap:

    Click image for larger version

Name:	NormalHeigth.png
Views:	11
Size:	159.3 KB
ID:	1640566

    Next step, go to ComputeNormal Material and HeigthSim Material, change the constant value of texelSize to SceneTexelSize(this is very important). The value texelSize provided by the content will not work, so please change all of it.

    Click image for larger version

Name:	ChangeTexelSize.png
Views:	12
Size:	467.8 KB
ID:	1640567

    Now, go to Water Material, and add to the UV of HeigthfieldNormal:

    Click image for larger version

Name:	WaterMaterial.png
Views:	12
Size:	431.3 KB
ID:	1640568

    For the Heigthfield, i dont care about it because when you do infinite surface, the vertices of the plane mesh will not be enough unless you use tessalation, if you want it, simply add to the
    UV of Heigthfield like the HeigthfieldNormal, and do boxmask or sphereMask to increase the Multiply of tessalation around camera position(do not just multiply or fps will be greatly reduced).

    Next step is the splat material, change it like these pictures:
    Click image for larger version

Name:	Splat1.png
Views:	11
Size:	461.2 KB
ID:	1640569

    Click image for larger version

Name:	Splat2.png
Views:	13
Size:	437.1 KB
ID:	1640570

    Yay, we'r done for the material, now the is time to go in water surface blueprint and make a little change. First, create 2 functions:

    1.This one is to pass the value of xy coordinate to splat material
    Click image for larger version

Name:	XYPass.png
Views:	11
Size:	254.7 KB
ID:	1640577

    Click image for larger version

Name:	ReturnRightCoordinate.png
Views:	12
Size:	282.4 KB
ID:	1640578 Ok, now is the last part. In tick event, change it like these pics:

    Click image for larger version

Name:	WaterSurfaceBP.png
Views:	11
Size:	340.0 KB
ID:	1640579



    Click image for larger version

Name:	WaterSurfaceBP2.png
Views:	13
Size:	306.8 KB
ID:	1640580

    DONE! Now i want to discuss somethings about this.
    The first one is that, because of the large size simulation (8192), player cannot see the far size that is doing draw tiling, its imposible to see that far, but if you really do not want to simulate outside, you can do boxmask or spheremask around camera position, and multiply the value to the normal output(make sure to lerp from vec3(0,0,1) to vec3(1,1,1), do not use 0 value or the normal will not right).
    The second one is, i forgot to mention that you have to change the logic also in the Point Damage event, change it exactly like the one i did in tick event, they are the same, plus tick event modify the splat strength to decrease it overtime, not in point damage event.
    And the third one, if you want to simulate > 2 actors overlaping, you should make an array of components and location of there components that are overlaping, foreachloop and draw those to render target.
    Finally, here is the result when you do it right


    Goodluck everyone!
    Attached Files
Working...
X