Shadows vs transparent objects

As you may have notice in the Forester thread, I reworked the way the post shadow pass is done.

There was an issue when transparent objects were receiving shadows (shadows were rendered on transparent areas).



If you have 5 minutes to spare, I’d like you to run the TestTransparentShadows and see if it works on your hardware.

It should look like that

http://i.imgur.com/5TUWB.jpg



Also, now there are 2 new techniques PostShadow15 and PostShadow (the 15 one is used only for hardwares that supports glsl1.5)

So if you have your own lighting, or w/e shader and you want it to support shadow, you can add those 2 techniques to your material definition.

Also you can implement your own post shadow shader.





EDIT : @ogerlord and @survivor this fixes that issue

http://hub.jmonkeyengine.org/groups/effects/forum/topic/shadow-and-transparency/?topic_page=1&num=15

8 Likes

[java]If you have 5 minutes to spare, I’d like you to run the TestTransparentShadows and see if it works on your hardware.

It should look like that[/java]

Ehm, maybe you could add a link or a hint where I can find the TestTransparentShadows?^^

I just updated jMP, created a new test (through new projects → jME tests), found TestTransparentShadows.java in the light folder, but it is still the old file for me. That still works great tho, and I like that weird fire put there on the rocks. :slight_smile:

This build isn’t though yet and it would be nightly at any instance.

1 Like

oh yeah sorry about that , i guess you’ll have to wait for nightly build.

it works for me nv295 gtx seems to work here

Actually do i have to implement both tehniques? (Since my minimal requirement is opengl3.0+ anyway, it would be just a waste for those few lines)

@EmpirePhoenix said:
Actually do i have to implement both tehniques? (Since my minimal requirement is opengl3.0+ anyway, it would be just a waste for those few lines)

Yeah in that case you just need the PostShadow15.
Some precision though, your texture that holds alpha information has to be named ColorMap or DiffuseMap and you need an AlphaDiscardThreshold float that determine the apha value below which the pixels will be discarded.

Hi



[java]

Information: Running on jMonkeyEngine 3.0.0 Beta

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglAbstractDisplay run

Information: Using LWJGL 2.8.3

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglDisplay createContext

Information: Selected display mode: 1280 x 720 x 0 @0Hz

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

Information: Adapter: nvd3dumx,nvwgf2umx,nvwgf2umx

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

Information: Driver Version: null

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

Information: Vendor: NVIDIA Corporation

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

Information: OpenGL Version: 4.2.0

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

Information: Renderer: GeForce GTX 460M/PCI/SSE2

Apr 08, 2012 7:57:59 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

Information: GLSL Ver: 4.20 NVIDIA via Cg compiler

[/java]



http://i.imgur.com/JsW1s.jpg



Works.



If i fly into the shadow area of the tree, the shadow on the sphere starts flickering and you see some bad grafic effects at the leaves which receive shadows.



Regards

Hey, cool stuff. I had this “bug” for a long time in my project. Unfortunately, not working here:





[java]Using LWJGL 2.8.3

Offscreen buffer created.

Adapter: null

Driver Version: null

Vendor: NVIDIA Corporation

OpenGL Version: 2.1 NVIDIA-7.18.11

Renderer: NVIDIA GeForce GT 330M OpenGL Engine

GLSL Ver: 1.20

Timer resolution: 1.000 ticks per second

Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, ARBprogram, GLSL100, GLSL110, GLSL120, VertexTextureFetch, TextureArray, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, NonPowerOfTwoTextures, MeshInstancing]

[/java]



The error being

[java]08.04.2012 09:05:04 com.jme3.app.Application handleError

SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Shadow/PostShadowPSSM.frag, defines, type=Fragment] error:ERROR: 0:51: Initializer not allowed

ERROR: 0:52: Use of undeclared identifier ‘pixSize’

ERROR: 0:55: Use of undeclared identifier ‘pixSize2’

ERROR: 0:56: Use of undeclared identifier ‘coord’

[/java]



I did not try your testcase but my own project where I use the PostWater effect. Did no changes except nightly update. Oh, also using OSX. Maybe the shader compiler is more strict here.

@Dodikles was it working before? i didn’t change how those variables are declared…

[xml]INFO: Running on jMonkeyEngine 3.0.0 Beta

08.04.2012 12:46:53 com.jme3.system.lwjgl.LwjglAbstractDisplay run

INFO: Using LWJGL 2.8.3

08.04.2012 12:46:53 com.jme3.system.lwjgl.LwjglDisplay createContext

INFO: Selected display mode: 1024 x 768 x 0 @0Hz

08.04.2012 12:46:54 com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Adapter: aticfx64

08.04.2012 12:46:54 com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Driver Version: 8.17.10.1094

08.04.2012 12:46:54 com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Vendor: ATI Technologies Inc.

08.04.2012 12:46:54 com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: OpenGL Version: 4.1.11079 Compatibility Profile Context

08.04.2012 12:46:54 com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Renderer: AMD Radeon HD 6800 Series

08.04.2012 12:46:54 com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: GLSL Ver: 4.10[/xml]



Works.



Edit: Hm, are there some options to fix this?:

http://img7.imagebanana.com/img/8lmhs5ud/problem.jpg

Yes, it did!

@ogerlord

There’s something called alpha threshold you can use. the pixel shader will discard pixels with alpha lower then the threshold you set.You could maybe try threshold of 0.5 and see, then adapt to the level you think look good.



EDIT: It’s is a light-material parameter.

1 Like

the exact parameter is AlphaDiscardThreshold



@Dodikles mhh ok, i’ll test with Normen’s mac.

This works for me on a HP 635 notebook. Radeon HD 6320 graphics.

Works here too.



The flickering issue does exist when you get close to the ball. Also, if you’re really close to the ball where some of the front-side tris will be culled because it’s too close, you’ll see the back side’s shadow being rendered. Not really an issue, but worth mentioning.



GTX 480 + Win 7 x64.



EDIT:

Forgot to add. @nehon next time you have a test, would you be so kind as to bold the name and give the directory it’s in please? It would make things easier and faster. :wink:

1 Like
@madjack said:
Forgot to add. nehon next time you have a test, would you be so kind as to bold the name and give the directory it's in please? It would make things easier and faster. ;)

Just run the test chooser..?
@normen said:
Just run the test chooser..?

That's against my religion. :P
1 Like

Cool :).