Results 1 to 4 of 4

Thread: GLSL fragment shader problem

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Location
    UK
    Posts
    16

    Default GLSL fragment shader problem

    Hi
    I am using a fragment shader (below) to create a greyscale earth, but it's causing a problem with some tiles (see screenshot).

    Looks like the its sometimes using the texture coordinates from the neighbouring tile for some reason. Anyone had this problem or know how to solve it?

    Note the tiles are rendered correctly if I disable the shader.

    Thanks

    Code:
    uniform sampler2D testTexture;
    
    void main( void )
    {
    	vec4 texelColor = texture2D( testTexture, gl_TexCoord[0].xy );
    	vec4 greyWeights = vec4(0.3, 0.59, 0.11, 1.0);
    	vec4 scaledColor = texelColor * greyWeights;
    	float luminance = scaledColor.r + scaledColor.g + scaledColor.b;
    	gl_FragColor = vec4( luminance, luminance, luminance, texelColor.a );
    }
    Attached Images Attached Images
    Last edited by jwheeler; 08-16-2010 at 03:37 PM. Reason: Clarification

  2. #2
    weekend warrior
    Join Date
    May 2008
    Posts
    95

    Default

    I'm not saying that this is your problem, but I have seen similar behavior on 'vanilla world' wind setups where the terrain data has become corrupted or when graphics driver updates are needed. You might trying deleting all of your elevation data and/or updating graphics drivers. It might just help

  3. #3
    Senior Member
    Join Date
    Jun 2007
    Posts
    217

    Default

    "Normal" World Wind rendering uses an alpha mask texture (through multi-texture rendering) so that it only renders the portion of the surface tile which is covered by the texture. That's how it combines several different textures of various sizes together to cover a tile.

    Once you use a shader, you no longer necessarily benefit from the alpha masking which all takes place in the fixed-function pipeline. So in your fragment shader, you need to discard any pixes for texture coords less than 0 or greater than 1.

    Something like:

    if (gl_TexCoord[0].s < 0 || gl_TexCoord[0].s > 1) discard;
    if (gl_TexCoord[0].t < 0 || gl_TexCoord[0].t > 1) discard;

  4. #4
    Junior Member
    Join Date
    Jan 2008
    Location
    Huntsville, AL
    Posts
    24

    Default

    I just came across this posting and it fixed an issue have been having since upgrading WWJ this week.. I had been using the version of world wind java from about May 2010, and it worked fine with my shader. I upgraded this week to the newest world wind java and started getting the same incorrectly rendered tile. Adding those 2 lines to my shader fixed the issue. Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Custom terrain tile visibility/altitude problem
    By Peter Skvarenina in forum Development Help
    Replies: 7
    Last Post: 06-24-2014, 03:55 PM
  2. Normal mapping (GLSL shader)
    By Omega in forum Feature Discussion
    Replies: 12
    Last Post: 09-11-2011, 11:53 PM
  3. Updating GLSL support with new JOGL
    By what_nick in forum Development Help
    Replies: 7
    Last Post: 09-28-2010, 11:35 AM
  4. GLSL Shader support that renders tiles correctly
    By tve in forum Development Help
    Replies: 7
    Last Post: 09-09-2009, 09:53 AM
  5. Problem with terrain and its modification
    By bako in forum Development Help
    Replies: 1
    Last Post: 02-23-2009, 06:35 PM

Posting Permissions

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