Re: [osg-users] StandardShadowMap on ATI

2010-09-06 Thread Wojciech Lewandowski

Hi Everyone browsing this thread.

I just downoaded Catalyst 10.8 for Windows. Its a pleasure to report that 
problems (broken TexMat  base Textures) with osgShadow  example on recent 
Catalyst versions 10.4-10.7 seem to be fixed on 10.8. Thats the way to go 
AMD ;-). I tested on OSG trunk 32 bit / Windows 7 64 bit / Radeon 5980 .


Wojtek

--
From: Bradley Baker Searles bsear...@carsim.com
Sent: Wednesday, August 04, 2010 6:13 PM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] StandardShadowMap on ATI


Hi Wojtek,

Ahh, good catch with the improper derivation!  :)  Thank you. I'm 
attaching the corrected st.h file.


I just tried to get the osgShadow example working (-4 --lispsm), and it 
didn't work with any of the workarounds that I'd used in my code (not 
using variables to index light sources, don't use derived light values 
such as gl_FrontLightModelProduct, skip empty program add, etc).


Now the standard LispSM does its lighting in the vertex shader, and all of 
my Programs do their lighting in the fragment programs...  so there may be 
additional tricks for vert shaders that I'm not yet aware of?


I haven't tried any of the other techniques yet, but perhaps I'll see if 
those can be patched up.  But... even if we could patch them, the fixes 
are ugly enough that I don't think they'd belong in the osg source. 
Perhaps I should post some of these issues on the ATI forums.


Thank you!
Baker

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30533#30533




Attachments:
http://forum.openscenegraph.org//files/st_191.h


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StandardShadowMap on ATI

2010-08-04 Thread Wojciech Lewandowski

Perfect !

One thing got me intrigued, though. You derive internal ViewData class from 
MinimalShadowMap::ViewData instead of 
VsvCustomShadowTechniqueClass::ViewData. Is it deliberate ? I suspect this 
works because VsvCustomShadowTechniqueClass is actually 
MinimalCullBoundsShadowMap and MinimalCullBoundsShadowMap::ViewData does not 
differ from MinimalShadowMap::ViewData. But if one day you will try to 
change VsvCustomShadowTechniqueClass typedef to other ViewDependentTechnique 
class some issues may appear.


PS. In the meantime I managed to install Catalsyst 10.7. Textures on island 
scene are still broken (as in 10.5/10.6) no matter which shadow technique I 
use. They are broken even with the simplest ShadowMap. Perhaps, you have 
found a workaround for this problem ?


Wojtek



--
From: Bradley Baker Searles bsear...@carsim.com
Sent: Tuesday, August 03, 2010 10:47 PM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] StandardShadowMap on ATI

Alright, so just wanted to post the code for the overrides I did, just in 
case anyone stumbles upon this forum entry and wants to see precisely what 
I did.  It's a bit different than the example that Wojtek posted in this 
thread (as referenced above):


http://forum.openscenegraph.org/viewtopic.php?t=4178   (Wojtek's 
MyViewDependentShadowMap example)


:D

Seems to be working very well.

Thanks again-
Baker Searles

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30504#30504




Attachments:
http://forum.openscenegraph.org//files/osgforum_ati_107_drivers_266.jpg
http://forum.openscenegraph.org//files/st_174.cpp
http://forum.openscenegraph.org//files/st_482.h


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StandardShadowMap on ATI

2010-08-04 Thread Bradley Baker Searles
Hi Wojtek,

Ahh, good catch with the improper derivation!  :)  Thank you. I'm attaching the 
corrected st.h file.

I just tried to get the osgShadow example working (-4 --lispsm), and it didn't 
work with any of the workarounds that I'd used in my code (not using variables 
to index light sources, don't use derived light values such as 
gl_FrontLightModelProduct, skip empty program add, etc).

Now the standard LispSM does its lighting in the vertex shader, and all of my 
Programs do their lighting in the fragment programs...  so there may be 
additional tricks for vert shaders that I'm not yet aware of?

