Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Shader linking fails when editing a copy of gl_PointCoord

  1. #1
    Intern Contributor
    Join Date
    May 2003
    Location
    Dortmund, Germany
    Posts
    60

    Shader linking fails when editing a copy of gl_PointCoord

    Hi!

    I try to fake rotatable pointsprites by rotating the calculated
    gl_PointCoord in the fragment shader.
    For some strange reason the linking of the program
    fails as soon as I try to modify a _copy_ of the gl_PointCoord
    values.
    This is the error (including a typo from a nv dev ):
    error C7001: inconsitent use of semantic modifiers: "sin_a" and "gl_PointCoord"

    This is my fragment shader:
    Code :
    uniform sampler2D u_base;
     
    varying float sin_a;
    varying float cos_a;
     
    void main()
    {
    	// apply rotation
    	vec2 coords = gl_PointCoord;
    	/*
    	coords = coords * 2.0 - 1.0; // [0, 1] ->[-1, 1]
    	float xx = cos_a * coords.x + sin_a * coords.y;
    	coords.y = -sin_a * coords.x + cos_a * coords.y;
    	coords.x = xx;
    	coords = (coords + 1.0) * 0.5;  // [-1, 1] -> [0, 1]
    	*/
     
    	vec3 color = texture2D(u_base, coords).rgb;
    	gl_FragColor = vec4(color, 1.0) * gl_Color;
    }
    The vertex shader
    Code :
     varying float sin_a;
     varying float cos_a;
     
     void main()
     {
     	vec4 vtx = gl_ModelViewMatrix * vec4(gl_Vertex.xyz, 1.0);
     
     	// distance attenuation
    	// add an epsilon 'cause zero size is undefined for pointsprites
    	gl_PointSize = VIEWPORT_WIDTH * gl_Vertex.w * 2.0 / -vtx.z + 0.01;
     
    	// decode color and rotation
    	vec4 tmp = gl_MultiTexCoord0;
    	gl_FrontColor = vec4(tmp.r, tmp.g, fract(tmp.b) * 10.0, fract(tmp.a) * 10.0);
     
    	sin_a = tmp.b / 1000000.0;
    	cos_a = tmp.a / 1000000.0;
     
    	gl_Position = gl_ProjectionMatrix * vtx;
     }
    As soon as I remove the comments around the
    codeblock that recalculates the coords, the linking fails.

    Card used: Geforce 8 GTS
    Version: 2.1.1 NVIDIA 100.14.19
    OS is Linux

  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2005
    Location
    South Tyrol, Italy
    Posts
    105

    Re: Shader linking fails when editing a copy of gl_PointCoord

    Just guessing: gl_PointCoord is olny available in GLSL 1.20. Maybe you should put a #version 120 at the top of your fragment shader source?

    [ www.trenki.net | vector_math (3d math library) | software renderer ]

  3. #3
    Intern Contributor
    Join Date
    May 2003
    Location
    Dortmund, Germany
    Posts
    60

    Re: Shader linking fails when editing a copy of gl_PointCoord

    I do that.
    What I have posted is the raw shader-source,
    my engine adds a set of preprocessor macros
    and defines at the top of each shaderfile, with
    "#version 120" beeing one of them.

  4. #4
    Intern Contributor
    Join Date
    May 2003
    Location
    Dortmund, Germany
    Posts
    60

    Re: Shader linking fails when editing a copy of gl_PointCoord

    Anybody?

  5. #5
    Junior Member Regular Contributor
    Join Date
    Feb 2006
    Location
    greece
    Posts
    183

    Re: Shader linking fails when editing a copy of gl_PointCoord

    Is it the linking or the compilation that fails?
    while(1){keyboardsolo(FORTE, BPM_190);}

  6. #6
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    883

    Re: Shader linking fails when editing a copy of gl_PointCoord

    I just tested in Shader Designer on WinXP-SP2 + 7600GT fw 163.69 and it works.

  7. #7
    Intern Contributor
    Join Date
    May 2003
    Location
    Dortmund, Germany
    Posts
    60

    Re: Shader linking fails when editing a copy of gl_PointCoord

    Is it the linking or the compilation that fails?
    Linking fails.

    Originally posted by yooyo:
    I just tested in Shader Designer on WinXP-SP2 + 7600GT fw 163.69 and it works.
    That is good news, I guess I have to wait for a Linux driverupdate then.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •