OS X graphics bug?

Discussion in 'Mac Programming' started by Nein01, Nov 5, 2013.

  1. Nein01 macrumors 6502

    Nein01

    Joined:
    Dec 1, 2009
    Location:
    Germany
    #1
    Hopefully this is the right place for me to post this topic..

    I can't get any custom 2d filter scripts to work in the blender game engine and it's driving me crazy. I need a toon outline filter for the game I'm working on. The uploader of this filter says it works fine on his windows machine.

    I don't know if there could be a problem with the code as I don't know python, but the script is as follows and I've been told there is nothing wrong with it:

    Code:
     uniform sampler2D bgl_RenderedTexture;
        uniform sampler2D bgl_DepthTexture;
    
        void main()
        {
           float depth = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy).r;
           float depth2 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0,0.002)).r;
           float depth3 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0.002,0)).r;
           
           float fac = abs(depth-depth2) + abs(depth-depth3);
           
           float intensity = 300;
    
           vec4 sub = vec4(fac*intensity,fac*intensity,fac*intensity,0);
           
           gl_FragColor = texture2D( bgl_RenderedTexture, gl_TexCoord[0].xy ) - sub;
        }
    I would like to ask someone with a little knowledge of blender (you'll have to set up a tiny bit of game logic) who maybe has access to a PC and a Mac to try this filter and tell me if it is working on OS X or not.

    I get no outline when I play the game engine.
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    This appears to be C, not Python.

    Further, the API looks like straight up OpenGL, with nothing unique to Blender.

    Having said that, I'm not familiar enough with OpenGL or Blender to actually help you.
     
  3. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #3
    It is GLSL not C.
     
  4. theyoda3, Nov 7, 2013
    Last edited: Nov 7, 2013

    theyoda3 macrumors member

    Joined:
    Sep 27, 2006
    #4
    I figured it out. GLSL on Mac OS tends to be strict. If you declare a float you must assign a float. There are two instances where the author declared float, but assigned an integer. The author is lazy.

    This is the correct code:

    Code:
    uniform sampler2D bgl_RenderedTexture;
    uniform sampler2D bgl_DepthTexture;
    
    void main()
    {
      float depth = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy).r;
      float depth2 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0.0, 0.002)).r;
      float depth3 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0.002, 0.0)).r;
    
      float fac = abs(depth-depth2) + abs(depth-depth3);
    
      float intensity = 300.0;
    
      vec4 sub = vec4(fac*intensity, fac*intensity, fac*intensity, 0.0);
    
      gl_FragColor = texture2D( bgl_RenderedTexture, gl_TexCoord[0].xy ) - sub;
    }
    
     
  5. Nein01 thread starter macrumors 6502

    Nein01

    Joined:
    Dec 1, 2009
    Location:
    Germany

Share This Page