I try to convert an hlsl Sky shader to glsl and cant figure out how to do a proper NdotL calculation.
So, what else for tools are usable to write/debug glshaders ?
Currently iam just using the material editor and 3DLabs glsl validator and leaning from
lighthouse3d and clockworkcoders.
If you want to take a look into the shader iam messing around with
#extension GL_ARB_draw_buffers : enable
uniform sampler2D texture0;
uniform float apptime;
uniform vec3 lightdir;
uniform vec3 sunpos;
varying vec2 texcoord0;
varying vec3 vertexposition;
varying vec3 N;
void main(void) {
vec3 sunvector = normalize(-vertexposition.xyz + lightdir);
vec2 TexCoord = vec2(apptime/40000.0, texcoord0.y * 2.0);
vec4 color = texture2D( texture0, TexCoord );
float glowfactor = 0.2; // 0.6
float dotproduct = max(dot(-N, sunvector), 0.0);
float sunglow = pow(dotproduct, 2.0) * glowfactor;
if (dotproduct > 0.0) // near to sun
{
float sun = pow(dotproduct, 128.0) * 0.6; // * 0.6
color.rgb += sun + sunglow; // * sunglow
}
else // reverse side
{
float intensity = 0.299 * color.r + 0.578 * color.g + 0.114 * color.b;
color.rgb -= sunglow/2.0;
color = mix(color, vec4(intensity, intensity, intensity, color.a), sunglow);
}
gl_FragData[0] = color;
gl_FragData[1] = vec4(1.0,1.0,1.0,0.0);
gl_FragData[2] = vec4(0.0);
gl_FragData[3] = vec4(0.0);
}
material file is calling
shader="abstract::mesh_diffuse.vert","abstract::SkySphere.frag"
and the image mapped to a sphere model
[edit]
passing vars to shader
//pass shader
TShader scatterShader = GetMaterialShader(scatterMat);
//from Renderer::DrawEffectGodRays
TVec3 lightdir;
lightdir = TFormNormal(Vec3(0,0,1), sun, fw.GetMain().GetCamera() );
TVec3 sunPos;
sunPos = EntityPosition (sun);
SetShaderFloat(scatterShader, "apptime", AppTime() );
SetShaderVec3 (scatterShader, "lightdir", lightdir );
SetShaderVec3 (scatterShader, "sunpos", sunPos );
It suppose to look like this
FrameLuaSampleScatterSimple
but the sun is moving with the cameraPos atm.
any help on wrapping my head around LE`s glsl very welcome.