|
You tell the shader what texture UNIT you're using and you still bind that texture in your C code. That's why passing 0 seemed to work for you. You don't give it the texture ID.
|
# ¿ Nov 20, 2011 16:26 |
|
|
# ¿ Apr 26, 2024 03:25 |
|
HolaMundo posted:Doh! It's probably defaulting the value of that variable to 0, which is the first texture unit. And yes, for bump mapping, you would have multiple texture units and thus multiple sampler2D variables.
|
# ¿ Nov 20, 2011 19:51 |
|
HauntedRobot posted:I have a world defined as a bunch of polygon meshes and I'm using VBOs at the moment to render them. Currently the setup is If you want to still use VBOs with dynamic lighting instead of shaders, you could put the color values into another VBO and modify them each frame: code:
|
# ¿ Mar 26, 2012 14:44 |
|
FlyingDodo posted:I know that binding things in opengl is fairly expensive thing to do and you should try to minimise the amount of times it is called per frame. If something such as a buffer, texture, shader etc is already bound then how much is the performance hit if it is bound again? Is there a way to check what is currently bound, and if so how expensive is that compared to blindly rebinding something? You can use the glGet* functions to get the currently bound object for a particular type, for example: code:
Edit: Make sure you do an initial "OpenGL state reset" to get the GL state machine to match up to your initial state array values. HiriseSoftware fucked around with this message at 16:57 on Apr 6, 2012 |
# ¿ Apr 6, 2012 16:54 |
|
Boz0r posted:I'm trying to add the color from a texture with the colors of another texture (containing my lights). I have the following code: http://ideone.com/mb9380 and shader: http://ideone.com/AWCisI. However it only draws stuff from the tex texture. Can anyone spot my error? Maybe use glEnable(GL_TEXTURE_2D) for the texture unit 1 if it's not done somewhere else? Or maybe call glClientActiveTexture() as well as glActiveTexture()?
|
# ¿ Nov 19, 2012 15:42 |
|
unixbeard posted:How can I set a vertex to an arbitrary location in a vertex shader? So you don't see a single point being drawn? What kind of primitives are you trying to render?
|
# ¿ Dec 27, 2012 19:49 |
|
1. Use the translate, rotate, and scale functions to "fill in" your matrix, then you can multiply those matrices together. Read up on 3D matrix math. 2. He's trying to show that the math (i.e. the matrix multiplication) used by GLM is similar to GLSL, but suggests that you build the matrix first in GLM/C++ and then send the final matrix to GLSL via glUniformMatrix4fv(). 3. The "??" is the X, Y, Z coordinates of the rotation axis. So if you want to rotate a vector around the Z axis, specify (0, 0, 1). 4. You're correct about using MVP and glUniformMatrix4fv() - build your matrix with GLM and then send that to GLSL where the shader will multiply it by the vertex. 5. "g_element_buffer_data" looks like the indexes used to draw the triangle - it must be used (or something similar) inside blDrawTriangle() VVV Sure, but I was too lazy to quote his post! HiriseSoftware fucked around with this message at 04:38 on Jan 27, 2014 |
# ¿ Jan 27, 2014 03:34 |
|
Based on your code you're not multiplying your model matrix that you create in bInitMatrix2 with a view and a projection matrix, like what bInitMatrix is doing. The way you have it now, the "eye" at the origin is actually inside the cube, so you're not gonna see it with backface culling. You'll need a view matrix (like with glm::lookAt) to push out the cube a little bit so that you can see it. Plus you shouldn't have to use the identity matrix in your multiplication. code:
code:
|
# ¿ Jan 30, 2014 20:00 |
|
Raenir Salazar posted:But I mean, with that code I can see a single triangle that I draw with the three vertices, shouldn't it still be possible to see a cube without a projection matrix? Is the triangle facing towards the screen? At what Z is the triangle at? With a cube you're not going to see the faces of the cube while you're inside it (the eye is at 0, 0, 0) because of backface culling. Turn off culling and see if the cube shows up.
|
# ¿ Jan 30, 2014 21:27 |
|
Did you try drawing each of the triangles individually (i.e. without drawing the other) to see if it's actually doing the wireframe? Also, I saw this StackOverflow post that offsets the wireframe triangles instead of the filled: http://stackoverflow.com/questions/13438450/glpolygonmodegl-back-gl-line-isnt-working
|
# ¿ Feb 5, 2014 16:46 |
|
Colonel J posted:I am getting into programming with Three.js and I hope some of you can help me here. Does "cubeGeometry" have texture coordinates? When you're giving the mesh a texture material, it must be expecting some texture coordinates as part of the geometry, and it's getting none, which would cause the error. glDrawElements renders vertices by an array of indexes - it probably found the XYZ, but not the UV. Edit: I'll admit I don't have any experience with THREE.js but I was fiddling around with your, uh, fiddle, based on some info I found online, but I couldn't get anything to work. I did see this though: http://stackoverflow.com/questions/16531759/three-js-map-material-causes-webgl-warning HiriseSoftware fucked around with this message at 05:50 on Feb 6, 2014 |
# ¿ Feb 6, 2014 04:58 |
|
I don't have any experience with shadow mapping, but I found this which has a part about calculating the shadow map coordinates: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/ It's something about multiplying a "bias matrix" against the MVP matrix used from the viewpoint of the light. Multiply that result by your model coordinates and you have the coordinate you pass to the texture - XY is for the texture lookup, and Z is used to determine if an object is in shadow or not.
|
# ¿ Feb 8, 2014 05:09 |
|
Colonel J posted:Thanks for your help, I finally got it working. I couldn't really get the bias matrix to work as it would distort my geometry in strange ways. I just multiplied the vertice positions by 0.5 and translated by 0.5 and they're good now. Is the shadowing working correctly as you're intending? At certain points the shadow of the vertical stick should pass over the horizontal ones, but I can see that it's not. Maybe it's an artifact of my older video card, but it doesn't look right to me.
|
# ¿ Feb 11, 2014 21:23 |
|
Can you changecode:
code:
|
# ¿ Apr 4, 2014 21:34 |
|
Raenir Salazar posted:Why yes indeed! So by trying to use 4fv it wasn't working/undefined or some such? When using 4fv it thinks that the matrix is arranged 4x4 when you're passing in a 3x3 so you were getting the matrix elements in the wrong places. It could have also caused a strange crash at some point since it was trying to access 16 floats and there were only 9 - it might have been accessing those last 7 floats (28 bytes) from some other variable (or unallocated memory)
|
# ¿ Apr 4, 2014 21:45 |
|
Raenir Salazar posted:I finally did it! You can have a vertex array of color attributes (like texture coordinates or normals) but to allow each face to have its own color you'd have to "unshare" the vertices so that one vertex is only used by one face. That increases the data processed by the video card by up to 3x, but it's what you'd need to do.
|
# ¿ Apr 11, 2014 21:09 |
|
Raenir Salazar posted:To populate that vertex array though do you know if that can be done automatically with assimp to extract it from the mtl and obj files? I have no experience with that library, but I would hope that it does. The unsharing would have to work for texture coordinates as well - if two faces sharing the same vertex had different UVs, then you'd have to split that vertex into two unique ones. And it says it supports loading color channels.
|
# ¿ Apr 11, 2014 21:36 |
|
Try the solution here? https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-319/+bug/1248642
|
# ¿ Jun 17, 2014 20:13 |
|
AntiPseudonym posted:This is probably a bit of a weird question, but does anyone know how to disable perspective correction on textures in OpenGL, or at least emulate it via shaders? I'm trying to go for an authentic PS1 retro look and I think removing perspective correction would help add to the feel. Reading this: http://www.glprogramming.com/red/chapter09.html#name17 posted:When the four texture coordinates (s, t, r, q) are multiplied by the texture matrix, the resulting vector (s' t' r' q') is interpreted as homogeneous texture coordinates. In other words, the texture map is indexed by s'/q' and t'/q' . It seems that if you can specify Q=1 in your texture coordinates, you can get the effect you want. Edit: Hmm I think the default of Q is 1, so perhaps there's another operation going on afterwards to do the perspective correction. Edit: Or how about this? quote:If you use a vertex shader, multiply the texture coordinate by the W of the vertex position after you''ve applied the projection transform to it. HiriseSoftware fucked around with this message at 04:47 on Oct 10, 2014 |
# ¿ Oct 10, 2014 04:42 |
|
Did you try putting glGetError() after EVERY GL command and see where it first fails?
|
# ¿ Oct 24, 2014 16:12 |
|
|
# ¿ Apr 26, 2024 03:25 |
|
I want to apply a repeatable normal map texture to an arbitrary triangle mesh, like say a 3D model of a papercraft and give it a paper-y texture. I've got the model UV unwrapped for things like ambient occlusion baking, but I want the "paper" texture to be nice and uniform with no distortion. Can I use GLSL and texture matrices to do something like that? What math would be involved?
|
# ¿ Jan 28, 2015 18:02 |