Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mxar

Pages: 1 2 [3] 4 5 6
31
Support / Re: Off screen rendering
« on: April 13, 2015, 12:30:44 am »
Hi,
sorry for the delay to answer.

I use the C++ method

 void glReadPixels(   GLint x,
    GLint y,
    GLsizei width,
    GLsizei height,
    GLenum format,
    GLenum type,
    GLvoid * data);

for better performance.

Best Regards


32
Support / Re: Off screen rendering
« on: March 31, 2015, 03:10:19 pm »

Many thanks. :)
It works.

33
Support / Re: Off screen rendering
« on: March 31, 2015, 09:12:29 am »

Thanks for the reply.

Is there an example which configs ES 2.0 mode?

Where can I find one?

Can you help me?

Thanks in advance

34
Support / Re: Off screen rendering
« on: March 30, 2015, 11:12:06 pm »
Hi,
finally i found out that when i create the frameBuffer then the trace shows that shaders couldn't load and compiled.

The trace is the following:

I/jPCT-AE(10012): Loading file from InputStream
 I/jPCT-AE(10012): Text file from InputStream loaded...2416 bytes
 I/jPCT-AE(10012): Default vertex shader is: /defaultVertexShader.src
 I/jPCT-AE(10012): Loading file from InputStream
 I/jPCT-AE(10012): Text file from InputStream loaded...4496 bytes
 I/jPCT-AE(10012): Compiling shader program!
 E/libEGL(10012): called unimplemented OpenGL ES API
 E/libEGL(10012): called unimplemented OpenGL ES API
 E/libEGL(10012): called unimplemented OpenGL ES API
E/libEGL(10012): called unimplemented OpenGL ES API
 E/libEGL(10012): called unimplemented OpenGL ES API
 I/jPCT-AE(10012): Could not compile shader 35633:
 E/libEGL(10012): called unimplemented OpenGL ES API
 E/jPCT-AE(10012): [ 1427752506957 ] - ERROR: Failed to load and compile vertex shaders!
 W/jPCT-AE(10012): [ 1427752506957 ] - WARNING: Unable to load shader!
 E/jPCT-AE(10012): [ 1427752506958 ] - ERROR: java.lang.RuntimeException: [ 1427752506957 ] - ERROR: Failed to load and compile vertex shaders!
 E/jPCT-AE(10012):    at com.threed.jpct.Logger.log(Logger.java:206)
 E/jPCT-AE(10012):    at com.threed.jpct.GLSLShader.loadProgram(GLSLShader.java:1070)
 E/jPCT-AE(10012):    at com.threed.jpct.GLSLShader.<init>(GLSLShader.java:265)
 E/jPCT-AE(10012):    at com.threed.jpct.GL20.<init>(GL20.java:124)
 E/jPCT-AE(10012):    at java.lang.Class.newInstanceImpl(Native Method)
 E/jPCT-AE(10012):    at java.lang.Class.newInstance(Class.java:1208)
 E/jPCT-AE(10012):    at com.threed.jpct.GLRenderer.init(GLRenderer.java:403)
 E/jPCT-AE(10012):    at com.threed.jpct.GLRenderer.init(GLRenderer.java:384)
 E/jPCT-AE(10012):    at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:94)
 E/jPCT-AE(10012):    at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:119)


i call the opengl version 2: fb = new FrameBuffer(width, height);


Before creating the FrameBuffer i try to create EGLContext compatible with Opengl 2.

I believe that i dont config correctly the EGLContext,perhaps the EGLContext i created is not compatible with openGL 2.

I use the following code to config the EGLContext:


