Another simple shader technique is the skybox (or cubemap) reflection. Cubemaps are useful for creating quick and easy reflective surfaces for objects and work particularly well on curved surfaces or objects with bumpy normals. You can create an impression of a metallic, wet, or polished look quite easily (provided you have a way to generate cubemaps). In code, they are about as easy as fresnel, which gives them something of a broad utiity. Once you have the technique, you can treat it as a "part" to add to other shaders.
Here's the cubemap section in the shader:
vec3 eyevec = normalize(ex_vertexposition.xyz - cameraposition);
vec3 reflection = normalize(reflect(eyevec, normal));
vec4 cube = texture(texture7,reflection);
Not much at all.
Below is my noob skybox reflection shader. Note the vec3 effect is put in "fragData2" which handles specular and emission. Basic noob specular output can be written like this "fragData2 = vec4(0,0,0,1); Technically, it is only the alpha channel in the output which handles the specular. The ".xyz" of the output handles emission. So anything you put there will become emissive, like a light. Try fragData2 like something like this: "fragData2 = vec4(1,0,0,1); Now your shader glows red and you've learned emission in shaders - you shader artist, you:
Add a fresnel to a skybox reflection and you get a metallic chrome effect:
I used a little contrast trick I learned from the desaturation shader and created a specular reflectance effect using a cubemap and a blinn-phong. It yields a polished look like wet or waxed paint:
Below I combined the fresnel, blinn-phong and cubemap reflection to revisit the pearl shader.
As you can see, for the most part, shaders are just a lot of smaller parts combined to produce some effect. it's a lot of mixing and matching. But once you have those parts you can reuse them to your heart's content. It is my goal that by the end of this series I will have given enough of these parts that those wanting to learn shaders can do just about anything they can think of, and if I succeed getting one guy up that initial step then this endeavor has been a success.