My Fluid Simulation (SPH) Sample (3) – Optical Effects using GLSL, and Integration of Physical Model

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:

 

0

 

1

 

 

3

 

2

 

4

 

5

 

6

 

7

 

8

 

9

 

 

 

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 !

 

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值