My Fluid Simulation (SPH) Sample (3) – Optical Effects using GLSL, and Integration of Physical Model
来源:互联网 发布:delicious大金家淘宝店 编辑:程序博客网 时间:2024/03/29 07:46
I would say my SPH application is ALMOST done. In recent 2 days I finished optical effects of curvature flow using GLSL.
Cubemap using GLSL
As the paper titile indicates “Screen-Space”, the first rendering step is to the regular object, and the second rendering step is to calculate corresponding fluid positioned vertices, and these vertices will be post on the camera len directly (a QUAD). However, these vertices have been assigned calculated curvature/thickness/normal information then will be transferred to GLSL to get a finer shading effets. Cubemap is the best choice for GLSL implementation.
First a Cubemap texture should be setup using regular OpenGL, and I will offer the src here:
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X + i, …)
Another critical point for GLSL is as below:
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, nCubemapTexId);
cubeMapInx = glGetUniformLocation(program, "cubemapTex");
glUniform1i(cubeMapInx, 0);
Please notice that GLSL counts its texture index from ‘GL_TEXTURE0’, and the corresponding pass-in var of texture index is 0. This is a rookie trivia but it still costs me several hours to figure out.
Using the intrinsic function “reflect()/refract()” in GLSL, you can achieve a really beautiful shading effect.
Integration of Physical Model
After shading part is over, I integrate the former Rigid/N-S model into this framework.
OK here are the screenshots:
TODO
1. Performance is still low.. most time is spent on curvature flow iterations. I’m considering to use CUDA to accelerate it.
2. As shown, the physical model still needs more fine tuning – the fluid is over compressive and spring force is not large enough…
Again, just wait for me !
- My Fluid Simulation (SPH) Sample (3) – Optical Effects using GLSL, and Integration of Physical Model
- My Fluid Simulation (SPH) Sample (1) – Rigid body model + N-S model
- My Fluid Simulation (SPH) Sample (2) – Curvature Flow
- Fluid Simulation–Driven Effects in Dark Void
- SPH fluid simulation methods & source codes (cpu & gpu)
- 论文精读2-ReLayNet: Retinal Layer and Fluid Segmentation of Macular Optical Coherence Tomography·····
- Internet of Things Automatic Testing – Using Simulation
- READING NOTE: Face Detection with End-to-End Integration of a ConvNet and a 3D Model
- 人脸检测--Face Detection with End-to-End Integration of a ConvNet and a 3D Model
- analysis of ShadowMapping Sample with GLSL
- GLSL实现Interactive Fluid
- GLSL实现Interactive Fluid
- 1.4 Dynamically change the look of an application by using view states,transitions and effects
- 【Unity Shaders and Effects Cookbook】Using Textures for Effects
- Fluid simulation:PIC VS FLIP
- The Effects of Free Sample Promotions on Incremental Brand Sales
- RPL objective function & simulation using DGRM model in cooja
- My sample of Marching Cube Algorithm
- PKU2250 最长公共字串 DP
- 建造模式笔记(Java)
- 关于GetTickCount和QueryPerformanceCounter的精度区别
- 诗歌
- Ubuntu 10.04下编译
- My Fluid Simulation (SPH) Sample (3) – Optical Effects using GLSL, and Integration of Physical Model
- IFrame引用跨域站点页面时,Session失效问题解决
- sap-基于jco2.x的简单封装
- Flex 序列化自定义类 解决 sharedObject 保存自定义对象
- Flex 序列化自定义类 解决 sharedObject 保存自定义对象
- 转 【http://blog.mcuol.com/User/yanxiaojun1015/Article/36219_1.htm】收藏
- Beta 3版火狐4支持Windows 7多点触摸
- window.showModalDialog 窗口中下载文件
- 1.4.2 Clocks