default shader lighting problem

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

Previous topic - Next topic

EgonOlsen


EgonOlsen

I gave the blitting issue a shot...I couldn't fix it with increased accuracy. It didn't change one little bit, which makes me think that it's actually caused by inaccuracies in the GPU's view frustum and not so much in the generated coordinates. But I can't reset the fov in all cases, I should rather rework the blitting code as a whole. Anyway, that's not going to happen too soon, so...if you have a workaround, I suggest that you simply use it for now. These very low fov values are a very unusual use case anyway.
I'll look into the specular thing once my toothache is gone...can't really concentrate on it ATM... ;)

MichaelJPCT

i think using an empty world to reset fov is good enough. just that more operations are done than simply changing the frustum. if cpu speed is high enough, it's ok.

EgonOlsen

There's no real overhead in that workaround, so it's just fine.

EgonOlsen

About the specular lighting: I made myself a test case and it looks in OpenGL ES 2.0 mode exactly the same way as it looks in 1.x mode (which can't be wrong, because specular is done by the fixed function pipeline in that one). So...I'm not sure what the actual issue is... ???

MichaelJPCT

do you mean you see specular effect with the new jar?
i tested my app on another device with powervr 544 and IPS(better color) screen, i still don't see the effect similar to desktop version.
settings are the same as desktop.

EgonOlsen

At least I'm seeing the same outcome in OpenGL ES 1.x as I do in 2.0 and it does look different from not having specular enabled, so I would say "yes, I'm seeing a specular highlight". I'm not sure if it's equal to what the desktop version provides, because I haven't checked that. I'll do later and report back.

MichaelJPCT

the way i judge specular effect is that when viewed from different angles, a polygon has different light intensity. that is what "diffuse" lighting can't have.

EgonOlsen

Yes, that should actually happen. You can look into the default shader's code. They do take the angle into account just like the fixed function pipeline should...!?

MichaelJPCT

today i tested gl es 1.1 with my app on a mali400 device and i see the specular effect. with es 2.0 still no effect.
my app has something special in graphics - camera is always positioned at (0,0,0), objects move instead of the camera.
can this affect the specular effect?

EgonOlsen

No, I don't think so. It should work. Can you provide me with a test case that shows the difference between the two modes?

MichaelJPCT

i made a test case.
if gl2=false, you can see the color of a box changes a bit, while with gl2=true, color doesn't change.

package abc.def;
import com.threed.jpct.*;
import javax.microedition.khronos.egl.EGL10;
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;
import java.lang.reflect.Field;

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 Object3D box=Primitives.getBox(5,1),gnd=Primitives.getPlane(1,500);
   static float yaw;
   static SimpleVector vec=new SimpleVector();
   static Light sun;
   static Texture tex=new Texture(1,1,new RGBColor(200,200,200));
   static boolean gl2=false;

   void init() { sun=new Light(world); sun.setAttenuation(-1f);
      sun.setDiscardDistance(-1f); vec.set(0,2000,10000);
      sun.setPosition(vec); TextureManager.getInstance().addTexture("tex",tex);
      box.setTexture("tex"); box.build();
      world.addObject(box); box.setSpecularLighting(true);
      gnd.build(); world.addObject(gnd);
      vec.set(0,50,0); gnd.setOrigin(vec); gnd.rotateX((float)Math.PI/2);
   }

   protected void onCreate(Bundle a) {
      super.onCreate(a); renderer=new MyRenderer();
      GLview=new GLSurfaceView(getApplication());
      if (gl2) GLview.setEGLContextClientVersion(2); else
      GLview.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
         public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display) {
            int[] attributes=new int[]{EGL10.EGL_DEPTH_SIZE,16,EGL10.EGL_NONE};
            EGLConfig[] configs=new EGLConfig[1]; int[] result=new int[1];
            egl.eglChooseConfig(display,attributes,configs,1,result);
            return configs[0]; } } );
      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 (gl2) fb=new FrameBuffer(w,h);
         else fb=new FrameBuffer(g,w,h);
         init(); }

      public void onDrawFrame(GL10 g) {
         float a=0.01f; yaw-=a; cam.rotateY(a);
         vec.set(50*(float)Math.sin(yaw),10f,50*(float)Math.cos(yaw));
         box.setOrigin(vec);
         fb.clear(); world.renderScene(fb);
         world.draw(fb); fb.display(); } }
}

EgonOlsen


EgonOlsen

#28
FYI: I'm working on it. I've to refactor the default shaders to make this work.