int[] version = new int[2];
        int[] attribList = new int[] {
            EGL_WIDTH, width,
            EGL_HEIGHT, height,
            EGL_NONE
        };
       
       
        mEGL = (EGL10) EGLContext.getEGL();
       
       
        mEGLDisplay = mEGL.eglGetDisplay(EGL_DEFAULT_DISPLAY);
        mEGL.eglInitialize(mEGLDisplay, version);
     
        mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated

        int EGL_CONTEXT_CLIENT_VERSION = 0x3098;

        int[] list = {EGL_CONTEXT_CLIENT_VERSION, (int) 2,EGL10.EGL_NONE };
               
        mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, list); //null);
               
        mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig,  attribList);
        mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
        mGL = (GL10) mEGLContext.getGL();



  private EGLConfig chooseConfig() {
        int[] attribList = new int[] { 
              EGL_DEPTH_SIZE, 16,
            EGL_STENCIL_SIZE, 8,
            EGL_RED_SIZE, 8,
            EGL_GREEN_SIZE, 8,
            EGL_BLUE_SIZE, 8,
            EGL_ALPHA_SIZE, 8,
            EGL_NONE
        };
   

        // No error checking performed, minimum required code to elucidate logic
        // Expand on this logic to be more selective in choosing a configuration
        int[] numConfig = new int[1];
        mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig);
        int configSize = numConfig[0];
        mEGLConfigs = new EGLConfig[configSize];
        mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig);

        if (LIST_CONFIGS) {
            listConfig();
        }

        return mEGLConfigs[0];  // Best match is probably the first configuration
    }
   
    private void listConfig() {
        Log.i(TAG, "Config List {");

        for (EGLConfig config : mEGLConfigs) {
            int d, s, r, g, b, a;
                   
            // Expand on this logic to dump other attributes       
            d = getConfigAttrib(config, EGL_DEPTH_SIZE);
            s = getConfigAttrib(config, EGL_STENCIL_SIZE);
            r = getConfigAttrib(config, EGL_RED_SIZE);
            g = getConfigAttrib(config, EGL_GREEN_SIZE);
            b = getConfigAttrib(config, EGL_BLUE_SIZE);
            a = getConfigAttrib(config, EGL_ALPHA_SIZE);               
            Log.i(TAG, "    <d,s,r,g,b,a> = <" + d + "," + s + "," +
                r + "," + g + "," + b + "," + a + ">");
        }

        Log.i(TAG, "}");
    }
       
    private int getConfigAttrib(EGLConfig config, int attribute) {
        int[] value = new int[1];
        return mEGL.eglGetConfigAttrib(mEGLDisplay, config,
                        attribute, value)? value[0] : 0;
    }
       
Right after this code i create the frameBuffer but then the default shaders cannot loaded and compiled.


Thanks for your time.


35
Support / Re: Off screen rendering
« on: March 30, 2015, 11:30:49 am »

Hi,

at last i found a way to read screen pixels with better speed.
Using PixelBuffer the speed was around 42 ms instead of >120 ms.
With PixelBuffer the rendering is done in background.
This worked well if the Jpct-AE was  configured for Opengl 1.x.

But when i configured Jpct-AE to opengl 2.0 the problem was that the shaders couldn't load and compiled.
I think that the problem is that the EGL needs a proper configuration.

A set of EGL method is used to configure EGL:

int[] version = new int[2];
        int[] attribList = new int[] {
            EGL_WIDTH, mWidth,
            EGL_HEIGHT, mHeight,
            EGL_VERSION, 2,
            EGL_NONE
        };

private EGLConfig chooseConfig() {
        int[] attribList = new int[] {   
           EGL_RENDERABLE_TYPE,4, //important   
            EGL_DEPTH_SIZE, 16,
            EGL_STENCIL_SIZE, 0,
            EGL_RED_SIZE, 8,
            EGL_GREEN_SIZE, 8,
            EGL_BLUE_SIZE, 8,
            EGL_ALPHA_SIZE, 8,
            EGL_NONE
        };

   mEGL = (EGL10) EGLContext.getEGL();
        mEGLDisplay = mEGL.eglGetDisplay(EGL_DEFAULT_DISPLAY);
        mEGL.eglInitialize(mEGLDisplay, version);
        mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated
        mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, null);
        mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig,  attribList);
        mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
        mGL = (GL10) mEGLContext.getGL();


Do you have any idea about it?

Thanks for your time.



36
Support / Re: Off screen rendering
« on: March 27, 2015, 12:17:26 pm »
Hi,

is it possible to do the rendering but not to show the rendering results on screen?
e.g. the screen is reserved by other activity View?

Something like background rendering.

thanks

37
Support / Re: Off screen rendering
« on: March 24, 2015, 02:54:38 pm »
Thanks,

the bitmap is needed to read the screen image as  feedback.We want to add the option to read back the screen and apply some OpenCV methods to recognize some real objects (e.g texts,the face of a person,...).

Thanks for yout time :)

38
Support / Re: Off screen rendering
« on: March 24, 2015, 01:09:11 pm »
Hi,

is it possible to do the rendering on a bitmap instead of Texture in MixingExample example?

I need to create a bitmap or ByteBuffer which has the pixels of the screen shown in the MixingExample.

How can i convert the Overlay's texture  to bitmap or a ByteBuffer?

FrameBuffer.getPixels slows down the application.

ITextureEffect can help me?

Thanks in advance

39
Support / Re: Off screen rendering
« on: March 17, 2015, 12:52:46 pm »
ok

thanks

40
Support / Re: Off screen rendering
« on: March 17, 2015, 11:21:53 am »
Hi,

can Config.maxTextureLayers be greater than 4 ?

thanks in advance

41
Support / Re: Off screen rendering
« on: March 10, 2015, 10:49:38 am »
Many Thanks!!!!  :)

The hacky example is realy very helpful.

Is a good example for my needs.

Thank you very much.


42
Support / Re: Off screen rendering
« on: March 09, 2015, 10:42:58 am »

Thank you for the answer,

At the beginning i create an Overlay object sceneImageOverlay having a NPOTTexture npotTexture as texture.
The overlay has the screen sizes, screenWidth,screenHeight.

The overlay is created in the onSurfaceChanged method


   npotTexture = new NPOTTexture(screenWidth,screenHeight,new RGBColor(255, 255, 0) );//null);//null for rendering
        textureManager.addTexture("npotTexture ", npotTexture );
   
         sceneImageOverlay = new Overlay(world, 0, 0, screenWidth,screenHeight, "npotTexture ", true);
       sceneImageOverlay.setDepth(900);
       sceneImageOverlay.setVisibility(false);
       sceneImageOverlay.setSourceCoordinates(0, 0, screenWidth, screenHeight);
 


In the application i render off screen 2 3d objects. After that i add the removed sceneImageOverlay showing the NPOT texture with the rendered 2 3d objects.


In onDrawFrame method i do this

 world.removeObject(sceneImageOverlay.getObject3D());//remove the overlay,must not participate in the off screen rendering.
       
      
       frameBuffer.setRenderTarget(npotTexture );//use for rendering the NPOT texture with screenWidth and screenHeight dimensions
      
       //clear screen
       frameBuffer.clear(back);
      
      ObjectA_3D.setVisibility(true);   //must exist in the off screen rendering
      ObjectB_3D.setVisibility(true);    //must exist in the off screen rendering
        world.renderScene(frameBuffer);
      world.draw(frameBuffer);
      frameBuffer.display();

         //--- till here the npot texture has the two 3d objects drawn in it's surface
      
        //---- NOW SHOW THE OVERLAY WITH THE npot_Texture TEXTURE -------
   
   world.addObject(sceneImageOverlay.getObject3D());//add the overlay because has the npot texture.
   sceneImageOverlay.getObject3D().setVisibility(true);

   frameBuffer.removeRenderTarget();//use the on screen renderer
   frameBuffer.clear(back);
   ObjectA_3D.setVisibility(false);   //we dont want it to participate in the on screen rendering
   ObjectB_3D.setVisibility(false);       //we dont want it to participate in the on screen rendering
   world.renderScene(frameBuffer);
   world.draw(frameBuffer);
   frameBuffer.display();


Finally on screen the sceneImageOverlay's npot texture is displayed.

How do you think about this solution?

I used overlay instead of plane, i dont know which is the better solution.

Now i want to apply some effects on this NPOT texture.

Behind sceneImageOverlay is drawn another overlay with depth =1000 ,which has on it's texture a captured image.

So i want to replace the red pixels of the sceneImageOverlay with transparent pixels to show on screen the captured image's pixels of the same position with red pixels.

I think i can use a fragment shader's discard command to do this.

The next step is to replace the blue pixels of sceneImageOverlay with the corresponding pixels of another texture.

Till now i havent found a solution.I think a small demo from you  will be very helpfull.

The displayed npot texture is shown upside down.How can I fix this problem?


Thanks in advance

43
Support / Re: Off screen rendering
« on: March 07, 2015, 10:46:35 pm »
Hi again,

I  assigned a  NPOTTexture  to the FrameBuffer as render target to render the scene into .

How can i convert the NPOTTexture  to a bitmap?

Thanks in advance.

44
Support / Re: Off screen rendering
« on: March 06, 2015, 12:58:31 pm »

These images are just to create effects and wil be  created by me.
Will be stored in the assets folder.

Actually the first image is an array of images which are called one next to other creating animation (like a movie).These images are called with high frame rate.Thats why i want to make the color replacement fastly.

Thanks in advance.


45
Support / Re: Off screen rendering
« on: March 06, 2015, 09:28:55 am »
Hi

In the AR Game is needed to render offscreen some 3d models (space ships,planets ...).
Perhaps is good idea to do the offscreen rendering on a NPOT texture.(The screen width and height are not power of 2 size).

When the offscreen rendering is completed i want to apply some effects on the NPOT Texture before rendering this texture on screen.

I want the black pixels of the NPOT texture to be replaced by the corresponding pixels of an image.(If a pixel of the NPOT texture in x,y position is black then must be replaced by the image's pixel located in the same x,y).

After that i want to replace the white pixels of the modified NPOT texture by the corresponding pixels of another texture this time.(If a pixel of the NPOT texture in x,y position is white then must be replaced by the other's texture pixel located in the same x,y).

Finally the modified NPOT Texture is rendered on screen.

Using FrameBuffer.getPixels() slows down the game because i need to apply the effects many times.

So using shaders i believe is a good solution.

Do you have an example of shaders to help me?

Thanks in advance.





Pages: 1 2 [3] 4 5 6