default shader lighting problem

Started by MichaelJPCT, August 29, 2016, 04:13:03 AM

Previous topic - Next topic

MichaelJPCT

i have a JPCT app ported to JPCT-AE. i see a grey object with default shader has color problem. its faces are either grey or total black according to light direction, look like very much overbrighted.
my device has PowerVR540 GPU and Android 4.2.2.
what could be the cause?

EgonOlsen

Do you have screenshots of both version that you can show?

MichaelJPCT

i found it was setSpecularLighting(true) that cause the problem.
but even if specpow=0 specterm=0 , the problem is still there.
here is a screenshot without specular.

EgonOlsen

Yes, looks like a bug in the GL20 support. I'm not actually setting the shininess in the shader, like it's supposed to be. I'll fix that and upload a fixed version later today.

MichaelJPCT

great! thanks!
will you fix it based on the version with correct camera nearclip/farclip/fov settings?

EgonOlsen

Yes, sure. I only have that one. I don't really work with branches for jPCT(-AE).

MichaelJPCT

also , i found a problem with blitting.
if before blitting, the fov is very small (say 0.05 rad), the blit result is inaccurate - text distorted/biased.
can you reset the fov to a normal figure before blitting?
i use an empty world to reset the fov as a temperary solution for now.

EgonOlsen

Not sure...I would rather try to increase precision of the calculations. Maybe that helps. I'll look into it.

EgonOlsen

This version should fix the specular issue: http://jpct.de/download/beta/jpct_ae.jar...at least it fixes the shader uniform not being initialized correctly. That should actually make it work, but I haven't fully tested it.
About the blitting: I can't verify that. Blitting works fine for me even with extremely low fov values. Can you create a simple test case that shows the problem?

MichaelJPCT

this is test code, you'll see a white square on top left corner and it moves a little.
if your screen has high resolution, maybe it's less noticeable, test screen is 1024x600.

package abc.def;
import com.threed.jpct.*;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.app.Activity;

public class Sim extends Activity {
   static GLSurfaceView GLview;
   static MyRenderer renderer;
   static FrameBuffer fb;
   static World world=new World();
   static Camera cam=world.getCamera();
   static Texture tex;
   static float fov=0.1f;

   protected void onCreate(Bundle a) {
      super.onCreate(a);
      renderer=new MyRenderer();
      GLview=new GLSurfaceView(getApplication());
      GLview.setEGLContextClientVersion(2);
      GLview.setRenderer(renderer);
      setContentView(GLview); }
   @Override
   protected void onPause() { super.onPause(); GLview.onPause(); }
   @Override
   protected void onResume() { super.onResume(); GLview.onResume(); }
   @Override
   protected void onStop() { super.onStop(); }

   class MyRenderer implements GLSurfaceView.Renderer {
      public void onSurfaceCreated(GL10 g,EGLConfig c) {}
      public void onSurfaceChanged(GL10 g,int w,int h) {
         if (fb!=null) fb.dispose();
         fb=new FrameBuffer(w,h);
         cam.setFOVLimits(0.0001f,10f);
         cam.setClippingPlanes(0.1f,100f);
         tex=new Texture(1,1,new RGBColor(200,200,200));
         TextureManager.getInstance().addTexture("tex",tex);
      }
      public void onDrawFrame(GL10 g) {
         fb.clear(); cam.setFOV(fov);
         fov-=0.001f; if (fov<0.01) fov=0.1f;
         world.renderScene(fb); world.draw(fb);
         fb.blit(tex,0,0,10,10,0,0,80,80,-1,false);
         fb.display(); }
   }
}

MichaelJPCT

i tested the newer version of jar, but i didn't see any specular effect.
my settings specterm=20 specpow=90.

EgonOlsen

Do you see something in the desktop application? And if you do, does this still apply if you set Config.lightMul=1 (in the desktop app)?

MichaelJPCT

my desktop app has noticeable specular effect.
my desktop app uses hardware GL, so max lightmul is 1 , right?
i didn't set lightmul in it.

EgonOlsen

Quote from: MichaelJPCT on August 30, 2016, 12:27:10 PM
my desktop app uses hardware GL, so max lightmul is 1 , right?
No, default is 10. It's only 1 for compiled objects, i.e. objects on which you've called compile(...);

MichaelJPCT

ok, my objects are all compiled, so that i didn't change lightmul in desktop app.