lighting

OpenGL normals misunderstanding?

狂风中的少年 提交于 2019-12-12 03:55:42
问题 I'm trying to get my lighting to work in OpenGL, using LWJGL as an implementation library. The problem I think I'm having, is that I don't set my normals properly and therefore the lighting doesn't work at certain angles. Here is the code for the cube I'm testing on: glBegin(GL_QUADS); glColor3f(r,g,b); glNormal3f(position.x, position.y, position.z - radius - 0.1f); glVertex3f(position.x + radius, position.y + radius, position.z - radius); glVertex3f(position.x + radius, position.y - radius,

Difference between positioned and direct light in C++ OpenGL?

﹥>﹥吖頭↗ 提交于 2019-12-12 03:54:27
问题 I just did a tutorial from videotutorialsrock.com on lighting in C++ OpenGL. I understand ambient light, but don't understand the difference between positioned light and direct light, since the idea and the code of both looked very similar. Here's my code for positioned light: //Add positioned light GLfloat lightColor0[] = {.6, .6, .6, 1}; GLfloat lightPos0[] = {4, 0, 8, 1}; glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0); glLightfv(GL_LIGHT0, GL_POSITION, lightPos0); And for directional light:

Make pixel lighting like terraria and starbound

旧街凉风 提交于 2019-12-12 03:54:19
问题 I'm making a 2D sandbox game like "Terraria" and "Starbound". This is my game The light is filling the whole terrain but i don't want it. I want following: 回答1: You're probably using Directional Lighting, which illuminates the whole terrain equally in the direction you made it. You could use Spot Lights or Point Lights, which will illuminate only the surface you want to. Edit: although using this method, this could take way more resources due to the number of single lights placed throughout

Per vertex pre-computated lighting in DirectX9 using fixed function rendering pipeline

感情迁移 提交于 2019-12-11 14:06:47
问题 I'm making a DirectX 9 C++ application using the fixed function pipeline, given pre-computated lighting for each vertex, (Regardless of normals/etc) how can I apply this to the final image? I'm currently using textured primitives and I'm trying to change colour as a whole (over the entire primitive -- rather than using a gradient) and I have to precalculate lighting because of the the number of lights and the application being designed to get decent framerates even on low-end machines. (IE

GLSL spotlight projection volume

筅森魡賤 提交于 2019-12-10 17:09:35
问题 In my open source project I have setup a deferred rendering pipeline using Qt3D. So far so good, but now I'd like to move forward by adding spotlights projection volume. (e.g. as if there is smoke in the scene) Like this: The fragment shader I'm using is at the end of the question. I've read that for each fragment I should do ray marching from the light position and find the intersections with a cone, but I have no idea how to translate this into GLSL. I can easily add a uniform with the

Deferred Rendering with OpenGL, experiencing heavy pixelization near lit boundaries on surfaces

∥☆過路亽.° 提交于 2019-12-10 10:26:12
问题 Problem Explaination I am currently implementing point lights for a deferred renderer and am having trouble determining where a the heavy pixelization/triangulation that is only noticeable near the borders of lights is coming from. The problem appears to be caused by loss of precision somewhere, but I have been unable to track down the precise source. Normals are an obvious possibility, but I have a classmate who is using directx and is handling his normals in a similar manner with no issues.

Rotate Normals in Shader

社会主义新天地 提交于 2019-12-09 18:24:00
问题 I have a scene with several models with individual positions and rotations. Given normals, the shaders apply simple bidirectional lighting to each pixel. That is my vertex shader. #version 150 in vec3 position; in vec3 normal; in vec2 texcoord; out vec3 f_normal; out vec2 f_texcoord; uniform mat4 model; uniform mat4 view; uniform mat4 proj; void main() { mat4 mvp = proj * view * model; f_normal = normal; f_texcoord = texcoord; gl_Position = mvp * vec4(position, 1.0); } And here is the

SceneKit shadows on wall

青春壹個敷衍的年華 提交于 2019-12-08 04:28:26
问题 I have a cube, a wall and two lightNodes in my SceneKit application and I would like to make the cube throw a shadow onto the wall. My lightNodes are here: let lightNode = SCNNode() lightNode.light = SCNLight() lightNode.light!.type = SCNLightTypeSpot lightNode.position = SCNVector3(x: 0, y: 0, z: 15) lightNode.castsShadow = true scene.rootNode.addChildNode(lightNode) // create and add an ambient light to the scene let ambientLightNode = SCNNode() ambientLightNode.light = SCNLight()

Drawing normals in LWJGL messes with lighting

不问归期 提交于 2019-12-07 23:59:40
问题 My issue is fairly straightforward: Drawing normals in LWJGL causes the light source to only apply to the model until it is manually updated after initialization. Here's the lighting initialization: static Vector3f lightPosition = new Vector3f(-500f, -100f, 500f); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, asFloatBuffer(new float[]{0.05f, 0.05f, 0.05f, 1f})); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, asFloatBuffer(new

Gamma correction doesn't look properly corrected, is this linear?

安稳与你 提交于 2019-12-07 14:21:23
问题 I want to implement gamma correction to my OpenGL lighting, but with gamma correction applied, my results do not seem linear at all. I also found OpenGL: Gamma corrected image doesn't appear linear which is very similar to my issue, but hasn't yet received an answer nor discussed actual diffuse lights. As an illustration, I have the following 4 light colors defined in linear space: glm::vec3 lightColors[] = { glm::vec3(0.25), glm::vec3(0.50), glm::vec3(0.75), glm::vec3(1.00) }; With each