I haven't tried any of the other techniques yet, but perhaps I'll see if those 
can be patched up.  But... even if we could patch them, the fixes are ugly 
enough that I don't think they'd belong in the osg source.  Perhaps I should 
post some of these issues on the ATI forums.

Thank you!
Baker

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30533#30533




Attachments: 
http://forum.openscenegraph.org//files/st_191.h


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StandardShadowMap on ATI

2010-08-03 Thread Bradley Baker Searles
Alright, so just wanted to post the code for the overrides I did, just in case 
anyone stumbles upon this forum entry and wants to see precisely what I did.  
It's a bit different than the example that Wojtek posted in this thread (as 
referenced above):

http://forum.openscenegraph.org/viewtopic.php?t=4178   (Wojtek's 
MyViewDependentShadowMap example)

 :D 

Seems to be working very well.

Thanks again-
Baker Searles

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30504#30504




Attachments: 
http://forum.openscenegraph.org//files/osgforum_ati_107_drivers_266.jpg
http://forum.openscenegraph.org//files/st_174.cpp
http://forum.openscenegraph.org//files/st_482.h


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StandardShadowMap on ATI

2010-07-29 Thread Wojciech Lewandowski

Hi Baker,

My responses below.

 Just for reference, the modifications I've made in my glsl shaders to get 
it running on ATI were mainly the following:



 - only index texture coordinates with constants, variables (even const) 
don't seem to work.

 - ensure all variables are initialized (sloppy on my part)
 - hardcode to light 0, the accumulation loop did not work.
 - don't use gl_FrontMaterial / gl_BackMaterial, as the values didn't work 
as they did with nVidia, and produced unexpected values.

 - don't use gl_FrontLightModelProduct, same reason as previous.


Thats the ATI. I stay with Catalyst 10.4. With 10.5 I had the issues you 
show on osgshadow screenshots.  10.6 and 10.7 does not start on my machine. 
Bombs with blue screen on startup. Thats maybe related to the fact that I 
switched to dual GPU Radeon 5970.  I saw on ATI forums that blue screens 
happen on dual GPU Radeons.




 I'm not using alpha in a nonstandard way (at least not intentionally), 
and I don't use discard for anything.  That's good information though, and 
I will fiddle around with my shaders to see if they have any impact 
(although with the NULL program, they shouldn't be used, eh?).


 So having said that, the use of a NULL program indeed does seem like it 
should be valid, as specified in the OpenGL 21.20061201 spec (p. 75), and 
indeed OSG does call glUseProgram(0),  which should revert to fixed 
function.  So this is a driver bug, right?


 Still, I agree it might be useful to let the user provide a Program to 
use, or whether to attach the NULL program.


I agree. However, its should be more generic to allow for modification of 
other StateAttributes as well. Some callback maybe... Currently the only 
option is overriding technique  its internal ViewData class (which is bit 
tricky but I think I have posted 'how to do it' on the forum).


 I ran osgshadow on the ATI 4670 with the 10.7 drivers, and I'll post the 
results below.  I'm also attaching a screenshot of the vehicle in 
osgviewerWX, which seems to be having some texture coordinate issues 
(again, fine on nVidia).  Hmm, even the osg cow seems wrong.


 I don't know precisely what the Texture Matrix fix is that you're 
speaking about, but I can poke around the forums and see if I find the 
issue.


There is a line in  Main Vertex Shader where tex coords at index zero 0 are 
computed:

   gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TextureMatrix seems to be initialized to 0 on ATI Catalyst 10.4 and 
resulting tex coords are always 0.


Workaround for this is to either comment out gl_TextureMatrix[0] 
multiplication in this shader or set up identity osg::TexMat at the scene 
root state set.


With above change I am fairly happy on 10.4. So I recommend you try these 
drivers. For my laptop with really old ATi XPress 1200 I use Catalyst 10.2 
and these drivers seem to be even better because osgshadow works without any 
modifications. I must be honest with you though. I actually have two cards 
on my Windows 7 one NVidia 8800 and Radeon 5970. And NVidia is most of the 
time the card of choice for OpenGL.  So I maybe shoud not say I do lots of 
extensive testing on the Radeon. I switch to it  when I want to check code 
compatibilty.


As I wrote earlier I am not able to get 10.6 and 10.7 to start up. But I 
have earlier tried 10.5 and they showed the same problems with texture that 
looked like your screenshots. We discussed this on the osg-forum couple 
weeks ago (http://forum.openscenegraph.org/viewtopic.php?p=29501#29501) So 
you may consider giving 10.4 or earlier drivers second chance ;-)



 And by the way, thanks for the lispsm submission, it's really well done!


I am happy when people use it ;-)

