question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OrthographicCamera and GLSL rendering issue

See original GitHub issue
Description of the problem

When generating a square mesh (using ShapeGeometry) with a ShaderMaterial (barebones GLSL shader) in a scene with an OrthographicCamera it is neither at the right origin nor the right scale. This is not the case using any other material.

https://jsfiddle.net/h3m951x6/1/

Three.js version
  • [ x] r116
Browser
  • All of them
OS
  • All of them

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sciecodecommented, May 13, 2020

The generated geometry is not centered, so it won’t appear centered eitherway. You are assigning the vertex position in object space directly to gl_Position, so the object doesn’t follow the rendering pipeline and it won’t be based on the camera’s configuration or world coordinates.

This is not an issue with Three.js, I suggest taking a look at the examples and/or opening a thread on the Three.js Discourse Forum for help.

1reaction
olgageletinacommented, May 13, 2020

Thanks @sciecode .

I did look at examples my OrthographicCamera should be in line with a top left origin of my canvas as documented here and I set the vertex position in object space as demonstrated here line 22.

There was nothing in my post to suggest that the geometry needs to be centered – its origin needs to be in line with my canvas coordinates. I’ll open up a thread on the forum. In the future, I’d encourage you to heed your own advice by taking a look at some examples.

@mrdoob thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Texture is rendering as white at some specific orthographic camera ...
Hello! Im having a curious problem with my textures that a searched literally in all related topics and can't solve by myself. Im...
Read more >
LibGDX Orthographic camera not rendering at certain angles
The camera only renders elements between the near and far planes. OpenGL near and far planes. The default values are 0 (near) and...
Read more >
[Solved] OpenGL shows nothing - LWJGL Forum
I have a problem while trying to render a triangle with OpenGL using LWJGL. ... a simple orthographic camera at the position (0|0|1)....
Read more >
A Simple Method to Render an Image | HackLAB - Geeks3D
To render an image, we need an orthographic camera, a texture GPU program, a quad and the image (a texture). Here is how...
Read more >
Creating an Orthographic Camera | Game Engine series
Creating an Orthographic Camera | Game Engine series. 34K views 3 years ago ... GRASS RENDERING in OpenGL // Code Review. The Cherno....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found