<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Shader effect displayed as 1&#x2F;4 of screen]]></title><description><![CDATA[<p dir="auto">Hi all.</p>
<p dir="auto">I want to implement a (Dizzy) shader effect, taken from the 'AMD RenderMonkey' utility.<br />
A source code of that shaders are:</p>
<p dir="auto">== vertex ==</p>
<pre><code>varying vec2 vTexCoord;
void main(void)
{
   // Clean up inaccuracies
   vec2 Position;
   Position.xy = sign(gl_Vertex.xy);
   gl_Position = vec4(Position.xy, 0.0, 1.0);
   vTexCoord = Position.xy;
}
</code></pre>
<p dir="auto">== fragment ==</p>
<pre><code>// Basic idea:
// Rings = sin(radius)
// Spiral = slow offset according to angle, so sin(angle + radius)
// Add time for animation
uniform float exponent;
uniform float speed;
uniform float rings;
uniform float time_0_X;
varying vec2 vTexCoord;

void main(void)
{
   float ang = atan( vTexCoord.y / vTexCoord.x );
   float rad = pow( dot( vTexCoord, vTexCoord ), exponent );
   vec4 value =  vec4( sin( ang + rings * rad + speed * time_0_X ) );
   value = vec4( 0.5, 0.5, 0.5, 0.5 ) * ( vec4( 1.0, 1.0, 1.0, 1.0 ) + value );
   if( vTexCoord.x &lt; 0.0 ) 
   {   
      value = 1.0 - value;
   }
   gl_FragColor = value;
}
</code></pre>
<p dir="auto">I have modified this code to the my QML application with a shader effect item:</p>
<pre><code>ShaderEffect {
        ...
        ...
        blending: false

        vertexShader: "
            uniform highp mat4 qt_Matrix;
            attribute highp vec4 qt_Vertex;
            attribute highp vec2 qt_MultiTexCoord0;
            varying highp vec2 qt_TexCoord0;
            void main() {
                qt_TexCoord0 = qt_MultiTexCoord0;
                gl_Position = qt_Matrix * qt_Vertex;
            }"

        fragmentShader: "
            // Basic idea:
            // Rings = sin(radius)
            // Spiral = slow offset according to angle, so sin(angle + radius)
            // Add time for animation

            uniform float exponent;
            uniform float speed;
            uniform float rings;
            uniform float time_0_X;
            uniform highp mat4 qt_Matrix;
            varying vec2 qt_TexCoord0;

            void main(void)
            {
               float ang = atan( qt_TexCoord0.y / qt_TexCoord0.x );
               float rad = pow( dot( qt_TexCoord0, qt_TexCoord0 ), exponent );
               vec4 value =  vec4( sin( ang + rings * rad + speed * time_0_X ) );
               value = vec4( 0.5, 0.5, 0.5, 0.5 ) * ( vec4( 1.0, 1.0, 1.0, 1.0 ) + value );
               if( qt_TexCoord0.x &lt; 0.0 )
               {
                  value = 1.0 - value;
               }
               gl_FragColor = value;
            }
        "
        ...
        ...
}
</code></pre>
<p dir="auto">But, in my case, the QML's effect show an 1/4 of original dizzy. I suspect that a reason can be in a different coordinates mesh in qt (where are 0.0 ... 1.0) and in OpenGL (where are -1.0 ... 1.0). But I'm not an expert, and I don't know how to fix my shaders according to original dizzy example.</p>
<p dir="auto">Could someone help me?</p>
<p dir="auto"><a href="https://pasteboard.co/HmnpQHw.png" target="_blank" rel="noopener noreferrer nofollow ugc">Original</a></p>
<p dir="auto"><a href="https://pasteboard.co/Hmnqaw7.png" target="_blank" rel="noopener noreferrer nofollow ugc">My</a></p>
]]></description><link>https://forum.qt.io/topic/90947/shader-effect-displayed-as-1-4-of-screen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 06:27:24 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/90947.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 May 2018 16:04:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Shader effect displayed as 1&#x2F;4 of screen on Tue, 22 May 2018 16:17:57 GMT]]></title><description><![CDATA[<p dir="auto">Ahh... need just to add an offset (-0.5, -0.5) to the vertex shader:</p>
<pre><code>qt_TexCoord0 = qt_MultiTexCoord0 + vec2(-0.5, -0.5);
</code></pre>
]]></description><link>https://forum.qt.io/post/459618</link><guid isPermaLink="true">https://forum.qt.io/post/459618</guid><dc:creator><![CDATA[kuzulis]]></dc:creator><pubDate>Tue, 22 May 2018 16:17:57 GMT</pubDate></item></channel></rss>