Original Post
Hi, I'm trying to implement the scattering terms by hoffman/preetham in Rendermonkey with GLSL. But my output is...well it's just white and has holes! I have a rendermonkey zip file if someone wants to see it in action... The following is the vertex shader i use. I know this can be optimized a lot but i just want to see it working...then I will optimize it :) in the fragment shader I just add F_ex and L_in together as output color for the skydome! I think that I've missed something in the paper. But I don't know what. Is there anyone can help me or give some suggestions? -------- Bebud :) [EDIT by mittens] Threw your snippet in some source tags. [Edited by - mittens on July 27, 2005 8:22:29 AM]
uniform vec3 sunDir; // should be normalized
const vec3 bethaR = vec3(0.00000695, 0.0000118, 0.0000244);
const vec3 bethaM = vec3(0.0000004, 0.0000006, 0.0000024);
uniform float g;
uniform vec4 sunColor;
varying vec3 L_in;
varying vec3 F_ex;
varying vec2 vTexCoord0;
uniform vec3 reflectance;
uniform vec4 vViewPosition;
void main(void)
{
vTexCoord0 = gl_MultiTexCoord0.xy;
vec3 gConst = vec3(pow(1.0-g,2.0), 1.0+pow(g,2.0), 2.0*g);
vec3 ecPosition = gl_Vertex.xyz;
float s = length(ecPosition-vViewPosition.xyz);
F_ex = exp((bethaR + bethaM)* (-s));
vec3 ecDirection = normalize(ecPosition);
float cos0 = dot(sunDir, ecDirection);
//just for prototyping -------------------->
float bethaRay = 3.0/(16.0 * 3.1415926535897932384626433832795);
float bethaMie = 1.0/(4.0 * 3.1415926535897932384626433832795);
//just for prototyping <--------------------
float phiR = bethaRay * (1.0 + pow(cos0,2.0));
float phiM = bethaMie * gConst.x / pow(gConst.y - gConst.z * cos0, 1.5 );
L_in = ( phiR + phiM )/( bethaR + bethaM ) * sunColor.xyz *
( 1.0 - F_ex );
vec3 totalF_ex = F_ex * sunColor.xyz * reflectance;
F_ex = totalF_ex * sunColor.w;
L_in *= sunColor.w;
gl_Position = ftransform();
}
