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 / Any info on writing agk shaders?

Author
Message
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Nov 2012 17:13 Edited at: 4th Jul 2013 20:53
Samsung Galxy s3 or other mali 400 gpu chippset devices.
If you have problems with agk shaders read this.
http://forum.thegamecreators.com/?m=forum_view&t=206452&b=41

Nivida tegra 2 devices demands that you pass in your own values from agk thru the vertex shader first and then to the fragment/pixel shader with an varying.
This is if you do your own fog shader etc.
And want to pass in an min and max value to the fragment shader.
-------------------------------------------------------------------

Great online resource with open glshaders.

http://www.iquilezles.org/apps/shadertoy/index.html
-------------------------------------------------------------------

If you get slow performance with your shader on mobiles test this.

This code part should be at the top of your pixel shader.


Now do you wonder wath this code does ?
It simply first checks if the device is an mobile device.
then does it check if the device supports high precicion calculations or not.
And if it dosent so does it set it to medium precision.
I only tested this on some parts of my segments on an test map and i got an increase in 10 fps by doing this.
-------------------------------------------------------------------
-------------------------------------------------------------------


And the point light shader with 108 beta 3 do you also nead to activate the directional light.

The shaders under here have not bin tested on android!!!!

Working on some kind of bump fx.

vertex shader for the pixel shaders with bump map and tiling.

Pixel frag. Here is the one with an bump map.


This shader have 1 directional light,1 point light and ambient lighting.


Here is it used for a dungeon.

The shader it self.
Pixel/frag shader default lighting,ambient,directional and point light.



Reference card. (kronos group)
http://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf

Your agk commands if you want to convert shaders to agk.

The shader constants supported by AppGameKit are
agk_World - object world matrix
agk_WorldNormal - object world matrix for normals, only necessary when an object has a non-uniform scale applied, otherwise it is the same as agk_World
agk_View - the camera view matrix
agk_Proj - the 3D projection matrix
agk_Ortho - the 2D orthographic projection matrix used by sprites
agk_ViewProj - combined view and projection matrices
agk_WorldViewProj - combined world, view, and projection matrices
agk_WorldOrtho - combined world and ortho matrices for sprites

texture0 to texture7 - texture stages 0-7 applied to the current object (pixel shader only)
uvBounds0 to uvBounds7 - UV adjustments for the textures applied above

agk_ObjColor - the current color set for this object

agk_PLightPos - the position of the first point light
agk_PLightColor - the color of the first point light
agk_DLightDir - the direction of the first directional light
agk_DLightColor - the color of the first directional light

The vertex attributes supported by the AppGameKit primitives and OBJ models are
"position"
"normal"
"uv"

But the AGO format allows you to add as many vertex attributes as you want and to name them whatever you like.


The shaders i create while iam trying to learn agk shaders.

This is base shaders you can base your own shaders on.
They are simply only coloring your objects with the object color.

Vertex color.


Pixel color.


Here is my vertex shader with tiling that works with all of the previous pixel frag shaders.

You set the tiling like this in agk.
SetShaderConstantByName( box, "tiling",1.0 ,0.5,0, 0 )
The order are x/y.
This do not work on atlas images!
setimage wrap u and wrap v to 1 on the image you use.



vertex shader texture.


Clean version.


pixel shader texture.


Clean version.


Pixel shader ramp colors.


Clean version.


Pixel shader embosse.


Clean version.


pixel shader wavy grass.


Clean version.


Template shader (No texture, 1 dir light,1 point light)
vertex.

pixel.


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
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 14th Nov 2012 17:35
Here's the list of shaders I wrote for the default scenarios



The spec for GLSL for OpenGL ES can be found here

don't include any "version" or "precision" fields as these aren't cross platform compatible.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Nov 2012 20:49
Do these work with the primitives created with agk?

I notice that the light and textured shaders have uv and normals data?

These are well only created on objects created in an 3d modeller?

Iam asking as i cant get the agk primitiv plane to light up as i want with the agk commands.

I am after the same look as the game delver you see here.



But wathever i do to the primitives with the built in light so do i only get this.


Back to reading the pdf

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Nov 2012 23:21
Wathever i do so do i not get proper lightning

Maybe i cant use the primitives?

Will have to read some more about shaders ! But its pretty new to me as it whas a long time ago i wrote a basic shader for dbp.

