Live Shading difficulties

BlitzMax Forums/BlitzMax Programming/Live Shading difficulties

BlitzProg(Posted 2009) [#1]
I'm experiencing shading for some map-based games, and i would like to do something that doesn't seem easy at all: dealing with the only buffer avaliable.

by live shading i mean that the shadings are being recalculated for each frame. It seemed easy this way.

Cls
SetBlend SOLIDBLEND
Local shade = CreateImage(...)
'greyscale circles, box or stuff, why not switching to lightblend or alphablend.
GrabImage shade,0,0

SetBlend MASKBLEND
Cls
'map drawing, with several layers of stuff

SetBlend SHADEBLEND
DrawImage shade,0,0


exept this is not efficient as grabimage for saving the screen is way too slow.

I tried using pixmaps. Grabpixmap is a lot faster, but Drawpixmap is unaffected by any blendmode! :(
I tried locking Images. Too slow!


if i had direct access to imagebuffer(shade), i'd just stick drawing things on it without worries. but this command isn't available in BlitzMax :(

Is there any "miracle" solution that can do the trick? thanks!


jkrankie(Posted 2009) [#2]
What *exactly* are you trying to do? you didn't really make that clear...

Cheers
Charlie


BlitzProg(Posted 2009) [#3]
Looks like an example will be clearer.

Copy&paste, run.

Graphics 640,480

Local x=0
Local dx=2

Local light=CreateImage(640,480)

While Not KeyDown(KEY_ESCAPE)

	
	x=x+dx
	If x<0 Or x>440 Then dx=-dx
	
	
	
	SetBlend SOLIDBLEND
	
	SetColor 55,55,55
	DrawRect 0,0,640,480
	
	For i=0 To 100
		SetColor 55+i,55+i,55+i
		DrawOval x+i,i,200-(2*i),200-(2*i)
		DrawOval (440-x)+i,280+i,200-(2*i),200-(2*i)
	Next
	
	GrabImage light,0,0
	
	
	
	
	SetBlend MASKBLEND
	
	For j=0 To 5
		For i=0 To 8
			SetColor 255,0,0
			DrawRect i*64+32,j*64+32,32,32
			SetColor 0,255,0
			DrawOval i*64+32,j*64+32,32,32
		Next
	Next
	
	
	
	
	
	
	
	
	SetBlend SHADEBLEND
	
	SetColor 255,255,255
	DrawImage light,0,0
	
	
	




	Flip

Wend
End


As you may see, it's slow, because of grabimage. Any way to reproduce the same effect without slowdown?

Note, if not in debugmode you may not notice anything. But still, don't tell me to turn debug mode off because of this... :P


Zeke(Posted 2009) [#4]
try this: http://www.blitzmax.com/Community/posts.php?topic=49403#550016


BlitzProg(Posted 2009) [#5]
^lucky post just above
I wouldn't have expected more than this, this is spot on! thanks a lot. (the scaling blur does exactly everything i need on top of this, that's truely insane!)


ImaginaryHuman(Posted 2009) [#6]
It's a little blocky, not much reason why you couldn't draw at a higher resolution.