My Fluid Simulation (SPH) Sample (3) – Optical Effects using GLSL, and Integration of Physical Model
2010-08-18 11:23
549 查看
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 !
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 (1) – Rigid body model + N-S model
- My Fluid Simulation (SPH) Sample (2) – Curvature Flow
- [论文泛读] Accurate and efficient stochastic reliability analysis of composite services using their compact Markov reward model representations (SCC, 2007)
- My priliminary understanding of the relationship between virtual address and physical memory address
- 1.4 Dynamically change the look of an application by using view states,transitions and effects
- 论文精读2-ReLayNet: Retinal Layer and Fluid Segmentation of Macular Optical Coherence Tomography·····
- System and method for parallel execution of memory transactions using multiple memory models, including SSO, TSO, PSO and RMO
- 《Fundamentals of Inertial Navigation,Satellite-based Positioning and their Integration》读书笔记——第一章+绪论
- How HipChat Stores And Indexes Billions Of Messages Using ElasticSearch And Redis[转]
- Using MATLAB to analyze principal components obtained from a molecular dynamics simulation of a pro
- Unity Shaders and Effects Cookbook (5-1)LitSphere lighting model
- Ten potential of mobile Internet business and profit model
- Design and Model Analysis of the E-Commerce Development Platform for 3-Tiered Web Applications
- How to get Full Rom Dump / Stock ROM of MT6572 MediaTek Smartphones using SPFT and MTK Droid Root an
- Linux to read the Processor model, physical cores, virtual cores and L1, L2 cache
- A sample that using the completion port I/O model
- Using DbContext in EF 4.1 Part 1: Introduction and Model 学习摘要
- 《The Story of My Life》Introductiom - The Life and Work of Helen Keller
- Model View Controller (MVC) Using C#, Delegates and Events in .NET
- Sample Application using JSF, Spring 2.0, and Java Persistence APIs