Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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 414 times)
0 Members and 1 Guest are viewing this topic.
Offline wessles

JGO Wizard


Medals: 65
Projects: 4
Exp: 3 years


Radirius Software Developer


« Posted 2014-04-22 02: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?

Online HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


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


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

FBOs

Offline wessles

JGO Wizard


Medals: 65
Projects: 4
Exp: 3 years


Radirius Software Developer


« Reply #2 - Posted 2014-04-22 02: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.'

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BurntPizza
« Reply #3 - Posted 2014-04-22 03: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);
}
Online HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


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


« Reply #4 - Posted 2014-04-22 03: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
« Reply #5 - Posted 2014-04-22 03: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  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!