Discuss Scratch

kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

I found this project by @banbot2: https://scratch.mit.edu/projects/705175442/ and I found it quite intriguing.
I'd like to apply this to my game that's in development rn, and I can't seem to figure out how to do so.
My project: https://scratch.mit.edu/projects/996750324/

Some things I have noticed, are that his scroll x and y variables are inverted from mine. (when you go up on mine; camera x (the scrolling variable for my project) goes up. His does the opposite, the number goes down.
That and the fact that camera x is based off of the player position and mouse position. (his is not)
I also have a different scrolling function; his map is quite small and doesn't use the costume glitch for scrolling, while mine is massive and does use that.
I find that the shadows almost want to work properly as you get closer to (0,0) but still really janky.
Any help through explanation or otherwise would be various much appreciated. Thanks!
102acrimea
Scratcher
100+ posts

Simple Shadow Rendering

Simply put, the zoom is bugging it I'm pretty sure, since if you multiply it by the zoom divided by X, it no longer is relative to the camera and becomes relative to the center of the map, if you put zoom at 0 it works just fine. You'll also need to make you shadows solid and ad layering.

You'll need to use some formulas to recenter the go to around the player rather then around the center of the map if you want to use zoom.

Last edited by 102acrimea (Feb. 8, 2025 01:35:23)

kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

102acrimea wrote:

Simply put, the zoom is bugging it I'm pretty sure, since if you multiply it by the zoom divided by X, it no longer is relative to the camera and becomes relative to the center of the map, if you put zoom at 0 it works just fine. You'll also need to make you shadows solid and ad layering.

You'll need to use some formulas to recenter the go to around the player rather then around the center of the map if you want to use zoom.
Is there anyway to determine what these formulas are? It seems as if you've found a problem, not a solution?

Last edited by kanomaster (Feb. 8, 2025 18:49:13)

kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

bump
kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

kanomaster wrote:

bump
bump
kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

kanomaster wrote:

kanomaster wrote:

bump
bump
bump
HighlaneGamingStudio
Scratcher
500+ posts

Simple Shadow Rendering

kanomaster wrote:

102acrimea wrote:

Simply put, the zoom is bugging it I'm pretty sure, since if you multiply it by the zoom divided by X, it no longer is relative to the camera and becomes relative to the center of the map, if you put zoom at 0 it works just fine. You'll also need to make you shadows solid and ad layering.

You'll need to use some formulas to recenter the go to around the player rather then around the center of the map if you want to use zoom.
Is there anyway to determine what these formulas are? It seems as if you've found a problem, not a solution?
What 102acrimea is saying is that you should go though your scripts and see what is relying on the center of the map and what is relying on the player.

Last edited by HighlaneGamingStudio (Feb. 9, 2025 00:04:54)

kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

HighlaneGamingStudio wrote:

kanomaster wrote:

102acrimea wrote:

Simply put, the zoom is bugging it I'm pretty sure, since if you multiply it by the zoom divided by X, it no longer is relative to the camera and becomes relative to the center of the map, if you put zoom at 0 it works just fine. You'll also need to make you shadows solid and ad layering.

You'll need to use some formulas to recenter the go to around the player rather then around the center of the map if you want to use zoom.
Is there anyway to determine what these formulas are? It seems as if you've found a problem, not a solution?
What 102acrimea is saying is that you should go though your scripts and see what is relying on the center of the map and what is relying on the player.
Im sorry, but that really doesn't help me? The current variables I have in the shadow sprite find the current position of the player and align it to the player. And if it isn't, what change to the formula would “rely” on the player. I appreciate you identifying the problem, but what you don't understand, is that I don't understand why the solutions I've come up with don't work. (I don't know the solution) If you could be more specific that would be helpful.
The current formula I have looks like this:
go to x: (((Clone Identification) / (100)) * (((0) - (Camera X)) * ((Zoom) / (100)))) y: (((Clone Identification) / (100)) * (((0) - (Camera Y)) * ((Zoom) / (100))))
The first part has an Clone ID that changes by 1 to cover each pixel with shadows.
(Clone Identification) / (100)
The second part:
 (((0) - (Camera X)) * ((Zoom) / (100)))
Finds the x value of the player, and then adjusts the proportion to the zoom function.

@102acrimea said that I need “formulas” to make it work properly, and I am at a loss to a different formula.
kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

bump
HighlaneGamingStudio
Scratcher
500+ posts

Simple Shadow Rendering

kanomaster wrote:

The current formula I have looks like this:
go to x: (((Clone Identification) / (100)) * (((0) - (Camera X)) * ((Zoom) / (100)))) y: (((Clone Identification) / (100)) * (((0) - (Camera Y)) * ((Zoom) / (100))))
The first part has an Clone ID that changes by 1 to cover each pixel with shadows.
(Clone Identification) / (100)
The second part:
 (((0) - (Camera X)) * ((Zoom) / (100)))
Finds the x value of the player, and then adjusts the proportion to the zoom function.

@102acrimea said that I need “formulas” to make it work properly, and I am at a loss to a different formula.
I'm going to have trouble helping you because I'm not entirely sure how the original project worked. I would highly recommend using the first 12 minutes of this for inspiration. I'm not sure how to convert the shadows in the video into the shadows you're trying to create, but I think the pen extension is part of the solution.

Last edited by HighlaneGamingStudio (Feb. 9, 2025 16:19:09)

kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

HighlaneGamingStudio wrote:

kanomaster wrote:

The current formula I have looks like this:
go to x: (((Clone Identification) / (100)) * (((0) - (Camera X)) * ((Zoom) / (100)))) y: (((Clone Identification) / (100)) * (((0) - (Camera Y)) * ((Zoom) / (100))))
The first part has an Clone ID that changes by 1 to cover each pixel with shadows.
(Clone Identification) / (100)
The second part:
 (((0) - (Camera X)) * ((Zoom) / (100)))
Finds the x value of the player, and then adjusts the proportion to the zoom function.

@102acrimea said that I need “formulas” to make it work properly, and I am at a loss to a different formula.
I'm going to have trouble helping you because I'm not entirely sure how the original project worked. I would highly recommend using the first 12 minutes of this for inspiration. I'm not sure how to convert the shadows in the video into the shadows you're trying to create, but I think the pen extension is part of the solution.
I suppose using pen would be a possible alternative, but I'm not casting light from the player, but shadows based off of the map collisions. That's entirely different. Can someone actually take a look at the project and give some specific help?

Last edited by kanomaster (Feb. 9, 2025 22:43:01)

miloszprobet
Scratcher
13 posts

Simple Shadow Rendering

kanomaster wrote:

kanomaster wrote:

kanomaster wrote:

bump
bump
bump
bump
bump
bump
bump
bump
bump
bump
bump
bump
kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

miloszprobet wrote:

kanomaster wrote:

kanomaster wrote:

kanomaster wrote:

bump
??

Last edited by kanomaster (Feb. 9, 2025 22:44:18)

kanomaster
Scratcher
100+ posts

Simple Shadow Rendering

kanomaster wrote:

HighlaneGamingStudio wrote:

kanomaster wrote:

The current formula I have looks like this:
go to x: (((Clone Identification) / (100)) * (((0) - (Camera X)) * ((Zoom) / (100)))) y: (((Clone Identification) / (100)) * (((0) - (Camera Y)) * ((Zoom) / (100))))
The first part has an Clone ID that changes by 1 to cover each pixel with shadows.
(Clone Identification) / (100)
The second part:
 (((0) - (Camera X)) * ((Zoom) / (100)))
Finds the x value of the player, and then adjusts the proportion to the zoom function.

@102acrimea said that I need “formulas” to make it work properly, and I am at a loss to a different formula.
I'm going to have trouble helping you because I'm not entirely sure how the original project worked. I would highly recommend using the first 12 minutes of this for inspiration. I'm not sure how to convert the shadows in the video into the shadows you're trying to create, but I think the pen extension is part of the solution.
I suppose using pen would be a possible alternative, but I'm not casting light from the player, but shadows based off of the map collisions. That's entirely different. Can someone actually take a look at the project and give some specific help?
bump (sigh)

Powered by DjangoBB