Cheers,
Wojtek


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StandardShadowMap on ATI

2010-07-29 Thread Bradley Baker Searles
Hi Wojtek-

  Thanks again for the thoughtful response.

  I believe I have enough information to work around this issue now.  I just 
wanted to post my last set of findings for anyone else who might be helped by 
the thread.

  I installed catalyst 10.4 and 10.2, and I never quite got to a point where 
everything worked as expected.  I will post some screenshots below.  I am 
thinking I will probably just go with the latest drivers and work around the 
NULL program driver bug, either by hacking our local OSG copy, or doing the 
proper ViewData override as you suggested (haven't looked at those details yet).

  Ahh, yes the texture matrix issue in the glsl.  I had indeed already done 
that (just omitted the matrix altogether in the shader as you referenced). I 
didn't think to attach an osg TexMat identity matrix at the root, so I was 
confused by your reference to the osg TexMat class  :)  But the TexMat solution 
is probably a more appropriate workaround.

Take care-
Baker Searles

P.S. Yes I too had a dual-gpu ATI setup at home last year (dual 4850 in 
crossfire) and they were crazy fast, but I had render issues in Fallout 3 (HDR 
effects would blink on and off) so I had to drop down to using just one of the 
boards.  I guess you can't do that though with the 5970 having both chips on 
one board  :)

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30405#30405




Attachments: 
http://forum.openscenegraph.org//files/ati_102_osgshadow_4_sm_211.jpg
http://forum.openscenegraph.org//files/ati_102_osgshadow_4_lispsm_299.jpg
http://forum.openscenegraph.org//files/ati_102_osgshadow_4_stsm_112.jpg
http://forum.openscenegraph.org//files/ati_102_osgviewer_coupe_106.jpg
http://forum.openscenegraph.org//files/ati_102_coupe_143.jpg


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StandardShadowMap on ATI

2010-07-28 Thread Wojciech Lewandowski

Hi Bradley,

I have not tested StandardShadowMap with Catalyst 10.7.  10.5  10.6 did not 
work for me so I have been staying at 10.4. With 10.4 the only issue I had 
was TexMat not initialized to identity and mainVertexShader in Standard 
Shadow Map was producing 0,0 base texture coords for all frgments.


I guess you have a bit different situation, though. You write that your 
scene already contains programs with shaders. When NULL program is applied 
with override, it means that your shaders are blocked and fixed pipeline 
draws the shadow map. So you may have the problems if your shaders compute 
alpha with some non standard (non repeatable in fixed pipeline) way or 
discard fragments.


I must admit that for above case setting NULL program might be seen as a 
bug. However, it was done in purpose to make shadow map rendering faster 
because color does not need to be computed and thus there is no need to use 
existing usually more complex shaders. But if they discard fragments or 
compute depth it may be not such good idea after all... We may try to come 
up with a new method to let user select if he/she wants to set this NULL 
program or not.


Out of curiosity does the same problem appear in osgshadow example ? The 
example works on 10.4 (with minor TexMat modification).


Try: osgshadow -4 --lispsm  or  osgshadow -4 --stsm

Cheers,
Wojtek
--
From: Bradley Baker Searles bsear...@carsim.com
Sent: Wednesday, July 28, 2010 12:48 AM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] StandardShadowMap on ATI


Hi,

 I have been working for a while on compatibility issues with nVidia and 
