Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411489 Posts in 69377 Topics- by 58433 Members - Latest Member: Bohdan_Zoshchenko

April 29, 2024, 04:42:47 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsProject Rain World
Pages: 1 ... 75 76 [77] 78 79 ... 367
Print
Author Topic: Project Rain World  (Read 1447834 times)
kruxus
Level 0
***


View Profile
« Reply #1520 on: May 02, 2014, 06:09:42 AM »

30 layer parallax sounds pretty insane. Couldn't you bake it down to 4-5 layers or something? Some depth would be lost of course but it would be better than no parallax.
Logged
JLJac
Level 10
*****



View Profile
« Reply #1521 on: May 02, 2014, 06:20:44 AM »

Hm, not really, it's an either-or situation, because the graphics consist of the 30 layers, and if I'm unable to displace them in the game I need to do it in the level editor, and I can't have two conflicting displacements or every line in the z-dimension would look jagged :/

Maybe I can make it happen through some sort of bump mapping-like shader...
Logged
dancing_dead
Level 2
**


View Profile
« Reply #1522 on: May 02, 2014, 06:28:52 AM »

separate textures really sounds like the only reasonable way to go here, and there's nothing really bad with it. 30 layers do sound a bit much, but there are people doing it in engines less fancy (Ghost Song uses 25 parallax layers + moderate amount of post-processing in Stencyl of all things)) than Unity. if it's filesize you worry about, perhaps you can store that stuff as png and decompress it at runtime or smth, not sure, how unity goes about that.

even if the filesize can't be cut down without big pain, is disk size really the thing to worry about in these times?

also, I'm sure you could still do the lookup stuff you wanted for lighting, although I'm not sure how would that work exactly. texture lookup on cpu time is expensive, but on gpu time you would have to compensate for the parallax in texture lookup, although it sounds doable.
Logged
JLJac
Level 10
*****



View Profile
« Reply #1523 on: May 02, 2014, 06:34:50 AM »

It seems like a not very elegant solution, is all... Looking at this steep parallax mapping, it looks to me like it's a fragment shader which basically does a per-pixel raytrace both from the camera to the surface and then from the surface to the light source. Maybe something like that could be done here as well? If they have the time to step back and forth like that on each pixel, what I want to do shouldn't be impossible either, right?

http://graphics.cs.brown.edu/games/SteepParallax/index.html

Logged
dancing_dead
Level 2
**


View Profile
« Reply #1524 on: May 02, 2014, 06:51:31 AM »

umm, that's parallax mapping, an effect for 3d environments. it would look seriously weird in a 2d game, it also doesn't care for light sources at all. for scrolling 2d backgrounds you want parallax scrolling.
Logged
JLJac
Level 10
*****



View Profile
« Reply #1525 on: May 02, 2014, 08:26:49 AM »

Well, it's not really a question of large sprites moving about as much as one unified terrain that's just going to be slightly displaced according to the perspective of the camera - so if we wanted it to be done properly parallax scrolling would be the solution, but I think it could very well be solved using some kind of depth map and a shader as well. I.e it's more about objects being viewed from slightly different angles rather than being moved around.

But maybe the dynamic shadows will be enough to give a sense of depth to the scenes, maybe scrolling environments aren't necessary. I'll have to go over this in my head a few times before I settle on a decision.
Logged
Chromanoid
Level 10
*****



View Profile
« Reply #1526 on: May 02, 2014, 09:01:23 AM »

You should draw the 30 layers one by one in a screen sized render target. Each layer can have multiple textures, just render them as quads (this way your levels can be as big as you want). Then draw the layers again with a custom "depth color" instead of rgb in a low-bit-per-pixel screen sized render target. Now you can do some depth effects with the information from the "depth texture" and the "color texture". You might also want to split the layer rendering in multiple steps, this way you can add some kind of depth of field effects.

If you run short of memory maybe you can use one texture for multiple textures by using each color channel for one texture.
« Last Edit: May 02, 2014, 09:11:42 AM by Chromanoid » Logged
dancing_dead
Level 2
**


