libgdx-contribs icon indicating copy to clipboard operation
libgdx-contribs copied to clipboard

bias.fragment issue

Open CorellianAle opened this issue 9 years ago • 14 comments

I've tried to use LensFlare2 effect in my libgdx application, but it crashed. I've read logs and it seams that there is an error in "bias.fragment" shader. Looks like it is impossible to multiply "vec4" an "int" values in "gl_FragColor = vec4(max(0.0, avg + u_bias)) * 50;"

I've found similar issue here http://stackoverflow.com/questions/14304290/null-checks-in-glsl Maybe it only happens on OS X. I am not familiar with shader programming so I am unable to fix this issue myself.

" Executing: gradle run Configuration on demand is an incubating feature. :core:compileJava UP-TO-DATE :core:processResources UP-TO-DATE :core:classes UP-TO-DATE :core:jar UP-TO-DATE :desktop:compileJava UP-TO-DATE :desktop:processResources UP-TO-DATE :desktop:classes UP-TO-DATE :desktop:run 2880x1800 ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 3)... ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 3)... ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 5)... ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 5)... ShaderLoader: Compiling "screenspace/threshold"... ShaderLoader: Compiling "screenspace/combine"... ShaderLoader: Compiling "screenspace/lensflare2"... ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 3)... ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 3)... ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 5)... ShaderLoader: Compiling "screenspace/convolve-1d" w/ (#define LENGTH 5)... ShaderLoader: Compiling "screenspace/bias"... ShaderLoader: ERROR: 0:26: '*' does not operate on 'vec4' and 'int' "

CorellianAle avatar Feb 19 '15 14:02 CorellianAle

Mmm.. do you have an ATI card? I had similar problems in the past with an ATI-based GPU for some tricky casts..

manuelbua avatar Feb 19 '15 14:02 manuelbua

No, I have a GT750M and Iris Pro Graphics. One moment, I'll try to run this on integrated GPU.

CorellianAle avatar Feb 19 '15 14:02 CorellianAle

Ah! Please try change the line to read:

gl_FragColor = vec4(max(0.0, avg + u_bias)) * 50.0;

This one i missed when i reviewed the code..

manuelbua avatar Feb 19 '15 14:02 manuelbua

Yes, I was just writing the same, this should do the trick.

langurmonkey avatar Feb 19 '15 14:02 langurmonkey

Yea, it worked. Thanks.

CorellianAle avatar Feb 19 '15 14:02 CorellianAle

NP, thanks for reporting! Please leave open this issue so that i remember about it :)

manuelbua avatar Feb 19 '15 14:02 manuelbua

I am sorry, but could you explain how to use this LensFlare2 effect. I've created lensFlare2 object, set lenscolor texture and passed it to postProcessor. When I execute app, nothing really happens. Scene stays the same. Bloom and other effects work just fine.

CorellianAle avatar Feb 19 '15 15:02 CorellianAle

You probably need to play around a bit with the parameters in the LensFlare2 class. You may have noted that there is a ton of them.

You can start with these values and adjust them to your needs: Ghosts: 8 (number of lens artifacts) Halo width: 0.55 Flare intensity: 0.4 Flare saturation: 0.7 Base intensity: 1 Bias: -0.98 Blur amount: 0 Blur passes: 2

The bias is the one that determines which parts of your frame buffer will be used to produce the lens effect. As you get close to -1 only the brighter parts are selected.

The effect with this parameters is shown here: https://www.youtube.com/watch?v=ikXaHILvNEs

langurmonkey avatar Feb 19 '15 15:02 langurmonkey

Mmm something should be visible, have you tried to tweak some values such as the bias or the combine pass intensities? I had to tweak some to really see the effect in action..

manuelbua avatar Feb 19 '15 15:02 manuelbua

Looks like i am close =D Thanks! screen shot 2015-02-19 at 17 55 56

CorellianAle avatar Feb 19 '15 15:02 CorellianAle

@langurmonkey Please take a look at this line: https://github.com/manuelbua/libgdx-contribs/blob/master/postprocessing/src/main/resources/shaders/lensflare2.fragment#L65 Are you sure the v_texCoords has to be used instead of the transformed one texcoord?

manuelbua avatar Feb 19 '15 15:02 manuelbua

By the way, do you plan to implement gaussian blur or motion blur? Those effects are quite important today.

https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson5

Both your bloom and blur from this article work really well together.

CorellianAle avatar Feb 19 '15 16:02 CorellianAle

@manuelbua Nope, you are totally right, texcoord should be used indeed. My bad :sweat:

langurmonkey avatar Feb 19 '15 16:02 langurmonkey

@langurmonkey no problem, nice work indeed, i'll fix it soon, hopefully :) @AlexejNowikoff is the lib's gaussian blur not working for you? There is a full set of convolve filters used for that and other: i started implementing a camera motion blur but don't have much time to finish it yet..

manuelbua avatar Feb 19 '15 16:02 manuelbua