I have been working on my card flip shader and have made decent progress with it. I know some people have mentioned that I should use a perspective camera, but that does not do what I want and scaling is wacky when used in a gui. My shader allows me to not have a camera used and still have perspective with my render script allowing for depth test.
My current issue is the following. Number one is what I am seeking help with. (Can post project if requested)
- The depth test works, but blending is being weird at the card corners which are rounded. it is blending with the ‘canvas’ instead of the card below it in the depth test. I was hoping someone is willing to assist me with this as I believe this could be a useful shader. It is not code heavy and it works so far.
– Addidtion to the default render script
-- GUI 2.5D placed near GUI render code
render.set_depth_mask(true)
render.enable_state(render.STATE_DEPTH_TEST)
render.set_depth_func(render.COMPARE_FUNC_LESS)
render.enable_state(render.STATE_BLEND)
render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)
-- Custom shader preds
render.draw(self.gui3D_pred)
render.draw(self.gui3Dtext_pred)
render.set_depth_mask(false)
--render.disable_state(render.STATE_BLEND)
render.disable_state(render.STATE_DEPTH_TEST)
-- End GUI 2.5D
– Update: vertex shader source → flip_gu.vp, Gui shader
attribute mediump vec4 position;
attribute mediump vec2 texcoord0;
attribute lowp vec4 color;
varying lowp vec4 var_color;
uniform mediump mat4 view_proj;
varying mediump vec2 var_texcoord0;
void main() {
var_texcoord0 = texcoord0;
var_color = vec4(color.rgb * color.a, color.a);
// Scale perspective "Z" value. Gets funky when larger
// Less perspective when smaller
float perspective = .001;
// Apply the transformation
gl_Position = view_proj * position * vec4(1.0, 1.0, (1.0 + position.w) * perspective, (1.0 - position.z * perspective));
}