Skip to content

Commit

Permalink
Merge pull request #74 from Lugdunum3D/fix-beta-samples
Browse files Browse the repository at this point in the history
Different things adding functionnalities for the beta samples
  • Loading branch information
saveman71 authored Jul 12, 2017
2 parents bcd8d5a + 3ab2402 commit 31cce9d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 14 deletions.
21 changes: 14 additions & 7 deletions include/lug/Graphics/Render/Light.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ class LUG_GRAPHICS_API Light : public Resource, public DirtyObject {

~Light() = default;

/**
* @brief Gets the light type.
*
* @return The light type.
*/
Type getType() const;

void setType(Type type);
void setColor(const Math::Vec4f& color);
void setDirection(const Math::Vec3f& direction);
Expand All @@ -76,7 +69,21 @@ class LUG_GRAPHICS_API Light : public Resource, public DirtyObject {
void setFalloffAngle(float falloffAngle);
void setFalloffExponent(float falloffExponent);

/**
* @brief Gets the light type.
*
* @return The light type.
*/
Type getType() const;

const Math::Vec4f& getColor() const;
const Math::Vec3f& getDirection() const;
float getConstantAttenuation() const;
float getDistance() const;
float getLinearAttenuation() const;
float getQuadraticAttenuation() const;
float getFalloffAngle() const;
float getFalloffExponent() const;

void getData(Light::Data& lightData, Scene::Node& node);

Expand Down
36 changes: 32 additions & 4 deletions include/lug/Graphics/Render/Light.inl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
inline Light::Type Light::getType() const {
return _type;
}

inline void Light::setType(Type type) {
::lug::Graphics::Render::DirtyObject::setDirty();
_type = type;
Expand Down Expand Up @@ -47,6 +43,38 @@ inline void Light::setFalloffExponent(float falloffExponent) {
_falloffExponent = falloffExponent;
}

inline Light::Type Light::getType() const {
return _type;
}

inline const Math::Vec4f& Light::getColor() const {
return _color;
}

inline const Math::Vec3f& Light::getDirection() const {
return _direction;
}

inline float Light::getConstantAttenuation() const {
return _constantAttenuation;
}

inline float Light::getDistance() const {
return _distance;
}

inline float Light::getLinearAttenuation() const {
return _linearAttenuation;
}

inline float Light::getQuadraticAttenuation() const {
return _quadraticAttenuation;
}

inline float Light::getFalloffAngle() const {
return _falloffAngle;
}

inline float Light::getFalloffExponent() const {
return _falloffExponent;
}
2 changes: 1 addition & 1 deletion resources/shaders/forward/shader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void main() {
// cook-torrance brdf
const float NDF = DistributionGGX(NdotH, roughness); // Normal distribution (Distribution of the microfacets)
const float G = GeometrySchlickGGX(NdotV, NdotL, roughness); // Geometric shadowing term (Microfacets shadowing)
const vec3 F = fresnelSchlick(NdotV, F0); // Fresnel factor (Reflectance depending on angle of incidence)
const vec3 F = fresnelSchlick(NdotH, F0); // Fresnel factor (Reflectance depending on angle of incidence)

const vec3 kD = (vec3(1.0) - F) * (1.0 - metallic);

Expand Down
2 changes: 1 addition & 1 deletion src/lug/Core/FreeMovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void FreeMovement::onFrame(const System::Time& elapsedTime) {


// Capture / Release the mouse cursor
if (_eventSource->isMousePressed(lug::Window::Mouse::Button::Left) && !_hasFocus) {
if (_eventSource->isKeyPressed(lug::Window::Keyboard::Key::C) && !_hasFocus) {
_lastMousePos = _eventSource->getMousePos();
_hasFocus = true;
_eventSource->setMouseCursorVisible(false);
Expand Down
19 changes: 19 additions & 0 deletions src/lug/Graphics/GltfLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,25 @@ static bool createNode(Renderer& renderer, const gltf2::Asset& asset, const gltf
node->attachMeshInstance(mesh);
}

node->setPosition({
gltfNode.translation[0],
gltfNode.translation[1],
gltfNode.translation[2]
}, Node::TransformSpace::Parent);

node->setRotation(Math::Quatf{
gltfNode.rotation[3],
gltfNode.rotation[0],
gltfNode.rotation[1],
gltfNode.rotation[2]
}, Node::TransformSpace::Parent);

node->scale({
gltfNode.scale[0],
gltfNode.scale[1],
gltfNode.scale[2]
});

for (uint32_t nodeIdx : gltfNode.children) {
const gltf2::Node& childrenGltfNode = asset.nodes[nodeIdx];
if (!createNode(renderer, asset, childrenGltfNode, *node)) {
Expand Down
2 changes: 1 addition & 1 deletion thirdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ googlemock:

gltf2-loader:
repository:
tag: c007c437cb435d44506669b8959c7f1682ef2c16
tag: 5c736d11b9c324d85ae44b03479274c33cff37ed

imgui:
repository:
Expand Down

0 comments on commit 31cce9d

Please sign in to comment.