Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411667 Posts in 69397 Topics- by 58452 Members - Latest Member: homina

May 16, 2024, 09:45:40 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsProject Rain World
Pages: 1 ... 77 78 [79] 80 81 ... 367
Print
Author Topic: Project Rain World  (Read 1454307 times)
JLJac
Level 10
*****



View Profile
« Reply #1560 on: May 06, 2014, 11:21:47 AM »

All the more reason to fight to keep the pixels pure then haha! I'm a bit more worried that I've heard you shouldn't use if statements in shaders, and the decoding of this system is obviously going to be a huge knot of ifs and modulus operations...
Logged
Chromanoid
Level 10
*****



View Profile
« Reply #1561 on: May 06, 2014, 11:27:21 AM »

Just imagine all cases of the conditions are processed, this is the worst case scenario and afaik usually the norm for older GPUs.
« Last Edit: May 06, 2014, 11:34:00 AM by Chromanoid » Logged
Christian
Level 10
*****



View Profile WWW
« Reply #1562 on: May 06, 2014, 01:30:04 PM »

In this GDC 2014 talk by David Rosen, a dev working on Wolfire's Overgrowth, he's discussing procedural animations in indie games and talks about Rain World around the 20 minute mark. The whole talk is really interesting though
Logged

Visit Indie Game Enthusiast or follow me @IG_Enthusiast to learn about the best new and upcoming indie games!
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #1563 on: May 06, 2014, 02:29:41 PM »

@JLJac
NO that's okay, it's a common technique actually used in some game, but since it's an uber optimisation that sit not well with artist friendly workflow it's widely used to not complexify the process:

http://teckartist.com/?p=26

Code:
int bands = 4; //this is the number of value bands to split the range
float range = 1.0 / bands; //range of each band

float ReRamp(float val, int band)
//val is the pixel's luminance, band is the... band [index]
{
  float minRange = range * band;
  float maxRange = range * (band + 1);
  float c = min(saturate(val - minRange) / (maxRange - minRange), 1);
  c = c >= 1?0:c;
  return c;
}

In this code it divide equally the channel range to store more data, but it can be a good start for custom packing, similar techniques is also used to encode HDR bmp in the RGBM format.

applied to a whole 3D scenes
http://www.polycount.com/forum/showthread.php?t=89682

Other similar technique you can take inspiration from:
http://artisaverb.info/DitchingDiffuse.html

http://technical-eden.blogspot.fr/2012/01/gradient-mapping-awesome-way-to-get.html

Combine at will

Complementary data
http://www.stuartdenman.com/improved-color-blending/

edit:
Also you must know about color compression and also you can encode in RGBA Wink
http://www.fsdeveloper.com/wiki/index.php?title=DXT_compression_explained


edit2
http://filipangelison.com/?page_id=274
« Last Edit: May 06, 2014, 03:15:37 PM by Gimym JIMBERT » Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #1564 on: May 06, 2014, 02:49:05 PM »

Also if branch DOES NOT save time in shader, a shader would compute all branch and discard it, you don't save any time. To understand shader you must understand that shader are highly parallel processing, they are bad at stuff sequential processing excel therefore optimization from it don't work.
« Last Edit: May 06, 2014, 02:57:39 PM by Gimym JIMBERT » Logged

jamesprimate
Level 10
*****


wave emoji


View Profile WWW
« Reply #1565 on: May 07, 2014, 01:55:50 AM »

In this GDC 2014 talk by David Rosen, a dev working on Wolfire's Overgrowth, he's discussing procedural animations in indie games and talks about Rain World around the 20 minute mark. The whole talk is really interesting though

ah yes! thanks for the link. David contacted us a while back to ask questions and if we'd be cool with him using RW as an example. which is awesome because that was a fantastic presentation, I learned a lot. Not as much as from Gimym's links though Grin
Logged

JLJac
Level 10
*****



View Profile
« Reply #1566 on: May 07, 2014, 02:27:52 AM »

Awesome! Thank you, Jimbert Grin My implementation is actually very similar to those gradient maps, except my input is ... what would it be, 7 dimensional, and the output is a coordinate on a 2D palette texture rather than an 1-dimensional gradient.

I've had pretty good luck today, and got quite far with my deciphering algorithm! Then I ran into a weird error. I hit my instruction limit, which was kind of due to happen because the basic settings only allow for 64 instructions.

No biggie, let's just upgrade to shader model 3.0, right? That's like, 2003 graphic cards or something, people's PC's will be able to handle that.

No can do. For some reason Unity says "no subshaders can run at this graphics card" if I target the shader at anything higher than 2.0. Unity refuses to believe anything else than that my graphics card is from 2002.

I've searched Unity's settings for the "dude I bought my computer 2 months ago it's not ten years old"-checkbox, but can't seem to find it. There's an option to emulate for 3.0, in order to try the compability with older machines, but since Unity is adamant that my machine is even older than those older machines, no luck.

Any tips?

Found a command SystemInfo.graphicsShaderLevel in Unity, and this claims that I have 3.0, which is worrying for every reason. First, if I have 3.0 it should work, right? Second, I don't have 3.0, I'm supposed to have 5.0! Fun times!
« Last Edit: May 07, 2014, 03:51:22 AM by JLJac » Logged
Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #1567 on: May 07, 2014, 03:54:54 AM »

Download the latest drivers
You may not have a dedicated graphics card
Logged
JLJac
Level 10
*****



View Profile
« Reply #1568 on: May 07, 2014, 04:35:29 AM »

James solved it.... Hahahahahaha! 

I was looking for high tech solutions all over, and the answer was this: Go to the "We now feature directx 11" page on unity.com - acquire the information that in order for complex shaders to work, you need to tick the "use directx 11" box in the unity editor. Tick the "use directx 11" box.
Cheesy Facepalm Tired Tears of Joy Cry Epileptic
Logged
Sebioff
Level 1
*



View Profile
« Reply #1569 on: May 07, 2014, 05:15:47 AM »

Hahaha yeah, I had a couple of "forgot to check some checkbox somewhere" experiences with Unity as well. Glad you figured it out, looking forward to hear how it works Smiley
Logged

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


The archivest master, leader of all documents


View Profile
« Reply #1570 on: May 07, 2014, 08:09:06 AM »

But doesn't that mean people with older computer would not be able to play the game? ... like me? Who, Me?
Or you do it for experimentation purpose only and will have a tiered graphical set up?

Well the 2D gradient is in the link for variety map (filipangelison)
Logged

JLJac
Level 10
*****



View Profile
« Reply #1571 on: May 07, 2014, 08:55:23 AM »

I'll write a fallback shader, so no worries Smiley
Logged
JLJac
Level 10
*****



View Profile
« Reply #1572 on: May 07, 2014, 11:40:50 AM »

Update 134
A very good day!

I got a good chunk of my shader done - there is still work (dynamic palettes, effect colors, the rainbow effect, etc etc) but now I know that the basics work.

The level editor encodes an image looking as such:



This in turn is deciphered by the shader, which can tell things such as depth, whether or not the pixel is lit, and all that stuff I mentioned in the last post.



The shader is also fed another texture, a palette texture which is very small. In the future I think it might be cool to be able to interpolate between different palettes, to do cool effects such as darkening as the rain comes, lightning and the such.



This one has a little bit of random static in it - that will not likely stay, I'm just having fun.

And, finally, I got my dynamic shadows to work!



Woooho!

I have it working with the normal color scheme as well, just used this wacky palette so you'd see clearer. The principle is super simple: each pixel has a depth value (red in the mockup). If it's lit, it looks at a certain pixel to check if it's occupied by a sprite. Which pixel it looks at is determined by stepping backwards in the light direction.