View Profile
« Reply #1527 on: May 02, 2014, 09:07:22 AM »

shaders must have really blown your mind, heh. parallax scrolling is just a matter of drawing things at different coordinates, relative to the camera's position. say, you have 3 layers, background, midground, foreground, where background should move slightly slower than the midground, midground is where the player's character resides and all the action happens and foreground is some misc foliage, obscuring the view and moving faster than the midground, since it's the closest to the camera.

what you do here to achieve parallax is draw the midground at x with the same delta x (factor 1) you apply to camera (say, you move the camera 300 pixels to the right, midground moves to the right 300 pixels as well). you want background to be slower, you multiply the camera delta by a scrolling factor of, say, 0.5, and now when you move camera and the midground 300 pixels to the right, background will have moved slower and moved less - only 150 pixels, thus producing the illusion of depth. likewise, you want foreground to be faster, apply factor of 2.0 to foreground and for delta of 300 pixels, foreground will move 600 pixels, producing the impression that it's the closest to the camera.

anything more than this simple math is serious overkill for parallax scrolling, imo. especially if you want to do 30 layers of this, you want it to be as simple as possible.
Logged
JLJac
Level 10
*****



View Profile
« Reply #1528 on: May 02, 2014, 09:19:50 AM »

You should draw the 30 layers one by one in a screen sized render target. Each layer can have multiple textures, just render them as quads (this way your levels can be as big as you want). Then draw the layers again with a custom "depth color" instead of rgb in a low-bit-per-pixel screen sized render target. Now you can do some depth effects with the information from the "depth texture" and the "color texture".

If you run short of memory maybe you can use one texture for multiple textures by using each color channel for one texture.
This sounds super nice! And I don't quite understand what you mean - how does rendering as quads solve the problem with the texture being too big?

Dancing dead - Yeah I totally know how you traditionally do parallax scrolling, and that was my original plan! But when I ran into this hurdle I started thinking about the ray tracing shaders such as parallax mapping as another way to solve it, without actually storing all that data, but rather working from something like just a texture and a depth map. The parallax scrolling here isn't really distinct objects with large distances between them, but rather one single box might consist of 10 layers very close to each other, making it more of a voxel solution. So I though maybe I could fake that effect without doing parallax proper. Like, just bending the edges of stuff a little to fake some shift in angle, like this:

Logged
Chromanoid
Level 10
*****



View Profile
« Reply #1529 on: May 02, 2014, 09:27:38 AM »

This sounds super nice! And I don't quite understand what you mean - how does rendering as quads solve the problem with the texture being too big?
You can use multiple textures per layer, just like a tilemap. How many colors do you use per layer texture?

I think I now get what you want to achieve. You should be aware that it will probably loose its pixelated look when you use such 3D effects. Why exactly do you want to do this? Fur is often rendered in a similar way, just layer by layer.
Logged
JLJac
Level 10
*****



View Profile
« Reply #1530 on: May 02, 2014, 09:34:16 AM »

This is already how I do it! I just bake it together to a single image. All the rain world level art is 30 bitmap layers, each of them slightly smaller than the next, that together form semi-threedimensional objects. What I want to do now is the exact same thing, just at run time - so if I manage to do it it'll supposedly look the same, just moving.

Each layer texture has only a few colors, to indicate what color to grab from a palette. Maybe 6 colors all in all, including white which is treated as transparent. What's a tilemap? Can it help me?
Logged
Chromanoid
Level 10
*****



View Profile
« Reply #1531 on: May 02, 2014, 09:46:47 AM »

Why don't you split you big image into smaller ones?
World 30x9000x9000
becomes
World NW 30x3000x3000World N 30x3000x3000World NE 30x3000x3000
World W 30x3000x3000World C 30x3000x3000World E 30x3000x3000
World SW 30x3000x3000World S 30x3000x3000World SE 30x3000x3000

If you have such few colors per texture it might be possible to use a texture format like https://docs.unity3d.com/Documentation/ScriptReference/TextureFormat.RGB565.html and storing in each channel your color indexes. This way you can save much memory (3 textures per RGB565 texture).

Here is a tilemap editor that should illustrate how a tilemap works (you probably know what it is when you see it): http://elias-schuett.de/git/Online-Tile-Map-Editor/ Just imagine unique non-repetitive tiles for your case.
« Last Edit: May 02, 2014, 10:02:52 AM by Chromanoid » Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #1532 on: May 02, 2014, 10:02:40 AM »

@jljac
WTF ate you doing? It's like you are both over designing and overkilling shader ....

- First parallax mapping is for 3D perspective, if your game is a 2D projected game it's overkill, there is no perspective, therefore the parallax is trivial.
- Is your game using tile in any shape or form? You can create a tile atlas ans use an index texture to map it and reduce the size (without filtering). For exemple let say you have 256 tiles of 32² sized tiles, you store the tile in an atlas, index them by constraining uv to 32 pixel sizes increments, then using the index map to reference each tile by having the texture scale to 32px per texel and using the color to offset the tile UV by 32 increments from the atlas.

- You don't have to put everything in a single shader, that's insane. You can use many screen aligned quad with the same shader and different texture. Plus unity allow shadow casting which would do the jobs.

- Always research what other people have done before ... This is pre 2D implementation from unity, watch and listen carefully, they give some basics:



Logged

Sebioff
Level 1
*



View Profile
« Reply #1533 on: May 02, 2014, 10:46:35 AM »

Who, Me? My understanding of GPUs is limited, but wouldn't drawing 30 screen-sized textures be pretty bad performance-wise due to overdraw? Plus they're so big the GPU couldn't keep them in memory anyways and would have to constantly upload and switch between them which would be even worse considering how huge and many they are?
Logged

Current devlog: Parkitect, a theme park simulation, currently on Kickstarter | Twitter
JLJac
Level 10
*****



View Profile
« Reply #1534 on: May 02, 2014, 11:25:02 AM »

  Cheesy hahaha ok you guys are right, I've gone a bit overboard with this. I had a very particular vision, and an idea of how to make that happen, and when it didnt work I got a bit obsessed with making it work. I'll just look into other options, such as pre-rendering a few screen positions and switching between them with hard cuts. Don't worry, I've not become crazy obsessed with shaders and I won't mess up the game hehe Tongue
Logged
Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #1535 on: May 02, 2014, 12:50:18 PM »

I'm not saying it's not feasible, just complicated, the easiest way I can think of is just going 3D, merging all of the bitmaps into one big mesh and multiplying it by a perspective matrix and your world matrix, that should do the trick

How about 30 quads... Now that I think of it, how about just interpolating between two images, one at the left border and one at the right border maybe using a depth buffer to find the pixel at said position

Edit, not on my main rig, I may be able to try it a bit later on
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #1536 on: May 02, 2014, 01:08:03 PM »

Why the hell he need a multiplication matrix? Each layer is a depth therefore just scaling speed linearly according to the encoded depth of the plane is enough. Still overkill.
Logged

dancing_dead
Level 2
**


View Profile
« Reply #1537 on: May 02, 2014, 04:50:02 PM »

Why the hell he need a multiplication matrix? Each layer is a depth therefore just scaling speed linearly according to the encoded depth of the plane is enough. Still overkill.

thousand times this.

man, I never knew parallax scrolling can cause this much trouble, haha.
I just hope something good comes out of all this.
Logged
Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #1538 on: May 02, 2014, 04:59:32 PM »

Why the hell he need a multiplication matrix? Each layer is a depth therefore just scaling speed linearly according to the encoded depth of the plane is enough. Still overkill.
I swear, I'm as bad of a shaderer as can be ... please don't shoot me ...
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #1539 on: May 02, 2014, 05:37:35 PM »

@JLJac
When discussing shader it's best to provide visual example to what you want to achieve, it make it easier to break down a solution. Technically you can do everything in shader, however you might not want to do it for many reason lol.
Logged

Pages: 1 ... 75 76 [77] 78 79 ... 367
Print
Jump to:  

Theme orange-lt created by panic