Remove old materials

This commit is contained in:
Lubos Lenco 2016-12-20 01:39:16 +01:00
parent fa576fd2c8
commit 0114c00b71
38 changed files with 85 additions and 5584 deletions

View file

@ -10,7 +10,7 @@ precision highp float;
// tonemapFilmic()
#include "../std/math.glsl"
// linearize()
#ifdef _CompoDOF
#ifdef _CDOF
#include "../std/dof.glsl"
#endif
@ -19,12 +19,12 @@ uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform sampler2D gbuffer1;
// #ifdef _CompoPos
// #ifdef _CPos
// uniform vec3 eye;
// uniform vec3 eyeLook;
// #endif
#ifdef _CompoGlare
#ifdef _CGlare
uniform vec3 light;
uniform mat4 VP;
uniform vec3 eye;
@ -32,13 +32,13 @@ uniform vec3 eyeLook;
uniform float aspectRatio;
#endif
#ifdef _CompoFXAA
#ifdef _CFXAA
uniform vec2 texStep;
#elif _CompoDOF
#elif _CDOF
uniform vec2 texStep;
#endif
#ifdef _CompoGrain
#ifdef _CGrain
uniform float time;
#endif
@ -47,12 +47,12 @@ uniform float dynamicScale;
#endif
in vec2 texCoord;
// #ifdef _CompoPos
// #ifdef _CPos
// in vec3 viewRay;
// #endif
out vec4 fragColor;
#ifdef _CompoFog
#ifdef _CFog
// const vec3 compoFogColor = vec3(0.5, 0.6, 0.7);
// const float compoFogAmountA = 1.0; // b = 0.01
// const float compoFogAmountB = 1.0; // c = 0.1
@ -76,7 +76,7 @@ float vignette() {
return 0.3 + 0.7 * pow(16.0 * texCoord.x * texCoord.y * (1.0 - texCoord.x) * (1.0 - texCoord.y), 0.2);
}
#ifdef _CompoGlare
#ifdef _CGlare
// Based on lense flare implementation by musk
// https://www.shadertoy.com/view/4sX3Rs
vec3 lensflare(vec2 uv, vec2 pos) {
@ -114,7 +114,7 @@ void main() {
texCo *= dynamicScale;
#endif
#ifdef _CompoFishEye
#ifdef _CFishEye
const float fishEyeStrength = -0.01;
const vec2 m = vec2(0.5, 0.5);
vec2 d = texCo - m;
@ -131,11 +131,11 @@ void main() {
}
#endif
#ifdef _CompoDepth
#ifdef _CDepth
float depth = texture(gbufferD, texCo).r * 2.0 - 1.0;
#endif
#ifdef _CompoFXAA
#ifdef _CFXAA
const float FXAA_REDUCE_MIN = 1.0 / 128.0;
const float FXAA_REDUCE_MUL = 1.0 / 8.0;
const float FXAA_SPAN_MAX = 8.0;
@ -186,7 +186,7 @@ void main() {
#else
#ifdef _CompoDOF
#ifdef _CDOF
vec3 col = dof(texCo, depth, tex, gbufferD, texStep);
#else
vec3 col = texture(tex, texCo).rgb;
@ -194,7 +194,7 @@ void main() {
#endif
#ifdef _CompoFog
#ifdef _CFog
// if (depth < 1.0) {
// vec3 pos = getPos(depth);
// float dist = distance(pos, eye);
@ -205,7 +205,7 @@ void main() {
// }
#endif
#ifdef _CompoGlare
#ifdef _CGlare
if (dot(light, eyeLook) > 0.0) { // Facing light
vec4 lndc = VP * vec4(light, 1.0);
lndc.xy /= lndc.w;
@ -221,21 +221,21 @@ void main() {
}
#endif
#ifdef _CompoGrain
#ifdef _CGrain
// const float compoGrainStrength = 4.0;
float x = (texCo.x + 4.0) * (texCo.y + 4.0) * (time * 10.0);
col.rgb += vec3(mod((mod(x, 13.0) + 1.0) * (mod(x, 123.0) + 1.0), 0.01) - 0.005) * compoGrainStrength;
#endif
#ifdef _CompoVignette
#ifdef _CVignette
col.rgb *= vignette();
#endif
#ifdef _CompoExposure
#ifdef _CExposure
col.rgb *= compoExposureStrength;
#endif
#ifdef _CompoTonemap
#ifdef _CTonemap
col.rgb = tonemapUncharted2(col.rgb);
// col.rgb = tonemapFilmic(col.rgb); // With gamma
#endif
@ -243,22 +243,22 @@ void main() {
// To gamma
col.rgb = pow(col.rgb, vec3(1.0 / 2.2));
#ifdef _CompoBW
#ifdef _CBW
// col.rgb = vec3(clamp(dot(col.rgb, col.rgb), 0.0, 1.0));
col.rgb = vec3((col.r * 0.3 + col.g * 0.59 + col.b * 0.11) / 3.0) * 2.5;
#endif
// #ifdef _CompoContrast
// #ifdef _CContrast
// -0.5 - 0.5
// const float compoContrast = 0.2;
// col.rgb = ((col.rgb - 0.5) * max(compoContrast + 1.0, 0.0)) + 0.5;
// #endif
// #ifdef _CompoBrighness
// #ifdef _CBrighness
// col.rgb += compoBrightness;
// #endif
#ifdef _CompoLetterbox
#ifdef _CLetterbox
// const float compoLetterboxSize = 0.1;
col.rgb *= 1.0 - step(0.5 - compoLetterboxSize, abs(0.5 - texCo.y));
#endif

View file

@ -9,54 +9,54 @@
{
"name": "eye",
"link": "_cameraPosition",
"ifdef": ["_CompoGlare"]
"ifdef": ["_CGlare"]
},
{
"name": "eye",
"link": "_cameraPosition",
"ifdef": ["_Disabled_CompoPos"]
"ifdef": ["_Disabled_CPos"]
},
{
"name": "eyeLook",
"link": "_cameraLook",
"ifdef": ["_CompoGlare"]
"ifdef": ["_CGlare"]
},
{
"name": "eyeLook",
"link": "_cameraLook",
"ifdef": ["_Disabled_CompoPos"]
"ifdef": ["_Disabled_CPos"]
},
{
"name": "invVP",
"link": "_inverseViewProjectionMatrix",
"ifdef": ["_Disabled_CompoPos"]
"ifdef": ["_Disabled_CPos"]
},
{
"name": "light",
"link": "_lampPosition",
"ifdef": ["_CompoGlare"]
"ifdef": ["_CGlare"]
},
{
"name": "VP",
"link": "_viewProjectionMatrix",
"ifdef": ["_CompoGlare"]
"ifdef": ["_CGlare"]
},
{
"name": "time",
"link": "_time",
"ifdef": ["_CompoGrain"]
"ifdef": ["_CGrain"]
},
{
"name": "texStep",
"link": "_screenSizeInv",
"ifdef": ["_CompoFXAA", "_CompoDOF"]
"ifdef": ["_CFXAA", "_CDOF"]
},
{
"name": "texStep",
"link": "_screenSizeInv",
"ifdef": ["_CompoFXAA"]
"ifdef": ["_CFXAA"]
},
@ -68,7 +68,7 @@
{
"name": "aspectRatio",
"link": "_aspectRatioF",
"ifdef": ["_CompoGlare"]
"ifdef": ["_CGlare"]
}
],
"texture_params": [],

View file

@ -4,7 +4,7 @@
precision highp float;
#endif
// #ifdef _CompoPos
// #ifdef _CPos
// uniform mat4 invVP;
// uniform vec3 eye;
// #endif
@ -12,7 +12,7 @@ precision highp float;
in vec2 pos;
out vec2 texCoord;
// #ifdef _CompoPos
// #ifdef _CPos
// out vec3 viewRay;
// #endif
@ -23,7 +23,7 @@ void main() {
gl_Position = vec4(pos.xy, 0.0, 1.0);
// #ifdef _CompoPos
// #ifdef _CPos
// NDC (at the back of cube)
// vec4 v = vec4(pos.xy, 1.0, 1.0);
// v = vec4(invVP * v);

View file

@ -1,131 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#include "../std/gbuffer.glsl"
// octahedronWrap()
uniform sampler2D gbufferD;
#ifdef _BaseTex
uniform sampler2D sbase;
#endif
#ifdef _NorTex
uniform sampler2D snormal;
#endif
#ifdef _RoughTex
uniform sampler2D srough;
#else
uniform float roughness;
#endif
#ifdef _MetTex
uniform sampler2D smetal;
#else
uniform float metalness;
#endif
// uniform vec2 screenSize;
uniform mat4 invVP;
uniform mat4 invW;
uniform mat4 V;
in vec4 wvpposition;
in vec4 matColor;
// in vec3 orientation;
out vec4[2] fragColor;
mat3 cotangentFrame(vec3 nor, vec3 pos, vec2 uv) {
// Get edge vectors of the pixel triangle
vec3 dp1 = dFdx(pos);
vec3 dp2 = dFdy(pos);
vec2 duv1 = dFdx(uv);
vec2 duv2 = dFdy(uv);
// Solve the linear system
vec3 dp2perp = cross(dp2, nor);
vec3 dp1perp = cross(nor, dp1);
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
// Construct a scale-invariant frame
float invmax = inversesqrt(max(dot(T,T), dot(B,B)));
return mat3(T * invmax, B * invmax, nor);
}
vec4 reconstructPos(float depth, vec2 uv) {
vec4 sPos = vec4(uv * 2.0 - 1.0, depth, 1.0);
sPos = invVP * sPos;
return vec4((sPos.xyz / sPos.w), 1.0);
}
void main() {
vec2 screenPosition = wvpposition.xy / wvpposition.w;
vec2 depthUV = screenPosition * 0.5 + 0.5;
// depthUV += vec2(0.5 / screenSize); // Half pixel offset
float depth = texture(gbufferD, depthUV).r * 2.0 - 1.0;
vec4 worldPos = reconstructPos(depth, depthUV);
// Angle reject
// Reconstruct normal
// vec3 dnor = normalize(cross(dFdx(worldPos.xyz), dFdy(worldPos.xyz)));
// Get decal box orientation
// vec3 orientation = vec3(1.0, 0.0, 0.0);
// if (dot(dnor, orientation) < cos(3.1415)) discard;
vec4 localPos = invW * worldPos;
localPos.y *= -1.0;
if (abs(localPos.x) > 1.0) discard;
if (abs(localPos.y) > 1.0) discard;
if (abs(localPos.z) > 1.0) discard;
vec2 texCoord = (localPos.xy / 2.0) - 0.5; // / 2.0 - adjust decal box size
#ifdef _BaseTex
vec4 baseColor = texture(sbase, texCoord) * matColor;
#else
vec4 baseColor = matColor;
#endif
// Alpha write is disabled in shader res, we acces all channels for blending
// Use separate texture for base color in the future
fragColor[1].rgb = baseColor.rgb;
fragColor[1].a = baseColor.a;
#ifdef _MetTex
float metalness = texture(smetal, texCoord).r;
#endif
#ifdef _RoughTex
float roughness = texture(srough, texCoord).r;
#endif
#ifdef _NorTex
vec3 normal = texture(snormal, texCoord).rgb * 2.0 - 1.0;
vec3 nn = normalize(normal);
vec3 dp1 = dFdx(worldPos.xyz);
vec3 dp2 = dFdy(worldPos.xyz);
vec2 duv1 = dFdx(texCoord);
vec2 duv2 = dFdy(texCoord);
vec3 dp2perp = cross(dp2, nn);
vec3 dp1perp = cross(nn, dp1);
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
float invmax = inversesqrt(max(dot(T,T), dot(B,B)));
mat3 TBN = mat3(T * invmax, B * invmax, nn);
vec3 n = normalize(TBN * nn);
n /= (abs(n.x) + abs(n.y) + abs(n.z));
n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);
fragColor[0].rg = n.xy;
#else
fragColor[0].rg = vec2(1.0);
#endif
fragColor[0].b = 0.0; // Unused for now so we can rewrite it
// Use separete RG texture for normal storage in the future
// Color mask does not disable write for all buffers so mask is overwritten
// Half of color alpha to soft normals blend
fragColor[0].a = baseColor.a / 2.0;
}

View file

@ -1,47 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#ifdef _NorTex
#define _BaseTex
#endif
#ifdef _RampID
#include "../std/math.glsl"
// hash()
#endif
in vec3 pos;
uniform mat4 VP;
uniform mat4 W;
// uniform mat4 WV;
uniform vec4 baseCol;
#ifdef _RampID
uniform vec4 baseCol2;
uniform int uid;
#endif
out vec4 wvpposition;
out vec4 matColor;
// out vec3 orientation;
void main() {
vec4 sPos = vec4(pos, 1.0);
wvpposition = VP * W * sPos;
// orientation = normalize(WV[1].xyz);
#ifdef _RampID
vec2 p = vec2(float(uid), float(uid));
float factor = hash(p);
matColor = mix(baseCol, baseCol2, factor);
#else
matColor = baseCol;
#endif
gl_Position = wvpposition;
}

View file

@ -1,460 +0,0 @@
{
"contexts": [
{
"name": "mesh",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "WVP",
"link": "_worldViewProjectionMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "P",
"link": "_projectionMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "WV",
"link": "_worldViewMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "prevWVP",
"link": "_prevWorldViewProjectionMatrix",
"ifdef": ["_Veloc"]
},
{
"name": "W",
"link": "_worldMatrix",
"ifdef": ["_Probes"]
},
{
"name": "probeVolumeCenter",
"link": "_probeVolumeCenter",
"ifdef": ["_Probes"]
},
{
"name": "probeVolumeSize",
"link": "_probeVolumeSize",
"ifdef": ["_Probes"]
},
{
"name": "probeID",
"link": "_probeID",
"ifdef": ["_Probes"]
},
{
"name": "probeStrength",
"link": "_probeStrength",
"ifdef": ["_Probes"]
},
{
"name": "probeBlending",
"link": "_probeBlending",
"ifdef": ["_Probes"]
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "mesh.vert.glsl",
"fragment_shader": "mesh.frag.glsl"
},
{
"name": "meshheight",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "WVP",
"link": "_worldViewProjectionMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "P",
"link": "_projectionMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "WV",
"link": "_worldViewMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "prevWVP",
"link": "_prevWorldViewProjectionMatrix",
"ifdef": ["_Veloc"]
},
{
"name": "W",
"link": "_worldMatrix",
"ifdef": ["_Probes"]
},
{
"name": "probeVolumeCenter",
"link": "_probeVolumeCenter",
"ifdef": ["_Probes"]
},
{
"name": "probeVolumeSize",
"link": "_probeVolumeSize",
"ifdef": ["_Probes"]
},
{
"name": "probeID",
"link": "_probeID",
"ifdef": ["_Probes"]
},
{
"name": "probeStrength",
"link": "_probeStrength",
"ifdef": ["_Probes"]
},
{
"name": "probeBlending",
"link": "_probeBlending",
"ifdef": ["_Probes"]
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "meshheight.vert.glsl",
"fragment_shader": "meshheight.frag.glsl",
"fragment_shader_path": "mesh.frag.glsl",
"tesscontrol_shader": "meshheight.tesc.glsl",
"tesseval_shader": "meshheight.tese.glsl"
},
{
"name": "overlay",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
},
{
"name": "sltcMat",
"link": "_ltcMat",
"ifdef": ["_PolyLight"]
},
{
"name": "sltcMag",
"link": "_ltcMag",
"ifdef": ["_PolyLight"]
}
],
"vertex_shader": "overlay.vert.glsl",
"vertex_shader_path": "../include/overlay.vert.glsl",
"fragment_shader": "overlay.frag.glsl",
"fragment_shader_path": "../include/overlay.frag.glsl"
},
{
"name": "shadowmap",
"depth_write": true,
"compare_mode": "less_equal",
"cull_mode": "clockwise",
"links": [
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "shadowmap.vert.glsl",
"vertex_shader_path": "../include/shadowmap.vert.glsl",
"fragment_shader": "shadowmap.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl"
},
{
"name": "shadowmapheight",
"depth_write": true,
"compare_mode": "less_equal",
"cull_mode": "clockwise",
"links": [
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "shadowmapheight.vert.glsl",
"vertex_shader_path": "../include/shadowmapheight.vert.glsl",
"fragment_shader": "shadowmapheight.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl",
"tesscontrol_shader": "shadowmapheight.tesc.glsl",
"tesscontrol_shader_path": "../include/shadowmapheight.tesc.glsl",
"tesseval_shader": "shadowmapheight.tese.glsl",
"tesseval_shader_path": "../include/shadowmapheight.tese.glsl"
},
{
"name": "decals",
"depth_write": false,
"compare_mode": "less",
"cull_mode": "clockwise",
"blend_source": "source_alpha",
"blend_destination": "inverse_source_alpha",
"blend_operation": "add",
"color_write_alpha": false,
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "VP",
"link": "_viewProjectionMatrix"
},
{
"name": "invVP",
"link": "_inverseViewProjectionMatrix"
},
{
"name": "invW",
"link": "_inverseWorldMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "screenSize",
"link": "_screenSize",
"ifdef": ["_Disabled"]
},
{
"name": "uid",
"link": "_uid",
"ifdef": ["_RampID"]
}
],
"texture_params": [],
"vertex_shader": "decals.vert.glsl",
"fragment_shader": "decals.frag.glsl"
},
{
"name": "translucent",
"depth_write": false,
"compare_mode": "less",
"cull_mode": "clockwise",
"blend_source": "blend_one",
"blend_destination": "blend_one",
"blend_operation": "add",
"alpha_blend_source": "blend_zero",
"alpha_blend_destination": "inverse_source_alpha",
"alpha_blend_operation": "add",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix",
"ifndef": "_NoShadows"
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias",
"ifndef": "_NoShadows"
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "spotlightCutoff",
"link": "_spotlampCutoff"
},
{
"name": "spotlightExponent",
"link": "_spotlampExponent"
},
{
"name": "lightType",
"link": "_lampType"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
}
],
"texture_params": [],
"vertex_shader": "translucent.vert.glsl",
"vertex_shader_path": "../include/translucent.vert.glsl",
"fragment_shader": "translucent.frag.glsl",
"fragment_shader_path": "../include/translucent.frag.glsl"
},
{
"name": "voxel",
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "PX",
"link": "_projectionXMatrix"
},
{
"name": "PY",
"link": "_projectionYMatrix"
},
{
"name": "PZ",
"link": "_projectionZMatrix"
}
],
"texture_params": [],
"vertex_shader": "voxel.vert.glsl",
"vertex_shader_path": "../include/voxel.vert.glsl",
"fragment_shader": "voxel.frag.glsl",
"fragment_shader_path": "../include/voxel.frag.glsl",
"geometry_shader": "voxel.geom.glsl",
"geometry_shader_path": "../include/voxel.geom.glsl"
}
]
}

View file

@ -1,175 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#include "../std/gbuffer.glsl"
// octahedronWrap()
// packFloat()
// uniform float mask;
#ifdef _BaseTex
uniform sampler2D sbase;
#endif
#ifdef _NorTex
uniform sampler2D snormal;
#endif
#ifdef _NorStr
uniform float normalStrength;
#endif
#ifdef _OccTex
uniform sampler2D socclusion;
#else
uniform float occlusion;
#endif
#ifdef _RoughTex
uniform sampler2D srough;
#else
uniform float roughness;
#endif
#ifdef _RoughStr
uniform float roughnessStrength;
#endif
#ifdef _MetTex
uniform sampler2D smetal;
#else
uniform float metalness;
#endif
#ifdef _Probes
uniform int probeID;
uniform float probeBlending;
uniform float probeStrength;
uniform vec3 probeVolumeCenter;
uniform vec3 probeVolumeSize;
#endif
in vec4 matColor;
#ifdef _Tex
in vec2 texCoord;
#endif
#ifdef _Tex1
in vec2 texCoord1;
#endif
#ifdef _NorTex
in mat3 TBN;
#else
in vec3 normal;
#endif
#ifdef _Probes
in vec4 wpos;
#endif
#ifdef _Veloc
in vec4 wvppos;
in vec4 prevwvppos;
#endif
#ifdef _Veloc
out vec4[3] fragColor;
#else
out vec4[2] fragColor;
#endif
#ifdef _Probes
float distanceBox(vec3 point, vec3 center, vec3 halfExtents) {
vec3 d = abs(point - center) - halfExtents;
return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0));
}
#endif
void main() {
#ifdef _NorTex
#ifdef _NorTex1
vec3 n = texture(snormal, texCoord1).rgb * 2.0 - 1.0;
#else
vec3 n = texture(snormal, texCoord).rgb * 2.0 - 1.0;
#endif
n = normalize(TBN * normalize(n));
#else
vec3 n = normalize(normal);
#endif
#ifdef _NorStr
n *= normalStrength;
#endif
vec3 baseColor = matColor.rgb;
#ifdef _BaseTex
#ifdef _BaseTex1
vec4 texel = texture(sbase, texCoord1);
#else
vec4 texel = texture(sbase, texCoord);
#endif
// #ifdef _AlphaTest
// if(texel.a < 0.4)
// discard;
// #endif
texel.rgb = pow(texel.rgb, vec3(2.2)); // Variant 1
baseColor *= texel.rgb;
#endif
#ifdef _MetTex
#ifdef _MetTex1
float metalness = texture(smetal, texCoord1).r;
#else
float metalness = texture(smetal, texCoord).r;
#endif
#endif
#ifdef _RoughTex
#ifdef _RoughTex1
float roughness = texture(srough, texCoord1).r;
#else
float roughness = texture(srough, texCoord).r;
#endif
#endif
#ifdef _RoughStr
roughness *= roughnessStrength;
#endif
#ifdef _OccTex
#ifdef _OccTex1
float occ = texture(socclusion, texCoord1).r;
#else
float occ = texture(socclusion, texCoord).r;
#endif
#else
float occ = occlusion;
#endif
// Pack normal
n /= (abs(n.x) + abs(n.y) + abs(n.z));
n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);
#ifdef _Probes
float mask_probe;
if (probeID > 0) { // Non-global probe attached
// Distance of vertex located inside probe to probe bounds
float dist = distanceBox(wpos.xyz, probeVolumeCenter, probeVolumeSize);
if (dist > 0) mask_probe = 0;
else {
// Blend local probe with global probe
const float eps = 0.00001;
float clampres = clamp(probeBlending + dist, 0.0, 1.0 - eps);
mask_probe = probeID + clampres;
}
}
fragColor[0] = vec4(n.xy, packFloat(metalness, roughness), mask_probe);
#else
// fragColor[0] = vec4(n.xy, packFloat(metalness, roughness), mask);
// TODO: Can not read and test depth buffer at once, fetch depth from g0
fragColor[0] = vec4(n.xy, packFloat(metalness, roughness), 1.0 - gl_FragCoord.z);
#endif
fragColor[1] = vec4(baseColor.rgb, occ);
#ifdef _Veloc
vec2 posa = (wvppos.xy / wvppos.w) * 0.5 + 0.5;
vec2 posb = (prevwvppos.xy / prevwvppos.w) * 0.5 + 0.5;
fragColor[2].rg = vec2(posa - posb);
#endif
}

View file

@ -1,134 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
in vec3 pos;
in vec3 nor;
#ifdef _Tex
in vec2 tex;
#endif
#ifdef _Tex1
in vec2 tex1;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 WVP;
uniform mat4 N;
uniform vec4 baseCol;
#ifdef _Billboard
uniform mat4 WV;
uniform mat4 P;
#endif
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
#ifdef _Probes
uniform mat4 W;
#endif
#ifdef _Veloc
uniform mat4 prevWVP;
#endif
out vec4 matColor;
#ifdef _Tex
out vec2 texCoord;
#endif
#ifdef _Tex1
out vec2 texCoord1;
#endif
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
#ifdef _Probes
out vec4 wpos;
#endif
#ifdef _Veloc
out vec4 wvppos;
out vec4 prevwvppos;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
vec3 _normal = normalize(mat3(N) * (nor + 2.0 * cross(skinA.xyz, cross(skinA.xyz, nor) + skinA.w * nor)));
#else
vec3 _normal = normalize(mat3(N) * nor);
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
#ifdef _Probes
wpos = W * sPos;
#endif
#ifdef _Billboard
mat4 constrWV = WV;
// Spherical
constrWV[0][0] = 1.0; constrWV[0][1] = 0.0; constrWV[0][2] = 0.0;
constrWV[1][0] = 0.0; constrWV[1][1] = 1.0; constrWV[1][2] = 0.0;
constrWV[2][0] = 0.0; constrWV[2][1] = 0.0; constrWV[2][2] = 1.0;
// Cylindrical
//constrWV[0][0] = 1.0; constrWV[0][1] = 0.0; constrWV[0][2] = 0.0;
//constrWV[2][0] = 0.0; constrWV[2][1] = 0.0; constrWV[2][2] = 1.0;
gl_Position = P * constrWV * sPos;
#else
gl_Position = WVP * sPos;
#endif
#ifdef _Veloc
wvppos = gl_Position;
prevwvppos = prevWVP * sPos;
#endif
#ifdef _Tex
texCoord = tex;
#endif
#ifdef _Tex1
texCoord1 = tex1;
#endif
matColor = baseCol;
#ifdef _VCols
matColor.rgb *= col;
// matColor.rgb *= pow(col, vec3(2.2));
#endif
#ifdef _NorTex
vec3 tangent = normalize(mat3(N) * (tan));
vec3 bitangent = normalize(cross(_normal, tangent)); // Use cross() * tangent.w for handedness
TBN = mat3(tangent, bitangent, _normal);
#else
normal = _normal;
#endif
}

View file

@ -1,52 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(vertices = 3) out;
in vec3 v_position[];
in vec2 v_texCoord[];
#ifdef _Tex1
in vec2 v_texCoord1[];
#endif
in vec3 v_normal[];
#ifdef _NorTex
in vec3 v_tangent[];
#endif
out vec3 tc_position[];
out vec2 tc_texCoord[];
#ifdef _Tex1
out vec2 tc_texCoord1[];
#endif
out vec3 tc_normal[];
#ifdef _NorTex
out vec3 tc_tangent[];
#endif
uniform float innerLevel;
uniform float outerLevel;
#define ID gl_InvocationID
void main() {
tc_position[ID] = v_position[ID];
tc_texCoord[ID] = v_texCoord[ID];
#ifdef _Tex1
tc_texCoord1[ID] = v_texCoord1[ID];
#endif
tc_normal[ID] = v_normal[ID];
#ifdef _NorTex
tc_tangent[ID] = v_tangent[ID];
#endif
if (ID == 0) {
gl_TessLevelInner[0] = innerLevel;
gl_TessLevelInner[1] = innerLevel;
gl_TessLevelOuter[0] = outerLevel;
gl_TessLevelOuter[1] = outerLevel;
gl_TessLevelOuter[2] = outerLevel;
gl_TessLevelOuter[3] = outerLevel;
}
}

View file

@ -1,81 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(triangles, equal_spacing, ccw) in;
in vec3 tc_position[];
in vec2 tc_texCoord[];
#ifdef _Tex1
in vec2 tc_texCoord1[];
#endif
in vec3 tc_normal[];
#ifdef _NorTex
in vec3 tc_tangent[];
#endif
out vec4 matColor;
out vec2 texCoord;
#ifdef _Tex1
out vec2 texCoord1;
#endif
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
uniform mat4 WVP;
uniform mat4 N;
uniform sampler2D sheight;
uniform float heightStrength;
void main() {
matColor = vec4(1.0);
vec3 p0 = gl_TessCoord.x * tc_position[0];
vec3 p1 = gl_TessCoord.y * tc_position[1];
vec3 p2 = gl_TessCoord.z * tc_position[2];
vec3 te_position = p0 + p1 + p2;
vec3 n0 = gl_TessCoord.x * tc_normal[0];
vec3 n1 = gl_TessCoord.y * tc_normal[1];
vec3 n2 = gl_TessCoord.z * tc_normal[2];
vec3 _normal = normalize(n0 + n1 + n2);
vec2 tc0 = gl_TessCoord.x * tc_texCoord[0];
vec2 tc1 = gl_TessCoord.y * tc_texCoord[1];
vec2 tc2 = gl_TessCoord.z * tc_texCoord[2];
texCoord = tc0 + tc1 + tc2;
#ifdef _Tex1
vec2 tc01 = gl_TessCoord.x * tc_texCoord1[0];
vec2 tc11 = gl_TessCoord.y * tc_texCoord1[1];
vec2 tc21 = gl_TessCoord.z * tc_texCoord1[2];
texCoord1 = tc01 + tc11 + tc21;
#endif
#ifdef _HeightTex1
te_position += _normal * texture(sheight, texCoord1).r * heightStrength;
#else
te_position += _normal * texture(sheight, texCoord).r * heightStrength;
#endif
_normal = normalize(mat3(N) * _normal);
#ifdef _NorTex
vec3 t0 = gl_TessCoord.x * tc_tangent[0];
vec3 t1 = gl_TessCoord.y * tc_tangent[1];
vec3 t2 = gl_TessCoord.z * tc_tangent[2];
vec3 te_tangent = normalize(t0 + t1 + t2);
vec3 tangent = normalize(mat3(N) * (te_tangent));
vec3 bitangent = normalize(cross(_normal, tangent));
TBN = mat3(tangent, bitangent, _normal);
#else
normal = _normal;
#endif
gl_Position = WVP * vec4(te_position, 1.0);
}

View file

@ -1,73 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
in vec3 pos;
in vec3 nor;
in vec2 tex;
#ifdef _Tex1
in vec2 tex1;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
out vec3 v_position;
out vec3 v_normal;
out vec2 v_texCoord;
#ifdef _Tex1
out vec2 v_texCoord1;
#endif
// #ifdef _VCols
// out vec3 v_color;
// #endif
#ifdef _NorTex
out vec3 v_tangent;
#endif
// #ifdef _Skinning
// out vec4 v_bone;
// out vec4 v_weight;
// #endif
// uniform sampler2D sheight;
// uniform float heightStrength;
void main() {
v_position = pos;
#ifdef _Instancing
v_position += off;
#endif
v_texCoord = tex;
#ifdef _Tex1
v_texCoord1 = tex1;
#endif
v_normal = nor;
#ifdef _NorTex
v_tangent = tan;
#endif
// v_position += v_normal * texture(sheight, tex).r * heightStrength;
// #ifdef _VCols
// v_color = col;
// #endif
// #ifdef _Skinning
// v_bone = bone;
// v_weight = weight;
// #endif
}

View file

@ -1,565 +0,0 @@
{
"contexts": [
{
"name": "mesh",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix",
"ifndef": "_NoShadows"
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias"
},
{
"name": "spotlightCutoff",
"link": "_spotlampCutoff"
},
{
"name": "spotlightExponent",
"link": "_spotlampExponent"
},
{
"name": "lightType",
"link": "_lampType"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
},
{
"name": "U",
"link": "_undistortionMatrix",
"ifdef": ["_VR"]
},
{
"name": "maxRadSq",
"link": "_maxRadiusSq",
"ifdef": ["_VR"]
},
{
"name": "snoise",
"link": "_noise64",
"ifdef": ["_PCSS"]
},
{
"name": "lampSizeUV",
"link": "_lampSizeUV",
"ifdef": ["_PCSS"]
},
{
"name": "lampArea0",
"link": "_lampArea0",
"ifdef": ["_PolyLight"]
},
{
"name": "lampArea1",
"link": "_lampArea1",
"ifdef": ["_PolyLight"]
},
{
"name": "lampArea2",
"link": "_lampArea2",
"ifdef": ["_PolyLight"]
},
{
"name": "lampArea3",
"link": "_lampArea3",
"ifdef": ["_PolyLight"]
},
{
"name": "sltcMat",
"link": "_ltcMat",
"ifdef": ["_PolyLight"]
},
{
"name": "sltcMag",
"link": "_ltcMag",
"ifdef": ["_PolyLight"]
}
],
"vertex_shader": "mesh.vert.glsl",
"fragment_shader": "mesh.frag.glsl"
},
{
"name": "meshheight",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "WVP",
"link": "_worldViewProjectionMatrix"
},
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix",
"ifndef": "_NoShadows"
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias"
},
{
"name": "spotlightCutoff",
"link": "_spotlampCutoff"
},
{
"name": "spotlightExponent",
"link": "_spotlampExponent"
},
{
"name": "lightType",
"link": "_lampType"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
},
{
"name": "U",
"link": "_undistortionMatrix",
"ifdef": ["_VR"]
},
{
"name": "maxRadSq",
"link": "_maxRadiusSq",
"ifdef": ["_VR"]
},
{
"name": "snoise",
"link": "_noise64",
"ifdef": ["_PCSS"]
},
{
"name": "lampSizeUV",
"link": "_lampSizeUV",
"ifdef": ["_PCSS"]
},
{
"name": "lampArea0",
"link": "_lampArea0",
"ifdef": ["_PolyLight"]
},
{
"name": "lampArea1",
"link": "_lampArea1",
"ifdef": ["_PolyLight"]
},
{
"name": "lampArea2",
"link": "_lampArea2",
"ifdef": ["_PolyLight"]
},
{
"name": "lampArea3",
"link": "_lampArea3",
"ifdef": ["_PolyLight"]
},
{
"name": "sltcMat",
"link": "_ltcMat",
"ifdef": ["_PolyLight"]
},
{
"name": "sltcMag",
"link": "_ltcMag",
"ifdef": ["_PolyLight"]
}
],
"vertex_shader": "meshheight.vert.glsl",
"fragment_shader": "meshheight.frag.glsl",
"fragment_shader_path": "mesh.frag.glsl",
"tesscontrol_shader": "meshheight.tesc.glsl",
"tesseval_shader": "meshheight.tese.glsl"
},
{
"name": "overlay",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
},
{
"name": "sltcMat",
"link": "_ltcMat",
"ifdef": ["_PolyLight"]
},
{
"name": "sltcMag",
"link": "_ltcMag",
"ifdef": ["_PolyLight"]
}
],
"vertex_shader": "overlay.vert.glsl",
"vertex_shader_path": "../include/overlay.vert.glsl",
"fragment_shader": "overlay.frag.glsl",
"fragment_shader_path": "../include/overlay.frag.glsl"
},
{
"name": "shadowmap",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "shadowmap.vert.glsl",
"vertex_shader_path": "../include/shadowmap.vert.glsl",
"fragment_shader": "shadowmap.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl"
},
{
"name": "shadowmapheight",
"depth_write": true,
"compare_mode": "less_equal",
"cull_mode": "clockwise",
"links": [
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "shadowmapheight.vert.glsl",
"vertex_shader_path": "../include/shadowmapheight.vert.glsl",
"fragment_shader": "shadowmapheight.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl",
"tesscontrol_shader": "shadowmapheight.tesc.glsl",
"tesscontrol_shader_path": "../include/shadowmapheight.tesc.glsl",
"tesseval_shader": "shadowmapheight.tese.glsl",
"tesseval_shader_path": "../include/shadowmapheight.tese.glsl"
},
{
"name": "translucent",
"depth_write": false,
"compare_mode": "less",
"cull_mode": "clockwise",
"blend_source": "blend_one",
"blend_destination": "blend_one",
"blend_operation": "add",
"alpha_blend_source": "blend_zero",
"alpha_blend_destination": "inverse_source_alpha",
"alpha_blend_operation": "add",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix",
"ifndef": "_NoShadows"
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias",
"ifndef": "_NoShadows"
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "spotlightCutoff",
"link": "_spotlampCutoff"
},
{
"name": "spotlightExponent",
"link": "_spotlampExponent"
},
{
"name": "lightType",
"link": "_lampType"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
}
],
"texture_params": [],
"vertex_shader": "translucent.vert.glsl",
"vertex_shader_path": "../include/translucent.vert.glsl",
"fragment_shader": "translucent.frag.glsl",
"fragment_shader_path": "../include/translucent.frag.glsl"
},
{
"name": "voxel",
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "PX",
"link": "_projectionXMatrix"
},
{
"name": "PY",
"link": "_projectionYMatrix"
},
{
"name": "PZ",
"link": "_projectionZMatrix"
}
],
"texture_params": [],
"vertex_shader": "voxel.vert.glsl",
"vertex_shader_path": "../include/voxel.vert.glsl",
"fragment_shader": "voxel.frag.glsl",
"fragment_shader_path": "../include/voxel.frag.glsl",
"geometry_shader": "voxel.geom.glsl",
"geometry_shader_path": "../include/voxel.geom.glsl"
}
]
}

