particle.frag 688 B

1234567891011121314151617181920212223
  1. uniform sampler2D tex;
  2. uniform sampler2D dtex;
  3. uniform mat4 invproj;
  4. in float lf;
  5. in vec2 tc;
  6. in vec3 pc;
  7. out vec4 FragColor;
  8. vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
  9. void main(void)
  10. {
  11. vec2 xy = gl_FragCoord.xy / screen;
  12. float FragZ = gl_FragCoord.z;
  13. vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), InverseProjectionMatrix);
  14. float EnvZ = texture(dtex, xy).x;
  15. vec4 EnvPos = getPosFromUVDepth(vec3(xy, EnvZ), InverseProjectionMatrix);
  16. float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
  17. vec4 color = texture(tex, tc) * vec4(pc, 1.0);
  18. FragColor = color * alpha * smoothstep(1., 0.8, lf);
  19. }