Created
February 2, 2022 20:45
-
-
Save supahfunk/a34a0fdfbea4bf2a69e91c89e30243a6 to your computer and use it in GitHub Desktop.
Shader Material Basic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mergeUniforms } from 'three/src/renderers/shaders/UniformsUtils.js' | |
import { UniformsLib } from 'three/src/renderers/shaders/UniformsLib.js' | |
export default { | |
uniforms: mergeUniforms([ | |
UniformsLib.lights, | |
UniformsLib.fog, | |
]), | |
vertexShader: ` | |
#include <common> | |
#include <fog_pars_vertex> | |
#include <shadowmap_pars_vertex> | |
void main() { | |
#include <begin_vertex> | |
#include <project_vertex> | |
#include <worldpos_vertex> | |
#include <shadowmap_vertex> | |
#include <fog_vertex> | |
} | |
`, | |
fragmentShader: ` | |
#include <common> | |
#include <packing> | |
#include <fog_pars_fragment> | |
#include <bsdfs> | |
#include <lights_pars_begin> | |
#include <shadowmap_pars_fragment> | |
#include <shadowmask_pars_fragment> | |
#include <dithering_pars_fragment> | |
void main() { | |
// CHANGE THAT TO YOUR NEEDS | |
// ------------------------------ | |
vec3 finalColor = vec3(0, 0.75, 0); | |
vec3 shadowColor = vec3(0, 0, 0); | |
float shadowPower = 0.5; | |
// ------------------------------ | |
// it just mixes the shadow color with the frag color | |
gl_FragColor = vec4( mix(finalColor, shadowColor, (1.0 - getShadowMask() ) * shadowPower), 1.0); | |
#include <fog_fragment> | |
#include <dithering_fragment> | |
} | |
` | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment