[GSoC 2012] Volume Rendering with LOD aimed at terrain

Threads related to Google Summer of Code
Post Reply
User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by Mattan Furst »

I missed a couple of posts of yours
I plan to make most of the shaders configurable. Like materialGenerator.setFog(true/false); or materialGenerator.setAmountOfSupportedLights(2); etc.. This is "just" a bit of string concartanation when I'm done with the full blown version of the shader.
I think this is a bit of a redundant work. Take a look in the RTShaderSystem. If you'll add a triplanar texture sub-render state that will replace the regular texture sub-render state. The configuration of the rest of the shader (fog, number of lights and a lot more) will be automatically provided through the RTShaderSystem. Check the Basic RTShader demo and the RTShader multiple light demo (I forgot the name of this demo (which is funny since I wrote it)) in the sample browser.

I can help you with the code if you can wait till this weekend.
it's turtles all the way down

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

Hi,

it's a bit redundant, that's true. My thoughts behind this are:
- Maybe someone doesn't want to use the RTTS. I know of some Ogre projects where the download size is crucial.
- The Terrain component does it, too. Was it written before the RTTS system was done or was there any other reason behind it?
- The shader is done so far. :)

So if no reason against the RTTS appears, I'd go with adding triplanar support to the RTTS and leave the current shader as CG file in the media folder as reference what I want to achieve.
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by Mattan Furst »

1. More that reasonable
2. I the terrain started way before the RTSS
3. Oh :oops:

The truth of the matter is that I'm quite fond of the RTSS system. Its one of those system that I think are under used in Ogre. And I'm trying to advance it.
it's turtles all the way down

al2950
OGRE Expert User
OGRE Expert User
Posts: 1214
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 149

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by al2950 »

Mattan Furst wrote: The truth of the matter is that I'm quite fond of the RTSS system. Its one of those system that I think are under used in Ogre. And I'm trying to advance it.
I could not agree more! I think we may need correlate our ideas on it as I think I might be given some time to work on it at work over the summer :D

@PhilipLB
Congratulations on the work you have done, it looks amazing, and I cant wait to have a play with it!!

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 57
Contact:

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by CABAListic »

Mattan Furst wrote: The truth of the matter is that I'm quite fond of the RTSS system. Its one of those system that I think are under used in Ogre. And I'm trying to advance it.
A significant part of that problem is that RTSS is imho also significantly under-documented. For example, my notion of what RTSS is and what it can actually do are still somewhat fuzzy :)
I'd definitely recommend a couple of Wiki articles introducing the system and showing how to use it. Or if those articles exist, they need to be promoted more prominently :)

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by jacmoe »

I am also guilty of not using it, because I don't know what it is, and what the pro's and the con's are.
Is there any docs on this in the development structure in our Wiki?
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by duststorm »

jacmoe wrote:Is there any docs on this in the development structure in our Wiki?
There is this page on the wiki.
I must say I find it very interesting and have since long planned to take a look at it, but haven't had the time yet. I like the fact that it allows one to write a shader technique once, and then reuse and combine as much as he wants. Especially since I find writing shaders manually really tedious.
The more techniques that get contributed to RTSS (Like the wonderful dual quaternion GSoC of last year, which really deserves more attention IMO. Kudos to the student too who still maintains the code after summer.) the more interesting it will become for people to use.
With the coming of the OpenGL3+ and D3D11 rendersystems I think it will be used much more often too.

The system is quite new and it's not completely documented yet, but the wiki page already mentions a lot of things. Unforunately there's not much "how to use it" information. In my opinion the new Ogre 1.8 manual should also feature a page about it. Maybe a tutorial about how to use it too ;)
If I ever get busy with it, I'll write about what I learned. If someone else doesn't beat me to it, that is.
Developer @ MakeHuman.org

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

