• 9
• 9
• 11
• 12
• 9
• ### Similar Content

• Good evening everyone!

I was wondering if there is something equivalent of  GL_NV_blend_equation_advanced for AMD?
Basically I'm trying to find more compatible version of it.

Thank you!

• Hello guys,

How do I know? Why does wavefront not show for me?
I already checked I have non errors yet.

And my download (mega.nz) should it is original but I tried no success...
- Add blend source and png file here I have tried tried,.....

PS: Why is our community not active? I wait very longer. Stop to lie me!
Thanks !

• I wasn't sure if this would be the right place for a topic like this so sorry if it isn't.
I'm currently working on a project for Uni using FreeGLUT to make a simple solar system simulation. I've got to the point where I've implemented all the planets and have used a Scene Graph to link them all together. The issue I'm having with now though is basically the planets and moons orbit correctly at their own orbit speeds.
I'm not really experienced with using matrices for stuff like this so It's likely why I can't figure out how exactly to get it working. This is where I'm applying the transformation matrices, as well as pushing and popping them. This is within the Render function that every planet including the sun and moons will have and run.
if (tag != "Sun") { glRotatef(orbitAngle, orbitRotation.X, orbitRotation.Y, orbitRotation.Z); } glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glRotatef(rotationAngle, rotation.X, rotation.Y, rotation.Z); glScalef(scale.X, scale.Y, scale.Z); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); if (tag != "Sun") { glPopMatrix(); } The "If(tag != "Sun")" parts are my attempts are getting the planets to orbit correctly though it likely isn't the way I'm meant to be doing it. So I was wondering if someone would be able to help me? As I really don't have an idea on what I would do to get it working. Using the if statement is truthfully the closest I've got to it working but there are still weird effects like the planets orbiting faster then they should depending on the number of planets actually be updated/rendered.

• Hello everyone,
I have problem with texture

• Hello everyone
For @80bserver8 nice job - I have found Google search. How did you port from Javascript WebGL to C# OpenTK.?
I have been searched Google but it shows f***ing Unity 3D. I really want know how do I understand I want start with OpenTK But I want know where is porting of Javascript and C#?

Thanks!

# OpenGL pixel offset after rendering to fbo?

This topic is 413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, when I render the screen to an offscreen buffer for downsampling or storage for later it gets offset.

I noticed it when I was writing a wide radius bloom shader as the offset increased after every downsample and blur making it more and more noticeable.

im using opengl and have GL_LINEAR enabled for the offscreen buffer and the viewport size is 1024x1024 with the offscreen buffer matching that.

Shouldnt the offscreen buffer match the main exactly pixel for pixel if its not being resized or is this a side effect of using gl_linear?.

Heres the frag but it just passes through the color which gets sent to the next pass as an input.

uniform sampler2D ColorTexture;
uniform vec2 buffer_res;

vec2 texel = 1.0 / buffer_res;
vec2 texCoord = gl_TexCoord[0].xy;

void main() {
// with this the offset pushes out from the center rather than off to the top right corner
// but is still getting offset
texCoord += vec2(0.5, 0.5) * texel;

gl_FragColor.rgb = textureLod(bgl_RenderedTexture, texCoord, 0).rgb;
}



The images are crops from 1024x1024

##### Share on other sites

AFAIK, you're fighting a losing battle trying to get pixel perfect results with GL_LINEAR in OpenGL.

DirectX9 guaranteed you could do it by rendering at the right size with a half-pixel offset, but I think with OpenGL you just have to avoid bi-linear filtering.

Note, I'm not 100% confident in that assertion, so very happy to be corrected.

##### Share on other sites
Try this.

vec2 res = textureSize(bgl_RenderedTexture, 0);
texCoord = texCoord * (res / (res + 1.0)) + (0.5 / res);
Untested!

##### Share on other sites

How do you set up your vertex coordinates, your texture coordinates, your modelviewprojection matrix? In any case, interpolation free rendering using GL_LINEAR is definitely possible.

##### Share on other sites

Shouldnt the offscreen buffer match the main exactly pixel for pixel if its not being resized
Yep, assuming your geometry is correct. What do your vertices look like?

Note, I'm not 100% confident in that assertion, so very happy to be corrected.
OpenGL and D3D10+ should have no problem with this.
D3D9 uses a stupid coordinate system that requires a half-pixel offset to do this correctly.

##### Share on other sites

If your goal is just to make a copy, why not use GL_NEAREST?

L. Spiro

##### Share on other sites

If your goal is just to make a copy, why not use GL_NEAREST?

L. Spiro

While GL_NEAREST might theoretically be faster, there's nothing wrong with trying to get it right with GL_LINEAR first. GL_NEAREST might hide a scaling mistake which could also show up with GL_NEAREST for some target sizes. With GL_LINEAR it will show up as slight blurriness for all target sizes.

##### Share on other sites

Thanks for the replys guys. Seems I was doing a number of things poorly, one being how I was dividing my fbos down from my target res, im dividing and rounding now instead of div and flooring, they stay pretty square now at lower mips.

The other problem was with the fbo getting offset by 1 pixel towards the top right corner even if the res matched the main buffer.

Using this for the coords in my fbo frags when upsampling/downsampling stopped them getting offset.

uniform ivec2 buffer_res;
ivec2 intCoord = ivec2(gl_FragCoord.xy);
vec2 texCoord = vec2(intCoord + 0.5) / buffer_res;


Wouldn't surprise me its not completely bang on still need todo more checking I think.

If your goal is just to make a copy, why not use GL_NEAREST?

L. Spiro

Well I was doing this for a bloom shader and im heart set on making use of the linearly sampled gaussian blur trick to get some free taps which requires the use of gl_linear. But yeah for a straight full res copy I think gl_nearest would be best.

@Hodgman Yeah I originally thought the half pixel offset thing was the battle I was fighting till I found its a d3d9 thing.

before and now