View file

@ -1,423 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#include "../compiled.glsl"
#include "../std/brdf.glsl"
#ifdef _PolyLight
#include "../std/ltc.glsl"
#endif
#ifdef _Rad
#include "../std/math.glsl"
#endif
#ifndef _NoShadows
#ifdef _PCSS
#include "../std/shadows_pcss.glsl"
// PCSS()
#else
#include "../std/shadows.glsl"
// PCF()
#endif
#endif
#include "../std/shirr.glsl"
// shIrradiance()
//!uniform float shirr[27];
#ifdef _PolyLight
//!uniform sampler2D sltcMat;
//!uniform sampler2D sltcMag;
#endif
#ifdef _BaseTex
uniform sampler2D sbase;
#endif
#ifndef _NoShadows
//!uniform sampler2D shadowMap;
#ifdef _PCSS
//!uniform sampler2D snoise;
//!uniform float lampSizeUV;
#endif
#endif
#ifdef _Rad
uniform sampler2D senvmapRadiance;
uniform sampler2D senvmapBrdf;
uniform int envmapNumMipmaps;
#endif
#ifdef _NorTex
uniform sampler2D snormal;
#endif
#ifdef _NorStr
uniform float normalStrength;
#endif
#ifdef _OccTex
uniform sampler2D socclusion;
#else
uniform float occlusion;
#endif
#ifdef _RoughTex
uniform sampler2D srough;
#else
uniform float roughness;
#endif
#ifdef _RoughStr
uniform float roughnessStrength;
#endif
#ifdef _MetTex
uniform sampler2D smetal;
#else
uniform float metalness;
#endif
uniform float envmapStrength;
uniform bool receiveShadow;
uniform vec3 lightPos;
uniform vec3 lightDir;
uniform int lightType;
uniform vec3 lightColor;
uniform float spotlightCutoff;
uniform float spotlightExponent;
uniform float shadowsBias;
uniform vec3 eye;
#ifdef _PolyLight
uniform vec3 lampArea0;
uniform vec3 lampArea1;
uniform vec3 lampArea2;
uniform vec3 lampArea3;
#endif
#ifdef _VoxelGI
uniform sampler2D ssaotex;
uniform sampler2D senvmapBrdf;
//!uniform sampler3D voxels;
#endif
in vec3 position;
#ifdef _Tex
in vec2 texCoord;
#endif
#ifdef _Tex1
in vec2 texCoord1;
#endif
#ifndef _NoShadows
in vec4 lampPos;
#endif
in vec4 matColor;
in vec3 eyeDir;
#ifdef _NorTex
in mat3 TBN;
#else
in vec3 normal;
#endif
out vec4 fragColor;
#ifndef _NoShadows
float shadowTest(vec4 lPos) {
lPos.xyz /= lPos.w;
lPos.xy = lPos.xy * 0.5 + 0.5;
#ifdef _PCSS
return PCSS(lPos.xy, lPos.z - shadowsBias);
#else
return PCF(lPos.xy, lPos.z - shadowsBias);
#endif
// return VSM(lPos.xy, lPos.z);
// float distanceFromLight = texture(shadowMap, lPos.xy).r * 2.0 - 1.0;
// return float(distanceFromLight > lPos.z - shadowsBias);
}
#endif
// #ifdef _Toon
// float stepmix(float edge0, float edge1, float E, float x) {
// float T = clamp(0.5 * (x - edge0 + E) / E, 0.0, 1.0);
// return mix(edge0, edge1, T);
// }
// #endif
void main() {
#ifdef _NorTex
#ifdef _NorTex1
vec3 n = texture(snormal, texCoord1).rgb * 2.0 - 1.0;
#else
vec3 n = texture(snormal, texCoord).rgb * 2.0 - 1.0;
#endif
n = normalize(TBN * normalize(n));
// vec3 normal = texture(snormal, texCoord).rgb * 2.0 - 1.0;
// vec3 nn = normalize(normal);
// vec3 dp1 = dFdx(position);
// vec3 dp2 = dFdy(position);
// vec2 duv1 = dFdx(texCoord);
// vec2 duv2 = dFdy(texCoord);
// vec3 dp2perp = cross(dp2, nn);
// vec3 dp1perp = cross(nn, dp1);
// vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
// vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
// float invmax = inversesqrt(max(dot(T,T), dot(B,B)));
// mat3 TBN = mat3(T * invmax, B * invmax, nn);
// vec3 n = (TBN * nn);
#else
vec3 n = normalize(normal);
#endif
#ifdef _NorStr
n *= normalStrength;
#endif
// Move out
vec3 l;
if (lightType == 0) { // Sun
l = lightDir;
}
else { // Point, spot
l = normalize(lightPos - position.xyz);
}
float visibility = 1.0;
#ifndef _NoShadows
if (receiveShadow) {
if (lampPos.w > 0.0) {
visibility = shadowTest(lampPos);
}
}
#endif
vec3 baseColor = matColor.rgb;
#ifdef _BaseTex
#ifdef _BaseTex1
vec4 texel = texture(sbase, texCoord1);
#else
vec4 texel = texture(sbase, texCoord);
#endif
#ifdef _AlphaTest
if (texel.a < 0.4)
discard;
#endif
texel.rgb = pow(texel.rgb, vec3(2.2));
baseColor *= texel.rgb;
#endif
vec3 v = normalize(eyeDir);
vec3 h = normalize(v + l);
float dotNL = dot(n, l);
float dotNV = dot(n, v);
float dotNH = dot(n, h);
float dotVH = dot(v, h);
#ifdef _MetTex
#ifdef _MetTex1
float metalness = texture(smetal, texCoord1).r;
#else
float metalness = texture(smetal, texCoord).r;
#endif
#endif
vec3 albedo = surfaceAlbedo(baseColor, metalness);
vec3 f0 = surfaceF0(baseColor, metalness);
#ifdef _RoughTex
#ifdef _RoughTex1
float roughness = texture(srough, texCoord1).r;
#else
float roughness = texture(srough, texCoord).r;
#endif
#endif
#ifdef _RoughStr
roughness *= roughnessStrength;
#endif
// #ifdef _Toon
// vec3 v = normalize(eyeDir);
// vec3 h = normalize(v + l);
// const vec3 ambientMaterial = baseColor * vec3(0.35, 0.35, 0.35) + vec3(0.15);
// const vec3 diffuseMaterial = baseColor;
// const vec3 specularMaterial = vec3(0.45, 0.35, 0.35);
// const float shininess = 0.5;
// float df = max(0.0, dotNL);
// float sf = max(0.0, dot(n, h));
// sf = pow(sf, shininess);
// const float A = 0.1;
// const float B = 0.3;
// const float C = 0.6;
// const float D = 1.0;
// float E = fwidth(df);
// bool f = false;
// if (df > A - E) if (df < A + E) {
// f = true;
// df = stepmix(A, B, E, df);
// }
// /*else*/if (!f) if (df > B - E) if(df < B + E) {
// f = true;
// df = stepmix(B, C, E, df);
// }
// /*else*/if (!f) if (df > C - E) if (df < C + E) {
// f = true;
// df = stepmix(C, D, E, df);
// }
// /*else*/if (!f) if (df < A) {
// df = 0.0;
// }
// else if (df < B) {
// df = B;
// }
// else if (df < C) {
// df = C;
// }
// else df = D;
// E = fwidth(sf);
// if (sf > 0.5 - E && sf < 0.5 + E) {
// sf = smoothstep(0.5 - E, 0.5 + E, sf);
// }
// else {
// sf = step(0.5, sf);
// }
// fragColor.rgb = ambientMaterial + (df * diffuseMaterial + sf * specularMaterial) * visibility;
// float edgeDetection = (dot(v, n) < 0.1) ? 0.0 : 1.0;
// fragColor.rgb *= edgeDetection;
// // const int levels = 4;
// // const float scaleFactor = 1.0 / levels;
// // float diffuse = max(0, dotNL);
// // const float material_kd = 0.8;
// // const float material_ks = 0.3;
// // vec3 diffuseColor = vec3(0.40, 0.60, 0.70);
// // diffuseColor = diffuseColor * material_kd * floor(diffuse * levels) * scaleFactor;
// // float specular = 0.0;
// // if(dotNL > 0.0) {
// // specular = material_ks * pow( max(0, dot( h, n)), shininess);
// // }
// // // Limit specular
// // float specMask = (pow(dot(h, n), shininess) > 0.4) ? 1.0 : 0.0;
// // float edgeDetection = (dot(v, n) > 0.3) ? 1.0 : 0.0;
// // fragColor.rgb = edgeDetection * ((diffuseColor + specular * specMask) * visibility + ambientMaterial);
// #endif
// Direct
vec3 direct;
#ifdef _PolyLight
if (lightType == 3) { // Area
float theta = acos(dotNV);
vec2 tuv = vec2(roughness, theta / (0.5 * PI));
tuv = tuv * LUT_SCALE + LUT_BIAS;
// vec4 t = texture(sltcMat, tuv);
vec4 t = clamp(texture(sltcMat, tuv), 0.0, 1.0);
mat3 invM = mat3(
vec3(1.0, 0.0, t.y),
vec3(0.0, t.z, 0.0),
vec3(t.w, 0.0, t.x));
vec3 ltcspec = ltcEvaluate(n, v, dotNV, position, invM, lampArea0, lampArea1, lampArea2, lampArea3, false);
ltcspec *= texture(sltcMag, tuv).a;
vec3 ltcdiff = ltcEvaluate(n, v, dotNV, position, mat3(1.0), lampArea0, lampArea1, lampArea2, lampArea3, false);
direct = ltcdiff * albedo + ltcspec;
}
else {
#endif
// Direct
#ifdef _OrenNayar
direct = orenNayarDiffuseBRDF(albedo, roughness, dotNV, dotNL, dotVH) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#else
direct = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#endif
if (lightType == 2) { // Spot
float spotEffect = dot(lightDir, l);
if (spotEffect < spotlightCutoff) {
spotEffect = smoothstep(spotlightCutoff - spotlightExponent, spotlightCutoff, spotEffect);
direct *= spotEffect;
}
}
#ifdef _PolyLight
}
#endif
direct = direct * lightColor;
#ifdef _VoxelGI
vec3 tangent = normalize(cross(n, vec3(0.0, 1.0, 0.0)));
if (length(tangent) == 0.0) {
tangent = normalize(cross(n, vec3(0.0, 0.0, 1.0)));
}
vec3 bitangent = normalize(cross(n, tangent));
mat3 tanToWorld = inverse(transpose(mat3(tangent, bitangent, n)));
float diffOcclusion = 0.0;
vec3 indirectDiffuse = indirectLight(tanToWorld, n, diffOcclusion).rgb * 4.0;
indirectDiffuse *= albedo;
diffOcclusion = min(1.0, 1.5 * diffOcclusion);
vec3 reflectWorld = reflect(-v, n);
float specularOcclusion;
float lodOffset = 0.0;//getMipFromRoughness(roughness, numMips);
vec3 indirectSpecular = coneTrace(reflectWorld, n, 0.07 + lodOffset, specularOcclusion).rgb;
if (roughness > 0.0) { // Temp..
vec2 envBRDF = texture(senvmapBrdf, vec2(roughness, 1.0 - dotNV)).xy;
indirectSpecular *= (f0 * envBRDF.x + envBRDF.y);
}
vec3 indirect = indirectDiffuse * diffOcclusion + indirectSpecular;
#else
// Indirect
vec3 indirectDiffuse = shIrradiance(n, 2.2) / PI;
#ifdef _EnvLDR
indirectDiffuse = pow(indirectDiffuse, vec3(2.2));
#endif
indirectDiffuse *= albedo;
vec3 indirect = indirectDiffuse;
#ifdef _Rad
vec3 reflectionWorld = reflect(-v, n);
float lod = getMipFromRoughness(roughness, envmapNumMipmaps);
vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;
#ifdef _EnvLDR
prefilteredColor = pow(prefilteredColor, vec3(2.2));
#endif
vec2 envBRDF = texture(senvmapBrdf, vec2(roughness, 1.0 - dotNV)).xy;
vec3 indirectSpecular = prefilteredColor * (f0 * envBRDF.x + envBRDF.y);
indirect += indirectSpecular;
#endif
indirect = indirect * envmapStrength;// * lightColor;
#endif
fragColor = vec4(vec3(direct * visibility + indirect), 1.0);
#ifdef _OccTex
#ifdef _OccTex1
float occ = texture(socclusion, texCoord1).r;
#else
float occ = texture(socclusion, texCoord).r;
#endif
fragColor.rgb *= occ;
#else
fragColor.rgb *= occlusion;
#endif
#ifdef _LDR
fragColor = vec4(pow(fragColor.rgb, vec3(1.0 / 2.2)), fragColor.a);
#endif
}

View file

@ -1,141 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
#ifdef _VR
#include "../std/vr.glsl"
// undistort()
#endif
in vec3 pos;
in vec3 nor;
#ifdef _Tex
in vec2 tex;
#endif
#ifdef _Tex1
in vec2 tex1;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 W;
uniform mat4 N;
#ifdef _Billboard
uniform mat4 WV;
uniform mat4 P;
#endif
uniform mat4 V;
uniform mat4 P;
#ifndef _NoShadows
uniform mat4 LWVP;
#endif
uniform vec4 baseCol;
uniform vec3 eye;
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
#ifdef _VR
// !uniform mat4 U;
// !uniform float maxRadSq;
#endif
out vec3 position;
#ifdef _Tex
out vec2 texCoord;
#endif
#ifdef _Tex1
out vec2 texCoord1;
#endif
#ifndef _NoShadows
out vec4 lampPos;
#endif
out vec4 matColor;
out vec3 eyeDir;
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
vec3 _normal = normalize(mat3(N) * (nor + 2.0 * cross(skinA.xyz, cross(skinA.xyz, nor) + skinA.w * nor)));
#else
vec3 _normal = normalize(mat3(N) * nor);
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
#ifndef _NoShadows
lampPos = LWVP * sPos;
#endif
mat4 WV = V * W;
#ifdef _Billboard
// Spherical
WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
WV[1][0] = 0.0; WV[1][1] = 1.0; WV[1][2] = 0.0;
WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
// Cylindrical
//WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
//WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
#endif
#ifdef _VR
gl_Position = P * undistort(WV, sPos);
#else
gl_Position = P * WV * sPos;
#endif
#ifdef _Tex
texCoord = tex;
#endif
#ifdef _Tex1
texCoord1 = tex1;
#endif
matColor = baseCol;
#ifdef _VCols
matColor.rgb *= col;
#endif
position = vec4(W * sPos).xyz;
eyeDir = eye - position;
#ifdef _NorTex
vec3 tangent = (mat3(N) * (tan));
vec3 bitangent = normalize(cross(_normal, tangent));
TBN = mat3(tangent, bitangent, _normal);
#else
normal = _normal;
#endif
}

View file

@ -1,54 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(vertices = 3) out;
in vec3 v_position[];
in vec2 v_texCoord[];
#ifdef _Tex1
in vec2 v_texCoord1[];
#endif
in vec3 v_normal[];
#ifdef _NorTex
in vec3 v_tangent[];
#endif
out vec3 tc_position[];
out vec2 tc_texCoord[];
#ifdef _Tex1
out vec2 tc_texCoord1[];
#endif
out vec3 tc_normal[];
#ifdef _NorTex
out vec3 tc_tangent[];
#endif
uniform float innerLevel;
uniform float outerLevel;
#define ID gl_InvocationID
void main() {
tc_position[ID] = v_position[ID];
tc_texCoord[ID] = v_texCoord[ID];
#ifdef _Tex1
tc_texCoord1[ID] = v_texCoord1[ID];
#endif
tc_normal[ID] = v_normal[ID];
#ifdef _NorTex
tc_tangent[ID] = v_tangent[ID];
#endif
if (ID == 0) {
gl_TessLevelInner[0] = innerLevel;
gl_TessLevelInner[1] = innerLevel;
gl_TessLevelOuter[0] = outerLevel;
gl_TessLevelOuter[1] = outerLevel;
gl_TessLevelOuter[2] = outerLevel;
gl_TessLevelOuter[3] = outerLevel;
}
}

View file

@ -1,98 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(triangles, equal_spacing, ccw) in;
in vec3 tc_position[];
in vec2 tc_texCoord[];
#ifdef _Tex1
in vec2 tc_texCoord1[];
#endif
in vec3 tc_normal[];
#ifdef _NorTex
in vec3 tc_tangent[];
#endif
out vec3 position;
out vec2 texCoord;
#ifdef _Tex1
out vec2 texCoord1;
#endif
#ifndef _NoShadows
out vec4 lampPos;
#endif
out vec4 matColor;
out vec3 eyeDir;
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
uniform mat4 WVP;
uniform mat4 N;
uniform sampler2D sheight;
uniform float heightStrength;
#ifndef _NoShadows
uniform mat4 LWVP;
#endif
uniform mat4 W;
uniform vec3 eye;
uniform vec4 baseCol;
void main() {
vec3 p0 = gl_TessCoord.x * tc_position[0];
vec3 p1 = gl_TessCoord.y * tc_position[1];
vec3 p2 = gl_TessCoord.z * tc_position[2];
vec3 s_position = p0 + p1 + p2;
vec3 n0 = gl_TessCoord.x * tc_normal[0];
vec3 n1 = gl_TessCoord.y * tc_normal[1];
vec3 n2 = gl_TessCoord.z * tc_normal[2];
vec3 _te_normal = normalize(n0 + n1 + n2);
vec2 tc0 = gl_TessCoord.x * tc_texCoord[0];
vec2 tc1 = gl_TessCoord.y * tc_texCoord[1];
vec2 tc2 = gl_TessCoord.z * tc_texCoord[2];
texCoord = tc0 + tc1 + tc2;
#ifdef _Tex1
vec2 tc01 = gl_TessCoord.x * tc_texCoord1[0];
vec2 tc11 = gl_TessCoord.y * tc_texCoord1[1];
vec2 tc21 = gl_TessCoord.z * tc_texCoord1[2];
texCoord1 = tc01 + tc11 + tc21;
#endif
s_position += _te_normal * texture(sheight, texCoord).r * heightStrength;
position = vec4(W * vec4(s_position, 1.0)).xyz;
_te_normal = normalize(mat3(N) * _te_normal);
#ifdef _NorTex
vec3 t0 = gl_TessCoord.x * tc_tangent[0];
vec3 t1 = gl_TessCoord.y * tc_tangent[1];
vec3 t2 = gl_TessCoord.z * tc_tangent[2];
vec3 te_tangent = normalize(t0 + t1 + t2);
vec3 tangent = normalize(mat3(N) * (te_tangent));
vec3 bitangent = normalize(cross(_te_normal, tangent));
TBN = mat3(tangent, bitangent, _te_normal);
#else
normal = _te_normal;
#endif
#ifndef _NoShadows
lampPos = LWVP * vec4(s_position, 1.0);
#endif
matColor = baseCol;
// #ifdef _VCols
// matColor.rgb *= col;
// #endif
eyeDir = eye - position;
gl_Position = WVP * vec4(s_position, 1.0);
}

View file

@ -1,107 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
#ifdef _VR
#include "../std/vr.glsl"
// undistort()
#endif
in vec3 pos;
in vec3 nor;
in vec2 tex;
#ifdef _Tex1
in vec2 tex1;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 N;
#ifdef _Billboard
uniform mat4 WV;
uniform mat4 P;
#endif
uniform mat4 W;
uniform mat4 V;
uniform mat4 P;
#ifndef _NoShadows
uniform mat4 LWVP;
#endif
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
#ifdef _VR
// !uniform mat4 U;
// !uniform float maxRadSq;
#endif
out vec3 v_position;
out vec2 v_texCoord;
#ifdef _Tex1
out vec2 v_texCoord1;
#endif
out vec3 v_normal;
#ifdef _NorTex
out vec3 v_tangent;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
vec3 _normal = normalize(mat3(N) * (nor + 2.0 * cross(skinA.xyz, cross(skinA.xyz, nor) + skinA.w * nor)));
#else
vec3 _normal = normalize(mat3(N) * nor);
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
// mat4 WV = V * W;
// #ifdef _Billboard
// // Spherical
// WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
// WV[1][0] = 0.0; WV[1][1] = 1.0; WV[1][2] = 0.0;
// WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
// // Cylindrical
// //WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
// //WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
// #endif
v_texCoord = tex;
#ifdef _Tex1
v_texCoord1 = tex1;
#endif
v_position = sPos.xyz;
v_normal = nor;
#ifdef _NorTex
v_tangent = tan;
#endif
}

View file

@ -1,520 +0,0 @@
{
"contexts": [
{
"name": "mesh",
"depth_write": false,
"compare_mode": "less_equal",
"cull_mode": "clockwise",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "WV",
"link": "_worldViewMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "P",
"link": "_projectionMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "WVP",
"link": "_worldViewProjectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias"
},
{
"name": "spotlightCutoff",
"link": "_spotlampCutoff"
},
{
"name": "spotlightExponent",
"link": "_spotlampExponent"
},
{
"name": "lightType",
"link": "_lampType"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
},
{
"name": "snoise",
"link": "_noise64",
"ifdef": ["_PCSS"]
},
{
"name": "lampSizeUV",
"link": "_lampSizeUV",
"ifdef": ["_PCSS"]
}
],
"vertex_shader": "mesh.vert.glsl",
"fragment_shader": "mesh.frag.glsl"
},
{
"name": "meshheight",
"depth_write": false,
"compare_mode": "less_equal",
"cull_mode": "clockwise",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "WV",
"link": "_worldViewMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "P",
"link": "_projectionMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "WVP",
"link": "_worldViewProjectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias"
},
{
"name": "spotlightCutoff",
"link": "_spotlampCutoff"
},
{
"name": "spotlightExponent",
"link": "_spotlampExponent"
},
{
"name": "lightType",
"link": "_lampType"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
},
{
"name": "snoise",
"link": "_noise64",
"ifdef": ["_PCSS"]
},
{
"name": "lampSizeUV",
"link": "_lampSizeUV",
"ifdef": ["_PCSS"]
}
],
"vertex_shader": "meshheight.vert.glsl",
"fragment_shader": "meshheight.frag.glsl",
"fragment_shader_path": "mesh.frag.glsl",
"tesscontrol_shader": "meshheight.tesc.glsl",
"tesseval_shader": "meshheight.tese.glsl"
},
{
"name": "overlay",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
}
],
"vertex_shader": "overlay.vert.glsl",
"vertex_shader_path": "../include/overlay.vert.glsl",
"fragment_shader": "overlay.frag.glsl",
"fragment_shader_path": "../include/overlay.frag.glsl"
},
{
"name": "shadowmap",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"links": [
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "shadowmap.vert.glsl",
"vertex_shader_path": "../include/shadowmap.vert.glsl",
"fragment_shader": "shadowmap.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl"
},
{
"name": "shadowmapheight",
"depth_write": true,
"compare_mode": "less_equal",
"cull_mode": "clockwise",
"links": [
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "shadowmapheight.vert.glsl",
"vertex_shader_path": "../include/shadowmapheight.vert.glsl",
"fragment_shader": "shadowmapheight.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl",
"tesscontrol_shader": "shadowmapheight.tesc.glsl",
"tesscontrol_shader_path": "../include/shadowmapheight.tesc.glsl",
"tesseval_shader": "shadowmapheight.tese.glsl",
"tesseval_shader_path": "../include/shadowmapheight.tese.glsl"
},
{
"name": "depthwrite",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"color_write_red": false,
"color_write_green": false,
"color_write_blue": false,
"color_write_alpha": false,
"links": [
{
"name": "LWVP",
"link": "_worldViewProjectionMatrix"
},
{
"name": "P",
"link": "_projectionMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "WV",
"link": "_worldViewMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "depthwrite.vert.glsl",
"vertex_shader_path": "../include/shadowmap.vert.glsl",
"fragment_shader": "depthwrite.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl"
},
{
"name": "depthwriteheight",
"depth_write": true,
"compare_mode": "less",
"cull_mode": "clockwise",
"color_write_red": false,
"color_write_green": false,
"color_write_blue": false,
"color_write_alpha": false,
"links": [
{
"name": "LWVP",
"link": "_worldViewProjectionMatrix"
},
{
"name": "P",
"link": "_projectionMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "WV",
"link": "_worldViewMatrix",
"ifdef": ["_Billboard"]
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
}
],
"vertex_shader": "depthwriteheight.vert.glsl",
"vertex_shader_path": "../include/shadowmapheight.vert.glsl",
"fragment_shader": "depthwriteheight.frag.glsl",
"fragment_shader_path": "../include/shadowmap.frag.glsl",
"tesscontrol_shader": "depthwriteheight.tesc.glsl",
"tesscontrol_shader_path": "../include/shadowmapheight.tesc.glsl",
"tesseval_shader": "depthwriteheight.tese.glsl",
"tesseval_shader_path": "../include/shadowmapheight.tese.glsl"
},
{
"name": "translucent",
"depth_write": false,
"compare_mode": "less",
"cull_mode": "clockwise",
"blend_source": "blend_one",
"blend_destination": "blend_one",
"blend_operation": "add",
"alpha_blend_source": "blend_zero",
"alpha_blend_destination": "inverse_source_alpha",
"alpha_blend_operation": "add",
"links": [
{
"name": "W",
"link": "_worldMatrix"
},
{
"name": "N",
"link": "_normalMatrix"
},
{
"name": "V",
"link": "_viewMatrix"
},
{
"name": "P",
"link": "_projectionMatrix"
},
{
"name": "LWVP",
"link": "_lampWorldViewProjectionMatrix",
"ifndef": "_NoShadows"
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias",
"ifndef": "_NoShadows"
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightDir",
"link": "_lampDirection"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "spotlightCutoff",
"link": "_spotlampCutoff"
},
{
"name": "spotlightExponent",
"link": "_spotlampExponent"
},
{
"name": "lightType",
"link": "_lampType"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "skinBones",
"link": "_skinBones",
"ifdef": ["_Skinning"]
},
{
"name": "lightPos",
"link": "_lampPosition"
},
{
"name": "lightColor",
"link": "_lampColor"
},
{
"name": "shirr",
"link": "_envmapIrradiance"
},
{
"name": "senvmapRadiance",
"link": "_envmapRadiance",
"ifdef": ["_Rad"]
},
{
"name": "envmapNumMipmaps",
"link": "_envmapNumMipmaps",
"ifdef": ["_Rad"]
},
{
"name": "senvmapBrdf",
"link": "_envmapBrdf",
"ifdef": ["_Rad"]
},
{
"name": "envmapStrength",
"link": "_envmapStrength"
}
],
"texture_params": [],
"vertex_shader": "translucent.vert.glsl",
"vertex_shader_path": "../include/translucent.vert.glsl",
"fragment_shader": "translucent.frag.glsl",
"fragment_shader_path": "../include/translucent.frag.glsl"
}
]
}

View file

@ -1,259 +0,0 @@
// Inspired by 'The devil is in the details: idTech 666'
// http://advances.realtimerendering.com/s2016/index.html
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#include "../compiled.glsl"
#include "../std/brdf.glsl"
// ...
#include "../std/gbuffer.glsl"
// octahedronWrap()
// packFloat()
#include "../std/tonemap.glsl"
// tonemapUncharted2()
#ifdef _Rad
#include "../std/math.glsl"
// envMapEquirect()
#endif
#ifndef _NoShadows
#ifdef _PCSS
#include "../std/shadows_pcss.glsl"
// PCSS()
#else
#include "../std/shadows.glsl"
// PCF()
#endif
#endif
#include "../std/shirr.glsl"
// shIrradiance()
//!uniform float shirr[27];
#ifdef _BaseTex
uniform sampler2D sbase;
#endif
#ifndef _NoShadows
//!uniform sampler2D shadowMap;
#ifdef _PCSS
//!uniform sampler2D snoise;
//!uniform float lampSizeUV;
#endif
#endif
#ifdef _Rad
uniform sampler2D senvmapRadiance;
uniform sampler2D senvmapBrdf;
uniform int envmapNumMipmaps;
#endif
#ifdef _NorTex
uniform sampler2D snormal;
#endif
#ifdef _NorStr
uniform float normalStrength;
#endif
#ifdef _OccTex
uniform sampler2D socclusion;
#else
uniform float occlusion;
#endif
#ifdef _RoughTex
uniform sampler2D srough;
#else
uniform float roughness;
#endif
#ifdef _RoughStr
uniform float roughnessStrength;
#endif
#ifdef _MetTex
uniform sampler2D smetal;
#else
uniform float metalness;
#endif
uniform float envmapStrength;
uniform bool receiveShadow;
uniform vec3 lightPos;
uniform vec3 lightDir;
uniform int lightType;
uniform vec3 lightColor;
uniform float shadowsBias;
uniform float spotlightCutoff;
uniform float spotlightExponent;
uniform vec3 eye;
in vec3 position;
#ifdef _Tex
in vec2 texCoord;
#endif
#ifdef _Tex1
in vec2 texCoord1;
#endif
in vec4 lampPos;
in vec4 matColor;
in vec3 eyeDir;
#ifdef _NorTex
in mat3 TBN;
#else
in vec3 normal;
#endif
out vec4[2] fragColor;
#ifndef _NoShadows
float shadowTest(vec4 lPos) {
lPos.xyz = lPos.xyz / lPos.w;
lPos.xy = lPos.xy * 0.5 + 0.5;
#ifdef _PCSS
return PCSS(lPos.xy, lPos.z - shadowsBias);
#else
return PCF(lPos.xy, lPos.z - shadowsBias);
#endif
}
#endif
void main() {
#ifdef _NorTex
#ifdef _NorTex1
vec3 n = texture(snormal, texCoord1).rgb * 2.0 - 1.0;
#else
vec3 n = texture(snormal, texCoord).rgb * 2.0 - 1.0;
#endif
n = normalize(TBN * normalize(n));
#else
vec3 n = normalize(normal);
#endif
#ifdef _NorStr
n *= normalStrength;
#endif
// Move out
vec3 l;
if (lightType == 0) { // Sun
l = lightDir;
}
else { // Point, spot
l = normalize(lightPos - position.xyz);
}
float visibility = 1.0;
#ifndef _NoShadows
if (receiveShadow) {
if (lampPos.w > 0.0) {
visibility = shadowTest(lampPos);
}
}
#endif
vec3 baseColor = matColor.rgb;
#ifdef _BaseTex
#ifdef _BaseTex1
vec4 texel = texture(sbase, texCoord1);
#else
vec4 texel = texture(sbase, texCoord);
#endif
#ifdef _AlphaTest
if (texel.a < 0.4)
discard;
#endif
texel.rgb = pow(texel.rgb, vec3(2.2));
baseColor *= texel.rgb;
#endif
vec4 outputColor;
vec3 v = normalize(eyeDir);
vec3 h = normalize(v + l);
float dotNL = dot(n, l);
float dotNV = dot(n, v);
float dotNH = dot(n, h);
float dotVH = dot(v, h);
#ifdef _MetTex
#ifdef _MetTex1
float metalness = texture(smetal, texCoord1).r;
#else
float metalness = texture(smetal, texCoord).r;
#endif
#endif
vec3 albedo = surfaceAlbedo(baseColor, metalness);
vec3 f0 = surfaceF0(baseColor, metalness);
#ifdef _RoughTex
#ifdef _RoughTex1
float roughness = texture(srough, texCoord1).r;
#else
float roughness = texture(srough, texCoord).r;
#endif
#endif
#ifdef _RoughStr
roughness *= roughnessStrength;
#endif
// Direct
#ifdef _OrenNayar
vec3 direct = orenNayarDiffuseBRDF(albedo, roughness, dotNV, dotNL, dotVH) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#else
vec3 direct = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#endif
if (lightType == 2) { // Spot
float spotEffect = dot(lightDir, l);
if (spotEffect < spotlightCutoff) {
spotEffect = smoothstep(spotlightCutoff - spotlightExponent, spotlightCutoff, spotEffect);
direct *= spotEffect;
}
}
direct = direct * lightColor;
// Indirect
vec3 indirectDiffuse = shIrradiance(n, 2.2) / PI;
#ifdef _EnvLDR
indirectDiffuse = pow(indirectDiffuse, vec3(2.2));
#endif
indirectDiffuse *= albedo;
vec3 indirect = indirectDiffuse;
#ifdef _Rad
vec3 reflectionWorld = reflect(-v, n);
float lod = getMipFromRoughness(roughness, envmapNumMipmaps);// + 1.0;
vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;
#ifdef _EnvLDR
prefilteredColor = pow(prefilteredColor, vec3(2.2));
#endif
vec2 envBRDF = texture(senvmapBrdf, vec2(roughness, 1.0 - dotNV)).xy;
vec3 indirectSpecular = prefilteredColor * (f0 * envBRDF.x + envBRDF.y);
indirect += indirectSpecular;
#endif
indirect = indirect * envmapStrength; // * lightColor;
outputColor = vec4(vec3(direct * visibility + indirect), 1.0);
#ifdef _OccTex
#ifdef _OccTex1
float occ = texture(socclusion, texCoord1).r;
#else
float occ = texture(socclusion, texCoord).r;
#endif
outputColor.rgb *= occ;
#else
outputColor.rgb *= occlusion;
#endif
#ifdef _LDR
outputColor.rgb = tonemapUncharted2(outputColor.rgb);
fragColor[0] = vec4(pow(outputColor.rgb, vec3(1.0 / 2.2)), visibility);
#else
fragColor[0] = vec4(outputColor.rgb, visibility);
#endif
n /= (abs(n.x) + abs(n.y) + abs(n.z));
n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);
fragColor[1] = vec4(n.xy, packFloat(metalness, roughness), 0.0);
}

View file

@ -1,123 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
in vec3 pos;
in vec3 nor;
#ifdef _Tex
in vec2 tex;
#endif
#ifdef _Tex1
in vec2 tex1;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 W;
uniform mat4 N;
#ifdef _Billboard
uniform mat4 WV;
uniform mat4 P;
#endif
uniform mat4 WVP;
uniform mat4 LWVP;
uniform vec4 baseCol;
uniform vec3 eye;
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
out vec3 position;
#ifdef _Tex
out vec2 texCoord;
#endif
#ifdef _Tex1
out vec2 texCoord1;
#endif
out vec4 lampPos;
out vec4 matColor;
out vec3 eyeDir;
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
vec3 _normal = normalize(mat3(N) * (nor + 2.0 * cross(skinA.xyz, cross(skinA.xyz, nor) + skinA.w * nor)));
#else
vec3 _normal = normalize(mat3(N) * nor);
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
lampPos = LWVP * sPos;
#ifdef _Billboard
mat4 constrWV = WV;
// Spherical
constrWV[0][0] = 1.0; constrWV[0][1] = 0.0; constrWV[0][2] = 0.0;
constrWV[1][0] = 0.0; constrWV[1][1] = 1.0; constrWV[1][2] = 0.0;
constrWV[2][0] = 0.0; constrWV[2][1] = 0.0; constrWV[2][2] = 1.0;
// Cylindrical
//constrWV[0][0] = 1.0; constrWV[0][1] = 0.0; constrWV[0][2] = 0.0;
//constrWV[2][0] = 0.0; constrWV[2][1] = 0.0; constrWV[2][2] = 1.0;
gl_Position = P * constrWV * sPos;
#else
gl_Position = WVP * sPos;
#endif
#ifdef _Tex
texCoord = tex;
#endif
#ifdef _Tex1
texCoord1 = tex1;
#endif
matColor = baseCol;
#ifdef _VCols
matColor.rgb *= col;
#endif
vec3 mPos = vec4(W * sPos).xyz;
position = mPos;
eyeDir = eye - mPos;
#ifdef _NorTex
vec3 tangent = (mat3(N) * (tan));
vec3 bitangent = normalize(cross(_normal, tangent));
TBN = mat3(tangent, bitangent, _normal);
#else
normal = _normal;
#endif
}

