Jump to content

Extras 2


havenphillip

1,282 views

 Share

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:
    //Normal
    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);

microbump.thumb.jpg.c01b339d77cefb99dc3f9c1b1d239804.jpg

 

bumpnormals2.thumb.jpg.de9a513aa798441f70d672f8549fd127.jpg

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:

superbump.thumb.jpg.62de68014b7729df8022eaafa97a6c6d.jpg

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.

1236952311_anisotropicspecular.thumb.jpg.c0e7a7950def4222065175f0525aff9a.jpg

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:

weeper.thumb.jpg.c899ab438aa2a7132f98829d3e5b46d9.jpg

22a_weeper.zip

 

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:

770530685_highpass.thumb.jpg.f4e18a7bd2b6fdc09f818a03a5a534bf.jpg

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:

waterfallexample2.thumb.jpg.19d933d7689b675c933b3397f9096f04.jpg

 

waterfallexample1.thumb.jpg.8c2fd2ba46af11aa778f3bcfaf59128f.jpg

 

 

waterfallexample3.thumb.jpg.788f162e44997c63b1a135d6112b35b6.jpg

41b_waterfall.zip

 

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:

albedoize.thumb.jpg.bea2aa95b9e8140f275475db6345952a.jpg

 

albedoized.thumb.jpg.f1ece5624e3f7a47f689d651766b4282.jpg

53_albedoize.zip

 

  • Like 10
 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
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...