Cone Step Mapping (Ogre CG port)

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

Kojack wrote:Hmm, I just ran cube.mesh through the xml convertor and examined the xml output.
Strange.
First, there's 25 vertices, one of which isn't used (it's in the middle).
Second, Every vertex has a normal of either <0,0,1.5708> or <0,0,-1.5708>.
That's not normalised, and all normals face along the z or -z axis.
Alright, so I think we can pretty much agree that these issues are caused by incorrect normals (or possibly incorrect UV's, which would lead to incorrect tangents). Like I said, rotating planes, the knot mesh, the Ogre head, they all work fine.
User avatar
vilgeits
Goblin
Posts: 298
Joined: Tue Aug 02, 2005 10:41 pm

Post by vilgeits »

nullsquared wrote:
Kojack wrote:Hmm, I just ran cube.mesh through the xml convertor and examined the xml output.
Strange.
First, there's 25 vertices, one of which isn't used (it's in the middle).
Second, Every vertex has a normal of either <0,0,1.5708> or <0,0,-1.5708>.
That's not normalised, and all normals face along the z or -z axis.
Alright, so I think we can pretty much agree that these issues are caused by incorrect normals (or possibly incorrect UV's, which would lead to incorrect tangents). Like I said, rotating planes, the knot mesh, the Ogre head, they all work fine.
Have you tried with barrel? it seems to be much more like my exported meshes (in xml)

A 'tiny' example: box (it seems that this should work fine... but it doesn't)

Code: Select all

<mesh>

   <submeshes>
      <submesh material="caja" usesharedvertices="false" use32bitindexes="false" operationtype="triangle_list">
         <faces count="12">
            <face v1="0" v2="1" v3="2" />
            <face v1="3" v2="4" v3="5" />
            <face v1="6" v2="7" v3="8" />
            <face v1="9" v2="10" v3="11" />
            <face v1="12" v2="13" v3="14" />
            <face v1="15" v2="16" v3="17" />
            <face v1="18" v2="19" v3="20" />
            <face v1="21" v2="22" v3="23" />
            <face v1="24" v2="25" v3="26" />
            <face v1="27" v2="28" v3="29" />
            <face v1="30" v2="31" v3="32" />
            <face v1="33" v2="34" v3="35" />
         </faces>
         <geometry vertexcount="36">
            <vertexbuffer positions="true" normals="true" texture_coord_dimensions_0="2" texture_coords="1" >
               <vertex>
                  <position x="-4.20034" y="0.0" z="1.28093" />
                  <normal x="0.0" y="-1.0" z="0.0" />
                  <texcoord u="2.16667" v="2.17785" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="-3.71907" />
                  <normal x="0.0" y="-1.0" z="0.0" />
                  <texcoord u="2.16667" v="-1.17785" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="-3.71907" />
                  <normal x="0.0" y="-1.0" z="0.0" />
                  <texcoord u="-1.16667" v="-1.17785" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="-3.71907" />
                  <normal x="0.0" y="-1.0" z="0.0" />
                  <texcoord u="-1.16667" v="-1.17785" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="1.28093" />
                  <normal x="0.0" y="-1.0" z="0.0" />
                  <texcoord u="-1.16667" v="2.17785" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="1.28093" />
                  <normal x="0.0" y="-1.0" z="0.0" />
                  <texcoord u="2.16667" v="2.17785" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="1.28093" />
                  <normal x="0.0" y="1.0" z="0.0" />
                  <texcoord u="-1.16667" v="2.17785" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="1.28093" />
                  <normal x="0.0" y="1.0" z="0.0" />
                  <texcoord u="2.16667" v="2.17785" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="-3.71907" />
                  <normal x="0.0" y="1.0" z="0.0" />
                  <texcoord u="2.16667" v="-1.17785" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="-3.71907" />
                  <normal x="0.0" y="1.0" z="0.0" />
                  <texcoord u="2.16667" v="-1.17785" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="-3.71907" />
                  <normal x="0.0" y="1.0" z="0.0" />
                  <texcoord u="-1.16667" v="-1.17785" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="1.28093" />
                  <normal x="0.0" y="1.0" z="0.0" />
                  <texcoord u="-1.16667" v="2.17785" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="1.28093" />
                  <normal x="0.0" y="0.0" z="1.0" />
                  <texcoord u="-1.16667" v="1.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="1.28093" />
                  <normal x="0.0" y="0.0" z="1.0" />
                  <texcoord u="2.16667" v="1.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="1.28093" />
                  <normal x="0.0" y="0.0" z="1.0" />
                  <texcoord u="2.16667" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="1.28093" />
                  <normal x="0.0" y="0.0" z="1.0" />
                  <texcoord u="2.16667" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="1.28093" />
                  <normal x="0.0" y="0.0" z="1.0" />
                  <texcoord u="-1.16667" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="1.28093" />
                  <normal x="0.0" y="0.0" z="1.0" />
                  <texcoord u="-1.16667" v="1.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="1.28093" />
                  <normal x="1.0" y="0.0" z="0.0" />
                  <texcoord u="-1.17785" v="1.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="-3.71907" />
                  <normal x="1.0" y="0.0" z="0.0" />
                  <texcoord u="2.17785" v="1.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="-3.71907" />
                  <normal x="1.0" y="0.0" z="0.0" />
                  <texcoord u="2.17785" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="-3.71907" />
                  <normal x="1.0" y="0.0" z="0.0" />
                  <texcoord u="2.17785" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="1.28093" />
                  <normal x="1.0" y="0.0" z="0.0" />
                  <texcoord u="-1.17785" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="1.28093" />
                  <normal x="1.0" y="0.0" z="0.0" />
                  <texcoord u="-1.17785" v="1.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="-3.71907" />
                  <normal x="0.0" y="0.0" z="-1.0" />
                  <texcoord u="-1.16667" v="1.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="-3.71907" />
                  <normal x="0.0" y="0.0" z="-1.0" />
                  <texcoord u="2.16667" v="1.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="-3.71907" />
                  <normal x="0.0" y="0.0" z="-1.0" />
                  <texcoord u="2.16667" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="-3.71907" />
                  <normal x="0.0" y="0.0" z="-1.0" />
                  <texcoord u="2.16667" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="3.0" z="-3.71907" />
                  <normal x="0.0" y="0.0" z="-1.0" />
                  <texcoord u="-1.16667" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="0.799656" y="0.0" z="-3.71907" />
                  <normal x="0.0" y="0.0" z="-1.0" />
                  <texcoord u="-1.16667" v="1.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="-3.71907" />
                  <normal x="-1.0" y="0.0" z="0.0" />
                  <texcoord u="-1.17785" v="1.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="1.28093" />
                  <normal x="-1.0" y="0.0" z="0.0" />
                  <texcoord u="2.17785" v="1.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="1.28093" />
                  <normal x="-1.0" y="0.0" z="0.0" />
                  <texcoord u="2.17785" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="1.28093" />
                  <normal x="-1.0" y="0.0" z="0.0" />
                  <texcoord u="2.17785" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="3.0" z="-3.71907" />
                  <normal x="-1.0" y="0.0" z="0.0" />
                  <texcoord u="-1.17785" v="-0.5" />
               </vertex>
               <vertex>
                  <position x="-4.20034" y="0.0" z="-3.71907" />
                  <normal x="-1.0" y="0.0" z="0.0" />
                  <texcoord u="-1.17785" v="1.5" />
               </vertex>
            </vertexbuffer>
         </geometry>

      </submesh>

   </submeshes>


   <submeshnames>
      <submeshname name="Box01_plano" index="0" />
   </submeshnames>
</mesh>
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

I just ran that through XML converter, it works fine for me :|
Image

What hardware do you have? I'm not quite sure what to say, I can't reproduce your error.
User avatar
vilgeits
Goblin
Posts: 298
Joined: Tue Aug 02, 2005 10:41 pm

Post by vilgeits »

Win Vista SP1
GForce 8800 GT 512
Ogre 1.6 (From Subversion)
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

vilgeits wrote:Win Vista SP1
GForce 8800 GT 512
Ogre 1.6 (From Subversion)
That should definitely be able to run fine. I honestly have absolutely no clue why it doesn't work for you.
User avatar
vilgeits
Goblin
Posts: 298
Joined: Tue Aug 02, 2005 10:41 pm

Post by vilgeits »

sorry you were right, it was a problem with my vertex shader script
bharling
Gremlin
Posts: 166
Joined: Fri Jun 30, 2006 1:04 pm

Post by bharling »

is Ogre 1.6 a requirement to run this shader? I cant seem to get it working in my project with 1.4.9 ( I'm not getting any shader or material errors, just a flat texture on the material )

cheers .. ;)
Was here
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

bharling wrote:is Ogre 1.6 a requirement to run this shader? I cant seem to get it working in my project with 1.4.9 ( I'm not getting any shader or material errors, just a flat texture on the material )

cheers .. ;)
No, in fact I'm still back at 1.4.6. Can I see the log? Did you generate a proper cone step map? It's different from a height map (check my original post for a link to the thread on gamedev, where you can find the demo & tool to make cone step maps)
bharling
Gremlin
Posts: 166
Joined: Fri Jun 30, 2006 1:04 pm

Post by bharling »

Aha, well seems like my ATI X1650 does not support tex2dlod

Code: Select all

16:19:39: Parsing script csm.material
16:19:39: OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program csm_ps: CG ERROR : The compile returned an error.
(97) : error C5201: invalid internal function declaration for "tex2Dlod"
 in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)
16:19:39: High-level program csm_ps encountered an error during loading and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program csm_ps: CG ERROR : The compile returned an error.
(97) : error C5201: invalid internal function declaration for "tex2Dlod"
 in CgProgram::loadFromSource at ..\src\OgreCgProgramManagerDll.cpp (line 66)
However i originally tried it on my work machine, which is where I had the problem, I dont have access to that at the moment, but I did check the log and there was definitely no error reported ( the texture showed up, just no CSM effect, I would have expected the default white material if the shader compile failed ). However I was adding the material to Ogre.Plane's instead of a proper mesh, that could well be the problem as a Plane created in ogre doesn't have tangent coords by default ( i think ? )

I'm more interested in getting it to work here though, anyone know a way around tex2Dlod?
Was here
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

That's odd. tex2Dlod() is just a standard variation of tex2D() in ps_3_0. Can you check the material to make sure it's using ps_3_0? As for OpenGL, technically you should use fp40, but OpenGL is a little fubar for me right now, so I can't personally test under OpenGL.

Did you use a proper cone step map? Maybe I should include some example cone step map in the original post for testing. I'll go do that now.

A way around tex2Dlod() would be to use:

Code: Select all

// at the top of intersect_square_cone_exp
float2 dx = ddx(dp.xy);
float2 dy = ddy(dp.xy);

// at the sight of tex2Dlod, replace with
t = tex2D(csmMap, dp.xy, dx, dy);
Which is the "correct" way of doing it, except I find it very slow under some conditions.
bharling
Gremlin
Posts: 166
Joined: Fri Jun 30, 2006 1:04 pm

Post by bharling »

Sorry, yes I'm using the cone map from the original demo, so I think it should work. Thanks for the fix, will try that when I finally get home!
Was here
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

@nullsquared:
Could you wiki this, please? :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: Cone Step Mapping (Ogre CG port)

Post by lukeneorm »

nullsquared wrote:Paper & demo here: http://www.gamedev.net/community/forums ... _id=372739 (appears to be some patenting issues, don't use this commercially without researching all of that first)

I consider CSM completely superior to relief mapping or parallax occlusion mapping for 2 reasons:
- it's crazy fast
- it's crazy accurate
However, it has its own fallback: you must pre-process all of your height maps to produce cone step maps. Yet, this not all that bad, considering you can extract normals from the cone step map, meaning there's no need for an additional normal map.
Hi,
I'm trying to use your shaders in my simple scene, but when I run the application the loader rise this exeption:
OGRE EXCEPTION(2:InvalidParametersException): Parameter called texSize does not exist. in GpuProgramParameters::_findNamedConstantDefinition at ..\src\OgreGpuProgram.cpp (line 1097)
While the only mesh of the scene (a simple plane) seems to take only the texture from the shader, without any depth:
Image
I use OGRE 1.6.2, Direct3D, and I tried the application both on an nVidia GeForce 9400M and on an nVidia Quadro 750.

What kind of error is that? :(
Thank you!
jmd
Gnoblar
Posts: 6
Joined: Tue Jan 20, 2009 10:22 pm

Re: Cone Step Mapping (Ogre CG port)

Post by jmd »

Because the paramter is not used in the shader (the line using it is commented), the compiler removes it.
Setting this parameter in the material generates this error.

Either uncomment the line in the shader or don't send it a value in the material.
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: Cone Step Mapping (Ogre CG port)

Post by lukeneorm »

jmd wrote:Because the paramter is not used in the shader (the line using it is commented), the compiler removes it.
Setting this parameter in the material generates this error.

Either uncomment the line in the shader or don't send it a value in the material.
Thak you for your reply jmd!
I uncomment the lines where texSize is involved with, and now the loader doesn't rise any warning. But the plane is still.. a plane. With its beautiful texture, but.. no way to see relief map on it (see the picture in my previous post). :(
It seems to me very strange, since the loader doesn't rise any warning about material compilation.. :?
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: Cone Step Mapping (Ogre CG port)

Post by nullsquared »

Does your plane have proper normals and tangents generated?
User avatar
iloseall
Gremlin
Posts: 156
Joined: Sun Sep 14, 2003 3:54 am
Location: Beijing China
Contact:

Re: Cone Step Mapping (Ogre CG port)

Post by iloseall »

great.
(I used a small alpha_rejection hack above to reject tiling, very cool-looking for terrains and what-not)
What's the "small alpha_rejection hack "?
User avatar
Lee04
Minaton
Posts: 945
Joined: Mon Jul 05, 2004 4:06 pm
Location: Sweden
x 1

Re: Cone Step Mapping (Ogre CG port)

Post by Lee04 »

Cone step mapping reslults looks very simular to the Ogre show case I did with my colleage some years a go here.
But that used per-pixel displacement mapping.

First weeks no one at the forum understod what it was...no reaction...even though GPU Gems had it for a year or more at the time. :-)

I notice that there is a big abbysse (years) inbetween released new papers and things developer conferences talks about and what is actually put into Ogre or done with Ogre.

Great work!
Ph.D. student in game development
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Cone Step Mapping (Ogre CG port)

Post by Kojack »

Cone step mapping reslults looks very simular to the Ogre show case I did with my colleage some years a go here.
But that used per-pixel displacement mapping.
I assume you are talking about: http://www.ogre3d.org/forums/viewtopic. ... =50#p72122
Have you got any pics of it? None of the links work anymore.
First weeks no one at the forum understod what it was...no reaction...even though GPU Gems had it for a year or more at the time. :-)
Weeks? It was 2 days before people understood that displacement mapping was different to the ogre version of parallax mapping from a year earlier.
Maybe there wasn't much reaction because it was in the middle of a thread where you were advertising a 3000 euro ogre render plugin, most people probably didn't make it to the third page to see the displacement mapping discussion.
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: Cone Step Mapping (Ogre CG port)

Post by nullsquared »

iloseall wrote:great.
(I used a small alpha_rejection hack above to reject tiling, very cool-looking for terrains and what-not)
What's the "small alpha_rejection hack "?
I honestly forgot exactly what i did... I think I had alpha rejection turned on, and then if the texture coordinates went outside of [0..1] then the fragment got 0 alpha, and thus got rejected. Therefore, when something was displaced, it wasn't tiled over "its walls", so you could see "through" it. Kind of hard to explain.
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: Cone Step Mapping (Ogre CG port)

Post by lukeneorm »

nullsquared wrote:Does your plane have proper normals and tangents generated?
You're right: I used oFusion exporter from 3DStudio for my scene, and I supposed that the "export normals" feature in the plug-in worked well, but obviously I was wrong. Using OgreMeshUpgrade command line tool fixed the problem.
Thank you! :wink:
NeParij
Gnoblar
Posts: 6
Joined: Tue Jun 28, 2011 9:26 pm

Re: Cone Step Mapping (Ogre CG port)

Post by NeParij »

Can anybody help me to make it works under GL Renderer?
I've stuck on it last 2 weeks.

* Supported Shader Profiles: arbfp1 arbvp1 fp20 fp30 fp40 glsl gp4fp gp4gp gp4vp gpu_fp gpu_gp gpu_vp nvgp4 vp30 vp40
Post Reply