LWJGL
June 18, 2013, 17:00:59 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.0 released!
 
   Home   Help Search Login Register  



Pages: 1 [2]
  Print  
Author Topic: GLSL Shaders  (Read 5293 times)
spasi
Nerdus Imperius
*****
Posts: 752



WWW
« Reply #15 on: October 11, 2011, 02:44:05 »

It sounds like premultiplied alpha will solve your problem. Read this post for details. Keep in mind you don't need to modify your textures, you can do the alpha pre-multiplication in the shader.
Logged
CodeBunny
Nerdus Imperius
*****
Posts: 561



WWW
« Reply #16 on: October 11, 2011, 04:14:56 »

...That might actually work. Let me test it.
Logged
CodeBunny
Nerdus Imperius
*****
Posts: 561



WWW
« Reply #17 on: October 11, 2011, 04:35:17 »

It does! Great. Cheesy

EDIT: Actually, the problem persists - Premultiplied alpha simple reduces the result significantly. Let me think about this some more.

EDIT#2: Actually, no, this is weird - my blending function won't take. Let me check my blending code.
Logged
CodeBunny
Nerdus Imperius
*****
Posts: 561



WWW
« Reply #18 on: October 11, 2011, 05:03:55 »

Nevermind, it works completely. I was making a dumb mistake.

Thank you very much, spasi!
Logged
Suds
Newbie
*
Posts: 11


« Reply #19 on: October 16, 2011, 23:25:33 »

While I agree the existing tutorials aren't adequate, it helps to start from a minimal working example.  I fixed the compile problem on the wiki, plus a logic issue that was causing it to fail.  I'm still not a fan of the way the code is organized, but it at least works now.

I have a single-file versions of that tutorial here, as well as a conversion that uses GL20 instead of ARB extensions.

https://bitbucket.org/chuck/lwjgl-sandbox/src/tip/src/main/java/tutorials/wiki



I was just working through this tutorial, and I was unable to get it to work. So I went over it, line by line. And I found that the printLogInfo method returns true if there was an error, and false if there was not.

Then peppered through the tutorial, there's "if(!printLogInfo(obj)) useShader = false".

In draw, "if(useShader) //use the shader". This translates to english roughly as:

"If there was not not an error, dont use shaders." or, "Only use shaders if there as an error." (I think. double/triple negatives get confusing after a while)

The code worked when I reversed the return values of printLogInfo().
Logged
Chuck
Newbie
*
Posts: 42


aka sproingie on freenode


« Reply #20 on: October 17, 2011, 10:11:18 »

Code:
       if (length > 1) {
            // We have some info we need to output.
            ByteBuffer infoLog = BufferUtils.createByteBuffer(length);
            iVal.flip();
            ARBShaderObjects.glGetInfoLogARB(obj, iVal, infoLog);
            byte[] infoBytes = new byte[length];
            infoLog.get(infoBytes);
            String out = new String(infoBytes);
            System.out.println("Info log:\n"+out);
        }
        else return true;
        return false;

It in fact does return false if there was an error and true if it succeeded.  The code style of this method in the wiki tutorial would result in heavy objects being thrown at me if it my peers went over it in a code review.  I really need to fix it, and I suppose update the wiki page too.  I didn't write the tutorial, so the fixes I actually want to apply probably wouldn't respect the author's intent.  Cleaning up the logic here would probably be okay tho.

This may be a more readable demo for shaders, but it does abstract a lot out: https://bitbucket.org/chuck/lwjgl-sandbox/src/tip/src/main/java/sandbox/misc/HelloShader.java

Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!