I had a quick look at it and read the Wiki page. Lead me to revamp the roadmap. :) Now I make the triplanarReference shader a bit more configurable with defines and say it's done and afterwards, I start with the implementation of a triplanar SubRenderState. The shader code itself is not much, just like 10 lines.
What do you think?
If this plan is good, is it worthwhile to implement three shader files for GLSL, HLSL and CG or could it be just CG?
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by duststorm »

Adding triplanar to RTSS would be wonderful, and would increase the arsenal of tricks it has up its sleeve.
But as with any more general solution, adding it to RTSS will be more work than just doing it directly. (not sure how much work, though)
However, if you intend to provide a configurable shader material setup, RTSS is the way to go. Just make sure you don't devote too much time to it, as it's not an actual core task, just a nice-to-have.

Now if only the Ogre::Terrain component used RTSS for its materials too ;)
Developer @ MakeHuman.org

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

Actually, supporting a configurable material setup is on my list of desired core things. Started yesterday with my own materialgenerator, but didn't invest much time in it yet (Basically just created a MaterialPtr so far) as I was distracted with experimenting with Parallax Mapping similar to the one in the terrain component. But the parallax mapping didn't lead to something usefull except some LSD like effects. :)
So: I'd consider adding triplanar texturing to the RTTS as core task. Or?
But: I might change the order in the roadmap so the RTTS SubRenderState comes last.
Mattan? :)
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by duststorm »

In that case I think it's best to use RTSS instead of doing a custom system. :)
Developer @ MakeHuman.org

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by Mattan Furst »

I agree with duststorm.
The RTSS is by no means perfect, But it has a lot of work behind it and generating a competing system sounds redundant.
The RTSS has several months work on it and is very customization. I think you will do well using it.

I am kind of swamped at work but I should have time over the weekend to help with the RTSS. I'll try to write something by tomorrow evening to get you started if you need it. But for now the RTSS sample tests are the best references.
it's turtles all the way down

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

The wiki entry along with the samples look actually good to get started. I'll ask questions when they occure. :)
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by duststorm »

PhilipLB wrote:I'll ask questions when they occure. :)
Might be a good opportunity to improve the wiki docs. Questions you have could apply to others too.
Developer @ MakeHuman.org

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by Mattan Furst »

a couple ofnotes on debugging shaders coming from the RTSS:
  • Go to samplebrowser.h and define the preprocessor command _RTSS_WRITE_SHADERS_TO_DISK. This will write the generated shaders into the disk under the \Samples\Media\RTShaderLib\cache and make them easier to debug.
  • Find the file "OgreShaderProgramManager.h" and add a breakpoint in the line 496 ("pGpuProgram.setNull();"). If a shader will fail to compile it will usually fail their. Once that happens you can find the shader name under the programName parameter, then look for it in the cahce directory you created.
  • Other common problems with creating shaders in RTSS usually occur from defining vertex shader parameters and using them in the pixel shader and vice-verse. so watch out for those.
it's turtles all the way down

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

Good hints, thx.
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by Mattan Furst »

A bit of topic

I just added a new sample to Ogre's trunk which shows how to add a textured fog effects to the RTSS.

At the company I work at, our graphic engine renders large terrains. The textured fog (A different code but the idea is the same) is the first custom sub-render state I implemented. It really upgraded the look of our engine IMHO. This is one of the reasons I'm so in favor of the RTSS.

Check it out if you want.

P.S.
I still have some cleanup to do there but the sample works.

P.S.S.
FYI If you want to build Ogre fast you can try unity build. Turn the option on in CMake (search for the keyword unity) and it will drastically cut build time.
it's turtles all the way down

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

A simple, separeted example is always good! I'll have a look at it as soon as the Chunk loading here is moved to the WorkerQueue. This shouldn't take that long.
The Unity build is a good hint as the build time for ogre itself is a bit nasty here on an older dual core. :)

// Edit: Yep, after rebuilding everything after a merge from the main trunk, it's really a lot faster.
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

