Point light and surface with coplanar t-junctions

Problems building or running the engine, queries about how to use features etc.
Post Reply
chilly willy
Halfling
Posts: 65
Joined: Tue Jun 02, 2020 4:11 am
x 19

Point light and surface with coplanar t-junctions

Post by chilly willy »

Ogre Version: 1.13
Operating System: macOS Catalina
Render System: GL

I have a model of a room. Due to my particular modeling technique, each wall or floor is made up of multiple co-planar triangles. Not all triangles meet at points (ie there are t-junctions). With a directional light everything looks as expected; each surface is continuous and of a consistent color. However, with a point light located near the walls, there are very distinct discontinuities between each of the pairs of triangles that make up a rectangle of the surfaces. I assumed this was a matter of interpolating between the colors calculated at each of the vertices. Looking at the ShadingMode/ShadeOptions I thought switching from Gouraud to Phong would fix it but it did not help.

Are the discontinuities due to the shading algorithm? Or is it more likely that I have done something wrong with setting up the meshes and scene? If it is the shading, is there an easy fix? Do I need to write a shader that calculates the angles at every pixel?

rpgplayerrobin
Gnoll
Posts: 619
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Point light and surface with coplanar t-junctions

Post by rpgplayerrobin »

Can you post some screenshots of the issue?

The only thing I can think of currently is that it might be fixed (at least somewhat) if you smooth the normals of the entire mesh.
I am not sure what 3D modelling program you are using, but in Maya it is just "Normals->Soften Edge".

chilly willy
Halfling
Posts: 65
Joined: Tue Jun 02, 2020 4:11 am
x 19

Re: Point light and surface with coplanar t-junctions

Post by chilly willy »

Here is a screenshot of the discontinuities. Each wall should be one continuous surface. Although I like the effect on the floor, it should also be one continuous surface as well. You can also see discontinuities in the fireplace. (The facets on the round parts is not the issue.)
Image

The more I think about it, the more it makes sense that linearly interpolating a sinusoidal function from different points along the same edge would result in a mismatch. The Phong shade option should fix that but I now see it says "Not supported on all hardware." in the comments.

I think my two options are writing a pixel shader or dealing with the T-junctions while loading and splitting the edges at the junctions. I would very much appreciate advice on either approach.

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Point light and surface with coplanar t-junctions

Post by sercero »

I recommend that you write a shader, this tutorial is great:
https://learnopengl.com/

rpgplayerrobin
Gnoll
Posts: 619
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Point light and surface with coplanar t-junctions

Post by rpgplayerrobin »

To me, it seems like you are possibly using fixed function pipeline (in which @sercero would be correct) or you are using a shader that only calculates lighting using the vertices and not per pixel.

If you want per-pixel lighting you can alter (or create) the shaders for all your materials in the scene to do that, but if you have no experience with shaders you can possibly use RTSS (https://ogrecave.github.io/ogre/api/1.11/rtss.html) (though I am not sure how to do that as I write all my own shaders).

chilly willy
Halfling
Posts: 65
Joined: Tue Jun 02, 2020 4:11 am
x 19

Re: Point light and surface with coplanar t-junctions

Post by chilly willy »

Thank you guys for pointing me in the right direction. I started looking into shaders, the RTSS, and FFP, and I realized I was using the GL RenderSystem with FFP. All I ended up having to do was switch to the GL 3+ RenderSystem and it automatically started doing per-pixel lighting.
Image

Post Reply