git-svn-id: svn://db.shs.com.ru/libs@626 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
64
qglengine/shaders/ds_geom.glsl
Normal file
64
qglengine/shaders/ds_geom.glsl
Normal file
@@ -0,0 +1,64 @@
|
||||
// vert //
|
||||
|
||||
out vec3 geom_normal;
|
||||
out mat3 TBN;
|
||||
out vec4 object_color;
|
||||
|
||||
void main(void) {
|
||||
qgl_MaterialIndex = qgl_Material;
|
||||
qgl_FragTexture = qgl_Texture;
|
||||
gl_Position = qgl_ftransform();
|
||||
|
||||
mat3 nmat = qgl_getNormalMatrix();
|
||||
geom_normal = normalize(nmat * qgl_Normal);
|
||||
TBN = nmat * mat3(qgl_Tangent, qgl_Bitangent, qgl_Normal);
|
||||
object_color = qgl_ObjectColor;
|
||||
}
|
||||
|
||||
|
||||
// frag //
|
||||
|
||||
in vec3 geom_normal;
|
||||
in mat3 TBN;
|
||||
in vec4 object_color;
|
||||
|
||||
uniform vec2 dt;
|
||||
uniform float z_near;
|
||||
|
||||
const vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
|
||||
void main(void) {
|
||||
vec2 tc = qgl_FragTexture.xy;
|
||||
|
||||
vec4 diffuse = qgl_materialTexture(QGL_MAP_DIFFUSE, tc, vec4(0)) * qgl_material[qgl_MaterialIndex].color_diffuse * object_color;
|
||||
|
||||
vec3 normal, dn;
|
||||
dn = qgl_materialTexture(QGL_MAP_NORMAL, tc, -vec4(0.5, 0.5, 1., 0.)).xyz;
|
||||
//dn.y = -dn.y;
|
||||
float dn_sl = length(dn);
|
||||
dn = TBN * dn;
|
||||
dn *= dn_sl / (length(dn) + 1E-6);
|
||||
normal = normalize(geom_normal + dn);
|
||||
|
||||
vec4 specular = qgl_materialTexture(QGL_MAP_SPECULAR, tc, vec4(0)) * qgl_material[qgl_MaterialIndex].color_specular;
|
||||
|
||||
float roughness = dot(qgl_materialTexture(QGL_MAP_ROUGHNESS, tc, vec4(0)).rgb, luma);
|
||||
roughness = clamp(roughness, 0.0001, 0.9999);
|
||||
|
||||
float reflectivity = clamp(qgl_material[qgl_MaterialIndex].reflectivity, 0., 1.);
|
||||
|
||||
vec4 emission = qgl_materialTexture(QGL_MAP_EMISSION, tc, vec4(0));
|
||||
emission *= qgl_material[qgl_MaterialIndex].color_emission;
|
||||
|
||||
float height = dot(qgl_materialTexture(QGL_MAP_RELIEF, tc, vec4(0)).rgb, luma);
|
||||
|
||||
qgl_FragData[0] = vec4(diffuse .rgb, roughness );
|
||||
qgl_FragData[1] = vec4(normal .xyz, reflectivity);
|
||||
qgl_FragData[2] = vec4(specular.rgb, height );
|
||||
qgl_FragData[3] = vec4(emission.rgb, 0/*bn.x*/);
|
||||
//qgl_FragData[4] = vec4(speed.xy, bn.yz);
|
||||
|
||||
//ivec2 itc = ivec2(gl_FragCoord.xy);
|
||||
//qgl_FragData[0].rgb = vec3(dot(n,vec3(0,0,1)));
|
||||
//qgl_FragData[0].rgb = diffuse.rgb * dot(n,vec3(0,0,1));
|
||||
}
|
||||
Reference in New Issue
Block a user