Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (595)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Screen deformation with shaders?  (Read 697 times)
0 Members and 1 Guest are viewing this topic.
Offline wessles

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years


Enthusiast of amusement. Lover of code.


« Posted 2014-04-22 00:08:00 »

I would like to create a shader that just messes with the screen. The problem is, I only know how to move individual pixels from the vertex shader. How might I stretch them?

Check out my twitter to hear more about RFLEX. My Twitter
Offline HeroesGraveDev

JGO Kernel


Medals: 359
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #1 - Posted 2014-04-22 00:13:49 »

FBOs

Offline wessles

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years


Enthusiast of amusement. Lover of code.


« Reply #2 - Posted 2014-04-22 00:51:44 »

Thanks! I had no idea these existed  Tongue. My only problem now is that I cannot figure out how to stretch the images; the page only talks about alpha things, and I couldn't find anything on google for 'deformation fbo.'

Check out my twitter to hear more about RFLEX. My Twitter
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 415
Exp: 6 years



« Reply #3 - Posted 2014-04-22 01:02:33 »

Deformation is just mapping coordinates with a function other than
(x1, y1) = (x0, y0)


Throw this into ShaderToy with some texture loaded in iChannel0:

1  
2  
3  
4  
5  
6  
7  
void main(void)
{
   vec2 uv = gl_FragCoord.xy / iResolution.xy;
   float distFromCenter = distance(uv, vec2(.5));
   uv *= (sin(iGlobalTime) / 2. + 1.) * distFromCenter;
   gl_FragColor = texture2D(iChannel0, uv);
}


Edit: Another, more "stretchy" example: (adds to UV instead of multiply)

1  
2  
3  
4  
5  
6  
void main(void)
{
   vec2 uv = gl_FragCoord.xy / iResolution.xy;
   uv += distance(uv, vec2(.5)) * (sin(iGlobalTime)/4.+.25);
   gl_FragColor = texture2D(iChannel0, uv);
}
Offline HeroesGraveDev

JGO Kernel


Medals: 359
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #4 - Posted 2014-04-22 01:02:40 »

If you use the techniques described here to get the coordinates of the screen, then you can just warp the texture coordinates accordingly.

Offline BurntPizza

« JGO Bitwise Duke »


Medals: 415
Exp: 6 years



« Reply #5 - Posted 2014-04-22 01:19:47 »

You got me playing with shadertoy again, but I got one that mimics 3D camera movement:

1  
2  
3  
4  
5  
6  
void main(void)
{
   vec2 uv = gl_FragCoord.xy / iResolution.xy;
   uv += (sin(iGlobalTime)/2.+.5) * dot(uv, vec2(.5));
   gl_FragColor = texture2D(iChannel0, uv);
}


Neat.

Change the multiply to a divide and see what happens.

Just mess around until you find something you like.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
deepthought (48 views)
2015-06-30 15:39:44

deepthought (55 views)
2015-06-30 15:39:09

deepthought (65 views)
2015-06-30 15:36:52

Za\'Anzabar (42 views)
2015-06-29 05:44:54

TritonDreyja (49 views)
2015-06-24 17:10:40

CopyableCougar4 (48 views)
2015-06-23 00:34:45

BurntPizza (55 views)
2015-06-21 20:36:46

cookiecompiler (94 views)
2015-06-11 15:42:53

cookiecompiler (56 views)
2015-06-11 15:41:14

NegativeZero (81 views)
2015-06-11 09:49:18
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!