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:
- –kernel file to make shader
- local kernel = {}
- kernel.language = “glsl”
- kernel.category = “generator”
- kernel.name = “wheel”
- kernel.isTimeDependent = true
- kernel.fragment =
- [[
- P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
- {
- P_UV vec2 pos = 2. * (texCoord - .5); // Get relative position and normalize it to [-1, 1]
- P_UV float len = length(pos);
- if (len > .9) return vec4(0.); // “outside”, use clear color
- if (len < .8) return vec4(0., 0., 1., 0.); // inner body, blue
- P_UV float PI_OVER_TWO = 2. * atan(1.); // arctangent of 1 = pi / 4
- P_UV float angle = atan(pos.y, pos.x); // returns value in [-pi / 2, pi / 2]
- if (angle < -PI_OVER_TWO) return vec4(1., 0., 0., 1.); // red
- else if (angle < 0.) return vec4(1., 1., 0., 1.); // yellow
- else if (angle < PI_OVER_TWO) return vec4(.5, 0., .5, 1.); // purple;
- else return vec4(0., 1., 0., 1.); // green
- }
- ]]
- return kernel
- –place in menu file where shader is implemented
- –create circle to be made into wheel
- local wheel = display.newCircle(150, 100, 100)
- wheel.x = display.contentCenterX; wheel.y = display.contentCenterY
- wheel:scale(1.7, 1.7)
- group:insert(wheel)
- print(“creating circle”)
- –initialize kernel to create wheel effect
- local kernel = require “kernel_generator_custom_wheel”
- graphics.defineEffect( kernel )
- –create wheel using effect on circle
- wheel.fill.effect = “generator.custom.wheel”
- print(“create wheel effect”)