'Black lighting' problem with procedural texture - OpenGL related?
in
Core Library Questions
•
11 months ago
Hi
I posted a question a week or so ago about Gouraud shading which (thanks to help from amonon.owed) was happily resolved. I've now run into some weird lighting issues when applying a texture which I'm generating procedurally at runtime. I've posted 2 screengrabs here showing how things should look and how they end up looking...
http://sdrv.ms/Z5Ljdh
Basically I'm reading in a low res heightmap in order to generate height values for my mountain model. I'm then recursively subdividing the vertex values in order to generate higher resolution vertex normals in order to calculate angles to the vertical which allows me to determine snow distribution before using this to create the higher res texture stored as a PImage. I'm then applying this texture to the lower res geometry, together stored as a retained mode object.
Here's the behaviour I see:
If I don't subdivide the basic height array values at all in order to generate the texture then everything is fine, albeit with a blocky texture
As soon as I apply any level of subdivision I start to see this blocky black error in the lighting of the model.
The black area creeps over the image based on viewing angle and can vary from being invisible (the firstscreenshot), through partial (the second) to completely covering the model.
The error appears with custom settings for both point and directional lights and the default 'lights()' setting. It doesn't appear if I specify no lights or just an ambient value.
I don't think its a UV mapping issue as my texture is appearing correctly as I'd expect over the model. I don't think it's a geometry issue as it works just fine with a low res texture and I don't think its an error in my lighting set up as it appears with lights() too. All told it's got me a bit stumped!
So does anyone recognise this visual glitch? It looks like some issue with the P3D renderer but I've been wrong on that one before so I'm hoping someone has some ideas that might point me in the right direction of a resolution. I'd post my source code but, as you can appreciate from the above, its fairly lengthy so thought I'd start with a description.
Really hope someone can help with this one, I'd hate not to be able to use my lovely procedural textures!
Thanks
Matt
I posted a question a week or so ago about Gouraud shading which (thanks to help from amonon.owed) was happily resolved. I've now run into some weird lighting issues when applying a texture which I'm generating procedurally at runtime. I've posted 2 screengrabs here showing how things should look and how they end up looking...
http://sdrv.ms/Z5Ljdh
Basically I'm reading in a low res heightmap in order to generate height values for my mountain model. I'm then recursively subdividing the vertex values in order to generate higher resolution vertex normals in order to calculate angles to the vertical which allows me to determine snow distribution before using this to create the higher res texture stored as a PImage. I'm then applying this texture to the lower res geometry, together stored as a retained mode object.
Here's the behaviour I see:
If I don't subdivide the basic height array values at all in order to generate the texture then everything is fine, albeit with a blocky texture
As soon as I apply any level of subdivision I start to see this blocky black error in the lighting of the model.
The black area creeps over the image based on viewing angle and can vary from being invisible (the firstscreenshot), through partial (the second) to completely covering the model.
The error appears with custom settings for both point and directional lights and the default 'lights()' setting. It doesn't appear if I specify no lights or just an ambient value.
I don't think its a UV mapping issue as my texture is appearing correctly as I'd expect over the model. I don't think it's a geometry issue as it works just fine with a low res texture and I don't think its an error in my lighting set up as it appears with lights() too. All told it's got me a bit stumped!
So does anyone recognise this visual glitch? It looks like some issue with the P3D renderer but I've been wrong on that one before so I'm hoping someone has some ideas that might point me in the right direction of a resolution. I'd post my source code but, as you can appreciate from the above, its fairly lengthy so thought I'd start with a description.
Really hope someone can help with this one, I'd hate not to be able to use my lovely procedural textures!
Thanks
Matt
1