i use setSpecificLighting (true) for Object3D,invalid on mobile phone。

Started by specularlighting123, April 16, 2021, 12:36:19 PM

Previous topic - Next topic

specularlighting123

hi, :-[

i use setSpecificLighting (true) for Object3D,invalid on mobile phone。

but in the android studio virtual simulator,i can see the reflection of the highlights。

EgonOlsen

Some devices don't really support it even if they should. Which version of OpenGL is your app using? if it's OpenGL ES 1.x, try OpenGL ES 2.0 instead. See: https://www.jpct.net/wiki/index.php?title=OpenGL_ES_2.0_support

specularlighting123

after I set it up,the simulator also lost its effectiveness,it looks like there's no contrast,and saturation is very high。
(simulator:x86 , phone:arm)

EgonOlsen

You can forget about the simulator in OpenGL ES 2.0 mode. At least that was my experience, so I stopped using it altogether. There are some alternative Android emulators available, maybe one of them works better.

specularlighting123





x86 emulator,running is effective
other mobile phones,only shadows and higher saturation

EgonOlsen

I'm not sure what you mean. Which image is which? Is that in ES 2.0 or 1.x mode?

specularlighting123

The first one:Run on ARM chip mobile phone
The second one:Run on android studio X86 emulator
I just started learning OpenGL,Just use demo to run a model file,Confused about the differences between the two platforms。The second image looks like a mirror reflection。

AeroShark333

OpenGL implementations differ per device model.
For myself, I have found that emulators actually produce most consistently good results (maybe this was different in the past but it seems fine for me).
I believe the specular lighting doesn't seem to work properly for you on one of both (I'm not sure which screenshot is tied to which device).
You can reduce the sun intensity values to reduce the 'mirror'-like reflections. (Specular lighting).

PS: do you have another phone/tablet you can test on?

specularlighting123

I tested about five different brands of mobile phones, and the mirror light was very weak.
I reduced the light source provided by the world class. It has a weak effect. But the effect looks bad.
Is there any way to improve?

AeroShark333

I'm not entirely sure what you mean by that it looks 'bad'.
In one of your figures the specular lighting seems missing entirely..?

I believe the default specular lightning implementation uses Gouroud shading.
If you're unhappy with the results, I'd recommend writing your own shaders to implement Phong shading.

specularlighting123

Thank you for your reply,I'm a rookie,Can you show me a shader example ;D
Why is there a big gap between the first and the second?
The second one runs on the emulator。
The first one runs on the mobile phone。



AeroShark333

Shader example: https://www.jpct.net/wiki/index.php/Shaders
Scroll to last images/code for specular lighting implementation that might be interesting for you.
You can use this to load shader textfiles (both vertex shader and fragment shader) to String variables: https://www.jpct.net/jpct-ae/doc/com/threed/jpct/Loader.html#loadTextFile-java.io.InputStream-
You can use this to create your own GLSLShader: https://www.jpct.net/jpct-ae/doc/com/threed/jpct/GLSLShader.html#GLSLShader-java.lang.String-java.lang.String-
And finally you can use this to apply a GLSLShader to your Object3D: https://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#setShader-com.threed.jpct.GLSLShader-

About the gap in graphical output:
Quote from: AeroShark333 on April 18, 2021, 10:37:31 AM
OpenGL implementations differ per device model.
This means that one device might have a worse compiler (for the (default) shaders) than another device.
This will lead to artifacts in the graphical/rendered output.

EgonOlsen

It might also help to know what exactly this "mobile phone" is!? Model number, Android version?

specularlighting123

In version 2.0, how can I get the default shader to modify the parameters?