Substance Live Shanghai final season 2019! Chapter 1

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_39812022/article/details/102746929

Substance Live Shanghai final season 2019

Chapter 1在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

Totally joined in Substance live How many visitor that around 18000 persons! Amazing.

Our main topic is here.

  1. HDR editor
  2. Custom blend node How to approaching
  3. ACES tonemapped shader tweaking
  4. Height based modeling to Sci-fi texture assets.
  5. Curvy filter via Linear inperpolation function

1. HDR Editor

在这里插入图片描述
在这里插入图片描述
使用在Substance中新添加的HDR编辑工具,可以很容易地修改UniBL照明,进行Look-Dev。
在角色选角窗口要达到什么样的照明效果,可以跟美术一起实时修改进行工作。

2. Custom blend node.

当混合多个Shape以创建新的造型时,Blend 的 min 和 max 很有用。
看看它是如何构建的,再尝试做出新的混合方式。
在这里插入图片描述
在这里插入图片描述
链接:https://pan.baidu.com/s/1ydknBeA2xfkTig67aVZV7g
提取码:q6jh
复制这段内容后打开百度网盘手机App,操作更方便哦

3. ACES Tonemapped Tweak Substance designer shader.

Substance designer没有ACES Tonemapped的方式。
所以美术会说,使用UE4或者用最新Unity3D喜欢的ACES方式制作时,材质的颜色感或Specular的感觉不同。
最初做材质的时候最好在ACES空间制作。
在这里插入图片描述
在这里插入图片描述

fs.glsl