And most of it have i forgotten

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 00:00
How did you guys get this effect ?
Is this another set of shaders?



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
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 15th Nov 2012 00:42
All the primitives come with normal and uv data, the 3D test scene was all done with the default shaders above.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 06:59
Thanks paul
Then is it me doing something wrong

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 17:01
I think iam getting there now paul

I have managed to write an shader that textures the object atleast

Your post whas very helpfull

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 17:35 Edited at: 15th Nov 2012 18:07
Here is my first agk shader
I included alot of explaining text inside them so it helps others who wants to try
Its pretty basic as it only textures an object.

vertex shader.


pixel shader.


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

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 18:04 Edited at: 15th Nov 2012 18:34
My second shader is only an pixel shader that works with the first vertex shader.

Its a ramp shader that uses an color ramp texture to do some tricks to your object
set the ramp image to be object texture 1 and not 0
Iam trying to learn agk shaders and will post wath i learn here.



Its used on the floor texture here.


I included the color ramp image in the above post!!!!!

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

Attachments

Login to view attachments
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 15th Nov 2012 18:22
Thanks for documenting your progress, it's interesting to see what other people can do with the power of shaders. Hopefully others will also find this useful.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 18:33
iam working on an embosse shader and will post it here as soon as i get it working
The web is full of information about shaders and is very handy.

The problem is to know how to convert shaders for other game engines in to agk

I nead something to do while i wait for intel to validate my app

Quote: "Thanks for documenting your progress, it's interesting to see what other people can do with the power of shaders. Hopefully others will also find this useful. "

Hopefully can i get someone that is a bit better with shaders intrested in adding some cool ones

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 20:04 Edited at: 15th Nov 2012 20:07
How do i send values like floats from agk to the shader?

Or i can only do this in tier 2?

Edited .....
I found it sorry.

SetShaderConstantByName

Description

Sets a shader constant by name, the ariable must be marked as "uniform" in the shader source. This will affect all objects drawn using this shader. All shader values have 1 to 4 components, this command accepts 4 values and discards any that are not used by the named constant.

Definition


SetShaderConstantByName( shaderID, szName, value1, value2, value3, value4 )

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 20:22 Edited at: 15th Nov 2012 20:24
Embosse pixel shader that works with the above vertex shader.
Learned to send values from agk to the shader


used on the floor texture.



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

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 21:19 Edited at: 15th Nov 2012 21:33
My new waving grass shader for agk!
This is fun as long as i dont get to the complicated shaders



Wavy grass pixel shader.


Clean version.


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
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 15th Nov 2012 21:26
It says the video is private...
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 21:32
Should work now
I set it to unlisted instead.

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
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 15th Nov 2012 21:42
That would look realy cool if you have a lot of them
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Nov 2012 21:45 Edited at: 15th Nov 2012 21:46
Quote: "That would look realy cool if you have a lot of them "

I havent tested how many you can have on screen before it slows down ?

Iam going to watch abraham lincoln vampire hunter now so see you guys tomorrow

And maybe a few more shaders for agk

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
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 15th Nov 2012 22:13 Edited at: 15th Nov 2012 22:16
If anyones interested, heres a book that I would recommend:
OpenGL ES 2.0 Programming Guide

It doesn't go into really cool stuff. But it teaches GLSL for OpenGL ES.

lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 16th Nov 2012 00:40
Good initiative Cliff. I'm following your progress!

My hovercraft is full of eels
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 17th Nov 2012 17:32 Edited at: 17th Nov 2012 17:33
I get some very weird results on my distance based light?

Its reversed and i dont know wath iam doing wrong?

Here is the pixel shader if anyone is intrested




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

Attachments

Login to view attachments
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 17th Nov 2012 17:44
It's not clear what you want he shader to do, the line

is subtracting a vector from a position which is unusual, I would expect something along the lines of


If this were the case "distance" is only used as distance*distance which means you could replace it with "atten" since then they would be equivalent. But it depends on the purpose of the distance variable.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 17th Nov 2012 17:52 Edited at: 17th Nov 2012 17:54
Quote: "If this were the case "distance" is only used as distance*distance which means you could replace it with "atten" since then they would be equivalent. But it depends on the purpose of the distance variable. "

I want the shader to light up the object as i get closer
Quote: "It's not clear what you want he shader to do, the line "

Iam trying to convert an android open gl shader that uses ambient lighting and diffuse.

The shader in agk dont do this.

If i dont subtracct from the light pos so do i not get an light i want as it lits the object the same all the time.

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
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 17th Nov 2012 18:13 Edited at: 17th Nov 2012 18:13
Not sure, but maybe this:



should be changed to this?




I just reminded myself that I want to do some nice shader effects... I might dive into this topic aswell

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: 17th Nov 2012 18:16 Edited at: 17th Nov 2012 18:17
Hi kamac

i solved it
wrong
float diffuse = max(dot(dir, norm), 0.1);
correct
float diffuse = max(dot(dir, posVarying), 0.1);

I will post the complete shader when its finished!

This is fun



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

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 18th Nov 2012 10:41 Edited at: 18th Nov 2012 10:56
The shader seams to only affect one of the objects ?

I ordered 2 books about opengl es 2.0 to get a better understanding

There seams to be alot of things missing in the data agk sends to shaders ?

Cheers.

Edited..........
I feel so dumb sometimes
You nead to set a shader for each object with its own id.

plane = CreateObjectbox( 40, 40,40 )
SetObjectShader( plane, plane )

But something is really wrong with the planes?

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
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 18th Nov 2012 12:51
By the way, any info on post processing shaders?
Or is it already possible?

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: 18th Nov 2012 13:01 Edited at: 18th Nov 2012 13:54
I belive we only nead to know the agk commands sent to the shaders

Iam starting to try to decompile pauls post to wath they usually are called on various tutorials.

So far.

View matrix = agk_World
Projection matrix = agk_ViewProj (combined model/view/projection matrix)
Per-vertex color information = agk_ObjColor
Per-vertex position information = position

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
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 18th Nov 2012 17:53
Post processing shader is something different Cliff.
It draws the whole thing not on the screen, but to the FBO. Then, we draw a texture which covers the entire screen that has it's own shader.

You can do quite cool things with it.

Follow me on twitter! @MotionStruct
Motion Struct blog
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Nov 2012 18:28 Edited at: 18th Nov 2012 18:29
Currently you can't do post processing shaders, I'll get to them eventually.

The shader constants supported by AppGameKit are
agk_World - object world matrix
agk_WorldNormal - object world matrix for normals, only necessary when an object has a non-uniform scale applied, otherwise it is the same as agk_World
agk_View - the camera view matrix
agk_Proj - the 3D projection matrix
agk_Ortho - the 2D orthographic projection matrix used by sprites
agk_ViewProj - combined view and projection matrices
agk_WorldViewProj - combined world, view, and projection matrices
agk_WorldOrtho - combined world and ortho matrices for sprites

texture0 to texture7 - texture stages 0-7 applied to the current object (pixel shader only)
uvBounds0 to uvBounds7 - UV adjustments for the textures applied above

agk_ObjColor - the current color set for this object

agk_PLightPos - the position of the first point light
agk_PLightColor - the color of the first point light
agk_DLightDir - the direction of the first directional light
agk_DLightColor - the color of the first directional light

The vertex attributes supported by the AppGameKit primitives and OBJ models are
"position"
"normal"
"uv"

But the AGO format allows you to add as many vertex attributes as you want and to name them whatever you like.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 18th Nov 2012 19:11
Just wath i neaded

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 18th Nov 2012 21:14
Brain on overdrive this weekend and i see spots in the ceiling
Starting to get it right with my ambient light for an dark dungeon
This shader have 1 directional light,1 point light and ambient lighting.


The shader is not finished so i will not post it right now.
i want to add more light sources etc.

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 19th Nov 2012 00:00
Added settings for the ambient light that is controlled inside agk.
Now can you give each object its own ambient settings that i used for the floor to lit up slightly brighter to get the right fx.
The flickering is my trying to get an torch fx
Iam getting closer to my goal of cool dungeon like lights for my engine



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
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 19th Nov 2012 00:58
Cliff - that's starting to work really well. Well done!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 19th Nov 2012 16:38
Quote: "Cliff - that's starting to work really well. Well done!"

Thanks

Iam working on adjustments to the textures now.
UV tiling and multiple textures on an object.

Its to slow with an dungeon with 400-600 cubes with shaders on

I belive i could half that amount if i solve uv tiling.
Cheers.

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
sovr
14
Years of Service
User Offline
Joined: 2nd Jan 2010
Location: USA
Posted: 19th Nov 2012 18:15
I have to thank you for your examples of different shaders! I am starting to understand how the shaders are working piece by piece. The thing I am thinking of is that we should all work on a collection of shaders and put it all into one package for people to use. I don't know, I am just thinking out loud, but to me it sounds like a good idea. When I get better at making these shaders I will contribute!

