Post processing effects?

Hi guys,

So, I’ve been playing with shaders and have an awesome CRT monitor effect working perfectly. The problem is with performance on older devices.

The way I’m doing it is using snapshots to capture the entire screen every frame and applying the shader to the snapshot.

This actually works perfectly in the simulator and my iPhone 6 plus, but as I expected it’s pretty poor performance on other devices.

Is there a way, maybe using enterprise to apply a shader to the full screen without needing to use snapshots?

Thanks

Let me move this to the shader forum…

Hi there everyone!

 

I have encountered a problem with implementation of a custom shader that for some odd reason, causes my app to crash on an iPhone 5 and iPad mini  but not an iPhone 6 or iPhone 6 plus!   I am getting a segmentation fault 11 error that causes my app to crash immediately after it is opened.  Any help is appreciated!  

 

Below is the code for my custom shader and my implementation of it:

 

  1. –kernel file to make shader
  2. local kernel = {}
  3.  
  4. kernel.language = “glsl”
  5. kernel.category = “generator”
  6. kernel.name = “wheel”
  7. kernel.isTimeDependent = true
  8.  
  9.  
  10. kernel.fragment =
  11. [[
  12. P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
  13. {
  14. P_UV vec2 pos = 2. * (texCoord - .5); // Get relative position and normalize it to [-1, 1]
  15.     P_UV float len = length(pos);
  16.  
  17.     if (len > .9) return vec4(0.); // “outside”, use clear color
  18. if (len < .8) return vec4(0., 0., 1., 0.); // inner body, blue
  19.  
  20. P_UV float PI_OVER_TWO = 2. * atan(1.); // arctangent of 1 = pi / 4
  21. P_UV float angle = atan(pos.y, pos.x); // returns value in [-pi / 2, pi / 2]
  22.  
  23. if (angle < -PI_OVER_TWO) return vec4(1., 0., 0., 1.); // red
  24. else if (angle < 0.) return vec4(1., 1., 0., 1.); // yellow
  25. else if (angle < PI_OVER_TWO) return vec4(.5, 0., .5, 1.); // purple;
  26. else return vec4(0., 1., 0., 1.); // green
  27. }
  28.  
  29.  
  30. ]]
  31. return kernel

 

 

  1. –place in menu file where shader is implemented 
  2. –create circle to be made into wheel
  3. local wheel = display.newCircle(150, 100, 100)
  4. wheel.x = display.contentCenterX; wheel.y = display.contentCenterY
  5. wheel:scale(1.7, 1.7)
  6. group:insert(wheel)
  7. print(“creating circle”)
  8.  
  9.  
  10. –initialize kernel to create wheel effect
  11. local kernel = require “kernel_generator_custom_wheel”
  12. graphics.defineEffect( kernel )
  13.  
  14. –create wheel using effect on circle
  15. wheel.fill.effect = “generator.custom.wheel”
  16. print(“create wheel effect”)

Let me move this to the shader forum…

Hi there everyone!

 

I have encountered a problem with implementation of a custom shader that for some odd reason, causes my app to crash on an iPhone 5 and iPad mini  but not an iPhone 6 or iPhone 6 plus!   I am getting a segmentation fault 11 error that causes my app to crash immediately after it is opened.  Any help is appreciated!  

 

Below is the code for my custom shader and my implementation of it:

 

  1. –kernel file to make shader
  2. local kernel = {}
  3.  
  4. kernel.language = “glsl”
  5. kernel.category = “generator”
  6. kernel.name = “wheel”
  7. kernel.isTimeDependent = true
  8.  
  9.  
  10. kernel.fragment =
  11. [[
  12. P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
  13. {
  14. P_UV vec2 pos = 2. * (texCoord - .5); // Get relative position and normalize it to [-1, 1]
  15.     P_UV float len = length(pos);
  16.  
  17.     if (len > .9) return vec4(0.); // “outside”, use clear color
  18. if (len < .8) return vec4(0., 0., 1., 0.); // inner body, blue
  19.  
  20. P_UV float PI_OVER_TWO = 2. * atan(1.); // arctangent of 1 = pi / 4
  21. P_UV float angle = atan(pos.y, pos.x); // returns value in [-pi / 2, pi / 2]
  22.  
  23. if (angle < -PI_OVER_TWO) return vec4(1., 0., 0., 1.); // red
  24. else if (angle < 0.) return vec4(1., 1., 0., 1.); // yellow
  25. else if (angle < PI_OVER_TWO) return vec4(.5, 0., .5, 1.); // purple;
  26. else return vec4(0., 1., 0., 1.); // green
  27. }
  28.  
  29.  
  30. ]]
  31. return kernel

 

 

  1. –place in menu file where shader is implemented 
  2. –create circle to be made into wheel
  3. local wheel = display.newCircle(150, 100, 100)
  4. wheel.x = display.contentCenterX; wheel.y = display.contentCenterY
  5. wheel:scale(1.7, 1.7)
  6. group:insert(wheel)
  7. print(“creating circle”)
  8.  
  9.  
  10. –initialize kernel to create wheel effect
  11. local kernel = require “kernel_generator_custom_wheel”
  12. graphics.defineEffect( kernel )
  13.  
  14. –create wheel using effect on circle
  15. wheel.fill.effect = “generator.custom.wheel”
  16. print(“create wheel effect”)