JSFiddle - React, Tailwind, and code Playground
by MrOrangeSky
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="main.css">
</head>
<body>
<script src = "https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
<script src = "https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.js"></script>
<script type = "x-shader/x-vertex" id="vertexShadow_Shader">
varying vec4 position_h; //position vector in camera space ,type vec4
void main()
{
vec4 modelViewPosition = modelViewMatrix * vec4(position, 1.0);
gl_Position = projectionMatrix * modelViewPosition;
position_h = gl_Position;
}
</script>
<script type ="x-shader/x-fragment" id = "fragmentShadow_Shader">
varying vec4 position_h;
const float PackUpscale = 256./255.;
const float UnpackDowncale = 255./256.;
const vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.);
const vec4 UnpackFactors = UnpackDowncale/ vec4(PackFactors,1.);
const float ShiftRight8 = 1./256.;
vec4 packDepthToRGBA(const in float v)
{
vec4 r = vec4(fract(v*PackFactors),v);
r.yzw-=r.xyz * ShiftRight8;
return r*PackUpscale;
}
void main()
{
lowp float depth;
depth = position_h.z;
vec4 depthTexture = packDepthToRGBA(depth);
gl_FragColor = depthTexture;
}
</script>
<script type = "x-shader/x-vertex" id="vertex2_Shader">
varying vec4 fragCoord;
varying vec2 fUv;
void main()
{
fUv = uv;
vec4 modelViewPosition = modelViewMatrix * vec4(position, 1.0);
gl_Position = projectionMatrix * modelViewPosition;
fragCoord = gl_Position;
}
</script>
<script type = "x-shader/x-fragment" id="fragment2_Shader">
uniform sampler2D depthMap;
uniform float O_SIZE;
varying vec4 fragCoord;
varying vec2 fUv;
#define A 0.01
const float UnpackDowncale =...