molstar
Version:
A comprehensive macromolecular library.
10 lines (9 loc) • 1.74 kB
TypeScript
/**
* Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*
* adapted from three.js (https://github.com/mrdoob/three.js/)
* which under the MIT License, Copyright © 2010-2019 three.js authors
*/
export declare const apply_light_color = "\n// inputs\n// - vec4 material\n// - vec3 vViewPosition\n// - vec3 normal\n// - float uMetalness\n// - float uRoughness\n// - float uReflectivity\n// - float uLightIntensity\n// - float uAmbientIntensity\n\n// outputs\n// - sets gl_FragColor\n\nvec4 color = material;\n\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0));\n\nPhysicalMaterial physicalMaterial;\nphysicalMaterial.diffuseColor = color.rgb * (1.0 - uMetalness);\nphysicalMaterial.specularRoughness = clamp(uRoughness, 0.04, 1.0);\nphysicalMaterial.specularColor = mix(vec3(0.16 * pow2(uReflectivity)), color.rgb, uMetalness);\n\nGeometricContext geometry;\ngeometry.position = -vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize(vViewPosition);\n\nIncidentLight directLight;\ndirectLight.direction = vec3(0.0, 0.0, -1.0);\ndirectLight.color = vec3(uLightIntensity);\n\nRE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);\n\nvec3 irradiance = vec3(uAmbientIntensity) * PI;\nRE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight);\n\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;\n\ngl_FragColor = vec4(outgoingLight, color.a);\n\n#ifdef dXrayShaded\n gl_FragColor.a *= 1.0 - pow(abs(dot(normal, vec3(0, 0, 1))), uXrayEdgeFalloff);\n#endif\n";