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 / [bug] 2.0.17 shader problems.

Author
Message
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 7th Mar 2016 12:58
1.
I reached a limit , when i add to my fragment shader it start to cut off at the end of the shader code.

Its like there are only room for around 5kb , then it start to fail.

It do not matter what is in the shader , comment lines also count.

not sure what these babies take up in file size:

mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );

but when i hit around 4 kb with my own code it start to fail.

2.
Something is wrong with the ApplyFog function , a ipad 2 take a 12fps drop when used , when i convert it to my own fog code it only drop by 1 fps. Perhaps there is some branch code in the function that cant be compiled ?.

best regards Preben Eriksen,
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 7th Mar 2016 18:49 Edited at: 7th Mar 2016 18:52
1. Never had this problem..even if I include the two mighty lines + 4Kb.
What nice shader are u making there ? : )


2. I think ApplyFog allow for fog near the sun which is a more expensive calculation.
check if you have SetFogSunColor in you code.

Using AGKv2 Tier1
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 7th Mar 2016 19:05
Fixed for the next version, it was using a fixed sized buffer that was about 4Kb for generated shader code, it will now use a dynamically size buffer. If you are not using pixel lighting or fog then you can remove the GetPSLighting and ApplyFog commands to avoid this bug.

The fog command uses the exp() to produce a realistic falloff, if you use linear fog instead then it will be faster. As janbo says, applying a sun color makes it an even more complicated function.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 8th Mar 2016 11:30
SetFogSunColor: i did not even notice that, i just tried it, and it look awesome , great stuff Poul , no wonder it takes a drop

janbo: been trying the new terrain commands, and are improving the shaders to run 60 fps on mobiles, and add mush more details, so im doing a LOD shader. going from 1 texture read (LOD2) to full 4 mixed textures with normals baked into the alpha ( LOD0 ), only happens when near camera. its currently at 60fps on ipad using the highest settings ( as screenshot ) so thats great, lod levels can be adjusted for slower devices.
LOD0: is not just a texture this is how it looks when you walk around ( closeup ).

I had one more idea , to speedup stuff:
Poul , would it be possible to get textures in the shader as an array perhaps like this ( uniform sampler2D texture[8] ) , this way i could precalculate what textures index to mix from like mix( texture[idx1], texture[idx2] , val ), would save me an additional 2 texture reads on LOD0.



best regards Preben Eriksen,

Attachments

Login to view attachments
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 8th Mar 2016 14:49
Quote: "would it be possible to get textures in the shader as an array perhaps like this ( uniform sampler2D texture[8] ), this way i could precalculate what textures index to mix from like mix( texture[idx1], texture[idx2] , val ) "

This might actually slow it down as the shader won't know in advance which texture to put in cache before your shader runs. This is called a dependent texture read.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 9th Mar 2016 13:51
Poul: if uvBounds[] is also an array and you assign the correct UVs in the vertex shader it should be able to cache before the fragment shader ? , anyway it was just for a test

How do you use transparent objects and the new dynamic skybox together , i tried every combination with SetObjectDepthWrite , but its always displaying the "clear color" as the background or the object is invisible in the skybox area ?

See screenshot:
best regards Preben Eriksen,

Attachments

Login to view attachments
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 9th Mar 2016 15:35
Quote: " if uvBounds[] is also an array and you assign the correct UVs in the vertex shader it should be able to cache before the fragment shader ?"

You can do anything in the vertex shader without a problem, but the UV must then be stored in a vec2 varying and remain unmodified in the pixel shader.

Quote: "How do you use transparent objects and the new dynamic skybox together"

That's a bug, I'll fix it for the next version. In this case it looks like you can use SetObjectAlphaMask to work around it, remember to set transparency off when using it.

Login to post a reply

Server time is: 2024-09-29 11:26:19
Your offset time is: 2024-09-29 11:26:19