Occlusion Shader...

Blender's renderer and external renderer export

Moderators: jesterKing, stiv

SysAdm
Posts: 0
Joined: Wed Feb 25, 2004 3:27 am

Occlusion Shader...

Post by SysAdm »

In this month's edition of Highend 3D Mag
http://www.highendmag.com/current.html there is a shader plugin for XSI that looks awesome...

It was written for XSI but looks like it might be able to be converted for Blender in Python... the lighting is awesome... It simulates Global lighting by taking in consideration where objects are located... basically, it looks at all the objects in the scene and determines the shadow/lighting calculations by it's neighbor objects... super fast for rendering animations...

Here's where to get it... (with source code)
http://animus.brinkster.net/stuff/plg_d ... rtmap.html

and here's his main webpage...
http://animus.brinkster.net/index.html

Here's some examples and more detail about using Occlusion. I believe this is using other shaders too, not just the Occlusion plugin....
http://www.xsibase.com/forum/index.php? ... eadid=6902

Just curious, since I'm not a Python guru by any means... if this is a Blender possibility? Maybe this will inspire a Python coder to "think along these lines"...

Last thing... please excuse me if this is in the wrong forum... :?

_____SysAdm

ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Post by ideasman »

This could be tested in python by splitting up the faces and applying vert colours.

Better if it was in blenders radio-bake tho, or the renderer its self.

eeshlo
Posts: 73
Joined: Wed Nov 06, 2002 10:02 pm

Post by eeshlo »

Well, this is almost exactly what the yafray hemilight does. I have in fact done this in Blender too shortly after the raytracer was added to Blender, but that was only a personal experiment. The Blender raytracer isn't really optimized enough to do this as you need lots of shadow samples (edit: actually, just tried it again, and renderingtimes are not really that bad) . However, you can 'fake' it by using a technique similar to the old GI dome, in fact little_cube posted an ambient occlusion tutorial on elysiun some time ago:
http://www.elYsiun.com/forum/viewtopic.php?t=18247

That plugin however is somewhat more versatile by not only calculating occlusion from objects by the background light (as done in yafray), but also by taking the distance to other nearby objects into account. Which can not only be used to simulate GI type lighting but also dirt. This is also known as 'obscurance' btw, used in games as well.
I also once tried to create a plugin to do this by calculating vertex colours, but that has the disadvantage that like radiosity you need enough faces to make good shadows.

leinad13
Posts: 192
Joined: Wed Oct 16, 2002 5:35 pm

Post by leinad13 »

So this Occlusion shader would simulate GI by calculating light from objects in the scene and their distance away from the camera. Whats the difference between this and Radiosity. Also if Yafray uses it for Hemilight why is it so damn slow?
-------------
Over to you boffins

L!13

eeshlo
Posts: 73
Joined: Wed Nov 06, 2002 10:02 pm

Post by eeshlo »

leinad13 wrote:So this Occlusion shader would simulate GI by calculating light from objects in the scene and their distance away from the camera. Whats the difference between this and Radiosity.
It only calculates shadows, not things like colorbleeding.
Also if Yafray uses it for Hemilight why is it so damn slow?
Probably because I'm not a good enough programmer?
:?
Actually, when it was first implemented quite a few people thought it was much faster than anything else they had tried sofar, so I guess it is a matter of opinion... Actually, that would be the second implementation, the first was really very slow and didn't look good, the typical test scene used at the time (which was very simple) took 40 minutes...
Of course I'm sure there are some programs which can do it faster still.

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

Was this thread inspired by the link on InsideCG to the small article on ambient occlusion?

If so, or if not, here's a link to that article:

http://www.andrew-whitehurst.net/amb_occlude.html

It's short, so read it. This guy did this using depth maps to calculate AO, not raytracing. It's Maya specific, but maybe someone who knows what the heck they're doing could adapt this for fast Blender scanline AO. Which, of course, would completely kick ass.

eeshlo
Posts: 73
Joined: Wed Nov 06, 2002 10:02 pm

