mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:18:24 +02:00
moving polyLineEntity over to core profile
This commit is contained in:
parent
3910cb0d69
commit
d735c85806
4 changed files with 57 additions and 31 deletions
|
@ -11,44 +11,68 @@
|
||||||
<@if not DEFERRED_BUFFER_WRITE_SLH@>
|
<@if not DEFERRED_BUFFER_WRITE_SLH@>
|
||||||
<@def DEFERRED_BUFFER_WRITE_SLH@>
|
<@def DEFERRED_BUFFER_WRITE_SLH@>
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 _fragColor0;
|
||||||
|
layout(location = 1) out vec4 _fragColor1;
|
||||||
|
layout(location = 2) out vec4 _fragColor2;
|
||||||
|
|
||||||
// the glow intensity
|
// the glow intensity
|
||||||
uniform float glowIntensity;
|
uniform float glowIntensity;
|
||||||
|
|
||||||
// the alpha threshold
|
// the alpha threshold
|
||||||
uniform float alphaThreshold;
|
uniform float alphaThreshold;
|
||||||
|
|
||||||
|
uniform sampler2D normalFittingMap;
|
||||||
|
|
||||||
|
vec3 bestFitNormal(vec3 normal) {
|
||||||
|
vec3 absNorm = abs(normal);
|
||||||
|
float maxNAbs = max(absNorm.z, max(absNorm.x, absNorm.y));
|
||||||
|
|
||||||
|
vec2 texcoord = (absNorm.z < maxNAbs ?
|
||||||
|
(absNorm.y < maxNAbs ? absNorm.yz : absNorm.xz) :
|
||||||
|
absNorm.xy);
|
||||||
|
texcoord = (texcoord.x < texcoord.y ? texcoord.yx : texcoord.xy);
|
||||||
|
texcoord.y /= texcoord.x;
|
||||||
|
vec3 cN = normal / maxNAbs;
|
||||||
|
float fittingScale = texture(normalFittingMap, texcoord).a;
|
||||||
|
cN *= fittingScale;
|
||||||
|
return (cN * 0.5 + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
|
float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
|
||||||
return mix(alpha * glowIntensity, 1.0 - alpha * glowIntensity, step(mapAlpha, alphaThreshold));
|
return mix(alpha * glowIntensity, 1.0 - alpha * glowIntensity, step(mapAlpha, alphaThreshold));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vec3 DEFAULT_SPECULAR = vec3(0.1);
|
||||||
|
const float DEFAULT_SHININESS = 10;
|
||||||
|
|
||||||
void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
|
void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
|
||||||
if (alpha != glowIntensity) {
|
if (alpha != glowIntensity) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
gl_FragData[0] = vec4(diffuse.rgb, alpha);
|
_fragColor0 = vec4(diffuse.rgb, alpha);
|
||||||
gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
_fragColor1 = vec4(bestFitNormal(normal), 1.0);
|
||||||
gl_FragData[2] = vec4(specular, shininess / 128.0);
|
_fragColor2 = vec4(specular, shininess / 128.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess, vec3 emissive) {
|
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess, vec3 emissive) {
|
||||||
if (alpha != glowIntensity) {
|
if (alpha != glowIntensity) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragData[0] = vec4(diffuse.rgb, alpha);
|
_fragColor0 = vec4(diffuse.rgb, alpha);
|
||||||
//gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
//_fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
|
_fragColor1 = vec4(bestFitNormal(normal), 0.5);
|
||||||
gl_FragData[2] = vec4(emissive, shininess / 128.0);
|
_fragColor2 = vec4(emissive, shininess / 128.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
|
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
|
||||||
if (alpha <= alphaThreshold) {
|
if (alpha <= alphaThreshold) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragData[0] = vec4(diffuse.rgb, alpha);
|
_fragColor0 = vec4(diffuse.rgb, alpha);
|
||||||
// gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
// _fragColor1 = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
// gl_FragData[2] = vec4(specular, shininess / 128.0);
|
// _fragColor2 = vec4(specular, shininess / 128.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
uniform sampler2D originalTexture;
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 interpolatedNormal;
|
in vec3 interpolatedNormal;
|
||||||
varying vec4 modelPosition;
|
in vec2 varTexcoord;
|
||||||
varying vec2 varTexcoord;
|
in vec4 varColor;
|
||||||
|
|
||||||
float rand(vec2 point){
|
float rand(vec2 point){
|
||||||
return fract(sin(dot(point.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
return fract(sin(dot(point.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||||
|
@ -31,14 +31,13 @@ float rand(vec2 point){
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
|
||||||
vec3 newNormal = normalize(interpolatedNormal.xyz);
|
|
||||||
|
|
||||||
vec4 texel = texture2D(originalTexture, varTexcoord);
|
vec4 texel = texture(originalTexture, varTexcoord);
|
||||||
int frontCondition = 1 -int(gl_FrontFacing) * 2;
|
int frontCondition = 1 -int(gl_FrontFacing) * 2;
|
||||||
vec3 color = gl_Color.rgb;
|
vec3 color = varColor.rgb;
|
||||||
//vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess
|
//vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess
|
||||||
packDeferredFragmentTranslucent(
|
packDeferredFragmentTranslucent(
|
||||||
newNormal * frontCondition,
|
interpolatedNormal * frontCondition,
|
||||||
texel.a,
|
texel.a,
|
||||||
color *texel.rgb,
|
color *texel.rgb,
|
||||||
vec3(0.01, 0.01, 0.01),
|
vec3(0.01, 0.01, 0.01),
|
||||||
|
|
|
@ -12,30 +12,29 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 interpolatedNormal;
|
out vec3 interpolatedNormal;
|
||||||
varying vec4 modelPosition;
|
|
||||||
|
|
||||||
//the diffuse texture
|
//the diffuse texture
|
||||||
varying vec2 varTexcoord;
|
out vec2 varTexcoord;
|
||||||
|
|
||||||
|
out vec4 varColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
|
||||||
varTexcoord = gl_MultiTexCoord0.st;
|
varTexcoord = inTexCoord0.st;
|
||||||
|
|
||||||
// pass along the diffuse color
|
// pass along the diffuse color
|
||||||
gl_FrontColor = gl_Color;
|
varColor = inColor;
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||||
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
|
<$transformModelToEyeDir(cam, obj, inNormal.xyz, interpolatedNormal)$>
|
||||||
|
|
||||||
modelPosition = gl_Vertex;
|
|
||||||
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
|
||||||
}
|
}
|
|
@ -109,6 +109,8 @@
|
||||||
#include "sdf_text3D_vert.h"
|
#include "sdf_text3D_vert.h"
|
||||||
#include "sdf_text3D_frag.h"
|
#include "sdf_text3D_frag.h"
|
||||||
|
|
||||||
|
#include "paintStroke_vert.h"
|
||||||
|
#include "paintStroke_frag.h"
|
||||||
|
|
||||||
class RateCounter {
|
class RateCounter {
|
||||||
std::vector<float> times;
|
std::vector<float> times;
|
||||||
|
@ -324,6 +326,8 @@ void QTestWindow::draw() {
|
||||||
testShaderBuild(SkyFromAtmosphere_vert, SkyFromAtmosphere_frag);
|
testShaderBuild(SkyFromAtmosphere_vert, SkyFromAtmosphere_frag);
|
||||||
|
|
||||||
testShaderBuild(Skybox_vert, Skybox_frag);
|
testShaderBuild(Skybox_vert, Skybox_frag);
|
||||||
|
|
||||||
|
testShaderBuild(paintStroke_vert,paintStroke_frag);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue