Shaders by example

I expect I’ve probably pitched this completely wrong, but for what it’s worth I’ve written up a couple of my shaders at http://loopspace.mathforge.org/discussion/19/shader-examples. I picked one that is basically a vertex shader and one that is a fragment shader. I’ve posted code for both of the shaders here before, the linked post is a bit more in depth.

(The problem with writing about shaders is that I don’t really understand them as yet. At least with matrices and quaternions then I knew what I was talking about!)

I good bit of info as well is this:
When it says attributes/ vectors etc in these limits it refers to vec4 items.

For uniforms these are packed so you could for instance give it 1024 individual float uniforms etc. For varyings it doesn’t pack it, so that’s 8 items regardless of whether they are vec4 or not. Another example, a matrix (eg modelMatrix) is 4 x vec4s so takes up 4 varyings.

info from: http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/OpenGLESPlatforms/OpenGLESPlatforms.html

Limits

The maximum 2D or cube map texture size is 2048 x 2048. This is also the maximum renderbuffer size and viewport size.

You can use up to 8 textures in a fragment shader. You cannot use texture lookups in a vertex shader.

You can use up to 16 vertex attributes.

You can use up to 8 varying vectors.

You can use up to 128 uniform vectors in a vertex shader and up to 64 uniform vectors in a fragment shader.

I found it myself difficult to find explanations on the internet that helped me to understand shaders, many of them are just code and textual explanations and, if you’re lucky, one or two static images. Here’s a nice visual introduction that supports my way of understanding things:

http://greggman.github.com/webgl-fundamentals/webgl/lessons/webgl-how-it-works.html

Page 3 of this document also fits my learning style:

http://www.benve.org/Download/Introduction%20to%20Shaders.pdf

Thanks for your documentation in pdf and mainly with epub3 format
for reading with ipad or epaper ebooks. Which software did you create epub with ?

I have a lot of lua progamming documentation for codea but in pdf format.
Calibre software doesn’t allowed to transform pdf in epub correctly.

Thanks

.@hpsoft The source for all the formats (blog - which is Markdown plus extras, PDF, and ePub3) is LaTeX code. I have a LaTeX class which then converts it to the required format. So I never convert directly from the PDF to ePub.

I tried Calibre but it doesn’t generate ePub3 (necessary for the maths).