ClassCastException in PBR when using setColor

Hi!
When using a PBR material (“Common/MatDefs/Light/PBRLighting.j3md”) without textures, but just using:

_jmeMaterial.setColor("BaseColor", ColorRGBA.Red);

I get:

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ClassCastException: com.jme3.math.Vector4f cannot be cast to com.jme3.math.ColorRGBA
    at com.jme3.shader.Uniform.setValue(Uniform.java:323)

Is it possible that its related to:

? Or maybe I am doing something wrong?

full trace:

INFO: Running on jMonkeyEngine 3.1-PBRisComing-5741
 * Branch: PBRisComing
 * Git Hash: 67fb8fc
 * Build Date: 2016-07-09
Aug 13, 2016 8:37:08 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: aticfx64
 * Driver Version: 8.17.10.1404
 * Scaling Factor: 1
Aug 13, 2016 8:37:08 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: ATI Technologies Inc.
 * Renderer: AMD Radeon HD 6800 Series
 * OpenGL Version: 4.5.13399 Compatibility Profile Context 15.201.1151.1008
 * GLSL Version: 4.40
 * Profile: Compatibility
Aug 13, 2016 8:37:08 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
Aug 13, 2016 8:37:08 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.audio.plugins.OGGLoader
Aug 13, 2016 8:37:08 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Aug 13, 2016 8:37:08 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Aug 13, 2016 8:37:08 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Aug 13, 2016 8:37:08 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
Aug 13, 2016 8:37:11 PM com.jme3.material.Material checkSetParam
WARNING: Material parameter being set: Texture with type Texture2D doesn't match definition types TextureCubeMap
Aug 13, 2016 8:37:11 PM com.jme3.material.Material setTextureParam
WARNING: The texture Textures/Sky/Path.hdr has linear color space, but the material parameter Texture specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Aug 13, 2016 8:37:14 PM at.illumine.morph.ui.serialization.MorphDesignerConfigurationLoader load
INFO: Loading designer configuration: Test designer


SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ClassCastException: com.jme3.math.Vector4f cannot be cast to com.jme3.math.ColorRGBA
    at com.jme3.shader.Uniform.setValue(Uniform.java:323)
    at com.jme3.material.Material.updateShaderMaterialParameters(Material.java:804)
    at com.jme3.material.Material.render(Material.java:964)
    at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:616)
    at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:266)
    at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:305)
    at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:879)
    at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:781)
    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1106)
    at com.jme3.renderer.RenderManager.render(RenderManager.java:1146)
    at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
    at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:193)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
    at java.lang.Thread.run(Thread.java:745)

mhhh, weird…
gonna check that

Thank you!

What version do you use? there in no way line 323 of Uniform.java cast this error on master.

The latest version of PBRisComing-SNAPSHOT on jcenter.

is there a chance you try with master? pull the engine ans run a gradle install?

Hmm - I did this and now its working!

This is how i got the PBR Version from jcenter (before switching to the local version on mavenLocal):

def jme3 = ["v" : "PBRisComing-SNAPSHOT", "g": "com.github.jMonkeyEngine.jmonkeyengine"] 
dependencies {
    compile "${jme3.g}:jme3-core:${jme3.v}"
    compile "${jme3.g}:jme3-plugins:${jme3.v}"
    compile "${jme3.g}:jme3-effects:${jme3.v}"
...

Maybe you can upload a new snapshot, but for me its working now and I think I will (at least currently) stay on using the local version.

Like always, thx a lot! :wink:

Well this branch is now deprecated and has been merged to master.
Future fixes and enhancements on PBR will be done on master.

Means, if I switch to master i will also have “Common/MatDefs/Light/PBRLighting.j3md” available?

yep
and latest fixes

Great news! But I did that and now I got:

INFO: Running on jMonkeyEngine 3.2-5933
 * Branch: master
 * Git Hash: beb5033
 * Build Date: 2016-08-14
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException
    at com.jme3.material.logic.SinglePassAndImageBasedLightingLogic.extractIndirectLights(SinglePassAndImageBasedLightingLogic.java:246)
    at com.jme3.material.logic.SinglePassAndImageBasedLightingLogic.makeCurrent(SinglePassAndImageBasedLightingLogic.java:83)
    at com.jme3.material.Technique.makeCurrent(Technique.java:152)
    at com.jme3.material.Material.preload(Material.java:847)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:665)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:656)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:656)
    at com.jme3.animation.SkeletonControl.testHardwareSupported(SkeletonControl.java:164)
    at com.jme3.animation.SkeletonControl.controlRender(SkeletonControl.java:282)
    at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:135)
    at com.jme3.scene.Spatial.runControlRender(Spatial.java:756)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:723)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:733)
    at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:712)
    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1095)
    at com.jme3.renderer.RenderManager.render(RenderManager.java:1146)
    at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
    at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
    at java.lang.Thread.run(Thread.java:745)

But this might be totally unrelated. I will investigate into this a little bit later…

Ha. I may have break things earlier. Will look into this.

Yeah with Master you get latest fixes… But also latest bugs… :smiley:

mhh ok. I guess you preload your scene, right?
makeCurrent is called with a null light list when you preload…

I pushed a fix could you test please?

Yes, its working with the fix you provided. Thx! The only thing thats currently a little bit irritating is that since moving from the PBR branch to master the frame drops 13fps while displaying my offscreen renderer (I render to texture, convert it to an image to display it in a jfx imageviewer). Before the update it was constant at ~60 fps (with enable vsync) and now its around 47 (but only when displaying the offscreen stuff).

But most probably that has something to do with my offscreen implementation…

Hmm - without vsync I have a drop from ~800fps to 57 - so definitely something in my offscreen stuff!

Hmm - its _renderManager.getRenderer().readFrameBufferWithFormat(_frameBuffer, _byteBuffer, Image.Format.BGRA8);

called in postRender thats causes the fps drop. Already tried:
_renderManager.getRenderer().readFrameBuffer(_frameBuffer, _byteBuffer);

but no significant performance increase. Can I read the framebuffer from another thread or will this cause some concurrentmodificationexception?

Any idea how I could optimize this (I know its hard without any code, but any hint will be appreciated)?

mhhh you mean the one in the PBR branch was faster?..
Weird.
Will check that :wink:

Yes - I cannot tell exactly, because vsync was always on, but back then i never had any performance issue and now its massive.

mhhh the implementation is the same between the 2 branches…
Do you use lwjgl 3, by any chance?
I mean with master?