Advertisement
XaskeL

Untitled

Nov 6th, 2019
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. local shader = dxCreateShader([[
  2. #define GENERATE_NORMALS
  3. #include "mta-helper.fx"
  4.  
  5. float transparency = 1.0f;
  6.  
  7. sampler Sampler0 = sampler_state
  8. {
  9. Texture = (gTexture0);
  10. };
  11.  
  12. struct VertexShaderInput
  13. {
  14. float3 Position : POSITION0;
  15. float4 Diffuse : COLOR0;
  16. float2 TexCoord : TEXCOORD0;
  17. float3 Normal : NORMAL0;
  18. };
  19.  
  20. struct VertexShaderOutput
  21. {
  22. float4 Position : POSITION0;
  23. float4 Diffuse : COLOR0;
  24. float2 TexCoord : TEXCOORD0;
  25. float3 Normal : TEXCOORD1;
  26. };
  27.  
  28. VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
  29. {
  30. VertexShaderOutput output = (VertexShaderOutput)0;
  31.  
  32. output.Position = MTACalcScreenPosition(input.Position);
  33. output.Diffuse = MTACalcGTABuildingDiffuse(input.Diffuse);
  34. output.Normal = MTACalcWorldNormal(input.Normal);
  35. output.TexCoord = input.TexCoord;
  36.  
  37. return output;
  38. }
  39.  
  40. float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
  41. {
  42. float4 color = tex2D(Sampler0, input.TexCoord);
  43. color.a = transparency;
  44. return color;
  45. }
  46.  
  47. technique
  48. {
  49. pass P0
  50. {
  51. PixelShader = compile ps_2_0 PixelShaderFunction();
  52. VertexShader = compile vs_2_0 VertexShaderFunction();
  53. }
  54. }]], 0, 200, false)
  55.  
  56. addEventHandler('onClientResourceStart', resourceRoot, function()
  57. local sW,sH = guiGetScreenSize()
  58. local myScreenSource = dxCreateScreenSource(sW, sH)
  59.  
  60. shader:setValue('screenSource', myScreenSource);
  61. shader:applyToWorldTexture('waterclear256')
  62.  
  63. local input = dxCreateScreenSource(sW, sH)
  64. local output = dxCreateScreenSource(sW, sH)
  65.  
  66. local frameTick = 0.0;
  67. local update = false;
  68.  
  69. addEventHandler('onClientPreRender', root, function(timeSlice)
  70. if getTickCount() > frameTick then
  71. frameTick = getTickCount() + (timeSlice * 2);
  72. iprint('frameTick-update: ', frameTick);
  73. end
  74. end )
  75.  
  76. -- addEventHandler('onClientHUDRender', root, function()
  77. -- if not continue then
  78. -- output:update(true);
  79. -- shader:setValue('transparency', 0.0);
  80. -- else
  81. -- input:update(false);
  82. -- shader:setValue('transparency', 1.0);
  83. -- end
  84. -- continue = not continue
  85. -- dxDrawImage(0, 0, sW, sH, output)
  86. -- end )
  87.  
  88. addEventHandler('onClientHUDRender', root, function()
  89. if getTickCount() > frameTick then
  90. shader:setValue('transparency', 0.0);
  91. update = true
  92. else
  93. shader:setValue('transparency', 1.0);
  94. if update then
  95. input:update(false);
  96. update = false
  97. end
  98. end
  99. end )
  100.  
  101. addEventHandler('onClientRender', root, function()
  102. dxDrawImage(1920 - 800, 0, 800, 600, input)
  103. end )
  104. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement