Page 2 of 8

Posted: Sun Apr 01, 2007 11:59 pm
by odyeiop
ah.. now that is really neat =) Great work!

Posted: Mon Apr 02, 2007 12:15 am
by nikki
Wow! That looks completely as if it was really modelled! Its all done in shaders with only one cube, right?

Posted: Mon Apr 02, 2007 1:14 am
by Praetor
Very much cooler. Urban simulations can really use this to get more detail. The inclusion of rooms really helps. You can change the number of rooms, right? So, for instance a whole building could be treated as one room?

Posted: Mon Apr 02, 2007 7:51 am
by nikki
Praetor wrote:Very much cooler. Urban simulations can really use this to get more detail. The inclusion of rooms really helps. You can change the number of rooms, right? So, for instance a whole building could be treated as one room?
The frequencies of the walls along different axes can be changed. So maybe the frequency must be set to the dimensions of the box, 0 or 1 or something like that to get just one room.

One additional feature ?

Posted: Mon Apr 02, 2007 11:19 am
by Shadow007
Wow, I really like it.
I've got one question and one suggestion though :

Question : I can't find the definition of the "step" function that you use in the shader (didn't download the cg toolkit though). Could you please explain what it does ?

Suggestion :
Would it be possible to use some kind of texture-atlas for the ceiling/floor/Walls textures so that some 'randomized' variety is added.
I'd guess you could use some kind of hash from height/walls to have a random but persistent pattern.
This could allow for example to have lit/unlit rooms on a facade, or to break the uniform look.
I'd guess using 4 distinct sub-textures (using the last 2 bits of a hash) would add quite a lot of variety...

Posted: Mon Apr 02, 2007 11:38 am
by Oogst
nikki wrote:Wow! That looks completely as if it was really modelled! Its all done in shaders with only one cube, right?
Yups!
Shadow007 wrote:... Question : I can't find the definition of the "step" function that you use in the shader (didn't download the cg toolkit though). Could you please explain what it does ?
From the Cg user's manual:

Code: Select all

step(a, x)
   0 if x < a;
   1 if x >= a.
Shadow007 wrote:Suggestion :
Would it be possible to use some kind of texture-atlas for the ceiling/floor/Walls textures so that some 'randomized' variety is added.
I'd guess you could use some kind of hash from height/walls to have a random but persistent pattern.
This could allow for example to have lit/unlit rooms on a facade, or to break the uniform look.
I'd guess using 4 distinct sub-textures (using the last 2 bits of a hash) would add quite a lot of variety...
It would be possible, but in the full version I do not have any instructions left to do the math. I will give it a try in a simpler version, though, but I think the added effect will not be large. Another solution for the light/dark thing would be to just create a lightness-function that depends on the position of a room.

Posted: Mon Apr 02, 2007 12:45 pm
by beaugard
My shader has become quite complex, so I am not sure who will win...
But the heavy work is all in the pixel shader, so if you're using early z-out your method will have constant complexity with respect to the number of houses... well almost. That's pretty good, right?

In fact, this is like faking a geometry shader on dx9!

Posted: Mon Apr 02, 2007 1:04 pm
by Oogst
beaugard wrote:...
But the heavy work is all in the pixel shader, so if you're using early z-out your method will have constant complexity with respect to the number of houses... well almost. That's pretty good, right?

In fact, this is like faking a geometry shader on dx9!
I had not thought of it like that yet, but what is "early z-out"? Do you mean that I should make sure things are rendered close-objects first (which Ogre does by default)? Or is there something specific that I will have to turn on?

Posted: Mon Apr 02, 2007 1:08 pm
by Kencho
Early z-out is exactly that. Once you write a pixel in the depth buffer, further pixels (higher z) won't be drawn. This way you avoid writing to the same pixel twice.
Ogre does that at an object-level. What I think he means is to do it in a wall-level, rendering the closest walls first.

Posted: Mon Apr 02, 2007 1:32 pm
by haffax
Ogre doesn't do this at object level. Or rather it only does it for objects with z-test/writing turned off and then in reversed order..

Though a course grained sorting could probably be achieved cheaply in the OctreeSM when making the order of the node traversal camera dependent. I've thought about it, but so far didn't try it.

And I guess with the all new SceneManagers in Shoggoth we will see this at work too.

Posted: Mon Apr 02, 2007 1:42 pm
by Kencho
I know Ogre does for the transparent objects, but I'd have bet it also does for the opaque ones! :| Good to know...

Posted: Mon Apr 02, 2007 1:49 pm
by beaugard
I meant like in this post (there are quite a few more, not sure if this is the best one).

http://www.ogre3d.org/phpBB2/viewtopic. ... early+zout

found another one:

http://www.ogre3d.org/phpBB2/viewtopic. ... &start=113

Since first pass of all materials are rendered before second pass, the z-buffer will be ready by the time your expensive shader is called, and only visible fragments will be processed. Just remember to use exactly the same calculations in the vertex programs of both passes, or there will be z fighting.

Posted: Mon Apr 02, 2007 2:01 pm
by Oogst
Hmm, interesting, that is definitely worth to give a try! As I understand it, I can use early z-out on just these objects and let all other objects be rendered normally. That sounds pretty efficient! I already knew the technology, but I did not know Ogre rendered per pass instead of per object.

Posted: Mon Apr 02, 2007 2:07 pm
by beaugard
Yes, this is how I use it too. On objects with inexpensive fragment shaders (or expensive vertex shaders, I suppose...) I have only one pass, whilst on objects with complicated fragment shaders I have two, the first with colour_write off.

Posted: Mon Apr 02, 2007 2:13 pm
by beaugard
I already knew the technology, but I did not know Ogre rendered per pass instead of per object.
Yeah, it took me a while until I happened to stumble upon this in the forums - not so easy to figure out from API docs and first principles :). Actually it should be in the manual (as an example or something) just because it is such a nice trick.

Posted: Mon Apr 02, 2007 9:52 pm
by free_FROZ
If you figure out how to add random office supplies and furniture in there, you'd really have something.

Posted: Mon Apr 02, 2007 9:58 pm
by stoneCold
free_FROZ wrote:If you figure out how to add random office supplies and furniture in there, you'd really have something.
xD

Oogst: interesting technique :wink:

Posted: Tue Apr 03, 2007 1:21 am
by nikki
free_FROZ wrote:If you figure out how to add random office supplies and furniture in there, you'd really have something.
ROFL.

Posted: Tue Apr 03, 2007 9:04 am
by Virion
Good job. It is really nice. :D

Other possibility ...

Posted: Tue Apr 03, 2007 4:34 pm
by Shadow007
Wouldn't it be possible to use a cubemap for the inside texture ? This could allow with one single pass to adress the floor/ceiling/walls problem would'nt it ?

Posted: Tue Apr 03, 2007 7:04 pm
by :wumpus:
very nice idea :) If this technique is used with good textures, and a blend of reflectivity/transparency mimicing real buildings you could achieve very convincing results
You're certainly unto something. I saw something like this technique (virtual geometry) before to map a pool bottom to a plane in a water simulation, but for buildings this is new afaik.

Posted: Tue Apr 03, 2007 7:17 pm
by Prezadent
Its a mirror of a hidden environment cube. Or it could be.

Posted: Tue Apr 03, 2007 8:20 pm
by Falagard
I think Crackdown is doing something like this for building interiors. Most of the windows in Crackdown let you see slightly into the buildings and they are all mapped with similar style textures (office buildings you can see the floor and ceiling and they fade to darkness as it gets deeper into the building.

I doubt that Crackdown modeled even simple interior geometry for the buildings and was wondering what kind of trickery they used.

It's possible they didn't do this technique though, and I could be rambling. Regardless, it's a very nice illusion - great work.

Posted: Tue Apr 03, 2007 8:26 pm
by jomunoz
:shock: That is so cool...

Posted: Sat Apr 07, 2007 1:09 pm
by Oogst
I tried the early z-out thing and who, that really kicked some framerate butt! For a scene with a lot of cubes behind each other, the framerate went from 58 tot 110 fps. :shock: Funny thing is that the exact boost depends on which object is in front. If the object I created first in 3D Studio MAX is in front, then there is hardly any boost. If one of the last objects is in front, then the boost is a almost a factor 2. This only makes sense, of course, but it is nice to see this thing work as expected.

I still did not get my cube mapping right, by the way, so I opened a topic about it here:

http://www.ogre3d.org/phpBB2/viewtopic.php?p=214446