[SOLVED] Mirror effect problem

O Ilusionista

Captain 100K
Hi guys, I have an issue with Mirror effect (I never handled it perfectly) and I need some help

This is how my stage is setup:
rQd04RW.png


This is the code:

background data/bgs/Zlevel0/newsky.png
bglayer data/bgs/Zlevel0/fmirror.png 0 1 0 -5 0 0 1 1 1 0 0 0 0 0 0
water data/bgs/porto/pagua2.gif  3
panel data/bgs/Zlevel0/street_floor.png none data/bgs/Zlevel0/mirror.png
panel data/bgs/Zlevel0/fmirror.png none none

Which works...but not the way I want:
gghf3Jh.png

(the reflect need to be only at the windows).

But I am having some issues with the transparencies and other stuff
J6R8OCX.png


So, I have some questions regarding this:

1)- why the WATER doesn't shows?

2) I see PANEL with 3 options (in red, green and blue). The red is the normal, the green is neon, and the blue is the screen. There is a way to make the reflect less intense? If I put a brighter color, it starts to be visible.

3) Since Mirror works between BACKGROUND and the first PANEL, I had to use a BGLAYER to not make the windows transparent (or we would see the sky there). But BGLAYER isn't affected by quakes, and its kinda weird. There is any other solution? Maybe spawn this layer as a PANEL ENTITY?

4) To avoid the reflection in the sky, should I use another bglayer with the newsky.png to cover that area?

5) Why I have to use a PANEL with all the graphics (and without any holes from mirror) after all panels (fmirror.png in the image above)?

Thanks
 
yeah, I discovered the bglayer/fglayer/layer (and mirror) is kinda broken.

Even If I set the specific Z position of the layers (which works), when I walk in X axis, some of the layers just exchange position, and this makes no sense at all, because X axis and Z axis are different animals.

I don't like the normal mirror behaviour, the reflection is too strong (its too crystal clear) and this happens just in certain type of glass X specific ammount of light. In all other cases, the reflection should have a alpha transparency.

To simulate this, I am using a bglayer with alpha, so it will be over the reflection (which happens in the background, as the manual says). I think I will need to change it to a Panel entity and set its layer manually.
 
It wasn't me either - not sure who else could have done them (the layers). I can check the source, though it probably doesn't matter. Fixing them is the important part.

DC
 
If we could add ALPHA in the mirroed image it would solve all my problems.
Dunno why, but the reflected image is swifted 1 px behind, just showing the shadows. When I use a move with scripted velocity, the the reflection is back. If I walk more to one side to another, the reflection appears again.

its just...weird.
 
I decided to remove the effect - its broken beyond rendemption.
I tried to use just a background and a panel, and the reflection just vanish while I walk
k9VmU1Q.png


I tried with version 3921, 3947 and newer one (I think its 4055). Its broken in each one.

This is something that the authors could take a look once they have time, because its a bug.
 
Damon Caskey said:
It wasn't me either - not sure who else could have done them (the layers). I can check the source, though it probably doesn't matter. Fixing them is the important part.

The guy who did layer command is kbandressen. He's been inactive for some time even before Lavalit ceased
 
The guy who did layer command is kbandressen. He's been inactive for some time even before Lavalit ceased
wow, so this is a very old info. How it wasn't added to the manual? btw, I still need to add it.

Guys, I think I got the culprit: the custom HUD. I was testing to see if there was a issue with filenames longer than 8 characters, and I accidentally have forgot to include the HUD on the stage:
fjSpgm9.png


now with the HUD:
V4Rrkq3.png


The way I call the hud
Code:
spawn HUD_base
coords 1 2
at 0

spawn HUD_panel
coords 1 2
at 0

The hud code thenselves

Name  HUD_base
type    panel
speed  10
facing  1
setlayer 2500
noquake 0 1

Name  HUD_panel
type    panel
speed  10
facing  1
setlayer 10000
noquake 0 1

I tried to change the type to none, but doesn't works. Even if I remove the setlayer, the reflection doesn't appears.
Even if I change the COORDS to -250, I won't work.

Any ideas? I have two, but I don't think if they are good ideas:

1) use the HUD as a fglayer in each stage. The problem is - fglayers are affected by quakes
2) call the HUD sprites using drawsprite function. But this will consume way more memory, no?
 
This could be an idea (and its a nice trick), but my HUD is composed of two images. Maybe if I reduce to just one...

btw, using drawsprite function works perfectly:
dk0JCPQ.png


So the problem is with the panels.

I will try to use Naota's trick with the timeicon, so I cut the memory usage + reduce 2 entities on my mod.
 
Drawing the HUD as a sprite is a minimal load; that's pretty much what the engine does anyway. It shouldn't hurt things at all if you need to keep it two separate images.

DC
 
Thank you boss.
using bgicon works too, but since I need two images (for those sections effect on the lifebar), it won't work:
dk0JCPQ.png


but works with drawsprite:
R6iwP9r.png


in updated.c
Code:
void main(){
if(openborvariant("in_level"))
{	
void HUD = loadsprite("data/sprites/hud-base.png");
void HUD2 = loadsprite("data/sprites/hud.png");

Thanks everyone :)
drawsprite(HUD, 0, 0, 8000, -100);
drawsprite(HUD2, 0, 0, 10000, -100);
}
 
Looking at that, it appears you are loading the sprite and drawing it on every update. While drawing is pretty cheap, loading most certainly isn't. You should load once outside of update. Then in your update script, verify the sprite index and draw it if valid.

DC
 
Care to give me an example?
I tried to load the sprite outside the main() and the engine crashed.

EDIT: like this?

void HUD;
void HUD2;

if (!HUD){
HUD = loadsprite("data/sprites/hud-base.png");
}
if (!HUD2){
HUD2 = loadsprite("data/sprites/hud.png");
}

drawsprite(HUD, 0, 0, 8000, -100);
drawsprite(HUD2, 0, 0, 10000, -100);
}
 
You put can't stuff like that outside of a function unless they are pre-processor directives. That's true for pretty much every language.

What I was suggesting is to load the sprites in a one time script elsewhere. Or you can try the oncreate/ondestroy functions that were added in build 3831.

Code:
void main()
{
...
}

void oncreate()
{
    if(!getglobalvar("spritex"))
    {
        setglobalvar("spritex", loasprite("data/sprites/spritex.gif"));
    }
}

void ondestroy()
{ 
   if(getglobalvar("spritex"))
    {
        free(getglobalvar("spritex"));
        setglobalvar("spritex",  NULL());
    }
}
[code]
 
Use mine if you can - I only discovered that feature the other day and haven't tested, but it's absolutely perfect for what you're doing.

Also, IIRC sprite indexes are integers not pointers, so declare the variables as int type.

DC
 
For the HUD in doom mod I load the images in level.c  -
Code:
	setglobalvar("p1stbar", loadsprite("data/gui/stbar/stbar.png"));
	setglobalvar("starms", loadsprite("data/gui/stbar/starms.png"));
	setglobalvar("sttprcnt", loadsprite("data/gui/stbar/sttprcnt.png"));

Is this method okay?
 
Back
Top Bottom