diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-03-04 16:05:02 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-03-04 15:21:01 +0000 |
commit | c82207d54c76d8b66be010bfa63e45f9507891fa (patch) | |
tree | 8d112e96bc1fa42dbc49907f53d71fa5b893869a /examples/wave/shaders/ribbonwireframe.frag | |
parent | 8bff6813ee2e7a59d27bd8639dc9a6e23287a0c8 (diff) |
Move the examples under a qt3d subdir
Modules cannot have their examples in the top-level examples directory because
in the pre-built packages all modules' examples are merged together.
Change-Id: I80fdbb8f1ec6f3d8fd793e4d856e705000237127
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'examples/wave/shaders/ribbonwireframe.frag')
-rw-r--r-- | examples/wave/shaders/ribbonwireframe.frag | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/examples/wave/shaders/ribbonwireframe.frag b/examples/wave/shaders/ribbonwireframe.frag deleted file mode 100644 index 659f00a8a..000000000 --- a/examples/wave/shaders/ribbonwireframe.frag +++ /dev/null @@ -1,98 +0,0 @@ -#version 330 core - -in WireframeVertex { - vec3 position; - vec3 normal; - noperspective vec4 edgeA; - noperspective vec4 edgeB; - flat int configuration; -} fs_in; - -out vec4 fragColor; - -uniform struct LightInfo { - vec4 position; - vec3 intensity; -} light; - -uniform struct LineInfo { - float width; - vec4 color; -} line; - -uniform vec3 ka; // Ambient reflectivity -uniform vec3 kd; // Diffuse reflectivity - -vec3 rimLightModel( const in vec3 pos, const in vec3 n ) -{ - // Calculate the vector from the light to the fragment - vec3 s = normalize( vec3( light.position ) - pos ); - - // Calculate the vector from the fragment to the eye position (the - // origin since this is in "eye" or "camera" space - vec3 v = normalize( -pos ); - - // Refleft the light beam using the normal at this fragment - vec3 r = reflect( -s, n ); - - // Calculate the diffuse component, which for rim lighting it 1 minus s dot n - // rather than s dot n as for standard diffuse lighting - float sDotN = dot( s, n ); - vec3 diffuse = vec3( 1.0 - max( sDotN, 0.0 ) ); - - // Combine the ambient, diffuse and specular contributions - return light.intensity * ( ka + kd * diffuse ); -} - -vec4 shadeLine( const in vec4 color ) -{ - // Find the smallest distance between the fragment and a triangle edge - float d; - if ( fs_in.configuration == 0 ) { - // Common configuration - d = min( fs_in.edgeA.x, fs_in.edgeA.y ); - d = min( d, fs_in.edgeA.z ); - } else { - // Handle configuration where screen space projection breaks down - // Compute and compare the squared distances - vec2 AF = gl_FragCoord.xy - fs_in.edgeA.xy; - float sqAF = dot( AF, AF ); - float AFcosA = dot( AF, fs_in.edgeA.zw ); - d = abs( sqAF - AFcosA * AFcosA ); - - vec2 BF = gl_FragCoord.xy - fs_in.edgeB.xy; - float sqBF = dot( BF, BF ); - float BFcosB = dot( BF, fs_in.edgeB.zw ); - d = min( d, abs( sqBF - BFcosB * BFcosB ) ); - - // Only need to care about the 3rd edge for some configurations. - if ( fs_in.configuration == 1 || - fs_in.configuration == 2 || - fs_in.configuration == 4 ) { - float AFcosA0 = dot( AF, normalize( fs_in.edgeB.xy - fs_in.edgeA.xy ) ); - d = min( d, abs( sqAF - AFcosA0 * AFcosA0 ) ); - } - - d = sqrt( d ); - } - - // Blend between line color and shaded color - float mixVal; - if ( d < line.width - 1.0 ) { - mixVal = 1.0; - } else if ( d > line.width + 1.0 ) { - mixVal = 0.0; - } else { - float x = d - ( line.width - 1.0 ); - mixVal = exp2( -2.0 * ( x * x ) ); - } - - return mix( color, line.color, mixVal ); -} - -void main() -{ - vec3 n = gl_FrontFacing ? fs_in.normal : -fs_in.normal; - vec4 color = vec4( rimLightModel( fs_in.position, normalize( n ) ), 1.0 ); - fragColor = shadeLine( color ); -} |