Post by eeshlo »

That is already done before, it is basically the same as the old GI dome method as I said in one of the previous posts, see this tutorial by Little_cube:
http://www.elYsiun.com/forum/viewtopic.php?t=18247

Monkeyboi
Posts: 251
Joined: Tue Nov 26, 2002 1:24 pm
Location: Copenhagen, Denmark
Contact:

Post by Monkeyboi »

Excuse me, but without being an expert in this particular field, I'd say some people are misunderstanding something here. I understand it like there are three ways of rendering AO:

1, The DupliVert spotlight tecnique

2, The GI rendering method

3, The Shader method (alternative to Phong or Lambert)


I think the shader method is by far the most interesting technique because render times will be very low. Aditionally it is better suited for scenes with rooms etc - stuff that wont work the DupliVerted spotlights. I think the author of this thread was refering to the shader method, which is much cleverer than the other solutions.

I really hope an Ambient Oclusion shader will the incorporated into the dropdown including Phong, Oren-Nayer etc. It would be useful for more than just a few tests, that's for sure!

eeshlo
Posts: 73
Joined: Wed Nov 06, 2002 10:02 pm

Post by eeshlo »

I'm not sure what you mean with the 'shader method', as far as I can see you need some way of determining occlusion, shadowing, and I don't know how to do that with just a shader. Note that I'm not an expert in this matter myself at all, but I have some interest in this, since basically that is where it all started with my very first python script to simulate hdr lighting. In fact, there is some notes in the docs which nobody really seemed to have noticed about making a diffuse texture out of the hdr image and using it with normal mapping for very fast lighting, of course shadows are missing, and you could combine that with the depthmap AO technique, but that is not really much different than using the multicolored spotlights solution as the script did in the first place.

Monkeyboi
Posts: 251
Joined: Tue Nov 26, 2002 1:24 pm
Location: Copenhagen, Denmark
Contact:

Post by Monkeyboi »

What I mean about the shader method is that it doesn't use shadows, but it colours the mesh in a clever way so that all dents and cracks etc are darkened, similar to a dirt map. As I understand the term "shader" in a 3D application, it means a way to calculate the objects shading. Therefore, a toon shader gives considerable different results than a Phong shader even if you use the same textures and colors. An Ambient Occlusion (or dirtmap) shader would ignore all lights and colour the object so that large smooth, exposed areas are white and corners, holes, dents are black. The trasision between white and black is gradual ofcourse. This is how thie following image was created (with an XSI dirtmat shader - no lights or shadows)

Image

Image 1: colour pass

Image 2: AO pass

Image 3: Multiplied composite

Render time: I don't know, but most probably scarily low. There is no true GI.

Dani
Posts: 143
Joined: Fri Oct 18, 2002 8:35 pm

Post by Dani »

Hum... hello people!

Yeap, this reminds me of some tests I did, and that I'm still doing...
Let sey all my materials in blender can be self lit... I use a bunch of textures (mostly blend and envmaps) and empties to determine the bright spots and the shadow spots (that is what I used to do cel-shading before it got INSIDE blender)...
this only gave light on objects...
So I tried faking radiosity and indirect light the same way... using an envmap (refl mode) with a high filter value to get the coulour and multiply it with the underlying textures... unfortunatly, high filter values for envmap give very strange results and are dependant on the OSA...

All this to say that I've been trying to do this in blender for ages!
I was beggining to think it was impossible, but now I know it's not... it's just very complicated to do in blender...

if it could be made easier :roll:
:)

Dani

eeshlo
Posts: 73
Joined: Wed Nov 06, 2002 10:02 pm

Post by eeshlo »

Monkeyboi wrote:What I mean about the shader method is that it doesn't use shadows, but it colours the mesh in a clever way so that all dents and cracks etc are darkened, similar to a dirt map. As I understand the term "shader" in a 3D application, it means a way to calculate the objects shading. Therefore, a toon shader gives considerable different results than a Phong shader even if you use the same textures and colors. An Ambient Occlusion (or dirtmap) shader would ignore all lights and colour the object so that large smooth, exposed areas are white and corners, holes, dents are black. The trasision between white and black is gradual ofcourse. This is how thie following image was created (with an XSI dirtmat shader - no lights or shadows)
...

Image 1: colour pass

Image 2: AO pass

Image 3: Multiplied composite

Render time: I don't know, but most probably scarily low. There is no true GI.
Ok, I think I see what you mean, but nevertheless that method uses raytracing as well. As I said before, instead of accumulating actual shadow information (occlusion), it simply uses the distance to nearby objects to darken areas. This sort of creates an 'indoor' hemilight, that is, it doesn't actually involve actual lights, it just darkens areas the closer they are. This is what I meant with the 'obscurances' method.
This is one of the things on the yafray to do list for the hemilight, although it involves only a single line of code. Unlike actual AO, It would be quite hard to do in Blender using shadowmaps (unless somebody says otherwise of course :wink: ).
But as I said, I have the code right here to do the same in Blender, there didn't seem much interest at the time, I suppose I could ask Ton et al again if this would be considered useful. It would be somewhat slower than yafray, but I guess that to some people that wouldn't really matter if it means they wouldn't have to install yafray, which more and more seems to be disliked in it's current implementation anyway.
For those looking for other renderers which do all this too, try 3delight/pixie or other similar renderers, they are very fast, and I'm sure that once Green gets back to coding renderman support again for Blender that yafray probably will only be a vague memory.

Anyway, I'll try to brush up the Blender code and do some renders to show what I mean.
(If you happen to read this, S68 sorry again, but as I said I get distracted easily...)

SysAdm
Posts: 0
Joined: Wed Feb 25, 2004 3:27 am

cont...

Post by SysAdm »

eeshlo, I did not mean to pull you off any projects!! LOL :lol:

I've actually emailed the owner of the script, Daniel "¡muh!" Rind, to see if he would join you on a discussion about incorporting this in Blender... here is a cut/paste of his "credentials" straight from his site:
In real life, I'm a professional programmer, proficient in most common, and even some uncommon programming languages out there in the wild, including (in no particular order) C/C++/C#, ASM (on x86), Cobol, Visual Basic (.NET) and Java, the scripting variations thereof, SQL (if you count that as programming language), and a bit of Python, Lisp, Haskell, Smalltalk, Fortran and X++ (if you don't know what that is, you're a lucky man). Yeah, and I can type HTML and ASP code...
Anyways... you guys are waaaaaaaaaay over my head with this, but I'm glad to have sparked a Blender inspiration... :)

____SysAdm

eeshlo
Posts: 73
Joined: Wed Nov 06, 2002 10:02 pm

Post by eeshlo »

Sorry for the delay, but it took quite some figuring out how to correctly import the Atrium in Blender.
Anyway, I didn't have enough time to complete the code, so the result is not quite correct, darkening is too strong in some places and missing in others, have to do more work tomorrow. Nevertheless the effect should be clearly visible, it looks more like a dirt effect than actual AO atm:

http://www.stormpages.com/eeshlo/hray/aotest.html

Hopefully I'll be able to update it all tomorrow.

macke
Posts: 24
Joined: Tue Oct 15, 2002 11:57 pm

Post by macke »

1. Shoot eye ray
2. At intersection, shoot "occlusion" rays to check for nearby geometry in a hemispherical fashion. Number of rays controlled by a user-set variable
3. Add up distances to a variable, average by the number of samples when all occlusion rays has been shot.
4. Return as final value.

Not too sure that point #3 is the way it works in Daniel's shader, but I'm pretty sure it's not far off. Just look in the source if you really wish to know how Daniel does it. It's not very complicated, and the mental ray API is pretty easy to learn especially since you can find the manual online, so you shouldn't have any real troubles translating to pseudo code.

I bet eeshlo'll have it done properly before anyone can say blueberry pancakes ;o)

Post Reply