More deferred rendering.
This commit is contained in:
parent
73325c8244
commit
1fc28ceacd
|
@ -11,6 +11,14 @@ os.chdir('./forward')
|
|||
make_resources.make('forward.shader.json')
|
||||
make_variants.make('forward.shader.json')
|
||||
|
||||
os.chdir('../deferred')
|
||||
make_resources.make('deferred.shader.json')
|
||||
make_variants.make('deferred.shader.json')
|
||||
|
||||
os.chdir('../deferred_light')
|
||||
make_resources.make('deferred_light.shader.json')
|
||||
make_variants.make('deferred_light.shader.json')
|
||||
|
||||
os.chdir('../env_map')
|
||||
make_resources.make('env_map.shader.json')
|
||||
make_variants.make('env_map.shader.json')
|
||||
|
@ -27,10 +35,10 @@ make_variants.make('env_map.shader.json')
|
|||
# make_resources.make('combine_pass.shader.json')
|
||||
# make_variants.make('combine_pass.shader.json')
|
||||
|
||||
os.chdir('../pt_trace_pass')
|
||||
make_resources.make('pt_trace_pass.shader.json')
|
||||
make_variants.make('pt_trace_pass.shader.json')
|
||||
# os.chdir('../pt_trace_pass')
|
||||
# make_resources.make('pt_trace_pass.shader.json')
|
||||
# make_variants.make('pt_trace_pass.shader.json')
|
||||
|
||||
os.chdir('../pt_final_pass')
|
||||
make_resources.make('pt_final_pass.shader.json')
|
||||
make_variants.make('pt_final_pass.shader.json')
|
||||
# os.chdir('../pt_final_pass')
|
||||
# make_resources.make('pt_final_pass.shader.json')
|
||||
# make_variants.make('pt_final_pass.shader.json')
|
||||
|
|
82
raw/deferred/deferred.frag.glsl
Normal file
82
raw/deferred/deferred.frag.glsl
Normal file
|
@ -0,0 +1,82 @@
|
|||
#version 450
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
#ifdef _NMTex
|
||||
#define _AMTex
|
||||
#endif
|
||||
|
||||
#ifdef _AMTex
|
||||
uniform sampler2D salbedo;
|
||||
#endif
|
||||
#ifdef _NMTex
|
||||
uniform sampler2D snormal;
|
||||
#endif
|
||||
#ifdef _OMTex
|
||||
uniform sampler2D som;
|
||||
#endif
|
||||
#ifdef _RMTex
|
||||
uniform sampler2D srm;
|
||||
#else
|
||||
uniform float roughness;
|
||||
#endif
|
||||
#ifdef _MMTex
|
||||
uniform sampler2D smm;
|
||||
#else
|
||||
uniform float metalness;
|
||||
#endif
|
||||
|
||||
in vec3 position;
|
||||
#ifdef _AMTex
|
||||
in vec2 texCoord;
|
||||
#endif
|
||||
in vec4 lPos;
|
||||
in vec4 matColor;
|
||||
in vec3 lightDir;
|
||||
in vec3 eyeDir;
|
||||
#ifdef _NMTex
|
||||
in mat3 TBN;
|
||||
#else
|
||||
in vec3 normal;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
#ifdef _NMTex
|
||||
vec3 n = (texture(snormal, texCoord).rgb * 2.0 - 1.0);
|
||||
n = normalize(TBN * normalize(n));
|
||||
#else
|
||||
vec3 n = normalize(normal);
|
||||
#endif
|
||||
|
||||
#ifdef _AMTex
|
||||
vec4 texel = texture(salbedo, texCoord);
|
||||
#ifdef _AlphaTest
|
||||
if(texel.a < 0.4)
|
||||
discard;
|
||||
#endif
|
||||
vec3 baseColor = texel.rgb;
|
||||
#else
|
||||
vec3 baseColor = matColor.rgb;
|
||||
#endif
|
||||
|
||||
#ifdef _MMTex
|
||||
float metalness = texture(smm, texCoord).r;
|
||||
#endif
|
||||
|
||||
#ifdef _RMTex
|
||||
float roughness = texture(srm, texCoord).r;
|
||||
#endif
|
||||
|
||||
#ifdef _OMTex
|
||||
float occlusion = texture(som, texCoord).r;
|
||||
#else
|
||||
float occlusion = 0.0;
|
||||
#endif
|
||||
|
||||
gl_FragData[0] = vec4(position.xyz, metalness);
|
||||
gl_FragData[1] = vec4(normal.xyz, roughness);
|
||||
gl_FragData[2] = vec4(baseColor.rgb, occlusion);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"contexts": [
|
||||
{
|
||||
"id": "deferred_attrib",
|
||||
"id": "deferred",
|
||||
"params": [
|
||||
{
|
||||
"id": "depth_write",
|
||||
|
@ -42,8 +42,8 @@
|
|||
"link": "_projectionMatrix"
|
||||
},
|
||||
{
|
||||
"id": "lightMVP",
|
||||
"link": "_lightMVP"
|
||||
"id": "LMVP",
|
||||
"link": "_lightModelViewProjectionMatrix"
|
||||
},
|
||||
{
|
||||
"id": "light",
|
||||
|
@ -59,8 +59,8 @@
|
|||
"ifdef": "_Skinning"
|
||||
}
|
||||
],
|
||||
"vertex_shader": "deferred_attrib.vert.glsl",
|
||||
"fragment_shader": "deferred_attrib.frag.glsl"
|
||||
"vertex_shader": "deferred.vert.glsl",
|
||||
"fragment_shader": "deferred.frag.glsl"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -4,19 +4,19 @@
|
|||
precision highp float;
|
||||
#endif
|
||||
|
||||
#ifdef _NormalMapping
|
||||
#define _Texturing
|
||||
#ifdef _NMTex
|
||||
#define _AMTex
|
||||
#endif
|
||||
|
||||
in vec3 pos;
|
||||
in vec3 nor;
|
||||
#ifdef _Texturing
|
||||
#ifdef _AMTex
|
||||
in vec2 tex;
|
||||
#endif
|
||||
#ifdef _VCols
|
||||
in vec4 col;
|
||||
#endif
|
||||
#ifdef _NormalMapping
|
||||
#ifdef _NMTex
|
||||
in vec3 tan;
|
||||
#endif
|
||||
#ifdef _Skinning
|
||||
|
@ -31,8 +31,8 @@ uniform mat4 M;
|
|||
uniform mat4 NM;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
uniform mat4 lightMVP;
|
||||
uniform vec4 diffuseColor;
|
||||
uniform mat4 LMVP;
|
||||
uniform vec4 albedo_color;
|
||||
uniform vec3 light;
|
||||
uniform vec3 eye;
|
||||
#ifdef _Skinning
|
||||
|
@ -40,21 +40,17 @@ uniform float skinBones[50 * 12];
|
|||
#endif
|
||||
|
||||
out vec3 position;
|
||||
#ifdef _Texturing
|
||||
#ifdef _AMTex
|
||||
out vec2 texCoord;
|
||||
#endif
|
||||
out vec3 normal;
|
||||
out vec4 lPos;
|
||||
out vec4 matColor;
|
||||
out vec3 lightDir;
|
||||
out vec3 eyeDir;
|
||||
|
||||
#ifdef _NormalMapping
|
||||
mat3 transpose(mat3 m) {
|
||||
return mat3(m[0][0], m[1][0], m[2][0],
|
||||
m[0][1], m[1][1], m[2][1],
|
||||
m[0][2], m[1][2], m[2][2]);
|
||||
}
|
||||
#ifdef _NMTex
|
||||
out mat3 TBN;
|
||||
#else
|
||||
out vec3 normal;
|
||||
#endif
|
||||
|
||||
#ifdef _Skinning
|
||||
|
@ -101,37 +97,48 @@ void main() {
|
|||
mat3 skinningMatVec = getSkinningMatVec(skinningMat);
|
||||
sPos = sPos * skinningMat;
|
||||
#endif
|
||||
vec4 mPos = M * sPos;
|
||||
lPos = lightMVP * sPos;
|
||||
lPos = LMVP * sPos;
|
||||
|
||||
gl_Position = P * V * mPos;
|
||||
position = mPos.xyz / mPos.w;
|
||||
mat4 VM = V * M;
|
||||
|
||||
#ifdef _Texturing
|
||||
#ifdef _Billboard
|
||||
// Spherical
|
||||
VM[0][0] = 1.0; VM[0][1] = 0.0; VM[0][2] = 0.0;
|
||||
VM[1][0] = 0.0; VM[1][1] = 1.0; VM[1][2] = 0.0;
|
||||
VM[2][0] = 0.0; VM[2][1] = 0.0; VM[2][2] = 1.0;
|
||||
// Cylindrical
|
||||
//VM[0][0] = 1.0; VM[0][1] = 0.0; VM[0][2] = 0.0;
|
||||
//VM[2][0] = 0.0; VM[2][1] = 0.0; VM[2][2] = 1.0;
|
||||
#endif
|
||||
|
||||
gl_Position = P * VM * sPos;
|
||||
|
||||
#ifdef _AMTex
|
||||
texCoord = tex;
|
||||
#endif
|
||||
|
||||
#ifdef _Skinning
|
||||
normal = normalize(mat3(NM) * (nor * skinningMatVec));
|
||||
vec3 _normal = normalize(mat3(NM) * (nor * skinningMatVec));
|
||||
#else
|
||||
normal = normalize(mat3(NM) * nor);
|
||||
vec3 _normal = normalize(mat3(NM) * nor);
|
||||
#endif
|
||||
|
||||
matColor = diffuseColor;
|
||||
matColor = albedo_color;
|
||||
|
||||
#ifdef _VCols
|
||||
matColor *= col;
|
||||
#endif
|
||||
|
||||
#ifdef _NormalMapping
|
||||
vec3 vtan = (tan);
|
||||
vec3 vbitan = cross(normal, vtan) * 1.0;//tangent.w;
|
||||
|
||||
mat3 TBN = transpose(mat3(vtan, vbitan, normal));
|
||||
lightDir = normalize(TBN * lightDir);
|
||||
eyeDir = normalize(TBN * eyeDir);
|
||||
vec3 mPos = vec4(M * sPos).xyz;
|
||||
position = mPos;
|
||||
lightDir = light - mPos;
|
||||
eyeDir = eye - mPos;
|
||||
|
||||
#ifdef _NMTex
|
||||
vec3 tangent = (mat3(NM) * (tan));
|
||||
vec3 bitangent = normalize(cross(_normal, tangent));
|
||||
TBN = mat3(tangent, bitangent, _normal);
|
||||
#else
|
||||
lightDir = normalize(light - position);
|
||||
eyeDir = normalize(eye - position);
|
||||
normal = _normal;
|
||||
#endif
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_EXT_draw_buffers : require
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
#ifdef _NormalMapping
|
||||
#define _Texturing
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _Texturing
|
||||
uniform sampler2D stex;
|
||||
#endif
|
||||
uniform sampler2D shadowMap;
|
||||
#ifdef _NormalMapping
|
||||
uniform sampler2D normalMap;
|
||||
#endif
|
||||
uniform bool lighting;
|
||||
uniform bool receiveShadow;
|
||||
uniform float roughness;
|
||||
|
||||
in vec3 position;
|
||||
#ifdef _Texturing
|
||||
in vec2 texCoord;
|
||||
#endif
|
||||
in vec3 normal;
|
||||
in vec4 lPos;
|
||||
in vec4 matColor;
|
||||
in vec3 lightDir;
|
||||
in vec3 eyeDir;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_FragData[0] = vec4(position.xyz, 0);
|
||||
gl_FragData[1] = vec4(normal.xyz, 0);
|
||||
#ifdef _Texturing
|
||||
gl_FragData[2] = vec4(texture(stex, texCoord).rgb, 0);
|
||||
#endif
|
||||
}
|
|
@ -4,13 +4,16 @@
|
|||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D gbuffer0; // Positions
|
||||
uniform sampler2D gbuffer1; // Normals
|
||||
uniform sampler2D gbuffer2; // Textures
|
||||
uniform sampler2D gbuffer0; // Positions, metalness
|
||||
uniform sampler2D gbuffer1; // Normals, roughness
|
||||
uniform sampler2D gbuffer2; // Base color, occlusion
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_FragColor = vec4(texture(gbuffer2, texCoord).rgb, 1.0);
|
||||
vec3 normal = texture(gbuffer1, texCoord).rgb * 2.0 - 1.0;
|
||||
vec3 baseColor = texture(gbuffer2, texCoord).rgb;
|
||||
|
||||
gl_FragColor = vec4(baseColor, 1.0);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"params": [
|
||||
{
|
||||
"id": "depth_write",
|
||||
"value": "false"
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"id": "compare_mode",
|
||||
|
@ -25,10 +25,6 @@
|
|||
}
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"id": "cameraPosition",
|
||||
"link": "_cameraPosition"
|
||||
}
|
||||
],
|
||||
"vertex_shader": "deferred_light.vert.glsl",
|
||||
"fragment_shader": "deferred_light.frag.glsl"
|
||||
|
|
|
@ -18,7 +18,6 @@ uniform sampler2D shadowMap;
|
|||
uniform sampler2D senvmapRadiance;
|
||||
uniform sampler2D senvmapIrradiance;
|
||||
uniform sampler2D senvmapBrdf;
|
||||
uniform sampler2D gimap;
|
||||
#ifdef _NMTex
|
||||
uniform sampler2D snormal;
|
||||
#endif
|
||||
|
|
|
@ -15,8 +15,8 @@ void main() {
|
|||
float depth = position.z / position.w;
|
||||
// depth += 0.005;
|
||||
|
||||
// gl_FragDepth = depth;
|
||||
gl_FragColor = vec4(depth, 0.0, 0.0, 1.0);
|
||||
gl_FragDepth = depth;
|
||||
// gl_FragColor = vec4(depth, 0.0, 0.0, 1.0);
|
||||
|
||||
// VSM
|
||||
// float dx = dFdx(depth);
|
||||
|
|
Loading…
Reference in a new issue