I'm new to 3D libgdx.
I created the model in Blender and imported it into libgdx.
This is a regular cube with its own texture (looks like a simple box).
I use ModelInstance to create the cube in the game
it looks like this
ModelInstance box = new ModelInstance(new G3dModelLoader(new JsonReader()).loadModel(Gdx.files.internal(path)));
And I just have a question:
How should I create the effect: so that a yellow strip (2-3 pixels thick) runs along the perimeter of the box, from bottom to top??
The strip should not be light! (must not illuminate the environment)
If I understand correctly, I need to use shaders? (I would be grateful for at least an example of such a scheider).
Related
I have a card game (with dice) prototype made fully with UI objects in the canvas. I made it so 3D dice are shown whenever Dice are involved in the game.
It works like this:
Somewhere out of view of the main camera I made a little 3D area where Dice fall.
This Area has it's own camera with a render texture.
A Raw Image is placed in the canvas above everything else, with the render texture.
The view from the camera at the dice area is displayed through the Raw Image so it looks like the Dice are actually falling on the canvas.
This works perfect on PC and in the Editor. But on Android the RawImage and thus the RenderTexture is completely black. This seems to be a known issue in Unity for years now, but I can't find a solution that works for me anywhere. Does anyone know how I can make it so the RenderTexture works on Android?
Here are some images showing the elements I described:
The Game running with 3D Dice rolling:
Scene view, left = canvas, mainCamera and raw image, right = 3D Dice Area with seperate camera:
Close up for the 3D Dice area:
The Render Texture:
The camera in the 3D dice area with the render texture:
The Raw Image in the canvas with the render texture:
Set Depth Buffer to At least 24 bits depth
Just in case you still have problems with the black rendertexture, changing the graphic API from Vulkan to OpenGL ES3 should solve the problem, it did for me.
Credit for possible solution goes to pch4n:
https://forum.unity.com/threads/unity-rendertexture-black-when-saving-png-on-oculus-quest-android.1152818/
P.S. Please don't ask me why or how is this solution for our problem, because I have no idea, I just started learning unity.
I am developing an augmented reality app, that should render a 3D model. So far so good. I am using Vuforia for AR, libgdx for graphics, everything is on Android, works like charm...
Problem is, that I need to create a "window - like" effect. I literally need to make the model look like a window you can look through and see behind it. That means I have some kind of wall-object, which has a hole in it(a window). Through this hole, you can see another 3D model behind the wall.
Problem is, I need to also render the video background. And this background is also behind the wall. I can't just turn of blending when rendering the wall, because that would corrupt the video image.
So I need to make the wall and everything directly behind it transparent, but not the video background.
Is such marvel even possible using only OpenGL?
I have been thinking about some combination of front-to-end and back-to-front rendering: render background first, then render the wall, but blend it only into the alpha channel (making video visible only on pixels that are not covered by wall), then render the actual content, but blend it only into the visible pixels (that are not behind the wall) and then "render" the wall once more, but this time make everything behind it visible. Would such thing work?
I can't just turn of blending when rendering the wall
What makes you think that? OpenGL is not a scene graph. It's a drawing API and everything happens in the order and as you call it.
So order of operations would be
Draw video background with blending turned off.
The the objects between video and the wall (turn blending on or off as needed)
Draw the wall, with blending or alpha test enabled, so that you can create the window.
Is such marvel even possible using only OpenGL?
The key in understanding OpenGL is, that you don't think of using it to setup a 3D world scene, but instead use it to draw a 2D picture of a 3D world (because that's what OpenGL actually does). In the end OpenGL is just a bit smarter brush to draw onto a flat canvas. Think about how you'd paint a picture on paper, how you'd mask different parts. And then you do that with OpenGL.
Update
Ohkay, now I see what you want to achieve. The wall is not really visible, but a depth dependent mask. Easy enough to achieve: Use alpha testing instead of blending to produce the window in the depth buffer. Or, instead of alpha testing you could just draw 4 quads, which form a window between them.
The trick is, that you draw it into just the depth buffer, but not into the color buffer.
glDepthMask(1);
glColorMask(0,0,0,0);
draw_wall();
Blending will not work in this case, since even fully transparent fragments will end up in the depth buffer. Hence alpha test. In fixed function OpenGL glEnable(GL_ALPHA_TEST) and glAlphaFunc(…). However on OpenGL-ES2 you've to implement it through a shader.
Say you've got a single channel texture, in the fragment shader do
float opacity = texture(sampler, uv).r;
if( opacity < threshold ) discard;
First up all sorry for my English.
I started learning the opengl in android by reffering following link
http://developer.android.com/guide/topics/graphics/opengl.html
and also about drawing shapes by refering these
links
http://developer.android.com/training/graphics/opengl/draw.html
http://obviam.net/index.php/opengl-es-android-displaying-graphical-elements-primitives/
Now i turned to drawing 2d and 3d text using opengl in android but coluld not foun an perfect link for providing solution for drawing 2d and 3d text.
If you want the text outside your OpenGL viewing area, you can place your GLSurfaceView within a layout, with the text in the other controls. This is the simplest option.
To place text within the GLSurfaceView, you either draw the individual characters as 3D ojbects and place them appropriately, or create a bitmap with the text you want and use it as the texture for a flat surface which you draw as part of your scene.
I have a 3D cube created using GL_TRIANGLE_STRIP.Is it possible to draw points(using GL_POINTS) or a triangle (using GL_TRIANGLE) on/inside my 3D Cube?How could that be achieved?
If you want to draw something directly of the face of another object (by using the exact same vertex coordinates), you will need to use glPolygonOffset to prevent stitching. There is a chapter in the Red Book that explains it.
If by inside you mean to draw something in the volume of the cube, than there is nothing stopping you. You just need to get the alpha values and blending right to actually see through the cube. Look for some generic tutorial on transparency in OpenGL.
But maybe I'm horribly mistaken and what you are looking for a textures.
If I understand you correctly you could just generate the appropriate texture with the points and apply it to the cube.
Firstly I must say I'm green as grass in opengl subject.
I'm writing simple 2-d game for android using opengl-es. I use GL11Ext.glDrawTexfOES() to draw the textures (just like in one sample code named 'sprite-method-test'), and gl.glColor4f to color them (and set transparency). But I'm completely helpless if I need apply some brightness or contrast to the rendering texture.
I really appreciate any help.