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.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.
Cone Step Mapping (Ogre CG port)
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
- vilgeits
- Goblin
- Posts: 298
- Joined: Tue Aug 02, 2005 10:41 pm
Have you tried with barrel? it seems to be much more like my exported meshes (in xml)nullsquared wrote: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.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.
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>
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
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 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 ..
-
- Gremlin
- Posts: 166
- Joined: Fri Jun 30, 2006 1:04 pm
Aha, well seems like my ATI X1650 does not support tex2dlod
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?
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)
I'm more interested in getting it to work here though, anyone know a way around tex2Dlod?
Was here
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
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:
Which is the "correct" way of doing it, except I find it very slow under some conditions.
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);
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
@nullsquared:
Could you wiki this, please?
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.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Halfling
- Posts: 61
- Joined: Wed Apr 01, 2009 12:03 am
Re: Cone Step Mapping (Ogre CG port)
Hi,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.
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:
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!
-
- Gnoblar
- Posts: 6
- Joined: Tue Jan 20, 2009 10:22 pm
Re: Cone Step Mapping (Ogre CG port)
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.
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.
-
- Halfling
- Posts: 61
- Joined: Wed Apr 01, 2009 12:03 am
Re: Cone Step Mapping (Ogre CG port)
Thak you for your reply jmd!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.
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..
- 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)
Does your plane have proper normals and tangents generated?
- iloseall
- Gremlin
- Posts: 156
- Joined: Sun Sep 14, 2003 3:54 am
- Location: Beijing China
- Contact:
Re: Cone Step Mapping (Ogre CG port)
great.
What's the "small alpha_rejection hack "?(I used a small alpha_rejection hack above to reject tiling, very cool-looking for terrains and what-not)
- Lee04
- Minaton
- Posts: 945
- Joined: Mon Jul 05, 2004 4:06 pm
- Location: Sweden
- x 1
Re: Cone Step Mapping (Ogre CG port)
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!
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
- Kojack
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 534
Re: Cone Step Mapping (Ogre CG port)
I assume you are talking about: http://www.ogre3d.org/forums/viewtopic. ... =50#p72122Cone 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.
Have you got any pics of it? None of the links work anymore.
Weeks? It was 2 days before people understood that displacement mapping was different to the ogre version of parallax mapping from a year earlier.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.
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.
- 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)
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.iloseall wrote:great.
What's the "small alpha_rejection hack "?(I used a small alpha_rejection hack above to reject tiling, very cool-looking for terrains and what-not)
-
- Halfling
- Posts: 61
- Joined: Wed Apr 01, 2009 12:03 am
Re: Cone Step Mapping (Ogre CG port)
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.nullsquared wrote:Does your plane have proper normals and tangents generated?
Thank you!
-
- Gnoblar
- Posts: 6
- Joined: Tue Jun 28, 2011 9:26 pm
Re: Cone Step Mapping (Ogre CG port)
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
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