Just got an idea how to voxelize heightmaps. Scetched it here:
http://www.ogre3d.org/tikiwiki/tiki-ind ... xelisation
What do you think?
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by Mattan Furst »

I think that even if it works (which it probably will) it will be unscalable for large height map images. both in term of memory and run time. In worst case scenario the time complexity can be O(width * height * depth^2). with a memory complexity of O(width * height * depth)

I think you need to start from an octree structure. remember that the figures of distance to ground don't have to be exact.

I think a general algorithm would be.
  1. Create an octree.
  2. Divide those octree nodes that include the terrain in them recursively. Do this until you get to the required graininess. Do not attempt to calculate distance, at this point, only calculate whether the node is inside or outside the terrain.
  3. In the leafs of the octree only, calculate the shortest vector of the center of the node to the ground. (The length of the vector is also the distance to the terrain of course)
  4. work backward in a reversed DFS (depth first search) algorithm over the nodes. For each node calculate its approximate vector to the surface by:
    1. For each child node calculate the vector between the center of the node to the center of the child.
    2. For each such calculation add the resulting vector with the vector of the child to the surface.
    3. Select the shortest or median distance between all resulting vectors.
You can improve this algorithm's result by
1. calculating a non-leaf node distance to the surface by considering both the distance of its children and it's neighbours children.
2. not calculating the non-leaf node distance from its direct descendants but from some level lower down.
it's turtles all the way down

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

O(n^2) is bad, yep.

Going over an Octree could really be sensible, thx! Added this to the wiki. At least, this is stuff for the end of the GSoC or afterwards. :)
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

Weekly update is coming.
Just learned, that the Movie Maker is just a piece of sh**. The few minutes with Lightworks showed that this would be way over the top. Now playing with Blenders video features. :)

// Edit: Blender as video editor is great! Very simple and does what it's supposed to do.
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

Some more features and optimizations.
  • Finished the reference shader. Although it's missing shadows.
  • Updated the roadmap again. Removed the own material generation system, moved the other features in front and added triplanar texturing for RTTS afterwards.
  • Added a possibility to load a volume terrain from a config file.
  • Moved the calculation of the triplanar blending weights from the vertexshader to the pixelshader. Gives slightly nicer results.
  • Using Ogres memory allocators (OGRE_NEW, OGRE_DELETE, ...) for the resources now (OctreeNode deriving now from UtilityAlloc). Decreases the loading time by about a third!?
  • Encoding the isovalue in the length of the normal of the marching squares vertices which are completly within the volume. This value is then added to the planar mappings in the shader. The effect is, that there are way less texture distortions in the skirts.
  • Removed the parameter skirtBlendWeightInsideNormal as this is not needed anymore.
  • Fixed a bug in the generation of trilinear interpolated normals of the TextureSource.
  • Removed Chunk::setChunkMaterial() and overriding the now virtual SimpleRenderable::setMaterial().
[youtube]515ORZ9x7z8[/youtube]
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by Xavyiy »

Hi PhilipLB!
Really awesome work! Can't wait to play with it!

Btw, I've noticed some saturated colours on your triplanar shader compared to mine so I've had a look to your sources and found that:

Code: Select all

float4 textColour = float4(expand(col1.xyz * blendWeights.xxx +
                col2.xyz * blendWeights.yyy +
                col3.xyz * blendWeights.zzz), 1);
Why do you apply an expand operation to the final diffuse colour? (It's not a compressed normal, just a diffuse colour)

Without expanding it, you should get something like that:
Image

P.D.: Yes, saturated colours always looks cool, but I it doesn't represent the real colours :)

Xavier

PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: [GSoC 2012] Volume Rendering with LOD aimed at terrain

Post by PhilipLB »

Good question. I think I introduced it to "fix" some overbright colours when I didn't know what expand actually did. Can't remember, how I came up with it. :) But as said, if I remove it, everything is just bright. Would be nice, if you could show me your complete fix (maybe as PM)?
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.

Post Reply