View file

@ -1,54 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(vertices = 3) out;
in vec3 v_position[];
in vec2 v_texCoord[];
#ifdef _Tex1
in vec2 v_texCoord1[];
#endif
in vec3 v_normal[];
#ifdef _NorTex
in vec3 v_tangent[];
#endif
out vec3 tc_position[];
out vec2 tc_texCoord[];
#ifdef _Tex1
out vec2 tc_texCoord1[];
#endif
out vec3 tc_normal[];
#ifdef _NorTex
out vec3 tc_tangent[];
#endif
uniform float innerLevel;
uniform float outerLevel;
#define ID gl_InvocationID
void main() {
tc_position[ID] = v_position[ID];
tc_texCoord[ID] = v_texCoord[ID];
#ifdef _Tex1
tc_texCoord1[ID] = v_texCoord1[ID];
#endif
tc_normal[ID] = v_normal[ID];
#ifdef _NorTex
tc_tangent[ID] = v_tangent[ID];
#endif
if (ID == 0) {
gl_TessLevelInner[0] = innerLevel;
gl_TessLevelInner[1] = innerLevel;
gl_TessLevelOuter[0] = outerLevel;
gl_TessLevelOuter[1] = outerLevel;
gl_TessLevelOuter[2] = outerLevel;
gl_TessLevelOuter[3] = outerLevel;
}
}

View file

@ -1,98 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(triangles, equal_spacing, ccw) in;
in vec3 tc_position[];
in vec2 tc_texCoord[];
#ifdef _Tex1
in vec2 tc_texCoord1[];
#endif
in vec3 tc_normal[];
#ifdef _NorTex
in vec3 tc_tangent[];
#endif
out vec3 position;
out vec2 texCoord;
#ifdef _Tex1
out vec2 texCoord1;
#endif
// #ifndef _NoShadows
out vec4 lampPos;
// #endif
out vec4 matColor;
out vec3 eyeDir;
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
uniform mat4 WVP;
uniform mat4 N;
uniform sampler2D sheight;
uniform float heightStrength;
// #ifndef _NoShadows
uniform mat4 LWVP;
// #endif
uniform mat4 W;
uniform vec3 eye;
uniform vec4 baseCol;
void main() {
vec3 p0 = gl_TessCoord.x * tc_position[0];
vec3 p1 = gl_TessCoord.y * tc_position[1];
vec3 p2 = gl_TessCoord.z * tc_position[2];
vec3 s_position = p0 + p1 + p2;
vec3 n0 = gl_TessCoord.x * tc_normal[0];
vec3 n1 = gl_TessCoord.y * tc_normal[1];
vec3 n2 = gl_TessCoord.z * tc_normal[2];
vec3 _te_normal = normalize(n0 + n1 + n2);
vec2 tc0 = gl_TessCoord.x * tc_texCoord[0];
vec2 tc1 = gl_TessCoord.y * tc_texCoord[1];
vec2 tc2 = gl_TessCoord.z * tc_texCoord[2];
texCoord = tc0 + tc1 + tc2;
#ifdef _Tex1
vec2 tc01 = gl_TessCoord.x * tc_texCoord1[0];
vec2 tc11 = gl_TessCoord.y * tc_texCoord1[1];
vec2 tc21 = gl_TessCoord.z * tc_texCoord1[2];
texCoord1 = tc01 + tc11 + tc21;
#endif
s_position += _te_normal * texture(sheight, texCoord).r * heightStrength;
position = vec4(W * vec4(s_position, 1.0)).xyz;
_te_normal = normalize(mat3(N) * _te_normal);
#ifdef _NorTex
vec3 t0 = gl_TessCoord.x * tc_tangent[0];
vec3 t1 = gl_TessCoord.y * tc_tangent[1];
vec3 t2 = gl_TessCoord.z * tc_tangent[2];
vec3 te_tangent = normalize(t0 + t1 + t2);
vec3 tangent = normalize(mat3(N) * (te_tangent));
vec3 bitangent = normalize(cross(_te_normal, tangent));
TBN = mat3(tangent, bitangent, _te_normal);
#else
normal = _te_normal;
#endif
// #ifndef _NoShadows
lampPos = LWVP * vec4(s_position, 1.0);
// #endif
matColor = baseCol;
// #ifdef _VCols
// matColor.rgb *= col;
// #endif
eyeDir = eye - position;
gl_Position = WVP * vec4(s_position, 1.0);
}

View file

@ -1,107 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
#ifdef _VR
#include "../std/vr.glsl"
// undistort()
#endif
in vec3 pos;
in vec3 nor;
in vec2 tex;
#ifdef _Tex1
in vec2 tex1;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 N;
#ifdef _Billboard
uniform mat4 WV;
uniform mat4 P;
#endif
uniform mat4 W;
uniform mat4 V;
uniform mat4 P;
#ifndef _NoShadows
uniform mat4 LWVP;
#endif
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
#ifdef _VR
// !uniform mat4 U;
// !uniform float maxRadSq;
#endif
out vec3 v_position;
out vec2 v_texCoord;
#ifdef _Tex1
out vec2 v_texCoord1;
#endif
out vec3 v_normal;
#ifdef _NorTex
out vec3 v_tangent;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
vec3 _normal = normalize(mat3(N) * (nor + 2.0 * cross(skinA.xyz, cross(skinA.xyz, nor) + skinA.w * nor)));
#else
vec3 _normal = normalize(mat3(N) * nor);
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
// mat4 WV = V * W;
// #ifdef _Billboard
// // Spherical
// WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
// WV[1][0] = 0.0; WV[1][1] = 1.0; WV[1][2] = 0.0;
// WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
// // Cylindrical
// //WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
// //WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
// #endif
v_texCoord = tex;
#ifdef _Tex1
v_texCoord1 = tex1;
#endif
v_position = sPos.xyz;
v_normal = nor;
#ifdef _NorTex
v_tangent = tan;
#endif
}

View file

@ -1,186 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#define _NoShadows
#define _LDR
#include "../compiled.glsl"
#include "../std/brdf.glsl"
// ...
#ifdef _Rad
#include "../std/math.glsl"
// envMapEquirect()
#endif
#ifndef _NoShadows
#ifdef _PCSS
#include "../std/shadows_pcss.glsl"
// PCSS()
#else
#include "../std/shadows.glsl"
// PCF()
#endif
#endif
#include "../std/shirr.glsl"
// shIrradiance()
//!uniform float shirr[27];
#ifdef _BaseTex
uniform sampler2D sbase;
#endif
#ifndef _NoShadows
//!uniform sampler2D shadowMap;
#ifdef _PCSS
//!uniform sampler2D snoise;
//!uniform float lampSizeUV;
#endif
#endif
#ifdef _Rad
uniform sampler2D senvmapRadiance;
uniform sampler2D senvmapBrdf;
uniform int envmapNumMipmaps;
#endif
#ifdef _NorTex
uniform sampler2D snormal;
#endif
#ifdef _OccTex
uniform sampler2D socclusion;
#else
uniform float occlusion;
#endif
#ifdef _RoughTex
uniform sampler2D srough;
#else
uniform float roughness;
#endif
#ifdef _MetTex
uniform sampler2D smetal;
#else
uniform float metalness;
#endif
uniform float envmapStrength;
uniform bool receiveShadow;
uniform vec3 lightDir;
uniform vec3 lightColor;
in vec3 position;
#ifdef _Tex
in vec2 texCoord;
#endif
in vec4 lampPos;
in vec4 matColor;
in vec3 eyeDir;
#ifdef _NorTex
in mat3 TBN;
#else
in vec3 normal;
#endif
out vec4 fragColor;
#ifndef _NoShadows
float shadowTest(vec4 lPos) {
lPos.xyz /= lPos.w;
lPos.xy = lPos.xy * 0.5 + 0.5;
#ifdef _PCSS
return PCSS(lPos.xy, lPos.z - shadowsBias);
#else
return PCF(lPos.xy, lPos.z - shadowsBias);
#endif
}
#endif
void main() {
#ifdef _NorTex
vec3 n = (texture(snormal, texCoord).rgb * 2.0 - 1.0);
n = normalize(TBN * normalize(n));
#else
vec3 n = normalize(normal);
#endif
vec3 l = normalize(lightDir);
float dotNL = max(dot(n, l), 0.0);
float visibility = 1.0;
#ifndef _NoShadows
if (receiveShadow) {
if (lampPos.w > 0.0) {
visibility = shadowTest(lampPos);
}
}
#endif
vec3 baseColor = matColor.rgb;
#ifdef _BaseTex
vec4 texel = texture(sbase, texCoord);
#ifdef _AlphaTest
if (texel.a < 0.4)
discard;
#endif
texel.rgb = pow(texel.rgb, vec3(2.2));
baseColor *= texel.rgb;
#endif
vec3 v = normalize(eyeDir);
vec3 h = normalize(v + l);
float dotNV = max(dot(n, v), 0.0);
float dotNH = max(dot(n, h), 0.0);
float dotVH = max(dot(v, h), 0.0);
float dotLV = max(dot(l, v), 0.0);
float dotLH = max(dot(l, h), 0.0);
#ifdef _MetTex
float metalness = texture(smetal, texCoord).r;
#endif
vec3 albedo = surfaceAlbedo(baseColor, metalness);
vec3 f0 = surfaceF0(baseColor, metalness);
#ifdef _RoughTex
float roughness = texture(srough, texCoord).r;
#endif
// Direct
#ifdef _OrenNayar
vec3 direct = orenNayarDiffuseBRDF(albedo, roughness, dotNV, dotNL, dotVH) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#else
vec3 direct = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#endif
direct = direct * lightColor;
// Indirect
vec3 indirectDiffuse = shIrradiance(n, 2.2) / PI;
#ifdef _EnvLDR
indirectDiffuse = pow(indirectDiffuse, vec3(2.2));
#endif
indirectDiffuse *= albedo;
vec3 indirect = indirectDiffuse;
#ifdef _Rad
vec3 reflectionWorld = reflect(-v, n);
float lod = getMipFromRoughness(roughness, envmapNumMipmaps);// + 1.0;
vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;
#ifdef _EnvLDR
prefilteredColor = pow(prefilteredColor, vec3(2.2));
#endif
vec2 envBRDF = texture(senvmapBrdf, vec2(roughness, 1.0 - dotNV)).xy;
vec3 indirectSpecular = prefilteredColor * (f0 * envBRDF.x + envBRDF.y);
indirect += indirectSpecular;
#endif
indirect = indirect * envmapStrength; // * lightColor;
fragColor = vec4(vec3(direct * visibility + indirect), 1.0);
#ifdef _OccTex
vec3 occ = texture(socclusion, texCoord).rgb;
fragColor.rgb *= occ;
#else
fragColor.rgb *= occlusion;
#endif
#ifdef _LDR
fragColor.rgb = vec3(pow(fragColor.rgb, vec3(1.0 / 2.2)));
#endif
}

View file

@ -1,115 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
#ifdef _NorTex
#define _Tex
#endif
in vec3 pos;
in vec3 nor;
#ifdef _Tex
in vec2 tex;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 W;
uniform mat4 N;
uniform mat4 V;
uniform mat4 P;
uniform mat4 LWVP;
uniform vec4 baseCol;
uniform vec3 eye;
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
out vec3 position;
#ifdef _Tex
out vec2 texCoord;
#endif
out vec4 lampPos;
out vec4 matColor;
out vec3 eyeDir;
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
vec3 _normal = normalize(mat3(N) * (nor + 2.0 * cross(skinA.xyz, cross(skinA.xyz, nor) + skinA.w * nor)));
#else
vec3 _normal = normalize(mat3(N) * nor);
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
lampPos = LWVP * sPos;
mat4 WV = V * W;
#ifdef _Billboard
// Spherical
WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
WV[1][0] = 0.0; WV[1][1] = 1.0; WV[1][2] = 0.0;
WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
// Cylindrical
//WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
//WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
#endif
gl_Position = P * WV * sPos;
#ifdef _Tex
texCoord = tex;
#endif
matColor = baseCol;
#ifdef _VCols
matColor.rgb *= col;
#endif
vec3 mPos = vec4(W * sPos).xyz;
position = mPos;
eyeDir = eye - mPos;
#ifdef _NorTex
vec3 tangent = (mat3(N) * (tan));
vec3 bitangent = normalize(cross(_normal, tangent));
TBN = mat3(tangent, bitangent, _normal);
#else
normal = _normal;
#endif
}

View file

@ -1,36 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#ifdef _Translucent
in vec2 texCoord;
#endif
out vec4 fragColor;
#ifdef _Translucent
#ifdef _OpacTex
uniform sampler2D sopacity;
#else
#ifdef _BaseTex
uniform sampler2D sbase;
#endif
#endif
#endif
void main() {
#ifdef _Translucent
#ifdef _OpacTex
if (texture(sopacity, texCoord).r < 0.5) discard;
#else
#ifdef _BaseTex
if (texture(sbase, texCoord).a < 0.5) discard;
#endif
#endif
#endif
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
}

View file

@ -1,78 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
in vec3 pos;
in vec3 nor;
#ifdef _Tex
in vec2 tex;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 LWVP;
#ifdef _Billboard
uniform mat4 WV;
uniform mat4 P;
#endif
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
#ifdef _Translucent
out vec2 texCoord;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
#ifdef _Translucent
#ifdef _Tex
texCoord = tex;
#endif
#endif
#ifdef _Billboard
mat4 constrWV = WV;
// Spherical
constrWV[0][0] = 1.0; constrWV[0][1] = 0.0; constrWV[0][2] = 0.0;
constrWV[1][0] = 0.0; constrWV[1][1] = 1.0; constrWV[1][2] = 0.0;
constrWV[2][0] = 0.0; constrWV[2][1] = 0.0; constrWV[2][2] = 1.0;
// Cylindrical
//constrWV[0][0] = 1.0; constrWV[0][1] = 0.0; constrWV[0][2] = 0.0;
//constrWV[2][0] = 0.0; constrWV[2][1] = 0.0; constrWV[2][2] = 1.0;
gl_Position = P * constrWV * sPos;
#else
gl_Position = LWVP * sPos;
#endif
}

View file

@ -1,34 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(vertices = 3) out;
in vec3 v_position[];
in vec2 v_texCoord[];
in vec3 v_normal[];
out vec3 tc_position[];
out vec2 tc_texCoord[];
out vec3 tc_normal[];
uniform float innerLevel;
uniform float outerLevel;
#define ID gl_InvocationID
void main() {
tc_position[ID] = v_position[ID];
tc_texCoord[ID] = v_texCoord[ID];
tc_normal[ID] = v_normal[ID];
if (ID == 0) {
gl_TessLevelInner[0] = innerLevel;
gl_TessLevelInner[1] = innerLevel;
gl_TessLevelOuter[0] = outerLevel;
gl_TessLevelOuter[1] = outerLevel;
gl_TessLevelOuter[2] = outerLevel;
gl_TessLevelOuter[3] = outerLevel;
}
}

View file

