camera-height.tsg 787 B

123456789101112131415
  1. //// view //// { "id": "", "UIState": { "showMainPreview": true, "showBlackBoard": true, "showInspector": true }, "type": "ShaderGraph", "version": "1.0.0", "setting": { "template": "MeshStandardNodeMaterial", "surfaceType": "Transparent", "renderFace": "FrontSide", "depthWrite": "enable", "depthTest": "enable", "depthTestFunc": "LessEqualDepth", "blendingMode": "NormalBlending", "castShadows": true }, "parameters": [], "textures": [] }
  2. (() => {
  3. const cameraHeight = tsl.cameraPosition.y;
  4. // Normalize camera height to brightness (adjust range as needed)
  5. const brightness = tsl.clamp(tsl.div(tsl.abs(cameraHeight), tsl.float(100)), tsl.float(0), tsl.float(1));
  6. material.colorNode = tsl.vec4(
  7. brightness,
  8. brightness,
  9. brightness,
  10. tsl.float(1)
  11. );
  12. })();