## Archive for March 10th, 2008

10
Mar
08

### Maths Surfaces Almost Ready for Release

My QC/GLSL conversion of desaxismundi’s Maths Surfaces Simple shaders is more-or-less ready for release. I’ve spent a lot of time tweaking the shaders so the surfaces are similar in scale (there were huge differences initally), and fine-tuning controls for VDMX.The plan is to get permission from desaxismundi, then post the QTZ on Memo’s site, hopefully tomorrow.

See here and
here for examples of some of the surfaces.

10
Mar
08

### GLSL CosH, SinH & TanH

GLSL lacks builtin functions to calculate hyperbolic Cosines, Sines and Tangents. Turns out it’s very simple to do all three in GLSL (as anyone who, unlike me, knew anything about maths would know)…

```/// COSH Function (Hyperbolic Cosine)
float cosh(float val)
{
float tmp = exp(val);
float cosH = (tmp + 1.0 / tmp) / 2.0;
return cosH;
}

// TANH Function (Hyperbolic Tangent)
float tanh(float val)
{
float tmp = exp(val);
float tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);
return tanH;
}

// SINH Function (Hyperbolic Sine)
float sinh(float val)
{
float tmp = exp(val);
float sinH = (tmp - 1.0 / tmp) / 2.0;
return sinH;
}
```
10
Mar
08

### Superformula 2D-3D Lighting

I’ve finally got simple Phong Directional lighting working with the Superformula 2D-3D shader.
Not sure what I was doing wrong last time I tried this. The best approach seems to be to ignore the HLSL lighting code, and write that stuff from scratch in GLSL. The normal calculation code seems to work in this shader, which leads me to suspect maybe I was going wrong somewhere else when I tried this last time.

I’m not entirely convinced this particular shader looks better ‘lit’ than with the fake lighting code I was using before. Certainly, the places where the mesh cuts through itself look much glitchier (and not in a nice way) once directional lighting has been applied. Some of the simpler surfaces may look better though.

Next task is maybe to try and get lighting working in one of the Maths Surfaces shaders. Then I can decide if it’s worth converting the whole set (a long and tedious job, I suspect, given there are 50+ of them).