[
Edit Could a Mod please correct the spelling in the title?
Thanks.
]
Not sure what the bug is exactly here - but the behaviour is unexpected.
The code shown below attempts to use
lock object,
set screen effect and
sprite together.
set display mode desktop width(), desktop height(), 32
sync on: sync rate 60: sync
create bitmap 1, 128, 128
cls rgb(255, 0, 255)
ink rgb(255, 255, 0), 0
set text transparent
text 20, 20, "HELP"
text 20, 50, " ME!"
get image 1, 0, 0, 128, 128
text 20, 80, "PLEASE!!"
get image 3, 0, 0, 128, 128
set current bitmap 0
autocam off
position camera -150, 50, -300
point camera 0, 0, 0
make object sphere 1, 100
position object 1, 0, 0, 0
color object 1, rgb(255, 0, 255)
make object cube 2, 80
position object 2, -100, 0, 0
color object 2, rgb(0, 255, 255)
global cx#
global cy#
cx# = camera angle x()
cy# = camera angle y()
make object plain 3, 256, 256
texture object 3, 1
position object 3, -150, -100, 1500
lock object on 3
load effect "quadGreen.fx", 1, 0
set camera to image 0,2, desktop width(), desktop height()
set screen effect 1
texture screen 2
make vector4 1
set vector4 1, desktop width(), desktop height(), 0, 0
set effect constant vector 1, "ViewSize", 1
repeat
sprite 1, screen width()/2+64, screen height()/2-64, 3
positionCamera()
sync
until spacekey()
end
function positionCamera()
control camera using arrowkeys 0, 1, 0
cx# = cx# + mousemovey()*0.25: cy# = cy# + mousemovex()*0.25
rotate camera cx#, cy#, 0
endfunction
The "quadGreen.fx" shader simply masks out the red and blue colour components (so you can see the screen effect working). Here's the code:
//
// FX Effect file - QUAD
//
float2 ViewSize : ViewSize = { 640, 480 };
float4 mask = {0.0, 1.0, 0.0, 1.0};
texture background < string Name=""; >;
sampler2D background_smp = sampler_state
{
Texture = <background>;
AddressU = Clamp; AddressV = Clamp;
MinFilter = Point; MagFilter = Point; MipFilter = None;
};
struct output
{
float4 opos : POSITION;
float2 uv : TEXCOORD0;
};
output VS( float4 pos : POSITION )
{
output OUT;
OUT.uv = pos.xy * float2(0.5,-0.5) + 0.5;
// Go here for more info: http://www.sjbrown.co.uk/?article=directx_texels
float4 oPos = float4( pos.xy + float2( -1.0f/ViewSize.x, 1.0f/ViewSize.y ),0.0,1.0 );
OUT.opos = oPos;
return OUT;
}
float4 PS(output IN) : COLOR
{
return tex2D(background_smp,IN.uv) * mask;
}
technique screenquad
{
pass p0
{
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_1_1 PS();
}
}
I expected the sprite not to appear. In fact it is the only thing that appears!
If you comment out the sprite line you'll see the locked object working correctly with the screen effect. If you comment out the lock object line you'll see the sprite is ignored as expected.