├── Catch
├── RockStar.png
├── Welcome.jpg
├── YouLost.jpg
├── YouWon.jpg
├── a.png
├── b.png
├── ball.png
├── boy.png
├── broach.png
├── c.png
├── farm.JPG
├── girl.png
├── m.png
├── n.png
├── s.png
├── sky1.JPG
├── sky2.JPG
├── sky3.JPG
├── t.png
└── u.png
├── Configuration
├── 3DSphericalDisplay.view
├── 3DSphericalDisplayTopProjector.view
├── AllScreens.view
├── PanoramicSphericalDisplay.view
├── PanoramicSphericalDisplayTopProjector.view
├── SingleScreen.view
└── SmallWindow.view
├── Cubemap_axis
├── negx.png
├── negy.png
├── negz.png
├── posx.png
├── posy.png
└── posz.png
├── Cubemap_snow
├── negx.jpg
├── negy.jpg
├── negz.jpg
├── posx.jpg
├── posy.jpg
└── posz.jpg
├── ExampleThumbnails
├── osganimation.jpg
├── osgcubemap.jpg
├── osgdepthshadow.jpg
├── osgdistortion.jpg
├── osgfxbrowser.jpg
├── osggeometry.jpg
├── osghud.jpg
├── osgkeyboard.jpg
├── osglight.jpg
├── osgmotionblur.jpg
├── osgmultitexture.jpg
├── osgparticle.jpg
├── osgprerendercubemap.jpg
├── osgreflect.jpg
├── osgscribe.jpg
└── osgvertexprogram.jpg
├── Images
├── Brick-Norman-Brown.TGA
├── Brick-Std-Orange.TGA
├── Saturn.TGA
├── blueFlowers.png
├── brow.l.tga
├── clockface.JPG
├── continous_smoke.rgb
├── dark_grey.tga
├── dog_left_eye.jpg
├── dog_right_eye.jpg
├── eye.l.tga
├── fireparticle8x8.png
├── forestRoof.png
├── forestWall.png
├── land_ocean_ice_lights_2048.jpg
├── land_shallow_topo_2048.jpg
├── lz.rgb
├── moon256128.TGA
├── mouth.tga
├── nose.tga
├── osg128.png
├── osg256.png
├── osg64.png
├── osgshaders1.png
├── osgshaders2.png
├── particle.rgb
├── primitives.gif
├── purpleFlowers.png
├── red.tga
├── reflect.rgb
├── road.png
├── rockwall.png
├── rockwall_NH.png
├── skin.tga
├── skymap.jpg
├── smoke.rgb
├── tank.rgb
├── tree0.rgba
├── water.rgb
├── white.rgb
├── whitemetal_diffuse.jpg
└── whitemetal_normal.jpg
├── Present3D
├── OpenSceneGraphlogo.png
└── present3dwhite.png
├── README
├── SmokeBox.osgt
├── SolarSystem
├── earth_clouds256128.jpg
├── jupiter256128.jpg
├── mars256128.jpg
├── mercury256128.jpg
├── moon256128.jpg
├── neptune256128.jpg
├── pluto256128.jpg
├── saturn256128.jpg
├── sun256128.jpg
└── venus256128.jpg
├── avatar.osg
├── axes.osgt
├── bignathan.osg
├── cessna.osg
├── cessna.osgt
├── cessnafire.osg
├── cessnafire.osgt
├── clock.osgt
├── cow.osg
├── cow.osgt
├── cube_mapped_torus.osgt
├── dot3_bumpmapping.osgt
├── dumptruck.osg
├── dumptruck.osgt
├── example.osg
├── fonts
├── COPYRIGHT.TXT
├── Vera.ttf
├── VeraMono.ttf
├── arial.ttf
├── dirtydoz.ttf
├── fudd.ttf
└── times.ttf
├── fountain.osgt
├── glider.osg
├── glider.osgt
├── glsl_confetti.osgt
├── glsl_julia.osgt
├── glsl_mandelbrot.osgt
├── glsl_simple.osgt
├── htdocs
├── config.rb
├── index.html
├── javascripts
│ ├── jquery-1.8.2.min.js
│ ├── main.js
│ └── modernizr-2.5.3.js
├── sass
│ ├── partials
│ │ ├── _base.scss
│ │ ├── _design.scss
│ │ └── _layout.scss
│ └── style.scss
└── stylesheets
│ └── style.css
├── introduction.p3d
├── lz.osg
├── lz.osgt
├── morphing.osg
├── morphtarget_shape0.osg
├── morphtarget_shape1.osg
├── nathan.osg
├── osg.conf
├── osg64.logo
├── osgWidget
├── README
├── back.png
├── border-bottom.tga
├── border-left.tga
├── border-right.tga
├── border-top.tga
├── natascha.png
├── next.png
├── open.png
├── osgwidgetshader-frag.glsl
├── osgwidgetshader-vert.glsl
├── osgwidgetwindow.lua
├── osgwidgetwindow.py
├── panel-center.tga
├── panel-left.tga
├── panel-right.tga
├── pause.png
├── play.png
├── scrolled1.jpg
├── scrolled2.jpg
├── scrolled3.jpg
├── scrolled4.jpg
├── stop.png
├── theme-1.png
├── theme-2.png
└── theme.png
├── osgcool.osgt
├── robot.osg
├── shaders
├── blocky.frag
├── blocky.vert
├── brick.frag
├── brick.vert
├── depthpeel_colormap.frag
├── depthpeel_colormap.vert
├── depthpeel_edgemap.frag
├── depthpeel_edgemap.vert
├── depthpeel_final.frag
├── depthpeel_final.vert
├── depthpeel_normaldepthmap.frag
├── depthpeel_normaldepthmap.vert
├── eroded.frag
├── eroded.vert
├── gameoflife.frag
├── lighting.vert
├── line_rain.vert
├── lookup.frag
├── lookup.vert
├── marble.frag
├── marble.vert
├── osgText_Text.frag
├── osgText_Text.vert
├── osgshadercomposition.frag
├── osgshadercomposition.vert
├── osgssboComputeShader.cs
├── osgssboFragmentShader.fs
├── osgssboGeometryShader.gs
├── osgssboVertexShader.vs
├── osgtexture2DArray.frag
├── osgtexture2DArray.vert
├── overlay_perspective_main.frag
├── overlay_perspective_rtt.vert
├── pass1Shadow.frag
├── pass2.frag
├── pass2.vert
├── pass3.frag
├── pass3.vert
├── point_rain.frag
├── point_rain.vert
├── quad_rain.vert
├── rain.frag
├── rain.vert
├── screen.frag
├── screen.vert
├── shader.vert
├── shadergen.frag
├── shadergen.vert
├── shaderpipeline.frag
├── shaderpipeline.vert
├── skinning.vert
├── stereomatch_aggregate.frag
├── stereomatch_clear.frag
├── stereomatch_select.frag
├── stereomatch_stereopass.frag
├── stereomatch_subtract.frag
├── terrain_displacement_mapping.frag
├── terrain_displacement_mapping.geom
├── terrain_displacement_mapping.vert
├── volume.frag
├── volume.vert
├── volume_accumulateSamples_iso.frag
├── volume_accumulateSamples_iso_tf.frag
├── volume_accumulateSamples_lit.frag
├── volume_accumulateSamples_lit_tf.frag
├── volume_accumulateSamples_mip.frag
├── volume_accumulateSamples_mip_tf.frag
├── volume_accumulateSamples_standard.frag
├── volume_accumulateSamples_standard_tf.frag
├── volume_color_depth.frag
├── volume_color_depth.vert
├── volume_compute_ray_color.frag
├── volume_iso.frag
├── volume_lit.frag
├── volume_lit_tf.frag
├── volume_mip.frag
├── volume_multipass.frag
├── volume_multipass.vert
├── volume_multipass_cube.frag
├── volume_multipass_cube_and_hull.frag
├── volume_multipass_hull.frag
├── volume_tf.frag
├── volume_tf_iso.frag
└── volume_tf_mip.frag
├── simpleroom.osgt
├── skydome.osgt
├── spaceship.osgt
├── torus.osgt
└── ui
├── TabWidget.lua
├── TransferFunctionWidget.lua
├── VolumeEditor.lua
├── VolumeEditorWidget.lua
├── VolumeSettings.lua
└── WidgetUtils.lua
/Catch/RockStar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/RockStar.png
--------------------------------------------------------------------------------
/Catch/Welcome.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/Welcome.jpg
--------------------------------------------------------------------------------
/Catch/YouLost.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/YouLost.jpg
--------------------------------------------------------------------------------
/Catch/YouWon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/YouWon.jpg
--------------------------------------------------------------------------------
/Catch/a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/a.png
--------------------------------------------------------------------------------
/Catch/b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/b.png
--------------------------------------------------------------------------------
/Catch/ball.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/ball.png
--------------------------------------------------------------------------------
/Catch/boy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/boy.png
--------------------------------------------------------------------------------
/Catch/broach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/broach.png
--------------------------------------------------------------------------------
/Catch/c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/c.png
--------------------------------------------------------------------------------
/Catch/farm.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/farm.JPG
--------------------------------------------------------------------------------
/Catch/girl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/girl.png
--------------------------------------------------------------------------------
/Catch/m.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/m.png
--------------------------------------------------------------------------------
/Catch/n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/n.png
--------------------------------------------------------------------------------
/Catch/s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/s.png
--------------------------------------------------------------------------------
/Catch/sky1.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/sky1.JPG
--------------------------------------------------------------------------------
/Catch/sky2.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/sky2.JPG
--------------------------------------------------------------------------------
/Catch/sky3.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/sky3.JPG
--------------------------------------------------------------------------------
/Catch/t.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/t.png
--------------------------------------------------------------------------------
/Catch/u.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Catch/u.png
--------------------------------------------------------------------------------
/Configuration/3DSphericalDisplay.view:
--------------------------------------------------------------------------------
1 | osgViewer::View
2 | {
3 | setUpViewFor3DSphericalDisplay
4 | {
5 | radius 1.0
6 | collar 0.43
7 | intensityMap
8 | {
9 | 0 100
10 | 90 100
11 | 135 50
12 | 180 0
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Configuration/3DSphericalDisplayTopProjector.view:
--------------------------------------------------------------------------------
1 | osgViewer::View
2 | {
3 | setUpViewFor3DSphericalDisplay
4 | {
5 | radius 1.0
6 | collar 0.43
7 | intensityMap
8 | {
9 | 0 100
10 | 90 100
11 | 135 50
12 | 180 0
13 | }
14 | projectorMatrix
15 | {
16 | 1 0 0 0
17 | 0 -1 0 0
18 | 0 0 -1 0
19 | 0 0 0 1
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Configuration/AllScreens.view:
--------------------------------------------------------------------------------
1 | osgViewer::View
2 | {
3 | setUpViewOnAllScreens
4 | }
5 |
--------------------------------------------------------------------------------
/Configuration/PanoramicSphericalDisplay.view:
--------------------------------------------------------------------------------
1 | osgViewer::View
2 | {
3 | setUpViewForPanoramicSphericalDisplay
4 | {
5 | radius 1.0
6 | collar 0.43
7 | intensityMap
8 | {
9 | 0 100
10 | 90 100
11 | 135 50
12 | 180 0
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Configuration/PanoramicSphericalDisplayTopProjector.view:
--------------------------------------------------------------------------------
1 | osgViewer::View
2 | {
3 | setUpViewForPanoramicSphericalDisplay
4 | {
5 | radius 1.0
6 | collar 0.43
7 | intensityMap
8 | {
9 | 0 100
10 | 90 100
11 | 135 50
12 | 180 0
13 | }
14 | projectorMatrix
15 | {
16 | 1 0 0 0
17 | 0 -1 0 0
18 | 0 0 -1 0
19 | 0 0 0 1
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Configuration/SingleScreen.view:
--------------------------------------------------------------------------------
1 | osgViewer::View
2 | {
3 | setUpViewOnSingleScreen 0
4 | }
5 |
--------------------------------------------------------------------------------
/Configuration/SmallWindow.view:
--------------------------------------------------------------------------------
1 | osgViewer::Viewer
2 | {
3 | setUpViewInWindow 100 200 600 400 0
4 | }
5 |
--------------------------------------------------------------------------------
/Cubemap_axis/negx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_axis/negx.png
--------------------------------------------------------------------------------
/Cubemap_axis/negy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_axis/negy.png
--------------------------------------------------------------------------------
/Cubemap_axis/negz.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_axis/negz.png
--------------------------------------------------------------------------------
/Cubemap_axis/posx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_axis/posx.png
--------------------------------------------------------------------------------
/Cubemap_axis/posy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_axis/posy.png
--------------------------------------------------------------------------------
/Cubemap_axis/posz.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_axis/posz.png
--------------------------------------------------------------------------------
/Cubemap_snow/negx.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_snow/negx.jpg
--------------------------------------------------------------------------------
/Cubemap_snow/negy.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_snow/negy.jpg
--------------------------------------------------------------------------------
/Cubemap_snow/negz.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_snow/negz.jpg
--------------------------------------------------------------------------------
/Cubemap_snow/posx.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_snow/posx.jpg
--------------------------------------------------------------------------------
/Cubemap_snow/posy.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_snow/posy.jpg
--------------------------------------------------------------------------------
/Cubemap_snow/posz.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Cubemap_snow/posz.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osganimation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osganimation.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgcubemap.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgcubemap.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgdepthshadow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgdepthshadow.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgdistortion.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgdistortion.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgfxbrowser.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgfxbrowser.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osggeometry.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osggeometry.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osghud.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osghud.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgkeyboard.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgkeyboard.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osglight.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osglight.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgmotionblur.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgmotionblur.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgmultitexture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgmultitexture.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgparticle.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgparticle.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgprerendercubemap.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgprerendercubemap.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgreflect.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgreflect.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgscribe.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgscribe.jpg
--------------------------------------------------------------------------------
/ExampleThumbnails/osgvertexprogram.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/ExampleThumbnails/osgvertexprogram.jpg
--------------------------------------------------------------------------------
/Images/Brick-Norman-Brown.TGA:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/Brick-Norman-Brown.TGA
--------------------------------------------------------------------------------
/Images/Brick-Std-Orange.TGA:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/Brick-Std-Orange.TGA
--------------------------------------------------------------------------------
/Images/Saturn.TGA:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/Saturn.TGA
--------------------------------------------------------------------------------
/Images/blueFlowers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/blueFlowers.png
--------------------------------------------------------------------------------
/Images/brow.l.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/brow.l.tga
--------------------------------------------------------------------------------
/Images/clockface.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/clockface.JPG
--------------------------------------------------------------------------------
/Images/continous_smoke.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/continous_smoke.rgb
--------------------------------------------------------------------------------
/Images/dark_grey.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/dark_grey.tga
--------------------------------------------------------------------------------
/Images/dog_left_eye.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/dog_left_eye.jpg
--------------------------------------------------------------------------------
/Images/dog_right_eye.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/dog_right_eye.jpg
--------------------------------------------------------------------------------
/Images/eye.l.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/eye.l.tga
--------------------------------------------------------------------------------
/Images/fireparticle8x8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/fireparticle8x8.png
--------------------------------------------------------------------------------
/Images/forestRoof.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/forestRoof.png
--------------------------------------------------------------------------------
/Images/forestWall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/forestWall.png
--------------------------------------------------------------------------------
/Images/land_ocean_ice_lights_2048.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/land_ocean_ice_lights_2048.jpg
--------------------------------------------------------------------------------
/Images/land_shallow_topo_2048.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/land_shallow_topo_2048.jpg
--------------------------------------------------------------------------------
/Images/lz.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/lz.rgb
--------------------------------------------------------------------------------
/Images/moon256128.TGA:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/moon256128.TGA
--------------------------------------------------------------------------------
/Images/mouth.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/mouth.tga
--------------------------------------------------------------------------------
/Images/nose.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/nose.tga
--------------------------------------------------------------------------------
/Images/osg128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/osg128.png
--------------------------------------------------------------------------------
/Images/osg256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/osg256.png
--------------------------------------------------------------------------------
/Images/osg64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/osg64.png
--------------------------------------------------------------------------------
/Images/osgshaders1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/osgshaders1.png
--------------------------------------------------------------------------------
/Images/osgshaders2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/osgshaders2.png
--------------------------------------------------------------------------------
/Images/particle.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/particle.rgb
--------------------------------------------------------------------------------
/Images/primitives.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/primitives.gif
--------------------------------------------------------------------------------
/Images/purpleFlowers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/purpleFlowers.png
--------------------------------------------------------------------------------
/Images/red.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/red.tga
--------------------------------------------------------------------------------
/Images/reflect.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/reflect.rgb
--------------------------------------------------------------------------------
/Images/road.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/road.png
--------------------------------------------------------------------------------
/Images/rockwall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/rockwall.png
--------------------------------------------------------------------------------
/Images/rockwall_NH.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/rockwall_NH.png
--------------------------------------------------------------------------------
/Images/skin.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/skin.tga
--------------------------------------------------------------------------------
/Images/skymap.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/skymap.jpg
--------------------------------------------------------------------------------
/Images/smoke.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/smoke.rgb
--------------------------------------------------------------------------------
/Images/tank.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/tank.rgb
--------------------------------------------------------------------------------
/Images/tree0.rgba:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/tree0.rgba
--------------------------------------------------------------------------------
/Images/water.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/water.rgb
--------------------------------------------------------------------------------
/Images/white.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/white.rgb
--------------------------------------------------------------------------------
/Images/whitemetal_diffuse.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/whitemetal_diffuse.jpg
--------------------------------------------------------------------------------
/Images/whitemetal_normal.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Images/whitemetal_normal.jpg
--------------------------------------------------------------------------------
/Present3D/OpenSceneGraphlogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Present3D/OpenSceneGraphlogo.png
--------------------------------------------------------------------------------
/Present3D/present3dwhite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/Present3D/present3dwhite.png
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | If not otherwise specified all files in the OpenSceneGraph-Data are provided free
2 | for non commercial usage. Commercial users may use the data for testing and development purposes,
3 | but may not distribute these models with commercial products.
4 |
5 | Thanks to:
6 |
7 | The Configure/*.view files are all published in the public domain, you
8 | may do with them what you wish, you can copy them into commercial or
9 | non commercial works, and open source works as required.
10 |
11 | Image/land_shallow_topo_2048.jpg is slightly lightened version of the
12 | NASA blue marble data which is published in the public domain,
13 | http://earthobservatory.nasa.gov/Newsroom/BlueMarble/
14 |
15 | aferescher.geo and associated images are provided by carbongraphics.com
16 |
17 | osgcool.osg, fountain.osg and cessnafire.osg were provided by Marco Jez.
18 |
19 | cube_mapped_torus.osg and Cubemap_axis/ images were provided by Brede Johansen.
20 |
21 | Cubemap_snow/ images provided by Humus - http://esprit.campus.luth.se/~humus/
22 |
23 | shaders/ were provided by Mike Weiblen.
24 |
25 | The rest of the files are compiled by Don Burns and Robert Osfield.
26 |
--------------------------------------------------------------------------------
/SolarSystem/earth_clouds256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/earth_clouds256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/jupiter256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/jupiter256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/mars256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/mars256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/mercury256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/mercury256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/moon256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/moon256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/neptune256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/neptune256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/pluto256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/pluto256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/saturn256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/saturn256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/sun256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/sun256128.jpg
--------------------------------------------------------------------------------
/SolarSystem/venus256128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/SolarSystem/venus256128.jpg
--------------------------------------------------------------------------------
/fonts/Vera.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/fonts/Vera.ttf
--------------------------------------------------------------------------------
/fonts/VeraMono.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/fonts/VeraMono.ttf
--------------------------------------------------------------------------------
/fonts/arial.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/fonts/arial.ttf
--------------------------------------------------------------------------------
/fonts/dirtydoz.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/fonts/dirtydoz.ttf
--------------------------------------------------------------------------------
/fonts/fudd.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/fonts/fudd.ttf
--------------------------------------------------------------------------------
/fonts/times.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/fonts/times.ttf
--------------------------------------------------------------------------------
/htdocs/config.rb:
--------------------------------------------------------------------------------
1 | require 'sassy-buttons'
2 | # Require any additional compass plugins here.
3 |
4 |
5 | # Set this to the root of your project when deployed:
6 | http_path = "/"
7 | css_dir = "stylesheets"
8 | sass_dir = "sass"
9 | images_dir = "images"
10 | javascripts_dir = "javascripts"
11 |
12 | # You can select your preferred output style here (can be overridden via the command line):
13 | # output_style = :expanded or :nested or :compact or :compressed
14 |
15 | # To enable relative paths to assets via compass helper functions. Uncomment:
16 | # relative_assets = true
17 |
18 | # To disable debugging comments that display the original location of your selectors. Uncomment:
19 | # line_comments = false
20 |
21 |
22 | # If you prefer the indented syntax, you might want to regenerate this
23 | # project again passing --syntax sass, or you can uncomment this:
24 | # preferred_syntax = :sass
25 | # and then run:
26 | # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
27 |
--------------------------------------------------------------------------------
/htdocs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | test
4 |
5 |
6 |
7 |
8 |
9 |
10 | Present3D specific:
11 |
46 | Raw events:
47 |
53 |
--------------------------------------------------------------------------------
/htdocs/javascripts/main.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {
2 |
3 |
4 | var send_rest_request = function(href, args, on_complete_handler) {
5 | args['time'] = Date.now() / 1000.0;
6 | $.ajax({
7 | url: href,
8 | context: document.body,
9 | data: args
10 | }).done(function(data) {
11 | data = jQuery.parseJSON(data);
12 | // console.log(href+" done.");
13 | if (data)
14 | // console.log(data);
15 | if(on_complete_handler)
16 | on_complete_handler(data);
17 | });
18 | };
19 |
20 | $('a.ajax').click(function(e) {
21 | e.preventDefault();
22 | send_rest_request($(this).attr('href'), {});
23 | });
24 |
25 | $('a.keycode').click(function(e) {
26 | var keycode = $('#keycode').val();
27 | e.preventDefault();
28 | send_rest_request($(this).attr('href'), {code: keycode});
29 | });
30 |
31 | $('a.set-mouse-input-range').click(function(e) {
32 | e.preventDefault();
33 | send_rest_request($(this).attr('href'), {x_min: 0, y_min: 0, x_max: $('#mouse-input').width(), y_max: $('#mouse-input').height() });
34 | });
35 |
36 | $('#mouse-input').mousemove(function(e) {
37 | e.preventDefault();
38 | send_rest_request('/mouse/motion', {x: e.pageX - $(this).offset().left, y:e.pageY - $(this).offset().top});
39 | return false;
40 | }).mousedown(function(e) {
41 | e.preventDefault();
42 | send_rest_request('/mouse/press', {x: e.pageX - $(this).offset().left, y:e.pageY - $(this).offset().top, button: e.which});
43 | return false;
44 | }).mouseup(function(e) {
45 | e.preventDefault();
46 | send_rest_request('/mouse/release', {x: e.pageX - $(this).offset().left, y:e.pageY - $(this).offset().top, button: e.which});
47 | return false;
48 | }).bind('contextmenu', function(e) {
49 | // do stuff here instead of normal context menu
50 | return false;
51 | });
52 |
53 | var last_touch_x, last_touch_y;
54 |
55 | // touch events:
56 | $('#mouse-input').bind('touchmove', function(e) {
57 | e.preventDefault();
58 | var touch = e.originalEvent.touches[0];
59 | last_touch_y = touch.pageY;
60 | last_touch_x = touch.pageX;
61 | send_rest_request('/mouse/motion', {x: touch.pageX, y:touch.pageY, button: 1});
62 | }).bind('touchstart', function(e) {
63 | e.preventDefault();
64 | var touch = e.originalEvent.touches[0];
65 | last_touch_y = touch.pageY;
66 | last_touch_x = touch.pageX;
67 | send_rest_request('/mouse/press', {x: touch.pageX, y:touch.pageY, button: 1});
68 | }).bind('touchend', function(e) {
69 | e.preventDefault();
70 |
71 | send_rest_request('/mouse/release', {x: last_touch_x, y:last_touch_y, button: 1});
72 | });
73 |
74 | send_rest_request('/mouse/set_input_range', {x_min: 0, y_min: 0, x_max: $('#mouse-input').width(), y_max: $('#mouse-input').height() });
75 | });
--------------------------------------------------------------------------------
/htdocs/sass/partials/_base.scss:
--------------------------------------------------------------------------------
1 | @import "compass/reset";
2 | @import "sassy-buttons";
3 |
4 |
--------------------------------------------------------------------------------
/htdocs/sass/partials/_design.scss:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: Helvetica, Arial, sans-serif;
3 | padding:15px;
4 | }
5 |
6 | a {
7 | @include sassy-button("simple", 5px, 12px, #aaa, #bbb);
8 | text-decoration: none;
9 | }
--------------------------------------------------------------------------------
/htdocs/sass/partials/_layout.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/htdocs/sass/partials/_layout.scss
--------------------------------------------------------------------------------
/htdocs/sass/style.scss:
--------------------------------------------------------------------------------
1 | @import 'partials/base';
2 | @import 'partials/layout';
3 | @import 'partials/design';
4 |
--------------------------------------------------------------------------------
/htdocs/stylesheets/style.css:
--------------------------------------------------------------------------------
1 | /* line 17, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
2 | html, body, div, span, applet, object, iframe,
3 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
4 | a, abbr, acronym, address, big, cite, code,
5 | del, dfn, em, img, ins, kbd, q, s, samp,
6 | small, strike, strong, sub, sup, tt, var,
7 | b, u, i, center,
8 | dl, dt, dd, ol, ul, li,
9 | fieldset, form, label, legend,
10 | table, caption, tbody, tfoot, thead, tr, th, td,
11 | article, aside, canvas, details, embed,
12 | figure, figcaption, footer, header, hgroup,
13 | menu, nav, output, ruby, section, summary,
14 | time, mark, audio, video {
15 | margin: 0;
16 | padding: 0;
17 | border: 0;
18 | font: inherit;
19 | font-size: 100%;
20 | vertical-align: baseline;
21 | }
22 |
23 | /* line 22, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
24 | html {
25 | line-height: 1;
26 | }
27 |
28 | /* line 24, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
29 | ol, ul {
30 | list-style: none;
31 | }
32 |
33 | /* line 26, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
34 | table {
35 | border-collapse: collapse;
36 | border-spacing: 0;
37 | }
38 |
39 | /* line 28, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
40 | caption, th, td {
41 | text-align: left;
42 | font-weight: normal;
43 | vertical-align: middle;
44 | }
45 |
46 | /* line 30, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
47 | q, blockquote {
48 | quotes: none;
49 | }
50 | /* line 103, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
51 | q:before, q:after, blockquote:before, blockquote:after {
52 | content: "";
53 | content: none;
54 | }
55 |
56 | /* line 32, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
57 | a img {
58 | border: none;
59 | }
60 |
61 | /* line 116, ../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.13.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
62 | article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {
63 | display: block;
64 | }
65 |
66 | /* line 1, ../sass/partials/_design.scss */
67 | body {
68 | font-family: Helvetica, Arial, sans-serif;
69 | padding: 15px;
70 | }
71 |
72 | /* line 6, ../sass/partials/_design.scss */
73 | a {
74 | font-size: 12px;
75 | padding: 0.5em 1.5em;
76 | display: inline-block;
77 | cursor: pointer;
78 | -webkit-border-radius: 5px;
79 | -moz-border-radius: 5px;
80 | -ms-border-radius: 5px;
81 | -o-border-radius: 5px;
82 | border-radius: 5px;
83 | *zoom: 1;
84 | filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFAAAAAA', endColorstr='#FF777777');
85 | background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #aaaaaa), color-stop(100%, #bbbbbb));
86 | background: -webkit-linear-gradient(#aaaaaa, #bbbbbb);
87 | background: -moz-linear-gradient(#aaaaaa, #bbbbbb);
88 | background: -o-linear-gradient(#aaaaaa, #bbbbbb);
89 | background: -ms-linear-gradient(#aaaaaa, #bbbbbb);
90 | background: linear-gradient(#aaaaaa, #bbbbbb);
91 | -webkit-box-shadow: #d0d0d0 0 1px 0 inset;
92 | -moz-box-shadow: #d0d0d0 0 1px 0 inset;
93 | box-shadow: #d0d0d0 0 1px 0 inset;
94 | border: 1px solid #aeaeae;
95 | color: white;
96 | text-shadow: #6c6c6c 0 -1px 0;
97 | text-decoration: none;
98 | }
99 | /* line 15, ../../../../../../../../Library/Ruby/Gems/1.8/gems/sassy-buttons-0.1.4/stylesheets/sassy-buttons/_sassy-button-pseudo-states.sass */
100 | a:hover {
101 | text-decoration: none;
102 | }
103 | /* line 36, ../../../../../../../../Library/Ruby/Gems/1.8/gems/sassy-buttons-0.1.4/stylesheets/sassy-buttons/_sassy-button-pseudo-states.sass */
104 | a:hover {
105 | background-color: #aeaeae;
106 | background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #9d9d9d), color-stop(100%, #aeaeae));
107 | background: -webkit-linear-gradient(#9d9d9d, #aeaeae);
108 | background: -moz-linear-gradient(#9d9d9d, #aeaeae);
109 | background: -o-linear-gradient(#9d9d9d, #aeaeae);
110 | background: -ms-linear-gradient(#9d9d9d, #aeaeae);
111 | background: linear-gradient(#9d9d9d, #aeaeae);
112 | }
113 | /* line 39, ../../../../../../../../Library/Ruby/Gems/1.8/gems/sassy-buttons-0.1.4/stylesheets/sassy-buttons/_sassy-button-pseudo-states.sass */
114 | a:active {
115 | -webkit-box-shadow: #a7a7a7 0 1px 2px inset;
116 | -moz-box-shadow: #a7a7a7 0 1px 2px inset;
117 | box-shadow: #a7a7a7 0 1px 2px inset;
118 | }
119 | /* line 6, ../../../../../../../../Library/Ruby/Gems/1.8/gems/sassy-buttons-0.1.4/stylesheets/sassy-buttons/_sassy-button-pseudo-states.sass */
120 | a.disabled, a[disabled] {
121 | opacity: 0.6;
122 | background: #bbbbbb;
123 | cursor: default;
124 | -webkit-box-shadow: none;
125 | -moz-box-shadow: none;
126 | box-shadow: none;
127 | }
128 | /* line 73, ../../../../../../../../Library/Ruby/Gems/1.8/gems/sassy-buttons-0.1.4/stylesheets/_sassy-buttons.sass */
129 | a::-moz-focus-inner {
130 | padding: 0 !important;
131 | margin: -1px !important;
132 | }
133 |
--------------------------------------------------------------------------------
/introduction.p3d:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
12 | OSG_COMPUTE_NEAR_FAR_MODE=COMPUTE_NEAR_FAR_USING_PRIMITIVES
13 | OSG_NEAR_FAR_RATIO=0.00001
14 |
15 |
16 | YELLOW
17 | SKY
18 |
19 |
20 | 0.20 0.45 0.60 1.0
21 |
22 |
23 | Introduction to
24 | Present3D/OpenSceneGraphlogo.png
25 | and
26 | Present3D/present3dwhite.png
27 |
28 |
29 |
30 |
31 | Motivation for Open Source
32 |
33 | lz.osg
34 |
35 |
36 | "Scratch the itch" not some moral crusade
37 |
38 |
39 |
40 | 1997 Don Burns, SGI in California, start works on Hang glider simulator just for fun
41 |
42 | 1998 Robert Osfield, based in Scotland, introduced for aeronatical expertise.
43 |
44 | Robert gets addicated to real-time graphics side to the project
45 |
46 | 1999 decide to open source the graphics side...
47 |
48 | OpenSceneGraph is born
49 |
50 |
51 |
52 |
53 |
54 | Open Souce licensing
55 |
56 | lz.osg
57 |
58 | Users are explicitly given rights
59 |
60 | Copy:
61 |
62 | As many copies as you wish, and not cost
63 |
64 | Modify:
65 |
66 | Full access to source,
67 | and right to modify it to you own needs
68 |
69 |
70 | Distribute:
71 |
72 | Right to distribute original works and
73 | modifications
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | The impact of the licensing model
83 |
84 | lz.osg
85 |
86 |
87 |
88 | Copy:
89 |
90 | Lowers the barrier to entry
91 | Removes the painful procurment process
92 | Lower costs, means you can afford more
93 |
94 |
95 | Modify:
96 |
97 | Fix things when they don't work
98 | Port to new platforms
99 | Add new features
100 |
101 |
102 | Distribute:
103 |
104 | Opens the door to different distribution models
105 | No longer need to pay royalty payments
106 |
107 |
108 |
109 |
110 |
111 | The impact of the licensing model
112 |
113 | lz.osg
114 |
115 |
116 | Security:
117 |
118 | Breaks vendor lock-in
119 | You have full source code
120 | You can maitain it yourself
121 | You can fully QA source code
122 |
123 | Productivity:
124 |
125 | You can control release schedule
126 | You can modify software as required
127 | You can facilitate full platform support
128 |
129 |
130 |
131 |
132 |
133 |
134 | Networking Effects of Open Source
135 |
136 | lz.osg
137 |
138 |
139 | Community:
140 |
141 | Like-mind individuals provide support
142 | Sharing of expertise
143 | Non adversarily - share and share alike
144 | Diverse community - diverse contributions
145 |
146 | 24/7 availability:
147 |
148 | Latest developments get rapidly tested
149 | Bug fix turnaround very rapid
150 | Positive feedback loop on quality
151 | Much faster release schedule
152 |
153 |
154 |
155 |
156 |
157 | Personal Development Philosophy
158 |
159 | lz.osg
160 |
161 | Catch phrase coding:
162 |
163 | Release Early - Release Often
164 |
165 | Priortize bug fixing over feature development
166 |
167 | If it ain't broke don't fix it
168 |
169 | Prepare to throw one away, you will anyhow
170 |
171 | Grand plans come undone
172 |
173 | Milestones should only be a stones through away
174 |
175 | Know where you are going - use an
176 | internal compass when you run off the map
177 |
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/osg.conf:
--------------------------------------------------------------------------------
1 | ExampleThumbnails/osganimation.jpg
2 | osganimate
3 | ExampleThumbnails/osgcubemap.jpg
4 | osgcubemap cessna.osg
5 | ExampleThumbnails/osgdepthshadow.jpg
6 | osgshadow
7 | ExampleThumbnails/osgdistortion.jpg
8 | osgdistortion cow.osg
9 | ExampleThumbnails/osgfxbrowser.jpg
10 | osgfxbrowser dumptruck.osg
11 | ExampleThumbnails/osggeometry.jpg
12 | osggeometry
13 | ExampleThumbnails/osghud.jpg
14 | osghud dumptruck.osg
15 | ExampleThumbnails/osgkeyboard.jpg
16 | osgkeyboard
17 | ExampleThumbnails/osglight.jpg
18 | osglight glider.osg
19 | ExampleThumbnails/osgmotionblur.jpg
20 | osgmotionblur cow.osg
21 | ExampleThumbnails/osgmultitexture.jpg
22 | osgmultitexture cessnafire.osg
23 | ExampleThumbnails/osgparticle.jpg
24 | osgparticle
25 | ExampleThumbnails/osgprerendercubemap.jpg
26 | osgprerendercubemap
27 | ExampleThumbnails/osgreflect.jpg
28 | osgreflect cessna.osg
29 | ExampleThumbnails/osgscribe.jpg
30 | osgscribe cow.osg
31 | ExampleThumbnails/osgvertexprogram.jpg
32 | osgvertexprogram
33 |
--------------------------------------------------------------------------------
/osg64.logo:
--------------------------------------------------------------------------------
1 | LowerRight
2 | Images/osg64.png
3 |
4 |
--------------------------------------------------------------------------------
/osgWidget/README:
--------------------------------------------------------------------------------
1 | natascha.png:
2 |
3 | Used with permission, Natascha Dailey; 2008.
4 |
5 | {panel,border}*.tga:
6 | theme-1.png, theme-2.png:
7 |
8 | Created by Jeremy Moles; 2008.
9 |
10 | scrolled[1-4].jpg:
11 |
12 | Created by Jeremy Moles; 2006.
13 |
--------------------------------------------------------------------------------
/osgWidget/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/back.png
--------------------------------------------------------------------------------
/osgWidget/border-bottom.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/border-bottom.tga
--------------------------------------------------------------------------------
/osgWidget/border-left.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/border-left.tga
--------------------------------------------------------------------------------
/osgWidget/border-right.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/border-right.tga
--------------------------------------------------------------------------------
/osgWidget/border-top.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/border-top.tga
--------------------------------------------------------------------------------
/osgWidget/natascha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/natascha.png
--------------------------------------------------------------------------------
/osgWidget/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/next.png
--------------------------------------------------------------------------------
/osgWidget/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/open.png
--------------------------------------------------------------------------------
/osgWidget/osgwidgetshader-frag.glsl:
--------------------------------------------------------------------------------
1 | // osgWidget/GLSL - Copyright (C) 2007 Jeremy Moles
2 | // $Id: osgwidgetshader-frag.glsl 59 2008-05-15 20:55:31Z cubicool $
3 |
4 | varying vec4 color;
5 |
6 | void main()
7 | {
8 | vec4 c = clamp(color, 0.0, 1.0);
9 |
10 | if(mod(gl_FragCoord.y, 10.0) >= 3.0)
11 | {
12 | gl_FragColor = c * vec4(
13 | gl_FragCoord.y / 1024.0,
14 | gl_FragCoord.y / 1024.0,
15 | gl_FragCoord.y / 1024.0,
16 | 0.5);
17 |
18 | }
19 | else
20 | {
21 | gl_FragColor = c * vec4(
22 | gl_FragCoord.y / 1024.0,
23 | gl_FragCoord.y / 1024.0,
24 | gl_FragCoord.y / 1024.0,
25 | 1.0);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/osgWidget/osgwidgetshader-vert.glsl:
--------------------------------------------------------------------------------
1 | // osgWidget/GLSL - Copyright (C) 2007 Jeremy Moles
2 | // $Id: osgwidgetshader-vert.glsl 28 2008-03-26 15:26:48Z cubicool $
3 |
4 | // TODO: If I want do picking properly I need to transform the mouse coordinates
5 | // by the matrix of the WindowManger.
6 |
7 | varying vec4 color;
8 |
9 | void main() {
10 | color = gl_Color;
11 |
12 | gl_Position = ftransform();
13 | }
14 |
--------------------------------------------------------------------------------
/osgWidget/osgwidgetwindow.lua:
--------------------------------------------------------------------------------
1 | -- $Id: osgwidgetwindow.lua 50 2008-05-06 05:06:36Z cubicool $
2 |
3 | --[[
4 | Table = {}
5 |
6 | function Table:new()
7 | local t = {}
8 |
9 | setmetatable(t, self)
10 |
11 | self.__index = self
12 |
13 | return t
14 | end
15 |
16 | function Table:__concat(other)
17 | return tostring(self) .. other
18 | end
19 |
20 | function Table:foo(x)
21 | print("foo: " .. self .. x.x)
22 | print(self .. x.x)
23 | end
24 |
25 | Table.__metatable = "Protected"
26 |
27 | t1 = Table:new()
28 | t2 = Table:new()
29 |
30 | t1:foo{x="hello", y="world"}
31 |
32 | -- Other stuff...
33 | ]]--
34 |
35 | print("Our exising window var is: " .. window)
36 |
37 | w = osgwidget.newWidget()
38 |
39 | print("A new Widget is: " .. w)
40 |
--------------------------------------------------------------------------------
/osgWidget/osgwidgetwindow.py:
--------------------------------------------------------------------------------
1 | # $Id: osgwidgetwindow.py 2 2008-01-24 16:11:26Z cubicool $
2 |
3 | w = osgwidget.newWindow("nope")
4 |
--------------------------------------------------------------------------------
/osgWidget/panel-center.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/panel-center.tga
--------------------------------------------------------------------------------
/osgWidget/panel-left.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/panel-left.tga
--------------------------------------------------------------------------------
/osgWidget/panel-right.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/panel-right.tga
--------------------------------------------------------------------------------
/osgWidget/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/pause.png
--------------------------------------------------------------------------------
/osgWidget/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/play.png
--------------------------------------------------------------------------------
/osgWidget/scrolled1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/scrolled1.jpg
--------------------------------------------------------------------------------
/osgWidget/scrolled2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/scrolled2.jpg
--------------------------------------------------------------------------------
/osgWidget/scrolled3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/scrolled3.jpg
--------------------------------------------------------------------------------
/osgWidget/scrolled4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/scrolled4.jpg
--------------------------------------------------------------------------------
/osgWidget/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/stop.png
--------------------------------------------------------------------------------
/osgWidget/theme-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/theme-1.png
--------------------------------------------------------------------------------
/osgWidget/theme-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/theme-2.png
--------------------------------------------------------------------------------
/osgWidget/theme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openscenegraph/OpenSceneGraph-Data/6ac81babef49afffc1307cac130d796f56e14ba5/osgWidget/theme.png
--------------------------------------------------------------------------------
/shaders/blocky.frag:
--------------------------------------------------------------------------------
1 | // blocky.frag - an OGLSL fragment shader with animation
2 | // Mike Weiblen 2003-09-16 : derived from brick.frag
3 | // Copyright 2003 3Dlabs Inc.
4 | // see http://www.3dlabs.com/opengl2/ for more OpenGL Shading Language info.
5 |
6 |
7 | // the App updates uniforms "slowly" (eg once per frame) for animation.
8 | uniform float Sine;
9 | uniform vec3 Color1;
10 | uniform vec3 Color2;
11 |
12 | // varyings are written by vert shader, interpolated, and read by frag shader.
13 | varying vec2 BlockPosition;
14 | varying float LightIntensity;
15 |
16 | void main(void)
17 | {
18 | vec3 color;
19 | float ss, tt, w, h;
20 |
21 | ss = BlockPosition.x;
22 | tt = BlockPosition.y;
23 |
24 | if (fract(tt * 0.5) > 0.5)
25 | ss += 0.5;
26 |
27 | ss = fract(ss);
28 | tt = fract(tt);
29 |
30 | // animate the proportion of block to mortar
31 | float blockFract = (Sine + 1.1) * 0.4;
32 |
33 | w = step(ss, blockFract);
34 | h = step(tt, blockFract);
35 |
36 | color = mix(Color2, Color1, w * h) * LightIntensity;
37 | gl_FragColor = vec4 (color, 1.0);
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/shaders/blocky.vert:
--------------------------------------------------------------------------------
1 | // blocky.vert - an OGLSL vertex shader with animation
2 | // Mike Weiblen 2003-09-16 : derived from brick.vert
3 | // Copyright 2003 3Dlabs Inc.
4 | // see http://www.3dlabs.com/opengl2/ for more OpenGL Shading Language info.
5 |
6 |
7 | // the App updates uniforms "slowly" (eg once per frame) for animation.
8 | uniform float Sine;
9 |
10 | const vec3 LightPosition = vec3(0.0, 0.0, 4.0);
11 | const float BlockScale = 0.30;
12 |
13 | // varyings are written by vert shader, interpolated, and read by frag shader.
14 | varying float LightIntensity;
15 | varying vec2 BlockPosition;
16 |
17 | void main(void)
18 | {
19 | // per-vertex diffuse lighting
20 | vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
21 | vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
22 | vec3 lightVec = normalize(LightPosition - vec3 (ecPosition));
23 | LightIntensity = max(dot(lightVec, tnorm), 0.0);
24 |
25 | // blocks will be determined by fragment's position on the XZ plane.
26 | BlockPosition = gl_Vertex.xz / BlockScale;
27 |
28 | // scale the geometry based on an animation variable.
29 | vec4 vertex = gl_Vertex;
30 | vertex.w = 1.0 + 0.4 * (Sine + 1.0);
31 |
32 | gl_Position = gl_ModelViewProjectionMatrix * vertex;
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/shaders/brick.frag:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // brick.frag: Fragment shader for procedural bricks
4 | // an example of an OpenGL Shading Language source file.
5 | //
6 | // author: Dave Baldwin, Steve Koren, Randi Rost
7 | // originally based on a shader by Darwyn Peachey
8 | //
9 | // Copyright (c) 2002: 3Dlabs, Inc.
10 | //
11 |
12 | // This file derived from the ogl2demo example in the 3Dlabs OpenGL2 SDK
13 | // available from http://www.3dlabs.com/opengl2/
14 | // Mike Weiblen 2003-07-14 : til osgGL2 implements the setting of uniforms,
15 | // temporarily use consts instead.
16 |
17 | // uniform vec3 BrickColor, MortarColor;
18 | // uniform float ColumnWidth, RowHeight;
19 | // uniform float Bwf, Bhf;
20 |
21 | const vec3 BrickColor = vec3(1.0, 0.3, 0.2);
22 | const vec3 MortarColor = vec3(0.85, 0.85, 0.85);
23 | const float ColumnWidth = 0.30;
24 | const float RowHeight = 0.15;
25 | const float Bwf = 0.95;
26 | const float Bhf = 0.90;
27 |
28 | varying vec2 MCposition;
29 | varying float LightIntensity;
30 |
31 | void main(void)
32 | {
33 | vec3 color;
34 | float ss, tt, w, h;
35 |
36 | ss = MCposition.x / ColumnWidth;
37 | tt = MCposition.y / RowHeight;
38 |
39 | if (fract(tt * 0.5) > 0.5)
40 | ss += 0.5;
41 |
42 | ss = fract(ss);
43 | tt = fract(tt);
44 |
45 | w = step(ss, Bwf);
46 | h = step(tt, Bhf);
47 |
48 | color = mix(MortarColor, BrickColor, w * h) * LightIntensity;
49 | gl_FragColor = vec4 (color, 1.0);
50 | }
51 |
--------------------------------------------------------------------------------
/shaders/brick.vert:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // brick.vert: Vertex shader for procedural bricks
4 | // an example of an OpenGL Shading Language source file.
5 | //
6 | // author: Dave Baldwin, Steve Koren, Randi Rost
7 | // based on a shader by Darwyn Peachey
8 | //
9 | // Copyright (c) 2002: 3Dlabs, Inc.
10 | //
11 |
12 | // This file derived from the ogl2demo example in the 3Dlabs OpenGL2 SDK
13 | // available from http://www.3dlabs.com/opengl2/
14 | // Mike Weiblen 2003-07-14 : til osgGL2 implements the setting of uniforms,
15 | // temporarily use consts instead.
16 |
17 | //uniform vec3 LightPosition;
18 | const vec3 LightPosition = vec3(0.0, 0.0, 4.0);
19 |
20 | const float specularContribution = 0.3;
21 | const float diffuseContribution = (1.0 - specularContribution);
22 |
23 | varying float LightIntensity;
24 | varying vec2 MCposition;
25 |
26 | void main(void)
27 | {
28 | vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
29 | vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
30 | vec3 lightVec = normalize(LightPosition - vec3 (ecPosition));
31 | vec3 reflectVec = reflect(-lightVec, tnorm);
32 | vec3 viewVec = normalize(vec3 (-ecPosition));
33 | float spec = max(dot(reflectVec, viewVec), 0.0);
34 | spec = pow(spec, 16.0);
35 | LightIntensity = diffuseContribution * max(dot(lightVec, tnorm), 0.0) +
36 | specularContribution * spec;
37 | MCposition = gl_Vertex.xz;
38 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
39 | }
40 |
--------------------------------------------------------------------------------
/shaders/depthpeel_colormap.frag:
--------------------------------------------------------------------------------
1 | /*
2 | Steffen Frey
3 | Fachpraktikum Graphik-Programmierung 2007
4 | Institut fuer Visualisierung und Interaktive Systeme
5 | Universitaet Stuttgart
6 | */
7 |
8 | uniform sampler2D tex;
9 | uniform sampler2D normalDepthMap;
10 |
11 | uniform float width;
12 | uniform float height;
13 |
14 | varying float depthInCamera;
15 |
16 | void main( void )
17 | {
18 | vec2 texCoord = vec2(gl_FragCoord.x/width, gl_FragCoord.y/height);
19 |
20 | float prevDepth = texture2D(normalDepthMap, texCoord).w;
21 |
22 | if(depthInCamera > prevDepth + 0.0005)
23 | discard;
24 |
25 | gl_FragColor = vec4(gl_Color.xyz, 0.3);
26 | gl_FragDepth = depthInCamera;
27 | }
28 |
--------------------------------------------------------------------------------
/shaders/depthpeel_colormap.vert:
--------------------------------------------------------------------------------
1 | /*
2 | Steffen Frey
3 | Fachpraktikum Graphik-Programmierung 2007
4 | Institut fuer Visualisierung und Interaktive Systeme
5 | Universitaet Stuttgart
6 | */
7 |
8 | uniform float znear;
9 | uniform float zfar;
10 |
11 | //depth in camera space
12 | varying float depthInCamera;
13 |
14 | void main( void )
15 | {
16 | vec4 position = gl_ModelViewMatrix * gl_Vertex;
17 | depthInCamera = (abs(position.z) - znear) / (zfar - znear);
18 | gl_Position = ftransform();
19 | gl_FrontColor = gl_Color;
20 | }
21 |
--------------------------------------------------------------------------------
/shaders/depthpeel_edgemap.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D normalDepthMap;
2 | uniform sampler2D edgeMap;
3 | uniform float first;
4 | uniform float width;
5 | uniform float height;
6 |
7 | void main( void )
8 | {
9 | vec2 dx = vec2(1.0/width, 0.0);
10 | vec2 dy = vec2(0.0, 1.0/height);
11 | //vec2 center = gl_TexCoord[1].st;
12 | vec2 center = vec2(gl_FragCoord.x/width, gl_FragCoord.y/height);
13 |
14 | vec4 ul, ur, ll, lr;
15 |
16 | ul = texture2D(normalDepthMap, center -dx + dy);
17 | ur = texture2D(normalDepthMap, center + dx + dy);
18 | ll = texture2D(normalDepthMap, center - dx + dy);
19 | lr = texture2D(normalDepthMap, center + dx - dy);
20 |
21 | // calculate discontinuities
22 | vec3 discontinuity = vec3(0.0, 0.0, 0.0);
23 |
24 | //(Maybe should decode normals from [0,1] to [-1, 1], but works well the way it is done below)
25 | float dot0 = dot(ul.xyz, lr.xyz);
26 | float dot1 = dot(ur.xyz, ll.xyz);
27 | discontinuity.x = 0.5*(dot0+dot1);
28 |
29 | float depth_discont0 = 1.0-abs(ul.w - lr.w);
30 | float depth_discont1 = 1.0-abs(ur.w - ll.w);
31 |
32 | discontinuity.y = depth_discont0*depth_discont1;
33 |
34 | discontinuity.z = abs(discontinuity.x*discontinuity.y);
35 |
36 | //combine the generated edge map with the previous edge map
37 | vec4 prevEdge = texture2D(edgeMap, center);
38 | discontinuity.z = max(discontinuity.z - (1.0-first)*(1.0 - prevEdge.z), 0.0);
39 | gl_FragColor = vec4(discontinuity.z, discontinuity.z, discontinuity.z, 1.0);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/shaders/depthpeel_edgemap.vert:
--------------------------------------------------------------------------------
1 | void main( void )
2 | {
3 | //gl_ClipVertex
4 | gl_TexCoord[1] = gl_MultiTexCoord1;
5 | //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
6 | gl_Position = ftransform();
7 | }
8 |
--------------------------------------------------------------------------------
/shaders/depthpeel_final.frag:
--------------------------------------------------------------------------------
1 | /*
2 | Steffen Frey
3 | Fachpraktikum Graphik-Programmierung 2007
4 | Institut fuer Visualisierung und Interaktive Systeme
5 | Universitaet Stuttgart
6 | */
7 |
8 | //these are for debugging purposes only
9 | uniform sampler2D normalDepthMap0;
10 | uniform sampler2D normalDepthMap1;
11 |
12 | uniform sampler2D edgeMap;
13 | uniform sampler2D colorMap;
14 | uniform sampler2D noiseMap;
15 |
16 | uniform bool sketchy;
17 | uniform bool colored;
18 | uniform bool edgy;
19 |
20 | uniform float sketchiness;
21 |
22 | void main( void )
23 | {
24 | vec4 color;
25 | vec4 edge;
26 | //sketchy
27 | if(sketchy)
28 | {
29 | vec2 off = vec2(texture2D(noiseMap, gl_TexCoord[1].st).x,
30 | texture2D(noiseMap, vec2(1. - gl_TexCoord[1].s, 1. - gl_TexCoord[1].t)).x);
31 | off = 2. * off - 1.;
32 | vec4 a = sketchiness * vec4(0.007, 0.005, 0.006, 0.004);
33 | vec2 stEdge = gl_TexCoord[1].st + vec2(a[0]*off[0] + a[1]*off[1], a[2]*off[0] + a[3] * off[1]);
34 |
35 | vec4 b = sketchiness * vec4(0.014, 0.012, 0.016, 0.01);
36 | vec2 stColor = gl_TexCoord[1].st + vec2(b[0]*off[0] + b[1]*off[1], b[2]*off[0] + b[3] * off[1]);
37 |
38 | float borderWidth = 0.005;
39 |
40 | color = texture2D(colorMap, vec2(clamp(stColor.s, borderWidth, 1.-borderWidth) ,
41 | clamp(stColor.t, borderWidth, 1.-borderWidth)));
42 | edge = texture2D(edgeMap, vec2(clamp(stEdge.s, borderWidth, 1.-borderWidth) ,
43 | clamp(stEdge.t, borderWidth, 1.-borderWidth)));
44 |
45 | }
46 | else
47 | {
48 | color = texture2D(colorMap, gl_TexCoord[1].st);
49 | edge = texture2D(edgeMap, gl_TexCoord[1].st);
50 | }
51 |
52 | vec4 composed = vec4(max(color.x - (1.0 - edge.x), 0.0),
53 | max(color.y - (1.0 - edge.y), 0.0),
54 | max(color.z - (1.0 - edge.z), 0.0),
55 | 1.0);
56 |
57 |
58 | if(colored && edgy)
59 | {
60 | gl_FragColor = composed;
61 | }
62 | else if(edgy)
63 | {
64 | gl_FragColor = vec4(edge.xyz, 1.0);
65 | }
66 | else if(colored)
67 | {
68 | gl_FragColor = vec4(color.xyz, 1.0);
69 | }
70 | else
71 | {
72 | gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/shaders/depthpeel_final.vert:
--------------------------------------------------------------------------------
1 | /*
2 | Steffen Frey
3 | Fachpraktikum Graphik-Programmierung 2007
4 | Institut fuer Visualisierung und Interaktive Systeme
5 | Universitaet Stuttgart
6 | */
7 |
8 | void main( void )
9 | {
10 | //gl_ClipVertex
11 | gl_TexCoord[0] = gl_MultiTexCoord0;
12 | gl_TexCoord[1] = gl_MultiTexCoord1;
13 | //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
14 | gl_Position = ftransform();
15 | }
16 |
--------------------------------------------------------------------------------
/shaders/depthpeel_normaldepthmap.frag:
--------------------------------------------------------------------------------
1 | /*
2 | Steffen Frey
3 | Fachpraktikum Graphik-Programmierung 2007
4 | Institut fuer Visualisierung und Interaktive Systeme
5 | Universitaet Stuttgart
6 | */
7 |
8 | uniform sampler2D normalDepthMap;
9 |
10 | uniform float width;
11 | uniform float height;
12 | varying vec3 normalPerVertex;
13 | varying float depthInCamera;
14 |
15 | uniform bool first;
16 |
17 | void main()
18 | {
19 | vec2 texCoord = vec2(gl_FragCoord.x/width, gl_FragCoord.y/height);
20 | float prevDepth = texture2D(normalDepthMap, texCoord).w;
21 |
22 | //peel away depth layers
23 | if(!first && depthInCamera <= prevDepth + 0.0005)
24 | discard;
25 |
26 | //normalize the per fragment normal
27 | vec3 normal = normalize(normalPerVertex);
28 |
29 | // Encode normals: [-1,1] to [0,1]
30 | //normal = (normal+1.0)*0.5;
31 | normal = abs(normal);
32 |
33 | // Output color and depth
34 | gl_FragColor = vec4(normal, depthInCamera);
35 | gl_FragDepth = depthInCamera;
36 | }
37 |
--------------------------------------------------------------------------------
/shaders/depthpeel_normaldepthmap.vert:
--------------------------------------------------------------------------------
1 | /*
2 | Steffen Frey
3 | Fachpraktikum Graphik-Programmierung 2007
4 | Institut fuer Visualisierung und Interaktive Systeme
5 | Universitaet Stuttgart
6 | */
7 |
8 | uniform float znear;
9 | uniform float zfar;
10 |
11 | //normal per vertx
12 | varying vec3 normalPerVertex;
13 |
14 | //depth in camera space
15 | varying float depthInCamera;
16 |
17 | vec3 fnormal(void)
18 | {
19 | vec3 normal = gl_NormalMatrix * gl_Normal;
20 | normal = normalize(normal);
21 | return normal;
22 | }
23 |
24 | void main()
25 | {
26 | gl_TexCoord[0] = gl_MultiTexCoord0;
27 | normalPerVertex = fnormal();
28 | vec4 position = gl_ModelViewMatrix * gl_Vertex;
29 | depthInCamera = (abs(position.z) - znear) / (zfar - znear);
30 | gl_Position = ftransform();
31 | }
32 |
--------------------------------------------------------------------------------
/shaders/eroded.frag:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // eroded.frag: Fragment shader for erosion effect
4 | //
5 | // author: Randi Rost
6 | //
7 | // Copyright (c) 2002: 3Dlabs, Inc.
8 | //
9 |
10 | varying float lightIntensity;
11 | varying vec3 Position;
12 |
13 | uniform vec3 Offset;
14 | uniform sampler3D sampler3d; // value of sampler3d = 6
15 |
16 | void main (void)
17 | {
18 | vec4 noisevec;
19 | vec3 color;
20 | float intensity;
21 |
22 | noisevec = texture3D(sampler3d, 1.2 * (vec3 (0.5) + Position));
23 |
24 | intensity = 0.75 * (noisevec.x + noisevec.y + noisevec.z + noisevec.w);
25 |
26 | intensity = 1.95 * abs(2.0 * intensity - 1.0);
27 | intensity = clamp(intensity, 0.0, 1.0);
28 |
29 | if (intensity < fract(0.5-Offset.x-Offset.y-Offset.z)) discard;
30 |
31 | color = mix(vec3 (0.2, 0.1, 0.0), vec3(0.8, 0.8, 0.8), intensity);
32 |
33 | color *= lightIntensity;
34 | color = clamp(color, 0.0, 1.0);
35 |
36 | gl_FragColor = vec4 (color, 1.0);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/shaders/eroded.vert:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // eroded.vert: Vertex shader for erosion effect
4 | //
5 | // author: Randi Rost
6 | //
7 | // Copyright (c) 2002: 3Dlabs, Inc.
8 | //
9 |
10 | varying float lightIntensity;
11 | varying vec3 Position;
12 | uniform vec3 LightPosition;
13 | uniform float Scale;
14 |
15 | void main(void) {
16 | vec4 pos = gl_ModelViewMatrix * gl_Vertex;
17 | Position = vec3(gl_Vertex) * Scale;
18 | vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
19 | float dotval = max(dot(normalize(LightPosition - vec3(pos)), tnorm), 0.0);
20 | lightIntensity = dotval * 1.5;
21 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
22 | }
23 |
--------------------------------------------------------------------------------
/shaders/gameoflife.frag:
--------------------------------------------------------------------------------
1 | /* -*- Mode: C -*- */
2 | uniform sampler2DRect textureIn;
3 |
4 | void main(void)
5 | {
6 | vec2 texCoord = gl_TexCoord[0].xy;
7 |
8 | const float offset = 1.0;
9 |
10 | // Consider only the red channel in the input image, if > 0.5 assume alive.
11 |
12 | // center
13 | int c = texture2DRect(textureIn, texCoord).r > 0.5 ? 1 : 0;
14 | // bottom left
15 | int bl = texture2DRect(textureIn, texCoord + vec2(-offset, -offset)).r > 0.5 ? 1 : 0;
16 | // left
17 | int l = texture2DRect(textureIn, texCoord + vec2(-offset, 0.0)).r > 0.5 ? 1 : 0;
18 | // top left
19 | int tl = texture2DRect(textureIn, texCoord + vec2(-offset, offset)).r > 0.5 ? 1 : 0;
20 | // top
21 | int t = texture2DRect(textureIn, texCoord + vec2( 0.0, offset)).r > 0.5 ? 1 : 0;
22 | // top right
23 | int tr = texture2DRect(textureIn, texCoord + vec2( offset, offset)).r > 0.5 ? 1 : 0;
24 | // right
25 | int r = texture2DRect(textureIn, texCoord + vec2( offset, 0.0)).r > 0.5 ? 1 : 0;
26 | // bottom right
27 | int br = texture2DRect(textureIn, texCoord + vec2( offset, -offset)).r > 0.5 ? 1 : 0;
28 | // bottom
29 | int b = texture2DRect(textureIn, texCoord + vec2( 0.0, -offset)).r > 0.5 ? 1 : 0;
30 |
31 | // sum neighbours
32 | int sum = bl + l + tl + t + tr + r + br + b;
33 |
34 | // the rules of Conway's game of life
35 | vec4 outval;
36 | if (c == 1) { // cell alive
37 | if (sum < 2 ) { // loneliness
38 | outval = vec4(0,0,0,1);
39 | } else if (sum > 3) { // overcrowding
40 | outval = vec4(0,0,0,1);
41 | } else { // unchanged
42 | outval = vec4(1,1,1,1);
43 | }
44 | } else { // cell dead
45 | if (sum == 3) { // come to life
46 | outval = vec4(1,1,1,1);
47 | } else { // unchanged
48 | outval = vec4(0,0,0,1);
49 | }
50 | }
51 |
52 | gl_FragColor = outval;
53 | }
54 |
--------------------------------------------------------------------------------
/shaders/lighting.vert:
--------------------------------------------------------------------------------
1 | #pragma requires(LIGHTING)
2 |
3 | void directionalLight( int lightNum, vec3 normal, inout vec4 color )
4 | {
5 | vec3 n = normalize(gl_NormalMatrix * normal);
6 |
7 | float NdotL = dot( n, normalize(gl_LightSource[lightNum].position.xyz) );
8 | NdotL = max( 0.0, NdotL );
9 |
10 | float NdotHV = dot( n, gl_LightSource[lightNum].halfVector.xyz );
11 | NdotHV = max( 0.0, NdotHV );
12 | #if 1
13 | color *= gl_LightSource[lightNum].ambient +
14 | gl_LightSource[lightNum].diffuse * NdotL;
15 | #else
16 | color *= gl_FrontLightModelProduct.sceneColor +
17 | gl_FrontLightProduct[lightNum].ambient +
18 | gl_FrontLightProduct[lightNum].diffuse * NdotL;
19 | #endif
20 | #if 0
21 | if ( NdotL * NdotHV > 0.0 )
22 | color += gl_FrontLightProduct[lightNum].specular * pow( NdotHV, gl_FrontMaterial.shininess );
23 | #endif
24 | }
25 |
--------------------------------------------------------------------------------
/shaders/line_rain.vert:
--------------------------------------------------------------------------------
1 | uniform float inversePeriod;
2 | uniform vec4 particleColour;
3 | uniform float particleSize;
4 |
5 | uniform float osg_SimulationTime;
6 | uniform float osg_DeltaSimulationTime;
7 |
8 | varying vec4 colour;
9 | varying vec2 texCoord;
10 |
11 | void main(void)
12 | {
13 | float offset = gl_Vertex.z;
14 | float startTime = gl_MultiTexCoord1.x;
15 | texCoord = gl_MultiTexCoord0.xy;
16 |
17 | vec4 v_previous = gl_Vertex;
18 | v_previous.z = fract( (osg_SimulationTime - startTime)*inversePeriod - offset);
19 |
20 | vec4 v_current = v_previous;
21 | v_current.z += (osg_DeltaSimulationTime*inversePeriod);
22 |
23 |
24 | colour = particleColour;
25 |
26 | vec4 v1 = gl_ModelViewMatrix * v_current;
27 | vec4 v2 = gl_TextureMatrix[0] * v_previous;
28 |
29 | vec3 dv = v2.xyz - v1.xyz;
30 |
31 | vec2 dv_normalized = normalize(dv.xy);
32 | dv.xy += dv_normalized * particleSize;
33 |
34 | float area = length(dv.xy);
35 | colour.a = (particleSize)/area;
36 |
37 | v1.xyz += dv*texCoord.y;
38 |
39 | gl_Position = gl_ProjectionMatrix * v1;
40 | }
41 |
--------------------------------------------------------------------------------
/shaders/lookup.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D sourceTexture;
2 | uniform sampler1D lookupTexture;
3 |
4 | uniform float minValue;
5 | uniform float inverseRange;
6 | uniform mat3 filterMatrix;
7 | varying vec2 texcoord[9];
8 |
9 | uniform float filterBias;
10 |
11 | #if 1
12 |
13 | void main()
14 | {
15 | float value_0 = 0.0;
16 | float original_value = texture2D(sourceTexture, texcoord[4].xy, 0.0).x;
17 | float max_delta = 0.01;
18 | float value = original_value;
19 | float minBias = 0.5;
20 | float maxBias = 2.5;
21 | float deltaBias = 0.5;
22 | for(float bias = minBias; bias max_delta) break;
26 | value = new_value;
27 | }
28 |
29 | vec4 overlay_color = texture1D(lookupTexture, (value-minValue)*inverseRange );
30 |
31 | gl_FragColor = overlay_color * gl_Color;
32 | }
33 |
34 | #else
35 |
36 | void main()
37 | {
38 | float bias = filterBias;
39 |
40 | float value = 0.0;
41 | value += texture2D(sourceTexture, texcoord[0].xy, bias).x * filterMatrix[0][0];
42 | value += texture2D(sourceTexture, texcoord[1].xy, bias).x * filterMatrix[0][1];
43 | value += texture2D(sourceTexture, texcoord[2].xy, bias).x * filterMatrix[0][2];
44 | value += texture2D(sourceTexture, texcoord[3].xy, bias).x * filterMatrix[1][0];
45 | value += texture2D(sourceTexture, texcoord[4].xy, bias).x * filterMatrix[1][1];
46 | value += texture2D(sourceTexture, texcoord[5].xy, bias).x * filterMatrix[1][2];
47 | value += texture2D(sourceTexture, texcoord[6].xy, bias).x * filterMatrix[2][0];
48 | value += texture2D(sourceTexture, texcoord[7].xy, bias).x * filterMatrix[2][1];
49 | value += texture2D(sourceTexture, texcoord[8].xy, bias).x * filterMatrix[2][2];
50 |
51 | vec4 overlay_color = texture1D(lookupTexture, (value-minValue)*inverseRange );
52 |
53 | gl_FragColor = overlay_color * gl_Color;
54 | }
55 | #endif
56 |
--------------------------------------------------------------------------------
/shaders/lookup.vert:
--------------------------------------------------------------------------------
1 | uniform float filterWidth;
2 | uniform bool lightingEnabled;
3 |
4 | varying vec2 texcoord[9];
5 |
6 |
7 | vec3 fnormal(void)
8 | {
9 | //Compute the normal
10 | vec3 normal = gl_NormalMatrix * gl_Normal;
11 | normal = normalize(normal);
12 | return normal;
13 | }
14 |
15 | void directionalLight(in int i,
16 | in vec3 normal,
17 | inout vec4 ambient,
18 | inout vec4 diffuse,
19 | inout vec4 specular)
20 | {
21 | float nDotVP; // normal . light direction
22 | float nDotHV; // normal . light half vector
23 | float pf; // power factor
24 |
25 | nDotVP = max(0.0, dot(normal, normalize(vec3 (gl_LightSource[i].position))));
26 | nDotHV = max(0.0, dot(normal, vec3 (gl_LightSource[i].halfVector)));
27 |
28 | if (nDotVP == 0.0)
29 | {
30 | pf = 0.0;
31 | }
32 | else
33 | {
34 | pf = pow(nDotHV, gl_FrontMaterial.shininess);
35 |
36 | }
37 | ambient += gl_LightSource[i].ambient;
38 | diffuse += gl_LightSource[i].diffuse * nDotVP;
39 | specular += gl_LightSource[i].specular * pf;
40 | }
41 |
42 |
43 |
44 | void main()
45 | {
46 | gl_Position = ftransform();
47 |
48 | if (lightingEnabled)
49 | {
50 | vec4 ambient = vec4(0.0);
51 | vec4 diffuse = vec4(0.0);
52 | vec4 specular = vec4(0.0);
53 |
54 |
55 | vec3 normal = fnormal();
56 |
57 | directionalLight(0, normal, ambient, diffuse, specular);
58 |
59 | vec4 color = gl_FrontLightModelProduct.sceneColor +
60 | ambient * gl_FrontMaterial.ambient +
61 | diffuse * gl_FrontMaterial.diffuse +
62 | specular * gl_FrontMaterial.specular;
63 |
64 | gl_FrontColor = color;
65 |
66 | }
67 | else
68 | {
69 | gl_FrontColor = gl_Color;
70 | }
71 |
72 | float delta = filterWidth;
73 |
74 | texcoord[0].xy = gl_MultiTexCoord0.xy + vec2(-delta, delta);
75 | texcoord[1].xy = gl_MultiTexCoord0.xy + vec2(-delta, 0);
76 | texcoord[2].xy = gl_MultiTexCoord0.xy + vec2(-delta, -delta);
77 | texcoord[3].xy = gl_MultiTexCoord0.xy + vec2(0, delta);
78 | texcoord[4].xy = gl_MultiTexCoord0.xy + vec2(0, 0);
79 | texcoord[5].xy = gl_MultiTexCoord0.xy + vec2(0, -delta);
80 | texcoord[6].xy = gl_MultiTexCoord0.xy + vec2(delta, delta);
81 | texcoord[7].xy = gl_MultiTexCoord0.xy + vec2(delta, 0);
82 | texcoord[8].xy = gl_MultiTexCoord0.xy + vec2(delta, -delta);
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/shaders/marble.frag:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // marble.frag: Fragment shader for producing a marble effect
4 | //
5 | // author: Randi Rost
6 | //
7 | // Copyright (c) 2002: 3Dlabs, Inc.
8 | //
9 |
10 | // Mike Weiblen 2003-09-19 : derived from ogl2demo in the 3Dlabs OpenGL2 SDK,
11 | // available from http://www.3dlabs.com/opengl2/
12 |
13 | varying float LightIntensity;
14 | varying vec3 MCposition;
15 |
16 | const vec3 MarbleColor = vec3( 0.7, 0.7, 0.7 );
17 | const vec3 VeinColor = vec3( 0.0, 0.15, 0.0 );
18 |
19 | uniform sampler3D NoiseTex;
20 | uniform sampler1D SineTex;
21 | uniform vec3 Offset;
22 |
23 | void main (void)
24 | {
25 | vec4 noisevec = texture3D(NoiseTex, MCposition + Offset.yzx);
26 |
27 | float intensity = abs(noisevec[0] - 0.25) +
28 | abs(noisevec[1] - 0.125) +
29 | abs(noisevec[2] - 0.0625) +
30 | abs(noisevec[3] - 0.03125);
31 |
32 | vec4 unswiz = texture1D(SineTex, MCposition.z + intensity * 2.0);
33 | float sineval = unswiz.s;
34 | vec3 color = mix(VeinColor, MarbleColor, sineval);
35 | color *= LightIntensity;
36 | color = clamp(color, 0.0, 1.0);
37 | gl_FragColor = vec4 (color, 1.0);
38 | }
39 |
--------------------------------------------------------------------------------
/shaders/marble.vert:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // marble.vert: Vertex shader for producing a marble effect
4 | //
5 | // author: Randi Rost
6 | //
7 | // Copyright (c) 2002: 3Dlabs, Inc.
8 | //
9 |
10 | // Mike Weiblen 2003-09-19 : derived from ogl2demo in the 3Dlabs OpenGL2 SDK,
11 | // available from http://www.3dlabs.com/opengl2/
12 |
13 | const float Scale = 1.0;
14 | const vec3 LightPos = vec3( 0.0, 0.0, 4.0 );
15 |
16 | varying float LightIntensity;
17 | varying vec3 MCposition;
18 |
19 | void main(void)
20 | {
21 | vec4 ECposition = gl_ModelViewMatrix * gl_Vertex;
22 | MCposition = vec3 (gl_Vertex) * Scale;
23 | vec3 tnorm = normalize(vec3 (gl_NormalMatrix * gl_Normal));
24 | LightIntensity = dot(normalize(LightPos - vec3 (ECposition)), tnorm) * 1.5;
25 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
26 | }
27 |
--------------------------------------------------------------------------------
/shaders/osgText_Text.vert:
--------------------------------------------------------------------------------
1 | $OSG_GLSL_VERSION
2 | $OSG_PRECISION_FLOAT
3 |
4 | $OSG_VARYING_OUT vec2 texCoord;
5 | $OSG_VARYING_OUT vec4 vertexColor;
6 |
7 | void main(void)
8 | {
9 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
10 | texCoord = gl_MultiTexCoord0.xy;
11 | vertexColor = gl_Color;
12 |
13 | #if !defined(GL_ES) && __VERSION__<140
14 | gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
15 | #endif
16 | }
17 |
--------------------------------------------------------------------------------
/shaders/osgshadercomposition.frag:
--------------------------------------------------------------------------------
1 | #pragma import_defines ( TEXTURE_2D )
2 |
3 | #ifdef TEXTURE_2D
4 | uniform sampler2D texture0;
5 |
6 | varying vec2 texcoord;
7 | #endif
8 |
9 | varying vec4 basecolor;
10 |
11 | void main(void)
12 | {
13 | #ifdef TEXTURE_2D
14 | gl_FragColor = texture2D( texture0, texcoord) * basecolor;
15 | #else
16 | gl_FragColor = basecolor;
17 | #endif
18 | }
19 |
--------------------------------------------------------------------------------
/shaders/osgshadercomposition.vert:
--------------------------------------------------------------------------------
1 | #pragma import_defines ( LIGHTING, TEXTURE_2D, VERTEX_FUNC(v) )
2 |
3 | #ifdef LIGHTING
4 | // forward declare lighting computation, provided by lighting.vert shader
5 | void directionalLight( int lightNum, vec3 normal, inout vec4 color );
6 | #endif
7 |
8 | #ifdef TEXTURE_2D
9 | varying vec2 texcoord;
10 | #endif
11 |
12 | #ifdef VERTEX_FUNC
13 | uniform float osg_SimulationTime;
14 | #endif
15 |
16 | varying vec4 basecolor;
17 |
18 | void main(void)
19 | {
20 | basecolor = gl_Color;
21 |
22 | #ifdef LIGHTING
23 | directionalLight( 0, gl_Normal.xyz, basecolor);
24 | #endif
25 |
26 | #ifdef TEXTURE_2D
27 | // if we want texturing we need to pass on texture coords
28 | texcoord = gl_MultiTexCoord0.xy;
29 | #endif
30 |
31 | #ifdef VERTEX_FUNC
32 | gl_Position = gl_ModelViewProjectionMatrix * VERTEX_FUNC(gl_Vertex);
33 | #else
34 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
35 | #endif
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/shaders/osgssboComputeShader.cs:
--------------------------------------------------------------------------------
1 | #version 430
2 | uniform int numRows;
3 | uniform int numCols;
4 | uniform highp float osg_FrameTime;
5 | uniform uint osg_FrameNumber;
6 | uniform highp float osg_DeltaFrameTime;
7 |
8 | layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
9 |
10 | float timeMultiplier = 0.01 ;
11 | int OFFSET = numRows*numRows;
12 | int POSITION_NOW_OFFSET = 0;
13 | int POSITION_OLD_OFFSET = 1;
14 | int POSITION_INIT_OFFSET = 2;
15 | int VELOCITY_NOW_OFFSET = 3;
16 | int VELOCITY_OLD_OFFSET = 4;
17 | int VELOCITY_INIT_OFFSET = 5;
18 | int ACCELERATION_OFFSET = 6;
19 | int PROPERTIES_OFFSET = 7;
20 |
21 |
22 | layout(std140, binding = 0) coherent buffer particles{vec4 particleDataBuffer[];};
23 |
24 |
25 | void main() {
26 | uint gidX = gl_GlobalInvocationID.x;
27 | uint gidY = gl_GlobalInvocationID.y;
28 | ivec2 storePos = ivec2(gidX,gidY);
29 | vec4 partCurrPos = particleDataBuffer[ POSITION_NOW_OFFSET *OFFSET+(gidY*numCols + gidX)];
30 | vec4 partPrevPos = particleDataBuffer[ POSITION_OLD_OFFSET *OFFSET+(gidY*numCols + gidX)];
31 | vec4 partInitPos = particleDataBuffer[ POSITION_INIT_OFFSET *OFFSET+(gidY*numCols + gidX)];
32 | vec4 partCurrVelocity = particleDataBuffer[ VELOCITY_NOW_OFFSET *OFFSET+(gidY*numCols + gidX)];
33 | vec4 partPrevVelocity = particleDataBuffer[ VELOCITY_OLD_OFFSET *OFFSET+(gidY*numCols + gidX)];
34 | vec4 partInitVelocity = particleDataBuffer[ VELOCITY_INIT_OFFSET *OFFSET+(gidY*numCols + gidX)];
35 | vec4 partAcceleration = particleDataBuffer[ ACCELERATION_OFFSET *OFFSET+(gidY*numCols + gidX)];
36 | vec4 partProperties = particleDataBuffer[ PROPERTIES_OFFSET *OFFSET+(gidY*numCols + gidX)];
37 | highp vec4 tempCurrPos;
38 | highp vec4 tempCurrVelocity;
39 |
40 | #if 0 //begin reininit (resetset all particles back on init position)
41 |
42 | partPrevPos = partInitPos ;
43 | partPrevVelocity = partInitVelocity;
44 | //partProperties.w = 0.0;
45 |
46 | #endif //end reininit
47 |
48 |
49 |
50 | float maxParticles = numRows *numCols;
51 | uint gid = gidY*numCols + gidX;
52 |
53 |
54 |
55 |
56 | #if 0 //collision testing could be done here , all against all not working yet
57 |
58 | bool hitSomeOtherParticle = false;
59 |
60 | for(uint i = 0; i < maxParticles ;i++)
61 | {
62 | if ( (i == gid) ) //|| (mod(i+osg_FrameNumber, 5) > 0) )
63 | {
64 | //ignore, not try to test against itself
65 | }
66 | else
67 | {
68 | vec4 somneighborPrevPos = particleDataBuffer[POSITION_OLD_OFFSET *OFFSET+(numRows * numCols) + i];
69 |
70 | //collision testing this way is expensive
71 | float distanceBetweenParticles = length(partPrevPos.xyz-somneighborPrevPos.xyz);
72 | if(distanceBetweenParticles < (0.05) )
73 | {
74 | hitSomeOtherParticle = true;
75 | }
76 | }
77 | }
78 |
79 | if(hitSomeOtherParticle)
80 | {
81 | //store hittime and change the color (used by vertexshader)
82 | partProperties.z = osg_FrameTime;
83 | partProperties.w = 1.0;
84 | }
85 | else
86 | {
87 | partProperties.w = 0.0;
88 | }
89 |
90 | #endif
91 |
92 |
93 | //is highp needed to get best precision on nvidia gpu's
94 |
95 | //put your own rocket science stuff here.. this is just to get it moving
96 | highp float r = partProperties.y;
97 | highp float _coeff_A = 1.0;
98 | highp float _coeff_B = 1.0;
99 | highp vec3 velocityNormalized = normalize(partPrevVelocity.xyz);
100 | highp float R = _coeff_A * r * velocityNormalized.x + _coeff_B * r * r * velocityNormalized.y * velocityNormalized.z;
101 | highp vec3 fr = -R * vec3(partPrevVelocity.xyz);
102 | highp float mass = 1000.0 * r*r*r *3.141572 *0.75;
103 | highp float massInvers = 1.0 / mass;
104 | highp vec3 dv = fr * massInvers * osg_DeltaFrameTime;
105 |
106 |
107 | vec3 vortAxis = vec3(0, 1, 0);
108 | highp float l = dot(vortAxis, ( partPrevPos.xyz - vec3(0.5, 0.5, 0.5)));
109 | highp vec3 lc = vec3(0.5, 0.5, 0.5) + vortAxis * l;
110 | highp vec3 Ra = partPrevPos.xyz - lc;
111 | highp vec3 vVort = cross(Ra, vortAxis) * massInvers ;
112 |
113 |
114 | #if 1 //begin toggle to pause simulation , set 0, it will stop writing
115 |
116 | tempCurrVelocity = partPrevVelocity + timeMultiplier*osg_DeltaFrameTime*osg_DeltaFrameTime*partAcceleration*mass*100 + 10000.0*vec4(vVort.xyz,1.0)* 100.0 *timeMultiplier*osg_DeltaFrameTime;
117 | partPrevVelocity = partCurrVelocity;
118 | partCurrVelocity = tempCurrVelocity;
119 |
120 | tempCurrPos= partPrevPos + (timeMultiplier*osg_DeltaFrameTime * partCurrVelocity);
121 | partPrevPos = partCurrPos;
122 | partCurrPos = tempCurrPos;
123 |
124 | //memoryBarrierBuffer();
125 |
126 | particleDataBuffer[POSITION_NOW_OFFSET*OFFSET+(gidY*numCols + gidX)] = partCurrPos;
127 | particleDataBuffer[POSITION_OLD_OFFSET*OFFSET+(gidY*numCols + gidX)] = partPrevPos;
128 | particleDataBuffer[VELOCITY_NOW_OFFSET *OFFSET+(gidY*numCols + gidX)] = partCurrVelocity;
129 | particleDataBuffer[VELOCITY_NOW_OFFSET*OFFSET+(gidY*numCols + gidX)] = partPrevVelocity;
130 | particleDataBuffer[ACCELERATION_OFFSET*OFFSET+(gidY*numCols + gidX)] = partAcceleration;
131 | particleDataBuffer[PROPERTIES_OFFSET*OFFSET+(gidY*numCols + gidX)] = partProperties;
132 |
133 |
134 |
135 | #endif //end pause
136 | };
137 |
--------------------------------------------------------------------------------
/shaders/osgssboFragmentShader.fs:
--------------------------------------------------------------------------------
1 | uniform sampler2D particleTexture;
2 | in vec2 ex_TexCoor;in vec4 particlecolorGS;
3 |
4 |
5 | void main(void)
6 | {
7 | gl_FragColor = particlecolorGS*texture2D(particleTexture,ex_TexCoor.xy);
8 | }
9 |
--------------------------------------------------------------------------------
/shaders/osgssboGeometryShader.gs:
--------------------------------------------------------------------------------
1 | #version 430
2 | #extension GL_EXT_geometry_shader4 : enable
3 | layout(points) in;
4 | layout(triangle_strip, max_vertices = 4) out;
5 | uniform mat4 osg_ProjectionMatrix;
6 | uniform mat4 osg_ModelViewMatrix;
7 | out vec2 ex_TexCoor;in vec4 particlecolor[];
8 | in float particleradius[];
9 | out vec4 particlecolorGS;
10 | void main(void){
11 | vec4 particlePos = osg_ProjectionMatrix * osg_ModelViewMatrix *gl_PositionIn[0];
12 | float quadLength = particleradius[0] *0.025 ;
13 | particlecolorGS = particlecolor[0];gl_Position = particlePos;ex_TexCoor = vec2(0, 0);
14 | EmitVertex();
15 | gl_Position = particlePos; gl_Position.x += quadLength;
16 | ex_TexCoor = vec2(1, 0);
17 | EmitVertex();
18 |
19 | gl_Position = particlePos;gl_Position.y += quadLength * 2;
20 | ex_TexCoor = vec2(0, 1);
21 | EmitVertex();
22 | gl_Position = particlePos;
23 | gl_Position.y += quadLength * 2;
24 | gl_Position.x += quadLength;
25 | ex_TexCoor = vec2(1, 1);
26 | EmitVertex();
27 | EndPrimitive();
28 | }
29 |
--------------------------------------------------------------------------------
/shaders/osgssboVertexShader.vs:
--------------------------------------------------------------------------------
1 | #version 430
2 | uniform int numRows;
3 | uniform int numCols;
4 | uniform float osg_FrameTime;
5 | uniform float osg_DeltaFrameTime;
6 | uniform mat4 osg_ProjectionMatrix;
7 | uniform mat4 osg_ModelViewMatrix;
8 | out vec4 particlecolor;
9 | out float particleradius;
10 | attribute vec2 tex_coords;
11 |
12 | struct particle{ float x; float y; float z; float w;};
13 |
14 | layout(std140, binding=0) coherent buffer particles{particle p[];};
15 |
16 | void main() {
17 | ivec2 storePos = ivec2(numRows*tex_coords.x, numCols*tex_coords.y);
18 |
19 | particle partCurrPos = p[(storePos.x*numRows + storePos.y)];
20 | particle partProperties = p[7*(numRows*numCols)+(storePos.x*numRows + storePos.y)];
21 |
22 | #if 0 //color it somehow if hit
23 | float lastHitTime = partProperties.z;
24 | if( (osg_FrameTime-lastHitTime) < 0.5)
25 | {
26 | partProperties.w =10.0;
27 | }else
28 | {
29 | partProperties.w = 0.0;
30 | }
31 | particlecolor.rgb *= partProperties.w; particlecolor.a = 1.0; particleradius = partProperties.y;
32 | #else
33 | particlecolor.rgb = vec3(1,1,1); particlecolor.a = 1.0; particleradius = partProperties.y;
34 | #endif
35 |
36 |
37 | vec4 posFromBuffer = vec4(partCurrPos.x, partCurrPos.y, partCurrPos.z, 1.0);
38 | gl_Position = posFromBuffer;
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/shaders/osgtexture2DArray.frag:
--------------------------------------------------------------------------------
1 | #extension GL_EXT_texture_array : enable
2 |
3 | uniform sampler2DArray texture;
4 | varying vec3 texcoord;
5 |
6 |
7 | void main(void)
8 | {
9 | gl_FragColor = texture2DArray( texture, texcoord.xyz);
10 | }
11 |
--------------------------------------------------------------------------------
/shaders/osgtexture2DArray.vert:
--------------------------------------------------------------------------------
1 | varying vec3 texcoord;
2 | uniform float osg_SimulationTime;
3 |
4 | void main(void)
5 | {
6 | texcoord.xy = gl_MultiTexCoord0.xy;
7 | texcoord.z = mod(osg_SimulationTime,3.0);
8 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
9 | }
10 |
--------------------------------------------------------------------------------
/shaders/overlay_perspective_main.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D texture_0;
2 | uniform sampler2D texture_1;
3 |
4 | uniform float y0;
5 |
6 | vec2 warp(in vec2 source)
7 | {
8 | float inv_divisor = 1.0 / (source.y + y0);
9 | return vec2(source.x * (1.0 + y0 ) * inv_divisor , (source.y * y0 + 1.0 ) * inv_divisor);
10 | }
11 |
12 | void main()
13 | {
14 | vec2 coord = gl_TexCoord[1].xy;
15 | coord.x = coord.x*2.0 - 1.0;
16 | coord.y = coord.y*2.0 - 1.0;
17 |
18 | vec2 warped = warp(coord);
19 | warped.x = (warped.x + 1.0)*0.5;
20 | warped.y = (warped.y + 1.0)*0.5;
21 |
22 | vec4 base_color = texture2D(texture_0, gl_TexCoord[0].xy);
23 | vec4 overlay_color = texture2D(texture_1, warped );
24 | vec3 mixed_color = mix(base_color.rgb, overlay_color.rgb, overlay_color.a);
25 | gl_FragColor = vec4(mixed_color, base_color.a);
26 | }
27 |
--------------------------------------------------------------------------------
/shaders/overlay_perspective_rtt.vert:
--------------------------------------------------------------------------------
1 | uniform float y0;
2 | uniform bool lightingEnabled;
3 |
4 | vec4 warp(in vec4 source)
5 | {
6 | float divisor = source.y + y0;
7 | return vec4(source.x * (1.0 + y0 ), source.y * y0 + 1.0, (source.z * y0 + 1.0)*0.01, source.w * divisor);
8 | }
9 |
10 |
11 | vec3 fnormal(void)
12 | {
13 | //Compute the normal
14 | vec3 normal = gl_NormalMatrix * gl_Normal;
15 | normal = normalize(normal);
16 | return normal;
17 | }
18 |
19 | void directionalLight(in int i,
20 | in vec3 normal,
21 | inout vec4 ambient,
22 | inout vec4 diffuse,
23 | inout vec4 specular)
24 | {
25 | float nDotVP; // normal . light direction
26 | float nDotHV; // normal . light half vector
27 | float pf; // power factor
28 |
29 | nDotVP = max(0.0, dot(normal, normalize(vec3 (gl_LightSource[i].position))));
30 | nDotHV = max(0.0, dot(normal, vec3 (gl_LightSource[i].halfVector)));
31 |
32 | if (nDotVP == 0.0)
33 | {
34 | pf = 0.0;
35 | }
36 | else
37 | {
38 | pf = pow(nDotHV, gl_FrontMaterial.shininess);
39 |
40 | }
41 | ambient += gl_LightSource[i].ambient;
42 | diffuse += gl_LightSource[i].diffuse * nDotVP;
43 | specular += gl_LightSource[i].specular * pf;
44 | }
45 |
46 | void main()
47 | {
48 | gl_Position = warp(ftransform());
49 |
50 | if (lightingEnabled)
51 | {
52 | vec4 ambient = vec4(0.0);
53 | vec4 diffuse = vec4(0.0);
54 | vec4 specular = vec4(0.0);
55 |
56 |
57 | vec3 normal = fnormal();
58 |
59 | directionalLight(0, normal, ambient, diffuse, specular);
60 |
61 | vec4 color = gl_FrontLightModelProduct.sceneColor +
62 | ambient * gl_FrontMaterial.ambient +
63 | diffuse * gl_FrontMaterial.diffuse +
64 | specular * gl_FrontMaterial.specular;
65 |
66 | gl_FrontColor = color;
67 |
68 | }
69 | else
70 | {
71 | gl_FrontColor = gl_Color;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/shaders/pass1Shadow.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 | // Modified fragment shader from osgShadow::SoftShadowMap.
3 |
4 | /*
5 | // osgShadow::ShadowMap.
6 | uniform vec2 osgShadow_ambientBias;
7 | uniform sampler2DShadow osgShadow_shadowTexture;
8 |
9 | void main()
10 | {
11 | gl_FragColor =
12 | osgShadow_ambientBias.x +
13 | shadow2DProj(osgShadow_shadowTexture, gl_TexCoord[1]) * osgShadow_ambientBias.y;
14 | }
15 | */
16 |
17 | #define SAMPLECOUNT 64
18 | #define SAMPLECOUNT_FLOAT 64.0
19 | #define SAMPLECOUNT_D2 32
20 | #define SAMPLECOUNT_D2_FLOAT 32.0
21 | #define INV_SAMPLECOUNT (1.0 / SAMPLECOUNT_FLOAT)
22 |
23 | uniform sampler2DShadow osgShadow_shadowTexture;
24 | uniform sampler3D osgShadow_jitterTexture;
25 | uniform vec2 osgShadow_ambientBias;
26 | uniform float osgShadow_softnessWidth;
27 | uniform float osgShadow_jitteringScale;
28 |
29 | void main()
30 | {
31 | vec4 sceneShadowProj = gl_TexCoord[1];
32 | float softFactor = osgShadow_softnessWidth * sceneShadowProj.w;
33 | vec4 smCoord = sceneShadowProj;
34 | vec3 jitterCoord = vec3(gl_FragCoord.xy / osgShadow_jitteringScale, 0.0);
35 | float shadow = 0.0;
36 | // First "cheap" sample test
37 | const float pass_div = 1.0 / (2.0 * 4.0);
38 | for (int i = 0; i < 4; ++i)
39 | {
40 | // Get jitter values in [0,1]; adjust to have values in [-1,1]
41 | vec4 offset = 2.0 * texture3D(osgShadow_jitterTexture, jitterCoord) - 1.0;
42 | jitterCoord.z += 1.0 / SAMPLECOUNT_D2_FLOAT;
43 |
44 | smCoord.xy = sceneShadowProj.xy + offset.xy * softFactor;
45 | shadow += shadow2DProj(osgShadow_shadowTexture, smCoord).x * pass_div;
46 |
47 | smCoord.xy = sceneShadowProj.xy + offset.zw * softFactor;
48 | shadow += shadow2DProj(osgShadow_shadowTexture, smCoord).x * pass_div;
49 | }
50 | // skip all the expensive shadow sampling if not needed
51 | if (shadow * (shadow - 1.0) != 0.0)
52 | {
53 | shadow *= pass_div;
54 | for (int i = 0; i < SAMPLECOUNT_D2 - 4; ++i)
55 | {
56 | vec4 offset = 2.0 * texture3D(osgShadow_jitterTexture, jitterCoord) - 1.0;
57 | jitterCoord.z += 1.0 / SAMPLECOUNT_D2_FLOAT;
58 |
59 | smCoord.xy = sceneShadowProj.xy + offset.xy * softFactor;
60 | shadow += shadow2DProj(osgShadow_shadowTexture, smCoord).x * INV_SAMPLECOUNT;
61 |
62 | smCoord.xy = sceneShadowProj.xy + offset.zw * softFactor;
63 | shadow += shadow2DProj(osgShadow_shadowTexture, smCoord).x * INV_SAMPLECOUNT;
64 | }
65 | }
66 | // apply shadow, modulo the ambient bias
67 | gl_FragColor = vec4(osgShadow_ambientBias.x + shadow * osgShadow_ambientBias.y);
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/shaders/pass2.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 | uniform sampler2D diffMap;
3 | uniform sampler2D bumpMap;
4 |
5 | uniform int useBumpMap;
6 |
7 | varying vec3 pos_worldspace;
8 | varying vec3 n_worldspace;
9 | varying vec3 t_worldspace;
10 | varying vec3 b_worldspace;
11 |
12 | void main()
13 | {
14 | gl_FragData[0] = vec4(pos_worldspace, gl_FragCoord.z);
15 | vec3 nn = vec3(1.0);
16 | if (useBumpMap > 0)
17 | // Convert [0; 1] range to [-1; 1].
18 | nn = 2.0 * texture2D(bumpMap, gl_TexCoord[0].xy).xyz - vec3(1.0);
19 | // Convert Tangent space to World space with TBN matrix.
20 | gl_FragData[1] = vec4(nn.x * t_worldspace + nn.y * b_worldspace + nn.z * n_worldspace, 1.0);
21 | gl_FragData[2] = texture2D(diffMap, gl_TexCoord[0].xy);
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/shaders/pass2.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 | uniform mat4 osg_ViewMatrixInverse;
3 |
4 | varying vec3 pos_worldspace;
5 | varying vec3 n_worldspace;
6 | varying vec3 t_worldspace;
7 | varying vec3 b_worldspace;
8 |
9 | void main()
10 | {
11 | // Model space * Model matrix = World space
12 | // World space * View matrix = Camera (eye) space
13 | // Camera (eye) space * Projection matrix = Screen space
14 | // We simply translate vertex from Model space to Screen space.
15 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
16 | // Pass the texture coordinate further to the fragment shader.
17 | gl_TexCoord[0] = gl_MultiTexCoord0;
18 | // gl_ModelViewMatrix, gl_NormalMatrix, etc. are in Camera(eye) space
19 | // Discussion: http://forum.openscenegraph.org/viewtopic.php?p=44257#44257
20 | // Camera (eye) space * inverse View matrix = World space
21 | mat4 modelMatrix = osg_ViewMatrixInverse * gl_ModelViewMatrix;
22 | mat3 modelMatrix3x3 = mat3(modelMatrix);
23 | // Convert everything to World space.
24 | // Position.
25 | pos_worldspace = (modelMatrix * gl_Vertex).xyz;
26 | // Normal.
27 | n_worldspace = modelMatrix3x3 * gl_Normal;
28 | // Tangent.
29 | t_worldspace = modelMatrix3x3 * gl_MultiTexCoord1.xyz;
30 | // Bitangent / binormal.
31 | b_worldspace = cross(n_worldspace, t_worldspace);
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/shaders/pass3.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 | uniform mat4 osg_ViewMatrixInverse;
3 | uniform vec3 lightPos;
4 | uniform sampler2DRect posMap;
5 | uniform sampler2DRect normalMap;
6 | uniform sampler2DRect colorMap;
7 | uniform sampler2DRect shadowMap;
8 |
9 | void main()
10 | {
11 | vec3 p_worldspace = texture2DRect(posMap, gl_FragCoord.xy).xyz;
12 | vec3 n_worldspace = texture2DRect(normalMap, gl_FragCoord.xy).xyz;
13 | vec3 c_worldspace = texture2DRect(colorMap, gl_FragCoord.xy).xyz;
14 | vec3 s_worldspace = texture2DRect(shadowMap, gl_FragCoord.xy).xyz;
15 | // Direction from point to light (not vice versa!)
16 | vec3 lightDir_worldspace = normalize(lightPos - p_worldspace);
17 | // Lambertian diffuse color.
18 | float diff = max(0.2, dot(lightDir_worldspace, n_worldspace));
19 | // Convert camera position from Camera (eye) space (it's always at 0, 0, 0
20 | // in there) to World space. Don't forget to use mat4 and vec4!
21 | vec4 cameraPos_worldspace = osg_ViewMatrixInverse * vec4(0, 0, 0, 1);
22 | // Direction from point to camera.
23 | vec3 viewDir_worldspace = normalize(vec3(cameraPos_worldspace) - p_worldspace);
24 | // Blinn-Phong specular highlights.
25 | vec3 h_worldspace = normalize(lightDir_worldspace + viewDir_worldspace);
26 | float spec = pow(max(0.0, dot(h_worldspace, n_worldspace)), 40.0);
27 | // Final fragment color.
28 | vec3 color = diff * c_worldspace * s_worldspace;
29 | // Only add specular if the fragment is NOT in the shadow.
30 | if (s_worldspace.x == 1)
31 | color += spec;
32 | gl_FragColor = vec4(color, 1.0);
33 | }
34 |
--------------------------------------------------------------------------------
/shaders/pass3.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 | void main()
3 | {
4 | // Vertex position in main camera Screen space.
5 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/shaders/point_rain.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D baseTexture;
2 | varying vec4 colour;
3 |
4 | void main (void)
5 | {
6 | gl_FragColor = colour * texture2D( baseTexture, gl_TexCoord[0].xy);
7 | }
8 |
--------------------------------------------------------------------------------
/shaders/point_rain.vert:
--------------------------------------------------------------------------------
1 | uniform float inversePeriod;
2 | uniform vec4 particleColour;
3 | uniform float particleSize;
4 |
5 | uniform float osg_SimulationTime;
6 |
7 | varying vec4 colour;
8 |
9 | void main(void)
10 | {
11 | float offset = gl_Vertex.z;
12 | float startTime = gl_MultiTexCoord1.x;
13 |
14 | vec4 v_current = gl_Vertex;
15 | v_current.z = fract( (osg_SimulationTime - startTime)*inversePeriod - offset);
16 |
17 | colour = particleColour;
18 |
19 | gl_Position = gl_ModelViewProjectionMatrix * v_current;
20 |
21 | float pointSize = abs(1280.0*particleSize / gl_Position.w);
22 |
23 | //gl_PointSize = max(ceil(pointSize),2);
24 | gl_PointSize = ceil(pointSize);
25 |
26 | colour.a = 0.05+(pointSize*pointSize)/(gl_PointSize*gl_PointSize);
27 | }
28 |
--------------------------------------------------------------------------------
/shaders/quad_rain.vert:
--------------------------------------------------------------------------------
1 | uniform float inversePeriod;
2 | uniform vec4 particleColour;
3 | uniform float particleSize;
4 |
5 | uniform float osg_SimulationTime;
6 | uniform float osg_DeltaSimulationTime;
7 |
8 | varying vec4 colour;
9 | varying vec2 texCoord;
10 |
11 | void main(void)
12 | {
13 | float offset = gl_Vertex.z;
14 | float startTime = gl_MultiTexCoord1.x;
15 | texCoord = gl_MultiTexCoord0.xy;
16 |
17 | vec4 v_previous = gl_Vertex;
18 | v_previous.z = fract( (osg_SimulationTime - startTime)*inversePeriod - offset);
19 |
20 | vec4 v_current = v_previous;
21 | v_current.z += (osg_DeltaSimulationTime*inversePeriod);
22 |
23 |
24 | colour = particleColour;
25 |
26 | vec4 v1 = gl_ModelViewMatrix * v_current;
27 | vec4 v2 = gl_TextureMatrix[0] * v_previous;
28 |
29 | vec3 dv = v2.xyz - v1.xyz;
30 |
31 | vec2 dv_normalized = normalize(dv.xy);
32 | dv.xy += dv_normalized * particleSize;
33 | vec2 dp = vec2( -dv_normalized.y, dv_normalized.x ) * particleSize;
34 |
35 | float area = length(dv.xy);
36 | colour.a = 0.05+(particleSize)/area;
37 |
38 |
39 | v1.xyz += dv*texCoord.y;
40 | v1.xy += dp*texCoord.x;
41 |
42 | gl_Position = gl_ProjectionMatrix * v1;
43 | }
44 |
--------------------------------------------------------------------------------
/shaders/rain.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D baseTexture;
2 | varying vec2 texCoord;
3 | varying vec4 colour;
4 |
5 | void main (void)
6 | {
7 | gl_FragColor = colour * texture2D( baseTexture, texCoord);
8 | }
9 |
--------------------------------------------------------------------------------
/shaders/rain.vert:
--------------------------------------------------------------------------------
1 | uniform vec3 position;
2 | uniform vec3 dv_i;
3 | uniform vec3 dv_j;
4 | uniform vec3 dv_k;
5 |
6 | uniform float inversePeriod;
7 | uniform float startTime;
8 | uniform vec4 particleColour;
9 |
10 | uniform float osg_SimulationTime;
11 | uniform float osg_DeltaSimulationTime;
12 | uniform mat4 previousModelViewMatrix;
13 |
14 | varying vec4 colour;
15 | varying vec2 texCoord;
16 |
17 | void main(void)
18 | {
19 | const float particleSize = 0.01;
20 | const float particleSize2 = 0.0001;//particleSize*particleSize;
21 |
22 | vec3 pos = position + (gl_Vertex.x*dv_i) + (dv_j * gl_Vertex.y);
23 |
24 | float offset = gl_Vertex.z;
25 | texCoord = gl_MultiTexCoord0.xy;
26 |
27 | vec3 v_previous = pos + dv_k * fract( (osg_SimulationTime - startTime)*inversePeriod - offset);
28 | vec3 v_current = v_previous + dv_k * (osg_DeltaSimulationTime*inversePeriod);
29 |
30 | colour = particleColour;
31 |
32 | vec4 v1 = gl_ModelViewMatrix * vec4(v_current,1.0);
33 | vec4 v2 = previousModelViewMatrix * vec4(v_previous,1.0);
34 |
35 | vec3 dv = v2.xyz - v1.xyz;
36 |
37 | vec2 dv_normalized = normalize(dv.xy);
38 | dv.xy += dv_normalized * particleSize;
39 | vec2 dp = vec2( -dv_normalized.y, dv_normalized.x ) * particleSize;
40 |
41 | float area = length(dv.xy)*length(dp);
42 | colour.a = 0.2+(particleSize2)/area;
43 |
44 |
45 | v1.xyz += dv*texCoord.y;
46 | v1.xy += dp*texCoord.x;
47 |
48 | gl_Position = gl_ProjectionMatrix * v1;
49 | }
50 |
--------------------------------------------------------------------------------
/shaders/screen.frag:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // screen.frag: Fragment shader for testing the "discard" command
4 | // an example of an OpenGL Shading Language source file.
5 | //
6 | // author: Randi Rost
7 | //
8 | // Copyright (c) 2002: 3Dlabs, Inc.
9 | //
10 |
11 | // This file derived from the ogl2demo example in the 3Dlabs OpenGL2 SDK
12 | // available from http://www.3dlabs.com/opengl2/
13 | // Mike Weiblen 2003-07-14 : til osgGL2 implements the setting of uniforms,
14 | // temporarily use consts instead.
15 |
16 | varying vec3 Position;
17 | varying float lightIntensity;
18 |
19 | void main (void)
20 | {
21 | vec3 ct;
22 | float ss, tt;
23 |
24 | vec3 pos = Position;
25 |
26 | ss = pos.x * 5.1;
27 | tt = pos.z * 5.1;
28 |
29 | ss = fract (ss);
30 | tt = fract (tt);
31 |
32 | if ((ss > 0.13) && (tt > 0.13)) discard;
33 |
34 | ct = vec3 (0.9, 0.7, 0.25) * lightIntensity * 1.5;
35 | ct = clamp(ct, 0.0, 1.0);
36 |
37 | gl_FragColor = vec4 (ct, 1.0);
38 | }
39 |
--------------------------------------------------------------------------------
/shaders/screen.vert:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // screen.vert: Vertex shader for testing the "discard" command
4 | // in a fragment shader
5 | // an example of an OpenGL Shading Language source file.
6 | //
7 | // author: Randi Rost
8 | //
9 | // Copyright (c) 2002: 3Dlabs, Inc.
10 | //
11 |
12 | // This file derived from the ogl2demo example in the 3Dlabs OpenGL2 SDK
13 | // available from http://www.3dlabs.com/opengl2/
14 | // Mike Weiblen 2003-07-14 : til osgGL2 implements the setting of uniforms,
15 | // temporarily use consts instead.
16 |
17 | // uniform vec3 LightPosition;
18 | const vec3 LightPosition = vec3(0.0, 0.0, 4.0);
19 |
20 | const float Scale = 2.1;
21 |
22 | varying float lightIntensity;
23 | varying vec3 Position;
24 |
25 | const float specularContribution = 0.5;
26 | const float diffuseContribution = (1.0 - specularContribution);
27 |
28 | void main(void) {
29 | vec4 pos = gl_ModelViewMatrix * gl_Vertex;
30 | Position = gl_Vertex.xyz * Scale;
31 | vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
32 | vec3 lightVec = normalize(LightPosition - vec3(pos));
33 | vec3 reflectVec = reflect(lightVec, tnorm);
34 | vec3 viewVec = normalize(vec3(pos));
35 | float dotval = abs(dot(lightVec, tnorm));
36 |
37 | float spec = pow(dot(reflectVec, viewVec), 8.0);
38 |
39 | lightIntensity = diffuseContribution * dotval +
40 | specularContribution * spec;
41 |
42 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/shaders/shader.vert:
--------------------------------------------------------------------------------
1 | varying vec4 color;
2 | void main(void)
3 | {
4 | color = gl_Vertex;
5 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
6 | }
7 |
--------------------------------------------------------------------------------
/shaders/shadergen.frag:
--------------------------------------------------------------------------------
1 | // ShaderGen shader
2 | // new version
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | #pragma import_defines(GL_TEXTURE_2D)
8 |
9 | varying vec4 vertexColor;
10 |
11 | #if defined(GL_TEXTURE_2D)
12 | uniform sampler2D diffuseMap;
13 | #endif
14 |
15 | void main()
16 | {
17 | vec4 color = vertexColor;
18 |
19 | #if defined(GL_TEXTURE_2D)
20 | color = color * texture2D(diffuseMap, gl_TexCoord[0].st);
21 | #endif
22 |
23 | gl_FragColor = color;
24 | }
25 |
--------------------------------------------------------------------------------
/shaders/shadergen.vert:
--------------------------------------------------------------------------------
1 | // ShaderGen shader
2 | // new version
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | #pragma import_defines(GL_LIGHTING, GL_TEXTURE_2D)
8 |
9 |
10 | #ifdef GL_LIGHTING
11 | void directionalLight( int lightNum, vec3 normal, inout vec4 color )
12 | {
13 | vec3 n = normalize(gl_NormalMatrix * normal);
14 |
15 | float NdotL = dot( n, normalize(gl_LightSource[lightNum].position.xyz) );
16 | NdotL = max( 0.0, NdotL );
17 |
18 | float NdotHV = dot( n, gl_LightSource[lightNum].halfVector.xyz );
19 | NdotHV = max( 0.0, NdotHV );
20 |
21 | color *= gl_FrontLightModelProduct.sceneColor +
22 | gl_FrontLightProduct[lightNum].ambient +
23 | gl_FrontLightProduct[lightNum].diffuse * NdotL;
24 |
25 | if ( NdotL * NdotHV > 0.0 )
26 | color += gl_FrontLightProduct[lightNum].specular * pow( NdotHV, gl_FrontMaterial.shininess );
27 | }
28 | #endif
29 |
30 | varying vec4 vertexColor;
31 |
32 | void main()
33 | {
34 | gl_Position = ftransform();
35 |
36 | #if defined(GL_TEXTURE_2D)
37 | gl_TexCoord[0] = gl_MultiTexCoord0;
38 | #endif
39 |
40 | vertexColor = gl_Color;
41 |
42 | #if defined(GL_LIGHTING)
43 | directionalLight(0, gl_Normal, vertexColor);
44 | #endif
45 | }
46 |
--------------------------------------------------------------------------------
/shaders/shaderpipeline.frag:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision highp float;
3 | #endif
4 |
5 | #pragma import_modes ( GL_LIGHTING )
6 | #pragma import_defines ( GL_MAX_TEXTURE_UNITS, GL_ALPHA )
7 |
8 | #pragma import_defines ( TEXTURE_FRAG_DECLARE0, TEXTURE_FUNCTION0, TEXTURE_ENV_FUNCTION0 )
9 | #pragma import_defines ( TEXTURE_FRAG_DECLARE1, TEXTURE_FUNCTION1, TEXTURE_ENV_FUNCTION1 )
10 | #pragma import_defines ( TEXTURE_FRAG_DECLARE2, TEXTURE_FUNCTION2, TEXTURE_ENV_FUNCTION2 )
11 | #pragma import_defines ( TEXTURE_FRAG_DECLARE3, TEXTURE_FUNCTION3, TEXTURE_ENV_FUNCTION3 )
12 |
13 | #if GL_MAX_TEXTURE_UNITS>0
14 |
15 | uniform int osg_TextureFormat[GL_MAX_TEXTURE_UNITS];
16 | uniform vec4 osg_TextureEnvColor[GL_MAX_TEXTURE_UNITS];
17 |
18 | vec4 texenv_MODULATE(vec4 color, vec4 texture_color, int unit) { return (osg_TextureFormat[unit]==GL_ALPHA) ? vec4(color.r, color.g, color.b, color.a*texture_color.a) : color*texture_color; }
19 | vec4 texenv_REPLACE(vec4 color, vec4 texture_color, int unit) { return (osg_TextureFormat[unit]==GL_ALPHA) ? vec4(color.r, color.g, color.b, texture_color.a) : texture_color; }
20 | vec4 texenv_DECAL(vec4 color, vec4 texture_color, int unit) { color.rgb = color.rgb * (1.0-texture_color.a) + texture_color.rgb*texture_color.a; return color; }
21 | vec4 texenv_ADD(vec4 color, vec4 texture_color, int unit) { color.rgb = color.rgb + texture_color.rgb; color.a = color.a*texture_color.a; return color; }
22 | vec4 texenv_BLEND(vec4 color, vec4 texture_color, int unit) { color.rgb = color.rgb * (vec3(1.0,1.0,1.0)-texture_color.rgb) + texture_color.rgb * osg_TextureEnvColor[unit].rgb; return color; }
23 |
24 | #ifdef TEXTURE_FRAG_DECLARE0
25 | TEXTURE_FRAG_DECLARE0
26 | #endif
27 |
28 | #ifdef TEXTURE_FRAG_DECLARE1
29 | TEXTURE_FRAG_DECLARE1
30 | #endif
31 |
32 | #ifdef TEXTURE_FRAG_DECLARE2
33 | TEXTURE_FRAG_DECLARE2
34 | #endif
35 |
36 | #ifdef TEXTURE_FRAG_DECLARE3
37 | TEXTURE_FRAG_DECLARE3
38 | #endif
39 |
40 | #endif
41 |
42 |
43 | varying vec4 vertex_color;
44 |
45 | void main()
46 | {
47 | vec4 frag_color = vertex_color;
48 |
49 | #if GL_MAX_TEXTURE_UNITS>0
50 | #ifdef TEXTURE_FUNCTION0
51 | #ifdef TEXTURE_ENV_FUNCTION0
52 | frag_color = TEXTURE_ENV_FUNCTION0(frag_color, TEXTURE_FUNCTION0(), 0);
53 | #else
54 | frag_color = TEXTURE_FUNCTION0();
55 | #endif
56 | #endif
57 |
58 | #ifdef TEXTURE_FUNCTION1
59 | #ifdef TEXTURE_ENV_FUNCTION1
60 | frag_color = TEXTURE_ENV_FUNCTION1(frag_color, TEXTURE_FUNCTION1(), 1);
61 | #else
62 | frag_color = TEXTURE_FUNCTION1();
63 | #endif
64 | #endif
65 |
66 | #ifdef TEXTURE_FUNCTION2
67 | #ifdef TEXTURE_ENV_FUNCTION2
68 | frag_color = TEXTURE_ENV_FUNCTION2(frag_color, TEXTURE_FUNCTION2(), 2);
69 | #else
70 | frag_color = TEXTURE_FUNCTION2();
71 | #endif
72 | #endif
73 |
74 | #ifdef TEXTURE_FUNCTION3
75 | #ifdef TEXTURE_ENV_FUNCTION3
76 | frag_color = TEXTURE_ENV_FUNCTION3(frag_color, TEXTURE_FUNCTION3(), 3);
77 | #else
78 | frag_color = TEXTURE_FUNCTION3();
79 | #endif
80 | #endif
81 |
82 | #endif
83 |
84 | gl_FragColor = frag_color;
85 | }
86 |
87 |
--------------------------------------------------------------------------------
/shaders/skinning.vert:
--------------------------------------------------------------------------------
1 | /* -*-c++-*-
2 | * Copyright (C) 2008 Cedric Pinson
3 | *
4 | * This library is open source and may be redistributed and/or modified under
5 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 | * (at your option) any later version. The full license is in LICENSE file
7 | * included with this distribution, and on the openscenegraph.org website.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * OpenSceneGraph Public License for more details.
13 | */
14 |
15 | in vec4 boneWeight0;
16 | in vec4 boneWeight1;
17 | in vec4 boneWeight2;
18 | in vec4 boneWeight3;
19 |
20 | uniform uint nbBonesPerVertex;
21 | uniform mat4 matrixPalette[MAX_MATRIX];
22 |
23 | vec4 position;
24 | vec3 normal;
25 |
26 |
27 | // accumulate position and normal in global scope
28 | void computeAcummulatedNormalAndPosition(vec4 boneWeight)
29 | {
30 | int matrixIndex;
31 | float matrixWeight;
32 | for (int i = 0; i < 2; i++)
33 | {
34 | matrixIndex = int(boneWeight[0]);
35 | matrixWeight = boneWeight[1];
36 | mat4 matrix = matrixPalette[matrixIndex];
37 | // correct for normal if no scale in bone
38 | mat3 matrixNormal = mat3(matrix);
39 | position += matrixWeight * (matrix * gl_Vertex );
40 | normal += matrixWeight * (matrixNormal * gl_Normal );
41 |
42 | boneWeight = boneWeight.zwxy;
43 | }
44 | }
45 |
46 | void main( void )
47 | {
48 | position = vec4(0.0,0.0,0.0,0.0);
49 | normal = vec3(0.0,0.0,0.0);
50 | gl_TexCoord[0] = gl_MultiTexCoord0;
51 | // there is 2 bone data per attributes
52 | if (nbBonesPerVertex > 0u)
53 | computeAcummulatedNormalAndPosition(boneWeight0);
54 | if (nbBonesPerVertex > 2u)
55 | computeAcummulatedNormalAndPosition(boneWeight1);
56 | if (nbBonesPerVertex > 4u)
57 | computeAcummulatedNormalAndPosition(boneWeight2);
58 | if (nbBonesPerVertex > 6u)
59 | computeAcummulatedNormalAndPosition(boneWeight3);
60 |
61 | normal = gl_NormalMatrix * normal;
62 |
63 | vec3 lightDir = normalize(vec3(gl_LightSource[0].position));
64 | float NdotL = max(dot(normal, lightDir), 0.0);
65 | vec4 diffuse = NdotL * gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
66 |
67 | vec4 ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
68 | vec4 globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient;
69 |
70 | float NdotHV = max(dot(normal, gl_LightSource[0].halfVector.xyz),0.0);
71 | vec4 specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(NdotHV,gl_FrontMaterial.shininess);
72 |
73 | gl_FrontColor = specular + diffuse + globalAmbient + ambient;
74 | gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * position;
75 | }
76 |
--------------------------------------------------------------------------------
/shaders/stereomatch_aggregate.frag:
--------------------------------------------------------------------------------
1 | /* -*- Mode: C -*- */
2 | uniform sampler2DRect textureDiff0;
3 | uniform sampler2DRect textureDiff1;
4 | uniform sampler2DRect textureDiff2;
5 | uniform sampler2DRect textureDiff3;
6 | uniform sampler2DRect textureAggIn;
7 | uniform int start_disparity;
8 | uniform int window_size;
9 |
10 | void main(void)
11 | {
12 | int half_window_size = window_size/2;
13 |
14 | vec2 texCoord = gl_TexCoord[0].xy;
15 | sampler2DRect tdiff[4];
16 | tdiff[0] = textureDiff0;
17 | tdiff[1] = textureDiff1;
18 | tdiff[2] = textureDiff2;
19 | tdiff[3] = textureDiff3;
20 |
21 | float smallest_sum = 100;
22 | float sum;
23 | float disparity = 0;
24 |
25 | for (int t=0; t<4; t++) { // four textures
26 | for (int c=0; c<4; c++) { // four channels
27 | sum = 0.0;
28 | for (int y=-half_window_size; y<=half_window_size; y++) {
29 | for (int x=-half_window_size; x<=half_window_size; x++) {
30 | vec2 coord = texCoord + vec2(x,y);
31 | vec4 val = texture2DRect(tdiff[t], coord)[c];
32 | sum+=val;
33 | }
34 | }
35 | if (sum < smallest_sum) {
36 | smallest_sum = sum;
37 | disparity = start_disparity + ((t*4)+c);
38 | }
39 | }
40 | }
41 |
42 | float old_best_sum = texture2DRect(textureAggIn, texCoord)[0];
43 | float old_disparity = texture2DRect(textureAggIn, texCoord)[1];
44 | if (smallest_sum < old_best_sum) {
45 | gl_FragData[0][0] = smallest_sum;
46 | gl_FragData[0][1] = disparity;
47 | } else {
48 | gl_FragData[0][0] = old_best_sum;
49 | gl_FragData[0][1] = old_disparity;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/shaders/stereomatch_clear.frag:
--------------------------------------------------------------------------------
1 | /* -*- Mode: C -*- */
2 | void main(void)
3 | {
4 | gl_FragData[0] = vec4(100.0, 0.0, 0.0, 1.0);
5 | gl_FragData[1] = vec4(100.0, 0.0, 0.0, 1.0);
6 | }
7 |
--------------------------------------------------------------------------------
/shaders/stereomatch_select.frag:
--------------------------------------------------------------------------------
1 | /* -*- Mode: C -*- */
2 | uniform sampler2DRect textureIn;
3 | uniform int min_disparity;
4 | uniform int max_disparity;
5 |
6 | void main(void)
7 | {
8 | float disp = texture2DRect( textureIn, gl_TexCoord[0].st ).g;
9 | float sad = texture2DRect( textureIn, gl_TexCoord[0].st ).r;
10 | if (sad > 0.7+100) {
11 | gl_FragColor = vec4(1,0,0,1);
12 | } else {
13 | disp = (disp-min_disparity)/(float)(max_disparity-min_disparity);
14 | gl_FragColor = vec4(disp,disp,disp,1);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/shaders/stereomatch_stereopass.frag:
--------------------------------------------------------------------------------
1 | /* -*- Mode: C -*- */
2 | uniform sampler2DRect textureID0;
3 | uniform sampler2DRect textureID1;
4 | uniform int min_disparity;
5 | uniform int max_disparity;
6 | uniform int window_size;
7 |
8 | float SADWindow(in int disparity, in int half_window_size, in vec2 texCoord)
9 | {
10 | float sad = 0.0;
11 |
12 | float gain = 1.0;
13 | float offset = 0.0;
14 |
15 | for (int y=-half_window_size; y<=half_window_size; y++) {
16 | float ygo = (y*gain)+(sign(y)*offset);
17 | for (int x=-half_window_size; x<=half_window_size; x++) {
18 | float xgo = (x*gain)+(sign(x)*offset);
19 | vec2 l_coord = texCoord + vec2(xgo, ygo);
20 | vec2 r_coord = texCoord + vec2(xgo-disparity, ygo);
21 | vec4 l_val = texture2DRect(textureID0, l_coord);
22 | vec4 r_val = texture2DRect(textureID1, r_coord);
23 | sad = sad + abs(l_val - r_val);
24 | }
25 | }
26 | return sad;
27 | }
28 |
29 | void main(void)
30 | {
31 | float sad=100;
32 |
33 | float disp = min_disparity;
34 |
35 | int halfsz = window_size/2;
36 |
37 | for (int i=min_disparity; i < max_disparity; i++) {
38 | float temp_sad = SADWindow(i, halfsz, gl_TexCoord[0].xy);
39 | if (temp_sad < sad) {
40 | sad = temp_sad;
41 | disp = i;
42 | }
43 | }
44 |
45 | if (sad > 2.3+100) {
46 | gl_FragColor = vec4(1,0,0,1);
47 | } else {
48 | gl_FragColor = (disp-min_disparity)/(float)(max_disparity-min_disparity);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/shaders/stereomatch_subtract.frag:
--------------------------------------------------------------------------------
1 | /* -*- Mode: C -*- */
2 | uniform sampler2DRect textureLeft;
3 | uniform sampler2DRect textureRight;
4 | uniform int start_disparity;
5 |
6 | void main(void)
7 | {
8 | vec2 texCoord = gl_TexCoord[0].xy;
9 | vec4 final;
10 |
11 | vec4 im0 = texture2DRect(textureLeft, texCoord);
12 |
13 | for (int t=0; t<4; t++) {
14 | for (int c=0; c<4; c++) {
15 | int disp_offset = (t*4)+c;
16 | vec4 im1 = texture2DRect(textureRight, texCoord + vec2(-(disp_offset+start_disparity),0));
17 | gl_FragData[t][c] = abs(im0 - im1);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/shaders/terrain_displacement_mapping.frag:
--------------------------------------------------------------------------------
1 | #pragma import_defines ( TEXTURE_2D, TEXTURE_WEIGHTS, COLOR_LAYER0, COLOR_LAYER1, COLOR_LAYER2)
2 |
3 |
4 | #if defined(TEXTURE_2D) && defined(COLOR_LAYER0)
5 | uniform sampler2D colorTexture0;
6 | #endif
7 |
8 | #if defined(TEXTURE_2D) && defined(COLOR_LAYER1)
9 | uniform sampler2D colorTexture1;
10 | #endif
11 |
12 | #if defined(TEXTURE_2D) && defined(COLOR_LAYER2)
13 | uniform sampler2D colorTexture2;
14 | #endif
15 |
16 |
17 | #if defined(TEXTURE_2D) && defined(TEXTURE_WEIGHTS)
18 | uniform float TextureWeights[];
19 | #define WEIGHTS_LOOKUP(i) TextureWeights[i]
20 | #else
21 | #define WEIGHTS_LOOKUP(i) 1.0
22 | #endif
23 |
24 | varying vec2 texcoord;
25 | varying vec4 basecolor;
26 |
27 | void main(void)
28 | {
29 | #ifdef TEXTURE_2D
30 | vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
31 |
32 | #ifdef COLOR_LAYER0
33 | color = color + texture2D( colorTexture0, texcoord)*WEIGHTS_LOOKUP(0);
34 | #endif
35 |
36 | #ifdef COLOR_LAYER1
37 | color = color + texture2D( colorTexture1, texcoord)*WEIGHTS_LOOKUP(1);
38 | #endif
39 |
40 | #ifdef COLOR_LAYER2
41 | color = color + texture2D( colorTexture2, texcoord)*WEIGHTS_LOOKUP(2);
42 | #endif
43 |
44 | gl_FragColor = basecolor * color;
45 | #else
46 | gl_FragColor = basecolor;
47 | #endif
48 | }
49 |
--------------------------------------------------------------------------------
/shaders/terrain_displacement_mapping.geom:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | #pragma requires(COMPUTE_DIAGONALS)
4 |
5 | #extension GL_EXT_geometry_shader4 : enable
6 |
7 | varying in vec3 normals_in[4];
8 | varying in vec2 texcoord_in[4];
9 | varying in vec4 basecolor_in[4];
10 |
11 | varying out vec2 texcoord;
12 | varying out vec4 basecolor;
13 |
14 | void main(void)
15 | {
16 | float delta_02 = dot(normals_in[2],normals_in[0]);
17 | float delta_13 = dot(normals_in[3],normals_in[1]);
18 |
19 | if (delta_02>delta_13)
20 | {
21 | gl_Position = gl_PositionIn[3]; texcoord = texcoord_in[3]; basecolor = basecolor_in[3]; EmitVertex();
22 | gl_Position = gl_PositionIn[2]; texcoord = texcoord_in[2]; basecolor = basecolor_in[2]; EmitVertex();
23 | gl_Position = gl_PositionIn[0]; texcoord = texcoord_in[0]; basecolor = basecolor_in[0]; EmitVertex();
24 | gl_Position = gl_PositionIn[1]; texcoord = texcoord_in[1]; basecolor = basecolor_in[1]; EmitVertex();
25 | EndPrimitive();
26 | }
27 | else
28 | {
29 | gl_Position = gl_PositionIn[0]; texcoord = texcoord_in[0]; basecolor = basecolor_in[0]; EmitVertex();
30 | gl_Position = gl_PositionIn[3]; texcoord = texcoord_in[3]; basecolor = basecolor_in[3]; EmitVertex();
31 | gl_Position = gl_PositionIn[1]; texcoord = texcoord_in[1]; basecolor = basecolor_in[1]; EmitVertex();
32 | gl_Position = gl_PositionIn[2]; texcoord = texcoord_in[2]; basecolor = basecolor_in[2]; EmitVertex();
33 | EndPrimitive();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/shaders/terrain_displacement_mapping.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | #pragma import_defines ( HEIGHTFIELD_LAYER, COMPUTE_DIAGONALS, LIGHTING )
4 |
5 | #ifdef COMPUTE_DIAGONALS
6 | #extension GL_EXT_geometry_shader4 : enable
7 | #endif
8 |
9 | #ifdef HEIGHTFIELD_LAYER
10 | uniform sampler2D terrainTexture;
11 | #endif
12 |
13 | #ifdef COMPUTE_DIAGONALS
14 | varying vec2 texcoord_in;
15 | varying vec3 normals_in;
16 | varying vec4 basecolor_in;
17 | #else
18 | varying vec2 texcoord;
19 | varying vec4 basecolor;
20 | #endif
21 |
22 |
23 | #ifdef LIGHTING
24 | // forward declare lighting computation, provided by lighting.vert shader
25 | void directionalLight( int lightNum, vec3 normal, inout vec4 color );
26 | #endif
27 |
28 | void main(void)
29 | {
30 | vec2 texcoord_center = gl_MultiTexCoord0.xy;
31 |
32 | #ifdef HEIGHTFIELD_LAYER
33 | float height_center = texture2D(terrainTexture, texcoord_center).r;
34 | #else
35 | float height_center = 0.0;
36 | #endif
37 |
38 | #if defined(LIGHTING) && defined(HEIGHTFIELD_LAYER)
39 | vec2 texelWorldRatio = gl_MultiTexCoord0.zw;
40 | vec2 texelTexcoordSize = gl_Color.xy;
41 |
42 | vec2 texcoord_right = vec2(texcoord_center.x+texelTexcoordSize.x, texcoord_center.y);
43 | vec2 texcoord_left = vec2(texcoord_center.x-texelTexcoordSize.x, texcoord_center.y);
44 | vec2 texcoord_up = vec2(texcoord_center.x, texcoord_center.y+texelTexcoordSize.y);
45 | vec2 texcoord_down = vec2(texcoord_center.x, texcoord_center.y-texelTexcoordSize.y);
46 |
47 | float dz_dx = 0.0;
48 | float dx = 0.0;
49 | if (texcoord_left.x>=0.0)
50 | {
51 | float height = texture2D(terrainTexture, texcoord_left).r;
52 | dz_dx += (height_center-height)*texelWorldRatio.x;
53 | dx += 1.0;
54 | }
55 |
56 | if (texcoord_right.x<=1.0)
57 | {
58 | float height = texture2D(terrainTexture, texcoord_right).r;
59 | dz_dx += (height-height_center)*texelWorldRatio.x;
60 | dx += 1.0;
61 | }
62 |
63 | //dz_dx = 0.0;
64 |
65 | float dx_denominator = 1.0 / sqrt(dx*dx + dz_dx*dz_dx);
66 | float sin_rx = -dz_dx * dx_denominator;
67 | float cos_rx = 1.0 / (dx * dx_denominator);
68 |
69 | mat3 rotate_x_mat = mat3(cos_rx, 0.0, -sin_rx,
70 | 0.0, 1.0, 0.0,
71 | sin_rx, 0.0, cos_rx);
72 |
73 |
74 | float dz_dy = 0.0;
75 | float dy = 0.0;
76 | if (texcoord_down.y>=0.0)
77 | {
78 | float height = texture2D(terrainTexture, texcoord_down).r;
79 | dz_dy += (height_center-height)*texelWorldRatio.y;
80 | dy += 1.0;
81 | }
82 |
83 | if (texcoord_up.y<=1.0)
84 | {
85 | float height = texture2D(terrainTexture, texcoord_up).r;
86 | dz_dy += (height-height_center)*texelWorldRatio.y;
87 | dy += 1.0;
88 | }
89 |
90 | //dz_dy = 0.0;
91 |
92 | float dy_denominator = 1.0 / sqrt(dy*dy + dz_dy*dz_dy);
93 | float sin_ry = -dz_dy * dy_denominator;
94 | float cos_ry = 1.0 / (dy_denominator*dy);
95 |
96 | mat3 rotate_y_mat = mat3(1.0, 0.0, 0.0,
97 | 0.0, cos_ry, -sin_ry,
98 | 0.0, sin_ry, cos_ry);
99 |
100 |
101 | vec3 normal = normalize(rotate_x_mat * (rotate_y_mat * gl_Normal.xyz));
102 | //vec3 normal = normalize(gl_Normal.xyz);
103 | vec4 color = vec4(1.0,1.0,1.0,1.0);
104 | directionalLight( 0, normal, color);
105 |
106 | #elif defined(LIGHTING)
107 | vec3 normal = gl_Normal.xyz;
108 | vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
109 | directionalLight( 0, normal, color);
110 | #else
111 | vec3 normal = gl_Normal.xyz;
112 | vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
113 | #endif
114 |
115 |
116 | #ifdef COMPUTE_DIAGONALS
117 | normals_in = normal;
118 | texcoord_in = texcoord_center;
119 | basecolor_in = color;
120 | #else
121 | texcoord = texcoord_center;
122 | basecolor = color;
123 | #endif
124 |
125 | vec3 position = gl_Vertex.xyz + gl_Normal.xyz * height_center;
126 | gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0);
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/shaders/volume.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | #pragma import_defines(NVIDIA_Corporation)
4 |
5 | uniform sampler3D baseTexture;
6 | uniform float SampleDensityValue;
7 | uniform float TransparencyValue;
8 | uniform float AlphaFuncValue;
9 |
10 | varying vec4 cameraPos;
11 | varying vec4 vertexPos;
12 | varying mat4 texgen;
13 | varying vec4 baseColor;
14 |
15 | void main(void)
16 | {
17 |
18 | vec4 t0 = vertexPos;
19 | vec4 te = cameraPos;
20 |
21 | if (te.x>=0.0 && te.x<=1.0 &&
22 | te.y>=0.0 && te.y<=1.0 &&
23 | te.z>=0.0 && te.z<=1.0)
24 | {
25 | // do nothing... te inside volume
26 | }
27 | else
28 | {
29 | if (te.x<0.0)
30 | {
31 | float r = -te.x / (t0.x-te.x);
32 | te = te + (t0-te)*r;
33 | }
34 |
35 | if (te.x>1.0)
36 | {
37 | float r = (1.0-te.x) / (t0.x-te.x);
38 | te = te + (t0-te)*r;
39 | }
40 |
41 | if (te.y<0.0)
42 | {
43 | float r = -te.y / (t0.y-te.y);
44 | te = te + (t0-te)*r;
45 | }
46 |
47 | if (te.y>1.0)
48 | {
49 | float r = (1.0-te.y) / (t0.y-te.y);
50 | te = te + (t0-te)*r;
51 | }
52 |
53 | if (te.z<0.0)
54 | {
55 | float r = -te.z / (t0.z-te.z);
56 | te = te + (t0-te)*r;
57 | }
58 |
59 | if (te.z>1.0)
60 | {
61 | float r = (1.0-te.z) / (t0.z-te.z);
62 | te = te + (t0-te)*r;
63 | }
64 | }
65 |
66 | t0 = t0 * texgen;
67 | te = te * texgen;
68 |
69 | const float min_iteratrions = 2.0;
70 | const float max_iteratrions = 2048.0;
71 |
72 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
73 |
74 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
76 | #ifdef NVIDIA_Corporation
77 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
78 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
79 | #endif
80 |
81 | vec3 deltaTexCoord=(te-t0).xyz/(num_iterations-1.0);
82 | vec3 texcoord = t0.xyz;
83 |
84 | vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);
85 | while(num_iterations>0.0)
86 | {
87 | vec4 color = texture3D( baseTexture, texcoord);
88 | float r = color[3]*TransparencyValue;
89 | if (r>AlphaFuncValue)
90 | {
91 | fragColor.xyz = fragColor.xyz*(1.0-r)+color.xyz*r;
92 | fragColor.w += r;
93 | }
94 |
95 | if (fragColor.w1.0) fragColor.w = 1.0;
106 |
107 | fragColor *= baseColor;
108 |
109 | if (fragColor.w0)
23 | {
24 | vec4 color = texture3D( volumeTexture, texcoord);
25 |
26 | float m = (previousColor.a-targetValue) * (color.a-targetValue);
27 | if (m <= 0.0)
28 | {
29 | float r = (targetValue-color.a)/(previousColor.a-color.a);
30 | texcoord = texcoord - r*dt;
31 |
32 | color.rgba = vec4(1.0, 1.0, 1.0, 1.0);
33 |
34 | float px = texture3D( volumeTexture, texcoord + deltaX).a;
35 | float py = texture3D( volumeTexture, texcoord + deltaY).a;
36 | float pz = texture3D( volumeTexture, texcoord + deltaZ).a;
37 |
38 | float nx = texture3D( volumeTexture, texcoord - deltaX).a;
39 | float ny = texture3D( volumeTexture, texcoord - deltaY).a;
40 | float nz = texture3D( volumeTexture, texcoord - deltaZ).a;
41 |
42 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
43 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
44 | {
45 | vec3 normal = normalize(grad);
46 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
47 |
48 | color.r *= lightScale;
49 | color.g *= lightScale;
50 | color.b *= lightScale;
51 | }
52 |
53 | color.a = clamp(color.a*TransparencyValue, 0.0, 1.0);
54 | return color;
55 | }
56 |
57 | previousColor = color;
58 |
59 | texcoord += dt;
60 |
61 | --num_iterations;
62 | }
63 |
64 | return vec4(0.0, 0.0, 0.0, 0.0);
65 | }
66 |
--------------------------------------------------------------------------------
/shaders/volume_accumulateSamples_iso_tf.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler3D volumeTexture;
4 |
5 | uniform sampler1D tfTexture;
6 | uniform float tfScale;
7 | uniform float tfOffset;
8 | uniform float TransparencyValue;
9 | uniform float IsoSurfaceValue;
10 |
11 | varying vec3 lightDirection;
12 |
13 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)
14 | {
15 | vec3 texcoord = te.xyz;
16 |
17 | float normalSampleDistance = length(dt);
18 | vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);
19 | vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);
20 | vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);
21 |
22 | float previous_a = texture3D( volumeTexture, texcoord).a;
23 |
24 | float targetValue = IsoSurfaceValue;
25 |
26 | while(num_iterations>0)
27 | {
28 | float a = texture3D( volumeTexture, texcoord).a;
29 | float m = (previous_a-targetValue) * (a-targetValue);
30 | if (m <= 0.0)
31 | {
32 | float r = (targetValue-a)/(previous_a-a);
33 | texcoord = texcoord - r*dt;
34 |
35 | float v = targetValue * tfScale + tfOffset;
36 | vec4 color = texture1D( tfTexture, v);
37 |
38 | float px = texture3D( volumeTexture, texcoord + deltaX).a;
39 | float py = texture3D( volumeTexture, texcoord + deltaY).a;
40 | float pz = texture3D( volumeTexture, texcoord + deltaZ).a;
41 |
42 | float nx = texture3D( volumeTexture, texcoord - deltaX).a;
43 | float ny = texture3D( volumeTexture, texcoord - deltaY).a;
44 | float nz = texture3D( volumeTexture, texcoord - deltaZ).a;
45 |
46 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
47 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
48 | {
49 | vec3 normal = normalize(grad);
50 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
51 |
52 | color.r *= lightScale;
53 | color.g *= lightScale;
54 | color.b *= lightScale;
55 | }
56 | fragColor.a = clamp(fragColor.a*TransparencyValue, 0.0, 1.0);
57 | return color;
58 | }
59 |
60 | previous_a = a;
61 |
62 | texcoord += dt;
63 |
64 | --num_iterations;
65 | }
66 |
67 | return vec4(0.0, 0.0, 0.0, 0.0);
68 | }
69 |
--------------------------------------------------------------------------------
/shaders/volume_accumulateSamples_lit.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler3D volumeTexture;
4 |
5 | uniform float AlphaFuncValue;
6 | uniform float TransparencyValue;
7 |
8 | varying vec3 lightDirection;
9 |
10 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)
11 | {
12 | vec3 texcoord = te.xyz;
13 |
14 | float normalSampleDistance = length(dt);
15 | vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);
16 | vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);
17 | vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);
18 |
19 | float transmittance = 1.0;
20 | float t_cutoff = 1.0-cutoff;
21 | while(num_iterations>0 && transmittance>=t_cutoff)
22 | {
23 | vec4 color = texture3D( volumeTexture, texcoord);
24 |
25 | if (color.a>=AlphaFuncValue)
26 | {
27 |
28 | float px = texture3D( volumeTexture, texcoord + deltaX).a;
29 | float py = texture3D( volumeTexture, texcoord + deltaY).a;
30 | float pz = texture3D( volumeTexture, texcoord + deltaZ).a;
31 |
32 | float nx = texture3D( volumeTexture, texcoord - deltaX).a;
33 | float ny = texture3D( volumeTexture, texcoord - deltaY).a;
34 | float nz = texture3D( volumeTexture, texcoord - deltaZ).a;
35 |
36 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
37 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
38 | {
39 | vec3 normal = normalize(grad);
40 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
41 |
42 | color.r *= lightScale;
43 | color.g *= lightScale;
44 | color.b *= lightScale;
45 | }
46 |
47 | float ca = clamp(color.a*TransparencyValue, 0.0, 1.0);
48 | float new_transmitance = transmittance*pow(1.0-ca, scale);
49 | float r = transmittance-new_transmitance;
50 | fragColor.rgb += color.rgb*r;
51 | transmittance = new_transmitance;
52 | }
53 |
54 | texcoord += dt;
55 |
56 | --num_iterations;
57 | }
58 |
59 | fragColor.a = clamp(1.0-transmittance, 0.0, 1.0);
60 | if (num_iterations>0) fragColor.a = 1.0;
61 |
62 | return fragColor;
63 | }
64 |
--------------------------------------------------------------------------------
/shaders/volume_accumulateSamples_lit_tf.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler3D volumeTexture;
4 |
5 | uniform sampler1D tfTexture;
6 | uniform float tfScale;
7 | uniform float tfOffset;
8 | uniform float TransparencyValue;
9 | uniform float AlphaFuncValue;
10 |
11 | varying vec3 lightDirection;
12 |
13 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)
14 | {
15 | vec3 texcoord = te.xyz;
16 |
17 | float normalSampleDistance = length(dt);
18 | vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);
19 | vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);
20 | vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);
21 |
22 | float transmittance = 1.0;
23 | float t_cutoff = 1.0-cutoff;
24 | while(num_iterations>0 && transmittance>=t_cutoff)
25 | {
26 | float a = texture3D( volumeTexture, texcoord).a;
27 | float v = a * tfScale + tfOffset;
28 | vec4 color = texture1D( tfTexture, v);
29 |
30 | if (a>=AlphaFuncValue)
31 | {
32 |
33 | float px = texture3D( volumeTexture, texcoord + deltaX).a;
34 | float py = texture3D( volumeTexture, texcoord + deltaY).a;
35 | float pz = texture3D( volumeTexture, texcoord + deltaZ).a;
36 |
37 | float nx = texture3D( volumeTexture, texcoord - deltaX).a;
38 | float ny = texture3D( volumeTexture, texcoord - deltaY).a;
39 | float nz = texture3D( volumeTexture, texcoord - deltaZ).a;
40 |
41 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
42 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
43 | {
44 | vec3 normal = normalize(grad);
45 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
46 |
47 | color.r *= lightScale;
48 | color.g *= lightScale;
49 | color.b *= lightScale;
50 | }
51 |
52 | float ca = clamp(color.a*TransparencyValue, 0.0, 1.0);
53 | float new_transmitance = transmittance*pow(1.0-ca, scale);
54 | float r = transmittance-new_transmitance;
55 | fragColor.rgb += color.rgb*r;
56 | transmittance = new_transmitance;
57 | }
58 |
59 | texcoord += dt;
60 |
61 | --num_iterations;
62 | }
63 |
64 | fragColor.a = clamp(1.0-transmittance, 0.0, 1.0);
65 | if (num_iterations>0) fragColor.a = 1.0;
66 |
67 | return fragColor;
68 | }
69 |
--------------------------------------------------------------------------------
/shaders/volume_accumulateSamples_mip.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler3D volumeTexture;
4 | uniform float TransparencyValue;
5 | uniform float AlphaFuncValue;
6 |
7 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)
8 | {
9 | vec3 texcoord = te.xyz;
10 |
11 | while(num_iterations>0)
12 | {
13 | vec4 color = texture3D( volumeTexture, texcoord);
14 |
15 | if (color.a>AlphaFuncValue && color.a>fragColor.a)
16 | {
17 | fragColor = color;
18 | }
19 |
20 | texcoord += dt;
21 |
22 | --num_iterations;
23 | }
24 |
25 | fragColor.a *= TransparencyValue;
26 |
27 | return fragColor;
28 | }
29 |
--------------------------------------------------------------------------------
/shaders/volume_accumulateSamples_mip_tf.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler3D volumeTexture;
4 |
5 | uniform float TransparencyValue;
6 | uniform float AlphaFuncValue;
7 | uniform sampler1D tfTexture;
8 | uniform float tfScale;
9 | uniform float tfOffset;
10 |
11 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)
12 | {
13 | vec3 texcoord = te.xyz;
14 |
15 | float max_a = 0.0;
16 | while(num_iterations>0)
17 | {
18 | float a = texture3D( volumeTexture, texcoord).a;
19 |
20 | if (a>max_a)
21 | {
22 | float v = a * tfScale + tfOffset;
23 | vec4 color = texture1D( tfTexture, v);
24 | if (color.a>AlphaFuncValue)
25 | {
26 | fragColor = color;
27 | max_a = a;
28 | }
29 | }
30 |
31 | texcoord += dt;
32 |
33 | --num_iterations;
34 | }
35 |
36 | fragColor.a *= TransparencyValue;
37 |
38 | return fragColor;
39 | }
40 |
--------------------------------------------------------------------------------
/shaders/volume_accumulateSamples_standard.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler3D volumeTexture;
4 |
5 | uniform float TransparencyValue;
6 | uniform float AlphaFuncValue;
7 |
8 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)
9 | {
10 | vec3 texcoord = te.xyz;
11 |
12 | float transmittance = 1.0;
13 | float t_cutoff = 1.0-cutoff;
14 | while(num_iterations>0 && transmittance>=t_cutoff)
15 | {
16 | vec4 color = texture3D( volumeTexture, texcoord);
17 |
18 | if (color.a>=AlphaFuncValue)
19 | {
20 | float ca = clamp(color.a*TransparencyValue, 0.0, 1.0);
21 | float new_transmitance = transmittance*pow(1.0-ca, scale);
22 | float r = transmittance-new_transmitance;
23 | fragColor.rgb += color.rgb*r;
24 | transmittance = new_transmitance;
25 | }
26 |
27 | texcoord += dt;
28 |
29 | --num_iterations;
30 | }
31 |
32 | fragColor.a = clamp(1.0-transmittance, 0.0, 1.0);
33 | if (num_iterations>0) fragColor.a = 1.0;
34 |
35 | return fragColor;
36 | }
37 |
--------------------------------------------------------------------------------
/shaders/volume_accumulateSamples_standard_tf.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler3D volumeTexture;
4 | uniform sampler1D tfTexture;
5 |
6 | uniform float tfScale;
7 | uniform float tfOffset;
8 | uniform float TransparencyValue;
9 | uniform float AlphaFuncValue;
10 |
11 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)
12 | {
13 | vec3 texcoord = te.xyz;
14 |
15 | float transmittance = 1.0;
16 | float t_cutoff = 1.0-cutoff;
17 | while(num_iterations>0 && transmittance>=t_cutoff)
18 | {
19 | float a = texture3D( volumeTexture, texcoord).a;
20 | float v = a * tfScale + tfOffset;
21 | vec4 color = texture1D( tfTexture, v);
22 |
23 | if (a>=AlphaFuncValue)
24 | {
25 | float ca = clamp(color.a*TransparencyValue, 0.0, 1.0);
26 | float new_transmitance = transmittance*pow(1.0-ca, scale);
27 | float r = transmittance-new_transmitance;
28 | fragColor.rgb += color.rgb*r;
29 | transmittance = new_transmitance;
30 | }
31 |
32 | texcoord += dt;
33 |
34 | --num_iterations;
35 | }
36 |
37 | fragColor.a = clamp(1.0-transmittance, 0.0, 1.0);
38 | if (num_iterations>0) fragColor.a = 1.0;
39 |
40 | return fragColor;
41 | }
42 |
--------------------------------------------------------------------------------
/shaders/volume_color_depth.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D colorTexture;
2 | uniform sampler2D depthTexture;
3 |
4 | varying vec4 texcoord;
5 |
6 | void main(void)
7 | {
8 | vec4 color = texture2D( colorTexture, texcoord);
9 | float texture_depth = texture2D( depthTexture, texcoord).s;
10 | gl_FragColor = color;
11 | gl_FragDepth = texture_depth;
12 | }
13 |
--------------------------------------------------------------------------------
/shaders/volume_color_depth.vert:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | varying vec4 texcoord;
4 |
5 | void main(void)
6 | {
7 | gl_Position = ftransform();
8 | texcoord = gl_MultiTexCoord0;
9 | }
10 |
--------------------------------------------------------------------------------
/shaders/volume_compute_ray_color.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform vec4 viewportDimensions;
4 | uniform sampler3D volumeTexture;
5 | uniform vec3 volumeCellSize;
6 | uniform mat4 tileToImage;
7 | uniform float SampleRatioValue;
8 |
9 | varying mat4 texgen_eyeToTile;
10 |
11 | // forward declare, probided by volume_accumulateSamples*.frag shaders
12 | vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations);
13 |
14 | vec4 accumulateSegment(vec4 fragColor, vec3 ts, vec3 te)
15 | {
16 | const int max_iterations = 8192;
17 |
18 | float density = volumeCellSize.x;
19 | if (volumeCellSize.ymax_iterations)
31 | {
32 | num_iterations = max_iterations;
33 | }
34 |
35 | // traverse from front to back
36 | vec3 deltaTexCoord=(ts-te).xyz/float(num_iterations-1);
37 | float stepLength = length(deltaTexCoord);
38 |
39 | //float scale = 0.5/sampleRatio;
40 | float scale = 1.73*stepLength/length(volumeCellSize);
41 | if (scale>1.0) scale = 1.0;
42 |
43 | float cutoff = 1.0-1.0/256.0;
44 |
45 | fragColor = accumulateSamples(fragColor, ts, te, deltaTexCoord, scale, cutoff, num_iterations);
46 |
47 | fragColor *= baseColor;
48 |
49 | return fragColor;
50 | }
51 |
52 | vec3 clampToUnitCube(vec3 ts, vec3 te)
53 | {
54 | if (te.x>=0.0 && te.x<=1.0 &&
55 | te.y>=0.0 && te.y<=1.0 &&
56 | te.z>=0.0 && te.z<=1.0)
57 | {
58 | // do nothing... te inside volume
59 | return te;
60 | }
61 | else
62 | {
63 | if (te.x<0.0)
64 | {
65 | float r = -te.x / (ts.x-te.x);
66 | te = te + (ts-te)*r;
67 | }
68 |
69 | if (te.x>1.0)
70 | {
71 | float r = (1.0-te.x) / (ts.x-te.x);
72 | te = te + (ts-te)*r;
73 | }
74 |
75 | if (te.y<0.0)
76 | {
77 | float r = -te.y / (ts.y-te.y);
78 | te = te + (ts-te)*r;
79 | }
80 |
81 | if (te.y>1.0)
82 | {
83 | float r = (1.0-te.y) / (ts.y-te.y);
84 | te = te + (ts-te)*r;
85 | }
86 |
87 | if (te.z<0.0)
88 | {
89 | float r = -te.z / (ts.z-te.z);
90 | te = te + (ts-te)*r;
91 | }
92 |
93 | if (te.z>1.0)
94 | {
95 | float r = (1.0-te.z) / (ts.z-te.z);
96 | te = te + (ts-te)*r;
97 | }
98 | }
99 | return te;
100 | }
101 |
102 |
103 | vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end)
104 | {
105 | float viewportWidth = viewportDimensions[2];
106 | float viewportHeight = viewportDimensions[3];
107 |
108 | px -= viewportDimensions.x;
109 | py -= viewportDimensions.y;
110 |
111 | // start and end clip space coords
112 | vec4 start_clip = vec4((px/viewportWidth)*2.0-1.0, (py/viewportHeight)*2.0-1.0, (depth_start)*2.0-1.0, 1.0);
113 | vec4 end_clip = vec4((px/viewportWidth)*2.0-1.0, (py/viewportHeight)*2.0-1.0, (depth_end)*2.0-1.0, 1.0);
114 |
115 | // compute the coords in tile coordinates
116 | vec4 start_tile = texgen_eyeToTile * start_clip;
117 | vec4 end_tile = texgen_eyeToTile * end_clip;
118 |
119 | start_tile.xyz = start_tile.xyz / start_tile.w;
120 | start_tile.w = 1.0;
121 |
122 | end_tile.xyz = end_tile.xyz / end_tile.w;
123 | end_tile.w = 1.0;
124 |
125 | vec4 clamped_start_tile = vec4(clampToUnitCube(end_tile.xyz, start_tile.xyz), 1.0);
126 | vec4 clamped_end_tile = vec4(clampToUnitCube(start_tile.xyz, end_tile.xyz), 1.0);
127 |
128 | // compute texcoords in image/texture coords
129 | vec4 start_texcoord = tileToImage * clamped_start_tile;
130 | vec4 end_texcoord = tileToImage * clamped_end_tile;
131 |
132 | start_texcoord.xyz = start_texcoord.xyz / start_texcoord.w;
133 | start_texcoord.w = 1.0;
134 |
135 | end_texcoord.xyz = end_texcoord.xyz / end_texcoord.w;
136 | end_texcoord.w = 1.0;
137 |
138 | vec3 clamped_start_texcoord = clampToUnitCube(end_texcoord.xyz, start_texcoord.xyz);
139 | vec3 clamped_end_texcoord = clampToUnitCube(start_texcoord.xyz, end_texcoord.xyz);
140 |
141 | return accumulateSegment(fragColor, clamped_start_texcoord, clamped_end_texcoord);
142 | }
143 |
--------------------------------------------------------------------------------
/shaders/volume_iso.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | #pragma import_defines(NVIDIA_Corporation)
4 |
5 | uniform sampler3D baseTexture;
6 | uniform float SampleDensityValue;
7 | uniform float TransparencyValue;
8 | uniform float IsoSurfaceValue;
9 |
10 | varying vec4 cameraPos;
11 | varying vec4 vertexPos;
12 | varying vec3 lightDirection;
13 | varying mat4 texgen;
14 | varying vec4 baseColor;
15 |
16 | void main(void)
17 | {
18 | vec4 t0 = vertexPos;
19 | vec4 te = cameraPos;
20 |
21 | if (te.x>=0.0 && te.x<=1.0 &&
22 | te.y>=0.0 && te.y<=1.0 &&
23 | te.z>=0.0 && te.z<=1.0)
24 | {
25 | // do nothing... te inside volume
26 | }
27 | else
28 | {
29 | if (te.x<0.0)
30 | {
31 | float r = -te.x / (t0.x-te.x);
32 | te = te + (t0-te)*r;
33 | }
34 |
35 | if (te.x>1.0)
36 | {
37 | float r = (1.0-te.x) / (t0.x-te.x);
38 | te = te + (t0-te)*r;
39 | }
40 |
41 | if (te.y<0.0)
42 | {
43 | float r = -te.y / (t0.y-te.y);
44 | te = te + (t0-te)*r;
45 | }
46 |
47 | if (te.y>1.0)
48 | {
49 | float r = (1.0-te.y) / (t0.y-te.y);
50 | te = te + (t0-te)*r;
51 | }
52 |
53 | if (te.z<0.0)
54 | {
55 | float r = -te.z / (t0.z-te.z);
56 | te = te + (t0-te)*r;
57 | }
58 |
59 | if (te.z>1.0)
60 | {
61 | float r = (1.0-te.z) / (t0.z-te.z);
62 | te = te + (t0-te)*r;
63 | }
64 | }
65 |
66 | t0 = t0 * texgen;
67 | te = te * texgen;
68 |
69 | const float min_iteratrions = 2.0;
70 | const float max_iteratrions = 2048.0;
71 |
72 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
73 |
74 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
76 | #ifdef NVIDIA_Corporation
77 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
78 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
79 | #endif
80 |
81 | vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1.0);
82 | vec3 texcoord = te.xyz;
83 |
84 | vec4 previousColor = texture3D( baseTexture, texcoord);
85 |
86 | float normalSampleDistance = 1.0/512.0;
87 | vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);
88 | vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);
89 | vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);
90 |
91 | while(num_iterations>0.0)
92 | {
93 | vec4 color = texture3D( baseTexture, texcoord);
94 |
95 | float m = (previousColor.a-IsoSurfaceValue) * (color.a-IsoSurfaceValue);
96 | if (m <= 0.0)
97 | {
98 | float r = (IsoSurfaceValue-color.a)/(previousColor.a-color.a);
99 | texcoord = texcoord - r*deltaTexCoord;
100 |
101 | float a = color.a;
102 | float px = texture3D( baseTexture, texcoord + deltaX).a;
103 | float py = texture3D( baseTexture, texcoord + deltaY).a;
104 | float pz = texture3D( baseTexture, texcoord + deltaZ).a;
105 |
106 | float nx = texture3D( baseTexture, texcoord - deltaX).a;
107 | float ny = texture3D( baseTexture, texcoord - deltaY).a;
108 | float nz = texture3D( baseTexture, texcoord - deltaZ).a;
109 |
110 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
111 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
112 | {
113 | vec3 normal = normalize(grad);
114 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
115 |
116 | color.x = lightScale;
117 | color.y = lightScale;
118 | color.z = lightScale;
119 | }
120 |
121 |
122 | color.a = 1.0;
123 |
124 | color *= baseColor;
125 |
126 | gl_FragColor = color;
127 |
128 | return;
129 | }
130 |
131 | previousColor = color;
132 |
133 | texcoord += deltaTexCoord;
134 |
135 | --num_iterations;
136 | }
137 |
138 | // we didn't find an intersection so just discard fragment
139 | discard;
140 | }
141 |
--------------------------------------------------------------------------------
/shaders/volume_lit.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | #pragma import_defines(NVIDIA_Corporation)
4 |
5 | uniform sampler3D baseTexture;
6 | uniform float SampleDensityValue;
7 | uniform float TransparencyValue;
8 | uniform float AlphaFuncValue;
9 |
10 | varying vec4 cameraPos;
11 | varying vec4 vertexPos;
12 | varying vec3 lightDirection;
13 | varying mat4 texgen;
14 | varying vec4 baseColor;
15 |
16 | void main(void)
17 | {
18 | vec4 t0 = vertexPos;
19 | vec4 te = cameraPos;
20 |
21 | if (te.x>=0.0 && te.x<=1.0 &&
22 | te.y>=0.0 && te.y<=1.0 &&
23 | te.z>=0.0 && te.z<=1.0)
24 | {
25 | // do nothing... te inside volume
26 | }
27 | else
28 | {
29 | if (te.x<0.0)
30 | {
31 | float r = -te.x / (t0.x-te.x);
32 | te = te + (t0-te)*r;
33 | }
34 |
35 | if (te.x>1.0)
36 | {
37 | float r = (1.0-te.x) / (t0.x-te.x);
38 | te = te + (t0-te)*r;
39 | }
40 |
41 | if (te.y<0.0)
42 | {
43 | float r = -te.y / (t0.y-te.y);
44 | te = te + (t0-te)*r;
45 | }
46 |
47 | if (te.y>1.0)
48 | {
49 | float r = (1.0-te.y) / (t0.y-te.y);
50 | te = te + (t0-te)*r;
51 | }
52 |
53 | if (te.z<0.0)
54 | {
55 | float r = -te.z / (t0.z-te.z);
56 | te = te + (t0-te)*r;
57 | }
58 |
59 | if (te.z>1.0)
60 | {
61 | float r = (1.0-te.z) / (t0.z-te.z);
62 | te = te + (t0-te)*r;
63 | }
64 | }
65 |
66 | t0 = t0 * texgen;
67 | te = te * texgen;
68 |
69 | const float min_iteratrions = 2.0;
70 | const float max_iteratrions = 2048.0;
71 |
72 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
73 |
74 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
76 | #ifdef NVIDIA_Corporation
77 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
78 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
79 | #endif
80 |
81 | vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);
82 | vec3 texcoord = t0.xyz;
83 |
84 | float normalSampleDistance = 1.0/512.0;
85 | vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);
86 | vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);
87 | vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);
88 |
89 | vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);
90 | while(num_iterations>0.0)
91 | {
92 | vec4 color = texture3D( baseTexture, texcoord);
93 |
94 | float a = color.a;
95 | float px = texture3D( baseTexture, texcoord + deltaX).a;
96 | float py = texture3D( baseTexture, texcoord + deltaY).a;
97 | float pz = texture3D( baseTexture, texcoord + deltaZ).a;
98 |
99 | float nx = texture3D( baseTexture, texcoord - deltaX).a;
100 | float ny = texture3D( baseTexture, texcoord - deltaY).a;
101 | float nz = texture3D( baseTexture, texcoord - deltaZ).a;
102 |
103 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
104 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
105 | {
106 | vec3 normal = normalize(grad);
107 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
108 |
109 | color.x *= lightScale;
110 | color.y *= lightScale;
111 | color.z *= lightScale;
112 | }
113 |
114 | float r = color[3]*TransparencyValue;
115 | if (r>AlphaFuncValue)
116 | {
117 | fragColor.xyz = fragColor.xyz*(1.0-r)+color.xyz*r;
118 | fragColor.w += r;
119 | }
120 |
121 | if (fragColor.w1.0) fragColor.w = 1.0;
132 |
133 | fragColor *= baseColor;
134 |
135 | if (fragColor.w=0.0 && te.x<=1.0 &&
27 | te.y>=0.0 && te.y<=1.0 &&
28 | te.z>=0.0 && te.z<=1.0)
29 | {
30 | // do nothing... te inside volume
31 | }
32 | else
33 | {
34 | if (te.x<0.0)
35 | {
36 | float r = -te.x / (t0.x-te.x);
37 | te = te + (t0-te)*r;
38 | }
39 |
40 | if (te.x>1.0)
41 | {
42 | float r = (1.0-te.x) / (t0.x-te.x);
43 | te = te + (t0-te)*r;
44 | }
45 |
46 | if (te.y<0.0)
47 | {
48 | float r = -te.y / (t0.y-te.y);
49 | te = te + (t0-te)*r;
50 | }
51 |
52 | if (te.y>1.0)
53 | {
54 | float r = (1.0-te.y) / (t0.y-te.y);
55 | te = te + (t0-te)*r;
56 | }
57 |
58 | if (te.z<0.0)
59 | {
60 | float r = -te.z / (t0.z-te.z);
61 | te = te + (t0-te)*r;
62 | }
63 |
64 | if (te.z>1.0)
65 | {
66 | float r = (1.0-te.z) / (t0.z-te.z);
67 | te = te + (t0-te)*r;
68 | }
69 | }
70 |
71 | t0 = t0 * texgen;
72 | te = te * texgen;
73 |
74 | vec3 eyeDirection = normalize((te-t0).xyz);
75 |
76 | const float min_iteratrions = 2.0;
77 | const float max_iteratrions = 2048.0;
78 |
79 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
80 |
81 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
83 | #ifdef NVIDIA_Corporation
84 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
85 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
86 | #endif
87 |
88 | vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);
89 | vec3 texcoord = t0.xyz;
90 |
91 | float normalSampleDistance = 1.0/512.0;
92 | vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);
93 | vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);
94 | vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);
95 |
96 | vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);
97 | while(num_iterations>0.0)
98 | {
99 | float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;
100 | vec4 color = texture1D( tfTexture, v);
101 |
102 | float a = v;
103 | float px = texture3D( baseTexture, texcoord + deltaX).a;
104 | float py = texture3D( baseTexture, texcoord + deltaY).a;
105 | float pz = texture3D( baseTexture, texcoord + deltaZ).a;
106 |
107 | float nx = texture3D( baseTexture, texcoord - deltaX).a;
108 | float ny = texture3D( baseTexture, texcoord - deltaY).a;
109 | float nz = texture3D( baseTexture, texcoord - deltaZ).a;
110 |
111 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
112 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
113 | {
114 | vec3 normal = normalize(grad);
115 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
116 |
117 | color.x *= lightScale;
118 | color.y *= lightScale;
119 | color.z *= lightScale;
120 | }
121 |
122 | float r = color[3]*TransparencyValue;
123 | if (r>AlphaFuncValue)
124 | {
125 | fragColor.xyz = fragColor.xyz*(1.0-r)+color.xyz*r;
126 | fragColor.w += r;
127 | }
128 |
129 | if (fragColor.w1.0) fragColor.w = 1.0;
141 | if (fragColor.w=0.0 && te.x<=1.0 &&
21 | te.y>=0.0 && te.y<=1.0 &&
22 | te.z>=0.0 && te.z<=1.0)
23 | {
24 | // do nothing... te inside volume
25 | }
26 | else
27 | {
28 | if (te.x<0.0)
29 | {
30 | float r = -te.x / (t0.x-te.x);
31 | te = te + (t0-te)*r;
32 | }
33 |
34 | if (te.x>1.0)
35 | {
36 | float r = (1.0-te.x) / (t0.x-te.x);
37 | te = te + (t0-te)*r;
38 | }
39 |
40 | if (te.y<0.0)
41 | {
42 | float r = -te.y / (t0.y-te.y);
43 | te = te + (t0-te)*r;
44 | }
45 |
46 | if (te.y>1.0)
47 | {
48 | float r = (1.0-te.y) / (t0.y-te.y);
49 | te = te + (t0-te)*r;
50 | }
51 |
52 | if (te.z<0.0)
53 | {
54 | float r = -te.z / (t0.z-te.z);
55 | te = te + (t0-te)*r;
56 | }
57 |
58 | if (te.z>1.0)
59 | {
60 | float r = (1.0-te.z) / (t0.z-te.z);
61 | te = te + (t0-te)*r;
62 | }
63 | }
64 |
65 | t0 = t0 * texgen;
66 | te = te * texgen;
67 |
68 | const float min_iteratrions = 2.0;
69 | const float max_iteratrions = 2048.0;
70 |
71 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
72 |
73 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
75 | #ifdef NVIDIA_Corporation
76 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
77 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
78 | #endif
79 |
80 | vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);
81 | vec3 texcoord = t0.xyz;
82 |
83 | vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);
84 | while(num_iterations>0.0)
85 | {
86 | vec4 color = texture3D( baseTexture, texcoord);
87 | if (fragColor.w1.0) fragColor.w = 1.0;
98 |
99 | fragColor *= baseColor;
100 |
101 | if (fragColor.wtexture_depth) discard;
82 |
83 | // gl_FragDepth = texture_depth;
84 |
85 | // need to blend the object color with the ray from the object depth to the eye point
86 | vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);
87 | // ray_color *= vec4(1.0,1.0,0.0,1.0);
88 | gl_FragColor = mix(color, ray_color, ray_color.a);
89 | }
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/shaders/volume_multipass.vert:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform mat4 eyeToTile;
4 | uniform mat4 tileToImage;
5 |
6 | varying vec4 vertexPos;
7 | varying vec3 lightDirection;
8 | varying vec4 baseColor;
9 |
10 | varying mat4 texgen_eyeToTile;
11 |
12 | varying float near;
13 | varying float far;
14 | varying float near_mult_far;
15 | varying float far_sub_near;
16 |
17 | void main(void)
18 | {
19 | // compute near and far values from projection matrix.
20 | near = gl_ProjectionMatrix[2][3] / (gl_ProjectionMatrix[2][2]-1.0);
21 | far = gl_ProjectionMatrix[2][3] / (1.0+gl_ProjectionMatrix[2][2]);
22 |
23 | near_mult_far = near*far;
24 | far_sub_near = far-near;
25 |
26 | gl_Position = ftransform();
27 |
28 | vertexPos = gl_Vertex;
29 | baseColor = gl_FrontMaterial.diffuse;
30 |
31 | vec4 lightPosition = gl_ModelViewMatrixInverse * gl_LightSource[0].position;
32 | if (lightPosition[3]==0.0)
33 | {
34 | // directional light source
35 | lightDirection = -normalize(lightPosition.xyz);
36 | }
37 | else
38 | {
39 | // positional light source
40 | lightDirection = normalize((lightPosition-vertexPos).xyz);
41 | }
42 |
43 | texgen_eyeToTile = eyeToTile * gl_ProjectionMatrixInverse;
44 | }
45 |
--------------------------------------------------------------------------------
/shaders/volume_multipass_cube.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler2D colorTexture;
4 | uniform sampler2D depthTexture;
5 | uniform vec4 viewportDimensions;
6 |
7 | // declare function defined in volume_compute_ray_color.frag
8 | vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end);
9 |
10 | void main(void)
11 | {
12 | vec2 texcoord = vec2((gl_FragCoord.x-viewportDimensions[0])/viewportDimensions[2], (gl_FragCoord.y-viewportDimensions[1])/viewportDimensions[3]);
13 | vec4 color = texture2D( colorTexture, texcoord);
14 | float texture_depth = texture2D( depthTexture, texcoord).s;
15 | float front_depth = 0.0;
16 |
17 | if (gl_FragCoord.ztexture_depth) discard;
76 |
77 | // gl_FragDepth = texture_depth;
78 |
79 | // need to blend the object color with the ray from the object depth to the eye point
80 | vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);
81 | // ray_color *= vec4(1.0,1.0,0.0,1.0);
82 | gl_FragColor = mix(color, ray_color, ray_color.a);
83 | }
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/shaders/volume_multipass_cube_and_hull.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler2D colorTexture;
4 | uniform sampler2D depthTexture;
5 | uniform sampler2D backFaceDepthTexture;
6 | uniform sampler2D frontFaceDepthTexture;
7 | uniform vec4 viewportDimensions;
8 | uniform float ExteriorTransparencyFactorValue;
9 |
10 |
11 | // declare function defined in volume_compute_ray_color.frag
12 | vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end);
13 |
14 | vec4 computeSegment(vec4 fragColor, float px, float py, float depth_start, float depth_end, float transparencyFactor, vec4 scene_color, float scene_depth)
15 | {
16 | #if 1
17 | //return mix(fragColor, computeRayColor(fragColor, px, py, depth_start, depth_end), transparencyFactor);
18 | if ((depth_end=1.0) return fragColor;
25 |
26 | // compute rear segement color and blend with accumulated_color
27 | return mix( fragColor, computeRayColor(fragColor, px, py, depth_start, scene_depth), transparencyFactor);
28 | }
29 | else
30 | {
31 | return mix( fragColor, computeRayColor(fragColor, px, py, depth_start, depth_end), transparencyFactor);
32 | }
33 | #else
34 | if ((depth_end=1.0) return fragColor;
41 |
42 | // compute rear segement color and blend with accumulated_color
43 | return computeRayColor(fragColor, px, py, depth_start, scene_depth) * transparencyFactor;
44 | }
45 | else
46 | {
47 | return computeRayColor(fragColor, px, py, depth_start, depth_end) * transparencyFactor;
48 | }
49 | #endif
50 | }
51 |
52 | void main(void)
53 | {
54 | vec2 texcoord = vec2((gl_FragCoord.x-viewportDimensions[0])/viewportDimensions[2], (gl_FragCoord.y-viewportDimensions[1])/viewportDimensions[3]);
55 | vec4 color = texture2D( colorTexture, texcoord);
56 | float texture_depth = texture2D( depthTexture, texcoord).s;
57 | float back_depth = texture2D( backFaceDepthTexture, texcoord).s;
58 | float front_depth = texture2D( frontFaceDepthTexture, texcoord).s;
59 |
60 | //float ExteriorTransparencyFactorValue = 1.0;
61 | vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);
62 |
63 | // make sure the front_depth and back_depth values represent usable depths for later tests
64 | if (front_depth>back_depth)
65 | {
66 | if (front_depth==1.0)
67 | {
68 | // front face likely to have been clipped out by near plane
69 | front_depth = 0.0;
70 | }
71 | else
72 | {
73 | // front and back faces of hull are reversed so treat them as empty.
74 | front_depth = 1.0;
75 | back_depth = 1.0;
76 | }
77 | }
78 |
79 | if (back_depthgl_FragCoord.z)
112 | {
113 | fragColor = mix(color, fragColor, fragColor.a);
114 | }
115 |
116 | gl_FragColor = fragColor;
117 | gl_FragDepth = 0.0;
118 | }
119 |
--------------------------------------------------------------------------------
/shaders/volume_multipass_hull.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler2D colorTexture;
4 | uniform sampler2D depthTexture;
5 | uniform sampler2D frontFaceDepthTexture;
6 | uniform vec4 viewportDimensions;
7 |
8 | // declare function defined in volume_compute_ray_color.frag
9 | vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end);
10 |
11 | void main(void)
12 | {
13 | vec2 texcoord = vec2((gl_FragCoord.x-viewportDimensions[0])/viewportDimensions[2], (gl_FragCoord.y-viewportDimensions[1])/viewportDimensions[3]);
14 | vec4 color = texture2D( colorTexture, texcoord);
15 | float texture_depth = texture2D( depthTexture, texcoord).s;
16 | float front_depth = texture2D( frontFaceDepthTexture, texcoord).s;
17 |
18 | // if front_depth is set to the far plane then front
19 | // face has been clipped out by the near plane, so assume
20 | // front_depth is near plane and reset depth to 0.0
21 | if (front_depth==1.0) front_depth = 0.0;
22 |
23 | if (gl_FragCoord.ztexture_depth) discard;
83 |
84 | // gl_FragDepth = texture_depth;
85 |
86 | // need to blend the object color with the ray from the object depth to the eye point
87 | vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);
88 | // ray_color *= vec4(1.0,1.0,0.0,1.0);
89 | gl_FragColor = mix(color, ray_color, ray_color.a);
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/shaders/volume_tf.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | #pragma import_defines(NVIDIA_Corporation)
4 |
5 | uniform sampler3D baseTexture;
6 |
7 | uniform sampler1D tfTexture;
8 | uniform float tfScale;
9 | uniform float tfOffset;
10 |
11 | uniform float SampleDensityValue;
12 | uniform float TransparencyValue;
13 | uniform float AlphaFuncValue;
14 |
15 | varying vec4 cameraPos;
16 | varying vec4 vertexPos;
17 | varying mat4 texgen;
18 | varying vec4 baseColor;
19 |
20 | void main(void)
21 | {
22 | vec4 t0 = vertexPos;
23 | vec4 te = cameraPos;
24 |
25 | if (te.x>=0.0 && te.x<=1.0 &&
26 | te.y>=0.0 && te.y<=1.0 &&
27 | te.z>=0.0 && te.z<=1.0)
28 | {
29 | // do nothing... te inside volume
30 | }
31 | else
32 | {
33 | if (te.x<0.0)
34 | {
35 | float r = -te.x / (t0.x-te.x);
36 | te = te + (t0-te)*r;
37 | }
38 |
39 | if (te.x>1.0)
40 | {
41 | float r = (1.0-te.x) / (t0.x-te.x);
42 | te = te + (t0-te)*r;
43 | }
44 |
45 | if (te.y<0.0)
46 | {
47 | float r = -te.y / (t0.y-te.y);
48 | te = te + (t0-te)*r;
49 | }
50 |
51 | if (te.y>1.0)
52 | {
53 | float r = (1.0-te.y) / (t0.y-te.y);
54 | te = te + (t0-te)*r;
55 | }
56 |
57 | if (te.z<0.0)
58 | {
59 | float r = -te.z / (t0.z-te.z);
60 | te = te + (t0-te)*r;
61 | }
62 |
63 | if (te.z>1.0)
64 | {
65 | float r = (1.0-te.z) / (t0.z-te.z);
66 | te = te + (t0-te)*r;
67 | }
68 | }
69 |
70 | t0 = t0 * texgen;
71 | te = te * texgen;
72 |
73 | const float min_iteratrions = 2.0;
74 | const float max_iteratrions = 2048.0;
75 |
76 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
77 |
78 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
80 | #ifdef NVIDIA_Corporation
81 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
82 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
83 | #endif
84 |
85 | vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);
86 | vec3 texcoord = t0.xyz;
87 |
88 | vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);
89 | while(num_iterations>0.0)
90 | {
91 | float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;
92 | vec4 color = texture1D( tfTexture, v);
93 |
94 | float r = color[3]*TransparencyValue;
95 | if (r>AlphaFuncValue)
96 | {
97 | fragColor.xyz = fragColor.xyz*(1.0-r)+color.xyz*r;
98 | fragColor.w += r;
99 | }
100 |
101 | if (fragColor.w1.0) fragColor.w = 1.0;
112 |
113 | fragColor *= baseColor;
114 |
115 | if (fragColor.w=0.0 && te.x<=1.0 &&
27 | te.y>=0.0 && te.y<=1.0 &&
28 | te.z>=0.0 && te.z<=1.0)
29 | {
30 | // do nothing... te inside volume
31 | }
32 | else
33 | {
34 | if (te.x<0.0)
35 | {
36 | float r = -te.x / (t0.x-te.x);
37 | te = te + (t0-te)*r;
38 | }
39 |
40 | if (te.x>1.0)
41 | {
42 | float r = (1.0-te.x) / (t0.x-te.x);
43 | te = te + (t0-te)*r;
44 | }
45 |
46 | if (te.y<0.0)
47 | {
48 | float r = -te.y / (t0.y-te.y);
49 | te = te + (t0-te)*r;
50 | }
51 |
52 | if (te.y>1.0)
53 | {
54 | float r = (1.0-te.y) / (t0.y-te.y);
55 | te = te + (t0-te)*r;
56 | }
57 |
58 | if (te.z<0.0)
59 | {
60 | float r = -te.z / (t0.z-te.z);
61 | te = te + (t0-te)*r;
62 | }
63 |
64 | if (te.z>1.0)
65 | {
66 | float r = (1.0-te.z) / (t0.z-te.z);
67 | te = te + (t0-te)*r;
68 | }
69 | }
70 |
71 | t0 = t0 * texgen;
72 | te = te * texgen;
73 |
74 | const float min_iteratrions = 2.0;
75 | const float max_iteratrions = 2048.0;
76 |
77 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
78 |
79 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
81 | #ifdef NVIDIA_Corporation
82 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
83 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
84 | #endif
85 |
86 | vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1.0);
87 | vec3 texcoord = te.xyz;
88 | float previousV = texture3D( baseTexture, texcoord).a;
89 |
90 | float normalSampleDistance = 1.0/512.0;
91 | vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);
92 | vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);
93 | vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);
94 |
95 | while(num_iterations>0.0)
96 | {
97 |
98 | float v = texture3D( baseTexture, texcoord).a;
99 |
100 | float m = (previousV-IsoSurfaceValue) * (v-IsoSurfaceValue);
101 | if (m <= 0.0)
102 | {
103 | float r = (IsoSurfaceValue-v)/(previousV-v);
104 | texcoord = texcoord - r*deltaTexCoord;
105 |
106 | v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;
107 | vec4 color = texture1D( tfTexture, v);
108 |
109 | float px = texture3D( baseTexture, texcoord + deltaX).a;
110 | float py = texture3D( baseTexture, texcoord + deltaY).a;
111 | float pz = texture3D( baseTexture, texcoord + deltaZ).a;
112 |
113 | float nx = texture3D( baseTexture, texcoord - deltaX).a;
114 | float ny = texture3D( baseTexture, texcoord - deltaY).a;
115 | float nz = texture3D( baseTexture, texcoord - deltaZ).a;
116 |
117 | vec3 grad = vec3(px-nx, py-ny, pz-nz);
118 | if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)
119 | {
120 | vec3 normal = normalize(grad);
121 | float lightScale = 0.1 + max(0.0, dot(normal.xyz, lightDirection))*0.9;
122 |
123 | color.x *= lightScale;
124 | color.y *= lightScale;
125 | color.z *= lightScale;
126 | }
127 |
128 | color *= baseColor;
129 |
130 | gl_FragColor = color;
131 |
132 | return;
133 | }
134 |
135 | previousV = v;
136 |
137 | texcoord += deltaTexCoord;
138 |
139 | --num_iterations;
140 | }
141 |
142 | // we didn't find an intersection so just discard fragment
143 | discard;
144 | }
145 |
--------------------------------------------------------------------------------
/shaders/volume_tf_mip.frag:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | #pragma import_defines(NVIDIA_Corporation)
4 |
5 | uniform sampler3D baseTexture;
6 |
7 | uniform sampler1D tfTexture;
8 | uniform float tfScale;
9 | uniform float tfOffset;
10 |
11 | uniform float SampleDensityValue;
12 | uniform float TransparencyValue;
13 | uniform float AlphaFuncValue;
14 |
15 | varying vec4 cameraPos;
16 | varying vec4 vertexPos;
17 | varying mat4 texgen;
18 | varying vec4 baseColor;
19 |
20 | void main(void)
21 | {
22 | vec4 t0 = vertexPos;
23 | vec4 te = cameraPos;
24 |
25 | if (te.x>=0.0 && te.x<=1.0 &&
26 | te.y>=0.0 && te.y<=1.0 &&
27 | te.z>=0.0 && te.z<=1.0)
28 | {
29 | // do nothing... te inside volume
30 | }
31 | else
32 | {
33 | if (te.x<0.0)
34 | {
35 | float r = -te.x / (t0.x-te.x);
36 | te = te + (t0-te)*r;
37 | }
38 |
39 | if (te.x>1.0)
40 | {
41 | float r = (1.0-te.x) / (t0.x-te.x);
42 | te = te + (t0-te)*r;
43 | }
44 |
45 | if (te.y<0.0)
46 | {
47 | float r = -te.y / (t0.y-te.y);
48 | te = te + (t0-te)*r;
49 | }
50 |
51 | if (te.y>1.0)
52 | {
53 | float r = (1.0-te.y) / (t0.y-te.y);
54 | te = te + (t0-te)*r;
55 | }
56 |
57 | if (te.z<0.0)
58 | {
59 | float r = -te.z / (t0.z-te.z);
60 | te = te + (t0-te)*r;
61 | }
62 |
63 | if (te.z>1.0)
64 | {
65 | float r = (1.0-te.z) / (t0.z-te.z);
66 | te = te + (t0-te)*r;
67 | }
68 | }
69 |
70 | t0 = t0 * texgen;
71 | te = te * texgen;
72 |
73 | const float min_iteratrions = 2.0;
74 | const float max_iteratrions = 2048.0;
75 |
76 | float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);
77 |
78 | if (num_iterationsmax_iteratrions) num_iterations = max_iteratrions;
80 | #ifdef NVIDIA_Corporation
81 | // Recent NVidia drivers have a bug in length() where it throws nan for some values of input into length() so catch these
82 | else if (num_iterations!=num_iterations) num_iterations = max_iteratrions;
83 | #endif
84 |
85 | vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);
86 | vec3 texcoord = t0.xyz;
87 |
88 | vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);
89 | while(num_iterations>0.0)
90 | {
91 | float v = texture3D( baseTexture, texcoord).s * tfScale + tfOffset;
92 | vec4 color = texture1D( tfTexture, v);
93 | if (fragColor.w1.0) fragColor.w = 1.0;
104 |
105 | fragColor *= baseColor;
106 |
107 | if (fragColor.w>>>>>>>>>>>>> WidgetUtils ",WidgetUtils);
5 | print(">>>>>>>>>>>>>> WidgetUtils ",WidgetUtils.createLabel);
6 |
7 | local widget = new("osgUI::Widget");
8 |
9 | widget.Name = "TransferFunctionWidget";
10 |
11 | if (extents) then
12 | widget.Extents = extents;
13 | end
14 |
15 | widget.load = function(widget, filename)
16 |
17 | local obj = readObjectFile(filename);
18 | print("widget.load", filename, obj);
19 | end
20 |
21 | widget.createGraphics = function(widget)
22 |
23 | if (widget.Extents.xMin > widget.Extents.xMax) then
24 | widget.Extents = {xMin=5, yMin=3, zMin=0, xMax=100,yMax=50,zMax=0.0};
25 | end
26 |
27 | print("Running TransferFunctionWidget: "..widget.Name..":createGraphics()");
28 | print(" extents ", widget.Extents);
29 |
30 |
31 | local geometry = new("osg::Geometry");
32 | local vertices = new("osg::Vec3Array");
33 | geometry.VertexArray = vertices;
34 |
35 | local colours = new("osg::Vec4Array");
36 | colours.Binding = "BIND_PER_PRIMITIVE_SET"
37 | geometry.ColorArray = colours;
38 |
39 |
40 | local primitives = new("osg::DrawElementsUShort");
41 |
42 | geometry.PrimitiveSetList:add(primitives);
43 |
44 | widget:addChild(geometry);
45 |
46 | print("geometry ",geometry);
47 | print("vertices ",vertices);
48 | print("colours ",colours);
49 |
50 | local extents = { xMin = widget.Extents.xMin,
51 | yMin = widget.Extents.yMin+20.0,
52 | zMin = widget.Extents.zMin,
53 | xMax = widget.Extents.xMax,
54 | yMax = widget.Extents.yMax,
55 | zMax = widget.Extents.zMax };
56 |
57 | vertices:add({x=extents.xMin, y=extents.yMin, z=extents.zMin});
58 | vertices:add({x=extents.xMin, y=extents.yMax, z=extents.zMin});
59 | vertices:add({x=extents.xMax, y=extents.yMin, z=extents.zMin});
60 | vertices:add({x=extents.xMax, y=extents.yMax, z=extents.zMin});
61 |
62 | colours:add({red=0.0,green=1.0,blue=1.0,alpha=1.0});
63 |
64 | primitives.Mode = "TRIANGLES";
65 | primitives:add(1);
66 | primitives:add(0);
67 | primitives:add(2);
68 | primitives:add(3);
69 | primitives:add(1);
70 | primitives:add(2);
71 |
72 |
73 | local cs = 5.0;
74 | local lg = cs*1.5;
75 | local labelWidth = cs*13.0;
76 | local labelHeight = cs*1.3;
77 | local editWidth = cs*7.0;
78 | local editHeight = labelHeight;
79 | local margin = cs*0.35;
80 |
81 | local currentX = widget.Extents.xMin;
82 | local currentY = extents.yMin-margin-labelHeight;
83 |
84 | local width = cs*3.0;
85 | local x1 = currentX;
86 | local x2 = x1+width;
87 | local x3 = x2+width;
88 | local x4 = x3+width;
89 | local x5 = x4+width;
90 | local x6 = x5+width;
91 | local x7 = x6+width;
92 | local x8 = x7+width;
93 |
94 | widget:addChild(WidgetUtils.createLabel("Intensity", "Intensity", x1, currentY, x2-x1, labelHeight));
95 | widget:addChild(WidgetUtils.createLineEdit("IntensityEdit", x2, currentY, x3-x2-cs, editHeight, 1.0, 0.0, 1.0, 5));
96 | widget:addChild(WidgetUtils.createLabel("Alpha", "Alpha", x3, currentY, x3-x2, labelHeight));
97 | widget:addChild(WidgetUtils.createLineEdit("AlphaEdit", x4, currentY, x4-x3-cs, editHeight, 1.0, 0.0, 1.0, 5));
98 | widget:addChild(WidgetUtils.createLabel("Name", "Name", x5, currentY, x5-x4, labelHeight));
99 | widget:addChild(WidgetUtils.createLineEdit("NameEdit", x6, currentY, x8-x6, editHeight));
100 |
101 | currentY = currentY-lg;
102 |
103 | widget:addChild(WidgetUtils.createLabel("Red", "Red", x1, currentY, x2-x1, labelHeight));
104 | widget:addChild(WidgetUtils.createLineEdit("ReadEdit", x2, currentY, x3-x2-cs, editHeight, 1.0, 0.0, 255.0, 5));
105 | widget:addChild(WidgetUtils.createLabel("Green", "Green", x3, currentY, x4-x3, labelHeight));
106 | widget:addChild(WidgetUtils.createLineEdit("GreenEdit", x4, currentY, x5-x4-cs, editHeight, 1.0, 0.0, 255.0, 5));
107 | widget:addChild(WidgetUtils.createLabel("Blue", "Blue", x5, currentY, x6-x5, labelHeight));
108 | widget:addChild(WidgetUtils.createLineEdit("BlueEdit", x6, currentY, x6-x5-cs, editHeight, 1.0, 0.0, 255.0, 5));
109 |
110 | local colourCB = WidgetUtils.createComboBox("ColourComboBox", x7, currentY, x8-x7, editHeight);
111 | widget:addChild(colourCB);
112 |
113 | item = new("osgUI::Item");
114 | item.Text="bone";
115 | item.Color = {r=1.0,g=1.0,b=0.0,a=1.0};
116 | colourCB.Items:add(item);
117 |
118 | item = new("osgUI::Item");
119 | item.Text="skin";
120 | item.Color = {r=1.0,g=1.0,b=1.0,a=1.0};
121 | colourCB.Items:add(item);
122 |
123 | item = new("osgUI::Item");
124 | item.Text="muscle";
125 | item.Color = {r=1.0,g=0.0,b=0.0,a=1.0};
126 | colourCB.Items:add(item);
127 |
128 |
129 |
130 |
131 |
132 | widget:createGraphicsImplementation();
133 |
134 |
135 |
136 |
137 |
138 | end
139 |
140 | return widget;
141 | end
142 |
143 |
--------------------------------------------------------------------------------
/ui/WidgetUtils.lua:
--------------------------------------------------------------------------------
1 | local WidgetUtils = {}
2 |
3 | print("---------- Setting up WidgetUtils---------------------");
4 |
5 | function WidgetUtils.createLabel (name, text, x, y, width, height)
6 |
7 | local label = new("osgUI::Label");
8 | label.Name = name;
9 | label.Extents = {xMin=x, yMin=y, zMin=0, xMax=x+width, yMax=y+height, zMax=0};
10 | label.Text = text;
11 | label.TextSettings = ts;
12 | label.AlignmentSettings = as;
13 | return label;
14 |
15 | end
16 |
17 | function WidgetUtils.createComboBox(name, x, y, width, height, ...)
18 |
19 | local cb = new("osgUI::ComboBox");
20 | cb.Name = name;
21 | cb.Extents = {xMin=x, yMin=y, zMin=0, xMax=x+width, yMax=y+height, zMax=0};
22 | cb.TextSettings = ts;
23 | cb.FrameSettings = raisedFs;
24 |
25 | local as = new("osgUI::AlignmentSettings");
26 | as.Alignment = "CENTER_CENTER";
27 |
28 | cb.AlignmentSettings = as;
29 |
30 | for i,v in ipairs({...}) do
31 | if (type(v)=="function") then
32 | print("\n\n******* FOUND FUNCTION FOR COMBOBOX *********");
33 | cb.currentIndexChanged = v;
34 | else
35 | item = new("osgUI::Item");
36 | item.Text=v;
37 | -- item.Color = {r=1.0,g=1.0,b=0.0,a=0.0};
38 | cb.Items:add(item);
39 | end
40 | end
41 |
42 | return cb;
43 |
44 | end
45 |
46 | function WidgetUtils.createButton(name, x, y, width, height, text, pressedCallback)
47 |
48 | local pb = new("osgUI::PushButton");
49 | pb.Name = name;
50 | pb.Extents = {xMin=x, yMin=y, zMin=0, xMax=x+width, yMax=y+height, zMax=0};
51 | pb.TextSettings = ts;
52 | pb.AlignmentSettings = centerAlignment;
53 | pb.FrameSettings = raisedFs;
54 | pb.Text = text;
55 |
56 | if (pressedCallback) then pb.released = pressedCallback; end
57 | return pb;
58 |
59 | end
60 |
61 | function WidgetUtils.createLineEdit(name, x, y, width, height, text, minValue, maxValue, numDecimals, returnPressedCallback, textChangedCallback, leaveCallback)
62 |
63 | local le = new("osgUI::LineEdit");
64 | le.Name = name;
65 | le.Extents = {xMin=x, yMin=y, zMin=0, xMax=x+width, yMax=y+height, zMax=0};
66 | le.TextSettings = ts;
67 | le.AlignmentSettings = as;
68 | le.FrameSettings = fs;
69 | le.Text = text;
70 |
71 | if (minValue and maxValue) then
72 | le.Validator = new("osgUI::DoubleValidator");
73 | le.Validator.Bottom = minValue;
74 | le.Validator.Top = maxValue;
75 |
76 | if (numDecimals) then
77 | le.Validator.Decimals = numDecimals;
78 | end
79 | end
80 |
81 | if (returnPressedCallback) then le.returnPressed = retrunPressedCallback; end
82 | if (textChangedCallback) then le.textChanged = textChangedCallback; end
83 | if (leaveCallback) then le.leave = leaveCallback; end
84 |
85 | return le;
86 |
87 | end
88 |
89 | return WidgetUtils;
90 |
--------------------------------------------------------------------------------