mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
cleaning up fragment shaders
This commit is contained in:
parent
3d71dfc467
commit
09a6053044
35 changed files with 229 additions and 233 deletions
|
@ -30,6 +30,5 @@ void main(void) {
|
|||
float(frontCondition) * interpolatedNormal,
|
||||
texel.a * varColor.a,
|
||||
color * texel.rgb,
|
||||
vec3(0.01, 0.01, 0.01),
|
||||
10.0);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,5 @@ void main(void) {
|
|||
interpolatedNormal * float(frontCondition),
|
||||
texel.a * varColor.a,
|
||||
polyline.color * texel.rgb + fadeEmissive,
|
||||
vec3(0.01, 0.01, 0.01),
|
||||
10.0);
|
||||
}
|
||||
|
|
|
@ -981,7 +981,7 @@ FBXGeometry::Pointer OBJReader::readOBJ(QByteArray& model, const QVariantHash& m
|
|||
modelMaterial->setMetallic(ILLUMINATION_MODEL_APPLY_NON_METALLIC);
|
||||
}
|
||||
if (fresnelOn) {
|
||||
modelMaterial->setFresnel(glm::vec3(1.0f));
|
||||
// TODO: how to turn fresnel on?
|
||||
}
|
||||
|
||||
modelMaterial->setOpacity(fbxMaterial.opacity);
|
||||
|
|
|
@ -70,7 +70,7 @@ Material& Material::operator= (const Material& material) {
|
|||
Material::~Material() {
|
||||
}
|
||||
|
||||
void Material::setEmissive(const Color& emissive, bool isSRGB) {
|
||||
void Material::setEmissive(const Color& emissive, bool isSRGB) {
|
||||
_key.setEmissive(glm::any(glm::greaterThan(emissive, Color(0.0f))));
|
||||
_schemaBuffer.edit<Schema>()._key = (uint32) _key._flags.to_ulong();
|
||||
_schemaBuffer.edit<Schema>()._emissive = (isSRGB ? ColorUtils::sRGBToLinearVec3(emissive) : emissive);
|
||||
|
@ -100,11 +100,6 @@ void Material::setRoughness(float roughness) {
|
|||
_schemaBuffer.edit<Schema>()._roughness = roughness;
|
||||
}
|
||||
|
||||
void Material::setFresnel(const Color& fresnel, bool isSRGB) {
|
||||
//_key.setAlbedo(glm::any(glm::greaterThan(albedo, Color(0.0f))));
|
||||
_schemaBuffer.edit<Schema>()._fresnel = (isSRGB ? ColorUtils::sRGBToLinearVec3(fresnel) : fresnel);
|
||||
}
|
||||
|
||||
void Material::setMetallic(float metallic) {
|
||||
metallic = glm::clamp(metallic, 0.0f, 1.0f);
|
||||
_key.setMetallic(metallic > 0.0f);
|
||||
|
|
|
@ -291,9 +291,6 @@ public:
|
|||
void setAlbedo(const Color& albedo, bool isSRGB = true);
|
||||
Color getAlbedo(bool SRGB = true) const { return (SRGB ? ColorUtils::tosRGBVec3(_schemaBuffer.get<Schema>()._albedo) : _schemaBuffer.get<Schema>()._albedo); }
|
||||
|
||||
void setFresnel(const Color& fresnel, bool isSRGB = true);
|
||||
Color getFresnel(bool SRGB = true) const { return (SRGB ? ColorUtils::tosRGBVec3(_schemaBuffer.get<Schema>()._fresnel) : _schemaBuffer.get<Schema>()._fresnel); }
|
||||
|
||||
void setMetallic(float metallic);
|
||||
float getMetallic() const { return _schemaBuffer.get<Schema>()._metallic; }
|
||||
|
||||
|
@ -306,20 +303,18 @@ public:
|
|||
// Schema to access the attribute values of the material
|
||||
class Schema {
|
||||
public:
|
||||
glm::vec3 _emissive{ 0.0f }; // No Emissive
|
||||
float _opacity{ 1.0f }; // Opacity = 1 => Not Transparent
|
||||
glm::vec3 _emissive { 0.0f }; // No Emissive
|
||||
float _opacity { 1.0f }; // Opacity = 1 => Not Transparent
|
||||
|
||||
glm::vec3 _albedo{ 0.5f }; // Grey albedo => isAlbedo
|
||||
float _roughness{ 1.0f }; // Roughness = 1 => Not Glossy
|
||||
glm::vec3 _albedo { 0.5f }; // Grey albedo => isAlbedo
|
||||
float _roughness { 1.0f }; // Roughness = 1 => Not Glossy
|
||||
|
||||
glm::vec3 _fresnel{ 0.03f }; // Fresnel value for a default non metallic
|
||||
float _metallic{ 0.0f }; // Not Metallic
|
||||
float _metallic { 0.0f }; // Not Metallic
|
||||
float _scattering { 0.0f }; // Scattering info
|
||||
glm::vec2 _spare { 0.0f };
|
||||
|
||||
float _scattering{ 0.0f }; // Scattering info
|
||||
|
||||
glm::vec2 _spare{ 0.0f };
|
||||
|
||||
uint32_t _key{ 0 }; // a copy of the materialKey
|
||||
uint32_t _key { 0 }; // a copy of the materialKey
|
||||
glm::vec3 _spare2 { 0.0f };
|
||||
|
||||
// for alignment beauty, Material size == Mat4x4
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
struct Material {
|
||||
vec4 _emissiveOpacity;
|
||||
vec4 _albedoRoughness;
|
||||
vec4 _fresnelMetallic;
|
||||
vec4 _scatteringSpare2Key;
|
||||
vec4 _metallicScatteringSpare2;
|
||||
vec4 _keySpare3;
|
||||
};
|
||||
|
||||
layout(binding=GRAPHICS_BUFFER_MATERIAL) uniform materialBuffer {
|
||||
|
@ -36,15 +36,12 @@ float getMaterialOpacity(Material m) { return m._emissiveOpacity.a; }
|
|||
|
||||
vec3 getMaterialAlbedo(Material m) { return m._albedoRoughness.rgb; }
|
||||
float getMaterialRoughness(Material m) { return m._albedoRoughness.a; }
|
||||
|
||||
vec3 getMaterialFresnel(Material m) { return m._fresnelMetallic.rgb; }
|
||||
float getMaterialMetallic(Material m) { return m._fresnelMetallic.a; }
|
||||
|
||||
float getMaterialShininess(Material m) { return 1.0 - getMaterialRoughness(m); }
|
||||
|
||||
float getMaterialScattering(Material m) { return m._scatteringSpare2Key.x; }
|
||||
float getMaterialMetallic(Material m) { return m._metallicScatteringSpare2.x; }
|
||||
float getMaterialScattering(Material m) { return m._metallicScatteringSpare2.y; }
|
||||
|
||||
BITFIELD getMaterialKey(Material m) { return floatBitsToInt(m._scatteringSpare2Key.w); }
|
||||
BITFIELD getMaterialKey(Material m) { return floatBitsToInt(m._keySpare3.x); }
|
||||
|
||||
const BITFIELD EMISSIVE_VAL_BIT = 0x00000001;
|
||||
const BITFIELD UNLIT_VAL_BIT = 0x00000002;
|
||||
|
|
|
@ -204,12 +204,12 @@ float fetchScatteringMap(vec2 uv) {
|
|||
<@endif@>
|
||||
<@endfunc@>
|
||||
|
||||
<@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmapVal)@>
|
||||
<@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmap)@>
|
||||
<@if occlusion@>
|
||||
float <$occlusion$> = (((<$matKey$> & OCCLUSION_MAP_BIT) != 0) ? fetchOcclusionMap(<$texcoord1$>) : 1.0);
|
||||
<@endif@>
|
||||
<@if lightmapVal@>
|
||||
vec3 <$lightmapVal$> = fetchLightmapMap(<$texcoord1$>);
|
||||
vec3 <$lightmap$> = fetchLightmapMap(<$texcoord1$>);
|
||||
<@endif@>
|
||||
<@endfunc@>
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ layout(location=3) out vec4 _fragColor3; // emissive
|
|||
|
||||
// the alpha threshold
|
||||
const float alphaThreshold = 0.5;
|
||||
// FIXME: is this correct?
|
||||
float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
|
||||
return mix(alpha, 1.0 - alpha, step(mapAlpha, alphaThreshold));
|
||||
}
|
||||
|
@ -39,7 +40,7 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness
|
|||
_fragColor3 = vec4(isEmissiveEnabled() * emissive, 1.0);
|
||||
}
|
||||
|
||||
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel, vec3 lightmap) {
|
||||
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 lightmap) {
|
||||
if (alpha != 1.0) {
|
||||
discard;
|
||||
}
|
||||
|
@ -61,7 +62,7 @@ void packDeferredFragmentUnlit(vec3 normal, float alpha, vec3 color) {
|
|||
_fragColor3 = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) {
|
||||
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, float roughness) {
|
||||
if (alpha <= 0.0) {
|
||||
discard;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 5/6/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -42,11 +40,14 @@ void main(void) {
|
|||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
float scattering = getMaterialScattering(mat);
|
||||
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
||||
|
@ -58,6 +59,6 @@ void main(void) {
|
|||
roughness,
|
||||
metallic,
|
||||
emissive,
|
||||
occlusionTex,
|
||||
occlusion,
|
||||
scattering);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -13,17 +11,15 @@
|
|||
//
|
||||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include graphics/Material.slh@>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
|
@ -34,13 +30,12 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
|
@ -54,13 +49,17 @@ void main(void) {
|
|||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
float scattering = getMaterialScattering(mat);
|
||||
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(_normalWS),
|
||||
|
@ -68,7 +67,7 @@ void main(void) {
|
|||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
emissive+fadeEmissive,
|
||||
occlusionTex,
|
||||
emissive + fadeEmissive,
|
||||
occlusion,
|
||||
scattering);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Samuel Gateau on 11/19/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -20,7 +18,6 @@
|
|||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
|
||||
<$declareMaterialLightmap()$>
|
||||
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
|
@ -30,15 +27,24 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
|
||||
|
||||
vec3 albedo = getMaterialAlbedo(mat);
|
||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color.rgb;
|
||||
|
||||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(_normalWS),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
|
||||
getMaterialRoughness(mat) * roughness,
|
||||
getMaterialMetallic(mat) * metallicTex,
|
||||
/*metallicTex, // no use of */getMaterialFresnel(mat),
|
||||
lightmapVal);
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
lightmap);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -13,18 +11,16 @@
|
|||
//
|
||||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include graphics/Material.slh@>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
|
||||
<$declareMaterialLightmap()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
|
@ -35,21 +31,29 @@ layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
|||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
|
||||
|
||||
vec3 albedo = getMaterialAlbedo(mat);
|
||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color.rgb;
|
||||
|
||||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(_normalWS),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
|
||||
getMaterialRoughness(mat) * roughness,
|
||||
getMaterialMetallic(mat) * metallicTex,
|
||||
/*metallicTex, // no use of */getMaterialFresnel(mat),
|
||||
lightmapVal+fadeEmissive);
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
lightmap + fadeEmissive);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_map.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Samuel Gateau on 11/19/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -31,18 +29,27 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
|
||||
|
||||
vec3 albedo = getMaterialAlbedo(mat);
|
||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color.rgb;
|
||||
|
||||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 fragNormal;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTexel, _normalWS, _tangentWS, fragNormal)$>
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$>
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(fragNormal.xyz),
|
||||
normalize(fragNormal),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
|
||||
getMaterialRoughness(mat) * roughness,
|
||||
getMaterialMetallic(mat) * metallicTex,
|
||||
/*specular, // no use of */ getMaterialFresnel(mat),
|
||||
lightmapVal);
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
lightmap);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -13,18 +11,17 @@
|
|||
//
|
||||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include graphics/Material.slh@>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$>
|
||||
<$declareMaterialLightmap()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
|
@ -32,29 +29,36 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|||
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
|
||||
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
|
||||
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
|
||||
|
||||
vec3 albedo = getMaterialAlbedo(mat);
|
||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color.rgb;
|
||||
|
||||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 fragNormal;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTexel, _normalWS, _tangentWS, fragNormal)$>
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$>
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(fragNormal.xyz),
|
||||
normalize(fragNormal),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color.rgb,
|
||||
getMaterialRoughness(mat) * roughness,
|
||||
getMaterialMetallic(mat) * metallicTex,
|
||||
/*specular, // no use of */ getMaterialFresnel(mat),
|
||||
lightmapVal+fadeEmissive);
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
lightmap + fadeEmissive);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_map.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 5/6/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -44,25 +42,28 @@ void main(void) {
|
|||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 fragNormalWS;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
float scattering = getMaterialScattering(mat);
|
||||
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
||||
|
||||
vec3 fragNormalWS;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(fragNormalWS.xyz),
|
||||
normalize(fragNormalWS),
|
||||
opacity,
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
emissive,
|
||||
occlusionTex,
|
||||
occlusion,
|
||||
scattering);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -16,10 +14,10 @@
|
|||
<@include graphics/Material.slh@>
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
|
||||
|
@ -34,13 +32,12 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
|
@ -54,24 +51,28 @@ void main(void) {
|
|||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
float scattering = getMaterialScattering(mat);
|
||||
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
||||
|
||||
vec3 fragNormalWS;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
float scattering = getMaterialScattering(mat);
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(fragNormalWS.xyz),
|
||||
normalize(fragNormalWS),
|
||||
opacity,
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
emissive + fadeEmissive,
|
||||
occlusionTex,
|
||||
occlusion,
|
||||
scattering);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_shadow.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_shadow_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -12,19 +10,17 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include Fade.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
||||
|
||||
layout(location=0) out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFadeClip(fadeParams, _positionWS.xyz);
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_translucent.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Sam Gateau on 2/15/2016.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -12,19 +10,20 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
<@include DefaultMaterials.slh@>
|
||||
<@include graphics/Material.slh@>
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include LightLocal.slh@>
|
||||
<@include ShadingModel.slh@>
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardCameraTransform()$>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
|
@ -39,7 +38,7 @@ layout(location=0) out vec4 _fragColor;
|
|||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = getMaterialOpacity(mat) * _color.a;
|
||||
|
@ -54,11 +53,16 @@ void main(void) {
|
|||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 fresnel = getFresnelF0(metallic, albedo);
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
|
@ -70,7 +74,6 @@ void main(void) {
|
|||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
|
@ -81,7 +84,7 @@ void main(void) {
|
|||
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
occlusion,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
|
|
|
@ -1,29 +1,33 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
// model_translucent_fade.frag
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include DefaultMaterials.slh@>
|
||||
<@include graphics/Material.slh@>
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include LightLocal.slh@>
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
|
||||
<@include LightLocal.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardCameraTransform()$>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
|
@ -37,13 +41,12 @@ layout(location=0) out vec4 _fragColor;
|
|||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = getMaterialOpacity(mat) * _color.a;
|
||||
|
@ -58,11 +61,16 @@ void main(void) {
|
|||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 fresnel = getFresnelF0(metallic, albedo);
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
|
@ -74,7 +82,6 @@ void main(void) {
|
|||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
|
@ -85,7 +92,7 @@ void main(void) {
|
|||
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
occlusion,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_translucent_normal_map.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 23/01/2018.
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -12,21 +10,20 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include DefaultMaterials.slh@>
|
||||
<@include graphics/Material.slh@>
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include LightLocal.slh@>
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
|
||||
<@include LightLocal.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardCameraTransform()$>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
|
@ -42,7 +39,7 @@ layout(location=0) out vec4 _fragColor;
|
|||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = getMaterialOpacity(mat) * _color.a;
|
||||
|
@ -57,11 +54,16 @@ void main(void) {
|
|||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 fresnel = getFresnelF0(metallic, albedo);
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
|
@ -71,10 +73,9 @@ void main(void) {
|
|||
TransformCamera cam = getTransformCamera();
|
||||
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
|
||||
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
|
@ -85,7 +86,7 @@ void main(void) {
|
|||
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
occlusion,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_translucent_normal_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 23/01/18.
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -12,47 +10,44 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
<@include DefaultMaterials.slh@>
|
||||
<@include graphics/Material.slh@>
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include LightLocal.slh@>
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
|
||||
<@include LightLocal.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardCameraTransform()$>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
||||
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
|
||||
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
|
||||
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
||||
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
||||
|
||||
layout(location=0) out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = getMaterialOpacity(mat) * _color.a;
|
||||
|
@ -67,11 +62,16 @@ void main(void) {
|
|||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
vec3 fresnel = getFresnelF0(metallic, albedo);
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float occlusion = DEFAULT_OCCLUSION;
|
||||
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
||||
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
|
@ -81,10 +81,9 @@ void main(void) {
|
|||
TransformCamera cam = getTransformCamera();
|
||||
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
|
||||
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
|
@ -95,7 +94,7 @@ void main(void) {
|
|||
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
occlusion,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_translucent_unlit.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Zach Pomerantz on 2/3/2016.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -13,12 +11,12 @@
|
|||
//
|
||||
|
||||
<@include graphics/Material.slh@>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include LightingModel.slh@>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
<$declareMaterialTextures(ALBEDO)$>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_translucent_unlit_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -13,16 +11,16 @@
|
|||
//
|
||||
|
||||
<@include graphics/Material.slh@>
|
||||
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include LightingModel.slh@>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO)$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
|
@ -34,7 +32,6 @@ layout(location=0) out vec4 _fragColor;
|
|||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
|
@ -50,5 +47,6 @@ void main(void) {
|
|||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color.rgb;
|
||||
albedo += fadeEmissive;
|
||||
|
||||
_fragColor = vec4(albedo * isUnlitEnabled(), opacity);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// material_opaque_unlit.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Sam Gateau on 5/5/2016.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -12,12 +10,13 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
<@include LightingModel.slh@>
|
||||
<@include graphics/Material.slh@>
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
<@include LightingModel.slh@>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO)$>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
|
@ -27,7 +26,6 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
|
|||
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
||||
|
||||
void main(void) {
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// <$_SCRIBE_FILENAME$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_unlit_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -12,13 +10,14 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
<@include LightingModel.slh@>
|
||||
<@include graphics/Material.slh@>
|
||||
<@include graphics/MaterialTextures.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
<@include Fade.slh@>
|
||||
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
<@include LightingModel.slh@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<$declareMaterialTextures(ALBEDO)$>
|
||||
|
@ -33,7 +32,6 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
|
@ -49,6 +47,7 @@ void main(void) {
|
|||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color.rgb;
|
||||
albedo += fadeEmissive;
|
||||
|
||||
packDeferredFragmentUnlit(
|
||||
normalize(_normalWS),
|
||||
opacity,
|
||||
|
|
|
@ -14,5 +14,5 @@
|
|||
layout(location=0) in vec4 _color;
|
||||
|
||||
void main(void) {
|
||||
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_FRESNEL, DEFAULT_ROUGHNESS);
|
||||
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_ROUGHNESS);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,5 @@ void main() {
|
|||
normalize(_normalWS),
|
||||
a * params.color.a,
|
||||
params.color.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
}
|
|
@ -65,7 +65,6 @@ void main(void) {
|
|||
diffuse,
|
||||
max(0.0, 1.0 - shininess / 128.0),
|
||||
DEFAULT_METALLIC,
|
||||
specular,
|
||||
vec3(clamp(emissiveAmount, 0.0, 1.0)));
|
||||
} else {
|
||||
packDeferredFragment(
|
||||
|
|
|
@ -75,14 +75,12 @@ void main(void) {
|
|||
normal,
|
||||
_color.a,
|
||||
specular+fadeEmissive,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragmentTranslucent(
|
||||
normal,
|
||||
_color.a,
|
||||
diffuse+fadeEmissive,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
}
|
||||
} else {
|
||||
|
@ -93,7 +91,6 @@ void main(void) {
|
|||
diffuse+fadeEmissive,
|
||||
max(0.0, 1.0 - shininess / 128.0),
|
||||
DEFAULT_METALLIC,
|
||||
specular,
|
||||
specular);
|
||||
} else {
|
||||
packDeferredFragment(
|
||||
|
|
|
@ -53,7 +53,6 @@ void main(void) {
|
|||
normalize(_normalWS),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb + fadeEmissive,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragment(
|
||||
|
|
|
@ -41,7 +41,6 @@ void main(void) {
|
|||
normalize(_normalWS),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragmentUnlit(
|
||||
|
|
|
@ -53,7 +53,6 @@ void main(void) {
|
|||
normalize(_normalWS),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb+fadeEmissive,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragmentUnlit(
|
||||
|
|
|
@ -34,6 +34,5 @@ void main(void) {
|
|||
normalize(_normalWS),
|
||||
colorAlpha,
|
||||
_color.rgb * texel.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
}
|
|
@ -34,6 +34,5 @@ void main(void) {
|
|||
normalize(_normalWS),
|
||||
_color.a,
|
||||
_color.rgb * texel.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue