PDA

View Full Version : Create a emitting plane using shader



walnutown
11-22-2014, 01:41 AM
I'm a newbie in the OpenGL ES world, and learning some basics on 3d graphics on Android OpenGL ES. I'm wondering how to create a image plane that emitting light? This is easy to be implemented in 3d model software like Blender (using the Cycles Render), see the image below for effects I'm looking for. Through some research, I learnt that they may be related to Blur or Bloom effect using shader. Any help is appreciated!
1509

Agent D
11-23-2014, 05:41 AM
I've seen hacks that try to implement area lights with a constant color (http://www.gamedev.net/topic/552315-glsl-area-light-implementation/), where first the closest point on the light rectangle is determined and then phong lighting is computed.
It looks nice, but it's nowhere near phyiscally acurrate.

Since every infinitesimally small point on the plane contributes light to a point on a surface, you would actually have to compute an integral
over the area, or the projected solid angle.
This also means that if you want shadows from area lights, it will get quite problematic. While some points on the light surface can not directly "see" a point on some
surface (i.e. it is in shadow for those parts of the area light), other points can and you get very smooth, fuzzy shadows.

Some approaches to solve this use shadow mapping by generating a series of shadow maps for different parts of the light surface.


You probably noticed that your modeling program takes quite some time to compute the frames, whereas OpenGL(R) programs typically pump out lots of frames per second.
Those modeling programs usually use different rendering and lighting algorithms (ray tracing, path tracing, radiosity, etc...) that generate physically acurate results, have no
problems with area lights but take a lot of time to compute.

There are some voxel based, real-time global illumination techniques that can cope with area lights (e.g. casceded light propagation volumes and voxel cone tracing) but I'm
not sure how well those are suited for embedded systems at the time being.


EDIT: I think this (https://www.youtube.com/watch?v=sF4mkZKonUQ) might come closest to what you want.

walnutown
12-02-2014, 10:49 PM
Thanks, Agent D. Shadow map is a good solution for static rendering. In my case, the screen actually is a video screen, so the shadow is rendered dynamically. I finally use Gaussian filter to blur the image texture. But the issue is that the interior part of the image is blurred, but the border of the image is very obvious (compared with the dark background). It looks like a blurred gloss effect. Is there any way to blur the border of the image?

Agent D
12-03-2014, 04:57 PM
Shadow map is a good solution for static rendering. In my case, the screen actually is a video screen, so the shadow is rendered dynamically.
Are you, by any chance confusing shadow maps (https://en.wikipedia.org/wiki/Shadow_mapping) with light maps (https://en.wikipedia.org/wiki/Lightmap)?

They are two different things.

A light map is a texture containing pre-computed light values for areas on a surface. Implementing an area light effect with light maps is easy,
but only suitable for static scenes (light and geometry don't change, ignoring recent developments in real-time radiosity).

A shadow map is a rendering of the scene from the perspective of a point light. Each pixel holds a distance from the light source. When
rendering the scene from the cameras point of view, the visible pixels are projected into the shadow map and checked if they are visible from
the light source (lit) or not (in shadow). Shadow maps can be used and are used for shadows in real-time rendering where light source and
geometry can change in real-time. Changing of the light color is absolutely irrelevant.

Using shadow maps for point lights is easy, as it translates to our simple pin-hole camera model. Using shadow maps for area lights is hard. The
light has an area and each pixel in the scene can be potentially seen from multiple points on the surface of the light, hence my suggestion of
breaking up the area into multiple parts and using multiple shadow maps for multiple parts on the area (as opposed to a single shadow map).



I finally use Gaussian filter to blur the image texture. But the issue is that the interior part of the image is blurred, but the border of the image is very obvious (compared with the dark background). It looks like a blurred gloss effect. Is there any way to blur the border of the image?
It depends on how you treat the borders when applying the filter kernel. Do you use zero values for positions outside the image or do you
repeate the last value inside the image?

GClements
12-03-2014, 05:29 PM
Is there any way to blur the border of the image?
Make the image larger so that it includes a border as part of the image, then blur it.