Alina's picture

spot light

Project:The Open Toolkit library
Version:0.9.9-0
Component:Miscellaneous
Category:support request
Priority:critical
Assigned:Alina
Status:closed
Description

I want to have a light similar with a street lamp. Please help. Thanks !


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

It's difficult to tell what the problem is without some code. What are the light parameters?

A screenshot would also help identify the cause of the issue.

One potential problem is that the lighting equations built into OpenGL need relatively well-tesselated geometry to function. For example, if the street consists of only two triangles, the whole street will be lit by the street light, as the equations are only evaluated at the triangle vertices.

Alina's picture

#2

I attach a screen shot. I disable the textures, the light color is red and it is placed inside the lamp. I think I have to use per pixel points lights, but I don't know how.

AttachmentSize
1.PNG112.2 KB
Alina's picture

#3

I attach a new file with the result that I want to obtain. (light only in the selected areas).

AttachmentSize
whatIwant.PNG114.22 KB
the Fiddler's picture

#4

Ok, the screenshot looks definitely wrong. The road receives no light from the lamp, which either means it has incorrect normals or that its tesselation is too low.

Is it possible to increase the tesselation of the road? If not, as far as I know per-pixel lighting is the only solution.

Alina's picture

#5

Hello again ! The road and the building is built in 3D studio Max and each separate object is exported into .txt format(points, polygons, normals, texture coordinates). The road has only 2 polygons in order to have a minimum number of polygons and increase the speed. I'll try per-pixel lighting, but I have any idea how I could do this. I found this tutorial but there are few methods and variables that I can't understand. Have you know another tutorials about per-pixel lighting ? Thanks !

Inertia's picture

#6

I kinda liked typhoon lab's shading language course (5 chapters), if you are looking more for a c&p solution take a look here.

But imho you want a huge point light originating from the lamp, not a spotlight. A spotlight pointing downwards would not illuminate the tree next to the lamp.

the Fiddler's picture

#7

GLSL has an initial learning curve, but the results are worth it once you get it working. Plus, it can simplify OpenGL code a lot, if you code with GLSL in mind.

OpenTK comes with a simple GLSL example that could help you get started: SimpleGLSL.cs.

A quick overview:

  1. Create the vertex and fragment shaders (you don't need to provide a vertex shader for per pixel lighting, but some drivers may complain). This is done in the CreateShaders() method of the SimpleGLSL example.
  2. Call GL.UseProgram(id) to render using your new shader and GL.UseShader(0) to revert back to disable the shader.
  3. Call GL.ActiveTexture and GL.Uniform1 to attach all necessary textures to the shader.
  4. Emit a draw call as usually (VBO, display list or even immediate mode).

In other words, the main change is that you have to add calls to UseProgram, ActiveTexture and Uniform to your drawing code.

the Fiddler's picture

#8

Status:open» closed

Closing issue after a month with no activity.