NewsWorksSoftwareTextBioContact
background image

OpenGL Shader for viewing alpha channel content

2007-08-08

Below is a simple shader for viewing alpha channel content of OpenGL textures in Max/Jitter.

Save as tl.alpha.view.jxs:
&lt jittershader name=" viewalpha" &gt
&lt description&gt
view content of alpha channel
&lt /description&gt
&lt param name=" tex0" type=" int" default=" 0" /&gt
&lt language name=" glsl" version=" 1.0" &gt
&lt bind param=" tex0" program=" fp" /&gt
&lt program name=" vp" type=" vertex" source=" sh.passthru.xform.vp.glsl" /&gt
&lt program name=" fp" type=" fragment" &gt
&lt ![CDATA[
//setup for single texture
varying vec2 texcoord0
uniform sampler2DRect tex0
//luma threshold
void main()
{
vec4 a = texture2DRect(tex0 texcoord0)
// output texture with alpha-mask
gl_FragColor = vec4(a.a a.a a.a 1.)
}
]]&gt
&lt /program&gt
&lt /language&gt
&lt /jittershader&gt
Save as tl.alpha.view.jxs:
#P window setfont “Sans Serif” 9.000
#P window linecount 1
#P hidden newex 241 456 60 196617 loadmess 1
#P comment 327 90 52 196617 Source
#P newex 241 500 27 196617 + 1
#P user ubumenu 241 480 75 196617 0 1 1 0
#X add apply alpha
#X add view alpha
#X prefix_set 0 0 0
#P newex 327 549 216 196617 jit.gl.slab tl.alphaview @file tl.alpha.view.jxs
#P newex 290 525 47 196617 gate 2 1
#P number 469 293 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0
#P toggle 519 292 15 0
#P flonum 651 293 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0
#P flonum 596 293 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0
#P message 596 313 54 196617 thresh $1
#P message 651 313 44 196617 fade $1
#P message 469 313 48 196617 plane $1
#P message 469 141 27 196617 stop
#P flonum 500 122 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0
#P message 500 141 42 196617 rate $1
#P message 437 141 28 196617 read
#P newex 437 174 105 196617 jit.qt.movie 320 240
#P message 519 313 70 196617 lum2alpha $1
#P newex 457 335 76 196617 prepend param
#P newex 290 584 305 196617 jit.gl.videoplane tl.alphaview @scale 1.333 1.000 1.000 @blend_enable 1
#P window linecount 2
#P newex 327 368 120 196617 jit.gl.slab tl.alphaview @file cc.alphaglue.jxs
#P window linecount 1
#P message 359 141 27 196617 stop
#P flonum 390 121 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0
#P message 390 141 42 196617 rate $1
#P message 327 141 28 196617 read
#P newex 327 174 105 196617 jit.qt.movie 320 240
#P newex 50 236 116 196617 jit.window tl.alphaview
#P newex 50 214 167 196617 jit.gl.render tl.alphaview @ortho 2
#P newex 50 170 58 196617 t b b erase
#P flonum 91 128 35 9 0.500 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0
#P toggle 50 128 15 0
#P newex 50 149 51 196617 qmetro 2
#P comment 606 390 100 196617 add alpha layer
#P user panel 307 279 414 136
#X brgb 209 211 220
#X frgb 0 0 0
#X border 0
#X rounded 0
#X shadow 0
#X done
#P comment 437 90 130 196617 Image to be used as alpha
#P window setfont “Sans Serif” 18.000
#P comment 41 26 117 196626 tl.alpha.view
#P window setfont “Sans Serif” 9.000
#P comment 40 54 244 196617 view the content of alpha channel
#P connect 6 0 5 0
#P connect 5 0 8 0
#P connect 8 0 9 0
#P fasten 8 2 9 0 103 196 55 196
#P connect 7 0 5 1
#P hidden connect 37 0 34 0
#P connect 34 0 35 0
#P fasten 35 0 32 0 246 521 295 521
#P connect 32 0 17 0
#P fasten 33 0 17 0 332 576 295 576
#P fasten 8 1 11 0 79 206 332 206
#P fasten 13 0 11 0 395 165 332 165
#P fasten 15 0 11 0 364 165 332 165
#P fasten 12 0 11 0 332 165 332 165
#P fasten 18 0 16 0 462 359 332 359
#P connect 11 0 16 0
#P connect 16 0 32 1
#P connect 32 1 33 0
#P connect 14 0 13 0
#P fasten 21 0 20 0 442 165 442 165
#P fasten 24 0 20 0 474 165 442 165
#P fasten 22 0 20 0 505 165 442 165
#P fasten 8 1 20 0 79 203 442 203
#P connect 20 0 16 1
#P fasten 27 0 18 0 601 331 462 331
#P fasten 26 0 18 0 656 331 462 331
#P fasten 25 0 18 0 474 331 462 331
#P fasten 19 0 18 0 524 331 462 331
#P connect 31 0 25 0
#P connect 23 0 22 0
#P connect 30 0 19 0
#P connect 28 0 27 0
#P connect 29 0 26 0
#P window clipboard copycount 38

Up

comments powered by Disqus

 
 
 

Creative Commons License Licensed under a Creative Commons Attribution 3.0 Norway License. Web site hosted by BEK.