@ -1,34 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
layout(triangles, equal_spacing, ccw) in;
in vec3 tc_position[];
in vec2 tc_texCoord[];
in vec3 tc_normal[];
uniform mat4 LWVP;
uniform sampler2D sheight;
uniform float heightStrength;
void main() {
vec3 p0 = gl_TessCoord.x * tc_position[0];
vec3 p1 = gl_TessCoord.y * tc_position[1];
vec3 p2 = gl_TessCoord.z * tc_position[2];
vec3 te_position = p0 + p1 + p2;
vec3 n0 = gl_TessCoord.x * tc_normal[0];
vec3 n1 = gl_TessCoord.y * tc_normal[1];
vec3 n2 = gl_TessCoord.z * tc_normal[2];
vec3 _te_normal = normalize(n0 + n1 + n2);
vec2 tc0 = gl_TessCoord.x * tc_texCoord[0];
vec2 tc1 = gl_TessCoord.y * tc_texCoord[1];
vec2 tc2 = gl_TessCoord.z * tc_texCoord[2];
vec2 te_texCoord = tc0 + tc1 + tc2;
te_position += _te_normal * texture(sheight, te_texCoord).r * heightStrength;
gl_Position = LWVP * vec4(te_position, 1.0);
}

View file

@ -1,41 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
in vec3 pos;
in vec3 nor;
in vec2 tex;
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
out vec3 v_position;
out vec2 v_texCoord;
out vec3 v_normal;
// uniform sampler2D sheight;
// uniform float heightStrength;
void main() {
v_position = pos;
#ifdef _Instancing
v_position += off;
#endif
v_texCoord = tex;
v_normal = nor;
// v_position += v_normal * texture(sheight, tex).r * heightStrength;
}

View file

@ -1,240 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#include "../compiled.glsl"
#include "../std/brdf.glsl"
// ...
#include "../std/math.glsl"
// envMapEquirect()
#include "../std/shirr.glsl"
// shIrradiance()
//!uniform float shirr[27];
#ifndef _NoShadows
#ifdef _PCSS
#include "../std/shadows_pcss.glsl"
// PCSS()
#else
#include "../std/shadows.glsl"
// PCF()
#endif
#endif
#ifdef _BaseTex
uniform sampler2D sbase;
#endif
#ifdef _OpacTex
uniform sampler2D sopacity;
#endif
#ifndef _NoShadows
//!uniform sampler2D shadowMap;
#ifdef _PCSS
//!uniform sampler2D snoise;
//!uniform float lampSizeUV;
#endif
uniform float shadowsBias;
// uniform bool receiveShadow; // TODO: pass uniform from exporter
#endif
#ifdef _Rad
uniform sampler2D senvmapRadiance;
uniform sampler2D senvmapBrdf;
uniform int envmapNumMipmaps;
#endif
#ifdef _NorTex
uniform sampler2D snormal;
#endif
#ifdef _NorStr
uniform float normalStrength;
#endif
#ifdef _OccTex
uniform sampler2D socclusion;
#else
uniform float occlusion;
#endif
#ifdef _RoughTex
uniform sampler2D srough;
#else
uniform float roughness;
#endif
#ifdef _RoughStr
uniform float roughnessStrength;
#endif
#ifdef _MetTex
uniform sampler2D smetal;
#else
uniform float metalness;
#endif
uniform float envmapStrength;
uniform vec3 lightPos;
uniform vec3 lightDir;
uniform int lightType;
uniform vec3 lightColor;
uniform float spotlightCutoff;
uniform float spotlightExponent;
uniform vec3 eye;
in vec4 wvpposition;
in vec3 position;
#ifdef _Tex
in vec2 texCoord;
#endif
#ifndef _NoShadows
in vec4 lampPos;
#endif
in vec4 matColor;
in vec3 eyeDir;
#ifdef _NorTex
in mat3 TBN;
#else
in vec3 normal;
#endif
out vec4[2] fragColor;
#ifndef _NoShadows
float shadowTest(vec4 lPos) {
lPos.xyz /= lPos.w;
lPos.xy = lPos.xy * 0.5 + 0.5;
#ifdef _PCSS
return PCSS(lPos.xy, lPos.z - shadowsBias);
#else
return PCF(lPos.xy, lPos.z - shadowsBias);
#endif
// return VSM(lPos.xy, lPos.z);
// float distanceFromLight = texture(shadowMap, lPos.xy).r * 2.0 - 1.0;
// return float(distanceFromLight > lPos.z - shadowsBias);
}
#endif
void main() {
#ifdef _NorTex
vec3 n = (texture(snormal, texCoord).rgb * 2.0 - 1.0);
n = normalize(TBN * normalize(n));
#else
vec3 n = normalize(normal);
#endif
#ifdef _NorStr
n *= normalStrength;
#endif
// Move out
vec3 l;
if (lightType == 0) { // Sun
l = lightDir;
}
else { // Point, spot
l = normalize(lightPos - position.xyz);
}
float dotNL = max(dot(n, l), 0.0);
float visibility = 1.0;
#ifndef _NoShadows
// if (receiveShadow) {
if (lampPos.w > 0.0) {
visibility = shadowTest(lampPos);
}
// }
#endif
vec3 baseColor = matColor.rgb;
#ifdef _BaseTex
vec4 texel = texture(sbase, texCoord);
// #ifdef _AlphaTest
// if (texel.a < 0.4)
// discard;
// #endif
texel.rgb = pow(texel.rgb, vec3(2.2));
baseColor *= texel.rgb;
#endif
vec3 v = normalize(eyeDir);
vec3 h = normalize(v + l);
float dotNV = max(dot(n, v), 0.0);
float dotNH = max(dot(n, h), 0.0);
float dotVH = max(dot(v, h), 0.0);
float dotLV = max(dot(l, v), 0.0);
float dotLH = max(dot(l, h), 0.0);
#ifdef _MetTex
float metalness = texture(smetal, texCoord).r;
#endif
vec3 albedo = surfaceAlbedo(baseColor, metalness);
vec3 f0 = surfaceF0(baseColor, metalness);
#ifdef _RoughTex
float roughness = texture(srough, texCoord).r;
#endif
#ifdef _RoughStr
roughness *= roughnessStrength;
#endif
#ifdef _OccTex
float occlusion = texture(socclusion, texCoord).r;
#endif
// Direct
#ifdef _OrenNayar
vec3 direct = orenNayarDiffuseBRDF(albedo, roughness, dotNV, dotNL, dotVH) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#else
vec3 direct = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, roughness, dotNL, dotNH, dotNV, dotVH);
#endif
if (lightType == 2) { // Spot
float spotEffect = dot(lightDir, l);
if (spotEffect < spotlightCutoff) {
spotEffect = smoothstep(spotlightCutoff - spotlightExponent, spotlightCutoff, spotEffect);
direct *= spotEffect;
}
}
direct = direct * lightColor;
// Indirect
vec3 indirectDiffuse = shIrradiance(n, 2.2) / PI;
#ifdef _EnvLDR
indirectDiffuse = pow(indirectDiffuse, vec3(2.2));
#endif
indirectDiffuse *= albedo;
vec3 indirect = indirectDiffuse;
#ifdef _Rad
vec3 reflectionWorld = reflect(-v, n);
float lod = getMipFromRoughness(roughness, envmapNumMipmaps);// + 1.0;
vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;
#ifdef _EnvLDR
prefilteredColor = pow(prefilteredColor, vec3(2.2));
#endif
vec2 envBRDF = texture(senvmapBrdf, vec2(roughness, 1.0 - dotNV)).xy;
vec3 indirectSpecular = prefilteredColor * (f0 * envBRDF.x + envBRDF.y);
indirect += indirectSpecular;
#endif
indirect = indirect * envmapStrength;// * lightColor;
vec4 premultipliedReflect = vec4(vec3(direct * visibility + indirect * occlusion), matColor.a);
#ifdef _OpacTex
premultipliedReflect.a *= texture(sopacity, texCoord).r;
#else
#ifdef _BaseTex
premultipliedReflect.a *= texel.a; // Base color alpha
#endif
#endif
float fragZ = wvpposition.z / wvpposition.w;
float a = min(1.0, premultipliedReflect.a) * 8.0 + 0.01;
float b = -fragZ * 0.95 + 1.0;
float w = clamp(a * a * a * 1e8 * b * b * b, 1e-2, 3e2);
fragColor[0] = vec4(premultipliedReflect.rgb * w, premultipliedReflect.a);
fragColor[1] = vec4(premultipliedReflect.a * w, 0.0, 0.0, 1.0);
}

View file

@ -1,119 +0,0 @@
#version 450
#ifdef GL_ES
precision highp float;
#endif
#include "../compiled.glsl"
#ifdef _Skinning
#include "../std/skinning.glsl"
// getSkinningDualQuat()
#endif
in vec3 pos;
in vec3 nor;
#ifdef _Tex
in vec2 tex;
#endif
#ifdef _VCols
in vec3 col;
#endif
#ifdef _NorTex
in vec3 tan;
#endif
#ifdef _Skinning
in vec4 bone;
in vec4 weight;
#endif
#ifdef _Instancing
in vec3 off;
#endif
uniform mat4 W;
uniform mat4 N;
uniform mat4 V;
uniform mat4 P;
#ifndef _NoShadows
uniform mat4 LWVP;
#endif
uniform vec4 baseCol;
uniform vec3 eye;
#ifdef _Skinning
//!uniform float skinBones[skinMaxBones * 8];
#endif
out vec4 wvpposition;
out vec3 position;
#ifdef _Tex
out vec2 texCoord;
#endif
#ifndef _NoShadows
out vec4 lampPos;
#endif
out vec4 matColor;
out vec3 eyeDir;
#ifdef _NorTex
out mat3 TBN;
#else
out vec3 normal;
#endif
void main() {
vec4 sPos = vec4(pos, 1.0);
#ifdef _Skinning
vec4 skinA;
vec4 skinB;
getSkinningDualQuat(ivec4(bone), weight, skinA, skinB);
sPos.xyz += 2.0 * cross(skinA.xyz, cross(skinA.xyz, sPos.xyz) + skinA.w * sPos.xyz); // Rotate
sPos.xyz += 2.0 * (skinA.w * skinB.xyz - skinB.w * skinA.xyz + cross(skinA.xyz, skinB.xyz)); // Translate
vec3 _normal = normalize(mat3(N) * (nor + 2.0 * cross(skinA.xyz, cross(skinA.xyz, nor) + skinA.w * nor)));
#else
vec3 _normal = normalize(mat3(N) * nor);
#endif
#ifdef _Instancing
sPos.xyz += off;
#endif
#ifndef _NoShadows
lampPos = LWVP * sPos;
#endif
mat4 WV = V * W;
#ifdef _Billboard
// Spherical
WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
WV[1][0] = 0.0; WV[1][1] = 1.0; WV[1][2] = 0.0;
WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
// Cylindrical
//WV[0][0] = 1.0; WV[0][1] = 0.0; WV[0][2] = 0.0;
//WV[2][0] = 0.0; WV[2][1] = 0.0; WV[2][2] = 1.0;
#endif
gl_Position = P * WV * sPos;
wvpposition = gl_Position;
#ifdef _Tex
texCoord = tex;
#endif
matColor = baseCol;
#ifdef _VCols
matColor.rgb *= col;
#endif
vec3 mPos = vec4(W * sPos).xyz;
position = mPos;
eyeDir = eye - mPos;
#ifdef _NorTex
vec3 tangent = (mat3(N) * (tan));
vec3 bitangent = normalize(cross(_normal, tangent));
TBN = mat3(tangent, bitangent, _normal);
#else
normal = _normal;
#endif
}

View file

