Improve shading
parent
3456aa2105
commit
d99356ef00
|
@ -67,6 +67,7 @@ uniform mat4 mScene;
|
|||
out vec4 color;
|
||||
out vec3 norm;
|
||||
out vec2 uv;
|
||||
out vec3 coord;
|
||||
|
||||
out float shading;
|
||||
|
||||
|
@ -86,14 +87,9 @@ void main()
|
|||
float sight = clamp( idist * idist * idist, 0.1, 1.0);
|
||||
//sight = 1;
|
||||
|
||||
if (norm.z > 0){
|
||||
fading = 0;
|
||||
} else {
|
||||
|
||||
};
|
||||
|
||||
shading = clamp(0.3 + (cosTheta * 0.7), 0.1, 0.9);
|
||||
color = clamp( vec4( iv_color.xyz * shading * sight, fading ), 0, 1);
|
||||
coord = camray;
|
||||
}
|
||||
|
||||
";
|
||||
|
@ -103,6 +99,7 @@ private string defFragmentShaderSource = @"#version 330
|
|||
in vec4 color;
|
||||
in vec3 norm;
|
||||
in vec2 uv;
|
||||
in vec3 coord;
|
||||
|
||||
in float shading;
|
||||
|
||||
|
@ -110,6 +107,12 @@ out vec4 _color;
|
|||
|
||||
void main()
|
||||
{
|
||||
float cosTheta = dot( -coord, norm );
|
||||
|
||||
if (cosTheta >= 0){
|
||||
discard;
|
||||
};
|
||||
|
||||
_color = color;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue