effect-last-record-final.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import XrFrame from 'XrFrame';
  2. const xrFrameSystem = wx.getXrFrameSystem();
  3. xrFrameSystem.registerEffect('last-record-final', scene => scene.createEffect({
  4. name: "last-record-final",
  5. properties: [],
  6. images: [
  7. {
  8. key: 'u_arBg',
  9. default: 'white'
  10. },
  11. {
  12. key: 'u_main',
  13. default: 'white'
  14. }
  15. ],
  16. defaultRenderQueue: 2000,
  17. passes: [{
  18. "renderStates": {
  19. cullOn: false,
  20. blendOn: false,
  21. depthWrite: false,
  22. depthTestOn: false
  23. },
  24. lightMode: "ForwardBase",
  25. useMaterialRenderStates: false,
  26. shaders: [0, 1]
  27. }],
  28. shaders: [`#version 100
  29. attribute vec3 a_position;
  30. attribute vec2 a_texCoord;
  31. varying vec2 v_texCoord;
  32. void main() {
  33. v_texCoord = a_texCoord;
  34. gl_Position = vec4(a_position.xy, 1.0, 1.0);
  35. }
  36. `,
  37. `#version 100
  38. precision mediump float;
  39. precision highp int;
  40. varying highp vec2 v_texCoord;
  41. uniform sampler2D u_arBg;
  42. uniform sampler2D u_main;
  43. void main()
  44. {
  45. vec2 uv = v_texCoord.xy;
  46. vec4 bgColor = texture2D(u_arBg, uv);
  47. vec4 mainColor = texture2D(u_main, uv);
  48. gl_FragData[0] = vec4(bgColor.rgb * (1. - mainColor.a) + mainColor.rgb * mainColor.a, 1.);
  49. // gl_FragData[0] = vec4(pow(mainColor.a, 1. / 2.2), 0., 0., 1.);
  50. // gl_FragData[0] = mainColor;
  51. }
  52. `],
  53. }));