@ -21,8 +21,7 @@ import assets
import armutils
import subprocess
import log
import make_material
import material.make as make_material_full
import material.make as make_material
import nodes
NodeTypeNode = 0
@ -2021,7 +2020,26 @@ class ArmoryExporter:
o['lamp_size'] = lamp_size * 10 # Match to Cycles
# Parse nodes
make_material.parse_lamp(objref.node_tree, o)
# Emission only for now
tree = objref.node_tree
for n in tree.nodes:
if n.type == 'EMISSION':
col = n.inputs[0].default_value
o['color'] = [col[0], col[1], col[2]]
o['strength'] = n.inputs[1].default_value
# Normalize point/spot strength
if o['type'] == 'point' or o['type'] == 'spot':
o['strength'] /= 1000.0
elif o['type'] == 'area':
o['strength'] /= 1000.0
# Texture test..
# if n.inputs[0].is_linked:
# color_node = nodes.find_node_by_link(tree, n, n.inputs[0])
# if color_node.type == 'TEX_IMAGE':
# o['color_texture'] = color_node.image.name
# make_texture(None, '', color_node, None)
## bpy.data.worlds['Arm'].world_defs += '_LampColTex'
break
# Fake omni shadows
if objref.lamp_omni_shadows:
@ -2133,32 +2151,29 @@ class ArmoryExporter:
o['contexts'] = []
if wrd.arm_material_level == 'Restricted':
self.post_export_material(material, o)
else:
sd = make_material_full.parse(material, o, self.materialToObjectDict, ArmoryExporter.renderpath_id)
sd = make_material.parse(material, o, self.materialToObjectDict, ArmoryExporter.renderpath_id)
uv_export = False
tan_export = False
vcol_export = False
for elem in sd['vertex_structure']:
if elem['name'] == 'tan':
tan_export = True
elif elem['name'] == 'tex':
uv_export = True
elif elem['name'] == 'col':
vcol_export = True
uv_export = False
tan_export = False
vcol_export = False
for elem in sd['vertex_structure']:
if elem['name'] == 'tan':
tan_export = True
elif elem['name'] == 'tex':
uv_export = True
elif elem['name'] == 'col':
vcol_export = True
if (material.export_tangents != tan_export) or \
(material.export_uvs != uv_export) or \
(material.export_vcols != vcol_export):
if (material.export_tangents != tan_export) or \
(material.export_uvs != uv_export) or \
(material.export_vcols != vcol_export):
material.export_uvs = uv_export
material.export_vcols = vcol_export
material.export_tangents = tan_export
mat_users = self.materialToObjectDict[material]
for ob in mat_users:
ob.data.mesh_cached = False
material.export_uvs = uv_export
material.export_vcols = vcol_export
material.export_tangents = tan_export
mat_users = self.materialToObjectDict[material]
for ob in mat_users:
ob.data.mesh_cached = False
self.output['material_datas'].append(o)
@ -2172,7 +2187,7 @@ class ArmoryExporter:
o['contexts'] = []
mat_users = dict()
mat_users[mat] = self.defaultMaterialObjects
make_material_full.parse(mat, o, mat_users, ArmoryExporter.renderpath_id)
make_material.parse(mat, o, mat_users, ArmoryExporter.renderpath_id)
self.output['material_datas'].append(o)
bpy.data.materials.remove(mat)
@ -2689,225 +2704,6 @@ class ArmoryExporter:
co['use_offset'] = constr.use_offset
co['influence'] = constr.influence
o['constraints'].append(co)
def post_export_material(self, material, o):
defs = []
# Geometry context
c = {}
c['name'] = ArmoryExporter.mesh_context
c['bind_constants'] = []
const = {}
const['name'] = 'receiveShadow'
const['bool'] = material.receive_shadow
c['bind_constants'].append(const)
# const = {}
# const['name'] = 'mask'
# const['float'] = material.stencil_mask
# c['bind_constants'].append(const)
c['bind_textures'] = []
# If material user has decal modifier, parse decal material context
mat_users = self.materialToObjectDict[material]
# Get decal uv map name
decal_uv_layer = None
for ob in mat_users:
for m in ob.modifiers:
if m.type == 'UV_PROJECT':
decal_uv_layer = m.uv_layer
break
# Get decal context from render paths
decal_context = bpy.data.cameras[0].last_decal_context
# Set uv layers to support multiple texcoords
if material in self.materialToObjectDict:
mat_user = self.materialToObjectDict[material][0]
if hasattr(mat_user.data, 'uv_layers'): # No uvlayers for Curve
make_material.uvlayers = []
for layer in mat_user.data.uv_layers:
make_material.uvlayers.append(layer.name)
# Parse from material output
if decal_uv_layer == None:
make_material.parse(self, material, c, defs)
o['contexts'].append(c)
# Decal attached, split material into two separate ones
# Mandatory starting point from mix node for now
# else:
# o2 = {}
# o2['name'] = o['name'] + '_decal'
# o2['contexts'] = []
# c2 = {}
# c2['name'] = decal_context
# c2['bind_constants'] = []
# c2['bind_textures'] = []
# defs2 = []
# tree = material.node_tree
# output_node = nodes.get_node_by_type(tree, 'OUTPUT_MATERIAL')
# mix_node = nodes.find_node_by_link(tree, output_node, output_node.inputs[0])
# surface_node1 = nodes.find_node_by_link(tree, mix_node, mix_node.inputs[1])
# surface_node2 = nodes.find_node_by_link(tree, mix_node, mix_node.inputs[2])
# make_material.parse_from(self, material, c, defs, surface_node1)
# make_material.parse_from(self, material, c2, defs2, surface_node2)
# o['contexts'].append(c)
# o2['contexts'].append(c2)
# self.finalize_shader(o2, defs2, [decal_context])
# self.output['material_datas'].append(o2)
# Override context
if material.override_shader_context:
c['name'] = material.override_shader_context_name
# If material has height map switch to tessellation displacement context
elif '_HeightTex' in defs:
c['name'] = ArmoryExporter.mesh_context + 'height'
const = {}
const['name'] = 'innerLevel'
const['float'] = material.height_tess_inner
c['bind_constants'].append(const)
const = {}
const['name'] = 'outerLevel'
const['float'] = material.height_tess_outer
c['bind_constants'].append(const)
# Append shadows height context
if wrd.generate_shadows == True:
if material.height_tess_shadows:
c2 = {}
c2['name'] = ArmoryExporter.shadows_context + 'height'
c2['bind_constants'] = []
c2['bind_textures'] = []
for bc in c['bind_constants']:
if bc['name'] == 'heightStrength':
c2['bind_constants'].append(bc)
break
for bt in c['bind_textures']:
if bt['name'] == 'sheight':
c2['bind_textures'].append(bt)
break
const = {}
const['name'] = 'innerLevel'
const['float'] = material.height_tess_shadows_inner
c2['bind_constants'].append(const)
const = {}
const['name'] = 'outerLevel'
const['float'] = material.height_tess_shadows_outer
c2['bind_constants'].append(const)
o['contexts'].append(c2)
else:
# Non-tessellated shadow context
c2 = {}
c2['name'] = ArmoryExporter.shadows_context
o['contexts'].append(c2)
# X-Ray enabled
elif material.overlay:
# Change to overlay context
c['name'] = ArmoryExporter.overlay_context
# Switch main context to translucent
elif '_Translucent' in defs:
c['name'] = ArmoryExporter.translucent_context
# Opacity for shadowmap in Translucent context
if wrd.generate_shadows == True and material.transluc_shadows == True:
texname = ''
if '_OpacTex' in defs:
texname = 'sopacity'
elif '_BaseTex' in defs:
texname = 'sbase'
if texname != '':
c2 = {}
c2['name'] = ArmoryExporter.shadows_context
o['contexts'].append(c2)
for bt in c['bind_textures']:
if bt['name'] == texname:
c2['bind_textures'] = [bt]
break
# Otherwise add shadows context
else:
if wrd.generate_shadows == True:
c2 = {}
c2['name'] = ArmoryExporter.shadows_context
o['contexts'].append(c2)
# VGI Voxels enabled, append context
if wrd.voxelgi:
#defs.append('_VoxelGI')
c2 = {}
c2['name'] = 'voxel' # TODO: Hard-coded context name for now
for bc in c['bind_constants']:
if bc['name'] == 'baseCol':
c2['bind_constants'] = [bc]
break
for bt in c['bind_textures']:
if bt['name'] == 'sbase':
c2['bind_textures'] = [bt]
break
o['contexts'].append(c2)
# Additional geometry contexts, useful for depth-prepass
# No pre-pass for translucent
if ArmoryExporter.mesh_context_empty != '' and '_Translucent' not in defs:
c2 = {}
c2['name'] = ArmoryExporter.mesh_context_empty
# Depth pre-pass for height context
if '_HeightTex' in defs:
c2['name'] += 'height'
c2['bind_constants'] = []
c2['bind_textures'] = []
for bc in c['bind_constants']:
if bc['name'] == 'heightStrength':
c2['bind_constants'].append(bc)
break
for bt in c['bind_textures']:
if bt['name'] == 'sheight':
c2['bind_textures'].append(bt)
break
const = {}
const['name'] = 'innerLevel'
const['float'] = material.height_tess_inner
c2['bind_constants'].append(const)
const = {}
const['name'] = 'outerLevel'
const['float'] = material.height_tess_outer
c2['bind_constants'].append(const)
o['contexts'].append(c2)
# Material users
for ob in mat_users:
# Instancing used by material user
if ob.instanced_children or len(ob.particle_systems) > 0:
defs.append('_Instancing')
# GPU Skinning
if ob.find_armature() and armutils.is_bone_animation_enabled(ob) and bpy.data.worlds['Arm'].generate_gpu_skin == True:
defs.append('_Skinning')
# Perform billboarding constraint in shader
if len(ob.constraints) > 0 and ob.constraints[0].type == 'TRACK_TO' and ob.constraints[0].target != None and \
ob.constraints[0].target.type == 'CAMERA' and ob.constraints[0].mute == False:
defs.append('_Billboard')
# Whether objects should export tangent data
normal_mapping = '_NorTex' in defs
if material.export_tangents != normal_mapping:
material.export_tangents = normal_mapping
# Delete mesh caches
for ob in mat_users:
ob.data.mesh_cached = False
# Process defs and append datas
if material.override_shader == False:
with_tess = False
geom_context = None
# TODO: auto-detect tessellation shaders
if '_HeightTex' in defs:
with_tess = True
if wrd.voxelgi:
geom_context = 'voxel'
self.finalize_shader(o, defs, ArmoryExporter.renderpath_passes, with_tess=with_tess, geom_context=geom_context)
else:
o['shader'] = material.override_shader_name
def post_export_world(self, world, o):
defs = bpy.data.worlds['Arm'].world_defs
@ -3087,59 +2883,3 @@ class ArmoryExporter:
po['volume'] = volume
po['volume_center'] = volume_center
return po
def finalize_shader(self, o, defs, renderpath_passes, with_tess=False, geom_context=None):
# Merge duplicates and sort
defs = sorted(list(set(defs)))
# Select correct shader variant
ext = ''
for d in defs:
ext += d
# Append world defs
ext += bpy.data.worlds['Arm'].world_defs
# Shader data
shader_data_name = ArmoryExporter.renderpath_id + ext
shader_data_path = 'build/compiled/ShaderDatas/' + ArmoryExporter.renderpath_id + '/' + shader_data_name + '.arm'
# Stencil mask
# if material.stencil_mask > 0:
# mask_ext = "_mask" + str(material.stencil_mask)
# shader_data_name_with_mask = shader_data_name + mask_ext
# shader_data_path_with_mask = 'build/compiled/ShaderDatas/' + ArmoryExporter.renderpath_id + '/' + shader_data_name_with_mask + '.arm'
# # Copy data if it does not exist and set stencil mask
# if not os.path.isfile(shader_data_path_with_mask):
# with open(shader_data_path) as f:
# json_file = f.read()
# json_data = json.loads(json_file)
# dat = json_data['shader_datas'][0]
# dat['name'] += mask_ext
# for c in dat['contexts']:
# c['stencil_pass'] = 'replace'
# c['stencil_reference_value'] = material.stencil_mask
# with open(shader_data_path_with_mask, 'w') as f:
# json.dump(json_data, f)
# assets.add_shader_data(shader_data_path_with_mask)
# o.shader = shader_data_name_with_mask + '/' + shader_data_name_with_mask
# # No stencil mask
# else:
assets.add_shader_data(shader_data_path)
o['shader'] = shader_data_name + '/' + shader_data_name
# Process all passes from render path
if with_tess: # TODO: properly handle adding height pass shaders to khafile
rpasses = [ArmoryExporter.mesh_context + 'height']
if ArmoryExporter.mesh_context_empty != '':
rpasses.append(ArmoryExporter.mesh_context_empty + 'height')
if bpy.data.worlds['Arm'].generate_shadows == True:
rpasses.append(ArmoryExporter.shadows_context + 'height')
else:
rpasses = renderpath_passes
for ren_pass in rpasses:
shader_name = ren_pass + ext
full_name = 'build/compiled/Shaders/' + ArmoryExporter.renderpath_id + '/' + shader_name
assets.add_shader(full_name + '.vert.glsl')
assets.add_shader(full_name + '.frag.glsl')
if geom_context == ren_pass:
assets.add_shader(full_name + '.geom.glsl')
if with_tess:
assets.add_shader(full_name + '.tesc.glsl')
assets.add_shader(full_name + '.tese.glsl')

View file

@ -107,13 +107,9 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
# Data does not exist yet
if not os.path.isfile(fp + '/' + ref):
shader_name = ref.split('/')[3] # Extract from 'build/compiled/...'
strdefs = ref[:-4] # Remove '.arm' extension
defs = strdefs.split(shader_name) # 'name/name_def_def'
if len(defs) > 2:
strdefs = defs[2] # Appended defs
defs = make_utils.def_strings_to_array(strdefs)
else:
defs = []
defs = make_utils.def_strings_to_array(wrd.world_defs)
if shader_name.startswith('compositor_pass'):
defs += make_utils.def_strings_to_array(wrd.compo_defs)
compile_shader(raw_shaders_path, shader_name, defs)
# Reset path

View file

