Posted: 11th Mar 2018 11:49
Hi

Do you know how to do an overlay shader (for 3D object), to replace the current SetObjectLightmap().

Another question : I try to use 2 uvchannels, but I don't know how to do that :

vs :
+ Code Snippet
attribute highp vec3 position;
attribute mediump vec3 normal;
varying highp vec3 posVarying;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );

uniform highp mat3 agk_WorldNormal;
uniform highp mat4 agk_World;
uniform highp mat4 agk_ViewProj;
varying mediump vec3 tangentVarying;
varying mediump vec3 binormalVarying;
attribute highp vec2 uv;
attribute highp vec2 uv1;
varying highp vec2 uvVarying0;
varying highp vec2 uvVarying1;
uniform highp vec4 uvBounds0;
uniform highp vec4 uvBounds1;

void main()
{ 
    uvVarying0 = uv * uvBounds0.xy + uvBounds0.zw;
    uvVarying1 = uv1 * uvBounds1.xy + uvBounds1.zw;
    mediump vec3 tangent;
    if ( abs(normal.y) > 0.999 ) tangent = vec3( normal.y,0.0,0.0 );
    else tangent = normalize( vec3(-normal.z, 0.0, normal.x) );
    mediump vec3 binormal = normalize( vec3(normal.y*tangent.z, normal.z*tangent.x-normal.x*tangent.z, -normal.y*tangent.x) );
    highp vec4 pos = agk_World * vec4(position,1.0);
    gl_Position = agk_ViewProj * pos;
    mediump vec3 norm = normalize(agk_WorldNormal * normal);
    posVarying = pos.xyz;
    normalVarying = norm;
    lightVarying = GetVSLighting( norm, posVarying );
    tangentVarying = normalize(agk_WorldNormal * tangent);
    binormalVarying = normalize(agk_WorldNormal * binormal);
}


ps :
+ Code Snippet
varying highp vec2 uvVarying0;
varying highp vec2 uvVarying1;
uniform sampler2D texture0;
uniform sampler2D texture1;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
varying highp vec3 posVarying;
mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
uniform sampler2D texture2;
varying mediump vec3 tangentVarying;
varying mediump vec3 binormalVarying;
uniform mediump vec2 agk_NormalScale;
uniform mediump vec4 agk_MeshDiffuse;
uniform mediump vec4 agk_MeshEmissive;
void main()
{ 
    mediump vec4 blendTex = vec4(1.0,1.0,1.0,1.0);
    mediump vec3 norm = normalize(normalVarying);
    mediump vec2 texture2UV = uvVarying1;
    mediump vec3 normalmap = texture2D(texture2, texture2UV*agk_NormalScale).xyz;
    normalmap = normalmap * 2.0 - 1.0;
    mediump vec3 tangent = normalize(tangentVarying);
    mediump vec3 binormal = normalize(binormalVarying);
    mediump mat3 TBN = mat3( tangent, binormal, norm );
    norm = TBN * normalmap;
    mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying ); 
    mediump vec4 tex1 = texture2D(texture1, uvVarying0); // lightmap
    light += tex1.rgb;
    light *= tex1.rgb;
    mediump vec4 texColor = texture2D(texture0, uvVarying1); // diffuse
    gl_FragColor = texColor * blendTex * vec4(light,1.0) * agk_MeshDiffuse + agk_MeshEmissive;
}



Do you now how I can use 2 uvchannels (my model has 2 uvchannels) ?

thanks
Posted: 11th Mar 2018 12:47
@Blendman
You want two UV coordinates per Vertex ?
The documentation says it supports two, but I never tried it.
Is the shader code custom or was it generated by AppGameKit ?
if not generated then try to check with GetObjectMeshVS/PSsource() if there is the uv1 attribute generated for your model.
Posted: 11th Mar 2018 13:10
@ janbo :
I have a model with 2 uvchannels : 1 for the diffuse/normalmap and 1 channel for the lightmap.
So i would like to know how to use the second uv channel in a shader.

The shader is generated by agk, but modified to test if i can use uv1, but it doesnt work.

I dont know how to define the second uv channel in the shader to, use it.

Edit :
ok, it works with an export in DAE

it's great !

But the specular from the normalmap AGk isn't good I think...
I don't know how to change that.

It could be great to have the possibilitie to increase/decrease the normalmap or specular of a shader
Posted: 13th Mar 2018 22:03
I turned my previous fade shader into a 3d shader
it allows for fog and should allow light but not tested

An example
Creates a pyramid of colors
fades the objects in
uses a mouse selection of objects (used to show the fog etc)
click the mouse and they fade out
and program ends

+ Code Snippet
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
#constant fadeShader =1

SetFogMode( 1 ) 
SetFogColor(10,10,10)
SetFogRange(6,16)

createTexture()
createShader()
LoadShader(fadeShader,"fade.vs", "fade.ps")
num=1
for y = 1 to 20	
for x = y to 20-y
for z = y to 20-y
	CreateObjectBox(num,1,1,1)
	SetObjectImage( num, random(1,20), 0) 
	SetObjectPosition(num,x-10,y,-z)
	SetObjectShader( num, fadeShader)
	inc num
next z
next x
next y
mask=CreateObjectBox(1.1,1.1,1.1)
SetObjectColor(mask,255,255,255,180)
SetObjectTransparency(mask,1)
SetObjectFogMode(mask,0)

fadeIn()
do
    
	selectedObj=mouseOver()
	if GetObjectExists(selectedObj) 
		SetObjectVisible( mask, 1 ) 
		SetObjectPosition (mask,GetObjectX(selectedObj),GetObjectY(selectedObj),GetObjectZ(selectedObj))
		lastObj=selectedObj
	endif
	if GetObjectExists(lastObj) and lastObj<>selectedObj 
		SetObjectVisible( mask, 0 ) 
		lastObj=selectedObj
	endif
    if getpointerpressed()=1
		fadeOut()
		end
	endif
	SetShaderConstantByName(fadeShader,"pointPos",1,1,1,1)
	sync()	

loop

function createTexture ()

	for num = 1 to 20
		r=random(50,255): g=random(50,255):b=random(50,255)
		DrawBox(0,0,32,32,MakeColor(r,g,b),MakeColor(r,g,b),MakeColor(r,g,b),MakeColor(r,g,b),1)
		render()
		GetImage(num,0,0,32,32)
	next num	
endfunction

function fadeIn()
resetTimer()
time#=Timer()
repeat
	time#=Timer()
	r#=7-time#
	g#=7-time#
	b#=7-time#
	SetShaderConstantByName(fadeShader,"myColor",r#,g#,b#,0.2) //red green blue factor
	sync()	
until timer()>7.0
endfunction	

function fadeOut()
resetTimer()
time#=Timer()
repeat
	time#=Timer()
	r#=time#
	g#=time#
	b#=time#
	SetShaderConstantByName(fadeShader,"myColor",r#,g#,b#,0.2) //red green blue factor
	sync()	
until timer()>7.0
endfunction	


function mouseOver()
        
    myX as float
    myY as float
    my3dX as float
    my3dY as float
    my3dZ as float
    rayStartX as float
    rayStartY as float
    rayStartZ as float
    rayEndX as float
    rayEndY as float
    rayEndZ as float 
        
    myX=GetPointerX()
    myY=GetPointerY()
        
    my3dX=Get3DVectorXFromScreen(myX,myY)
    my3dY=Get3DVectorYFromScreen(myX,myY)
    my3dZ=Get3DVectorZFromScreen(myX,myY)
        
    rayStartX=my3dX+GetCameraX(1)
    rayStartY=my3dY+GetCameraY(1)
    rayStartZ=my3dZ+GetCameraZ(1)
        
    rayEndX=800*my3dX+GetCameraX(1)
    rayEndY=800*my3dY+GetCameraY(1)
    rayEndZ=800*my3dZ+GetCameraZ(1) 
        
    theObjectHit= ObjectRayCast(0,rayStartX,rayStartY,rayStartZ,rayEndX,rayEndY,rayEndZ)      
endfunction theObjectHit

function createShader()
file = OpenToWrite("fade.vs")
WriteLine(file,"attribute highp vec3 position;")
WriteLine(file,"attribute mediump vec3 normal;")
WriteLine(file,"attribute mediump vec2 uv;")
WriteLine(file,"varying highp vec3 posVarying;")
WriteLine(file,"varying mediump vec3 normalVarying;")
WriteLine(file,"varying mediump vec2 uvVarying;")
WriteLine(file,"varying mediump vec3 lightVarying;")
WriteLine(file,"uniform highp mat3 agk_WorldNormal;")
WriteLine(file,"uniform highp mat4 agk_World;")
WriteLine(file,"uniform highp mat4 agk_ViewProj;")
WriteLine(file,"uniform mediump vec4 uvBounds0;")
WriteLine(file,"mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );")
WriteLine(file,"void main()")
WriteLine(file,"{") 
WriteLine(file,"    uvVarying = uv * uvBounds0.xy + uvBounds0.zw;")
WriteLine(file,"    highp vec4 pos = agk_World * vec4(position,1.0);")
WriteLine(file,"    gl_Position = agk_ViewProj * pos;")
WriteLine(file,"    mediump vec3 norm = normalize(agk_WorldNormal * normal);")
WriteLine(file,"    posVarying = pos.xyz;")
WriteLine(file,"    normalVarying = norm;")
WriteLine(file,"    lightVarying = GetVSLighting( norm, posVarying );")
WriteLine(file,"}")	
CloseFile(file)

//pixel shader
file = OpenToWrite("fade.ps")
WriteLine(file,"uniform sampler2D texture0;")
WriteLine(file,"varying highp vec3 posVarying;")
WriteLine(file,"varying mediump vec3 normalVarying;")
WriteLine(file,"varying mediump vec2 uvVarying;")
WriteLine(file,"varying mediump vec3 lightVarying;")
WriteLine(file,"mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );")
WriteLine(file,"mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );")
WriteLine(file,"uniform vec4 myColor;")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file,"mediump vec3 norm = normalize(normalVarying);")
WriteLine(file,"mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying );")
WriteLine(file,"vec3 colorA = texture2D(texture0, uvVarying).rgb*light;")
WriteLine(file,"colorA.r-=(myColor.x*myColor.w);")
WriteLine(file,"colorA.g-=(myColor.y*myColor.w);")
WriteLine(file,"colorA.b-=(myColor.z*myColor.w);")
WriteLine(file,"colorA = clamp(colorA,0.0,1.0);") //restricts color range
WriteLine(file,"mediump vec3 color = ApplyFog( colorA, posVarying );")
WriteLine(file,"gl_FragColor = vec4(color,1.0);")
WriteLine(file,"}")
CloseFile(file)
endfunction


I think its my best attempt at a shader yet lol
Posted: 14th Mar 2018 6:14
I now have the fog and light working
but if I wanted the normal color effects to still work is there something I need to add in the shader
Posted: 14th Mar 2018 9:03
I think you should add :
vec4 agk_MeshDiffuse

To your shader and change the line :
+ Code Snippet
vec3 colorA = texture2D(texture0, uvVarying).rgb*light;


By
+ Code Snippet
vec3 colorA = texture2D(texture0, uvVarying).rgb*light *agk_MeshDiffuse;


But im not sur (I Cant test, i post with my tablet)
Posted: 14th Mar 2018 14:51
Thanks blender

in the pixel shader I added
uniform mediump vec4 agk_MeshDiffuse;
and made your change to
vec3 colorA = texture2D(texture0, uvVarying).rgb*light *agk_MeshDiffuse;

That worked a treat.
Its something ive been working with Puzzler on the minecraft thread to help show mouse over blocks.
Theres several ways of been trying to show the mouse over, adding agk_MeshDiffuse to the shader
allows the blocks to be darkened during mouse over
Posted: 17th Mar 2018 7:15
Hi

I have found a glsl shader editor :
https://www.opengl.org/sdk/tools/ShaderDesigner/

I havent tried it, but it could interesting.

And another but in webgl :
https://shaderfrog.com/app
Posted: 19th Mar 2018 19:09
I follow the great hard work of Satman
https://forum.thegamecreators.com/thread/221599
as well as janbo's shader pack, which I've already purchased.
https://forum.thegamecreators.com/thread/220091
I dind't found a solution to my specific needs, and I believe it is easy an eay task for a shader guy.
What I need is:
- apply a small size texture, to a flat ground plane (CreateObjectPlane)
- scale the texture
- apply a second small size texture, to the ground
- scale the second texture also.
- apply a larger texture as mask to reveal parts of the second texture beneath the first.
Here is what I mean with images:

Can someone help me?
Posted: 19th Mar 2018 19:31
George++ :
In this example, i have blend two textures with an alpha :
https://forum.thegamecreators.com/thread/214598?page=1#msg2573831

In the vertex and the fragment, you have to add a uvchanel : varying vec2 uv1varying; // for the alpha texture size for example

In the fragment you use this 2nd uv channel in colorResult2 : vec4 colorResult2 = texture2d (texture2, uv1varying);

And that should work. You must change the uvscale of the texture of the ground.
Posted: 20th Mar 2018 2:39
Finishing revisiting all other engines but i still like agk2 tier 1...

But ermmm when i tried unity, unreal and godot the scene render better than agk2 and i guess that is Global Illumination sort of thing. is there any shader to do Gi in matter of on/off shader rather then lengthly setup?

SetGloballIlumination(1) alike

Sorry...kind of demamding but fell short when i see other engine.

Thanks
Posted: 20th Mar 2018 7:28
Blendman:
I tried your example without success. The only visible is the texture at stage 1. Here is my code:
+ Code Snippet
#include "../agklib/device.agc"
#include "../agklib/pointer.agc"
#include "../agklib/camera.agc"

img_grass as integer
img_dirt as integer
img_mask as integer
plane as integer
shader as integer

cam as _Camera

// set window properties
SetWindowTitle("probe")

device_Init(1024, 768, 0)
pointer_Init()

img_grass = LoadImage("grass.png")
img_dirt = LoadImage("dirt.png")
img_mask = LoadImage("mask.png")

plane = CreateObjectPlane(10.0, 10.0)
SetObjectRotation(plane, 90.0, 0.0, 0.0)
SetObjectImage(plane, img_grass, 0)
SetObjectImage(plane, img_dirt, 1)
SetObjectImage(plane, img_mask, 2)

shader = LoadShader("alpha.vs", "alpha.ps")
SetObjectShader(plane, shader)

camera_Create(cam, 0.0, 2.5, 0.0, 20.0, 0.0, 0.0, 0)
camera_SetActive(cam, 1)
cam.pitch_max = 80.0

do
	pointer_Update()
	camera_Update(cam)
    Sync()
loop

DeleteImage(img_grass)
DeleteImage(img_dirt)
DeleteImage(img_mask)
Posted: 20th Mar 2018 9:22
Sorry...kind of demamding but fell short when i see other engine.

AGK isn't an engine, it's a programming language. Please compare AppGameKit to the languages that were used to program other game engines. C++ doesn't have global illumination (for example), that's what shaders are for, and you can get all kinds of shaders in the forums, or the shader pack.
Posted: 20th Mar 2018 9:25
I dind't found a solution to my specific needs

I made you a Demo: Texture Mask.zip
But I think if you just wait one more day, you will be surprised


AGK isn't an engine, it's a programming language

Still fighting that war ?
Posted: 20th Mar 2018 9:29
@George++ :
sorry, I have forgoten to add some lines.

Here is a shader which works

The shader (with lighting and fog, but no normalmap, I can add it if needed) :

Vertex :
+ Code Snippet
// terrain with 2 textures  for ground and an alpha for the road
attribute highp vec3 position;
attribute vec2 uv;
attribute mediump vec3 normal;
varying highp vec3 posVarying;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );

varying vec2 uv0Varying;
varying vec2 uv1Varying;
varying vec2 uv2Varying;
uniform vec4 uvBounds0;
uniform vec4 uvBounds1;
uniform vec4 uvBounds2;
  
uniform highp mat4 agk_WorldViewProj;
uniform highp mat3 agk_WorldNormal;
uniform highp mat4 agk_World;
uniform highp mat4 agk_ViewProj;
 
void main()
{

	highp vec4 pos = agk_World * vec4(position,1.0);
    gl_Position = agk_ViewProj * pos;
    mediump vec3 norm = normalize(agk_WorldNormal * normal);
    posVarying = pos.xyz;
    normalVarying = norm;
    lightVarying = GetVSLighting( norm, posVarying );
	
	// TEXTURES COORDS	
    uv0Varying = uv * uvBounds0.xy + uvBounds0.zw;
    uv1Varying = uv * uvBounds1.xy + uvBounds1.zw;
    uv2Varying = uv * uvBounds2.xy + uvBounds2.zw;
}



pixel :
+ Code Snippet
// constant values sent through from AGK code.
uniform sampler2D texture0; // ground
uniform sampler2D texture1; // road
uniform sampler2D texture2; // mask 
 
varying vec2 uv0Varying; // uv for ground
varying vec2 uv1Varying; // uv for road
varying vec2 uv2Varying; // uv for the "alpha mask"

varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
varying highp vec3 posVarying;
mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );
uniform mediump vec4 agk_MeshDiffuse;
uniform mediump vec4 agk_MeshEmissive;
 
void main()
{
	// the textures coords
	vec4 colorResult0  = texture2D(texture0, uv0Varying);
	vec4 colorResult1  = texture2D(texture1, uv1Varying);
	vec4 colorResult2  = texture2D(texture2, uv2Varying);
   
    mediump vec4 blendTex = vec4(1.0,1.0,1.0,1.0);
    mediump vec3 norm = normalize(normalVarying);
    mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying ); 

	// mix with the R color of the 3rd texture. You can use the G and b channel for another road
	gl_FragColor = mix(colorResult0, colorResult1, colorResult2.r); 
	
	// add light
	gl_FragColor = gl_FragColor * blendTex * vec4(light,1.0) * agk_MeshDiffuse + agk_MeshEmissive;
	
	// add fog
	gl_FragColor.rgb = ApplyFog( gl_FragColor.rgb, posVarying );

}




The result :




@Hoyoyo80 :

You're right, the unreal/ unity/ godot render is really impressive, and better than AGk, for the moment .

Global illumination in GLSL (not very easy ^^):
https://realtimeillumination.wordpress.com/tag/glsl/


It's not only Global illumination (GI), I guess they have lots of parameters for lighting and a better render (shader, post-effect) :
- diffuse shader : in unity/unreal/godot we have the choice of the diffuse shader (lambert, oren-nayar...), with lots of parameters to change, in agk we have only one shader with no options.
- specular shader : in agk, we haven't that shader . In other engine, same as diffuse shader : lots of choice and parameters to change

Lighting :
- all use lightmaps baked (or in realtime for PC) with internal lightmapper, GI probe, SSAO, Ambient Occlusion, and lots of other great parameters.
- in AppGameKit, we have only 2 basics lights (1 directional (sun) and pointlight) but, we can't even set the parameters of the light (fall of, attenuation, linear...).
- shadows : all 3 engines use soft shadows system. Currently, the shadow system isn't as good as the other engine.
- post-prod : they use post-fx like bloom, saturation/contraste... We can do that in AGk with fullscreenshader. For Dof and other interesting effect, you have the janbo shaders .

Agk doesn't have a lightmap (like unity/godot or unreal), so we have to bake our lightmap in our 3Dmodeler.

If you want better lighting, you should use lightmap baked (from blender) :


Example of AppGameKit lighting :


- sun, ambient, shadow : not bad, but not very good ^^


- sun, ambient, no shadow, lightmap (baked) : much better


- Only the lightmap (baked) without texture, no light, no sun, no ambient, no shadow...

Note :
Lightmap is created in blender : with softshadows, AmbientOcclusion, GI... (mix of blender internal and cycle rendering)

@Mobius : agk is not only a langage.
From AppGameKit website : "AppGameKit is a game creation system for mobile cross platform development."
"game creation system" seems to be like "game engine + langage to use it" ^^
Posted: 20th Mar 2018 9:46
You are awesome guys!
Posted: 21st Mar 2018 2:58
Maybe i dont use the right term for agk2 but the main site state it is an engine. But nevermind, request for a Gi shader is my point...

Blenderman, ur editor surely look lovely
Posted: 21st Mar 2018 9:45
Hi

Here is a "base" for cartoon shader (source : http://www.lighthouse3d.com/tutorials/glsl-12-tutorial/toon-shading-version-iii/).

I think the lighting (direction of the sun) / position of the light isn't good.
I don't know how to set the direction of the sun to get a proper lighting. But it's a good start I guess .



Basic shader (agk) :





Vertex :
+ Code Snippet
attribute highp vec3 position;
attribute mediump vec3 normal;
varying highp vec3 posVarying;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );

uniform highp mat4 agk_WorldViewProj;
uniform highp mat3 agk_WorldNormal;
uniform highp mat4 agk_World;
uniform highp mat4 agk_ViewProj;
attribute highp vec2 uv;
varying highp vec2 uvVarying;
uniform highp vec4 uvBounds0;

void main()
{ 
    uvVarying = uv * uvBounds0.xy + uvBounds0.zw;
    highp vec4 pos = agk_World * vec4(position,1.0);
    gl_Position = agk_ViewProj * pos;
    mediump vec3 norm = normalize(agk_WorldNormal * normal);
    posVarying = pos.xyz;
    normalVarying = norm;
    lightVarying = GetVSLighting( norm, posVarying );
	
}



Pixel :

Multiply mode :


+ Code Snippet
uniform sampler2D texture0;
varying highp vec2 uvVarying;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
varying highp vec3 posVarying;
mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );
uniform mediump vec4 agk_MeshDiffuse;
uniform mediump vec4 agk_MeshEmissive;
 
void main()
{
	mediump vec4 color = texture2D(texture0, uvVarying);
	mediump vec4 blendTex = vec4(1.0,1.0,1.0,1.0);
    mediump vec3 norm = normalize(normalVarying);
    mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying ); 

	float intensity;
	vec4 color1;
	intensity = dot(GetPSLighting( norm, posVarying ), norm);
	
	
	
	if (intensity > 0.60)
		color1 = vec4(1.0,1.0,1.0,1.0);
	else if (intensity > 0.5)
		color1 = vec4(0.8,0.8,0.8,1.0);
	else if (intensity > 0.25)
		color1 = vec4(0.6,0.6,0.6,1.0);
	else
		color1 = vec4(0.5,0.5,0.5,1.0);
	
	
    gl_FragColor = color1 * color * blendTex * vec4(light,1.0) * agk_MeshDiffuse + agk_MeshEmissive;
	gl_FragColor.rgb = ApplyFog( gl_FragColor.rgb, posVarying );
}





Additive mode :


+ Code Snippet
uniform sampler2D texture0;
varying highp vec2 uvVarying;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
varying highp vec3 posVarying;
mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );
uniform mediump vec4 agk_MeshDiffuse;
uniform mediump vec4 agk_MeshEmissive;
 
void main()
{
	mediump vec4 color = texture2D(texture0, uvVarying);
	mediump vec4 blendTex = vec4(1.0,1.0,1.0,1.0);
    mediump vec3 norm = normalize(normalVarying);
    mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying ); 

	float intensity;
	vec4 color1;
	intensity = dot(GetPSLighting( norm, posVarying ), norm);

	if (intensity > 0.95)
		color1 = vec4(0.6,0.6,0.6,1.0);
	else if (intensity > 0.5)
		color1 = vec4(0.5,0.5,0.5,1.0);
	else if (intensity > 0.25)
		color1 = vec4(0.3,0.3,0.3,1.0);
	else
		color1 = vec4(0.1,0.1,0.1,1.0);
	
	// add a little multiply to not get a result with too much lighting
    gl_FragColor = color1 + (0.6+color1*0.4) * color * blendTex * vec4(light,1.0) * agk_MeshDiffuse + agk_MeshEmissive;
	gl_FragColor.rgb = ApplyFog( gl_FragColor.rgb, posVarying );
}






To change the cartoon "style", you have to change this part and set what you want :

+ Code Snippet
if (intensity > 0.60)
		color1 = vec4(1.0,1.0,1.0,1.0);
	else if (intensity > 0.5)
		color1 = vec4(0.8,0.8,0.8,1.0);
	else if (intensity > 0.25)
		color1 = vec4(0.6,0.6,0.6,1.0);
	else
		color1 = vec4(0.5,0.5,0.5,1.0);
Posted: 2nd Apr 2018 9:24
Thinking back to the minecraft thread I was wondering if at all possible to pass vertices of part of a mesh to a shader
so as just those vertices are colored. This would allow blocks within the mesh to be different colors

no need to answer Its been solved it without the use of a shader
https://forum.thegamecreators.com/thread/221994
Posted: 10th May 2018 20:35
I'm getting in love with this shader effect since long time ago.

http://fire-face.com/personal/water/

What do you think, Is it doable in AppGameKit?