mirror of
https://github.com/Linloir/SceneEditor.git
synced 2025-12-17 15:38:11 +08:00
add light and change shader
This commit is contained in:
parent
294cf7efb3
commit
df803c8dea
@ -5,9 +5,11 @@ in vec2 TexCoords;
|
|||||||
|
|
||||||
uniform sampler2D texture_diffuse1;
|
uniform sampler2D texture_diffuse1;
|
||||||
uniform sampler2D texture_specular1;
|
uniform sampler2D texture_specular1;
|
||||||
|
uniform vec3 lightColor;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = texture(texture_specular1, TexCoords);
|
FragColor = texture(texture_specular1, TexCoords);
|
||||||
FragColor = texture(texture_diffuse1, TexCoords);
|
FragColor = texture(texture_diffuse1, TexCoords);
|
||||||
|
FragColor = vec4(FragColor * vec4(lightColor,1.0f));
|
||||||
}
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#include"lightCaster.h"
|
||||||
|
|
||||||
@ -1 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include"shader.h"
|
||||||
|
|
||||||
|
// 发光物不需要纹理,所以说需要另外的shader
|
||||||
|
// 在sceneviewer中被包含
|
||||||
|
class LightCaster {
|
||||||
|
public:
|
||||||
|
LightCaster() {};
|
||||||
|
|
||||||
|
};
|
||||||
@ -87,6 +87,13 @@ void SceneViewer::paintGL() {
|
|||||||
glm::mat4 projection = glm::perspective(glm::radians(_camera.zoomVal()), (float)width() / (float)height(), 0.1f, 100.0f);
|
glm::mat4 projection = glm::perspective(glm::radians(_camera.zoomVal()), (float)width() / (float)height(), 0.1f, 100.0f);
|
||||||
_shaderProgram.setUniform("view", view);
|
_shaderProgram.setUniform("view", view);
|
||||||
_shaderProgram.setUniform("projection", projection);
|
_shaderProgram.setUniform("projection", projection);
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////最终不应该放在这里
|
||||||
|
_shaderProgram.setUniform("lightColor", 0.0f, 1.0f, 0.0f);
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (auto object : _objects) {
|
for (auto object : _objects) {
|
||||||
object.render(_shaderProgram);
|
object.render(_shaderProgram);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user