@ -1,648 +0,0 @@
import bpy
import math
import assets
import armutils
import os
import nodes
import log
import make_state as state
uvlayers = [''] # UV Map names of current material user
def is_pow(num):
return ((num & (num - 1)) == 0) and num != 0
# Material output is used as starting point
def parse(self, material, c, defs):
tree = material.node_tree
output_node = nodes.get_node_by_type(tree, 'OUTPUT_MATERIAL')
# Traverse material tree
if output_node != None:
# Surface socket is linked
if output_node.inputs[0].is_linked:
surface_node = nodes.find_node_by_link(tree, output_node, output_node.inputs[0])
parse_from(self, material, c, defs, surface_node)
# Displace socket is linked
if output_node.inputs[2].is_linked:
displace_node = nodes.find_node_by_link(tree, output_node, output_node.inputs[2])
parse_material_displacement(self, material, c, defs, tree, displace_node, 1.0)
# No albedo color parsed, append white
if parse.const_color == None:
make_albedo_const([1.0, 1.0, 1.0, 1.0], c)
if parse.const_occlusion == None and '_OccTex' not in defs:
make_occlusion_const(1.0, c)
if parse.const_roughness == None and '_RoughTex' not in defs:
make_roughness_const(0.0, c)
if parse.const_metalness == None and '_MetTex' not in defs:
make_metalness_const(0.0, c)
# Enable texcoords
if '_Tex' not in defs:
for d in defs:
if d == '_BaseTex' or d == '_NorTex' or d == '_OccTex' or d == '_RoughTex' or d == '_MetTex' or d == '_HeightTex' or d == '_OpacTex':
defs.append('_Tex')
break
def parse_lamp(tree, o):
# Emission only for now
for n in tree.nodes:
if n.type == 'EMISSION':
col = n.inputs[0].default_value
o['color'] = [col[0], col[1], col[2]]
o['strength'] = n.inputs[1].default_value
# Normalize point/spot strength
if o['type'] == 'point' or o['type'] == 'spot':
o['strength'] /= 1000.0
elif o['type'] == 'area':
o['strength'] /= 1000.0
# Texture test..
if n.inputs[0].is_linked:
color_node = nodes.find_node_by_link(tree, n, n.inputs[0])
if color_node.type == 'TEX_IMAGE':
o['color_texture'] = color_node.image.name
make_texture(None, '', color_node, None)
# bpy.data.worlds['Arm'].world_defs += '_LampColTex'
break
def make_albedo_const(col, c):
const = {}
parse.const_color = const
c['bind_constants'].append(const)
const['name'] = 'baseCol'
const['vec4'] = [col[0], col[1], col[2], col[3]]
def make_roughness_const(f, c):
const = {}
parse.const_roughness = const
c['bind_constants'].append(const)
const['name'] = 'roughness'
const['float'] = f
def make_occlusion_const(f, c):
const = {}
parse.const_occlusion = const
c['bind_constants'].append(const)
const['name'] = 'occlusion'
const['float'] = f
def make_metalness_const(f, c):
const = {}
parse.const_metalness = const
c['bind_constants'].append(const)
const['name'] = 'metalness'
const['float'] = f
# Manualy set starting material point
def parse_from(self, material, c, defs, surface_node):
parse.const_color = None
parse.const_occlusion = None
parse.const_roughness = None
parse.const_metalness = None
tree = material.node_tree
parse_material_surface(self, material, c, defs, tree, surface_node, 1.0)
def make_texture(self, id, image_node, material, image_format='RGBA32'):
wrd = bpy.data.worlds['Arm']
tex = {}
tex['name'] = id
tex['file'] = ''
image = image_node.image
if image != None:
if image.filepath == '':
log.warn(material.name + '/' + image.name + ' - file path not found')
return tex
# Reference image name
tex['file'] = armutils.extract_filename(image.filepath)
tex['file'] = armutils.safefilename(tex['file'])
s = tex['file'].rsplit('.', 1)
if len(s) == 1:
log.warn(material.name + '/' + image.name + ' - file extension required for image name')
return tex
ext = s[1].lower()
do_convert = ext != 'jpg' and ext != 'png' and ext != 'hdr' # Convert image
if do_convert:
tex['file'] = tex['file'].rsplit('.', 1)[0] + '.jpg'
# log.warn(material.name + '/' + image.name + ' - image format is not supported yet, converting to jpg. Use jpg, png, hdr.')
if image.packed_file != None:
# Extract packed data
unpack_path = armutils.get_fp() + '/build/compiled/Assets/unpacked'
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)
unpack_filepath = unpack_path + '/' + tex['file']
if do_convert:
if not os.path.isfile(unpack_filepath):
armutils.write_image(image, unpack_filepath)
# Write bytes if size is different or file does not exist yet
elif os.path.isfile(unpack_filepath) == False or os.path.getsize(unpack_filepath) != image.packed_file.size:
with open(unpack_filepath, 'wb') as f:
f.write(image.packed_file.data)
assets.add(unpack_filepath)
else:
# if not os.path.isfile(image.filepath):
# log.warn(material.name + '/' + image.name + ' - file not found')
# return tex
if do_convert:
converted_path = armutils.get_fp() + '/build/compiled/Assets/unpacked/' + tex['file']
# TODO: delete cache when file changes
if not os.path.isfile(converted_path):
armutils.write_image(image, converted_path)
assets.add(converted_path)
else:
# Link image path to assets
assets.add(armutils.safe_assetpath(image.filepath))
if image_format != 'RGBA32':
tex['format'] = image_format
interpolation = image_node.interpolation
aniso = wrd.anisotropic_filtering_state
if aniso == 'On':
interpolation = 'Smart'
elif aniso == 'Off' and interpolation == 'Smart':
interpolation = 'Linear'
# TODO: Blender seems to load full images on size request, cache size instead
powimage = is_pow(image.size[0]) and is_pow(image.size[1])
# Pow2 required to generate mipmaps
if powimage == True:
if interpolation == 'Cubic': # Mipmap linear
tex['mipmap_filter'] = 'linear'
tex['generate_mipmaps'] = True
elif interpolation == 'Smart': # Mipmap anisotropic
tex['min_filter'] = 'anisotropic'
tex['mipmap_filter'] = 'linear'
tex['generate_mipmaps'] = True
elif (image_node.interpolation == 'Cubic' or image_node.interpolation == 'Smart'):
log.warn(material.name + '/' + image.name + ' - power of 2 texture required for ' + image_node.interpolation + ' interpolation')
if image_node.extension != 'REPEAT': # Extend or clip
tex['u_addressing'] = 'clamp'
tex['v_addressing'] = 'clamp'
else:
if state.target == 'html5' and powimage == False:
log.warn(material.name + '/' + image.name + ' - non power of 2 texture can not use repeat mode on HTML5 target')
tex['u_addressing'] = 'clamp'
tex['v_addressing'] = 'clamp'
if image.source == 'MOVIE': # Just append movie texture trait for now
movie_trait = {}
movie_trait['type'] = 'Script'
movie_trait['class_name'] = 'armory.trait.internal.MovieTexture'
movie_trait['parameters'] = [tex['file']]
for o in self.materialToGameObjectDict[material]:
o['traits'].append(movie_trait)
tex['source'] = 'movie'
tex['file'] = '' # MovieTexture will load the video
return tex
def parse_value_node(node):
return node.outputs[0].default_value
def parse_float_input(tree, node, inp):
if inp.is_linked:
float_node = nodes.find_node_by_link(tree, node, inp)
if float_node.type == 'VALUE':
return parse_value_node(float_node)
else:
return inp.default_value
def parse_material_displacement(self, material, c, defs, tree, node, factor):
# Normal
if node.type == 'NORMAL_MAP':
normal_map_input = node.inputs[1]
parse_normal_map_socket(self, normal_map_input, material, c, defs, tree, node, factor)
def parse_material_surface(self, material, c, defs, tree, node, factor):
if node.type == 'GROUP' and node.node_tree.name.split('.', 1)[0] == 'Armory PBR':
parse_pbr_group(self, material, c, defs, tree, node, factor)
elif node.type == 'BSDF_TRANSPARENT':
parse_bsdf_transparent(self, material, c, defs, tree, node, factor)
elif node.type == 'BSDF_DIFFUSE':
parse_bsdf_diffuse(self, material, c, defs, tree, node, factor)
elif node.type == 'EMISSION':
parse_emission(self, material, c, defs, tree, node, factor)
elif node.type == 'BSDF_GLOSSY':
parse_bsdf_glossy(self, material, c, defs, tree, node, factor)
# elif node.type == 'BSDF_TRANSLUCENT':
# parse_bsdf_translucent(self, material, c, defs, tree, node, factor)
elif node.type == 'BSDF_GLASS':
parse_bsdf_glass(self, material, c, defs, tree, node, factor)
elif node.type == 'SUBSURFACE_SCATTERING':
parse_sss(self, material, c, defs, tree, node, factor)
elif node.type == 'BSDF_TOON':
parse_bsdf_toon(self, material, c, defs, tree, node, factor)
elif node.type == 'MIX_SHADER':
parse_mix_shader(self, material, c, defs, tree, node, factor)
else:
print('Armory Warning: Material node ' + node.type + ' in ' + material.name + ' is not yet supported! Please use "Armory PBR" node group for now.')
def parse_mix_shader(self, material, c, defs, tree, node, factor):
mixfactor = node.inputs[0].default_value * factor
if node.inputs[1].is_linked:
mixfactor0 = 1.0 - mixfactor
surface1_node = nodes.find_node_by_link(tree, node, node.inputs[1])
parse_material_surface(self, material, c, defs, tree, surface1_node, mixfactor0)
if node.inputs[2].is_linked:
surface2_node = nodes.find_node_by_link(tree, node, node.inputs[2])
parse_material_surface(self, material, c, defs, tree, surface2_node, mixfactor)
def parse_bsdf_transparent(self, material, c, defs, tree, node, factor):
# defs.append('_AlphaTest')
pass
def parse_sss(self, material, c, defs, tree, node, factor):
# Set stencil mask
# append '_SSS' to deferred_light
pass
def parse_bsdf_toon(self, material, c, defs, tree, node, factor):
# set pipe pass
defs.append('_Toon')
pass
def parse_bsdf_diffuse(self, material, c, defs, tree, node, factor):
# Color
base_color_input = node.inputs[0]
parse_base_color_socket(self, base_color_input, material, c, defs, tree, node, factor)
# Parse roughness but force 0.4 as minimum, set 0.0 metalness
add_metalness_const(0.0, c, factor)
roughness_input = node.inputs[1]
parse_roughness_socket(self, roughness_input, material, c, defs, tree, node, factor, minimum_val=0.4)
# Normal
normal_input = node.inputs[2]
if normal_input.is_linked:
normal_map_node = nodes.find_node_by_link(tree, node, normal_input)
if normal_map_node.type == 'NORMAL_MAP':
normal_map_input = normal_map_node.inputs[1]
parse_normal_map_socket(self, normal_map_input, material, c, defs, tree, normal_map_node, factor)
def parse_emission(self, material, c, defs, tree, node, factor):
# Color
base_color_input = node.inputs[0]
parse_base_color_socket(self, base_color_input, material, c, defs, tree, node, factor)
# Multiply color by strength
strength_input = node.inputs[1]
strength = strength_input.default_value * 50.0 + 1.0
if parse.const_color == None:
make_albedo_const([1.0, 1.0, 1.0, 1.0], c)
col = parse.const_color['vec4']
col[0] *= strength
col[1] *= strength
col[2] *= strength
parse.const_color['vec4'] = [col[0], col[1], col[2], col[3]]
def parse_bsdf_glossy(self, material, c, defs, tree, node, factor):
# Mix with current color
base_color_input = node.inputs[0]
parse_base_color_socket(self, base_color_input, material, c, defs, tree, node, factor)
# Parse sqrt roughness and set 1.0 metalness
add_metalness_const(1.0, c, factor)
roughness_input = node.inputs[1]
parse_roughness_socket(self, roughness_input, material, c, defs, tree, node, factor, sqrt_val=True)
def parse_bsdf_glass(self, material, c, defs, tree, node, factor):
# Mix with current color
base_color_input = node.inputs[0]
parse_base_color_socket(self, base_color_input, material, c, defs, tree, node, factor)
# Calculate alpha, TODO: take only glass color into account, separate getSocketColor method
if parse.const_color == None:
make_albedo_const([1.0, 1.0, 1.0, 1.0], c)
col = parse.const_color['vec4']
sum = (col[0] + col[1] + col[2]) / 3
# Roughly guess color to match cycles
mincol = min(col[:3])
parse.const_color['vec4'] = [col[0] - mincol, col[1] - mincol, col[2] - mincol, 1.0 - (sum * 0.7)]
# Parse sqrt roughness and set 0.0 metalness
add_metalness_const(0.0, c, factor)
roughness_input = node.inputs[1]
parse_roughness_socket(self, roughness_input, material, c, defs, tree, node, factor, sqrt_val=True)
# Append translucent
defs.append('_Translucent')
def mix_float(f1, f2, factor=0.5):
return (f1 + f2) * factor
def mix_color_vec4(col1, col2, factor=0.5):
return [mix_float(col1[0], col2[0], factor), mix_float(col1[1], col2[1], factor), mix_float(col1[2], col2[2], factor), mix_float(col1[3], col2[3], factor)]
def parse_val_to_rgb(node, c, defs):
factor = node.inputs[0].default_value
if not node.inputs[0].is_linked: # Take ramp color
return node.color_ramp.evaluate(factor)
else: # Assume 2 colors interpolated by id for now
defs.append('_RampID')
# Link baseCol2 as color 2
const = {}
c['bind_constants'].append(const)
const['name'] = 'baseCol2'
res = node.color_ramp.elements[1].color
const['vec4'] = [res[0], res[1], res[2], res[3]]
# Return color 1
return node.color_ramp.elements[0].color
def add_base_color(c, col):
if parse.const_color == None:
make_albedo_const(col, c)
else:
const = parse.const_color
res = mix_color_vec4(col, const['vec4'])
const['vec4'] = [res[0], res[1], res[2], res[3]]
def parse_mix_rgb(self, material, c, defs, tree, node, factor):
# blend_type = MULTIPLY
# use_clamp = False
# Factor, col1, col2
parse_base_color_socket(self, node.inputs[1], material, c, defs, tree, node, factor)
# Assume color 2 as occlusion
parse_occlusion_socket(self, node.inputs[2], material, c, defs, tree, node, factor)
def add_albedo_tex(self, node, material, c, defs):
if '_BaseTex' not in defs:
defs.append('_BaseTex')
tex = make_texture(self, 'sbase', node, material)
c['bind_textures'].append(tex)
def add_metalness_tex(self, node, material, c, defs):
if '_MetTex' not in defs:
defs.append('_MetTex')
tex = make_texture(self, 'smetal', node, material, image_format='R8')
c['bind_textures'].append(tex)
if parse.const_metalness != None: # If texture is used, remove constant
c['bind_constants'].remove(parse.const_metalness)
def add_roughness_tex(self, node, material, c, defs):
if '_RoughTex' not in defs:
defs.append('_RoughTex')
tex = make_texture(self, 'srough', node, material, image_format='R8')
c['bind_textures'].append(tex)
if parse.const_roughness != None:
c['bind_constants'].remove(parse.const_roughness)
def add_roughness_strength(self, c, defs, f):
if '_RoughStr' not in defs:
defs.append('_RoughStr')
const = {}
c['bind_constants'].append(const)
const['name'] = 'roughnessStrength'
const['float'] = f
def add_occlusion_tex(self, node, material, c, defs):
if '_OccTex' not in defs:
defs.append('_OccTex')
tex = make_texture(self, 'socclusion', node, material, image_format='R8')
c['bind_textures'].append(tex)
def add_height_tex(self, node, material, c, defs):
if '_HeightTex' not in defs:
defs.append('_HeightTex')
tex = make_texture(self, 'sheight', node, material, image_format='R8')
c['bind_textures'].append(tex)
def add_opacity_tex(self, node, material, c, defs):
if '_OpacTex' not in defs:
defs.append('_OpacTex')
tex = make_texture(self, 'sopacity', node, material, image_format='R8')
c['bind_textures'].append(tex)
def add_height_strength(self, c, f):
const = {}
c['bind_constants'].append(const)
const['name'] = 'heightStrength'
const['float'] = f / 10 # 1.0 = 0.1 as default
def add_normal_tex(self, node, material, c, defs):
if '_NorTex' not in defs:
defs.append('_NorTex')
tex = make_texture(self, 'snormal', node, material)
c['bind_textures'].append(tex)
def add_normal_strength(self, c, defs, f):
if '_NorStr' not in defs:
defs.append('_NorStr')
const = {}
c['bind_constants'].append(const)
const['name'] = 'normalStrength'
const['float'] = f
def parse_image_vector(node, defs, tree, def_name1):
# Check attribute linked to image vector to figure out referenced uvmap
vector_input = node.inputs[0]
if vector_input.is_linked:
vector_node = nodes.find_node_by_link(tree, node, vector_input)
if vector_node.type == 'ATTRIBUTE':
if vector_node.outputs[1].is_linked:
# References second uv map
if len(uvlayers) > 1 and vector_node.attribute_name == uvlayers[1]:
if def_name1 not in defs:
defs.append(def_name1)
if '_Tex1' not in defs:
defs.append('_Tex1')
def parse_base_color_socket(self, base_color_input, material, c, defs, tree, node, factor):
if base_color_input.is_linked:
color_node = nodes.find_node_by_link(tree, node, base_color_input)
if color_node.type == 'TEX_IMAGE':
add_albedo_tex(self, color_node, material, c, defs)
parse_image_vector(color_node, defs, tree, '_BaseTex1')
elif color_node.type == 'TEX_CHECKER':
pass
elif color_node.type == 'ATTRIBUTE': # Assume vcols for now
defs.append('_VCols')
elif color_node.type == 'VALTORGB':
col = parse_val_to_rgb(color_node, c, defs)
add_base_color(c, col)
elif color_node.type == 'MIX_RGB':
parse_mix_rgb(self, material, c, defs, tree, color_node, factor)
else: # Take node color
add_base_color(c, base_color_input.default_value)
def add_metalness_const(res, c, factor, minimum_val=0.0, sqrt_val=False):
if res < minimum_val:
res = minimum_val
if sqrt_val:
res = math.sqrt(res)
if parse.const_metalness == None:
make_metalness_const(res * factor, c)
else:
const = parse.const_metalness
const['float'] = mix_float(res, const['float'], factor=factor)
def parse_metalness_socket(self, metalness_input, material, c, defs, tree, node, factor, minimum_val=0.0, sqrt_val=False):
if metalness_input.is_linked:
metalness_node = nodes.find_node_by_link(tree, node, metalness_input)
if metalness_node.type == 'TEX_IMAGE':
add_metalness_tex(self, metalness_node, material, c, defs)
parse_image_vector(metalness_node, defs, tree, '_MetTex1')
elif '_MetTex' not in defs:
res = metalness_input.default_value
add_metalness_const(res, c, factor, minimum_val, sqrt_val)
def add_roughness_const(res, c, factor, minimum_val=0.0, sqrt_val=False):
if res < minimum_val:
res = minimum_val
if sqrt_val:
res = math.sqrt(res)
if parse.const_roughness == None:
make_roughness_const(res * factor, c)
else:
const = parse.const_roughness
const['float'] = mix_float(res, const['float'], factor=factor)
def parse_roughness_socket(self, roughness_input, material, c, defs, tree, node, factor, minimum_val=0.0, sqrt_val=False):
if roughness_input.is_linked:
roughness_node = nodes.find_node_by_link(tree, node, roughness_input)
if roughness_node.type == 'TEX_IMAGE':
add_roughness_tex(self, roughness_node, material, c, defs)
parse_image_vector(roughness_node, defs, tree, '_RoughTex1')
elif '_RoughTex' not in defs:
res = parse_float_input(tree, node, roughness_input)
add_roughness_const(res, c, factor, minimum_val, sqrt_val)
def parse_normal_map_socket(self, normal_input, material, c, defs, tree, node, factor):
if normal_input.is_linked:
normal_node = nodes.find_node_by_link(tree, node, normal_input)
if normal_node.type == 'TEX_IMAGE':
add_normal_tex(self, normal_node, material, c, defs)
parse_image_vector(normal_node, defs, tree, '_NorTex1')
def add_occlusion_const(res, c, factor):
if parse.const_occlusion == None:
make_occlusion_const(res * factor, c)
else:
const = parse.const_occlusion
const['float'] = mix_float(res, const['float'], factor=factor)
def parse_occlusion_socket(self, occlusion_input, material, c, defs, tree, node, factor):
if occlusion_input.is_linked:
occlusion_node = nodes.find_node_by_link(tree, node, occlusion_input)
if occlusion_node.type == 'TEX_IMAGE':
add_occlusion_tex(self, occlusion_node, material, c, defs)
parse_image_vector(occlusion_node, defs, tree, '_OccTex1')
elif '_OccTex' not in defs:
res = occlusion_input.default_value[0] # Take only one channel
add_occlusion_const(res, c, factor)
def parse_height_socket(self, height_input, material, c, defs, tree, node, factor):
# Not all targets can tessellate
if state.target != 'krom' and state.target != 'native':
return
wrd = bpy.data.worlds['Arm']
if height_input.is_linked and wrd.tessellation_enabled:
height_node = nodes.find_node_by_link(tree, node, height_input)
if height_node.type == 'TEX_IMAGE':
add_height_tex(self, height_node, material, c, defs)
parse_image_vector(height_node, defs, tree, '_HeightTex1')
def parse_opacity_socket(self, opacity_input, opacity_strength_input, material, c, defs, tree, node, factor):
# Image has to linked
if opacity_input.is_linked:
opacity_node = nodes.find_node_by_link(tree, node, opacity_input)
if opacity_node.type == 'TEX_IMAGE':
# Image Color is linked to opacity, add opacity texture
if opacity_input.links[0].from_socket.name == 'Color':
add_opacity_tex(self, opacity_node, material, c, defs)
parse_image_vector(opacity_node, defs, tree, '_OpacTex1')
defs.append('_Translucent')
# Otherwise use base color alpha
elif opacity_input.links[0].from_socket.name == 'Alpha':
defs.append('_Translucent')
# Take default value
else:
opacity = opacity_input.default_value
opacity_strength = opacity_strength_input.default_value
opacity_val = opacity * opacity_strength
if opacity_val != 1.0:
if parse.const_color == None:
make_albedo_const([1.0, 1.0, 1.0, 1.0], c)
col = parse.const_color['vec4']
parse.const_color['vec4'] = [col[0], col[1], col[2], opacity_val]
defs.append('_Translucent')
def parse_pbr_group(self, material, c, defs, tree, node, factor):
# Albedo Map
base_color_input = node.inputs[0]
parse_base_color_socket(self, base_color_input, material, c, defs, tree, node, factor)
# Occlusion Map
occlusion_input = node.inputs[1]
# occlusion_strength_input = node.inputs[2]
# occlusion_strength = occlusion_strength_input.default_value
parse_occlusion_socket(self, occlusion_input, material, c, defs, tree, node, factor)
# Roughness Map
roughness_input = node.inputs[3]
parse_roughness_socket(self, roughness_input, material, c, defs, tree, node, factor)
roughness_strength_input = node.inputs[4]
roughness_strength = roughness_strength_input.default_value
if roughness_strength != 1.0:
if roughness_input.is_linked:
add_roughness_strength(self, c, defs, roughness_strength)
else:
# No texture, multiply roughness float instead
const = parse.const_roughness
const['float'] *= roughness_strength
# Metalness Map
metalness_input = node.inputs[5]
parse_metalness_socket(self, metalness_input, material, c, defs, tree, node, factor)
# Normal Map
normal_map_input = node.inputs[6]
parse_normal_map_socket(self, normal_map_input, material, c, defs, tree, node, factor)
normal_strength_input = node.inputs[7]
normal_strength = normal_strength_input.default_value
# Strenght only for normal maps
if normal_map_input.is_linked and normal_strength != 1.0:
add_normal_strength(self, c, defs, normal_strength)
# Emission
emission_input = node.inputs[8]
emission_strength_input = node.inputs[9]
emission_strength = emission_strength_input.default_value
if emission_strength != 1.0: # Just multiply base color for now
if parse.const_color == None:
make_albedo_const([1.0, 1.0, 1.0, 1.0], c)
col = parse.const_color['vec4']
col[0] *= emission_strength
col[1] *= emission_strength
col[2] *= emission_strength
parse.const_color['vec4'] = [col[0], col[1], col[2], col[3]]
# Height Map
height_input = node.inputs[10]
parse_height_socket(self, height_input, material, c, defs, tree, node, factor)
# Height Strength
if height_input.is_linked:
height_strength_input = node.inputs[11]
add_height_strength(self, c, height_strength_input.default_value)
# Opacity
opacity_input = node.inputs[12]
opacity_strength_input = node.inputs[13]
parse_opacity_socket(self, opacity_input, opacity_strength_input, material, c, defs, tree, node, factor)

View file

@ -249,6 +249,8 @@ def make_draw_compositor(stage, node_group, node, with_fxaa=False):
if compo_depth:
compositor_defs += '_CompoDepth'
wrd.compo_defs = compositor_defs
defs = world_defs + compositor_defs
data_name = scon + defs

View file

@ -74,10 +74,6 @@ def init_properties():
bpy.types.World.arm_lod_advanced = BoolProperty(name="Advanced", default=False)
bpy.types.World.arm_lod_gen_levels = IntProperty(name="Levels", description="Number of levels to generate", default=3, min=1)
bpy.types.World.arm_lod_gen_ratio = FloatProperty(name="Decimate Ratio", description="Decimate ratio", default=0.8)
bpy.types.World.arm_material_level = EnumProperty(
items=[('Restricted', 'Restricted', 'Restricted'),
('Full', 'Full', 'Full')],
name="Materials", description="Node parser to use when building materials", default="Full")
bpy.types.World.arm_cache_shaders = BoolProperty(name="Cache Shaders", description="Do not rebuild existing shaders", default=True, update=assets.invalidate_shader_cache)
#bpy.types.World.arm_cache_envmaps = BoolProperty(name="Cache Envmaps", description="Do not remove prefiltered maps when cleaning project", default=True)
bpy.types.World.arm_play_live_patch = BoolProperty(name="Live Patching", description="Sync running player data to Blender", default=True)
@ -235,6 +231,7 @@ def init_properties():
bpy.types.World.world_envtex_turbidity = bpy.props.FloatProperty(name="Turbidity", default=1.0)
bpy.types.World.world_envtex_ground_albedo = bpy.props.FloatProperty(name="Ground Albedo", default=0.0)
bpy.types.World.world_defs = bpy.props.StringProperty(name="World Shader Defs", default='')
bpy.types.World.compo_defs = bpy.props.StringProperty(name="Compositor Shader Defs", default='')
bpy.types.World.generate_radiance = bpy.props.BoolProperty(name="Probe Radiance", default=True, update=assets.invalidate_shader_cache)
bpy.types.World.generate_radiance_size = EnumProperty(
items=[('512', '512', '512'),

View file

@ -383,7 +383,6 @@ class ArmoryBuildPanel(bpy.types.Panel):
layout.prop(wrd, 'arm_optimize_mesh')
layout.prop(wrd, 'arm_sampled_animation')
layout.prop(wrd, 'arm_deinterleaved_buffers')
layout.prop(wrd, 'arm_material_level')
layout.label('Libraries')
layout.prop(wrd, 'arm_physics')
layout.prop(wrd, 'arm_navigation')