add light and change shader

This commit is contained in:
ayachi3 2022-12-15 11:23:52 +08:00
parent 294cf7efb3
commit df803c8dea
4 changed files with 20 additions and 0 deletions

View File

@ -5,9 +5,11 @@ in vec2 TexCoords;
uniform sampler2D texture_diffuse1;
uniform sampler2D texture_specular1;
uniform vec3 lightColor;
void main()
{
FragColor = texture(texture_specular1, TexCoords);
FragColor = texture(texture_diffuse1, TexCoords);
FragColor = vec4(FragColor * vec4(lightColor,1.0f));
}

View File

@ -0,0 +1,2 @@
#include"lightCaster.h"

View File

@ -1 +1,10 @@
#pragma once
#include"shader.h"
// 发光物不需要纹理所以说需要另外的shader
// 在sceneviewer中被包含
class LightCaster {
public:
LightCaster() {};
};

View File

@ -88,6 +88,13 @@ void SceneViewer::paintGL() {
_shaderProgram.setUniform("view", view);
_shaderProgram.setUniform("projection", projection);
///////////////////////////////////////最终不应该放在这里
_shaderProgram.setUniform("lightColor", 0.0f, 1.0f, 0.0f);
//////////////////////////////////////
for (auto object : _objects) {
object.render(_shaderProgram);
}