Tag Info

New answers tagged

0

Now that I know that the context is rendering to a texture frame buffer I can try to answer. Yes, you do have to glDisable(GL_BLEND) otherwise it will blend according to whatever glBlendFunc is currently set, which will mess with the RGB channels based on what you're writing to the alpha channel. Then you need to do blending you write it in your shader. ...


0

A solution is to avoid deallocating the btBvhTriangleMeshShape altogether. Instead of this: physics_object->triangle_mesh_shape = new btBvhTriangleMeshShape{physics_object->triangle_mesh, true}; physics_object->collision_shape = new btBvhTriangleMeshShape{*physics_object->triangle_mesh_shape}; Use this: physics_object->collision_shape = ...


4

If the textures are the same general "shape" (dimensions, mip levels, etc.) then use texture arrays. You can pack differently "shaped" textures into different arrays if you have any regularity, which you should. This approach gives you all the advantages of individual textures (e.g., no bleeding) plus all the advantages of a texture atlas (e.g. fewer state ...


0

Use big texture, it's better. Avoiding pixel leakage is no that hard: If you can, use GL_NEAREST, else add small empty lines between textures.


0

Profiling is always the best choice... But I've liked the combined texture approach the most it makes it easier to deal with trying to minimize swaps because you don't have to :) You may also want to look at some of the sampling options you selected they could reduce the issue of the neighbor pixels bleeding into other textures.


0

I finally figured this out, and it's impossible to solve knowing only the code here, because it is actually right. The issue was the way normal maps were uploaded to OpenGL. In glTexImage2D you specify the internalFormat - the normal map was uploaded to OpenGL using the same code as diffuse textures, which are in non-linear colorspaces, so i was using ...


1

If anyone is interested or stumbles upon such problem. I implemented complete batch rendering. Meaning that now i can batch render objects from the same type with one draw Call. Further more i am working on implementing a LOD algorithm for the terrain and also implementing Frutrum Culling to limit maximum objects rendered per frame. This results in huge ...


1

You have a very strange code here. Why do you have glDetachShader(program, vertex_shader); glDetachShader(program, fragment_shader); lines in your shader init code? They should be used when you destroy your shaders. Remove them completely or call them on quit. If it won't help, then I suspect that glDisableVertexAttribArray() resets vertex attribs' ...


0

Lacking an OpenGL compiler I forgot a semicolon. So this "v_TexCoordinate = a_TexCoordinate" + should be this: "v_TexCoordinate = a_TexCoordinate;" +


2

It is typical to use a 32-bit depth-buffer: GL_DEPTH_COMPONENT32F //internal format GL_DEPTH_COMPONENT //depth only GL_FLOAT //float(32-bit depth) If you also wish to utilize the stencil buffer, it is typical to dedicate 8 of those 32-bits to the stencil: GL_DEPTH24_STENCIL8 //internal format GL_DEPTH_STENCIL //depth + stencil ...


1

Your problem is that you're doing this: glPushMatrix(); glTranslatef(0, 0.03 * dt, 0); // (...) glPopMatrix(); The offset created by the glTranslatef() command only exists between the glPushMatrix and the glPopMatrix; it doesn't retain its values from previous frames; the offset goes away forever as soon as the matrix is popped. So assuming that dt ...


0

There are a variety of formulae for converting colour to black and white. Furthermore, the programmer might mean something else when converting a vector into a scalar (length would be a common example). The shader compiler keeps things as simple as possible, just taking the first value in the vector, in your example. Experiment with different ways to get a ...


1

There's an easy solution - don't translate with a matrix. Since you're using immediate mode, it's an incredibly easy matter to simply offset the texture coords however much you'd like. EG, glTexCoord2f(1, 0.03 * dt); This will, of course, not be so easily done when you learn about the OpenGL Core Profile, which is highly recommended to be used. But until ...


0

have you tried to assign a separate var for each texture? also what is RepeatTexture(); calling? i think that may be the source of your problems


0

