T O P I C R E V I E W |
spetric |
Posted - Mar 06 2015 : 16:09:22 Hi,
I'm currently working on some shadow casting code that can cast perspective shadow with possibility of shadow folding. Of course, demo and source code will available.
As I'm using ImageProc's PerspectiveDraw method, I have some questions (prorably more to come).
Is it possible to reverse alphamin and aphamax, so that beginning of shadow is less transparent, and ending shadow is more transparent? Here is an example:
As you may see, shadow transparency should be inverted, but I don't know how to achieve that. Note: this is shadow casting with folding=1. Program has a parameter which produces more folding lines, i.e. shadow can make a step on the pavement and step on the wall.
The second question is: is it possible to automatically calculate shadow x, and y offset with respect to selection feather value? Here is an example with alphamin=aplhamax=-1:
As you can see, starting position of shadow must be adjusted. I have set two edit fields for controlling offset, but it would be nice to calculate them automatically. Any clue?
TIA, Siniša |
7 L A T E S T R E P L I E S (Newest First) |
xequte |
Posted - Mar 09 2015 : 20:42:28 Hi Sinisa
Nice work, the demo is really cool.
I did have a look at the source to see why it is skipping lines. It looked like it should be a simple case of failing to include a -1 or +1, but i could not find any such deficit.
Unfortunately my C++ skills are not good enough for me to debug better.
It's possible there are some quirks in PerspectiveDraw that require it to be slightly overdrawn, but that code predates me.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
spetric |
Posted - Mar 09 2015 : 17:08:16 An example, where only part of lines are missing from shadow. Maybe to adjust perspective quadrangle?
This is a nine fold shadow, cast on the stairs. Some shadow pixels are missing (dashed line occur). |
spetric |
Posted - Mar 09 2015 : 16:49:35 Oh well,
I have uploaded the new version:
attach/spetric/201539164127_shadow_caster_distrib.zip 5092.06 KB
1. Implemented methods to deal with lines position. 2. Bug with selecting grips fixed (wrong positions). 3. Possibility to show/hide ray lines (perspective lines) added. 4. Possibility to show/hide full quadrangle lines. 5. Possibility to select selection type (right-click on image area). 6. Possibility to disable section from shadowing (check list). 7. Example with text added: magic wand with shift click to select letters.
Disabling section comes handy when you want cast shadow on the wall and behind the wall is a sky. As we don't want to cast shadow on the sky, we can exclude, let's say final section from casting shadow, so that only partial shadow is casted.
Example with letters (with multiple narrow sections/stripes) casts problematic shadow (missing lines).
|
spetric |
Posted - Mar 09 2015 : 16:28:14 Hi,
I would like to upload newest version of program. Is it possible to upload it on the same URL (replace it)?
I have added selection choose (from pop-up menu - right click on image) and some other stuff. However, there is a problem with narrow stripes perspective warping (PerspectiveDraw method). Folding line is missing from shadow.
When stripes (in original rectangle) are wider, problem does not occur. If someone has a nerve to inspect the code, I would be much obliged. The suspect peace of code is in SpeedButton5Click event.
Thanks, Siniša
P.S. Oh yes, there is reuse option for uploading, sorry. |
spetric |
Posted - Mar 09 2015 : 03:22:31 Thanks Nigel,
Sorry, I built it with dynamic RTLs. Now I made a new built and test it on "barebone" virtual PC and it works Ok. In next version I'll add a check box to show/hide "perspective rays", i.e. lines that connect source rectangles (sectors) points to respective quadrangle points, for easier visualisation.
Also, I'll add a various selection types.
BTW, Is it possible to replace current upload with new one on the same URL?
Thanks, Siniša
P.S. I will also add possibility of loading previously stored selections, so that user can create selection in some other program and use it for shadow casting. Another example (I saw this trick somewhere on the web and tried to mimic it):
In other program, selection is created from transparent png image (dog). Selection is saved. Dog was merged with background. Currently, I have replace image and selection in example directory with new image and selection, as current shadow program does not have possibility of loading selection (only example selection). |
xequte |
Posted - Mar 08 2015 : 19:40:51 Wow, Sinisa, you do some very cool stuff!
AlphaMin/Max of PerspectiveDraw do not refer to starting and ending alpha values, but rather a max and minimum value for the existing alpha.
Anyway, I see from your demo code (could not actually run the exe because of a missing DLL) that you resolved the issue with an alpha gradient which is the best way anyway.
Also, FYI, TIEBitmap and TImageEnProc will both include FeatherAlphaEdges methods in next weeks update.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
spetric |
Posted - Mar 06 2015 : 17:38:32 Here is how it looks like (still a raw code). Just to solve transparency problem. I really don't know how to adjust transparency in PerspectiveDraw method.
As you may notice, the blue rectangle, surrounding woman's body is divided into sections. Each section maps to respective "perspective" section, so the shadow can be "folded" to adjust itself to background (road, pavement, wall).
Yellow rectangles are used to perform "perspective" line stretching and rotating, so that arbitrary quadrangle can be obtained. |
|
|