How to handle texture animation in OpenGL? [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I started using OpenGL with SDL2 and GLEW not so long ago, and I got two questions:
How to pass a texture to GLSL's uniform sampler2D ? It seems to do it automatically when binded, but it confuses me.
And the main question here:
What's the best way to handle texture animation?
Should I do it by GL_TEXTURE_3D? By loading all frames into multiple GL_TEXTURE_2D? Is there a built-in way for animation?

glActiveTexture and glBindTexture calls in this order will bind a texture to the given sampler slot.
Use a spritesheet as a TEXTURE_2D, and change the texture coordinates for swapping the animation frames.

Related

How to make low-res graphics with opengl? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am writing using opengl in C and I want to make oldschool style graphics – like Star Fox for SNES. So I plan to have a 2D array (I'll figure out how, just talking pseudocode for now) of fragments that will represent the lower resolution (you can imagine just containing rbg color info). So I'm going to be writing my own code that makes the 3D world and rasterizes it into this 2D array (might try to get the GPU to help there). Does this even make sense? Are there better ways to make low-res 2D graphics using OpenGL?
Render scene to low-resolution FBO.
Stretch-blit FBO contents to screen using a textured quad or glBlitFramebuffer().

change specific pixel color via fragment/pixel shader?(opengl) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Is there any way to change specific pixel color via fragment/pixel shader? (like a uniform variable?)
To be specific, im trying to implement ray-traced shadows.
If by pixel you mean an actual pixel on the screen, then you can achieve that with multistage rendering. Render your scene to an FBO (to a texture), then render the quad onto a screen with that texture.
If the FBO texture size will be exactly the same as screen size, every invocation of the fragment shader will nicely correspond to the screen position.

opengl texturing a height map [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I can't seem to find any tutorials or information on how to properly texture a terrain generated from a height map.
Texture mapping is not the problem, what I want to know is how to texture the entire terrain with difference elevations having different textures.
What I came up with was having a texture that looks like this:
Depending on the elevation of the triangle a different texture is assigned to it.
The result:
What I'm trying to do is create an environment like skyrim, were textures don't need to repeat constantly, a convincing landscape!
The question is how do I create some thing like this:
The textures blend together seamlessly at different elevations! How is this done? What is the technique used?
Example Video: http://www.youtube.com/watch?v=qzkBnCBpQAM
One way would be to use a 3D-Texture for your terrain. Each layer of the texture is a different material (sand, rock, grass for example). Every vertex has a third uv-component that specifies the blending between two adjacent textures, you could also use the height of the vertex here. Note that a blending between grass and sand in our example is not possible with this approach because rock 'lies in between', but it is certainly the easiest and fastest method. An other method would be to use individual 2-dimensional textures instead of a single 3D one. You would then bind the textures sand and grass for example and draw all vertices that need a blending between the two. Bind two other textures and repeat. That is certainly more complicated and slower but allows blending between any two textures.
There might be more methods but these two are the ones I can think off right now.
Professional game engines usually use more advanced methods, I've seen designers painting multiple materials on a terrain like in photoshop but that's a different story.

Simple texturing in OpenGL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am trying to texture a 3D sphere I created. I am having difficulties understanding How textures works. They way I understand it is a picture file that "wraps" a 3D object. I found some tutorial online but If there is a really simple one to get me started that will be nice.
I am usind OpenGL 3+ on Ubuntu.
As simple as it gets. Link.
Should be very easy to understand, if you don't then simply conduct further research.
opengl redbook is a good source of knowledge for this:
http://fly.cc.fer.hr/~unreal/theredbook/chapter09.html
basicly texturing any geometry requires you to specify for each vertex additional coordinates from your bitmap space. Since bitmaps are 2D you use two dimensional coordinates u,v. Your video card will extrapolate those coordinates and while rendering triangles from your verticies will put appropriate texels (texture pixels) from your bitmap. u,v coordinates for more complex geometry should be either calculated from code or be put manually in some 3D software like Blender.

How to add glowing effect to a line for OpenGL? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How can I add a glowing effect to a line that I draw? I'm using OpenGL for Linux.
You can implement the radial blur effect described on Nehe Lesson 36. The main idea is to render the drawing to a texture, and do that N times with a small offset after each render, until the drawing is ready to be copied to the framebuffer.
I've written a small demo that uses Qt and OpenGL. You can see the original drawing (without the blur) below:
The next image shows the drawing with the blur effect turned on:
I know it's not much, but it's a start.
I too once hoped there was a very simple solution to this, but unfortunately it is a little complicated, at least for a beginner.
The way glowing effects are implemented today, regardless of API (D3D,OpenGL) is with pixel/fragment-shaders. It usually involves multiple render passes where you render your scene, then render a pass where only "glowing objects" are visible, then you apply a bloom pixelshader and compose them together.
See the link provided by #Valmond for details
Edit:
It should be added that this can be achieved with deferred rendering, where normals, positions and other information like a "glow flag" is rendered to a texture, i.e. stored in different components of the texture. Then a shader will read from the textures and do lightning computations and post-processing effects in a single pass since all data it needs is available from that rendered texture.
Check this out : http://developer.download.nvidia.com/books/HTML/gpugems/gpugems_ch21.html
It explains easily how to make glow effects.
Without using shaders, you might also try rendering to texture and doing a radial blur.
As a starting point check out NeHe-Tutorials.