2D Shadows: Extended


Hello Readers!

I just continued working on the 2D shadows system, and implemented a box blur which creates the illusion of soft shadows.

The box blur is performed in this shader:

sampler2D shadowMap;

float4 PSShaderMain( float2 Tex : TEXCOORD0 ) : COLOR0
{
float texelWidth = 1.0/800;
float texelHeight = 1.0/600;

float4 Color = tex2D( shadowMap, Tex.xy);
/*Color += tex2D(shadowMap, float2(Tex.x-texelWidth, Tex.y-texelHeight));
Color += tex2D(shadowMap, float2(Tex.x, Tex.y-texelHeight));
Color += tex2D(shadowMap, float2(Tex.x+texelWidth, Tex.y-texelHeight));
Color += tex2D(shadowMap, float2(Tex.x+texelWidth, Tex.y));
Color += tex2D(shadowMap, float2(Tex.x+texelWidth, Tex.y+texelHeight));
Color += tex2D(shadowMap, float2(Tex.x, Tex.y+texelHeight));
Color += tex2D(shadowMap, float2(Tex.x-texelWidth, Tex.y+texelHeight));
Color += tex2D(shadowMap, float2(Tex.x-texelWidth, Tex.y));
Color = Color/9;*/

return Color;
}

And a few screenshots to illustrate (Click the images to view real size):
Before shader effect (zoomed in at shadow border):

After shader effect (zoomed in at shadow border):

Over-all view before:

Over-all view after:

You still see a bit of aliasing, thats because I needed to do a Gaussian blur and I did a box blur. Online they say when running the box blur three-times it produces a blur that looks strongly like Gaussian Blur. But I’m happy with the results now.

Calsmurf2904

Advertisements

2D Shadows


Hello Readers!

I recently started working on a little 2d top-down techdemo using my engine, and I soon found out that I wanted shadows!
Well, how do you do this when using sprites? (so pure pixels?)
The implementation what I now did was create 4 vertex points at each corner of the bounding box (so the shadows aren’t pixel perfect :() and then use those to generate the shadows.
And guess what, IT WORKED!
You can read about the code I used here: http://www.ogre3d.org/forums/viewtopic.php?f=10&t=56294&p=382388#p382388

And an image to show it off:
2D Shadows
(Click the image to show real size)

[edit]
Another image with some changes made, and a small test map
2D Shadows
(Click the image to show real size)

Calsmurf2904

Android’s NDK


Hello Readers!

Lately I’ve been in the process of porting Ogre over to android. This is quite hard since Ogre uses exceptions, RTTI and STL stuff which android’s NDK doesn’t support.
Then we stumbled across this link:
http://www.crystax.net/androidndk.php

The guy there, “Crystax”, made his own version of the ndk, using the official ndk, which supports RTTI, exceptions and STL. (Woohoo!).
So OgreMain got ported over with ease (I only had to ditch CMake for now and create a custom android makefile, it seems Assaf Raman on the Ogre forum created a Symbian CMake generator, so maybe this create’s a posibility to create a Android CMake generator) but the next problem was the GLES1 RenderSystem. I still haven’t ported this one over since it uses EGL which android only exposes to the java part for now. Maybe some reader here can give me an alternative for native code that works on android? I was thinking about using dlopen and dlsym to get the EGL functions from the active EGL library on the system, but this doesn’t seem to work either. (Haven’t fully tested it yet, so maybe it does work correctly).

If someone could give me some tips etc. on how to get this going, please let me know!

Calsmurf2904