Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Shader request

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 12th Mar 2013 13:09
Not having any experience of writing shaders, would someone be kind enough to produce me a shader that simply allows the textures to be UV shifted?

lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 12th Mar 2013 20:06
I second this. Or at least some sort of hint where to begin

My hovercraft is full of eels
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 13th Mar 2013 21:35
Since nobody tells what to do here, I'll speak.
Here you go:

Vertex shader:


Fragment shader:


The only change is in fragment shader. Namely, I've added uniform vec2 uvShift, and in texture2D I've summed uvVarying with uvShift.
If you want to, for example, scroll your texture 2 units to the right, then just set uvShift to -2,0.

Hope it's clear.

Follow me on twitter! @MotionStruct
Motion Struct blog
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 13th Mar 2013 23:46
Sir, you are a star.

Works a treat!!

lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 13th Mar 2013 23:47 Edited at: 13th Mar 2013 23:47
Haha damn. I just spent the night working on this too

http://forum.thegamecreators.com/?m=forum_view&t=201508&b=41&msg=2441096#m2441096

My hovercraft is full of eels
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 14th Mar 2013 07:28 Edited at: 14th Mar 2013 07:33
Quote: "Sir, you are a star."


You're welcome

It was actually very, very easy.

PS.
Why not use SetSpriteUVOffset ?

Follow me on twitter! @MotionStruct
Motion Struct blog
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 14th Mar 2013 10:48
It's for a 3d primitive

kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 14th Mar 2013 15:54
Alright, good to know

Follow me on twitter! @MotionStruct
Motion Struct blog
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Mar 2013 18:29 Edited at: 14th Mar 2013 18:30
Why do you do it in the pixel shader?

It should be done in the vertex shader.

An object that is 256x256 in size and use the same screen space as its size.
So do you do the simple calculation 65536 times each time its drawn.

But if you do it on an object with 2 vertexes and in the vertex shader so is this done 2 times and do the same thing.

Anything that can be done in the vertex shader should be done there.

But there is simply alot that have to be done in the fragment shader.

Shaders are very slow on mobiles
Thats why iam many times writing! anything that can be done in the vertex do it there

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 14th Mar 2013 19:05
Mine is done with vertex. Simply play with setShaderConstantByName(myShader, "startuv", startuvX#, startuvY#, 0, 0); to get desired results

My hovercraft is full of eels
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Mar 2013 19:15
Quote: "Mine is done with vertex. Simply play with setShaderConstantByName(myShader, "startuv", startuvX#, startuvY#, 0, 0); to get desired results"

Looked at your shaders and thanks for sharing with the others
Did you get yours to work on mobiles as i posted an sample there that works.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 14th Mar 2013 19:44
That was more aimed at nz0

My hovercraft is full of eels
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 14th Mar 2013 22:50 Edited at: 14th Mar 2013 22:52
Cliff Mellangard 3DEGS, that's right. Fixed:

Vertex


Fragment


Althrough sum operation is barely slowing down anything even when used in huge amounts.

Follow me on twitter! @MotionStruct
Motion Struct blog

Login to post a reply

Server time is: 2024-11-24 09:36:02
Your offset time is: 2024-11-24 09:36:02