merged
This commit is contained in:
commit
c06e138b3e
14 changed files with 48 additions and 60 deletions
|
|
@ -1,45 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
|
||||
varying vec3 vertex;
|
||||
varying vec3 normal;
|
||||
|
||||
uniform vec3 materialColor;
|
||||
uniform vec3 lightColor;
|
||||
uniform vec3 lightPosition;
|
||||
|
||||
varying vec3 lightDirection;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 Eye = normalize(-vertex);
|
||||
vec3 Reflected = normalize(reflect( -lightPosition, normal));
|
||||
|
||||
vec3 IAmbient = vec3(0.2f);
|
||||
|
||||
// TODO: add noise texture
|
||||
vec3 IDiffuse = vec3(materialColor) * lightColor * max(dot(normal, lightDirection), 0.0);
|
||||
|
||||
// TODO make instensity/exponent as parameter
|
||||
//vec3 ISpecular = lightColor * 5.0 * pow(max(dot(Reflected, Eye), 0.0), 2.0);
|
||||
vec3 ISpecular = lightColor * pow(max(dot(Reflected, Eye), 0.0), 2.0);
|
||||
|
||||
if (dot(lightDirection, normal) <= 0.0) {
|
||||
ISpecular = vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
// p: point of the fragment on the surface
|
||||
//vec3 v_eye = normalize(pos_eye - pos_space); // point from p to eye
|
||||
//vec3 v_sun = normalize(sun_light_dir); // points from p to the sun
|
||||
|
||||
//float specular = spec_int * pow(
|
||||
// clamp(dot((v_eye + v_sun)/2.0, normal), 0.0, 1.0),
|
||||
// 2.0*specular_exponent);
|
||||
|
||||
//ISpecular = vec3(1.0, 0.0, 0.0) * specular;
|
||||
|
||||
//gl_FragColor = vec4(ISpecular, 1.0);
|
||||
gl_FragColor = vec4((IAmbient + IDiffuse) + ISpecular, 1.0);
|
||||
//gl_FragColor = vec4(0.5+0.5*normal, 1.0);
|
||||
}
|
||||
)raw_string"
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
|
||||
attribute vec3 in_vertex;
|
||||
attribute vec3 in_normal;
|
||||
|
||||
varying vec3 vertex;
|
||||
varying vec3 normal;
|
||||
varying vec3 lightDirection;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform vec3 lightPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
// TODO: this becomes invalid when projection matrices are used
|
||||
vec3 p = (model*vec4(in_vertex, 1.0)).xyz;
|
||||
lightDirection = normalize(lightPosition - p);
|
||||
|
||||
vertex = p.xyz;
|
||||
normal = normalize((model*vec4(in_normal.xyz, 0.0)).xyz);
|
||||
|
||||
gl_Position = vec4(p, 1.0);
|
||||
}
|
||||
)raw_string"
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
varying vec2 vertex;
|
||||
varying vec2 velocity;
|
||||
uniform float maxAge;
|
||||
uniform float time;
|
||||
void main()
|
||||
{
|
||||
//gl_FragColor = vec4(0.5+0.5*vertex.x, 0.5+0.5*vertex.y, 0.0, 1.0);
|
||||
if (length(vertex) > 1.0) {
|
||||
discard;
|
||||
}
|
||||
float decay = time / maxAge;
|
||||
decay = 5.0*decay*decay;
|
||||
// (length(10.0*velocity));
|
||||
gl_FragColor = vec4(1.0/max(1.0, decay), 1.0/max(1.0, 6.0*decay), 0.0, 1.0);
|
||||
}
|
||||
)raw_string"
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
attribute vec2 in_vertex;
|
||||
attribute vec2 in_position;
|
||||
attribute vec2 in_velocity;
|
||||
varying vec2 velocity;
|
||||
varying vec2 vertex;
|
||||
uniform float time;
|
||||
uniform float size;
|
||||
void main()
|
||||
{
|
||||
vec2 p = size*in_vertex;
|
||||
p += log(1.0+time) * in_velocity;
|
||||
p += in_position;
|
||||
gl_Position = vec4(p, 0.0, 1.0);
|
||||
|
||||
vertex = in_vertex;
|
||||
velocity = in_velocity;
|
||||
}
|
||||
)raw_string"
|
||||
|
|
@ -30,17 +30,12 @@ namespace endofthejedi {
|
|||
m_data_kind.resize(m_numParticles);
|
||||
m_data_max_age.resize(m_numParticles);
|
||||
|
||||
std::string vss_particles =
|
||||
#include "particle.vert"
|
||||
;
|
||||
|
||||
std::string fss_particles =
|
||||
#include "particle.frag"
|
||||
;
|
||||
std::string vss_particles = "../data/shader/particle.vert";
|
||||
std::string fss_particles = "../data/shader/particle.frag";
|
||||
|
||||
m_shader.init();
|
||||
m_shader.load(vss_particles.c_str(), GL_VERTEX_SHADER);
|
||||
m_shader.load(fss_particles.c_str(), GL_FRAGMENT_SHADER);
|
||||
m_shader.loadFile(vss_particles, GL_VERTEX_SHADER);
|
||||
m_shader.loadFile(fss_particles, GL_FRAGMENT_SHADER);
|
||||
}
|
||||
|
||||
ParticleBatch::~ParticleBatch()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "polygon_model.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void discardLastGlError()
|
||||
{
|
||||
glGetError();
|
||||
|
|
@ -22,6 +24,7 @@ void checkAndPrintGlError()
|
|||
std::cout<<"glGetAttribLocation() returned error: " << errString << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
namespace endofthejedi {
|
||||
PolygonModel::PolygonModel(const std::string &filename)
|
||||
: m_filename(filename)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <assimp/Importer.hpp> // C++ importer interface
|
||||
#include <assimp/scene.h> // Output data structure
|
||||
|
|
|
|||
|
|
@ -13,34 +13,18 @@ namespace endofthejedi {
|
|||
|
||||
std::cout<<"setup polygon 3d" << std::endl;
|
||||
|
||||
std::string vss_simple =
|
||||
#include "simple.vert"
|
||||
;
|
||||
|
||||
std::string fss_simple =
|
||||
#include "simple.frag"
|
||||
;
|
||||
|
||||
std::string vss_game_objects =
|
||||
#include "gameobjects.vert"
|
||||
;
|
||||
|
||||
std::string fss_game_objects =
|
||||
#include "gameobjects.frag"
|
||||
;
|
||||
|
||||
m_shader.init();
|
||||
|
||||
#if 0
|
||||
(void) vss_simple;
|
||||
(void) fss_simple;
|
||||
m_shader.load(vss_simple.c_str(), GL_VERTEX_SHADER);
|
||||
m_shader.load(fss_simple.c_str(), GL_FRAGMENT_SHADER);
|
||||
std::string vss_simple = "../data/shader/simple.vert";
|
||||
std::string fss_simple = "../data/shader/simple.frag";
|
||||
m_shader.loadFile(vss_simple, GL_VERTEX_SHADER);
|
||||
m_shader.loadFile(fss_simple, GL_FRAGMENT_SHADER);
|
||||
#else
|
||||
(void) vss_game_objects;
|
||||
(void) fss_game_objects;
|
||||
m_shader.load(vss_game_objects.c_str(), GL_VERTEX_SHADER);
|
||||
m_shader.load(fss_game_objects.c_str(), GL_FRAGMENT_SHADER);
|
||||
std::string vss_game_objects = "../data/shader/gameobjects.vert";
|
||||
std::string fss_game_objects = "../data/shader/gameobjects.frag";
|
||||
m_shader.loadFile(vss_game_objects, GL_VERTEX_SHADER);
|
||||
m_shader.loadFile(fss_game_objects, GL_FRAGMENT_SHADER);
|
||||
#endif
|
||||
|
||||
addModel("../data/mesh/small_atomic_bomb.stl", &m_missileModel);
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
varying vec3 vertex;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(0.5+0.5*vertex.xyz, 1.0);
|
||||
}
|
||||
)raw_string"
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
varying vec3 vertex;
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_Vertex;
|
||||
vertex = gl_Position.xyz;
|
||||
}
|
||||
)raw_string"
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
varying vec3 vertex;
|
||||
uniform vec3 color;
|
||||
void main()
|
||||
{
|
||||
//gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
//gl_FragColor = vec4(0.5+0.5*vertex.xyz, 1.0);
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
||||
)raw_string"
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
R"raw_string(
|
||||
#version 120
|
||||
varying vec3 vertex;
|
||||
uniform mat4 model;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
//vec3 p = position + scale*gl_Vertex.xyz;
|
||||
vec3 p = (model*gl_Vertex).xyz;
|
||||
gl_Position = vec4(p, 1.0);
|
||||
vertex = p.xyz;
|
||||
}
|
||||
)raw_string"
|
||||
Loading…
Add table
Add a link
Reference in a new issue