Jump to content

Skybox Reflections


havenphillip

2,833 views

 Share

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:

skybox.thumb.jpg.0c2f068c3ca21884b6662d30850ce52e.jpg

14_skybox reflection.zip

 

Add a fresnel to a skybox reflection and you get a metallic chrome effect:

metal.thumb.jpg.f895cc999c7d72aa19b668c4cb65f864.jpg

15_metal.zip

 

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:

polished.thumb.jpg.4bd5018f88998252b7dc2f8e09d40bcd.jpg

16_polished.zip

 

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.

Happy shading!

 

1628563659_pearlrevisited.thumb.jpg.cacced31e9e23cf9081e8e9f9cbee984.jpg

17_pearl revisited.zip

 

Next: Creek...

  • Like 4
 Share

3 Comments


Recommended Comments

I'll take a look at these and see if I can spice up my glass shader.

My cubemap reflections aren't parallax reflections at the moment so I'll see if this fixes it 

  • Like 1
Link to comment
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...