Tutorials Request: Cg Shaders

While I’m proofreading the shader tutorial, I’m also putting it into the manual as I go along. Lesson 1 (0.py) is complete. I’d be all for putting it as a sample in the distribution and for having it in the manual. The idea is that this would help me sort out some of the best practices for doing a detailed tutorial so that I can help make a more detailed beginners tutorial.

Putting that tutorial in the manual instead of samples is a good idea IMHO, but having it in both sounds a bit overkill. I think we can better put this in the manual but put a nice nature scene with well-explained shaders in the samples instead.

pro-rsoft is right. This tutorial is not some example of Panda’s possibilities, but it is more about learning Cg with Panda. For samples we have to invent something more… exemplary :slight_smile:

Thanks for your help ZeroByte. If anything is unclear, write a note and I’ll try to explain it once more. Maybe it would be nice to first read through the source and then wikify it. We can then create a zip that contains everything. The two may get out of sync, because others add and/or rewrite the wiki pages, but I don’t think that this is a problem at all.

Tell you the truth i never really read the manual when starting panda3d. I basically read the tutorial code and cut and paste and used the reference. So i am up for putting the code in the download while explanation in the manual to support people like me :slight_smile:

Maybe there should be a note in the potential shader sample about the Cg tutorial in the manual? Then people who don’t check the manual first can still be directed to the tutorial. Sorry about the slow progress on editing Azraiyl, my weekend was eaten with trying to get an ODE sample working. The second part of the tutorial is up, hoping to finish at least two tutorials tomorrow since its a free day for me.

Just want to point out that I’m in the last group as well. Until I started poking around the information on this site (the manual and forums) I didn’t have a clear sense of what shaders actually are, but now I’m feeling like I can write some shaders myself. It is pretty exasperating that the information on nvidia’s site is so obtuse, but I am so grateful for the really clear and simple information about shaders here. And as others have pointed out, these tutorials you are writing are by far the best tutorials on Cg that I’ve seen anywhere.

yes, count me in the tryingtolearn group too,
i think is a very good think that this kind of tutorials are made, really,
most of the times the most difficult part about tech is, well, discovering how to start.
so thanks a lot for the effort!

One note about the cg tutorial I have to point out: you explicitly stated that l_position and o_color are required names and cannot be renamed.
This is not true. l_ and o_ keywords can be named anything you like (as long as they are l_ and o_ prefixed), those are not further parsed by panda. They are recognized by their keyword (COLOR or POSITION or so.)

Thanks for your hint, I’ve fixed this.

I have to say, this is one of the best shader tutorials I have ever tried. I really feel like I understand how the different shaders interact, which has been the biggest stumbling block for me on other references. I even went through some of the later unformatted parts of the tutorial that are not actually linked yet :stuck_out_tongue:

Agreed, excellent information on shaders. Thanks for the link.

In the same repoistory I’ve added a directory with some samples.

code.google.com/p/p3dst/source/b … derLibrary

They are written in Cg (therefore usable in Panda3D) but depend on some annotations from FX Composer.

  • Three post process effects (inside MetaScene). Although simple, with the film grain effect images are a bit more dirty (rendered images tend to be too perfect IMO).
  • An SSAO implementation (reduced to SSAO only, not integrated into anything else).
  • Texture coordinate generation.
  • Multiple lighting equations/models (OrenNayer, CookTorrance, …), normal/parallax mapping and environmental effects are merged into one shader (inside MetaObject). Included is a somewhat modifed attenuation function that IMO has one advantage. The equation is built around the maximum distance of the light. Beyond that radius, there is no light (the classic attenuation function does not share this property, every light has an infinite radius).
  • An example of a (not super trivial) geometry shader.

More than one idea was inspired by Blender. Commonalities are intentional (sometimes even with the same “bugs” as Blender, see comments).

First it tried to implement everything in Panda3D directly. But the Panda3D GUI (a requirement for interactive authoring tool) is ahhm . The idea of aspect2d is not that bad (the GUI automatically scales if it is inside the -1 - 1 rectangle), but the look and feel … So I started with my own ideas. It is work in progress (far away from beeing finished, and still some problems like an unicode aware key release event). If I remember correctly, open source means: Release early, release often. At least “early” is true here:

code.google.com/p/politeia/sourc … atever-gui

Until now the most obvious difference (and please do not tell me that Panda3D GUI offers this as well, and I just was unable to locate the doc) is that all elements can be placed on any 3D plane in 3D space and that it is possible to control everything with keyboard only (e.g. tab order).

This time more than one idea is stolen from Qt (if software patents are globally used I have to get a new job, I think).