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: 22nd Nov 2012 22:38
Thanks juande.

I will probably rewrite alot of shaders as soon as i get my opengl es book.

All the work i have done so far is pretty much guessing and trial and error

Keep in mind that you may have to change some values in the shader if you have larger images ?
I really dont know so far?

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: 22nd Nov 2012 23:44 Edited at: 22nd Nov 2012 23:45
some experiments with multiple lights.
Where actually easier then i thought.



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: 23rd Nov 2012 21:13
started testing the shaders on android and they dont work ?

so i have to backtrack and se waths the problem?

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
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Nov 2012 21:46
That's really cool Cliff!


this.mess = abs(sin(times#))
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 23rd Nov 2012 22:09
Cliff, I have a problem, I am trying make the vertex shader for bump effect, but I don't know for what posvarying variable is used.

I have written this:


Can you say to me if it's correct? and What is posVarying?

Thank you very much.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 23rd Nov 2012 22:17 Edited at: 23rd Nov 2012 22:18
Thanks bax!
But i have some trouble to backtrack why my more advanced shaders dont work on android?

juande it seams i missed the vertex shader that goes with the bump shader
vertex shader for the pixel shaders with bump map and tiling.




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
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 23rd Nov 2012 22:35
Thanks Cliff! I'm not be able to create a simple vertex Shader... I will test this shader in android and I tell you...

greetings
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 23rd Nov 2012 23:09
iam writing a new shader from the ground up to see where the trouble is and test it on android after every line of code

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: 23rd Nov 2012 23:46 Edited at: 24th Nov 2012 00:59
Found the command that crashes android

float distance = length(dir);

This is used for all the cool light fx.

Nead to find another solution?

The solution whas to clamp the lenght(dir);
windows dont care but android crashes the fragment shader compiling if the result is 0 .

android is extremely case sensetiv if its floats so will the compiling crash if you write 1 instead of 1.0.

Edited......
Now have a working shader that have 1 directional,2 point lights and tiling textures.

Will do the rest tomorrow ZZZZzzzzzzzz

whas a true pain to get it to work on android

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: 24th Nov 2012 07:44
hey cliff, I have been trying to use your dungeon light shader, but everytime I try to work with it... it keeps on telling me that the shader can not be compiled. I don't know what I am doing wrong... I am using the original vertex shader and all I do is load the shader nothing else. I thank you so much for the work you have been doing and thanks for the help

sov the game creator!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 24th Nov 2012 08:14
sovr.
Did you use this shader??
vertex shader for the pixel shaders with bump map and tiling.




Also keep in mind that my shaders are written with the agk primitives in mind and could be messed on another imported model?

Can you wait maybe 1-2 days as iam trying to do a template project.

This will show how to use the shaders and set them up.

I whas forced to rewrite the dungeon shader as it didt compile on android.

And after alot of searching on the web did i find someone on another forum that wrote that there iphone project didt show there shaders anymore.

And android have exactly he same case sensetiv no 0 results inside the shader or it crash.
I have solved it by clamping alot of calculations so they never get to 0.

I am also very used to windows that dont care about much and almost compiles anything, i had wrote alot of 1 instead of 1.0 in my early shaders that crashed them to.

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
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 24th Nov 2012 14:06
Hi,

Cliff, I have a problem in .ps for bump effect. AppGameKit tell me: "Pixel Shader fx/bump.ps failed to compile at line 22". I have removed the last line and then the script is compiled... This line is



I have tried to discover the problem, but I can't... I suppose that the problem was the vector. Fragcolor is a vec4 but in this case, there were 3 parameters. I have written 1.0 after ambientMax... but the ps is not compiled... I have written vec4 before clamp (What is clamp?) but not.

Where is the error?

Thanks
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 24th Nov 2012 16:26
Whas it android that failed ?

Depending on wath format so is it easier to pinpoint the problem.

Could you show me the whole shader code?

there is so many things that could be wrong with an 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
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 24th Nov 2012 16:56
Hi Cliff,

The problem is in windows (I suppose that the problem will be in Android too)

The vs and ps are yours (I am not able to modify them, yet). I think that they are well copied.

Vertex shader:


pixel shader


my AppGameKit code


Thanks!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 24th Nov 2012 17:39
Here is the first template that iam working on.
You could test by loading your object in to it and se if it fails with this?
Then do i probably know wath it is as yours is an model that nead extra uv data probably.
Something i noticed on tgc theater sample where they loaded models.

Here is the template with 1 directional light,2point lights and bump.
Its an tier 1 project.

This one works on windows and android.
Android gets very low framerate as its unoptimized.

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: 24th Nov 2012 18:30
Ok... the problem is mine... I don't indicate the variables: ambientPower, ambientMin and ambientMax.

Thanks!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 25th Nov 2012 12:15 Edited at: 25th Nov 2012 13:15
Started to look at why agk shaders where so slow on android !

Iam a bit confused as the built in shaders in agk is using 32 bits float values for even the small things like the object color?

The problem is color components/rgb will be converted to 32 bits float values.

This works ok on an computer but will completely hogg an iphone or android device.

The uniform that loads an color or another value that are not that precise should be lowp and not medump or highp.

Also in the fragment/pixel shader.
Wrong.
texture2D(texture0, uvVarying )
right.
texture2D(texture0, uvVarying.xy )

Seams like zw is never used in the pixel/fragment shader?

This is slower!
vec3 norm = agk_WorldNormal * normal;
normalVarying = norm;
Then this.
normalVarying = agk_WorldNormal * normal;

I think i nead some feddback from paul?

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
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 25th Nov 2012 14:09
Hi!

I am building a specular shader... but I am learning with Cliff's Shaders. I have written a simple pixel and vertex shader where it's added 2 textures... but I have a problem. AppGameKit say to me: "Vertex and Pixel failed to link, make sure any varying values used in the pixel shader are output in the vertex shader"

My vertex shader is:




My pixel shader:


I don't find the problem... the varyings are the same.

Thanks!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 25th Nov 2012 14:54 Edited at: 25th Nov 2012 14:56
You have alot of things missing in your vertex shader.

as you see on my shader so is there normals values.



Sorry for the bad answer but i have banged my head with shaders the whole morning and is tired right now

Look at the first post where paul posted his agk internal shaders.

I use them for templates the whole time

And be prepared to that you get all kinds of errors when writing shaders.
They are extremely case sensetiv.

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
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 25th Nov 2012 16:30
Thanks! It works!

One question: Is it possible to use samplerCube and textureCube?

Thanks.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 25th Nov 2012 18:30
Quote: "One question: Is it possible to use samplerCube and textureCube?"


I dont know as they are still developing the 3d parts of agk.

And iam still learning the beginings of agk 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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 25th Nov 2012 19:27 Edited at: 25th Nov 2012 19:30
when trying to improve android and iphone performance so could you do this and keep it cross platform.



Here is wath i found on the web.

Every GLSL shader (desktop or ES) needs to have a "preamble". The first non-comment thing in a shader needs to be a #version declaration. Fortunately for you, the version is the same between desktop GL 2.1 and GL ES 2.0: #version 1.20. The problem is what comes next: the #extension list (if any). This enables extensions needed by the 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
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 25th Nov 2012 21:11 Edited at: 25th Nov 2012 22:26
Only to show how complicated it sometimes get for a cross platform language

And the mess tgc have to make it work .

This is only wath i learned so far about opengl es shaders and wath varies on desktop and mobile device.

My current shader is this and runs at 415 fps on my pc and 13-14 fps on my slow 800 mhz zte skate that dont play 3d games from goggle play to well.

This shader also shows how you could make android/iphone not use some fx and computers show all the glory.

This is my latest pixel frag shader that gives the same display on mobile device and pc but runs better then the old on mobile.



Here is the vertex shader that goes with it.



If anyone else could test this with the template i posted before and let me know of your device and framerate?
Iam going to finetune the pc shader later on as it dont nead all clamping like mobile devices.

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: 25th Nov 2012 22:05
wow, thanks cliff! the most recent post of vertex and pixel shaders that you posted worked for me ... it was mainly the shader constant command within the agk that I did not use that created the error. The thing is for the bump/tiling shader is that I was going to use my normal map for the bump map... I realized that there were lines of light on the object and the rest were dark. I guess I could try to convert my main texture into a bump texture to see if the lighting works on that. I will try it out and tell you if it works.

sov the game creator!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 25th Nov 2012 22:18 Edited at: 25th Nov 2012 22:32
I belive normal maps will be pretty slow on mobile devices?

Normal maps are frequently stored as RGB images where the RGB components corresponds to the X, Y, and Z coordinates, respectively, of the surface normal.

Could you post a screenie of your scene and wath framerates you get ?

Edited...............
I posted the wrong vertex shader also

Here is the correct one and i updated the old post with the right one also.
Here is the vertex shader that goes with it.



Edited....................
i have 4-5 windows with shaders on screen while working as i do them in notepad and they often dont work when doing changes.

Thats why i sometimes post the wrong shader source as i also get a bit confused sometimes

The last pixel frag also have another fix that makes you decide how much brighter a wall/object gets when getting really close.
The old one simply made them extremely white or bright.

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: 25th Nov 2012 23:49
I found something on the web that could work better then the current bump map?

Its more like an overlay light map kind of thing that gives the same fx and should work with the old bump image.

With it so should i compress the lines to 2 instead of 6 lines of code.

Have to sleep now zzzz

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: 26th Nov 2012 00:45 Edited at: 26th Nov 2012 00:46
The game I am currently working on has been in my head for over a year now... I am wanting to make an iphone version and a PC version of the game. I figure I could use some of the more advance shaders for the PC version and keep just some minor ones in the iphone version. I guess I will try to work on the shaders you showed me so far and see if I could make one for normal maps.

sov the game creator!
Juande
12
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 26th Nov 2012 13:10 Edited at: 26th Nov 2012 13:14
Hi everyone,

I post a simple toon shader without outline. For drawing the outline, it's necessary glEnable command, but I am not able to work with this command yet (AGK failed when it compiles the shader).

Vertex Shader for Toon Shader (without outline)



Pixel Shader for Toon Shader (without outline)



You can set the toon effect using the float "toon" (range: (0,1]). If you use little values, you will have a color gradient (less toon effect). If you use big values, you will have a less color gradient. 0.2 or 0.3 is perfect for me.

Thanks Cliff, for your help and your shaders.

Edit: I have tested this shader in Android (Samsung Galaxy Mini)... FPS:59-60
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 26th Nov 2012 15:21
AGK handles the #version parameter for those platforms that support it. You'll find a huge performance difference between Android and Windows since Tegra 2 has 4 pixel pipelines, whilst a desktop card has hundreds or thousands of pixel pipelines, so things like dynamic lighting are to be avoided on mobile devices. Light mapping is the preferred method if you want maximum performance.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 26th Nov 2012 17:52 Edited at: 26th Nov 2012 17:56
Quote: "AGK handles the #version parameter for those platforms that support it."

Do you mean that agk adapts the shader to the format?

Because i noticed #ifdef GL_ES in the shader that came with the theater sample and browsed it on the web.
And is very comon when you want cross platform shaders that work at its best on various platforms.

I also noticed that this simple line detects if its mobile or desktop.

Iam very happy for any more info you can share about agk shaders

Iam pretty much guessing everything

Any time in the future we could se commands to have shaders on sprites?

Iam thinking about the large sprites that hoggs agk apps on mobile devices that could be solved with a shader maybe?

I have found alot of shaders to solve various problems with large sprites in opengl es.

The simple solution is simply to keep an shader like that exremely basic and use lowp as much as possible.


Quote: "You'll find a huge performance difference between Android and Windows since Tegra 2 has 4 pixel pipelines, whilst a desktop card has hundreds or thousands of pixel pipelines, so things like dynamic lighting are to be avoided on mobile devices. "

Its more or less me fooling around to see how much i can push it for my self.
Iam still waiting on my opengl es books to see how its supposed to be done and not all this guessing iam doing now
I ordered an book about writing opengl es shaders for games on iphone/android that should point me in the right directions on performance.
Wndows is pretty much all you nead on the web as it dont have to many limitations.

I have pretty much got it confirmed by the web that shadows,dynamic light and fogg is best to forget on iphone or android.

Most devs seams to fake alot of the effects like shadows with black meshes they use alpha on for shadows etc.

When browsing the web do i also see alot of people have performance problems on even the smallest shaders on iphone and android.

Some people suggest doing shaders in stages on an object and writes about using up to 3 shaders to get the right effect for performance.

Quote: "Light mapping is the preferred method if you want maximum performance."

I hope to be able to do some kind of lightmapping tool for the primitives when i understand shaders more.

Because it should be doable to draw some kind of light map on an object with a shader and light ,then position the camera in front of that face.
And use agk getimage command to get some kind of image for an lightmap?

But this is still pretty much ideas in my head so far.

Edited...................
Juande iam happy that i could help you somehow to start doing your own shaders

And thanks for sharing wath you do to the rest of the comunity

I will try to test your shader later on

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: 28th Nov 2012 23:08 Edited at: 28th Nov 2012 23:12
Recived my book today
It whas pretty good but the shaders seamed a bit over the top?
As i belive my game would run at 5-30 fps on android if i used them.
The book contains info on writing blur and shadow shaders etc.
But they pointed me in some good directions on alot of stuff i dont understand fully.
http://gfx.sio2interactive.com/
The book have a very low price and explains the things about shaders very well.
I strongly recomend it if you want to learn shaders.
But be prepared as you nead some previous knowhow.

Even if i dont use the shaders in the book so did i learn an effective method of doing fog/ambient falloff by reading it.
The writer had an very fast and small method of doing per vertex light calculation.
only 3 lines of code is the math behinde the fx.
I simply added a distance calculation that decreased the light an vertex recives.
It runs above 900 fps constantly on my pc and constantly above 60 fps on my android.
But before i show the shader off so do i nead some more testing as the objects are untextured and i nead to see wath happens?

But its pretty good with the fact in mind that i dont use any mediump or lowp and run the same shader on pc and droid.

Here is how the effect looks on 3 simple agk box primitives.

I also learned to do as much as i can in the vertex shader and keep it very minimal in the pixel/fragment shader.



The goals of the shader i nead is.
Fogg/ambient falloff.
texture tiling.
2-3 point lights.
Directional light.

And i want it to never dropp under 50 fps on my slow droid.

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: 1st Dec 2012 22:12 Edited at: 1st Dec 2012 22:13
added alpha transparency,texture tiling.

So right now does my uber shaders have .

Vertex based fog and lightning single source. (uses point light 1)
texture tiling.
alpha transparency.

But the progress is very slow as i hate my work and dont have much motivation for anything right now

Who wants to be an team leader at an factory when computers are so much more fun.



Here is the pixel fragment shader where the alpha transparency effect is done.



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
Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 2nd Dec 2012 15:20
Quote: "Who wants to be an team leader at an factory"

quit your job

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 2nd Dec 2012 15:46
This is extremely weird?
Its seams like passing in integers to shaders are broken?
It works as it should with floats but integers and bools seams broken?

Quote: "quit your job "

Its me pulling in the money
My girlfriend have bin unemployed for 4 years!

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
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 2nd Dec 2012 16:17
Quote: "My girlfriend have bin unemployed for 4 years!"

In Sweden do you know what is "unemployment"???
In Italy there is no need to quit the job, there are the employers that make the job quit you. Last guarantees for workers have cancelled by our "technical government" of Prof. Monti" (whose only achievement is the issue of a fine to Bill Gates when Monti worked for European Union).
Bill Gates has not yet stopped laughing at that ridiculous initiative, while in Italy there are a lot of people crying. So keep your team leader job in the factory...and be happy.
sovr
14
Years of Service
User Offline
Joined: 2nd Jan 2010
Location: USA
Posted: 7th Dec 2012 05:17
ok I am having a problem... I am trying to combine the wavy grass pixel shader and the transparency pixel shader into one. The problem I am having is with the vertex shader. I basically combined both pixel shaders and I updated the vertex shader to include the col and texcoord varying variables and I got this error:



I thank anyone who can help!!!

hello there!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 7th Dec 2012 18:32
Test if this one works ?
I made it from the back of my head so its not optimal.
It uses the same vertex shader as the old wavy grass shader.
The problem you have is that i simply changed names on some things on my later shaders
Iam getting more used to the works of shaders and can do that sometimes because of that.
Paul also reported that transparency and ghosting will be fixed as agk does this outside the shaders.
Thats why i couldt find it inside there shaders.
Paul wrote that there whas a error in the draworder that gave he weird results.


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
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st Jan 2013 19:43 Edited at: 21st Jan 2013 20:38
Hello

I'm trying to combine 2 textures. One grassy texture and a detail map texture which i want to "merge" (and repeat (tiling) it with a scale value in shaders or constants)

Any idea on how to do that ? (i need a course on shaders but have no time for the moment :p)

Maybe this page can help ? : http://rastertek.com/tertut13.html


.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 21st Jan 2013 20:57 Edited at: 21st Jan 2013 21:02
Quote: "I'm trying to combine 2 textures. One grassy texture and a detail map texture which i want to "merge" (and repeat (tiling) it with a scale value in shaders or constants)

Any idea on how to do that ?"


Tiling is easy

Merge could be performance hungry ?

But basicly so should you be able to use parts of the embosse shader.

I will se wath i can do later on ?

If i manage to get some time so will i post the shader in your racer thread.

Edited........
After reading the link so do i see that this type of shader is pretty complicated as its pretty much like an normal map shader that only draws the detail thats close up.
I dont know yet if iam up to the task

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
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st Jan 2013 21:03
Thanks a lot i have tried to customize some shaders but without any success
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st Jan 2013 23:02
I have it working ! except for tiling but i'm approching my goal

i will post here when i'll get it working
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st Jan 2013 23:59 Edited at: 22nd Jan 2013 02:41
Ok ! Just inspired by the embosse shader (thx Cliff) after having partially understood the shaders processing.

Here is the detail map shader files (also works for lightmaps with a u,v scale value of 1.0)

edit: integers "1" and "2" changed for "1.0" and "2.0" to avoid android compilation problems

vertex.vs :



pixel.ps :





Result :


Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 22nd Jan 2013 00:02 Edited at: 22nd Jan 2013 00:09
Looks great

Iam so tired in my head today that i spent 2 hours to find an error in my shader

And then it showed that i had put both textures in stage 0

Thanks for sharing as there is others probably that want one


Edited ...............
Mike i noticed that you have the detail map on the whole mesh and that could slow it down alot!
Especially on mobiles!
You could do an distance check before you add it.

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
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd Jan 2013 00:08 Edited at: 22nd Jan 2013 00:10
DetailMap is just mandatory to have textures to look great (especially for mobile devices and large maps with small textures

This shader is also for another thing i want to share soon ... a TerrainGeneratorFromHeightmap function (thx to Memblocks (i need it to create my Track editor and i already done this kind of function in others languages. just need to convert it to Tier 1
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 22nd Jan 2013 00:11
If you get performance problems so did i notice that you draw the detail map on the whole mesh even if parts of it is far away.
You could add an distance check.

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
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd Jan 2013 00:16 Edited at: 22nd Jan 2013 00:30
Quote: "Mike i noticed that you have the detail map on the whole mesh and that could slow it down alot!
Especially on mobiles!
You could do an distance check before you add it."


Ho yes ... with something like

and agk_View ?

Is there any documentation on internal AppGameKit shaders constants ??

EDIT : are we sure that pixels "merging" from texture0 and texture1 takes more time than calculate the distance ? And shaders processing is after clipping and culling in the pipeline so ... maybe it's not necessary
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd Jan 2013 00:24 Edited at: 22nd Jan 2013 02:38
Wow Big Problem ... works great on windows but on android ... the pixels don't appear ... My Track is invisible ^^

(on Nexus 10 and Galaxy Tab and Samsung S3 ..) WTF ?

EDIT : maybe an incorrect oompilation option with my android player 1088 ?

EDIT 2 : not a player compilation problem, Android player says simply that it fails to compile vertex.vs ...

EDIT 3 : GRRRR Damn floats ... was using "1" instead of "1.0" ... i will fix the code in my previous posts
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 22nd Jan 2013 11:44
That looks realy good, I will have to learn to write shaders soon.
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 22nd Jan 2013 16:49
Quote: "That looks realy good, I will have to learn to write shaders soon."


That's right, althrough, it's really easy what MikeMax did. It's simply applying one, tiled texture, plus the original mesh texture. Then you "blend" them, and you get the result above.

This method is good, but I don't like the fact that if you compare grass and rock/sand, it'll look almost the same, just different colour.

Better practise (but harder) is to have different texture for each vertex and balance between them. (You'd add texture weights, which could come in a separate vec4 [four textures] or use RGBA [four textures too] without ability to additionally colour it - I don't think you'd need it through)

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: 22nd Jan 2013 17:16
Quote: "are we sure that pixels "merging" from texture0 and texture1 takes more time than calculate the distance ?"


Shaders in general don't like branching, so it can be quicker to apply a technique to all pixels rather than say "if this pixel is here do this". Since parts of the model that are very far away will have fewer pixels covering them they will have less impact on the pixel shader anyway. The biggest performance impact is probably from the pixels close to the screen looking up 2 textures instead of 1, which is unavoidable for the result you want, so I wouldn't worry about it.

Login to post a reply

Server time is: 2024-05-09 01:02:49
Your offset time is: 2024-05-09 01:02:49