Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Nov 2005
Offline Last Active Today, 12:14 AM

#4961868 Want to rewrite the pixel buffer

Posted by on 21 July 2012 - 11:19 PM

Dont do that. glRead and glDraw are slow.

Are you just fading to red? Draw a red quad and change the alpha. You can always use a texture with varying red/blood instead of just using pure red.

You have to call glRasterPos and glLoadIdentity to DrawPixels

#4961351 Fill distance with quads

Posted by on 20 July 2012 - 10:02 AM

Simple way without using a line drawing algorithm like Bresenham:

Create a 2D vector between start and end brush.
Find the length in pixels of that line using pythagorean theorem.
float timeStep = 1.0/length in pixels
float time = 0;
for(int i = 0; i < length in pixels; i++)
Vec2 fillPos = start + time*brushvector;
time += timeStep;

When time = 1, the fill pos is the endpoint
When time = .5, the fill pos is halfway to the endpoint

#4960952 Fill distance with quads

Posted by on 19 July 2012 - 08:46 AM

I cant't know where user will be drawing

Based on your drawing you are trying to fill the points between the last brush position and the current. So you know where the user is drawing.

The only way to fix this is to draw a brush for each pixel in between the circles. If you use a distance bigger than that you won't get a brush stroke, you will get more of a caterpillar looking brush, like the medium drawing you posted.

#4960613 Easy OpenGL Directional Lighting Question

Posted by on 18 July 2012 - 01:22 PM

So what I would suggest again, is instead of binding the shadow texture, Bind an image of a tree or anything and see if you can see any of the image at all noticeable.

The Shadow Mapping part works great at the bottom, but the top part seems to be screwing up somehow.

So you have shadows but not lighting? Post a pic.

You mentioned you have a 0 for the w coordinate but you are subtracting light position from world position as if it is a point light.

#4960588 Easy OpenGL Directional Lighting Question

Posted by on 18 July 2012 - 12:27 PM

So you are most likely doing it wrong because shadow mapping does not require a vector to the sun at all, and will have nothing to do with normalizing it either.

When learning shadow mapping, try projecting an image texture instead of a depth buffer, this way you can get the math part down and then just replace the image with a depth buffer, because sometimes you will user a depth buffer that is not what you thought it was.

I would post your shader or the shadow portion of it.

#4960491 Fill distance with quads

Posted by on 18 July 2012 - 08:47 AM

So I calculate distance between previous point and current point, and if its bigger than something I need to add more quads to that distance automatically.

Uh.....call your draw function for the space in between each brush...

You know how to draw quads. You know how to draw multiple quads. It sounds like you can draw a few more....

#4960319 Easy OpenGL Directional Lighting Question

Posted by on 17 July 2012 - 09:53 PM

Wouldn't to the west and up (as per my prior description) be (-1,0,1)


Assuming that for whatever reason I had translated to some arbitrary point, making it the center (say, [x, y, z]), the resulting light would require the light direction to be (x -(-1), y, z - 1) => (x + 1, y, z -1), correct?

A light with w = 0, means it is directional and not effected by translation basically 0*translation is what the math comes out to be. If you want a positional light such as a lamp post then yea something like that.

I'm pretty sure the lights position is normalized if you use GL without shaders. The vector 1,0,1 is bigger than 1,0,0. If you don't know the Pythagorean theorem then thats what it is for.

#4959862 Easy OpenGL Directional Lighting Question

Posted by on 16 July 2012 - 10:23 PM

The direction in regards to lights is the direction pointing to the light. Not the direction the rays are coming.

Unless you have a modified coordinate system, openGL y-axis is up.

#4958822 Detect camera inside wall

Posted by on 13 July 2012 - 09:45 AM

This is a physics problem. You don't need to test every triangle but you can generalize things like say a statue as a box.

#4958052 Seriously don't understand WHY my framebuffer isn't rendering as a te...

Posted by on 11 July 2012 - 09:06 AM

Only thing I saw different from my code was
glFramebufferTexture vs glFramebufferTexture2D is what I use.

#4955103 Help please- Blender to Maya

Posted by on 02 July 2012 - 05:24 PM

Doesn't make a whole lot of sense that you need to learn Maya for an indie place. You can always export your models from blender and import into maya. Your question about learning it is pretty stupid though. What don't you specifically get? Edge loops? Uv-unwrap? Why can't you google those things for maya and read about it. You asked "I know blender so how do I learn maya." You learn maya, blender has nothing to do with it. Its not like someone here wrote a book called Blender to Maya, you just have to read about it and figure out hotkeys.

#4954716 Help! My directional light gets rotated along with my meshes :(

Posted by on 01 July 2012 - 06:39 PM

Oh duh, just re-read it:
float diffuse = max(dot(a_Normal, nSunVector), 0.0);

You have to keep both vectors in the same space. Right now your sun vector is in the world, A_Normal is static/in object space. As the model rotates, you need to take a_normal and multiply it by the model matrix. This keeps it in world space. If you put the view matrix in there as well then the normal is in view space relative to the viewer.

So multiply a_Normal by the model matrix and you are fine, or
multiply a_Normal by the modelviewmatrix and the sun by the view matrix to get them both into view space.

#4953678 Multitexturing and glBindTexture

Posted by on 28 June 2012 - 09:20 AM

We have told you several times, yes what you posted is safe, it is the same thing I posted in a different way. The textures always stay bound. In other words:
The textures always stay bound.

"Can I use them again by activating the texture and not re-binding the texture?"
Yes the textures always stay bound.

#4953468 VBO what does GPU prefers?

Posted by on 27 June 2012 - 03:59 PM

example 2 is still super fast. I've been using it forever and just focused on other things since I don't need to nitpick for optimization yet. example 1 is going to give you some boost for sure. I would think in big scenes it would even be noticeable.

#4953411 Multitexturing and glBindTexture

Posted by on 27 June 2012 - 12:48 PM

Not sure what you mean. You have 8 texture units by default. You can bind any texture you want to any unit, and they remain there for the life of the program no matter what unit is active or if texturing is disabled for that unit. The texture will stay bound even if texturing is disabled.

If you have a model with 3 textures, 2 textures and 1 texture, you can do:
drawModel3(); //again

That what you mean?