manuelbua/libgdx-contribs

CrtMonitor issue

CatInBank opened this issue · 9 comments

I got this error when trying to use CrtMonitor

Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: no uniform with name 'time' in shader
    at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:292)
    at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:282)
    at com.badlogic.gdx.graphics.glutils.ShaderProgram.setUniformf(ShaderProgram.java:384)
    at com.bitfire.postprocessing.filters.Filter.setParam(Filter.java:91)
    at com.bitfire.postprocessing.filters.CrtScreen.setTime(CrtScreen.java:132)
    at com.bitfire.postprocessing.filters.CrtScreen.<init>(CrtScreen.java:109)
    at com.bitfire.postprocessing.effects.CrtMonitor.<init>(CrtMonitor.java:61)

Could you check if your shaders/crt-screen.fragment file defines the uniform float time uniform as it should?

Yes, I see it in the file. I changed my code and this error has gone. But now I have black screen.

In the console I see message about compiling shader. Is there should be message that shader compiled?

Yes, it should: it looks like you have some cached .class files in your workspace, it happens to me too from time to time whenever Eclipse miss to update/rebuild them: try cleaning the project completely via Project -> Clean.
Did you try the accompanying demo? It should just work once it has been setup and the CRT shader should play fine there.

Demo works fine. I cleaned the projects, but it didn't help. I'm trying to do just like in demo.

This could be related to blending being disabled, but i'm not sure: you should try to mimic the demo and add on it until the screen goes black, so to find out what's causing the issue.

I found the problem. It's because of using other shaders when postProcessor capturing(lighting). Can I solve this problem and use lighting with CRT?

So, somehow I solved a problem. Huge thanks to you for help! I needed to remove operations with FrameBuffer from capturing.

I know of some projects using 3d lighting with the postprocessor just fine, but i haven't tried it myself: anyway, the post-processing library is quite flexible and it permits to hook at rendering level (PostProcessorListener::beforeRenderToScreen) and manipulate blending at will.
You'll probably need to find your way through it though, since i used it in conjunction with the box2dlights project but mostly 2d stuff.

Happy to hear that, and good luck with your project!