📄 update_position.cg
字号:
#include "sph.cg"
void main(fixed index : TEXCOORD0,
uniform samplerRECT attr_rect : TEXUNIT0,
uniform float timestep,
out float3 result : COLOR)
{
float3 pos = f3texRECT(attr_rect, half2(index, GPU_ATTR_PUSHPOS));
float3 vel = f3texRECT(attr_rect, half2(index, GPU_ATTR_VEL));
float3 acc = f3texRECT(attr_rect, half2(index, GPU_ATTR_ACC));
//float3 exacc = f3texRECT(attr_rect, float2(index, GPU_ATTR_EXACC));
float3 gravity = float3(0.0, 0.0, -9.8);
float3 new_v = vel + timestep*(acc + gravity - 1.1f*vel);
//float3 mid_v = 0.5f*(vel + new_v);
//if (length(mid_v) < 0.06f)
// result = pos;
// else result = pos + 0.5f*timestep*(vel + new_v);
result = pos + 0.5f*timestep*(vel + new_v);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -