New : fake enviro reflexion refraction shader material at low cost !

0 views
Skip to first unread message

ben

unread,
Jul 8, 2009, 8:38:59 PM7/8/09
to away3d.dev
Well, it's late and I can't sleep...
so I uploaded a video of a test for a new enviro reflexion refraction
shader I was working on.
In fact a modified bitmapMaterial with two new properties
and one new line of code in the abstractrendersession, so that you
just have to prebake your bitmapdata in photoshop and set:
yourBitmapMaterial.refract = true;

The starting point for a lot more experiment I think...

Fake because it's only a bitmapmaterial (you can do whatever you want
with it (composite, etc...), and that's a good point
and it's pretty low cost in perf...

I'll publish the code soon if you guys think that it deserves to be
shared, so let's comment !!
I know some will say that it is not really (in a physical way) what it
seems (real reflexion, etc...), but it looks like, and that's what I
wanted.

PS: sorry for the bug in the video, but I have to change my capture
tool...

here it is :
loud quicktime version (sorry...it's late for me):
http://www.agence-anonyme.com/lab/nouse/enviroPrebacked.mov
on vimeo (in about 1 hour from now):
http://www.vimeo.com/5515775

Matt N. M.

unread,
Jul 8, 2009, 9:49:54 PM7/8/09
to away3d.dev
Looks very cool. I can't really tell what's going on or whether the
result is accurate. It seems a little quirky. Can you do this on a
cube within a color coded environment map? or a map of terrain?

ben

unread,
Jul 9, 2009, 12:31:36 PM7/9/09
to away3d.dev
"Quirky", here we are !
yes it might be considerd as a way to render some kind of reflexion/
metal/crystal material at low perf cost.
I created it because of a project with a lot of mesh and texture and I
had to find tricks to display that kind of texture without perf loss.

Anyone would see something glossy and reflective ( thanks to our brain
habits) by looking at it... that's what I wanted
it's just an illusion !
;-)

Li

unread,
Jul 9, 2009, 12:34:59 PM7/9/09
to away3...@googlegroups.com
Looks cool indeed.

Could you comment on how it works a bit?

ben

unread,
Jul 9, 2009, 12:52:10 PM7/9/09
to away3d.dev
Glad you like it !
the fact is that I don't have the code under the eye,
but in fact in the final drawTriangle method of the session, you make
a swith on the matrix used to solves the bitmap :

like :
if(refract)m.scale(a2,c2);
if(refract)m.scale(.5,.5);

you pass the "refract" boolean value by creating a bitmap new property
with getter/setter and pass it when the bitmapMaterial calls for the
session.
so all you have to do is add a line in the abstractrendersession
and set
your bitmapMaterial :
yourBitMapMaterial.refract = true;
(or pass it in the init object)

you can imagine nice effect in a composite material.
I'm working on other effects and some more accurate method.

I'll post the code tonight.

Li

unread,
Jul 9, 2009, 1:08:43 PM7/9/09
to away3...@googlegroups.com
yeah, but beyond the usage, whats going on?

ben

unread,
Jul 9, 2009, 1:41:34 PM7/9/09
to away3d.dev
well as I told you, in the abstractRendersession :
in the bitmapMaterial class you have 1 more properties
you set refract (or whatever is the name of your property) to true

then to the line (don't remember where):
session.renderTriangleBitmap(bitmap, map, v0, v1, v2, smooth:Boolean,
repeat, layerGraphics,refract):void

renderTriangleBitmap(bitmap:BitmapData, map:Matrix, v0:ScreenVertex,
v1:ScreenVertex, v2:ScreenVertex, smooth:Boolean, repeat:Boolean,
layerGraphics:Graphics = null,refract:Boolean = false):void
{
.....
first calc the matrix(m), from map and vertices
then :
if(refract==true)m.scale(.5,.5);///or some other way , more accurate
I'm working on.
...
draw the graphics in the view
}

that's all for basic !

Li

unread,
Jul 9, 2009, 1:43:05 PM7/9/09
to away3...@googlegroups.com
Ah, wonderful. So you're just messing up the UV matrix a bit. Cool =)

ben

unread,
Jul 9, 2009, 3:26:44 PM7/9/09
to away3d.dev
Yes that's not a good idea for simple objects with low count of faces,
but for complex objects it makes the trick...very well I think...

I mean in a user point of view, enjoying the whole thing, not for the
disturbed mind of some dev ;-))

but it's a first try, I'll be searching for more result (scale more
depending on distance,etc...) and other effect not too compete with
the existing material, but to add an alternative...


Reply all
Reply to author
Forward
0 new messages