04
Apr
08

### Linear Harmonics

I was messing around with the Spherical Harmonics shader code, trying to work out how to get it to work with a Sphere primitive instead of a flat grid, when I thought I’d see what happened if I removed the part of the code that bends the flat mesh round into a sphere, and applied the radius variable to the z-coordinate of the mesh. The result is quite cool. I’ve applied the same shading I used in the original shader, and again textured the surface with simple shapes or lines.

#### 8 Responses to “Linear Harmonics”

1. April 4, 2008 at 11:56 am

now that, i _really like.

2. April 4, 2008 at 12:14 pm

very very nice.

3. 4 toneburst
April 4, 2008 at 1:17 pm

Thanks for the encouraging feedback guys.

Think I might have to add a ‘linear’ option to tb_sphericalHarmonics 1.01!

a|x

4. 5 optibreak
April 4, 2008 at 8:34 pm

Agreed, thats a wicked effect.

5. 6 639me
April 5, 2008 at 4:07 pm

absolutely amazing! i’d like to know what part of the code you’ve altered, and how. i realize i’ll never learn glsl, but its absolutely comprehendable to some point to alter the code. it would also be great to learn some basics about it, like why is the code split in two parts? thanks!

6. 7 toneburst
April 5, 2008 at 4:29 pm

Hi 639me,

Cheers!
There’s a part of the code that takes the result of the Spherical Harmonics formula itself, and bends the vertices around to create a sphere shape, distorted the radius of the sphere as it does so. I basically just removed this part of the code, and used r to set the z-coordinates of each vertex, creating a distorted plane rather than a distorted sphere. I’ll post the code here soon, and you can have a look at it yourself.

GLSL code always comes in two parts.
One part, the Vertex Shader, acts on the points making up a 3D mesh. This is where you write code to distort 3D models or primitives.
The second part is the Fragment Shader. This is where you write code to change the colour, shading and surface texture of the 3D mesh.

If you’re interested in making a start on GLSL yourself, you could do worse than take a look at the GLSL tutorials at lighthouse3d
http://www.lighthouse3d.com/opengl/glsl/
You could also pick up a copy of the GLSL Orange Book, which is pretty comprehensive. I bought it quite a while ago, but haven’t managed to force myself to read the whole thing yet. It’s got some good stuff in it, but assumes you’re using GLSL within the context of an OpenGL-based application you’re writing, so some of the tutorials won’t work without some tweaking in QC. A good reference though.

Hope this helps,

a|x

7. April 6, 2008 at 7:01 am

thanks a lot for the link

ansonx