Code works for me, exactly as presented in the question (after adding the missing #include lines). (Ubuntu 14.10, AMD Radeon HD 5870, running the latest Catalyst drivers) Middle sphere is hit by the spotlight, left and right spheres are not. Whatever your problem is, it's presumably not the code (although I haven't tested this on any devices other than ...


0

This portion of your code is not technically blend state, but could be affecting the behavior here: glDepthMask(FALSE) glDepthFunc(GL_EQUAL) D3D11 does have corresponding state to this, and you can set it by creating and binding a ID3D11DepthStencilState object, in a similar way to what you're doing with the ID3D11BlendState. See ...


0

I was not using the shader after I loaded it. Added GL.UseProgram(mShader.ShaderProgramID); After shader loading code.


4

Solution 1: Rotate your UVs in your vertex shader The vertex shader is where per-vertex attributes can be modified before rendering. These values are then linearly interpolated to generate values for all fragments of your polygons. As a rotation of your your UVs is a linear transformation, you only need to recalculate the values in the vertices, and linear ...


0

You draw with GL.BindVertexArray(mVertexArrayObjectIDs[1]); GL.DrawElements(PrimitiveType.TriangleFan, 4, DrawElementsType.UnsignedInt, 0); however the indices you use are for PrimitiveType.Triangles Replace that with GL.BindVertexArray(mVertexArrayObjectIDs[1]); GL.DrawElements(PrimitiveType.Triangles, 6, DrawElementsType.UnsignedInt, 0);


0

According to some math websites, when the modelMatrix lacks any non-uniform scaling, calling inverse().transpose() on it will produce the exact same matrix. This is slightly incorrect. Let's define N as M.inverse().transpose(). Then N = M is true only if M is a rotation matrix. If M has uniform scaling, the resulting matrix N will be different. ...


3

Original RenderTexture image on the left, edited Texture2D image on the right. public class PixelChange : MonoBehaviour { public RenderTexture renderTexture; // renderTextuer that you will be rendering stuff on public Renderer renderer; // renderer in which you will apply changed texture Texture2D texture; void Start () { texture = new Texture2D ...


0

Try using something like this ... http://docs.unity3d.com/ScriptReference/RenderTexture.html ... by that I mean more specifically this ... http://docs.unity3d.com/ScriptReference/RenderTexture.GetTemporary.html ... presumably combined with ... http://docs.unity3d.com/ScriptReference/Camera-targetTexture.html ... to render what a camera sees to a ...


1

Without immutable storage you can just specify a texture array using glTexImage3D. I note that you say you've tried this but it didn't work; it would have been helpful if you had given us the code that didn't work, as you clearly have an error in it which we may have been able to help you with. That aside, there is another way which is minimally invasive ...


0

Texture arrays have been part of the OpenGL core context for as long as there's been a core context; ever since OpenGL 3.0. Pretty much every desktop computer sold within the last six years will support OpenGL 3.0 or later. Ultra-mobility laptops more than three years old might be problematic, but anything more recent or more beefy than that should be ...


7

Unfortunately these kinds of unexplained stalls can be common, and very hard to answer perfectly. To answer the question precisely, we would have to know what is happening inside the driver during that short stall. NVidia and AMD only provide us with so much information about their driver's behaviour. Sometimes we have to make guesses. And sometimes the ...


0

I have the same issue, windows 8.1x64 R9290. The shader cannot read the length of a buffer. I got round this by creating another SSBO with containing the lengths of the Light array. I don't need to do this on Nvidia or Intel chips. Another issue is that vec3 types didn't seem to work due to memory padding, so I manually pad all data as a vec4. This ...


4

The artifacts are caused by scaling the images using point sampling / nearest neighbourhood filtering, which effetively doubles some of the pixels from the original image. To get better results, switch to bilinear filtering which uses weighed average of multiple pixels. The result will be a little blurry, but should look a lot better than the current one. ...


0

The bounding box you described is intersecting the frustum, even if your visualisation isn't making it apparent. At a position of 0, 10, 0, and the camera's position at 0, 3, 10, the difference in position is 0, 7, 10. Further, the difference of position from the camera to the top-most near corner of the 2x2x2 box is actually 0, 8, 9. With a FOV of 60 ...


3

Yeah, most games use a model's rigging and apply animation tracks to the bones in real time based on things happening in the game or player input. Animations can also be blended between to make new animations or transition from one animation to another. Animations can also be combined such that the lower half of a body is playing one animation and the ...


0

Here is an Intersects(A,B) method implementation taken from C# Rectangle.cs public bool Intersects(Rectangle a, Rectangle b) { return (b.X < a.X + a.Width) && (a.X < (b.X + b.Width)) && (b.Y < a.Y + a.Height) && (a.Y < b.Y + b.Height); }


2

I assume eye and look are in global space and up is in local space. Then you can use this: tmp = (look - eye) * up up = normalize(tmp * (look - eye)) tmp, look, eye and up are 3D vectors. * means cross product. - means usual vector subtraction. normalize() is normalization function, which returns same vector but with lenght == 1. If for some reason look ...


0

glEnable(GL_NORMALIZE); seems to work!


0

Short version: a) 0.5/0.5/0.5 In the metals workflow, the specular colour will be exactly as sampled in the Albedo map. It's possible with PBR to have some metals shinier than others (while of course still obeying conservation of energy), which can only be achieved by allowing dimmer colours in the Albedo Map to result in dimmer specular values.


0

Setting the glClearColor, as Josh Petrie said, is only necessary to do every frame if you do not know if another part of your program is changing it. Although, usually you would be drawing your own background, which would cover the entire background, so the color should not matter. (Of course, you still need to clear the screen every frame to prevent ...


1

In LibGDX Doc Gdx.gl.glClearColor(0, 0, 0, 1); and batch.setProjectionMatrix(camera.combined); is setting in render() method at a time. I use this definitions in create() method at once, and it is running perfect. So why should i use this definitions in render() method? is't it a performance loss? The clear color is part of your OpenGL ...


0

Edit: As usual, I've not paid attention and answered a GL question with DirectX code; sorry... Although the API differs, the idea is very much the same. It will technically qualify as a performance loss, but it may be unavoidable. Ideally, you only want to notify the video card of changes to "whatever is current". Since you are in complete control of the ...


4

The first step in implementing a physics engine is to model the movement of each object in form of a 3d velocity vector. Each object has current velocities in x, y and z direction. Each logic tick of your game engine, the object is moved by its current velocity. Changing the velocity-vector of an object by applying an acceleration-vector is the primary ...


1

Edit: We tried many combinations of the following and got many, many, equally-disappointing results. OP has resigned to using his backup plan of physically moving the geometry slightly toward the camera before drawing it as wireframe. Link to chat. A typical use might be to set factor and units to 1.0 to offset primitives into positive Z (into the ...


0

You need to unbind your texture object after using it for drawing certain shape. // In Texture class add void unbind() { glBindTexture(0); } public void drawTex(Texture t, int x, int y, int width, int height) { t.bind(); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(x,y); glTexCoord2f(1,0); ...


2

user1118321's answer will provide you the correct answer, though it is more general than necessary. Since we're dealing with a right triangle, the easiest solution is to use the definition of the tangent function: tan(α) = A / B Substituting half the height of the screen, the z coordinate of the camera, and half the vertical field of view gets us: ...


2

Check out the Law of Cosines. It allows you to calculate any side or angle in a triangle if you have the opposite 2 angles or sides. Or alternately, use the law of sines (described at the bottom of the above link). In your case, you know that vertical field of view is 45 degrees and that the base side you want is the height of the screen. You can think of ...


1

Okay, I solved the problem. As the guys commenting above pointed out, the code was weird. It wasn't really clear what was happening. This was a result of my brute forcing axis until the individual faces aligned. However, it's what resulted in the above. So I've taken the time to draw on paper how each face should be stepped through and I found the answer. ...


2

In order to do a glow or bloom, you generally need to start with an image, threshold it and possibly colorize it, then blur it and add the blurred version to the original. I would do this by creating a few textures and FBOs for multiple passes. Something like this pseudocode: Create an FBO Attach a texture to it to draw into Draw a textured quad with your ...


0

There is a problem using SDL_Renderer with OpenGL. You can save the text to a Surface, and then use this example: http://www.sdltutorials.com/sdl-tip-sdl-surface-to-opengl-texture


2

The scissor rectangle applies to pixels within the depth and stencil targets, just as it does to color targets. Only pixels within the scissor rectangle will be candidates for writing, so other states controlling reading from or writing to depth/stencil targets are essentially irrelevant - they will never be read or written. For example, the depth write mask ...


0

Doing this manually is insane. You need a tool that will take a folder full of images, pack them into atlases AND write a file containing all the coordinates. So then in your game you could address any image by its index or name or whatever and get its atlas coordinates (in pixels or UV).


0

You have 3 points, P01, P1 and P2. (Look at the figure right above the equation.) The points create a triangle. This triangle lies on a plane and on this plane are the two vectors T and B. (Tangent and Bitangent) These vectors are more or less random, optimally they are at a right angle, but this may not be the case, the only requirement is that they are not ...


3

Generally speaking, using old OpenGL API is not efficient. In ye olden days of OpenGL 1.0 this pattern was necessary. The model view matrix contains the model and the view matrix. You have the view matrix on the camera and the model matrix on the model. You set the view matrix onto the model view matrix and then push/pop the model matrix on top of it for ...


1

generally it's acceptable but not best. If objects share same material and animation skeleton, make them into one batch and call glDrawArray once, though it's advanced usage if you are new to opengl, and it need more code work to achieve. you can read this and this for reference. Another simpler way is reduce the glPush/Pop Call by grouping objects share ...


1

In my case, modify glutWarpPointer(centerX, centerY); to something like if (x != centerX || y != centerY) glutWarpPointer(centerX, centerY); perfectly solved the problem. The problem is caused by glutWarpPointer triggering another passive motion event to (centerX, centerY), which results in a loop and/or floods the event queue. To avoid it, simply ...



Top 50 recent answers are included