Author Topic: i use setSpecificLighting (true) for Object3D,invalid on mobile phone。  (Read 832 times)

Offline specularlighting123

  • byte
  • *
  • Posts: 12
    • View Profile
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。

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12202
    • View Profile
    • http://www.jpct.net
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

Offline specularlighting123

  • byte
  • *
  • Posts: 12
    • View Profile
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)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12202
    • View Profile
    • http://www.jpct.net
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.

Offline specularlighting123

  • byte
  • *
  • Posts: 12
    • View Profile




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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12202
    • View Profile
    • http://www.jpct.net
I'm not sure what you mean. Which image is which? Is that in ES 2.0 or 1.x mode?

Offline specularlighting123

  • byte
  • *
  • Posts: 12
    • View Profile
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。

Offline AeroShark333

  • float
  • ****
  • Posts: 266
    • View Profile
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?

Offline specularlighting123

  • byte
  • *
  • Posts: 12
    • View Profile
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?

Offline AeroShark333

  • float
  • ****
  • Posts: 266
    • View Profile
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.

Offline specularlighting123

  • byte
  • *
  • Posts: 12
    • View Profile
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。



Offline AeroShark333

  • float
  • ****
  • Posts: 266
    • View Profile
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:
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12202
    • View Profile
    • http://www.jpct.net
It might also help to know what exactly this "mobile phone" is!? Model number, Android version?

Offline specularlighting123

  • byte
  • *
  • Posts: 12
    • View Profile
In version 2.0, how can I get the default shader to modify the parameters?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12202
    • View Profile
    • http://www.jpct.net
Which parameters?