On Mon, May 19, 2008 at 6:03 PM, Alejandro Segovia <[EMAIL PROTECTED]> wrote:
> Hello List, > > I'm having a hard time using PSSM (or anything besides ShadowTexture for > that matter) to add shadows to my scene. > > I've got some initialization code inspired in the osgshadow example, which > seems to work fine when I pass the --NVidea parameter, but when I try the > very same technique in my code, it just crashes inside the PSSM's cull() > method. > > This is the backtrace I get from the core dump: > > #0 0xb6f961c9 in osgShadow::ParallelSplitShadowMap::cull () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgShadow.so.25 > #1 0xb6f87656 in osgShadow::ShadowTechnique::traverse () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgShadow.so.25 > #2 0xb6f8e7c0 in osgShadow::ShadowedScene::traverse () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgShadow.so.25 > #3 0xb6d38196 in osgUtil::CullVisitor::apply () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgUtil.so.25 > #4 0xb6f8eb11 in osgShadow::ShadowedScene::accept () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgShadow.so.25 > #5 0xb726fa84 in osg::Group::traverse () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosg.so.25 > #6 0xb6d38196 in osgUtil::CullVisitor::apply () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgUtil.so.25 > #7 0xb727095f in osg::Group::accept () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosg.so.25 > #8 0xb6dc89f7 in osgUtil::SceneView::cullStage () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgUtil.so.25 > #9 0xb6dc7cd6 in osgUtil::SceneView::cull () > from /usr/local/OpenSceneGraph/2.2.0/lib/libosgUtil.so.25 > #10 0xb6a596ef in Canvas::customEvent (this=0x80c4780, > event=0x80deb60) at Canvas.cpp:200 > > Canvas is just a custom class derived from QGLWidget. > > This is the initialization code I'm using, please note the ShadowedScene > node is not the root of the scene graph. > > osg::ref_ptr<osgShadow::ParallelSplitShadowMap> shadowTech = > new osgShadow::ParallelSplitShadowMap(NULL, 3); > shadowTech->setTextureResolution(1024); > shadowTech->setMinNearDistanceForSplits(0); > shadowTech->setMaxFarDistance(0); > shadowTech->setMoveVCamBehindRCamFactor(0); > double polyoffsetfactor = 10.0f; //-0.02; > double polyoffsetunit = 20.0f; //1.0; > shadowTech->setPolygonOffset(osg::Vec2(polyoffsetfactor,polyoffsetunit)); > > _shadowNode = new osgShadow::ShadowedScene(); > _shadowNode->setShadowTechnique(shadowTech.get()); > > _shadowNode->setCastsShadowTraversalMask(0x2|0x8); > _shadowNode->setReceivesShadowTraversalMask(0x1|0x8); > > I'm also using SceneView objects to hold the camera information such as the > projection and modelview matrices. There are two lights in the scene and > only one object (a floor). > > Thanks in advance, > Alejandro Segovia.- > > -- > [EMAIL PROTECTED] > http://varrojo.linuxuruguay.org Setting the OSG_NOTIFY_LEVEL variable to DEBUG in order to determine what could possibly be wrong, I noticed the shader program is never compiled for PSSM! Is there some way to force program compilation in OSG? I attach the dump for osgshadow and then for my application. Notice mine never gets its shader compiled. Dump for osgshadow: ... View::init() ParallelSplitShadowMap : Texture ID=0 Resolution=1024 CullSettings::readEnvironmentalVariables() Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent ParallelSplitShadowMap : Texture ID=1 Resolution=1024 CullSettings::readEnvironmentalVariables() Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent ParallelSplitShadowMap : Texture ID=2 Resolution=1024 CullSettings::readEnvironmentalVariables() ParallelSplitShadowMap: GLSL shader code: ------------------------------------------------------------------- uniform sampler2D baseTexture; uniform sampler2D randomTexture; uniform float enableBaseTexture; uniform sampler2DShadow shadowTexture0; uniform float zShadow0; uniform sampler2DShadow shadowTexture1; uniform float zShadow1; uniform sampler2DShadow shadowTexture2; uniform float zShadow2; void main(void) { vec4 coord = gl_FragCoord; float shadow0 = shadow2DProj( shadowTexture0,gl_TexCoord[1]).r; vec4 random0 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[1].st); float shadow10 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.r*vec4(-1,-1,0,0)).r; float shadow20 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.g*vec4(1,-1,0,0)).r; float shadow30 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.b*vec4(1,1,0,0)).r; float shadow40 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.a*vec4(-1,1,0,0)).r; shadow0 = shadow0 + shadow10 + shadow20 + shadow30 + shadow40; shadow0 = shadow0*0.2; float shadow1 = shadow2DProj( shadowTexture1,gl_TexCoord[2]).r; vec4 random1 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[2].st); float shadow11 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.r*vec4(-1,-1,0,0)).r; float shadow21 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.g*vec4(1,-1,0,0)).r; float shadow31 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.b*vec4(1,1,0,0)).r; float shadow41 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.a*vec4(-1,1,0,0)).r; shadow1 = shadow1 + shadow11 + shadow21 + shadow31 + shadow41; shadow1 = shadow1*0.2; float shadow2 = shadow2DProj( shadowTexture2,gl_TexCoord[3]).r; vec4 random2 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[3].st); float shadow12 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.r*vec4(-1,-1,0,0)).r; float shadow22 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.g*vec4(1,-1,0,0)).r; float shadow32 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.b*vec4(1,1,0,0)).r; float shadow42 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.a*vec4(-1,1,0,0)).r; shadow2 = shadow2 + shadow12 + shadow22 + shadow32 + shadow42; shadow2 = shadow2*0.2; float term0 = (1.0-shadow0); float term1 = (1.0-shadow1); float term2 = (1.0-shadow2); float v = clamp(term0+term1+term2,0.0,1.0); vec4 color = gl_Color; vec4 texcolor = texture2D(baseTexture,gl_TexCoord[0].st); float enableBaseTextureFilter = enableBaseTexture*(1.0 - step(texcolor.x+texcolor.y+texcolor.z+texcolor.a,0.0)); vec4 colorTex = color*texcolor; gl_FragColor = (color*(1.0-enableBaseTextureFilter) + colorTex*enableBaseTextureFilter)*(1.0-0.30*v); } Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent cull_draw() 0x8074200 OpenGL extensions supported by installed OpenGL drivers are: GL_ARB_color_buffer_float GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_half_float_pixel GL_ARB_imaging GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_EXTX_framebuffer_mixed_formats GL_EXT_Cg_shader GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_depth_bounds_test GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_sRGB GL_EXT_texture_shared_exponent GL_EXT_timer_query GL_EXT_vertex_array GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NVX_conditional_render GL_NV_blend_square GL_NV_conditional_render GL_NV_copy_depth_to_color GL_NV_depth_buffer_float GL_NV_depth_clamp GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_program GL_NV_fragment_program2 GL_NV_fragment_program_option GL_NV_framebuffer_multisample_coverage GL_NV_geometry_shader4 GL_NV_gpu_program4 GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_coverage GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_parameter_buffer_object GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_transform_feedback GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_S3_s3tc GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum OpenGL extension 'GL_ARB_vertex_program' is supported. OpenGL extension 'GL_EXT_secondary_color' is supported. OpenGL extension 'GL_EXT_fog_coord' is supported. OpenGL extension 'GL_ARB_multitexture' is supported. OpenGL extension 'GL_NV_occlusion_query' is supported. OpenGL extension 'GL_ARB_occlusion_query' is supported. OpenGL extension 'GL_EXT_timer_query' is supported. Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent OpenGL extension '' is not supported. OpenGL extension 'GL_EXT_framebuffer_object' is supported. OpenGL extension 'GL_ARB_vertex_program' is supported. OpenGL extension 'GL_ARB_fragment_program' is supported. OpenGL extension 'GL_ARB_shader_objects' is supported. OpenGL extension 'GL_ARB_vertex_shader' is supported. OpenGL extension 'GL_ARB_fragment_shader' is supported. OpenGL extension 'GL_ARB_shading_language_100' is supported. glVersion=2.1, isGlslSupported=YES, glslLanguageVersion=1.2 OpenGL extension 'GL_ARB_pixel_buffer_object' is supported. Setting up osg::Camera::FRAME_BUFFER_OBJECT OpenGL extension 'GL_EXT_texture_filter_anisotropic' is supported. OpenGL extension 'GL_EXT_texture_compression_s3tc' is supported. OpenGL extension 'GL_ARB_shadow' is supported. OpenGL extension 'GL_ARB_shadow_ambient' is not supported. OpenGL extension 'GL_APPLE_client_storage' is not supported. OpenGL extension 'GL_EXT_texture_integer' is supported. Setting up osg::Camera::FRAME_BUFFER_OBJECT Setting up osg::Camera::FRAME_BUFFER_OBJECT Setting up osg::Camera::FRAME_BUFFER Compiling FRAGMENT source: uniform sampler2D baseTexture; uniform sampler2D randomTexture; uniform float enableBaseTexture; uniform sampler2DShadow shadowTexture0; uniform float zShadow0; uniform sampler2DShadow shadowTexture1; uniform float zShadow1; uniform sampler2DShadow shadowTexture2; uniform float zShadow2; void main(void) { vec4 coord = gl_FragCoord; float shadow0 = shadow2DProj( shadowTexture0,gl_TexCoord[1]).r; vec4 random0 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[1].st); float shadow10 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.r*vec4(-1,-1,0,0)).r; float shadow20 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.g*vec4(1,-1,0,0)).r; float shadow30 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.b*vec4(1,1,0,0)).r; float shadow40 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.a*vec4(-1,1,0,0)).r; shadow0 = shadow0 + shadow10 + shadow20 + shadow30 + shadow40; shadow0 = shadow0*0.2; float shadow1 = shadow2DProj( shadowTexture1,gl_TexCoord[2]).r; vec4 random1 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[2].st); float shadow11 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.r*vec4(-1,-1,0,0)).r; float shadow21 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.g*vec4(1,-1,0,0)).r; float shadow31 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.b*vec4(1,1,0,0)).r; float shadow41 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.a*vec4(-1,1,0,0)).r; shadow1 = shadow1 + shadow11 + shadow21 + shadow31 + shadow41; shadow1 = shadow1*0.2; float shadow2 = shadow2DProj( shadowTexture2,gl_TexCoord[3]).r; vec4 random2 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[3].st); float shadow12 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.r*vec4(-1,-1,0,0)).r; float shadow22 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.g*vec4(1,-1,0,0)).r; float shadow32 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.b*vec4(1,1,0,0)).r; float shadow42 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.a*vec4(-1,1,0,0)).r; shadow2 = shadow2 + shadow12 + shadow22 + shadow32 + shadow42; shadow2 = shadow2*0.2; float term0 = (1.0-shadow0); float term1 = (1.0-shadow1); float term2 = (1.0-shadow2); float v = clamp(term0+term1+term2,0.0,1.0); vec4 color = gl_Color; vec4 texcolor = texture2D(baseTexture,gl_TexCoord[0].st); float enableBaseTextureFilter = enableBaseTexture*(1.0 - step(texcolor.x+texcolor.y+texcolor.z+texcolor.a,0.0)); vec4 colorTex = color*texcolor; gl_FragColor = (color*(1.0-enableBaseTextureFilter) + colorTex*enableBaseTextureFilter)*(1.0-0.30*v); } Linking osg::Program "" id=1 contextID=0 Uniform "baseTexture" loc=0 size=1 type=sampler2D Uniform "enableBaseTexture" loc=1 size=1 type=float Uniform "randomTexture" loc=2 size=1 type=sampler2D Uniform "shadowTexture0" loc=3 size=1 type=sampler2DShadow Uniform "shadowTexture1" loc=4 size=1 type=sampler2DShadow Uniform "shadowTexture2" loc=5 size=1 type=sampler2DShadow end cull_draw() 0x8074200 == My app == ParallelSplitShadowMap : Texture ID=0 Resolution=1024 CullSettings::readEnvironmentalVariables() Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent ParallelSplitShadowMap : Texture ID=1 Resolution=1024 CullSettings::readEnvironmentalVariables() Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent ParallelSplitShadowMap : Texture ID=2 Resolution=1024 CullSettings::readEnvironmentalVariables() ParallelSplitShadowMap: GLSL shader code: ------------------------------------------------------------------- uniform sampler2D baseTexture; uniform sampler2D randomTexture; uniform float enableBaseTexture; uniform sampler2DShadow shadowTexture0; uniform float zShadow0; uniform sampler2DShadow shadowTexture1; uniform float zShadow1; uniform sampler2DShadow shadowTexture2; uniform float zShadow2; void main(void) { vec4 coord = gl_FragCoord; float shadow0 = shadow2DProj( shadowTexture0,gl_TexCoord[1]).r; vec4 random0 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[1].st); float shadow10 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.r*vec4(-1,-1,0,0)).r; float shadow20 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.g*vec4(1,-1,0,0)).r; float shadow30 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.b*vec4(1,1,0,0)).r; float shadow40 = shadow2DProj( shadowTexture0,gl_TexCoord[1]+random0.a*vec4(-1,1,0,0)).r; shadow0 = shadow0 + shadow10 + shadow20 + shadow30 + shadow40; shadow0 = shadow0*0.2; float shadow1 = shadow2DProj( shadowTexture1,gl_TexCoord[2]).r; vec4 random1 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[2].st); float shadow11 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.r*vec4(-1,-1,0,0)).r; float shadow21 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.g*vec4(1,-1,0,0)).r; float shadow31 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.b*vec4(1,1,0,0)).r; float shadow41 = shadow2DProj( shadowTexture1,gl_TexCoord[2]+random1.a*vec4(-1,1,0,0)).r; shadow1 = shadow1 + shadow11 + shadow21 + shadow31 + shadow41; shadow1 = shadow1*0.2; float shadow2 = shadow2DProj( shadowTexture2,gl_TexCoord[3]).r; vec4 random2 = 0.0012207*coord.z*texture2D(randomTexture,gl_TexCoord[3].st); float shadow12 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.r*vec4(-1,-1,0,0)).r; float shadow22 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.g*vec4(1,-1,0,0)).r; float shadow32 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.b*vec4(1,1,0,0)).r; float shadow42 = shadow2DProj( shadowTexture2,gl_TexCoord[3]+random2.a*vec4(-1,1,0,0)).r; shadow2 = shadow2 + shadow12 + shadow22 + shadow32 + shadow42; shadow2 = shadow2*0.2; float term0 = (1.0-shadow0); float term1 = (1.0-shadow1); float term2 = (1.0-shadow2); float v = clamp(term0+term1+term2,0.0,1.0); vec4 color = gl_Color; vec4 texcolor = texture2D(baseTexture,gl_TexCoord[0].st); float enableBaseTextureFilter = enableBaseTexture*(1.0 - step(texcolor.x+texcolor.y+texcolor.z+texcolor.a,0.0)); vec4 colorTex = color*texcolor; gl_FragColor = (color*(1.0-enableBaseTextureFilter) + colorTex*enableBaseTextureFilter)*(1.0-0.30*v); } Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Uniform Adding parent Then it segfaults. -- [EMAIL PROTECTED] http://varrojo.linuxuruguay.org
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org