Opengl, mesh, shader question

SeBastianP.'s picture

//Hi//

I am completely new to QC but within a day managed to have interesting visual results, before I decide to jump into qc I have a couple of questions.

1) It seems QC comes with shapes such as cube, sphere etc. Is it possible to assign different drawing modes to these shapes? example - points, quad strip, line loop, poly, point etc.

2) What is a good method to capture a mesh , or qc shapes to a texture in order to pass it to a shader, and have the shader displace the geometry? I notice OpenCL does this efficiently but I am not ready to start coding.

3) I used the V002 model loader to load a .dae, and in wireframe mode y noticed some jaggies, Is antialiasing automatically turn on? or is there a way to get antialiasing happening in the render.

4) in Jitter it is possible to use - ambient light, diffuse and specular , in the overall render and also to specific shapes (mesh), how would you do that in qc?

5) can you share your QC learning methodology? I've been going through the list of patches in the library but sometimes it's not so clear what they do. Thanks for the time.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cybero's picture
Re: Opengl, mesh, shader question

1 - only way I can think of is to use the Polygon Mode patch. Otherwise no, not at present.

2 - Open CL, or perhaps Kineme 3D.

3 - pass - I'll leave that to the patch's author to answer.

4 - Lighting Environment - but it wraps up all within. Thus wrap up individual items in their own Lighting patch. Otherwise no, not so far as I know.

5 - Sharing QC learning methodology - trifle unclear on this. There are various 3rd party guides to the stock patches and to many 3rd party patches. I started of browsing through the guides on Apple's site. Then began to make my own reference.

idlefon's picture
Re: Opengl, mesh, shader question

1- You can't achieve that the easy way. You should calculate the vertices (it's a one-time job though) in JS or OpenCL and then send them to a quad/line/etc. structure patch or a mesh creator.

2- I've heard nothing but good things about V002 Model Loader and Kineme3D, so I think your answer is either of them. Just remember one thing about the GLSLshader patch (it's probabely the biggest bug in QC), you can't have more than one working shader in QC as far as I know :(

3- --------

4- the lighting patch in QC does this but as Cybero mentioned it affects the whole scene inside it.

5- There are some informative blogs/sites out there: http://machinesdontcare.wordpress.com/ http://www.georgetoledo.com/ http://cybero.co.uk/ and of course the kinem forums :)

gtoledo3's picture
Re: Opengl, mesh, shader question

SeBastianP. wrote:
//Hi//

I am completely new to QC but within a day managed to have interesting visual results, before I decide to jump into qc I have a couple of questions.

1) It seems QC comes with shapes such as cube, sphere etc. Is it possible to assign different drawing modes to these shapes? example - points, quad strip, line loop, poly, point etc.

QC is able to be extended through using QCPatches or QCPlugins.

QCPatches can take the shape of either qtz files, or plugin bundles. QCPlugins are always plugin bundles. These are able to be loaded into QuartzComposer.app by placing them in a Quartz Composer Patches or Quartz Composer Plugins folder, located in one of your Library/Graphics locations. It's preferable to place them in your user folder.

GLTools is a QCPatch that has an environment in it called Polygon Mode. This allows one to activate the GL Line and GL Point modes, and affect the way that objects inside of those environments draw.

Quad strips, line loop, and poly... One can draw with quadstrips by using the Kineme Quad Structure, or by using OpenCL or Javascript in combination with Mesh Creator. Actually, Mesh Creator and Mesh Render both have controls in their settings panels that will cause something to render in wireframe or point mode as well, but they are specific to that patch. You might also with to look at the Line Structure and Triangle structure renderer patches.

Quote:
2) What is a good method to capture a mesh , or qc shapes to a texture in order to pass it to a shader, and have the shader displace the geometry? I notice OpenCL does this efficiently but I am not ready to start coding.

In order to take on OpenGL scene and render in to texture, you place your objects inside of a Render In Image patch, with a clear at Layer 0. Then, you take the image output of it and hook it to a consumer patch, with or without processing in between, and the texture renders.

You can take that texture and pass it to something like the kineme heightfield, OpenCL, or a GLSL shader as well.

Also, Core Image effects are pixel shaders, and some have multiple image inputs that distort an image depending on the secondary input. You might want to examine some of that stuff, though your end result will be 2D.

Quote:
3) I used the V002 model loader to load a .dae, and in wireframe mode y noticed some jaggies, Is antialiasing automatically turn on? or is there a way to get antialiasing happening in the render.

You can enable multisampling in your Viewer by holding down Option and Command at the same time, then going to Preferences, then Editor, then check mark "multisampling". Restart QC and edges will now be multisampled.

All edges in QC look kind of funky by default, but rendering lines usually makes it more visually alarming. I don't think v002 model loader has any problems in this regards, it's just a matter of aliasing in general.

Quote:
4) in Jitter it is possible to use - ambient light, diffuse and specular , in the overall render and also to specific shapes (mesh), how would you do that in qc?

You can place your objects inside of a Lighting environment or a GLSL shader environment. It is possible to use multiple shader environments in a composition, though one can't "nest" them inside of one another, because that's meaningless in openGL.

Quote:
5) can you share your QC learning methodology? I've been going through the list of patches in the library but sometimes it's not so clear what they do. Thanks for the time.

I would examine the basic programming articles concerning QC that are available at Apple's developer website, and examine all of the sample zips (there are some downloads that show a qtz being built up in progressive levels of complexity), the sample qtz's, the meta data notes that are in the sample files, the app and plugin projects, and in general, place a big emphasis on all of the Apple materials and downloads. Many of the sample compositions demonstrate fundamental principles, and I think that more things are covered than Apple gets credited for.

idlefon's picture
Re: Opengl, mesh, shader question

Sorry, was not clear there. I meant the GLSL problem with iterators (http://kineme.net/forum/Discussion/DevelopingCompositions/GLSLshadersini...). As George said, you can make separate GLSL patches ;)

jersmi's picture
Re: Opengl, mesh, shader question

SebastienP., you are getting advanced answers from some of the more knowledgeable folks here, but I'm wondering if you need some simpler answers to get up and running:

  • Do you have Kineme GLTools installed? Lots of options, Mr. Toledo touched upon many.

  • Like GT says, the Apple developer examples already installed are really good. You can get a lot of useful variations out of some of them. Also, there's a folder with examples used by other apps here: System>Library>Compositions.

  • Re: lighting, as GT says, sounds like you just need to get to know the Lighting patch. You can put 3D stuff inside it. Also check out Fog with Lighting nested (or vice versa).

  • Antialiasing is kinda lame in QC for the non-programmer like me. You can supersample using Render in Image, you can turn on "multisampling" in prefs (hold option key down when opening prefs), but there are no "on/off" switches for 3D that I am aware of.

  • In general, get every patch Kineme has available (many are free). Also, there a good number of excellent examples from other users: vade (v002), gtoledo, toneburst, franz (1024), psonice, pixelnoizz, dust, idlefon, cybero, and more. most of these people have blogs/sites, too. and then there's cwright, one of the Kineme founders (along with smokris) who has some really good examples scattered throughout these forums. and he now has the little black apple next to his name, if that means anything to you.

  • also, the apple developer mailing list is another good place to get answers.

(formatting, hmm.... bullets with huge margins from dash with double line break, go figure....)

SeBastianP.'s picture
Re: Opengl, mesh, shader question

Great feedback! thanks to everyone.