Making a simple diffuse lighting shader. (Question, 1.5)

This post nearly went into Questions, but there is a brand new category here, and it needs attention. I think I won’t be the only person reading a lot of what is posted here.

Is there any example code written to do a diffuse or other lighting shader on a mesh in 1.5? is a gist of a LatheMesh class I wrote for 1.4.6, which would “bake on” lighting while creating rotated solids. If you set the useDiffuseShader button to on you will see that I am not yet managing to get a diffuse light shader to play nicely with the normals I think I have put into the mesh. (Please be kind - that is my first gist. I have been using phorkie at home for version control of Codea projects.)

As you can see, the conversion to 1.5 is ony partial so far - enough to make warnings about deprecated parameters go away, but there are still some new bits of 1.5 which could be better used here.

Advice on how to have a non-black shaded object would be welcome…


Try this out if you like, and point it to a texture.

Check out my 3d sin thingy here:

In the shader it also dynamically generates the waveform, however you can strip that out pretty simply (delete everything in main before it talks about light).

The key thing you need though is vertex normals, I calculate them on the fly because I create the wave on the fly, but for a more normal mesh you should be able to generate them upfront when you create the mesh.