Commit 118ee100 authored by Anne Berres's avatar Anne Berres

[REMOVE] Removed the surface sorting part from GLSL to improve efficiency

* will add this to C++ part
* merged matte phong into this branch
parent 7201e3a8
......@@ -206,6 +206,109 @@ float blinnPhongIlluminationIntensity( in vec3 normal )
return blinnPhongIlluminationIntensity( wge_DefaultLightIntensity, normal );
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
*
* \param ambient materials ambient color
* \param diffuse materials diffuse color
* \param lightColor the light color
* \param ambientLight the ambient light color
* \param normalDir the normal
* \param viewDir viewing direction
* \param lightDir light direction
*
* \return the color.
*/
vec4 mattePhongIllumination( vec3 ambient, vec3 diffuse,
vec3 lightColor, vec3 ambientLight,
vec3 normalDir, vec3 viewDir, vec3 lightDir )
{
vec3 H = normalize( lightDir + viewDir );
// compute ambient term
vec3 ambientV = ambient * ambientLight;
// compute diffuse term
float diffuseLight = max( dot( lightDir, normalDir ), 0.0 );
vec3 diffuseV = diffuse * diffuseLight;
return vec4( ambientV + diffuseV * lightColor, 1.0 );
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity.
*
* \param ambient materials ambient intensity
* \param diffuse materials diffuse intensity
* \param specular materials specular intensity
* \param shininess material shininess
* \param lightIntensity the light intensity
* \param ambientIntensity the ambient light intensity
* \param normalDir the normal
* \param viewDir viewing direction
* \param lightDir light direction
*
* \return the light intensity.
*/
float mattePhongIlluminationIntensity( float ambient, float diffuse,
float lightIntensity, float ambientIntensity,
vec3 normalDir, vec3 viewDir, vec3 lightDir )
{
vec3 H = normalize( lightDir + viewDir );
// compute ambient term
float ambientV = ambient * ambientIntensity;
// compute diffuse term
float diffuseLight = max( dot( lightDir, normalDir ), 0.0 );
float diffuseV = diffuse * diffuseLight;
return ambientV + diffuseV * lightIntensity;
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* Any specular or shininess given with the parameters will be ignored.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity.
*
* \param parameter the wge_LightIntensityParameter defining material and light
* \param normal the normal. Needs to be normalized.
*
* \return lighting intensity.
*/
float mattePhongIlluminationIntensity( in wge_LightIntensityParameter parameter, in vec3 normal )
{
return mattePhongIlluminationIntensity(
parameter.materialAmbient,
parameter.materialDiffuse,
parameter.lightDiffuse,
parameter.lightAmbient,
normal,
parameter.viewDirection,
parameter.lightPosition
);
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity. This uses the wge_DefaultLightIntensity without the specular and shininess.
*
* \param normal the normal. Must be normalized beforehand
*
* \return the light intensity
*/
float mattePhongIlluminationIntensity( in vec3 normal )
{
wge_LightIntensityParameter noSpecular = wge_DefaultLightIntensity;
noSpecular.materialShinines = 0.0;
noSpecular.materialSpecular = 0.0;
return mattePhongIlluminationIntensity( noSpecular, normal );
}
/**
* This illumination technique is from "Jens Krüger and Rüdiger Westermann - EFFICIENT STIPPLE RENDERING". It is a non-linear illumination model
* which only handles ambient and diffuse components. The parameter alpha determines how much the diffuse light should depend on the orientation
......
......@@ -177,7 +177,7 @@ void rayCast( in vec3 curPoint, in float isovalue, in vec4 isocolor )
float light = 1.0;
#ifdef PHONGSHADING_ENABLED
// only calculate the phong illumination only if needed
light = blinnPhongIlluminationIntensity( normalize( normal ) );
light = mattePhongIlluminationIntensity( normalize( normal ) );
#endif
// 5. set color
......@@ -247,33 +247,33 @@ void main()
vec3 curPoint = v_rayStart + v_ray;
#endif
// sort the isovalues (and their colors) in ascending order
vec4 isovalues;
mat4 isocolors;
// determine order (largest value first)
ivec4 order = ivec4( greaterThan( vec4( v_isovalues[0] ), v_isovalues ) ) +
ivec4( greaterThan( vec4( v_isovalues[1] ), v_isovalues ) ) +
ivec4( greaterThan( vec4( v_isovalues[2] ), v_isovalues ) ) +
ivec4( greaterThan( vec4( v_isovalues[3] ), v_isovalues ) );
// sort the values according to the determined order
for( int i = 0; i < 4; i++ )
{
isovalues[i] = v_isovalues[ order[i] ];
isocolors[i] = u_isocolors[ order[i] ];
}
// // sort the isovalues (and their colors) in ascending order
// vec4 isovalues;
// mat4 isocolors;
// // determine order (largest value first)
// ivec4 order = ivec4( greaterThan( vec4( v_isovalues[0] ), v_isovalues ) ) +
// ivec4( greaterThan( vec4( v_isovalues[1] ), v_isovalues ) ) +
// ivec4( greaterThan( vec4( v_isovalues[2] ), v_isovalues ) ) +
// ivec4( greaterThan( vec4( v_isovalues[3] ), v_isovalues ) );
// // sort the values according to the determined order
// for( int i = 0; i < 4; i++ )
// {
// isovalues[i] = v_isovalues[ order[i] ];
// isocolors[i] = u_isocolors[ order[i] ];
// }
float isovalue;
vec4 isocolor;
// for each isosurface, set the isovalue + isocolor and call the raytracer
for( int j = 0; j < u_surfCount; j++ )
{
isovalue = isovalues[j];
isovalue = v_isovalues[j];
#ifdef MANUALALPHA_ENABLED
// pick individual alpha values for all surfaces
isocolor = isocolors[j];
// isocolor = isocolors[j];
#else
// use value-dependent alpha
isocolor = vec4( isocolors[j].rgb, isovalue );
isocolor = vec4( u_isocolors[j].rgb, isovalue );
#endif
rayCast( curPoint, isovalue, isocolor );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment