Include cubemap filtering tool
This commit is contained in:
parent
42f7de586f
commit
ccb7ede766
|
@ -2128,6 +2128,11 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
tex.id = 'senvmaplod'
|
||||
tex.name = 'envmap_lod1'
|
||||
c.bind_textures.append(tex)
|
||||
|
||||
tex = Object() # TODO: parse from world nodes
|
||||
tex.id = 'senvmapbrdf'
|
||||
tex.name = 'envmap_brdf'
|
||||
c.bind_textures.append(tex)
|
||||
|
||||
# Parse nodes
|
||||
out_node = None
|
||||
|
|
|
@ -19,5 +19,6 @@ vec2 envMapEquirect(vec3 normal) {
|
|||
|
||||
void main() {
|
||||
vec3 n = normalize(normal);
|
||||
gl_FragColor = texture(envmap, envMapEquirect(n));
|
||||
gl_FragColor = texture(envmap, envMapEquirect(n));
|
||||
// gl_FragData[0] = texture(envmap, envMapEquirect(n));
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ mat4 inverse_(mat4 m) {
|
|||
|
||||
void main() {
|
||||
|
||||
mat4 invP = inverse_(P);
|
||||
mat4 invP = inverse_(P);
|
||||
// mat4 invP = inverse(P);
|
||||
mat3 invMV = transpose_(mat3(V));
|
||||
|
||||
vec4 p = vec4(pos.xy, 0.0, 1.0);
|
||||
|
|
|
@ -17,6 +17,7 @@ uniform sampler2D salbedo;
|
|||
uniform sampler2D shadowMap;
|
||||
uniform sampler2D senvmap;
|
||||
uniform sampler2D senvmaplod;
|
||||
uniform sampler2D senvmapbrdf;
|
||||
#ifdef _NormalMapping
|
||||
uniform sampler2D snormal;
|
||||
#endif
|
||||
|
@ -166,6 +167,11 @@ vec3 surfaceF0(vec3 baseColor, float metalness) {
|
|||
return mix(vec3(0.04), baseColor, metalness);
|
||||
}
|
||||
|
||||
float getMipLevelFromRoughness(float roughness) {
|
||||
return 0.0;
|
||||
// First mipmap level = roughness 0, last = roughness = 1
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 n = normalize(normal);
|
||||
vec3 l = normalize(lightDir);
|
||||
|
@ -217,18 +223,20 @@ void main() {
|
|||
|
||||
// Indirect
|
||||
vec3 indirectDiffuse = texture(senvmap, envMapEquirect(n)).rgb;
|
||||
indirectDiffuse = pow(indirectDiffuse, vec3(2.2));
|
||||
indirectDiffuse = pow(indirectDiffuse, vec3(2.2)) * albedo;
|
||||
|
||||
vec3 reflectionWorld = reflect(-v, n);
|
||||
//lod = getMipLevelFromRoughness(roughness)
|
||||
vec3 reflectionWorld = reflect(-v, n);
|
||||
float lod = getMipLevelFromRoughness(roughness);
|
||||
//prefilteredColor = textureCube(PrefilteredEnvMap, refVec, lod)
|
||||
// vec3 prefilteredColor = textureLod(senvmaplod, envMapEquirect(reflectionWorld)).rgb;
|
||||
vec3 prefilteredColor = texture(senvmaplod, envMapEquirect(reflectionWorld)).rgb;
|
||||
prefilteredColor = pow(prefilteredColor, vec3(2.2));
|
||||
//prefilteredColor = textureCube(PrefilteredEnvMap, refVec, lod)
|
||||
//envBRDF = texture2D(BRDFIntegrationMap,vec2(roughness, ndotv)).xy
|
||||
//indirectSpecular = prefilteredColor * (specularColor * envBRDF.x + envBRDF.y)
|
||||
vec3 indirectSpecular = prefilteredColor;
|
||||
vec2 envBRDF = texture(senvmapbrdf, vec2(roughness, dotNV)).xy;
|
||||
vec3 indirectSpecular = prefilteredColor * (vec3(1.0) * envBRDF.x + envBRDF.y); // vec3(1.0)=specularColor
|
||||
|
||||
vec3 indirect = albedo * indirectDiffuse + f0 * indirectSpecular;
|
||||
vec3 indirect = indirectDiffuse + indirectSpecular;
|
||||
|
||||
outColor = vec4(vec3((direct + indirect) * visibility), 1.0);
|
||||
}
|
||||
|
|
26
tools/cmft/LICENSE
Normal file
26
tools/cmft/LICENSE
Normal file
|
@ -0,0 +1,26 @@
|
|||
Copyright 2014-2015 Dario Manesku. All rights reserved.
|
||||
|
||||
https://github.com/dariomanesku/cmft
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. 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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||
|
||||
https://github.com/dariomanesku/cmft/blob/master/LICENSE
|
BIN
tools/cmft/cmft-linux64
Executable file
BIN
tools/cmft/cmft-linux64
Executable file
Binary file not shown.
BIN
tools/cmft/cmft-osx
Executable file
BIN
tools/cmft/cmft-osx
Executable file
Binary file not shown.
BIN
tools/cmft/cmft.exe
Executable file
BIN
tools/cmft/cmft.exe
Executable file
Binary file not shown.
Loading…
Reference in a new issue