mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Fixed ISS' normals transformation.
This commit is contained in:
@@ -47,10 +47,11 @@ namespace {
|
||||
constexpr const char* ProgramName = "ModelProgram";
|
||||
constexpr const char* KeyGeometry = "Geometry";
|
||||
|
||||
constexpr const std::array<const char*, 11> UniformNames = {
|
||||
constexpr const std::array<const char*, 12> UniformNames = {
|
||||
"opacity", "nLightSources", "lightDirectionsViewSpace", "lightIntensities",
|
||||
"modelViewTransform", "projectionTransform", "performShading", "texture1",
|
||||
"ambientIntensity", "diffuseIntensity", "specularIntensity"
|
||||
"modelViewTransform", "crippedModelViewTransform", "projectionTransform",
|
||||
"performShading", "texture1", "ambientIntensity", "diffuseIntensity",
|
||||
"specularIntensity"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
@@ -380,6 +381,16 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
_uniformCache.modelViewTransform,
|
||||
glm::mat4(modelViewTransform)
|
||||
);
|
||||
|
||||
glm::dmat4 crippedModelViewTransform = glm::transpose(glm::inverse(
|
||||
glm::dmat4(glm::inverse(data.camera.sgctInternal.viewMatrix())) * modelViewTransform
|
||||
));
|
||||
|
||||
_program->setUniform(
|
||||
_uniformCache.crippedModelViewTransform,
|
||||
glm::mat4(crippedModelViewTransform)
|
||||
);
|
||||
|
||||
_program->setUniform(
|
||||
_uniformCache.projectionTransform,
|
||||
data.camera.projectionMatrix()
|
||||
|
||||
@@ -88,8 +88,9 @@ private:
|
||||
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
UniformCache(opacity, nLightSources, lightDirectionsViewSpace, lightIntensities,
|
||||
modelViewTransform, projectionTransform, performShading, texture,
|
||||
ambientIntensity, diffuseIntensity, specularIntensity) _uniformCache;
|
||||
modelViewTransform, crippedModelViewTransform, projectionTransform,
|
||||
performShading, texture, ambientIntensity, diffuseIntensity,
|
||||
specularIntensity) _uniformCache;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
std::vector<std::unique_ptr<LightSource>> _lightSources;
|
||||
|
||||
@@ -37,7 +37,7 @@ out vec4 vs_positionCameraSpace;
|
||||
|
||||
uniform mat4 modelViewTransform;
|
||||
uniform mat4 projectionTransform;
|
||||
|
||||
uniform mat4 crippedModelViewTransform;
|
||||
|
||||
void main() {
|
||||
vs_positionCameraSpace = modelViewTransform * in_position;
|
||||
@@ -48,6 +48,6 @@ void main() {
|
||||
vs_st = in_st;
|
||||
vs_screenSpaceDepth = positionScreenSpace.w;
|
||||
|
||||
// The normal transform should be the transposed inverse of the model transform?
|
||||
vs_normalViewSpace = normalize(mat3(modelViewTransform) * in_normal);
|
||||
//vs_normalViewSpace = normalize(transpose(inverse(mat3(crippedModelViewTransform))) * in_normal);
|
||||
vs_normalViewSpace = normalize(mat3(crippedModelViewTransform) * in_normal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user