Hello I would like to know how I can clip off part of a texture that overlaps with another texture. Like the image below but without rendering part of the overlapped white "X". The octagon has an alpha transparency, i want to be able to see every thing under it except part of the overlapped white X.
Maybe this can help you
libgdx open gles 2.0 stencil alpha masking
It Looks like you Need to use a mask..
Another link, where I had my own Problem, where I used a depth buffer would be this here:
https://gamedev.stackexchange.com/questions/119821/libgdx-shaperender-within-a-circle-as-limitter/119869#119869
I hope this will help you furthermore.
Related
I'm developing little game based on LWJGL (so Java). I'm rendering skybox (that darkblue somthing on image), that is constructed from 6 quads (GL_QUADS) and one box (white something), that is rendered using VBO.
Problem is, that white box is glitching (geometry is OK, but image in framebuffer is...). I dunno, how to find reason (depth testing, alpha, ...) I've tried someting (render ordering), but nothing helps.
Is render order important for objects, that are solid (opaque)?
It's typical. Lastly I tried to disabling features in renderer.
glEnable(GL_DEPTH_TEST);
This was that beast.... tfuj - I'm sorry for spam.
It looks like your box is too close to camera so it is cut buy near clip plane. Try decreasing the nearVal of glFrustum.
I'm trying to make a simple java game.
I have some png file that i want to draw, but first i want to make some modification on that png. I would like to take a png, and delete to background some parts of it and add some colored lines..
For my game im using libgdx.
I dont know what to use for this, so i can search on google about it and learn.
Few hints, about what functions i should use could be awesome, Ty.
P.S. I tryed to search on internet before post here, but i didnt find something that could help me, probably idk what to search.v
Edit:
I found Pixmap from libgdx, but i can delete to background. Any advices ?
Edit2:
i want to load this texture
multiplicate when needed (no problem here)
and delete some parts of it, to background, so it will take this shape:
by using pixmap, when im drawing background over it, nothing is happen, because its draw over, not instead of.
What i could make, was using pixmap to draw the top part, that i want to delete, and manualy delete it using external programs:
I think you might want to look at a "mask" image. There are some approaches listed here: https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Masking
Alternatively, you could use create a mesh that encodes the "ground" (with the bump) and then texture it. OpenGL would take care of truncating the edge of the mesh. Try: Drawing textured polygons with libgdx
Another approach is to just draw the dirt texture on the full screen, and then draw the "background" over it. You will need to make pixels in the "background" image transparent so the dirt will show through. Whatever pixel editor you are using should be able to do that. Alternatively, pick a "key" color and convert those pixels to transparent when you load the image as a pixmap.
I don't know if this question is serious, but you cannot do what you're asking in Java. You need a photo editing software such as Photoshop or GIMP.
Im working with text recognition with Java and Tess4J. Im recognizing black and red images (separately), both with white background, very clear. With the black ones, it works perfectly, but with the red ones, tesseract just goes crazy. I tried adding the variable ("editor_image_text_color", "RED"), but it does not help at all.
Right now, what I do for the red ones is scan the whole image and set every red pixel to black, which I find very inefficient, because I need a few calculations for each pixel, due to the pictures have different intensity of red that I have to conserve.
Thanks a lot!
For instance:
http://imageshack.us/photo/my-images/593/3eu9.png/ does always give me a 9, but
http://imageshack.us/photo/my-images/818/efxf.png/ does not, is like if it were losing the number in the preprocessing, because the black ones work extremely well, but the red ones arent any better than a random number.
Try to convert the colored image to grayscale using ImageHelper.convertImageToGrayscale(BufferedImage image) method.
Thanks for the answer nguyenq, I tried that function and it didn't work very well, but after checking out that ImageHelper class, I used the method:
ImageHelper.convertImageToBinary(BufferedImage image)
and it works quite well, thanks!
the title must seem somewhat cryptic but I could not really explain there what I want to do, so I drew a picture to visualize my problem:
The black parts are transparent (aka alpha = 0). I have the blue object (left) in the framebuffer and want to render the white bitmap (middle) onto it, so that it looks like the merged bitmap (right).
The problem is that if I use the standard glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); the whole part of the white object is being displayed. I don't want it to completely overlap the stuff in the framebuffer (blue) but only be visible on the parts where it has an alpha value > 0 (is visible). And then it should also still takes its own alpha values into account (notice the hole in the white object).
Is something like this possible with glBlendFunc or do I have to write a shader for this ?
PS: I looked at the documentation of glBlendFunc at http://www.khronos.org/opengles/documentation/opengles1_0/html/glBlendFunc.html but I don't really get anywhere with it.
PPS: I am using OpenGL-ES 2.0 on Android with C++, but I don't think the language/platform matters all that much.
I don't think it will be possible to do this purely with the blend function. You want the source pixel to be multiplied by both the source and destination alpha, while the blendfunc only allows one or the other.
However the result you want may be possible with some use of the stencil buffer. I'm not an expert in it but I think you can set the stencil op to increment while drawing the background image, and then when you draw the bitmap set the stencil test to reject where stencil == 0 (with blending still enabled to get the transparent area of the bitmap correct). You'll have to review the API for glStencilOp and glStencilFunc to figure out the exact right arguments to use.
It might also be possible with some combination of glBlendFunc and glAlphaFunc, but it would depend on the order of which they are evaluated, so I'm not positive.
I've googled around everywhere, but cannot find much for rendering strings to textures and then displaying that texture on a quad on the screen. Can someone provide a run-down on the process or provide good resources that describe how? Is rendering strings to textures even the best method for displaying text in an Android OpenGL ES app?
EDIT:
Okay, so LabelMaker interferes with alpha blending, the texture (created from a PNG with a transparent background) now has a solid black background, rather than a transparent background. If I comment out all the LabelMaker-related code, it works fine.
UPDATE:
Nevermind. I took a look at the code to find that LabelMaker was disabling blending after drawing the labels.
I think this is what you are looking for.
If you don't want to use GL extensions you need to create the font as a bitmap and then create a class to convert that string into quads that you can draw.
I use this method with the 2 fonts in my game. I have a class that takes a wide texture with all the letters evenly spaced, and a string that matches the image, then uses lookups on the letters to find out how far in the bitmap it should go.
Your other option is to render your text to a offscreen bitmap using android, and then bind the text as a texture. This will let you use androids built-in font processing and rendering to create texture-based fonts.
The second method I have not used yet, but I have rendered google maps to a offscreen canvas and then bound the bitmap as a GL texture, so doing it for text should be much simpler.
If you are planning to have modifying string data in a gl loop you need to really worry about StringBuilder too, because it causes GC and performance issues. I hardcode all my strings so it doesn't allocate, and all my rapidly numbers are done through a second draw function dedicated to drawing changing numbers without using string-builder.