Author Topic: GLSL Transparencies  (Read 142 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1486
GLSL Transparencies
« on: January 03, 2020, 04:00:28 pm »
I'm currently fiddling with GLSL shaders to render glassy and crystalline objects.

It is relatively easy to draw just one glassy object with physically correct Fresnel reflection and refraction, whereby transparency is mimicked with distorting the environmental cube map on top of the otherwise opaque object, and there are a lot of such shaders all over the net. But it's next to impossible to draw such an object if there are other objects in the scene to be seen through the transparency, and especially if there are several transparent objects one arbitrarily behind another. Such layouts can only be drawn by ray tracing, which is very slow and impossible to render with high quality in real time.

OpenGL is full of compromises and approximations. And its probably major trade-off is its "thickless" transparency that's emulated by simple alpha blending of materials without any Fresnel effects. OpenGL built-in transparencies look and feel as if they aren't 3D objects but rather cut from sheet glass. Balls aren't balls but sheet "glass" disks, cubes aren't cubes but hollow glass "cages".

So, we'll also have to deviate from strict Fresnel and keep adding built-in transparency to indicate objects behind the transparent one. This isn't physically correct but it's better than OpenGL built-in dull transparency without reflection or refraction altogether. ???
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1486
Re: GLSL Transparencies
« Reply #1 on: January 03, 2020, 04:05:19 pm »
And one main prerequisite to draw such transparencies more or less correctly will be their strict sorting from back to front every time their mutual orientation is changed by mouse dragging. :-\
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1721
    • zapsolution
Re: GLSL Transparencies
« Reply #2 on: January 03, 2020, 04:28:44 pm »
Perhaps we can use something like the glass reflection i have used in my 3D Chart project, that serves me well.

I made a new post about emissive modulation see it there
http://www.objreader.com/index.php?topic=197.msg5880#msg5880
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1486
Re: GLSL Transparencies
« Reply #3 on: January 03, 2020, 07:08:49 pm »
Patrice,

Fresnel reflection is only one-third of all optical phenomena observed in a physically correct transparent object. While we are at it, I hope you understand that "ambient reflection" is not geometrically correct for a transparency at all.

Another third of optical phenomena is refraction, which is extra deflection of light rays on the borders between optical media such as e.g. air and water, air and glass, air and plastic, etc. Sufficiently thick objects such as crystal balls and the like have their refraction so high that the image behind the ball gets refracted upside down with a fish eye effect into the bargain.

And the last third of true Fresnel effect is chromatic aberration (a.k.a. dispersion), which is colorful de-focusing of light rays of different wavelengths on the boundaries of optical media:


And still finally, our own GLSL transparencies should have a fair bit of OpenGL fake "thickness-less" color blended transparency to denote the outlines of other, possibly also transparent, objects that arbitrarily happen to appear behind our transparent objects -- because the second third described above cannot be drawn on screen correctly other than by slow ray tracing.

Do you now understand the complexity of this apparently simple task? :-\
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1721
    • zapsolution
Re: GLSL Transparencies
« Reply #4 on: January 03, 2020, 09:06:27 pm »
Quote
I hope you understand that "ambient reflection" is not geometrically correct for a transparency at all.
Absolutly, but so far ambient reflection has been widely used into the OR model collection with all glass materials without exception.

Being able to produce  a more realistic one, would be a great addition, if the solution doesn't impact too much the current speed.
Patrice
(Always working with the latest Windows version available...)