how to use shadeblend?

BlitzMax Forums/BlitzMax Programming/how to use shadeblend?

Hiya,

Can't seem to find a good use for shadeblend. It looks ugly and has black borders whenever I try to use it.

I had thought lightblend was additive and shadeblend was multiplicative, but it does not seem to be.

Any example code or demos I can view of shadeblend actually being used to good effect?

Thanks!

Where's the game you were developing using popcap?

right back at you, champ

Pot, kettle...

Frying pan, Lean Mean Fat Reducing Grilling Machine...

It swings both ways doesn't i mike?

Lightblend is additive and shadeblend is either subtractive or divisive, I thought?

Also you'll have to be careful that Set Color does not add a tint to the image.

I had the same problem with my gelmap program. I wanted
a white background with black blobs, but had to settle for
the other way around because I couldn't get rid of the
rectangles around my blobs.

This isn't a glitch, is it?

If you have a rectangle around it then probably it is not `masking` the parts that are meant to be transparent.

To get around this you have to set all the pixels that you want to show as fully transparent, to black or white (can't remember which, either $000000 or $FFFFFF). These will then act as if they are `masked` at the same time as shadeblended.

If the math for shadeblend is source*dest, you should work with that math so that the pixels you want to be transparent calculate out to not change the destination.

What's the problem?
Graphics 640,480,0,60

maxd# = 30.0
For x = 0 To 63
	For y = 0 To 63
		d# = Sqr((x-32.0)*(x-32.0) + (y-32.0)*(y-32.0))/maxd
		d = d*0.5 + 0.5
		If d>1.0 Then d = 1.0
		SetColor d*255,d*255,d*255
		Plot x,y
	Next
Next
Flip

Global img:TImage = CreateImage(64,64)
GrabImage(img,0,0)
SetImageHandle img,32,32

Type lax
	Global list:TList = New TList
	
	Field x#,y#
	Field dx#,dy#
	
	Method New()
		List.AddLast Self
		x = Rnd(640)
		y = Rnd(480)
		dx = Rnd(-5,5)
		dy = Rnd(-5,5)
	End Method
	
	Function Update()
		
		SetBlend SHADEBLEND
		
		For l:lax = EachIn lax.list
			l.x = l.x + l.dx
			l.y = l.y + l.dy
			If l.x<32 And l.dx<0
				l.x = 32
				l.dx = -l.dx
			ElseIf l.x>GraphicsWidth()-32 And l.dx>0
				l.x = GraphicsWidth()-32
				l.dx = -l.dx
			EndIf

			If l.y>GraphicsHeight()-32 And l.dy>0
				l.y = GraphicsHeight()-32
				l.dy = -l.dy
				If l.dy>-1 Then l.dy = -20.0
			EndIf
			
			l.dy = l.dy + 0.4

			DrawImage img,l.x,l.y
		Next
		
	EndFunction
	
End Type

For i = 0 To 20
	New lax
Next

SetClsColor 255,255,255

Repeat
	Cls
	lax.Update()
	Flip 
Until KeyHit(KEY_ESCAPE)


Thanks fredborg. I see, it doesn't work with loaded AnimImages which have an alpha channel.

AlphaChannel only works with AlphaBlend but with none of the others.

LightBlend too.