|
Shaders in a plugin ?Hi ! Tinkering again with these new worlds for me that are OpenCL, Objective C and OpenGL, I'm trying to make a plugin with a shader (the one we use to make our "shadows"), but even while reading more and more of vade's beautiful (but hard !!! :-)) code (and GT's Heightfield) I can't manage to find a "simple" way to do this. I would like to output an image on a plane. No mesh complications... Is there an example I could study to learn about it ? Thanks again to you all !
|
v002 erode. it uses a FBO to render on. For multipass shaders things will get more complicated.
Thanks Franz !
It seems much more simple, yes !!!
Well... Hum...
I finally tried with v002Glitch and the AnalogGlitch plugin. It seems so preciously done...
But, I have a trouble with passing colors to the shader (CGFloat* to GLfloat I guess) through the "renderToFBO" method, using glUniform4fARB.
It seems that I have a trouble with header files too :
If someone could tell me what I am doing wrong it would be of great help (once again !).
Don't use v002 Erode as a template, its out of date and has some issues with how state is re-set in 10.6. Look at the blurs, and use the FBO classes if you must.
Also ensure you define the renderToFBO in an Execute category on your plugins class.
Just FYI, before you get to deep, read, understand and respect the licensing terms of the v002 plugins? If its not suited for your needs, don't use them.
What does "the one we use to make our shadows" mean? Did you get that shader from mesh kit?
FWIW, QC supplies it with info, and does other stuff to accomplish what we wind up seeing. Even in that "full" implementation, it kinda sucks for a lot of things, and can be tricked into being inaccurate.
Unless you can get valid depth info with enough resolution, or raw vertex info or everything, I don't really think you can make a decent shadow implementation. Even if you got that shader working in the context of a QCPlugin that outputs image, what would your intent be... to output to a billboard that lays over the entire scene?
It would be cool to have some kind of great QC shadow implementation, but I think that's going to come from A- reading and passing a high quality depth image of the QC scene, and B - outputting it in a way that doesn't kill the resolution and C - ignoring the shader that currently makes shadows in QC as part of that.
I may be off base on some of this, but it's my current thought on it, and I'm sticking to it for now.
If you look at apple tech notes/reference library, you can probably suss out how to utilize shaders in a plugin from scratch without using v002 as a guiding point. When I used last published v002 that used shaders (that I've seen anyway), I had to change some stuff to get it to not error in 10.6. I think it was something with how the file gets loaded (I think some method was deprecated?), and also with the error logging. Since then, I just looked at Apple's site, and did it from scratch, since I happened to be browsing and saw some breakdown on that topic (I cannot remember where the link is, but I know it's there).
Have you looked at the newer source for more recent releases? It all compiles clean.
Thanks vade and GT for your replies and your works... I've read ang agreed with the licensing terms... and read the "license file distribution" thread too.
To reply to GT's question : the shader "we use to make our shadows", is only used to track, fill and transform shadows by compositing. Kinect is surely better at silhouette tracking though.
It was built by the CNRS (french scientific national research center) during a bigger project we were experimenting from 2008 until the end of 2011.
It is open source, and a Jitter version of its implementation was made by one of our partners (we were 3 partners : CNRS, 2 theater/numeric companies) but it is very slow.
My theater company is working with Quartz Composer, then we translated the shader from CG to GLSL to use it inside a GLSL patch. We have very good results with a good IR light.
What I would like to do is to make an usable plugin and implement other functions inside the plugin, so we can use it in a simple way.
Also, it would be more simple to distribute it (freely and open source).
As I am going deeper in Quartz understanding I tried to make an openCL treatment of the resulting "shadow" of the shader, then I realized that I needed a C treatment of my resulting points, so I went to make a plugin in XCode, then I'm trying to come back to the basis of the project purposes : having a simple and distributable (for performing arts and educational purposes) tool for shadow treatment.
I guess I went to a certain point with vade's AnalogGlitch plugin, but I have this trouble I can't manage to resolve about the "renderToFBO" method. I have some kinds of headaches with this and getting mad !
Currently, I'm only displaying a checkerboard, with an exception about renderToFBO and a "initialization makes interger from pointer" in the renderToFBO call. Argh !
I'll look at your "blur" plugin, vade. I want to thank you again for sharing your work, which is really impressive (specially your enlightning way to share methods between plugins).
Greetings,
Ben
No worries!
In your interface for your plugin (in your header) you need to make sure you have
Underneath the normal class declaration.
The (Execution) is called a category tells Obj-C that the method belongs to the Execution category/ phase (see your @implementation / .m ), and that renderToFBO method will be called from within there. If you've made changes to the renderToFBO method (adding arguments to suit your need), you need to make sure all declarations of the method and everything calling it matches. Are you getting compilation errors or warnings?
Wooooow... Sorry for this : I kept your "texture" instead of my "texture1" in the call of the method...
Well... Now I have a display. But it's kind of weird in colors, and nothing works... ! But well, I have a display :-)
[edit : actually, I'm passing 4 GLfloat for each colors, is it the good way to do it ?]
Pass the CGColorRef. Also it looks as though you are using more than one image from QC for your effect. I would highly suggest making a "passthrough" shader, with one image input, and get that working. Baby steps. Plus it allows you to verify what stages are, and are not working.
"CGColorRef" OK !!! Thanks !
(and thanks for the advice ! You're right, I'll do this.)
Hi !
I have a new trouble (baby steps... ). It seems that I can't manage to link the shader with the program :
I took both "v002Blur" and "v002Glitch" as examples. I transformed the shader so it doesn't use anymore "if" conditions, to make it simple... But it still doesn't work. Don't know what I'm doing wrong...
Order of operations and GL State leaking. You need to really understand how OpenGL works, and how state changes effect the pipeline. Take your time ad go through step by step.
Thank you very much Vade. I guess I'm too impatient.