/*
Copyright (c) 2018, Allegorithmic. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
   * Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.
   * Neither the name of the Allegorithmic nor the
     names of its contributors may be used to endorse or promote products
     derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL ALLEGORITHMIC BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

//////////////////////////////// Fragment shader
#version 330
#extension GL_ARB_texture_query_lod : enable

#include "../common/common.glsl"
#include "../common/uvtile.glsl"
#include "../common/aniso_angle.glsl"
#include "../common/parallax.glsl"

in vec3 iFS_Normal;
in vec2 iFS_UV;
in vec3 iFS_Tangent;
in vec3 iFS_Binormal;
in vec3 iFS_PointWS;

out vec4 ocolor0;

uniform vec3 Lamp0Pos = vec3(0.0,0.0,70.0);
uniform vec3 Lamp0Color = vec3(1.0,1.0,1.0);
uniform float Lamp0Intensity = 1.0;
uniform vec3 Lamp1Pos = vec3(70.0,0.0,0.0);
uniform vec3 Lamp1Color = vec3(0.198,0.198,0.198);
uniform float Lamp1Intensity = 1.0;

uniform float AmbiIntensity = 1.0;
uniform float EmissiveIntensity = 1.0;

uniform int parallax_mode = 0;

uniform float tiling = 1.0;
uniform vec3 uvwScale = vec3(1.0, 1.0, 1.0);
uniform bool uvwScaleEnabled = false;
uniform float envRotation = 0.0;
uniform float tessellationFactor = 4.0;
uniform float heightMapScale = 1.0;
uniform bool flipY = true;
uniform bool perFragBinormal = true;
uniform bool sRGBBaseColor = true;
uniform bool acesEnabled = false;

uniform sampler2D heightMap;
uniform sampler2D normalMap;
uniform sampler2D baseColorMap;
uniform sampler2D metallicMap;
uniform sampler2D roughnessMap;
uniform sampler2D aoMap;
uniform sampler2D emissiveMap;
uniform sampler2D specularLevel;
uniform sampler2D opacityMap;
uniform sampler2D anisotropyLevelMap;
uniform sampler2D anisotropyAngleMap;
uniform sampler2D bluenoiseMask;
uniform samplerCube environmentMap;

uniform mat4 viewInverseMatrix;

// Number of miplevels in the envmap
uniform float maxLod = 12.0;

// Actual number of samples in the table
uniform int nbSamples = 16;

// Irradiance spherical harmonics polynomial coefficients
// This is a color 2nd degree polynomial in (x,y,z), so it needs 10 coefficients
// for each color channel
uniform vec3 shCoefs[10];



// This must be included after the declaration of the uniform arrays since they
// can't be passed as functions parameters for performance reasons (on macs)
#include "../common/pbr_aniso_ibl.glsl"

// ACES Tonemapping

vec3 tonemapSCurve(vec3 x)
{
  	float a = 2.51f;
    float b = 0.03f;
    float c = 2.43f;
    float d = 0.59f;
    float e = 0.14f;
    return clamp((x*(a*x+b))/(x*(c*x+d)+e),0.0,1.0);
}


void main()
{
	vec3 normalWS = iFS_Normal;
	vec3 tangentWS = iFS_Tangent;
	vec3 binormalWS = perFragBinormal ?
		fixBinormal(normalWS,tangentWS,iFS_Binormal) : iFS_Binormal;

	vec3 cameraPosWS = viewInverseMatrix[3].xyz;
	vec3 pointToLight0DirWS = Lamp0Pos - iFS_PointWS;
	float pointToLight0Length = length(pointToLight0DirWS);
	pointToLight0DirWS *= 1.0 / pointToLight0Length;
	vec3 pointToLight1DirWS = Lamp1Pos - iFS_PointWS;
	float pointToLight1Length = length(Lamp1Pos - iFS_PointWS);
	pointToLight1DirWS *= 1.0 / pointToLight1Length;
	vec3 pointToCameraDirWS = normalize(cameraPosWS - iFS_PointWS);

	// ------------------------------------------
	// Parallax
	vec2 uvScale = vec2(1.0);
	if (uvwScaleEnabled)
		uvScale = uvwScale.xy;
	vec2 uv = parallax_mode == 1 ? iFS_UV*tiling*uvScale : updateUV(
		heightMap,
		pointToCameraDirWS,
		normalWS, tangentWS, binormalWS,
		heightMapScale,
		iFS_UV,
		uvScale,
		tiling);

	uv = uv / (tiling * uvScale);
	bool disableFragment = hasToDisableFragment(uv);
	uv = uv * tiling * uvScale;
	uv = getUDIMTileUV(uv);

	// ------------------------------------------
	// Add Normal from normalMap
	vec3 fixedNormalWS = normalWS;  // HACK for empty normal textures
	vec3 normalTS = get2DSample(normalMap, uv, disableFragment, cDefaultColor.mNormal).xyz;
	if(length(normalTS)>0.0001)
	{
		normalTS = fixNormalSample(normalTS,flipY);
		fixedNormalWS = normalize(
			normalTS.x*tangentWS +
			normalTS.y*binormalWS +
			normalTS.z*normalWS );
	}

	// ------------------------------------------
	// Compute material model (diffuse, specular & roughness)
	float dielectricSpec = 0.08 * get2DSample(specularLevel, uv, disableFragment, cDefaultColor.mSpecularLevel).r;
	vec3 dielectricColor = vec3(dielectricSpec);
	// Convert the base color from sRGB to linear (we should have done this when
	// loading the texture but there is no way to specify which colorspace is
	// uѕed for a given texture in Designer yet)
	vec3 baseColor = get2DSample(baseColorMap, uv, disableFragment, cDefaultColor.mBaseColor).rgb;
	if (sRGBBaseColor)
		baseColor = srgb_to_linear(baseColor);

	float metallic = get2DSample(metallicMap, uv, disableFragment, cDefaultColor.mMetallic).r;
	float anisoLevel = get2DSample(anisotropyLevelMap, uv, disableFragment, cDefaultColor.mAnisotropyLevel).r;
	vec2 roughness;
	roughness.x = get2DSample(roughnessMap, uv, disableFragment, cDefaultColor.mRoughness).r;
	roughness.y = roughness.x / sqrt(max(1e-5, 1.0 - anisoLevel));
	roughness = max(vec2(1e-4), roughness);
	float anisoAngle = getAnisotropyAngleSample(anisotropyAngleMap, uv, disableFragment, cDefaultColor.mAnisotropyAngle.x);

	vec3 diffColor = baseColor * (1.0 - metallic);
	vec3 specColor = mix(dielectricColor, baseColor, metallic);

	// ------------------------------------------
	// Compute point lights contributions
	vec3 contrib0 = pointLightContribution(
			fixedNormalWS, tangentWS, binormalWS, anisoAngle,
			pointToLight0DirWS, pointToCameraDirWS,
			diffColor, specColor, roughness,
			Lamp0Color, Lamp0Intensity, pointToLight0Length);
	vec3 contrib1 = pointLightContribution(
			fixedNormalWS, tangentWS, binormalWS, anisoAngle,
			pointToLight1DirWS, pointToCameraDirWS,
			diffColor, specColor, roughness,
			Lamp1Color, Lamp1Intensity, pointToLight1Length);

	// ------------------------------------------
	// Image based lighting contribution
	float ao = get2DSample(aoMap, uv, disableFragment, cDefaultColor.mAO).r;

	float noise = roughness.x == roughness.y ?
		0.0 :
		texelFetch(bluenoiseMask, ivec2(gl_FragCoord.xy) & ivec2(0xFF), 0).x;

	vec3 contribE = computeIBL(
		environmentMap, envRotation, maxLod,
		nbSamples,
		normalWS, fixedNormalWS, tangentWS, binormalWS, anisoAngle,
		pointToCameraDirWS,
		diffColor, specColor, roughness,
		AmbiIntensity * ao,
		noise);

	// ------------------------------------------
	//Emissive
	vec3 emissiveContrib = get2DSample(emissiveMap, uv, disableFragment, cDefaultColor.mEmissive).rgb;
	emissiveContrib = srgb_to_linear(emissiveContrib) * EmissiveIntensity;

	// ------------------------------------------
	vec3 finalColor = contrib0 + contrib1 + contribE + emissiveContrib;
	vec3 finalColorToneMapped = tonemapSCurve(contrib0 + contrib1 + contribE + emissiveContrib);
	

	// Final Color
	// Convert the fragment color from linear to sRGB for display (we should
	// make the framebuffer use sRGB instead).
	float opacity = get2DSample(opacityMap, uv, disableFragment, cDefaultColor.mOpacity).r;
	
	if (acesEnabled)
	{
		ocolor0 = vec4(finalColorToneMapped, opacity);
	}
	else ocolor0 = vec4(finalColor, opacity);
	
}

physically_metallic_roughness_aces.glslfx

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sbsbatchnode SYSTEM "glslfx.dtd">
<glslfx version="1.0.0" author="allegorithmic.com">

    <!-- TECHNIQUES -->
    <technique name="Parallax Occlusion">
        <!-- PROPERTIES -->
        <property name="blend_enabled"     value="true"/>
        <property name="blend_func"        value="src_alpha,one_minus_src_alpha"/>
        <property name="cull_face_enabled" value="true"/>
        <property name="cull_face_mode"    value="back"/>

        <!-- SHADERS -->
        <shader type="vertex"   filename="common/parallax/vs.glsl"/>
        <shader type="fragment" filename="physically_metallic_roughness_aces/fs.glsl"/>

        <!-- UNIFORMS -->
        <uniform name="parallax_mode" guiName="Parallax Mode"         min="0" max="0" />
    </technique>


    <technique name="Tessellation">
        <!-- PROPERTIES -->
        <property name="blend_enabled"     value="true"/>
        <property name="blend_func"        value="src_alpha,one_minus_src_alpha"/>
        <property name="cull_face_enabled" value="true"/>
        <property name="cull_face_mode"    value="back"/>

        <!-- SHADERS -->
        <shader type="vertex"       filename="common/tessellation/vs.glsl" primitiveType="patch3"/>
        <shader type="tess_control" filename="common/tessellation/tcs.glsl"/>
        <shader type="tess_eval"    filename="common/tessellation/tes.glsl"/>
        <shader type="fragment"     filename="physically_metallic_roughness_aces/fs.glsl"/>

        <!-- UNIFORMS -->
        <uniform name="parallax_mode"      guiName="Parallax Mode" min="1" max="1" />
        <uniform name="tessellationFactor" guiGroup="Height"       guiName="Tessellation Factor"   default="4" min="1" max="64" guiMin="1" guiMax="16" guiStep="1" guiWidget="slider"/>

        <!-- PHONG TESSELLATION UNIFORMS -->
        <uniform name="usePhongTessellation"    guiGroup="Height"  guiName="Phong Tessellation"         default="true"      guiWidget="checkbox" />
        <uniform name="phongTessellationFactor" guiGroup="Height"  guiName="Phong Tessellation Factor"  default="0.6" min="0.0" max="1.0" guiMin="0.0" guiMax="1.0" guiStep="0.05" guiWidget="slider"/>
    </technique>

    

    <!-- INPUT VERTEX FORMAT -->
    <vertexformat name="iVS_Position" semantic="position"/>
    <vertexformat name="iVS_Normal"   semantic="normal"/>
    <vertexformat name="iVS_UV"       semantic="texcoord0"/>
    <vertexformat name="iVS_Tangent"  semantic="tangent0"/>
    <vertexformat name="iVS_Binormal" semantic="binormal0"/>

    <!-- SAMPLERS -->
    <sampler name="baseColorMap"       usage="basecolor,diffuse"/>
    <sampler name="heightMap"          usage="height"/>
    <sampler name="normalMap"          usage="normal"/>
    <sampler name="metallicMap"        usage="metallic"/>
    <sampler name="roughnessMap"       usage="roughness"/>
    <sampler name="aoMap"              usage="ambientocclusion"/>
    <sampler name="emissiveMap"        usage="emissive"/>
    <sampler name="specularLevel"      usage="specularlevel"/>
    <sampler name="opacityMap"         usage="opacity"/>
    <sampler name="anisotropyLevelMap" usage="anisotropylevel"/>
    <sampler name="anisotropyAngleMap" usage="anisotropyangle"/>
    <sampler name="environmentMap"     usage="environment"/>
    <sampler name="bluenoiseMask"      usage="bluenoisemask"     ishidden="true"/>

    <!-- MATRICES -->
    <uniform name="worldMatrix"                 semantic="world"/>
    <uniform name="worldViewProjMatrix"         semantic="worldviewprojection"/>
    <uniform name="worldViewMatrix"             semantic="worldview"/>
    <uniform name="worldInverseTransposeMatrix" semantic="worldinversetranspose"/>
    <uniform name="viewInverseMatrix"           semantic="viewinverse"/>
    <uniform name="modelViewMatrix"             semantic="modelview"/>
    <uniform name="projectionMatrix"            semantic="projection"/>

    <!-- SCENE PARAMETERS -->
    <uniform name="Lamp0Pos"       semantic="lightposition0"/>
    <uniform name="Lamp0Color"     semantic="lightcolor0"/>
    <uniform name="Lamp0Intensity" semantic="lightintensity0"/>
    <uniform name="Lamp1Pos"       semantic="lightposition1"/>
    <uniform name="Lamp1Color"     semantic="lightcolor1"/>
    <uniform name="Lamp1Intensity" semantic="lightintensity1"/>

    <!-- MISC PARAMETERS -->
    <uniform name="nbSamples"           semantic="samplespostablesize"/>
    <uniform name="maxLod"              semantic="panoramamipmapheight"/>
    <uniform name="AmbiIntensity"       semantic="panoramaintensity"/>
    <uniform name="envRotation"         semantic="panoramarotation"/>
    <uniform name="shCoefs"             semantic="irradianceshcoefs"/>
    <uniform name="perFragBinormal"     semantic="computebinormalinfragmentshader"/>
    <uniform name="uvwScale"            semantic="uvwscale"/>
    <uniform name="displayUVTileOnly"   semantic="renderuvtile"/>
    <uniform name="uvTileCoords"        semantic="uvtilecoords"/>
    <uniform name="acesEnabled"        semantic="acesEnabled"/>


    <!-- UNIFORMS -->
    <uniform name="EmissiveIntensity" guiGroup="Emissive"   guiName="Emissive Intensity"      default="1" min="0"  guiWidget="slider"  guiMin="0"  guiMax="20"/>
    <uniform name="sRGBBaseColor"     guiGroup="Base Color" guiName="sRGB Base Color Texture" default="true"       guiWidget="checkbox" />
    <uniform name="heightMapScale"    guiGroup="Height"     guiName="Scale"                   default="0"          guiWidget="slider" guiMin="0"  guiMax="10" />
    <uniform name="flipY"             guiGroup="Normal"     guiName="DirectX Normal"          default="true"       guiWidget="checkbox" semantic="isdirectxnormal"/>
    <uniform name="tiling"            guiGroup="Global"     guiName="Tiling"                  default="1" min="1"  guiWidget="slider"   guiMax="10"/>
    <uniform name="uvwScaleEnabled"   guiGroup="Global"     guiName="UV Scale Enabled"        default="false"      guiWidget="checkbox" />
    <uniform name="acesEnabled"   guiGroup="ToneMapped"     guiName="Aces Enabled"            default="false"      guiWidget="checkbox" />
    
</glslfx>

链接:https://pan.baidu.com/s/1gbvn6EeJwe1USStvl-Kxcg
提取码:qu6r
复制这段内容后打开百度网盘手机App,操作更方便哦

猜你喜欢

转载自blog.csdn.net/qq_39812022/article/details/102746929