git-svn-id: svn://db.shs.com.ru/libs@555 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -3,8 +3,7 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
|
||||||
GLWidget::GLWidget(QWidget *parent) : QWidget(parent)
|
GLWidget::GLWidget(QWidget *parent) : QWidget(parent) {
|
||||||
{
|
|
||||||
view_ = new QGLView();
|
view_ = new QGLView();
|
||||||
view_->setFlag(Qt::FramelessWindowHint);
|
view_->setFlag(Qt::FramelessWindowHint);
|
||||||
container = QWidget::createWindowContainer(view_, this);
|
container = QWidget::createWindowContainer(view_, this);
|
||||||
@@ -18,6 +17,187 @@ GLWidget::GLWidget(QWidget *parent) : QWidget(parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QColor GLWidget::backColor() const {
|
||||||
|
return view_->backColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float GLWidget::lineWidth() const {
|
||||||
|
return view_->lineWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float GLWidget::FOV() const {
|
||||||
|
return view_->FOV();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float GLWidget::depthStart() const {
|
||||||
|
return view_->depthStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float GLWidget::depthEnd() const {
|
||||||
|
return view_->depthEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QColor GLWidget::ambientColor() const {
|
||||||
|
return view_->ambientColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::isLightEnabled() const {
|
||||||
|
return view_->isLightEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::isGrabMouseEnabled() const {
|
||||||
|
return view_->isGrabMouseEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::isMouseRotateEnabled() const {
|
||||||
|
return view_->isMouseRotateEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::isMouseSelectionEnabled() const {
|
||||||
|
return view_->isMouseSelectionEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::isCameraOrbit() const
|
||||||
|
{
|
||||||
|
return view_->isCameraOrbit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::isHoverHaloEnabled() const {
|
||||||
|
return view_->isHoverHaloEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QColor GLWidget::hoverHaloColor() const {
|
||||||
|
return view_->hoverHaloColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float GLWidget::hoverHaloFillAlpha() const {
|
||||||
|
return view_->hoverHaloFillAlpha();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::isSelectionHaloEnabled() const {
|
||||||
|
return view_->isSelectionHaloEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QColor GLWidget::selectionHaloColor() const {
|
||||||
|
return view_->selectionHaloColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float GLWidget::selectionHaloFillAlpha() const {
|
||||||
|
return view_->selectionHaloFillAlpha();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::stop() {
|
||||||
|
return view_->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::start(float freq) {
|
||||||
|
return view_->start(freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setBackColor(const QColor & c) {
|
||||||
|
view_->setBackColor(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setLineWidth(const float & arg) {
|
||||||
|
view_->setLineWidth(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setFOV(const float & arg) {
|
||||||
|
view_->setFOV(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setDepthStart(const float & arg) {
|
||||||
|
view_->setDepthStart(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setDepthEnd(const float & arg) {
|
||||||
|
view_->setDepthEnd(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setAmbientColor(const QColor & arg) {
|
||||||
|
view_->setAmbientColor(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setLightEnabled(const bool & arg) {
|
||||||
|
view_->setLightEnabled(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setGrabMouseEnabled(const bool & arg) {
|
||||||
|
view_->setGrabMouseEnabled(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setMouseRotateEnabled(const bool & arg) {
|
||||||
|
view_->setMouseRotateEnabled(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setMouseSelectionEnabled(const bool & arg) {
|
||||||
|
view_->setMouseSelectionEnabled(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setCameraOrbit(const bool & arg) {
|
||||||
|
view_->setCameraOrbit(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setHoverHaloEnabled(const bool & arg) {
|
||||||
|
view_->setHoverHaloEnabled(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setHoverHaloColor(const QColor & arg) {
|
||||||
|
view_->setHoverHaloColor(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setHoverHaloFillAlpha(const float & arg) {
|
||||||
|
view_->setHoverHaloFillAlpha(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setSelectionHaloEnabled(const bool & arg) {
|
||||||
|
view_->setSelectionHaloEnabled(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setSelectionHaloColor(const QColor & arg) {
|
||||||
|
view_->setSelectionHaloColor(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLWidget::setSelectionHaloFillAlpha(const float & arg) {
|
||||||
|
view_->setSelectionHaloFillAlpha(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLWidget::viewDoubleClicked() {
|
void GLWidget::viewDoubleClicked() {
|
||||||
// qDebug() << "click widget!!";
|
// qDebug() << "click widget!!";
|
||||||
if (view_->windowState() == Qt::WindowFullScreen) {
|
if (view_->windowState() == Qt::WindowFullScreen) {
|
||||||
|
|||||||
@@ -9,11 +9,64 @@ class QGLView;
|
|||||||
class GLWidget : public QWidget
|
class GLWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY (QColor backColor READ backColor WRITE setBackColor)
|
||||||
|
Q_PROPERTY (float lineWidth READ lineWidth WRITE setLineWidth)
|
||||||
|
Q_PROPERTY (float FOV READ FOV WRITE setFOV)
|
||||||
|
Q_PROPERTY (float depthStart READ depthStart WRITE setDepthStart)
|
||||||
|
Q_PROPERTY (float depthEnd READ depthEnd WRITE setDepthEnd)
|
||||||
|
Q_PROPERTY (QColor ambientColor READ ambientColor WRITE setAmbientColor)
|
||||||
|
Q_PROPERTY (bool grabMouse READ isGrabMouseEnabled WRITE setGrabMouseEnabled)
|
||||||
|
Q_PROPERTY (bool mouseRotate READ isMouseRotateEnabled WRITE setMouseRotateEnabled)
|
||||||
|
Q_PROPERTY (bool mouseSelection READ isMouseSelectionEnabled WRITE setMouseSelectionEnabled)
|
||||||
|
Q_PROPERTY (bool cameraOrbit READ isCameraOrbit WRITE setCameraOrbit)
|
||||||
|
Q_PROPERTY (bool hoverHalo READ isHoverHaloEnabled WRITE setHoverHaloEnabled)
|
||||||
|
Q_PROPERTY (QColor hoverHaloColor READ hoverHaloColor WRITE setHoverHaloColor)
|
||||||
|
Q_PROPERTY (float hoverHaloFillAlpha READ hoverHaloFillAlpha WRITE setHoverHaloFillAlpha)
|
||||||
|
Q_PROPERTY (bool selectionHalo READ isSelectionHaloEnabled WRITE setSelectionHaloEnabled)
|
||||||
|
Q_PROPERTY (QColor selectionHaloColor READ selectionHaloColor WRITE setSelectionHaloColor)
|
||||||
|
Q_PROPERTY (float selectionHaloFillAlpha READ selectionHaloFillAlpha WRITE setSelectionHaloFillAlpha)
|
||||||
public:
|
public:
|
||||||
explicit GLWidget(QWidget *parent = nullptr);
|
explicit GLWidget(QWidget *parent = nullptr);
|
||||||
QGLView * view() {return view_;}
|
QGLView * view() {return view_;}
|
||||||
|
|
||||||
|
QColor backColor() const;
|
||||||
|
float lineWidth() const;
|
||||||
|
float FOV() const;
|
||||||
|
float depthStart() const;
|
||||||
|
float depthEnd() const;
|
||||||
|
QColor ambientColor() const;
|
||||||
|
bool isLightEnabled() const;
|
||||||
|
bool isGrabMouseEnabled() const;
|
||||||
|
bool isMouseRotateEnabled() const;
|
||||||
|
bool isMouseSelectionEnabled() const;
|
||||||
|
bool isCameraOrbit() const;
|
||||||
|
bool isHoverHaloEnabled() const;
|
||||||
|
QColor hoverHaloColor() const;
|
||||||
|
float hoverHaloFillAlpha() const;
|
||||||
|
bool isSelectionHaloEnabled() const;
|
||||||
|
QColor selectionHaloColor() const;
|
||||||
|
float selectionHaloFillAlpha() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void stop();
|
||||||
|
void start(float freq = 60.);
|
||||||
|
void setBackColor(const QColor & c);
|
||||||
|
void setLineWidth(const float & arg);
|
||||||
|
void setFOV(const float & arg);
|
||||||
|
void setDepthStart(const float & arg);
|
||||||
|
void setDepthEnd(const float & arg);
|
||||||
|
void setAmbientColor(const QColor & arg);
|
||||||
|
void setLightEnabled(const bool & arg);
|
||||||
|
void setGrabMouseEnabled(const bool & arg);
|
||||||
|
void setMouseRotateEnabled(const bool & arg);
|
||||||
|
void setMouseSelectionEnabled(const bool & arg);
|
||||||
|
void setCameraOrbit(const bool & arg);
|
||||||
|
void setHoverHaloEnabled(const bool & arg);
|
||||||
|
void setHoverHaloColor(const QColor & arg);
|
||||||
|
void setHoverHaloFillAlpha(const float & arg);
|
||||||
|
void setSelectionHaloEnabled(const bool & arg);
|
||||||
|
void setSelectionHaloColor(const QColor & arg);
|
||||||
|
void setSelectionHaloFillAlpha(const float & arg);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void viewDoubleClicked();
|
void viewDoubleClicked();
|
||||||
|
|||||||
@@ -24,12 +24,14 @@ bool QGLViewPlugin::isInitialized() const {
|
|||||||
|
|
||||||
|
|
||||||
QWidget * QGLViewPlugin::createWidget(QWidget * parent) {
|
QWidget * QGLViewPlugin::createWidget(QWidget * parent) {
|
||||||
return new GLWidget(parent);
|
GLWidget * w = new GLWidget(parent);
|
||||||
|
//if (m_initialized) w->start();
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString QGLViewPlugin::name() const {
|
QString QGLViewPlugin::name() const {
|
||||||
return QLatin1String("QGLView");
|
return QLatin1String("GLWidget");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -589,9 +589,9 @@ void QGLView::checkCaps() {
|
|||||||
|
|
||||||
void QGLView::reloadThisShaders() {
|
void QGLView::reloadThisShaders() {
|
||||||
if (!shaders_supported) return;
|
if (!shaders_supported) return;
|
||||||
loadShaders(shader_select, "selection", "shaders");
|
loadShaders(shader_select, "selection", "://shaders");
|
||||||
loadShaders(shader_halo, "selection_halo", "shaders");
|
loadShaders(shader_halo, "selection_halo", "://shaders");
|
||||||
//loadShaders(shader_rope, "rope", "shaders");
|
//loadShaders(shader_rope, "rope", "://shaders");
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGLView::glReleaseTextures(int channels) {
|
void QGLView::glReleaseTextures(int channels) {
|
||||||
|
|||||||
@@ -26,5 +26,51 @@
|
|||||||
<file>icons/edit-copy.png</file>
|
<file>icons/edit-copy.png</file>
|
||||||
<file>icons/edit-paste.png</file>
|
<file>icons/edit-paste.png</file>
|
||||||
<file>icons/qglview.png</file>
|
<file>icons/qglview.png</file>
|
||||||
|
<file>shaders/bloom_0.frag</file>
|
||||||
|
<file>shaders/bloom_1.frag</file>
|
||||||
|
<file>shaders/bloom_pass_0.frag</file>
|
||||||
|
<file>shaders/bloom_pass_0.vert</file>
|
||||||
|
<file>shaders/bloom_pass_1.frag</file>
|
||||||
|
<file>shaders/bloom_pass_1.vert</file>
|
||||||
|
<file>shaders/downscale.frag</file>
|
||||||
|
<file>shaders/downscale.vert</file>
|
||||||
|
<file>shaders/dsl_pass_0.frag</file>
|
||||||
|
<file>shaders/dsl_pass_0.vert</file>
|
||||||
|
<file>shaders/dsl_pass_1.frag</file>
|
||||||
|
<file>shaders/dsl_pass_1.vert</file>
|
||||||
|
<file>shaders/dsl_pass_2.frag</file>
|
||||||
|
<file>shaders/dsl_pass_2.vert</file>
|
||||||
|
<file>shaders/fbo_add.frag</file>
|
||||||
|
<file>shaders/fbo_add.vert</file>
|
||||||
|
<file>shaders/FXAA.frag</file>
|
||||||
|
<file>shaders/FXAA.vert</file>
|
||||||
|
<file>shaders/hdr.frag</file>
|
||||||
|
<file>shaders/hdr.vert</file>
|
||||||
|
<file>shaders/hdr_scale_0.frag</file>
|
||||||
|
<file>shaders/hdr_scale_1.frag</file>
|
||||||
|
<file>shaders/light_models.frag</file>
|
||||||
|
<file>shaders/motion_blur.frag</file>
|
||||||
|
<file>shaders/motion_blur.vert</file>
|
||||||
|
<file>shaders/post.frag</file>
|
||||||
|
<file>shaders/ppl.frag</file>
|
||||||
|
<file>shaders/ppl.vert</file>
|
||||||
|
<file>shaders/selection.frag</file>
|
||||||
|
<file>shaders/selection.vert</file>
|
||||||
|
<file>shaders/selection_halo.frag</file>
|
||||||
|
<file>shaders/selection_halo.vert</file>
|
||||||
|
<file>shaders/shadow.frag</file>
|
||||||
|
<file>shaders/shadow.vert</file>
|
||||||
|
<file>shaders/ssao_blur.frag</file>
|
||||||
|
<file>shaders/ssao_blur.vert</file>
|
||||||
|
<file>shaders/ssao_merge.frag</file>
|
||||||
|
<file>shaders/ssao_merge.vert</file>
|
||||||
|
<file>shaders/ssr.frag</file>
|
||||||
|
<file>shaders/ssr.vert</file>
|
||||||
|
<file>shaders/ssr_blur.frag</file>
|
||||||
|
<file>shaders/ssr_blur.vert</file>
|
||||||
|
<file>shaders/ssr_merge.frag</file>
|
||||||
|
<file>shaders/ssr_merge.vert</file>
|
||||||
|
<file>shaders/dof.frag</file>
|
||||||
|
<file>shaders/dof.vert</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ void RendererDeferredShading::reloadShaders() {
|
|||||||
for (int i = 0; i < shaders.size(); ++i) {
|
for (int i = 0; i < shaders.size(); ++i) {
|
||||||
QOpenGLShaderProgram * p(*(shaders[i].second));
|
QOpenGLShaderProgram * p(*(shaders[i].second));
|
||||||
if (!p) p = new QOpenGLShaderProgram(view.context());
|
if (!p) p = new QOpenGLShaderProgram(view.context());
|
||||||
loadShaders(p, shaders[i].first, "shaders");
|
loadShaders(p, shaders[i].first, "://shaders");
|
||||||
*(shaders[i].second) = p;
|
*(shaders[i].second) = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ RendererSimple::RendererSimple(QGLView * view_): GLRendererBase(view_), fbo(2)
|
|||||||
void RendererSimple::reloadShaders() {
|
void RendererSimple::reloadShaders() {
|
||||||
if (shader_fxaa == 0) {
|
if (shader_fxaa == 0) {
|
||||||
shader_fxaa = new QOpenGLShaderProgram(view.context());
|
shader_fxaa = new QOpenGLShaderProgram(view.context());
|
||||||
loadShaders(shader_fxaa, "FXAA", "shaders");
|
loadShaders(shader_fxaa, "FXAA", "://shaders");
|
||||||
}
|
}
|
||||||
/*if (shader == 0) {
|
/*if (shader == 0) {
|
||||||
shader = new QOpenGLShaderProgram(view.context()); /// WARNING
|
shader = new QOpenGLShaderProgram(view.context()); /// WARNING
|
||||||
|
|||||||
47
qglview/shaders/dof.frag
Normal file
47
qglview/shaders/dof.frag
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#version 150
|
||||||
|
|
||||||
|
uniform float z_near, z_far;
|
||||||
|
uniform sampler2D t0, td;
|
||||||
|
uniform vec2 dt;
|
||||||
|
uniform float radius, focus, diaphragm;
|
||||||
|
|
||||||
|
float w, sum;
|
||||||
|
const float _pe = 2.4e-7;
|
||||||
|
|
||||||
|
vec4 getTexel(vec2 c, float coeff) {
|
||||||
|
vec4 ret = texture(t0, c);
|
||||||
|
float cw = texture(td, c).r;
|
||||||
|
cw = clamp(1. - abs(cw - w) * 1000, 0., 1.) * coeff;
|
||||||
|
sum += cw;
|
||||||
|
return ret * cw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec2 tc = qgl_FragTexture.xy;
|
||||||
|
vec4 scol = texture(t0, tc);
|
||||||
|
w = texture(td, tc).r;
|
||||||
|
float z = w + w - 1;
|
||||||
|
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
|
||||||
|
z = 1./(z + 1);
|
||||||
|
float cf = 1./(focus + 1);
|
||||||
|
float factor = clamp(abs(z - cf) * diaphragm, 0, 100);
|
||||||
|
factor = 1. - 1. / (factor + 1.);
|
||||||
|
factor *= factor;
|
||||||
|
factor *= factor;
|
||||||
|
//factor *= factor;
|
||||||
|
factor *= radius;
|
||||||
|
vec2 cdt = factor * dt;
|
||||||
|
sum = 1.;
|
||||||
|
scol += getTexel(tc + (cdt * 1), 2.5);
|
||||||
|
scol += getTexel(tc + (cdt * 2), 2.0);
|
||||||
|
scol += getTexel(tc + (cdt * 3), 1.5);
|
||||||
|
scol += getTexel(tc + (cdt * 4), 1.0);
|
||||||
|
scol += getTexel(tc + (cdt * 5), 0.5);
|
||||||
|
scol += getTexel(tc + (cdt * -1), 2.5);
|
||||||
|
scol += getTexel(tc + (cdt * -2), 2.0);
|
||||||
|
scol += getTexel(tc + (cdt * -3), 1.5);
|
||||||
|
scol += getTexel(tc + (cdt * -4), 1.0);
|
||||||
|
scol += getTexel(tc + (cdt * -5), 0.5);
|
||||||
|
scol /= sum;
|
||||||
|
qgl_FragData[0].rgba = scol;
|
||||||
|
}
|
||||||
6
qglview/shaders/dof.vert
Normal file
6
qglview/shaders/dof.vert
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#version 150
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
qgl_FragTexture = qgl_Texture;
|
||||||
|
gl_Position = qgl_ftransform();
|
||||||
|
}
|
||||||
@@ -22,9 +22,11 @@ void main(void) {
|
|||||||
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
||||||
|
|
||||||
vec3 n, dn, bn;
|
vec3 n, dn, bn;
|
||||||
dn = (texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.)) * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
|
dn = texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.);
|
||||||
|
dn = dn * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
|
||||||
dn.y = -dn.y;
|
dn.y = -dn.y;
|
||||||
dn = TBN * dn;
|
dn = TBN * dn;
|
||||||
|
//dn.z = 0;
|
||||||
n = normalize(qgl_NormalMatrix * (normal + dn));
|
n = normalize(qgl_NormalMatrix * (normal + dn));
|
||||||
bn = normalize(qgl_NormalMatrix * binormal);
|
bn = normalize(qgl_NormalMatrix * binormal);
|
||||||
//n = dn;
|
//n = dn;
|
||||||
|
|||||||
@@ -34,57 +34,55 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
|||||||
ldist = length(ldir);
|
ldist = length(ldir);
|
||||||
ldir = normalize(ldir);
|
ldir = normalize(ldir);
|
||||||
halfV = normalize(ldir + v);
|
halfV = normalize(ldir + v);
|
||||||
NdotL = max(dot(n, ldir), 0.);
|
NdotL = max(dot(n, ldir), 0.0001);
|
||||||
NdotH = max(dot(n, halfV), 0.);
|
NdotH = max(dot(n, halfV), 0.0001);
|
||||||
spot = step(0., NdotL) * qgl_Light[index].intensity;
|
spot = step(0., NdotL) * qgl_Light[index].intensity;
|
||||||
if (NdotL > 0.) {
|
if (qgl_Light[index].endAngle <= 90.) {
|
||||||
if (qgl_Light[index].endAngle <= 90.) {
|
float scos = max(dot(-ldir, qgl_Light[index].direction.xyz), 0.);
|
||||||
float scos = max(dot(-ldir, qgl_Light[index].direction.xyz), 0.);
|
spot *= scos * step(qgl_Light[index].endAngleCos, scos);
|
||||||
spot *= scos * step(qgl_Light[index].endAngleCos, scos);
|
spot *= smoothstep(qgl_Light[index].endAngleCos, qgl_Light[index].startAngleCos, scos);
|
||||||
spot *= smoothstep(qgl_Light[index].endAngleCos, qgl_Light[index].startAngleCos, scos);
|
lwdir = mat3(mat_viewi) * qgl_Light[index].direction.xyz;
|
||||||
lwdir = mat3(mat_viewi) * qgl_Light[index].direction.xyz;
|
//bn = normalize(cross(lwdir, vec3(1, 0, 0)));
|
||||||
//bn = normalize(cross(lwdir, vec3(1, 0, 0)));
|
//bn2 = normalize(cross(lwdir, bn));
|
||||||
//bn2 = normalize(cross(lwdir, bn));
|
float ds = ldist/200.;//max(abs(sdist) / 5000, 0.02);
|
||||||
float ds = ldist/200.;//max(abs(sdist) / 5000, 0.02);
|
//spot *= clamp(1. - sdist, 0, 1);
|
||||||
//spot *= clamp(1. - sdist, 0, 1);
|
vds = ds * bn.xyz;
|
||||||
vds = ds * bn.xyz;
|
vds2 = ds * bn2.xyz;
|
||||||
vds2 = ds * bn2.xyz;
|
float shadow = getShadow(index, pos.xyz, vec3(0)) * 3. +
|
||||||
float shadow = getShadow(index, pos.xyz, vec3(0)) * 3. +
|
getShadow(index, pos.xyz, vds ) * 2. +
|
||||||
getShadow(index, pos.xyz, vds ) * 2. +
|
getShadow(index, pos.xyz, - vds ) * 2. +
|
||||||
getShadow(index, pos.xyz, - vds ) * 2. +
|
getShadow(index, pos.xyz, - vds2 ) * 2. +
|
||||||
getShadow(index, pos.xyz, - vds2 ) * 2. +
|
getShadow(index, pos.xyz, + vds2 ) * 2. +
|
||||||
getShadow(index, pos.xyz, + vds2 ) * 2. +
|
getShadow(index, pos.xyz, vds - vds2 ) * 1.5 +
|
||||||
getShadow(index, pos.xyz, vds - vds2 ) * 1.5 +
|
getShadow(index, pos.xyz, vds + vds2 ) * 1.5 +
|
||||||
getShadow(index, pos.xyz, vds + vds2 ) * 1.5 +
|
getShadow(index, pos.xyz, - vds - vds2 ) * 1.5 +
|
||||||
getShadow(index, pos.xyz, - vds - vds2 ) * 1.5 +
|
getShadow(index, pos.xyz, - vds + vds2 ) * 1.5 +
|
||||||
getShadow(index, pos.xyz, - vds + vds2 ) * 1.5 +
|
getShadow(index, pos.xyz, vds + vds ) +
|
||||||
getShadow(index, pos.xyz, vds + vds ) +
|
getShadow(index, pos.xyz, - vds - vds ) +
|
||||||
getShadow(index, pos.xyz, - vds - vds ) +
|
getShadow(index, pos.xyz, - vds2 - vds2) +
|
||||||
getShadow(index, pos.xyz, - vds2 - vds2) +
|
getShadow(index, pos.xyz, + vds2 + vds2) +
|
||||||
getShadow(index, pos.xyz, + vds2 + vds2) +
|
getShadow(index, pos.xyz, vds + vds - vds2 ) +
|
||||||
getShadow(index, pos.xyz, vds + vds - vds2 ) +
|
getShadow(index, pos.xyz, - vds - vds - vds2 ) +
|
||||||
getShadow(index, pos.xyz, - vds - vds - vds2 ) +
|
getShadow(index, pos.xyz, vds + vds + vds2 ) +
|
||||||
getShadow(index, pos.xyz, vds + vds + vds2 ) +
|
getShadow(index, pos.xyz, - vds - vds + vds2 ) +
|
||||||
getShadow(index, pos.xyz, - vds - vds + vds2 ) +
|
getShadow(index, pos.xyz, vds - vds2 - vds2) +
|
||||||
getShadow(index, pos.xyz, vds - vds2 - vds2) +
|
getShadow(index, pos.xyz, vds + vds2 + vds2) +
|
||||||
getShadow(index, pos.xyz, vds + vds2 + vds2) +
|
getShadow(index, pos.xyz, - vds - vds2 - vds2) +
|
||||||
getShadow(index, pos.xyz, - vds - vds2 - vds2) +
|
getShadow(index, pos.xyz, - vds + vds2 + vds2);
|
||||||
getShadow(index, pos.xyz, - vds + vds2 + vds2);
|
spot *= mix(1., shadow / 29., shadow_on);
|
||||||
spot *= mix(1., shadow / 29., shadow_on);
|
|
||||||
}
|
|
||||||
spot /= (qgl_Light[index].constantAttenuation + ldist * (qgl_Light[index].linearAttenuation + ldist * qgl_Light[index].quadraticAttenuation));
|
|
||||||
///li += spot * gl_LightSource[index].diffuse.rgb * light_diffuse(0, ldir, n);
|
|
||||||
//si += spot * qgl_Light[index].color.rgb * sh_mul * light_specular(0, ldir, n, halfV, v, sh_pow);
|
|
||||||
float NdotLs = NdotL*NdotL;
|
|
||||||
float NdotHs = NdotH*NdotH;
|
|
||||||
float ndlc = (1. - NdotLs) / NdotLs;
|
|
||||||
float der = NdotLs * (sh_mul + ndlc);
|
|
||||||
diff = 2. / (1. + sqrt(1. + (1. - sh_mul) * ndlc));
|
|
||||||
li += spot * qgl_Light[index].color.rgb * diff;// * light_diffuse(0, ldir, n);
|
|
||||||
ndlc = (1. - NdotHs) / NdotHs;
|
|
||||||
der = NdotHs * (sh_mul + ndlc);
|
|
||||||
si += spot * qgl_Light[index].color.rgb * (sh_mul / (der*der) / 3.1416);
|
|
||||||
}
|
}
|
||||||
|
spot /= (qgl_Light[index].constantAttenuation + ldist * (qgl_Light[index].linearAttenuation + ldist * qgl_Light[index].quadraticAttenuation));
|
||||||
|
///li += spot * gl_LightSource[index].diffuse.rgb * light_diffuse(0, ldir, n);
|
||||||
|
//si += spot * qgl_Light[index].color.rgb * sh_mul * light_specular(0, ldir, n, halfV, v, sh_pow);
|
||||||
|
float NdotLs = NdotL*NdotL;
|
||||||
|
float NdotHs = NdotH*NdotH;
|
||||||
|
float ndlc = (1. - NdotLs) / NdotLs;
|
||||||
|
float der = NdotLs * (sh_mul + ndlc);
|
||||||
|
diff = 2. / (1. + sqrt(1. + (1. - sh_mul) * ndlc));
|
||||||
|
li += spot * qgl_Light[index].color.rgb * diff;// * light_diffuse(0, ldir, n);
|
||||||
|
ndlc = (1. - NdotHs) / NdotHs;
|
||||||
|
der = NdotHs * (sh_mul + ndlc);
|
||||||
|
si += spot * qgl_Light[index].color.rgb * (sh_mul / (der*der) / 3.1416);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ void main(void) {
|
|||||||
}
|
}
|
||||||
if (acc_fog)
|
if (acc_fog)
|
||||||
color.rgb = mix(color.rgb, gl_Fog.color.rgb, fogCoord);
|
color.rgb = mix(color.rgb, gl_Fog.color.rgb, fogCoord);
|
||||||
|
color.r = 250;
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
//gl_FragColor.rgb = mix(ldir, texture2D(t2, sp).rgb, 1. - alpha);
|
//gl_FragColor.rgb = mix(ldir, texture2D(t2, sp).rgb, 1. - alpha);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ void main(void) {
|
|||||||
vec4 ds3 = abs(texelFetchOffset(t0, tc, 0, ivec2(0, 1)) - selected);
|
vec4 ds3 = abs(texelFetchOffset(t0, tc, 0, ivec2(0, 1)) - selected);
|
||||||
float d0 = dot(ds0, vec4(1., 1., 1., 1.)), d1 = dot(ds1, vec4(1., 1., 1., 1.)), d2 = dot(ds2, vec4(1., 1., 1., 1.)), d3 = dot(ds3, vec4(1., 1., 1., 1.));
|
float d0 = dot(ds0, vec4(1., 1., 1., 1.)), d1 = dot(ds1, vec4(1., 1., 1., 1.)), d2 = dot(ds2, vec4(1., 1., 1., 1.)), d3 = dot(ds3, vec4(1., 1., 1., 1.));
|
||||||
float vs = step(1e-6, d0 + d1 + d2 + d3);
|
float vs = step(1e-6, d0 + d1 + d2 + d3);
|
||||||
float vm = step(1e-3, (d0 * 255.) * (d1 * 255.) * (d2 * 255.) * (d3 * 255.));
|
float vm = step(1e-3, (d0 * 25.) * (d1 * 25.) * (d2 * 255.) * (d3 * 255.));
|
||||||
float v = mix(vs - vm, vs - vm - vm + 1, fill);
|
float v = mix(vs - vm, vs - vm - vm + 1, fill);
|
||||||
//qgl_FragData[0] = vec4(1,0,0,0.5);//vec4(color.rgb, v * color.a);
|
//qgl_FragData[0] = vec4(1,0,0,0.5);//vec4(color.rgb, v * color.a);
|
||||||
qgl_FragData[0] = vec4(color.rgb, v * color.a);
|
qgl_FragData[0] = vec4(color.bgr, v * color.a);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
#version 200
|
|
||||||
|
|
||||||
//in vec3 src_normal, normal, et;
|
|
||||||
in vec3 wpos;
|
|
||||||
|
|
||||||
void main(void) {
|
|
||||||
//vec2 tc = gl_TexCoord[0].xy;
|
|
||||||
gl_FragColor.xyz = wpos * 1E+6;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#version 300 core
|
|
||||||
|
|
||||||
layout(triangles, invocations = 1) in;
|
|
||||||
|
|
||||||
//in vec3 normal[];
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
for (int i = 0; i < gl_in.length(); i++ ) {
|
|
||||||
gl_Position = gl_in[i].gl_Position;
|
|
||||||
EmitVertex();
|
|
||||||
}
|
|
||||||
EndPrimitive();
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#version 300 core
|
|
||||||
|
|
||||||
//in vec3 src_normal, normal, et;
|
|
||||||
out vec3 wpos;
|
|
||||||
|
|
||||||
void main(void) {
|
|
||||||
//vec2 tc = gl_TexCoord[0].xy;
|
|
||||||
wpos = gl_Vertex.xyz;
|
|
||||||
//gl_TexCoord[0] = gl_MultiTexCoord0;
|
|
||||||
gl_Position = ftransform();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user