slightly fix forward pipelines

This commit is contained in:
SamGondelman 2018-09-26 14:44:19 -07:00
parent 09a6053044
commit 0f24c18de5
6 changed files with 36 additions and 37 deletions

View file

@ -226,16 +226,6 @@ vec3 fetchLightmapMap(vec2 uv) {
}
<@endfunc@>
<@func evalMaterialNormal(fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
{
vec3 normalizedNormal = normalize(<$interpolatedNormal$>.xyz);
vec3 normalizedTangent = normalize(<$interpolatedTangent$>.xyz);
vec3 normalizedBitangent = cross(normalizedNormal, normalizedTangent);
vec3 localNormal = <$fetchedNormal$>;
<$normal$> = vec3(normalizedBitangent * localNormal.x + normalizedNormal * localNormal.y + normalizedTangent * localNormal.z);
}
<@endfunc@>
<@func evalMaterialNormalLOD(fragPosES, fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
{
vec3 normalizedNormal = normalize(<$interpolatedNormal$>.xyz);

View file

@ -254,7 +254,7 @@ void initForwardPipelines(ShapePlumber& plumber) {
// Opaques
addPipeline(Key::Builder().withMaterial(), forward_model);
addPipeline(Key::Builder().withMaterial().withUnlit(), forward_model_unlit);
addPipeline(Key::Builder().withMaterial().withTangents(), forward_model_translucent);
addPipeline(Key::Builder().withMaterial().withTangents(), forward_model_normal_map);
// Skinned Opaques
addPipeline(Key::Builder().withMaterial().withSkinned(), forward_skin_model);
@ -272,6 +272,8 @@ void initForwardPipelines(ShapePlumber& plumber) {
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withDualQuatSkinned(), forward_skin_translucent_dq);
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withDualQuatSkinned(), forward_skin_translucent_normal_map_dq);
// FIXME: incorrent pipelines for normal mapped + translucent models
forceLightBatchSetter = false;
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model.frag
// fragment shader
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 High Fidelity, Inc.
//
@ -12,15 +10,16 @@
// 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 ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -56,8 +55,12 @@ void main(void) {
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal = normalize(_normalWS);
@ -66,7 +69,7 @@ void main(void) {
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPosition,
fragNormal,
albedo,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model_normal_map.frag
// fragment shader
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 High Fidelity, Inc.
//
@ -12,13 +10,16 @@
// 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 ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -55,18 +56,22 @@ void main(void) {
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal;
<$evalMaterialNormal(normalTex, _normalWS, _tangentWS, fragNormal)$>
<$evalMaterialNormalLOD(fragPosition, normalTex, _normalWS, _tangentWS, fragNormal)$>
TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPosition,
fragNormal,
albedo,
@ -74,7 +79,6 @@ void main(void) {
metallic,
roughness),
opacity);
color.rgb += emissive * isEmissiveEnabled();
_fragColor0 = color;

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model_translucent.frag
// fragment shader
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 High Fidelity, Inc.
//
@ -12,13 +10,16 @@
// 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 ForwardGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlended()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -51,8 +52,12 @@ void main(void) {
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
@ -64,7 +69,7 @@ void main(void) {
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusionTex,
occlusion,
fragPosition,
fragNormal,
albedo,

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_model_unlit.frag
// fragment shader
//
// Created by Sam Gateau on 5/5/2016.
// Copyright 2016 High Fidelity, Inc.
//
@ -12,11 +10,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include LightingModel.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
@ -27,7 +26,6 @@ layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
@ -40,8 +38,5 @@ void main(void) {
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
if (opacity != 1.0) {
discard;
}
_fragColor0 = vec4(albedo * isUnlitEnabled(), 1.0);
}