Hi
There are several types for lightmapping :
- lightmap : light + shadow (+ao, gi...) -> blendmode "overlay" ?
- shadowmap : only "shadow" (+ao) -> blendmode multiply (or color burn sometimes).
Another one could be (but not very interesting ^^) :
- "OnlyLightMap" : only lighting (+Gi, radiosity, light bounce...) -> blendmode "add" or "screen".
A lightmap is in color (RGB), it's not necessary to have an alpha channel, if you use the function of AppGameKit : SetObjectLightMap()
I think, the blendmode for this image is near the "overlay" photoshop blendmode.
All colors < rgb(127,127,127) will be used as shadow (multiply or perhap's burncolor mode)
All colors >= rgb(128,128,128) will be used as light (add mode)
So in multiply (or add) blendmode, you can have colors, not only white & black.
Here is a 3D multiply shader example :
Multiply.ps :
// Shader test for AGE (agk game editor)
uniform sampler2D texture0;
uniform sampler2D texture1;
varying highp vec2 uvVarying;
varying highp vec2 uv1Varying;
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 blendTex = vec4(1.0,1.0,1.0,1.0);
mediump vec3 norm = normalize(normalVarying);
mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying );
vec4 color = texture2D(texture0, uvVarying);
vec4 color1 = texture2D(texture1, uv1Varying);
gl_FragColor = color * color1;
gl_FragColor = gl_FragColor * blendTex * vec4(light,1.0) * agk_MeshDiffuse + agk_MeshEmissive;
gl_FragColor.rgb = ApplyFog( gl_FragColor.rgb, posVarying );
}
Multiply.vs :
// vs
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;
varying highp vec2 uv1Varying;
uniform highp vec4 uvBounds0;
uniform highp vec4 uvBounds1;
void main()
{
uvVarying = uv * uvBounds0.xy + uvBounds0.zw;
uv1Varying = uv * uvBounds1.xy + uvBounds1.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 );
}
And a screenshot with comparison
Left : shader multiply / Right : AppGameKit lightmap
No sun / no shadow, just SetAmbientColor(120,120,120) for this test
I hope this can help
AGK2 tier1 - http://www.dracaena-studio.com