Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Extras 2



Here's some more extra shaders. I had a lot of fun with these. Some playing with normals. Some post-effects. Some experimental stuff. Just a mixed batch of noob adventures.


This first shader is pretty simple and is a nice noob move to add more detail to any scene. You start with the base shader and simply mix it with another normal texture. You can easily see the effect it produces and this is useful if you want to add small details to a material - like for instance making skin or rocks (below) more porous, or if you want to show the threads in a cloth, etc. It's a cool little effect to have in the repertoire and it only requires an extra texture and two extra lines of code in the normals section:
    vec3 normal = ex_normal;
    normal = normalize(texture(texture1,ex_texcoords0).xyz * 2.0 - 1.0);
    vec3 normal_detail = normalize(texture(texture4,ex_texcoords0 * normal_detail_size).xyz * 2.0 - 1.0); <-- here
    normal = mix(normal,normal_detail + normal, normal_detail_mix); <-- here
    normal = ex_tangent * normal.x + ex_binormal * normal.y + ex_normal * normal.z;    
    normal = normalize(normal);




00a_normal detail.zip


This is a variation of the normals from heightmap shader (37_normals from heightmap) and I included it because I'm getting some better results with it than the other one. Set the heightmap to uncompressed in the texture editor for best results. You can see the normal dot3 map created in Leadwerks from the diffuse gives a nice normal map but it's not very bumpy. The "super bump" shader yields way more dramatic (and rounded) results, but you lose a bit of the sharp details that you would get from something like the Leadwerks normal because you are basing the normals on the heightmap. You can adjust the resolution to get varying results with 1000 being sharp but not very rounded normals. The picture below has the resolution set to about 300. The technique from the normal detail shader above is included so that you can still use the regular normal map to add details to the normals or double down on the normals in order to get some of those little details back. The difference here is instead of using two normal maps you're using one normal map and one  (adjustable) heightmap. I love this thing. It really adds a lot of drama to your materials:


37b_super bump.zip


I thought a shader collection ought to have an anisotropic specular and this was a pain to get working. You can see in the code it just looks like a tangled blinn-phong mess but it looks cool and can be used to give that anisotropic look to hair (below) or brushed metal.


48b anisotropic specular.zip


This next shader does a texture scroll on a normal texture and then adds the xy of that texture to the texture coordinates of the diffuse:
    ...water_normal = normalize(texture(texture6,water_texsize * tex - vec2(0,time * speed)).xyz * 2.0 - 1.0);

   ...vec4 wet_diffuse = texture(texture0, tex + (water_normal.xy * 0.1));

   ...fragData0 = mix(outcolor,wet_diffuse,mask);

This produces sort of a wobbling pseudo-refraction effect in the diffuse by slightly shifting the texcoords of the diffuse according to that scrolling normal, which gives the effect of water running down the face of a surface. Add a cubemap for reflections and a mask and you get this effect:




Here is a high-pass filter shader I made from the kernels blur shader. The high-pass filter is easy to create in Photoshop or GIMP. Essentially what you're doing with a high-pass filter is using a blur to sharpen an image. The idea is that you take the diffuse texture and blend it with a blurred and inverted version of itself. When you do that, you get just a grey image, but the blurring slightly offsets one of the textures and the difference created really dramatically draws out the little details in the image. I included a post-effect version of this here and I believe that would be the correct use of it, as seen below:


01d_high pass filter.zip


This is my attempt at creating a waterfall. I thought the tessellation shader would be a solid direction to go in and it did turn out pretty good. The trick was to get the diffuse texture scrolling with itself. Once I got something that looked pretty decent I copied and pasted that outcolor section into the evaluation stage as the displacement so that the lighter colors would jut out more than the darker colors - so there is a consistency in color and displacement. The material is z-sorted to get the alpha fade and as a result I lost the specular. So I used a blinn-phong to get a light source and then scrolled the normals so that I could get those little "sparkles" which is consistent with water effects. Ultimately all the scrolling speeds and texture sizing are pretty arbitrary. I was just trying to make chaos that looked cool and gave me the impression of falling water. My modeling skills are not that great and I get the feeling this shader could look much cooler with a better model, but the effect is there. One thing to note is that when I made the model I uv-mapped the mask to it so that it would fit regardless of the size or how I might stretch the Y scale on the model to make it taller or shorter, and the mask fades to black (alpha) near the bottom. On taller waterfalls this gives the impression that the water is dissipating into mist:









This last one is just a fun experiment I was messing with. There are techniques for turning a diffuse image into an albedo image in Photoshop or GiMP using the Luminance/Luminosity blend mode. The reason you would do that is  because you don't want shadow information in your diffuse texture. You want only color and you want the shadows and highlights work to be done by the lighting, object shape, and normals. The idea behind this shader is that you take the diffuse texture twice (one being the blend and one being the base) and blend these by the luminance so that the color of the blend blends according to the luminosity of the base (or was it the other way around???). This shader simulates that technique (There's a video link I included at the top of the shader that explains it better). You can adjust the contrast and saturation, and I included a post-effect version of it so you can "albedoize" everything all at once - and I have no idea if that's something that should actually be done but it was fun for me (You could maybe treat it as a tone map or something). You can see it colors in the dark areas and sort of flattens out the contrast. I set the diffuse and height textures to uncompressed and it looks pretty good:






  • Like 9


Recommended Comments

There are no comments to display.

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...