当前位置:网站首页>Unity interactive water ripple post-treatment
Unity interactive water ripple post-treatment
2022-07-03 08:26:00 【T.D.C】
Unity Interactive water ripple post-treatment
- be based on unity post-processing , Provide interactive screen water ripple effect
- git Address :https://github.com/ak47007tiger/OilWater
- design sketch

characteristic
- Provide 2 Algorithms : One from shader toy; A classic algorithm for online search
- I'm pragmatism , If there are ready-made algorithms , I'm not going to start with 0 To calculate , After understanding it, I only care about its use value
- Auto fit large screen , The larger the screen, the more stuck
- Key parameters are provided with configuration , Don't write code
How to see the effect after downloading the project
- open Assets/OilWave/Loading.unity, function
- Shortcut key "control + i" Switch scenes , Click the screen in the scene with pictures
principle
- This principle is said from the perspective of a rear-view mirror , That is, Zhugeliang , This is mainly to help readers understand , I can't reproduce the creator's ideas
- Water ripple is a kind of transmission of vibration , We need to create vibrations 、 Diffuse vibration
- There are ups and downs after the waves on the water surface , Specular reflection 、 refraction , To be realistic , We need to achieve these effects , This article doesn't care
- In natural phenomena, other places under the water can be seen on the water circle , Hereinafter referred to as distortion , This phenomenon is what this paper aims to achieve
Realize the idea
- Suppose a texture is calm water
- Produce initial vibration , Set a certain area of a texture r The channel is a value
- Spread vibration , Update this texture every frame , Let this area r The value of the channel can spread out like a ring , You need to know the value of the previous frame , You cannot discard the value of the previous frame after the current frame is updated , So we need to g The channel saves the vibration value of the previous frame
- The more volatility , The more severe the distortion , That is, the larger the pixel value representing the vibration amplitude in the vibration texture , The larger the offset when sampling the image to be displayed
combination Unity How to realize
- Vibration texture : Create a texture , Each frame call shader Read and render this texture
- Find out CustomRenderTexture Encapsulates this function , Direct use , Appoint shaderPass For spreading vibration pass, See the engineering code for details
- Generate amplitude
- CustomRenderTexutre On reset UpdateZones Will execute all pass, Add a function to convert clicks to texture coordinates , And send the coordinates to the material , Execute click pass The initial vibration will be set to a certain pixel of the vibration texture
- Let the whole scene produce interactive water ripples , Sample and distort the texture generated by the game scene , Post processing can meet this demand
- Twist formula
- Input
- x,y
- Amplitude texture waterTex
- Scene texture mainTex
- In the middle
- The amplitude of the target pixel up, down, left and right , l, r, t, b
- offset = normalize(float3(r - l, t - b, 1))
- With offset You can do that. mainTex Conduct distorted sampling
- Input
Needed unity knowledge
- Material property settings
- shader grammar
- CustomRenderTexutre characteristic
- Customize the post-processing process
Description of main classes in the project
- The code is all there Assets/OilWave Next , Under other folders are irrelevant codes , Have no meaning , Never mind
- ConfigManager, It is written for modifying the material parameters without changing the code after the program is packaged
- DemoForResolutionAdapt, Responsible for creating CustomRenderTexture, If the screen is too large, shrink the created vibration texture to improve performance
- EffectInput, adapter pc And mobile , Handle mouse click or finger touch events
- OilWavePostProcessing, Update vibration texture , Post execution processing
- ProcessingConfig, Parameter class , Used to create data objects
- WaterManager, Management resources , Adapt to screen size switching
- WaterWave01, One of the earliest demo edition , There is not so much business logic
- WaterWave01.shader, Update the vibration texture shader
- WaterWaveShow.shader, Post processing shows shader, The logic of distorted sampling is here
边栏推荐
- Jupyter remote server configuration and server startup
- Puhua PLM empowers the whole scene product lifecycle management and helps the enterprise digital transformation of the main line of products
- Unity learning notes
- Use of ue5 QRcode plug-in
- Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
- 数据库应用技术课程设计之商城管理系统
- 【K&R】中文第二版 个人题解 Chapter1
- jupyter远程服务器配置以及服务器开机自启
- 数据的存储
- [set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
猜你喜欢

A tunnel to all ports of the server

Transfinite hacker cognition

GIS实战应用案例100篇(七十八)-多规合一数据库设计及数据入库

Vscode, idea, VIM development tool shortcut keys

Clion toolchains are not configured configure disable profile problem solving

Unity2019_ Natural ambient light_ Sky box

C language - Introduction - essence Edition - take you into programming (I)

Easy touch plug-in

Gradle's method of dynamically modifying APK package name

Thymeleaf 404 reports an error: there was unexpected error (type=not found, status=404)
随机推荐
简易入手《SOM神经网络》的本质与原理
Transplantation of tslib Library
Mxone Pro adaptive 2.0 film and television template watermelon video theme apple cmsv10 template
Three characteristics
Base64 and base64url
Puhua PLM empowers the whole scene product lifecycle management and helps the enterprise digital transformation of the main line of products
[K & R] Chinese Second Edition personal questions Chapter1
Pit & ADB wireless debugging of vivo real machine debugging
Introduction to hexadecimal coding
Golang time format sorting
796 · unlock
【K&R】中文第二版 个人题解 Chapter1
Basic operation and process control 2
[updating] wechat applet learning notes_ three
swagger文档配置
Unity performance optimization
Golang的range
Golang 字符串分割,替换和截取
基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
Lua hot update basic grammar