有没有关于如何在GLSL或类似的着色器中创建rain的很好的教程?我可以很容易地为Maya找到一个,但不幸的是,不是这个。谢谢!
发布于 2012-06-19 00:42:59
你说的“雨”是什么意思。表示雨的方式有很多种。
此样本具有雨效应和涟漪效应。
https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/demos/google/particles/index.html
不过没有教程。它的工作原理是创建一堆单位正方形,为每个正方形赋予一个随机值,将该随机值与时间值相加,并计算着色器中的位置,如下所示
uniform float u_time; // a time value passed in by JavaScript
uniform mat4 u_view_inverse; // view inverse (camera world matrix)
uniform mat4 u_view_projection;// view projection matrix
attribute vec4 a_vertex; // the unit quad values
attribute vec4 a_position; // the base position of this particle repeated for
// each vertex
attribute vec4 a_velocity; // velocity for this quad, repeated for each vertex
attribute float a_time_offset; // a time offset for this particle
// repeated for each vertex
// compute a position
float localTime = u_time + a_time_offset;
vec4 base_position = a_position + a_velocity * localTime;
// rotate quad so it's perpendicular to the view
vec4 quadX = viewInverse[0] * a_vertex.x;
vec4 quadZ = viewInverse[1] * a_vertex.y;
// compute the real world position for this vertex
vec4 position = base_position + quadX + quadZ;
// at this point position is the same as any other 'standard' 3d shader
// do with it whatever. Example:
gl_Position = viewProjectionMatrix * position;抱歉,如果这太简短了。
https://stackoverflow.com/questions/11078539
复制相似问题