@Bengismo, I still don't get it.
My video on the plane is not seen anymore.
// Project: vidmasktest
// Created: 2018-10-27
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "vidmasktest" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 300, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
testvid = LoadVideo("Kerkerschrei_512x448_c_FL.mp4")
PlayVideoToImage(1)
//vidspr = CreateSprite(1)
vidmaskshader = LoadShader("standard2D.vs", "alphavid.ps")
SetShaderConstantByName(vidmaskshader , "_cutoff_level",0.1,0,0,0)
//SetSpriteShader(vidspr,vidmaskshader)
//SetSpriteDepth(vidspr,1)
obj = CreateObjectCylinder(40,12,8)
SetObjectRotation(obj,0,-75,0)
SetObjectPosition(obj,25,0,0)
SetObjectImage(obj,testvid,0)
SetCameraPosition(1, 0, 20, -100)
SetCameraLookat(1,0,20,0,0)
obj2 = CreateObjectPlane(60,60)
SetObjectRotation(obj2, 0,0,0)
SetObjectPosition(obj2,-10,0,0)
SetObjectImage(obj2, testvid,0)
SetObjectShader(obj2, vidmaskshader)
SetObjectAlphaMask(obj,1)
//SetObjectShader(obj, vidmaskshader)
//SetObjectTransparency(obj2,1)
//SetSpriteTransparency(vidspr,1)
// some random background stuff
for t = 1 to 50
CreateSprite(t+1,CreateImageColor(random2(0,255),random2(0,255),random(0,255),255))
SetSpriteSize(t+1,random2(30,200),random(30,200))
SetSpritePosition(t+1,random2(0,800),random(0,600))
SetSpriteDepth(t+1,5000+t)
next t
sync()
do
Print( ScreenFPS() )
Sync()
if GetVideoPlaying()
else
PlayVideoToImage(obj)
endif
loop
Shaders:
"Standard2D.vs"
attribute highp vec4 position;
attribute mediump vec4 color;
attribute mediump vec2 uv;
varying mediump vec2 uvVarying;
varying mediump vec4 colorVarying;
uniform highp mat4 agk_Ortho;
void main()
{
gl_Position = agk_Ortho * position;
uvVarying = uv;
colorVarying = color;
}
"alphavid.ps"
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
// constant values sent through from AGK code.
uniform sampler2D texture0;
uniform float _cutoff_level;
varying vec2 uvVarying; // uv
varying vec4 colorVarying;
void main()
{
gl_FragColor = texture2D(texture0, uvVarying) * colorVarying;
if ((gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) <= (_cutoff_level * 3.0)) gl_FragColor.a = (((gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0) / _cutoff_level);
}
I tried the shaders from the help, but most of them promted me with an error. The only one, that I got to work, is the one, I posted here.