mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
adding different shaders for transparent for simpel
This commit is contained in:
parent
a882beb2fd
commit
b18d82bd19
5 changed files with 56 additions and 20 deletions
|
@ -31,6 +31,8 @@
|
||||||
#include "simple_vert.h"
|
#include "simple_vert.h"
|
||||||
#include "simple_textured_frag.h"
|
#include "simple_textured_frag.h"
|
||||||
#include "simple_textured_unlit_frag.h"
|
#include "simple_textured_unlit_frag.h"
|
||||||
|
#include "simple_transparent_textured_frag.h"
|
||||||
|
#include "simple_transparent_textured_unlit_frag.h"
|
||||||
|
|
||||||
#include "model_frag.h"
|
#include "model_frag.h"
|
||||||
#include "model_unlit_frag.h"
|
#include "model_unlit_frag.h"
|
||||||
|
@ -152,6 +154,8 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
||||||
// Pixel shaders
|
// Pixel shaders
|
||||||
auto simplePixel = gpu::Shader::createPixel(std::string(simple_textured_frag));
|
auto simplePixel = gpu::Shader::createPixel(std::string(simple_textured_frag));
|
||||||
auto simpleUnlitPixel = gpu::Shader::createPixel(std::string(simple_textured_unlit_frag));
|
auto simpleUnlitPixel = gpu::Shader::createPixel(std::string(simple_textured_unlit_frag));
|
||||||
|
auto simpleTranslucentPixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_frag));
|
||||||
|
auto simpleTranslucentUnlitPixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_unlit_frag));
|
||||||
auto modelPixel = gpu::Shader::createPixel(std::string(model_frag));
|
auto modelPixel = gpu::Shader::createPixel(std::string(model_frag));
|
||||||
auto modelUnlitPixel = gpu::Shader::createPixel(std::string(model_unlit_frag));
|
auto modelUnlitPixel = gpu::Shader::createPixel(std::string(model_unlit_frag));
|
||||||
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag));
|
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag));
|
||||||
|
@ -196,13 +200,13 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
||||||
modelVertex, modelTranslucentPixel);
|
modelVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTranslucent(),
|
Key::Builder().withTranslucent(),
|
||||||
simpleVertex, simplePixel);
|
simpleVertex, simpleTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withMaterial().withTranslucent().withUnlit(),
|
Key::Builder().withMaterial().withTranslucent().withUnlit(),
|
||||||
modelVertex, modelTranslucentUnlitPixel);
|
modelVertex, modelTranslucentUnlitPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTranslucent().withUnlit(),
|
Key::Builder().withTranslucent().withUnlit(),
|
||||||
simpleVertex, simpleUnlitPixel);
|
simpleVertex, simpleTranslucentUnlitPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withMaterial().withTranslucent().withTangents(),
|
Key::Builder().withMaterial().withTranslucent().withTangents(),
|
||||||
modelNormalMapVertex, modelTranslucentPixel);
|
modelNormalMapVertex, modelTranslucentPixel);
|
||||||
|
|
|
@ -26,15 +26,17 @@ in vec2 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 texel = texture(originalTexture, _texCoord0);
|
vec4 texel = texture(originalTexture, _texCoord0);
|
||||||
|
float colorAlpha = _color.a;
|
||||||
if (_color.a <= 0.0) {
|
if (_color.a <= 0.0) {
|
||||||
texel = colorToLinearRGBA(texel);
|
texel = colorToLinearRGBA(texel);
|
||||||
|
colorAlpha = -_color.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float ALPHA_THRESHOLD = 0.999;
|
const float ALPHA_THRESHOLD = 0.999;
|
||||||
if (_color.a * texel.a < ALPHA_THRESHOLD) {
|
if (colorAlpha * texel.a < ALPHA_THRESHOLD) {
|
||||||
packDeferredFragmentTranslucent(
|
packDeferredFragmentTranslucent(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
_color.a * texel.a,
|
colorAlpha * texel.a,
|
||||||
_color.rgb * texel.rgb,
|
_color.rgb * texel.rgb,
|
||||||
DEFAULT_FRESNEL,
|
DEFAULT_FRESNEL,
|
||||||
DEFAULT_ROUGHNESS);
|
DEFAULT_ROUGHNESS);
|
||||||
|
|
|
@ -25,28 +25,20 @@ in vec2 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||||
|
float colorAlpha = _color.a;
|
||||||
if (_color.a <= 0.0) {
|
if (_color.a <= 0.0) {
|
||||||
texel = colorToLinearRGBA(texel);
|
texel = colorToLinearRGBA(texel);
|
||||||
|
colorAlpha = -_color.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float ALPHA_THRESHOLD = 0.999;
|
const float ALPHA_THRESHOLD = 0.999;
|
||||||
if (_color.a * texel.a < ALPHA_THRESHOLD) {
|
if (colorAlpha * texel.a < ALPHA_THRESHOLD) {
|
||||||
|
packDeferredFragmentTranslucent(
|
||||||
_fragColor0 = vec4(_color.rgb * texel.rgb, _color.a * texel.a);
|
|
||||||
|
|
||||||
if (_color.a * texel.a <= 0.0) {
|
|
||||||
_fragColor0 = vec4(_color.rgb * texel.rgb, _color.a * texel.a);
|
|
||||||
//discard;
|
|
||||||
} else {
|
|
||||||
_fragColor0 = vec4(_color.rgb * texel.rgb, _color.a * texel.a);
|
|
||||||
}
|
|
||||||
// _fragColor0 = vec4(albedo.rgb, alpha);
|
|
||||||
/* packDeferredFragmentTranslucent(
|
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
_color.a * texel.a,
|
colorAlpha * texel.a,
|
||||||
_color.rgb * texel.rgb,
|
_color.rgb * texel.rgb,
|
||||||
DEFAULT_FRESNEL,
|
DEFAULT_FRESNEL,
|
||||||
DEFAULT_ROUGHNESS);*/
|
DEFAULT_ROUGHNESS);
|
||||||
} else {
|
} else {
|
||||||
packDeferredFragmentUnlit(
|
packDeferredFragmentUnlit(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
|
|
|
@ -26,10 +26,15 @@ in vec2 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||||
texel = colorToLinearRGBA(texel);
|
float colorAlpha = _color.a;
|
||||||
|
if (_color.a <= 0.0) {
|
||||||
|
texel = colorToLinearRGBA(texel);
|
||||||
|
colorAlpha = -_color.a;
|
||||||
|
}
|
||||||
|
|
||||||
packDeferredFragmentTranslucent(
|
packDeferredFragmentTranslucent(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
_color.a,
|
colorAlpha,
|
||||||
_color.rgb * texel.rgb,
|
_color.rgb * texel.rgb,
|
||||||
DEFAULT_FRESNEL,
|
DEFAULT_FRESNEL,
|
||||||
DEFAULT_ROUGHNESS);
|
DEFAULT_ROUGHNESS);
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// simple_transparent_textured_unlit.slf
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 4/3/17.
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include gpu/Color.slh@>
|
||||||
|
|
||||||
|
// the albedo texture
|
||||||
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
|
// the interpolated normal
|
||||||
|
in vec3 _normal;
|
||||||
|
in vec4 _color;
|
||||||
|
in vec2 _texCoord0;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||||
|
float colorAlpha = _color.a;
|
||||||
|
if (_color.a <= 0.0) {
|
||||||
|
texel = colorToLinearRGBA(texel);
|
||||||
|
colorAlpha = -_color.a;
|
||||||
|
}
|
||||||
|
_fragColor0 = vec4(_color.rgb * texel.rgb, colorAlpha * texel.a);
|
||||||
|
}
|
Loading…
Reference in a new issue