Jump to content
  • Advertisement
Sign in to follow this  
Elixir

Translucent subsurface scattering approximation

This topic is 4970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know of a way to calculate translucent subsurface scattering in real time? For a good example of what I'm trying to simulate: I was thinking if I rendered each "frosted" part offscreen as a portal, then did a quick blur, it would look 1/2 decent. Has anyone tried this sort of thing before?

Share this post


Link to post
Share on other sites
Advertisement
I implemented a similar system a while ago, here is the pseudocode:


  1. Render scene as normal.
  2. Copy rendered image to a smaller texture, preferably on hw with stretch filtering.
  3. Render the effect areas into stencil buffer, effectively creating a mask for the effect.
  4. Set the stencil pass mode to non-zero.
  5. Using a pixel shader to sample the aforementioned texture with more blurring (gaussian, perhaps, and noise for "frost"), render the result to the framebuffer - which is now masked by the stencil buffer - using a full-screen quad.
  6. Repeat...

Share this post


Link to post
Share on other sites

One of my profs at UM has done stuff with subsurface scattering:

http://www.cs.umd.edu/projects/gvil/projects/translucency.shtml

...Not that I particularly understand how it works. :)

Share this post


Link to post
Share on other sites
For this particular effect, the method I described is more suitable than any vertex-based approach (correct me if I'm wrong). The blurring, especially if combined with little noise, is a very good approximation of light refraction scattering in fundamentally flat geometry (such as frosted glass or mirrors).

Share this post


Link to post
Share on other sites
Could you post a pic of your scene, when you've done it? I'm curious to see how it appears...

[Edited by - cignox1 on November 10, 2004 2:43:54 AM]

Share this post


Link to post
Share on other sites
I'll be happy to post pictures from my program, if I find the code - my archive is in my attic, in one of very numerous cardboard boxes...

Share this post


Link to post
Share on other sites
You've posted a fairly difficult example of subsurface scattering. Most approximations are performed in tangent-space, and are thus independent of the viewer; in more technical terms, they have a constant BRDF. This works well for surfaces with a fairly high scattering coefficient. The panels here, though, seem to have a low scattering coefficient. Thus, conventional real-time subsurface scattering techniques will be unacceptable as-is.



I suggest a combination method. The panels themselves should be lit with a realtime-determined ambience. To do this, do a low-res, untextured render of the scene from the POV of the center of the panel, facing you, with maximum FOV, into a pbuffer. downsample this to a single pixel by generating mipmaps, and use that one-pixel mipmap later, as an additive blend over the entire panel. (You'll only need to calculate this value once every few frames.) Now, here's the tricky part. Do an initial render of the scene into a texture the size of your screen, with everything on your side of the plane of the panel clipped off. (This will require a custom-built projection equation; glFrustum will not be sufficient.) Render that texture to the framebuffer. Now render a blurred version of it _only_ into the areas the panel occupies, remembering to blend that source with the ambient color you calculated earlier. (A stencil will be useful here.) Now render everything on your side of the panel directly to the framebuffer, completing the scene.



Essentially what we're doing here is rendering our scene in three parts: everything on the other side of the panel, the panel, everything on our side of the panel. The panel itself is illuminated by everything on the other side via the blur, as well as by the averaging of the light on your side. We use the custom-clipped frustra to ensure that stuff on your side of the panel doesn't get blurred onto the panel itself.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
...nice concept...


While this is more physically accurate than the method I recommended above, I think it is an overkill for this situation. As I see it, the blurring already gathers the ambience factor (mostly). Furthermore, my approach works with arbitrary amount of flat panels in one pass of the system as in, for example, the OP picture. However, I'm going to test your concept soon [smile]

Kind regards,
-Nik

EDIT: Ah, but my method does not take into account the light coming from the viewer's side of the panels! However, for simulations sake, it should suffice that the ambient mean is the same across the environment...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Does the OP image really show subsurface scattering?
It looks just like blurred refractions to me. Say you have a perfectly smooth glass pane - this has no subsurface scattering. Now if its fogged.. then the objects on the other side of the glass appear to be blurred. But this is due to the surface "dew" rather than scattering inside the glass. This is like "diffuse refractions". If the surface of the glass itself is not smooth but has small bumps.. then you'd have a similar effect too.
I feel blurring the image of the objects on the other side of the panel tries to simulate this effect. The blur factor should be dependent on the distance of the pixel from the translucent material. The farther the object, the blurrier it appears.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!