sov the game creator!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 19th Nov 2012 18:41
Thanks

Iam simply trying to help the game creators a bit as they have there hands full and alot of people have requests for 3d,texture and light fx.

Alot of people simply dont understand how much power we already have in our hands with the latest agk 3d betas

Its all in the shaders to do the magic.

I where also very affraid of shaders but is pretty simpel when you get in to it.

I will try to continou to post small shaders that do specific tasks that people can use to do there own in the future also.

My collection will be in this thread and you are all free to use them as you please.

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
fog
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Newcastle, England
Posted: 20th Nov 2012 16:10 Edited at: 20th Nov 2012 16:12
Great work Cliff. Much appreciated. I wrote a bunch of shaders when using XNA and this just confirms they will transfer easily enough.

I think what shaders can add to 2D is hugely under appreciated and under used.

For example, the movement in the second half of this vid is all created using a shader on a single background sprite.



Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Nov 2012 16:46
Quote: " I wrote a bunch of shaders when using XNA and this just confirms they will transfer easily enough."

It would be awesome if you could convert some of your shaders and post them here

Iam still learning and could probablly learn alot from yours

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Nov 2012 18:53
Here is the shader i used for the dungeon movie,its slightly modified as i added an default light setting also.

The default light is for when you dont want everything to falloff so dark in the distance.

Please let me know how i could make it faster

Anyone know of a good way to tile my textures?
iam a bit stuck on this one

Pixel/frag shader default lighting,ambient,directional and point light.


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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Nov 2012 22:06 Edited at: 20th Nov 2012 23:07
Whas playing around with the shader and got an crazy idea about implementing the embosse effect.

And ended up with some kind of bump map effect?



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
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 20th Nov 2012 23:06
Cliff - you are doing some great stuff.

Thanks for making me laugh out load. I think you mean "bump map" rather than "bum map." A bum map is what you get when you pull your trousers down and sit on a photocopier!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Nov 2012 23:10 Edited at: 20th Nov 2012 23:11
Thanks jim
i wanted do some kind of bump effect with material anyone can do without expensive paint apps.
Here is how the bump image looks.


As you can see are i working with mobile devices in mind

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

Attachments

Login to view attachments
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 21st Nov 2012 12:01
Hi,

Thanks cliff for this job! I would like to ask one question. What do you get with UV attribute and uvbounds? What is the difference? What does uvbounds store? why is uvbounds a vec4?

Thank you!
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 21st Nov 2012 15:47 Edited at: 21st Nov 2012 15:48
uvbounds store four values for each texture, an offset (2 values) and a scale (2 values), this is because the object assumes it is using a texture with UVs 0.0 to 1.0 whereas the image might be part of an atlas texture and the image we are interested in is at say UVs 0.1 to 0.4, so it maps 0.0-1.0 to 0.1-0.4.

This also applies to non-power of 2 textures that get resized internally so are no longer mapped to 0.0-1.0 either. If you were using a non-atlas power of 2 texture for the object then you can ignore the uvbounds parameter.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 21st Nov 2012 20:48
paul is gl repeat turned of in agk?

Wathever i do so cant i get an texture to tile on object

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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 21st Nov 2012 23:00
Thanks paul and it whas so simpel

I forgot to setimage wrapu and wrap v to 1.

Anyway here is my experiment shader for an bump map.

Pixel frag. Here is the one with an bump map.


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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 21st Nov 2012 23:20 Edited at: 21st Nov 2012 23:24
Thanks to paul that showed how dumb you can be when looking to much at only one thing

Here is my vertex shader with tiling that works with all of the previous pixel frag shaders.

You set the tiling like this in agk.
SetShaderConstantByName( box, "tiling",1.0 ,0.5,0, 0 )
The order are x/y.
This do not work on atlas images!
setimage wrap u and wrap v to 1 on the image you use.





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

Attachments

Login to view attachments
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 22nd Nov 2012 11:17
Thanks cliff for building the bump effect. You're genius!

I will check it and will try to understand the code, after my job.

Thanks!

Login to post a reply

Server time is: 2024-04-27 05:12:21
Your offset time is: 2024-04-27 05:12:21