0

I am trying to build a single room (first person) that you can walk around in python using opengl.

What I have so far is basically a subtle modification of the python code at the bottom of this pageI would like to place several focal light sources in the room and render the walls from images. Doing so directly didn't work because, as I understand from here, poor tesselation hurts lighting.

To remedy this issue, I thus want to subdivide the walls of my room (currently two triangles) into many more small triangles. What I am looking for is an algorithm that will further subdivide the triangles currently making up the walls of my rooms, telling me where the edges of the smaller triangles are as well as how to offset the texture. I assume this algorithm exists but am new to this kind of programming so don't know where to start,

user3235916
  • 604
  • 7
  • 22
  • 3
    You do not need to do that anymore ... using GLSL shaders will eliminate the need to have over-tessellated meshes (which hurt performance). As the shaders can compute lighting on per fragment(pixel) basis instead of per vertex ... If you still want to do this simple geometry shader can split your triangle into smaller ones up to some limit ... without any change in your CPU side code – Spektre Feb 16 '20 at 08:31
  • Having had a quick look at GLSL shaders it seems to be significantly more complicated than simply turning them on and off. or am I mistaken? Do I apply this as something like "glShadeModel(GL_SMOOTH)" before drawing a polygon or is this something entirely different? Sorry for probably very naive question but am very new to this... – user3235916 Feb 16 '20 at 10:28
  • take a look at this [complete GL+GLSL+VAO/VBO C++ example](https://stackoverflow.com/a/31913542/2521214) you just load/compile/link once and then `glUseProgram(id)` before the rendering ... glBeging/glEnd or glDraw... You can combine old api and GLSL in compatibility mode and older versions ... the new api (core profile) requires VAO/VBO. Not coding in Python but there is sure some shader package enabling you do just that ... – Spektre Feb 16 '20 at 11:02
  • in a nutshell what you want is to overide fragment shader. That one is called for each rendered "pixel" of the scene knowing its position in world, screen, texture and outputting color and depth ... So you need to pass additional info into it like where the lights are etc ... for that you use uniform variables ... – Spektre Feb 16 '20 at 11:25

0 Answers0