ATI in our OpenSceneGraph application.  Aside from a fair number of GLSL 
shader source issues, one of the last remaining problems was that textured 
objects were not casting shadows (please see first attached screenshot).


 After a little detective work, it seems that the empty osg Program 
attached to the StateSet belonging to the _camera in 
StandardShadowMap::ViewData::init() is causing the problem:





// optimization attributes
osg::Program* program = new osg::Program;
stateset-setAttribute( program, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON );

stateset-setMode
( GL_LIGHTING, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::OFF );

stateset-setMode
( GL_BLEND, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::OFF );


#if 0 // fixed pipeline seems faster (at least on my 7800)
program-addShader( new osg::Shader( osg::Shader::FRAGMENT,
uniform sampler2D texture; 
\n
void main(void) 
\n


{\n
 gl_FragColor = texture2D( texture, gl_TexCoord[0].xy ); 
\n
} 
\n

) ); // program-addShader Fragment

program-addShader( new osg::Shader( osg::Shader::VERTEX,
void main(void) 
\n


{\n
   gl_Position = ftransform(); 
\n
   gl_TexCoord[0] = gl_MultiTexCoord0; 
\n
} 
\n

) ); // program-addShader Vertex
#endif




 The setting of the fragment and vertex shaders to the stateset are #if 
0'd out, but the osg Program setting is not.


 Anyway, if I skip adding the empty program, things seem fine.  Oddly, if 
I keep the empty program and skip the AlphaFunc above it that allows 
texture alpha to affect the depth buffer render, it casts shadows properly 
(well, without the alpha penetration of course).


 Everything works fine with nVidia drivers, even with the empty program.

 My scene has a mixture of shader programs depending on how the objects 
are setup, but they all include the shadow shader source (except the flat 
shaded objects like the force arrows shown below).


 So it seems to be an easy fix, but I was curious if anyone else had run 
into this problem?  I did many searches on the forum and came up empty.


 And if anyone has deeper illumination into how the empty program could 
affect the statesets (seems like a bug to me since nVidia works fine), or 
if there is a more appropriate fix I'm not thinking of, I'd appreciate the 
feedback.


Thanks-
Baker Searles


Hardware Versions:
nVidia GTS 250
ATI Radeon HD4670

Software Versions:
OSG @ 2.8.3
ATI Display Drivers @ 10.7
nVidia Display Drivers @ 258.96

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30329#30329




Attachments:
http://forum.openscenegraph.org//files/ati_emptyglslprogram_noalphafunc_163.jpg
http://forum.openscenegraph.org//files/ati_noemptyglslprogram_192.jpg
http://forum.openscenegraph.org//files/ati_emptyglslprogram_debughud_103.jpg
http://forum.openscenegraph.org//files/ati_emptyglslprogram_167.jpg


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http

Re: [osg-users] StandardShadowMap on ATI

2010-07-28 Thread Bradley Baker Searles
Hi Wojtek,

  Thank you so much for the response.

  Just for reference, the modifications I've made in my glsl shaders to get it 
running on ATI were mainly the following:

  
  - only index texture coordinates with constants, variables (even const) don't 
seem to work.
  - ensure all variables are initialized (sloppy on my part)
  - hardcode to light 0, the accumulation loop did not work.
  - don't use gl_FrontMaterial / gl_BackMaterial, as the values didn't work as 
they did with nVidia, and produced unexpected values.
  - don't use gl_FrontLightModelProduct, same reason as previous.


  I'm not using alpha in a nonstandard way (at least not intentionally), and I 
don't use discard for anything.  That's good information though, and I will 
fiddle around with my shaders to see if they have any impact (although with the 
NULL program, they shouldn't be used, eh?).

  So having said that, the use of a NULL program indeed does seem like it 
should be valid, as specified in the OpenGL 21.20061201 spec (p. 75), and 
indeed OSG does call glUseProgram(0),  which should revert to fixed function.  
So this is a driver bug, right?

  Still, I agree it might be useful to let the user provide a Program to use, 
or whether to attach the NULL program.

  I ran osgshadow on the ATI 4670 with the 10.7 drivers, and I'll post the 
results below.  I'm also attaching a screenshot of the vehicle in osgviewerWX, 
which seems to be having some texture coordinate issues (again, fine on 
nVidia).  Hmm, even the osg cow seems wrong.

  I don't know precisely what the Texture Matrix fix is that you're speaking 
about, but I can poke around the forums and see if I find the issue.

  And by the way, thanks for the lispsm submission, it's really well done!

Thanks
Baker Searles

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30355#30355




Attachments: 
http://forum.openscenegraph.org//files/osgcow_504.jpg
http://forum.openscenegraph.org//files/osgviewerwx_coupe_325.jpg
http://forum.openscenegraph.org//files/osgshadow_4_stsm_369.jpg
http://forum.openscenegraph.org//files/osgshadow_4_lispsm_133.jpg


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] StandardShadowMap on ATI

2010-07-27 Thread Bradley Baker Searles
Hi,

  I have been working for a while on compatibility issues with nVidia and ATI 
in our OpenSceneGraph application.  Aside from a fair number of GLSL shader 
source issues, one of the last remaining problems was that textured objects 
were not casting shadows (please see first attached screenshot).

  After a little detective work, it seems that the empty osg Program attached 
to the StateSet belonging to the _camera in StandardShadowMap::ViewData::init() 
is causing the problem:


 
 // optimization attributes 
 osg::Program* program = new osg::Program;
 stateset-setAttribute( program, osg::StateAttribute::OVERRIDE | 
 osg::StateAttribute::ON );
 stateset-setMode
 ( GL_LIGHTING, osg::StateAttribute::OVERRIDE | 
 osg::StateAttribute::OFF );
 stateset-setMode
 ( GL_BLEND, osg::StateAttribute::OVERRIDE | 
 osg::StateAttribute::OFF );
 
 #if 0 // fixed pipeline seems faster (at least on my 7800)
 program-addShader( new osg::Shader( osg::Shader::FRAGMENT,
 uniform sampler2D texture;   
 \n
 void main(void)  
 \n
 {
 \n
  gl_FragColor = texture2D( texture, gl_TexCoord[0].xy ); 
 \n
 }
 \n
 ) ); // program-addShader Fragment
 
 program-addShader( new osg::Shader( osg::Shader::VERTEX,
 void main(void)  
 \n
 {
 \n
gl_Position = ftransform();   
 \n
gl_TexCoord[0] = gl_MultiTexCoord0;   
 \n
 }
 \n
 ) ); // program-addShader Vertex
 #endif
 


  The setting of the fragment and vertex shaders to the stateset are #if 0'd 
out, but the osg Program setting is not.

  Anyway, if I skip adding the empty program, things seem fine.  Oddly, if I 
keep the empty program and skip the AlphaFunc above it that allows texture 
alpha to affect the depth buffer render, it casts shadows properly (well, 
without the alpha penetration of course).

  Everything works fine with nVidia drivers, even with the empty program.

  My scene has a mixture of shader programs depending on how the objects are 
setup, but they all include the shadow shader source (except the flat shaded 
objects like the force arrows shown below).

  So it seems to be an easy fix, but I was curious if anyone else had run into 
this problem?  I did many searches on the forum and came up empty.

  And if anyone has deeper illumination into how the empty program could affect 
the statesets (seems like a bug to me since nVidia works fine), or if there is 
a more appropriate fix I'm not thinking of, I'd appreciate the feedback.

Thanks-
Baker Searles


Hardware Versions:
nVidia GTS 250
ATI Radeon HD4670

Software Versions:
OSG @ 2.8.3
ATI Display Drivers @ 10.7
nVidia Display Drivers @ 258.96

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30329#30329




Attachments: 
http://forum.openscenegraph.org//files/ati_emptyglslprogram_noalphafunc_163.jpg
http://forum.openscenegraph.org//files/ati_noemptyglslprogram_192.jpg
http://forum.openscenegraph.org//files/ati_emptyglslprogram_debughud_103.jpg
http://forum.openscenegraph.org//files/ati_emptyglslprogram_167.jpg


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org