Virtual Screen & Stencil Shadows?

Previous topic - Next topic

Hemlos

I dont know if this is exactly what youre looking for, but it is simple.
You can adjust the resolution of the spotlight too, to tweak it for more performance.


A parrallel project i made, giving a magnifier effect with the same sort of technique using poly is in discqus_magnifier.rar

More importantly, Disqus1_spotlight.rar is a test project i made giving a stencil shadow effect.

Hope this is useful, goodluck!

[attachment deleted by admin]
Bing ChatGpt is pretty smart :O

kanonet

Wow i really like Hemlos approach would have though about that way to do it, it needs a few adjustments to get it working the way you want it (and multiple lightsources, that even overlap each other), but its a really great idea.

My idea how to do it would be like Slydog suggested. Just a few thoughts about how i think it can be done:
-best way to change values is to use MEM2SPRITE, its faster than GETPIXEl etc.
-how to set alpha values is a bit hidden in the help, it should be under RGB(), but you need to look under SPRITE2MEM to find it:
rgba = bOR(RGB(r,g,b), ASL(a, 24) )
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

erico

maybe our RGB stuff could be implemented to read RGBA?

Albert

I have this test app. You can test all the alphamode settings and different types of lights.

download: https://dl.dropbox.com/u/292449/glbasic/Shadow/Shadow.zip

Zapp

#19
Quote from: Hemlos on 2012-Jun-28
I dont know if this is exactly what youre looking for, but it is simple.
You can adjust the resolution of the spotlight too, to tweak it for more performance.


A parrallel project i made, giving a magnifier effect with the same sort of technique using poly is in discqus_magnifier.rar

More importantly, Disqus1_spotlight.rar is a test project i made giving a stencil shadow effect.

Hope this is useful, goodluck!

Wow Hemlos, that might actually do it and so easily too! Thanks!

Edit: On closer examination the code falls over when you overlap spotlights, so I'll need to play with all the suggestions and see what works best.

Hatonastick

#20
The way I'd have done it (although it's probably not the most efficient way -- and might not even be possible as it's been ages since I coded anything) is this:

1) Create two work screens.
2) Colour work screen 1 black.
3) Draw all of my light sources on work screen 1. eg. white circles.  Use of various drawmodes might be required to blend light sources together if you are using gradients rather than just plain white.
4) Draw all my game graphics on work screen 2.
5) Alpha work screen 1 over work screen 2.
6) Display work screen 2.
7) Repeat.

This method, if it is possible in GLB, has some obvious drawbacks (and is a bit of a brute force approach rather than an intelligent one) but it would allow you to blend light sources.
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).

Zapp

That's essentially what I am already doing for every SHOWSCREEN

Screen 1 = World
Screen 2 = Black square with white circles for lights with gradient.

Draw Screen 1
Draw Screen 2 over Screen 1
SHOWSCREEN

The tricky part is:

1. Getting the white to not be white but rather a gradient from black to transparent
2. Maintaining 30fps on an Iphone (somehow I don't think this will be a problem)

I'm back to looking at number 1 right now after a weekend off, using all the wonderful suggestions given above.

Kind Regards,
-Zapp

Hemlos

Quote
Edit: On closer examination the code falls over when you overlap spotlights, so I'll need to play with all the suggestions and see what works best.

Hmm, you tried alphamode with it(only the poly)?
Bing ChatGpt is pretty smart :O

Zapp

Hi Hemlos,

Sorry for not replying sooner, I had to rebuild a large portion of code due to it not being flexible enough, I've just got back to the shadows and spent a few hours tinkering with your code. I must of completely misunderstood how it worked the last time, as I've played with it enough to get it to where I want it. Thanks again!

Hemlos

Awesome, cant wait to see your game in action! :good:
btw, what plaform is the game for, in the end?
Bing ChatGpt is pretty smart :O

Zapp

IOS initially, if it's popular I'll probably look at releasing it on Steam.