Parallax Occlusion Mapping
-
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
Parallax Occlusion Mapping
I implemented Parallax Occlusion Mapping in Ogre.
Shader Features:
- Supports up to 3 Lights
- Parallax Occlusion Mapping (:D)
A screenshot taken from my editor:
.hlsl, .program and .material files (for Ogre 1.6):
See page 3
Shader Features:
- Supports up to 3 Lights
- Parallax Occlusion Mapping (:D)
A screenshot taken from my editor:
.hlsl, .program and .material files (for Ogre 1.6):
See page 3
Last edited by Caphalor on Tue Jun 09, 2009 12:38 pm, edited 6 times in total.
-
- Gnoblar
- Posts: 15
- Joined: Fri Mar 14, 2008 12:44 am
-
- Gnoll
- Posts: 653
- Joined: Thu May 11, 2006 9:12 pm
- Location: Bavaria
- x 36
Wow this looks damn nice, totally have to agree with Samuelgames
ARTIFEX TERRA 3D - Artist-friendly, free and easy WYSIWYG realtime outdoor scene Editor & Painter
New loader now with Ogre::Terrain support: Addons for Artifex on SourceForge
MOC - Minimal Ogre Collision & Mousepicking
Simple TerrainMaterialGenerator for the use of standard Ogre material with Ogre::Terrain
Support me on Patreon
-
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
-
- Halfling
- Posts: 43
- Joined: Mon Jan 02, 2006 9:32 pm
-
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
-
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
Very, very nice! This is excellent! I've been wanted to implement POM for a while now, but never found a decent source to observe (that also magically worked with Ogre)
Mind if I post a quick screenshot while playing around with it?
Depth scale of 1 needs ... quite a lot of samples
Anyways, note the FPS. On my 8800GTS, it runs a lot faster like this:
- ditch all of the LOD calculations, do complete POM regardless of distance/etc.
- ditch the derivatives, ray trace using the first mip level of the height texture:
Chances are that the POM was being computed for some fragments regardless of the LOD'ing; and the derivatives usually only make things slower.
In my honest opinion, not only does this run faster, but it also looks a lot better when at a distance. Of course, using the first mip map of the height map has its own problems, but it looks good enough and runs fast enough for most scenes, so it's up to you.
(I can post the source if you want, but all I did was the above tex2Dlod change and I commented out the derivatives calculation and all of the if's for the LOD)
EDIT:
Here's with min 10 and max 50 samples, with LOTS of processing (filling up a lot of the screen):
EDIT2: Sorry, I just can't stop playing with it, this is BEAUTIFUL, man!
Mind if I post a quick screenshot while playing around with it?
Code: Select all
float nMinSamples = 100;
float nMaxSamples = 200;
Anyways, note the FPS. On my 8800GTS, it runs a lot faster like this:
- ditch all of the LOD calculations, do complete POM regardless of distance/etc.
- ditch the derivatives, ray trace using the first mip level of the height texture:
Code: Select all
fCurrHeight = tex2Dlod( normalHeightMap, float4(vTexCurrentOffset, 0, 0)).a;
In my honest opinion, not only does this run faster, but it also looks a lot better when at a distance. Of course, using the first mip map of the height map has its own problems, but it looks good enough and runs fast enough for most scenes, so it's up to you.
(I can post the source if you want, but all I did was the above tex2Dlod change and I commented out the derivatives calculation and all of the if's for the LOD)
EDIT:
Here's with min 10 and max 50 samples, with LOTS of processing (filling up a lot of the screen):
EDIT2: Sorry, I just can't stop playing with it, this is BEAUTIFUL, man!
Last edited by nullsquared on Tue Jul 01, 2008 7:55 pm, edited 1 time in total.
-
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
I did not test the performance very much (my Editor has a fixed framerate at the moment), but thank you for the advice, I will try it soon.
Edit: You are right, the performance gain without LOD is really impressive! I updated the .rar file.
Edit2: Your screenshots are always welcome.
Edit: You are right, the performance gain without LOD is really impressive! I updated the .rar file.
Edit2: Your screenshots are always welcome.
Last edited by Caphalor on Tue Jul 01, 2008 8:38 pm, edited 3 times in total.
-
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
Nice results !
'Parallax Occlusion Mapping' is nice and can be used/extended to brillant ideas too.
Check the implementation used in the paper labeled 'Instant Animated Grass'
http://www.cg.tuwien.ac.at/research/pub ... _2007_IAG/
They did use Ogre and hlsl, and did released the shader and texture, only missing the .material file.
'Parallax Occlusion Mapping' is nice and can be used/extended to brillant ideas too.
Check the implementation used in the paper labeled 'Instant Animated Grass'
http://www.cg.tuwien.ac.at/research/pub ... _2007_IAG/
They did use Ogre and hlsl, and did released the shader and texture, only missing the .material file.
-
- Halfling
- Posts: 42
- Joined: Wed Apr 30, 2008 11:01 am
yup... I was waiting to get some time off so I could check that out... for our game....... atm we use PG for grass but it has some terrible disadvantages related to the grass......
To be or not to be that is the question that dazzles us for centuries, now modern science have found the answer: 0x2B | ~0x2B == 0xFF
-
- Minaton
- Posts: 973
- Joined: Fri Dec 28, 2007 4:35 pm
- Location: Germany
- x 1
Hi!
Very nice shader! IMHO these lines are a copy paste error in ParallaxOcclusionMapping.hlsl:
[Edit]
You can avoid one normalize() in the VS if you calculate the tangent space matrix like this:
The length of a cross is 1 if both vectors have the length 1.
Very nice shader! IMHO these lines are a copy paste error in ParallaxOcclusionMapping.hlsl:
Code: Select all
float Dist1 = length(lightPosition1 - position);
float Dist2 = length(lightPosition1 - position);
float Dist3 = length(lightPosition1 - position);
You can avoid one normalize() in the VS if you calculate the tangent space matrix like this:
Code: Select all
float3 nNormal = normalize(normal);
float3 nTangent = normalize(tangent);
float3 binormal = cross(nTangent, nNormal);
-
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
-
- Minaton
- Posts: 973
- Joined: Fri Dec 28, 2007 4:35 pm
- Location: Germany
- x 1
-
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
-
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 535
No it isn't.The length of a cross is 1 if both vectors have the length 1.
The length of a cross product is affected by the angle between the 2 vectors. The result is only length 1 if the 2 vectors are unit length and at 90 degrees to each other.
If the normal and tangent are always going to be at right angles, then it's fine. But that's a specific case.
-
- OGRE Retired Moderator
- Posts: 4011
- Joined: Fri Sep 19, 2003 6:28 pm
- Location: Burgos, Spain
- x 2
I think he wanted to say it's in the range [-1, 1]. When both vectors are normalised, their dot product returns the cosine of the angle they form as is, because it's multiplied by the length of both vectors (which in this particular case is exactly 1 for both)Kojack wrote:No it isn't.The length of a cross is 1 if both vectors have the length 1.
The length of a cross product is affected by the angle between the 2 vectors. The result is only length 1 if the 2 vectors are unit length and at 90 degrees to each other.
If the normal and tangent are always going to be at right angles, then it's fine. But that's a specific case.
-
- OGRE Expert User
- Posts: 1067
- Joined: Mon Mar 29, 2004 8:49 pm
- Location: the Netherlands
- x 43
Looking good!
If you are having fun with this, then you could try to improve the performance with relaxed cone step mapping. Also, you could try to improve the visual quality by adding shadow to it as well.
If you are having fun with this, then you could try to improve the performance with relaxed cone step mapping. Also, you could try to improve the visual quality by adding shadow to it as well.
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
-
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
Thank you for the advice!
As far as I understand, the cone mapping algorithm would replace my while loop, and all in all it would be cone mapping with a dynamic step count, right? I think I will try to implement it, but don't expect a working shader soon, I also have to continue the programming of my editor.
And finally concerning the shadows, do you mean self-shadowing or shadows in general?
As far as I understand, the cone mapping algorithm would replace my while loop, and all in all it would be cone mapping with a dynamic step count, right? I think I will try to implement it, but don't expect a working shader soon, I also have to continue the programming of my editor.
And finally concerning the shadows, do you mean self-shadowing or shadows in general?
-
- OGRE Expert User
- Posts: 1067
- Joined: Mon Mar 29, 2004 8:49 pm
- Location: the Netherlands
- x 43
I meant self shadowing, because you can do that really easy once you have the ray marching working.
As for the relaxed cone step mapping: it is a pretty difficult one to implement, because it also requires a tool to generate the cone step map in the first place. Requires a lot of time to make, I would expect. That's why I first asked whether you are having fun with this. Relaxed cone step mapping is an awesome algorithm, though!
As for the relaxed cone step mapping: it is a pretty difficult one to implement, because it also requires a tool to generate the cone step map in the first place. Requires a lot of time to make, I would expect. That's why I first asked whether you are having fun with this. Relaxed cone step mapping is an awesome algorithm, though!
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
-
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
Wait, is there a difference between what you're describing and what one of those gamedev.net geniuses posted? Because the demo he provides runs with perfect quality (no aliasing or errors on the edges whatsoever) at least 10 times faster than POM or relief mapping with 200 steps (even at which you can still notice errors).Oogst wrote:I meant self shadowing, because you can do that really easy once you have the ray marching working.
As for the relaxed cone step mapping: it is a pretty difficult one to implement, because it also requires a tool to generate the cone step map in the first place. Requires a lot of time to make, I would expect. That's why I first asked whether you are having fun with this. Relaxed cone step mapping is an awesome algorithm, though!
-
- OGRE Contributor
- Posts: 1316
- Joined: Tue Nov 21, 2006 11:28 am
- Location: Groningen, The Netherlands
- x 18
I don't know, can you provide a link to the GameDev.net post? Cone Step Mapping and Relaxed Cone Mapping are described in GPU Gems 2 & 3 respectively, and the image in there are very good quality.nullsquared wrote:Wait, is there a difference between what you're describing and what one of those gamedev.net geniuses posted? Because the demo he provides runs with perfect quality (no aliasing or errors on the edges whatsoever) at least 10 times faster than POM or relief mapping with 200 steps (even at which you can still notice errors).