Kitty Corp Meow Mix Forums

Help & Tutorials => Stage Tutorials => Topic started by: Mewtwo2000 on January 13, 2011, 05:26:39 PM



Title: The shadow system for stages
Post by: Mewtwo2000 on January 13, 2011, 05:26:39 PM
Hi. Long time has passed from when I figured out a way to have shadows in custom made stages, for example imports or block-based stages.

I posted a shadow stage some time ago with the main models for you to place shadows in your stages. But I guess I never explained how they work.

Well, the shadow system consists of just an invisible model that casts shadows like most floors in official brawl stages. When these models are placed over floors without shadows, you get the shadow effect in your ground.

The standard model is just a surface centered in Y=0, that goes from -10 to 10 in the X and Z axes.

The model has 2 bones that can be used together to place the shadow in the right place. But I guess I won't explain this again. I'll just paste what I PM'd to CutterKirby64 when asked about my shadow system.

Quote
First of all, you must know that you can see the shadow models you're placing in brawlbox, but not until you enable them to be seen. If you've not done this yet, do it. Preview each MShadow model, and on the left, enable the TShadow1 texture. Now, you can see where the model will be placed.

With only this, you could place shadows accurately, but if you want to master the shadow system, you need more.

First of all, you need proper collisions. The collisions for your platforms are not perfect, they're near, but you've made them by just looking where they are. But you are the one who placed them, and you may know how big they are. With this info, you could make perfect collisions. Making perfect collisions is the same as knowing where the surface of the platform is, and this is needed to make a perfect shadow on it.

So, go to Platform01 and open the vertices folder. Inside, there are 2 elements. In any of them, you will see the Emin and Emax values. These mean which are the maxium dimensions of the model. In this case, your model goes from -10 to 10 in X, from 8 to 10 in Y, and from -20 to 20 in Z.

Now, you've animated that platform to place it somewhere. If you didn't move it, the perfect collision for the surface would be from -10,10 to 10,10. 10 is the higher value in vertical, so that's where the surface is. But you moved it, so you need to make a moved collision too. Unless you attach the collision as a separate collision object, if you were to do this, the collision would follow the model and would be always on it, whereever it is. This would be the needed thing if the platform was animated and you wanted a moving collision.

But this isn't the case, and your option was drawing the collision where the platform is. Platform01 is the right one, and the collisions you made went from (60.23403, 29.81254) to (102.4309, 29.81257). In your animation, the model has been moved and scaled. Doubled in X and Y. So, if we only thing that it's scaled, now the collision would be from -20,20 to 20,20. Now, let's apply the move. X=80. So let's add 80 to the X values. Now the collision would be from 60,20 to 100,20. Now, let's add that Y=10. The collision would be 60,30 to 100,30.

Your collision:  (60.23403, 29.81254) to (102.4309, 29.81257)
The exact one: (60, 30) to (100, 30)

As you can see, you were near to the exact, but you weren't using the proper collisions. If you're using squared blocks, you should never fail with this from now on.

Well, now lets go with shadows. The shadow models go from -10 to 10 in X, they're in Y=0 and go from -10 to 10 in Z. Also, it has 2 bones.

With the lower bone, we can change the properties of the shadow model. Let's change them, for example, to the ones in the surface of your platform. Viewing the max values, is easy to see that the surface is a square that goes from -10 to 10 in X, it's in Y=10 and goes from -20 to 20 in Z. If we move the MShadow model to Y=10.1, and double the size of Z, the shadow will fit the surface (well, it's 0.1 higher because if it was exactly where the surface is, there would be some flashing between shadow and surface).

Now, if we control the modified shadow in the same way we controled the platform, any change made to the platform will be automatically applied to the shadow. So, if we make:

NShadow-> Y=10.1, Z(size)=2
MShadow1-> X=80, Y=10, X(size)=2 and Y(size)=2

Then the shadow will be exactly on the platform.

Also, we can include the contributions of both bones, and an equivalent single bone would be like this:

X=80, Y=30.2, X(size)=2, Y(size)=2, Z(size)=2

And this, in terms of where the shadow is exactly, means that the shadow goes from 60 to 100 in X, it's in Y=30.2, and goes from -20 to 20 in Z. So, it's 0.2 higher to the surface, near enough to have a nice shadow effect without strange flashes.

Read all this more than once if you need it, and try to follow these steps in your original file. You can use the one I've sent you to compare.

The example in this quote should be good enough to help you understand things about shadow placements and even collisions in block-based stages.

Any question, just ask.


Title: Re: The shadow system for stages
Post by: SmashClash on January 13, 2011, 08:23:51 PM
Good tutorial.


Title: Re: The shadow system for stages
Post by: Quanno on January 31, 2011, 02:01:18 PM
Good tutorial! Gonna try this when I get time for it. Thanks!


Title: Re: The shadow system for stages
Post by: KTH on February 17, 2011, 06:44:02 AM
Good tutorial. Thank.


Title: Re: The shadow system for stages
Post by: ItalianStallion on February 26, 2011, 03:52:29 AM
Question. I am now working on my stage, and I imported the MShadow1 model, and the TShadow1 texture, and it worked fine.

The only problem, is that in game, the shadows blink really fast. Why does that happen?

I should probably tell you that the floor is different Stage Builder Blocks put together.


Title: Re: The shadow system for stages
Post by: Mansta8 on February 27, 2011, 05:42:06 AM
I think that's a problem with overlaping blocks in the first place. (Example: using the unresticted stage builder code, making lots of blocks overlap = flashing shadows.)
So it might have something to do with that. I'm not realy a stage maker anyway so idk. XD


Title: Re: The shadow system for stages
Post by: ItalianStallion on February 27, 2011, 07:44:37 AM
Well the problem is fixed now, and it wasn't overlapping buildings. I thought it was that at first, but it was a corrupted MShadow1 model or it just had the materials messed up or something.

Point blank, I got it to work. Thanks for trying to help though ;)


Title: Re: The shadow system for stages
Post by: CoolTrainerCore on March 09, 2011, 10:14:24 AM
Mewtwo, how do I change the direction of shadows?


Title: Re: The shadow system for stages
Post by: Mewtwo2000 on March 09, 2011, 06:02:27 PM
By editing the 0x2c and 0x30 offsets in miscdata[10]

The first one is the vertical angle, and the second one is the direction on the ground.