So say that I'm a lit pixel that's at a depth of 5. Then I step, for simplicity's sake, 5 pixels to the left and upwards, and ask that pixel if it has something rendered on it. If true, I become shadowed. If I'm at a greater depth, I go more steps up and to the left.

It's unpolished - for example it doesn't take notice of perspective yet. If the shadows are cast straight backwards, you'd want them to stretch towards the center of the screen according to perspective, right, and that's not factored in yet. But I'm getting there!

Super exciting to see that it works!
Logged
Franklin's Ghost
Level 10
*****



View Profile WWW
« Reply #1573 on: May 07, 2014, 03:18:52 PM »

Really impressed at how fast you're transitioning to this new engine and working with shaders.
Logged

jamesprimate
Level 10
*****


wave emoji


View Profile WWW
« Reply #1574 on: May 07, 2014, 04:41:11 PM »

 
Update 134
A very good day!

 Tears of Joy
Logged

Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #1575 on: May 07, 2014, 05:21:37 PM »

Come on Jack, you can du it,
Shaders no match for slugcat
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #1576 on: May 07, 2014, 05:27:20 PM »

Huh .... it's getting impressive Who, Me?
Logged

Vovosunt
Level 0
**


Lolcat


View Profile
« Reply #1577 on: May 07, 2014, 05:30:36 PM »

So you're basically raytracing (technically raymarching).
Well that is... hard on the graphics card.  Durr...?

I have to agree with Jimbert about using ramps.
In this case I would recommend using a gradient Texture/Textures like so(semi preudocode):
Code:
sampler2D colorRamp;
//Color Ramp has 4 Gradients:
//1)Depth + low/mid/high/lit gradient (v coord 0)
//2 and 3)Level Effect gradients 1 and 2 (v coords 0.25 and 0.5)
//4) Rainbow Ramp (v coord 0.75)
sampler2D level;
main
{
vec3 levelPixelInfo = tex2D(level,UV.xy).rgb;
vec3 mainColor = tex2d(colorRamp,vec2(levelPixelInfo.r,0)).rgb; // get mainColor

//returns either 0 or 1 for gradient 1 or 2 and 2 for rainbowEffect;
float isRainbow = floor(levelPixelInfo.g*3);
vec2 effectUv = vec2(levelPixelInfo.g * 3, isRainbow*0.25 +0.25);
vec3 effectColor = tex2d(colorRamp,effectUv).rgb;

//mod makes the rainbow change in in 10 second loops
vec2 rainbowUv = vec2(modf(time,10),0.75);
vec3 rainbowColor = tex2d(colorRamp,rainbowUv).rgb;

//mixes final effect color; floor returns either 0 if isRainbow < 3 or 1 if is Rainbow > 3
vec3 finalEffectColor = mix(effectColor,rainbowColor,floor(isRainbow/3));
FinalColor = mix(mainColor, finalEffectColor,levelPixelInfo.b);
}
Logged

JLJac
Level 10
*****



View Profile
« Reply #1578 on: May 07, 2014, 10:42:12 PM »

No, I'm actually not raymarching, as I don't do any step-by-step checking of different depths. Instead the procedure has only two steps:

1. Check the pixel and get its info, which is color info but also depth (already encoded by the level editor).

2. Use the depth to check for where in the grab texture to look for objects that shadow this pixel. The greater the depth, the more up/left we check.

Effect: If you are in front of a wall, there will be a shadow on the wall. The further back the wall is, the further down/right the shadow will appear.

Your pseudo code is super helpful, by reading it I see a lot of things I can optimize in my shader! It's impressive that you manage to keep away from if-statements like that!

My texture looks like this:



So that's the same basic idea, right?
Logged
dancing_dead
Level 2
**


View Profile
« Reply #1579 on: May 08, 2014, 12:34:10 AM »

hats off to you, Joar, for coming up with original and interesting solutions!

lookin' very good Smiley
Logged
Pages: 1 ... 77 78 [79] 80 81 ... 367
Print
Jump to:  

Theme orange-lt created by panic