By harism
on Thu, 11/15/2012 - 17:27
Hi, whilst pondering over how to implement some "photorealism" into Vuforia AR I came up with following simple shader idea. As basis there would be one marker in the middle of a paper plus a 3D object which is partly "below" the marker. In test implementation I'm about to try this would be a rotating cube which is positioned at (0, 0, 0). In this case you would want to occlude parts of the object that are under the marker.
To implement this I was thinking about following shaders.
uniform mat4 uModelViewMatrix; uniform mat4 uProjectionMatrix; attribute vec3 aPosition; varying vec4 vPosition; void main() { vPosition = uModelViewMatrix * vec4(aPosition, 1.0); gl_Position = uProjectionMatrix * vPosition; }
varying vec4 vPosition; void main() { if (vPosition.z < 0.0) { discard; } else { // Render pixel with actual color. } }
I still have to try this out but leaving the idea here for comments and future reference.
Using marker as occluder
Hi harism, it's a very nice idea, in principle it should work;
however keep in mind one thing:
Using marker as occluder
Hi, thank you for your extensive feedback. I tried the idea and will post a video utilizing this into "Shadow mapping" thread. Anyway, I made a mistake earlier and clipping has to be done in model space, of course, easy to say now after testing, instead of view space.
Using marker as occluder
Interesting work.