THREE.JS Blinn–Phong反射模型 高光shader

news2024/11/23 8:31:34

文章目录

          • 参考
          • 效果
          • 核心
          • 全部代码
          • 更新: 多点光(使用结构体)
          • TODO: 新增灯光更新着色器 (threejs也是这么做的 所以动态灯光开销颇大(动态visible不需要重新构建着色器))

参考

Blinn–Phong reflection model

效果
平滑着色平直着色
在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述
核心

顶点

// 法线
vNormal = normalMatrix * normal;
vNormal = normalize( vNormal );
// 点光位置
vPointLightPosition = (viewMatrix * vec4( pointLightPosition, 1.0 )).xyz;
//顶点位置
vec3 transformed = vec3( position );
vec4 mvPosition = vec4( transformed, 1.0 );
mvPosition = modelViewMatrix * mvPosition;
vViewPosition = - mvPosition.xyz;

片元
不同着色方式法线设置

#ifdef FLAT_SHADED

	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );

#else

	vec3 normal =  vNormal ;
	normal = normalize( vNormal );

#endif

vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = normalize( vViewPosition );

//光线方向
vec3 lVector = vPointLightPosition - geometryPosition;
vec3 lightDirection = normalize( lVector );	
//直接反射高光颜色
vec3 phongColor = BRDF_BlinnPhong( lightDirection, geometryViewDir, geometryNormal, vec3(1), 30.);
全部代码
import * as THREE from "three";

const bsdfs_glsl = /* glsl */ `

    float pow2( const in float x ) { return x*x; }
    vec3 pow2( const in vec3 x ) { return x*x; }
    float pow4( const in float x ) { float x2 = x*x; return x2*x2; }

    // 距离衰减
    float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
            
        float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );

        if ( cutoffDistance > 0.0 ) {

            distanceFalloff *= pow2( clamp( 1.0 - pow4( lightDistance / cutoffDistance ) ,0. ,1.) );

        }

        return distanceFalloff;

    }

    // common.glsl.js
    vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {

        // Original approximation by Christophe Schlick '94
        // float fresnel = pow( 1.0 - dotVH, 5.0 );

        // Optimized variant (presented by Epic at SIGGRAPH '13)
        // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
        float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );

        return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );

    }

    float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {

        // Original approximation by Christophe Schlick '94
        // float fresnel = pow( 1.0 - dotVH, 5.0 );

        // Optimized variant (presented by Epic at SIGGRAPH '13)
        // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
        float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );

        return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );

    }

    // bsdfs.glsl.js

    float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {

        // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)
        return 0.25;

    }

    float D_BlinnPhong( const in float shininess, const in float dotNH ) {

        return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );

    }

    vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {

        vec3 halfDir = normalize( lightDir + viewDir );

        float dotNH = clamp( dot( normal, halfDir ) ,0.,1.);
        float dotVH = clamp( dot( viewDir, halfDir ) ,0.,1.);

        vec3 F = F_Schlick( specularColor, 1.0, dotVH );

        float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );

        float D = D_BlinnPhong( shininess, dotNH );

        return F * ( G * D );

    }
`;

export class SpecularShaderMaterial extends THREE.ShaderMaterial {
    constructor(
        params?: ConstructorParameters<typeof THREE.ShaderMaterial>[0] & {
            pointLightPosition: THREE.Vector3;
            pointLightDistance: number;
            pointLightDecay: number;
        }
    ) {
        super({
            uniforms: {
                pointLightPosition: {
                    value: params!.pointLightPosition,
                },
                pointLightDistance: {
                    value: params?.pointLightDistance ?? 100,
                },
                pointLightDecay: {
                    value: params?.pointLightDecay ?? 2,
                },
            },
            defines: {
                RECIPROCAL_PI: 1 / Math.PI,
                // 平直着色 关闭则 平滑着色
                FLAT_SHADED: false,
            },
            vertexShader: /* glsl */ `
                varying vec3 vNormal;
                varying vec3 vertexPosition;
                uniform vec3 pointLightPosition;
                varying vec3 vPointLightPosition;
                
                varying vec3 vViewPosition;

                void main() {

                    vNormal = normalMatrix * normal;
                    vNormal = normalize( vNormal );

                    vec4 modelViewPosition = modelViewMatrix * vec4(position, 1.0);
                    gl_Position = projectionMatrix * modelViewPosition;
                    vertexPosition = modelViewPosition.xyz;
                    vPointLightPosition = (viewMatrix * vec4( pointLightPosition, 1.0 )).xyz;

                    vec3 transformed = vec3( position );

                    vec4 mvPosition = vec4( transformed, 1.0 );
                    
                    mvPosition = modelViewMatrix * mvPosition;

	                vViewPosition = - mvPosition.xyz;

                }`,
            fragmentShader: /* glsl */ `
                varying vec3 vNormal;               
                varying vec3 vertexPosition;
                varying vec3 vPointLightPosition;
                
                uniform vec3 pointLightPosition;
                uniform float pointLightDistance;
                uniform float pointLightDecay;
                varying vec3 vViewPosition;

                ${bsdfs_glsl}

                void main() {

                    #ifdef FLAT_SHADED

                        vec3 fdx = dFdx( vViewPosition );
                        vec3 fdy = dFdy( vViewPosition );
                        vec3 normal = normalize( cross( fdx, fdy ) );

                    #else

                        vec3 normal =  vNormal ;
                        normal = normalize( vNormal );

                    #endif

                    vec3 geometryPosition = - vViewPosition;
                    vec3 geometryNormal = normal;
                    vec3 geometryViewDir = normalize( vViewPosition );

                    // 取自 getPointLightInfo
                    // vec3 lVector = pointLightPosition - geometryPosition;
                    vec3 lVector = vPointLightPosition - geometryPosition;
            
                    vec3 lightDirection = normalize( lVector );
            
                    float lightDistance = length( lVector );
            
                    vec3 lightColor = vec3( 1. );
                    lightColor *= getDistanceAttenuation( lightDistance, pointLightDistance, pointLightDecay );

                    // 取自 RE_Direct_BlinnPhong
                    float dotNL = clamp( dot( geometryNormal, lightDirection ) ,0. ,1. );
                    vec3 irradiance = dotNL * lightColor;
                
                    // vec3 reflectedLightDirectSpecular = irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
                    vec3 phongColor = BRDF_BlinnPhong( lightDirection, geometryViewDir, geometryNormal, vec3(1), 30.);

                    // gl_FragColor = vec4(vec3( irradiance ) , 1. );
                    gl_FragColor = vec4(vec3( phongColor ) , 1. );
                    // gl_FragColor = vec4(vec3( lightDirection ) , 1. );
                    // gl_FragColor = vec4(vec3( pointLightPosition ) , 1. );
                    // gl_FragColor = vec4(vec3( vPointLightPosition ) , 1. );
                    // gl_FragColor = vec4(vec3( normal ) , 1. );
                    // gl_FragColor = vec4(vec3( lightColor ) , 1. );
                    // gl_FragColor = vec4(vec3( irradiance ) , 1. );
                }`,
        });
    }
}

更新: 多点光(使用结构体)
import * as THREE from "three";

interface PointLightUniforms {
    color: THREE.PointLight["color"];
    decay: THREE.PointLight["decay"];
    position: THREE.PointLight["position"];
    distance: THREE.PointLight["distance"];
}

const bsdfs_glsl = /* glsl */ `

    float pow2( const in float x ) { return x*x; }
    vec3 pow2( const in vec3 x ) { return x*x; }
    float pow4( const in float x ) { float x2 = x*x; return x2*x2; }

    // 距离衰减
    float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
            
        float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );

        if ( cutoffDistance > 0.0 ) {

            distanceFalloff *= pow2( clamp( 1.0 - pow4( lightDistance / cutoffDistance ) ,0. ,1.) );

        }

        return distanceFalloff;

    }

    // common.glsl.js
    vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {

        // Original approximation by Christophe Schlick '94
        // float fresnel = pow( 1.0 - dotVH, 5.0 );

        // Optimized variant (presented by Epic at SIGGRAPH '13)
        // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
        float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );

        return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );

    }

    float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {

        // Original approximation by Christophe Schlick '94
        // float fresnel = pow( 1.0 - dotVH, 5.0 );

        // Optimized variant (presented by Epic at SIGGRAPH '13)
        // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
        float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );

        return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );

    }

    // bsdfs.glsl.js

    float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {

        // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)
        return 0.25;

    }

    float D_BlinnPhong( const in float shininess, const in float dotNH ) {

        return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );

    }

    vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {

        vec3 halfDir = normalize( lightDir + viewDir );

        float dotNH = clamp( dot( normal, halfDir ) ,0.,1.);
        float dotVH = clamp( dot( viewDir, halfDir ) ,0.,1.);

        vec3 F = F_Schlick( specularColor, 1.0, dotVH );

        float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );

        float D = D_BlinnPhong( shininess, dotNH );

        return F * ( G * D );

    }
`;

/** Blinn-Phong模型 直接反射高光材质(暂止支持点光源) */
export class SpecularShaderMaterial extends THREE.ShaderMaterial {
    PointLights: PointLightUniforms[] = [];
    original: ConstructorParameters<typeof THREE.ShaderMaterial>[0];

    onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void {
        const PointLights: PointLightUniforms[] = [];

        const viewMatrix = camera.matrixWorldInverse;

        scene.traverse((obj) => {
            if (obj.type == "PointLight") {
                const light = obj as THREE.PointLight;
                const uniforms = {
                    color: light.color.clone(),
                    decay: light.decay,
                    position: new THREE.Vector3(),
                    distance: light.distance,
                    /** 采集visible信息 不用更新着色器 (新增灯光则需要重新构建着色器) */
                    visible: light.visible ? 1 : 0,
                };
                // uniforms.color.multiplyScalar(light.intensity);
                uniforms.position.setFromMatrixPosition(light.matrixWorld);
                uniforms.position.applyMatrix4(viewMatrix);
                PointLights.push(uniforms);
            }
        });

        // this.fragmentShader = this.replaceLightNums(this.original!.fragmentShader!, {
        //     numPointLights: PointLights.length,
        // });

        this.uniforms.pointLights.value = PointLights;
    }

    constructor(
        params?: ConstructorParameters<typeof THREE.ShaderMaterial>[0] & {
            // pointLightPosition: THREE.Vector3;
            // pointLightDistance: number;
            // pointLightDecay: number;
            scene: THREE.Scene;
            camera: THREE.PerspectiveCamera;
        }
    ) {
        const original = {
            uniforms: {
                pointLights: {
                    value: [] as PointLightUniforms[],
                },
            },
            defines: {
                RECIPROCAL_PI: 1 / Math.PI,
                // 平直着色 关闭则 平滑着色
                FLAT_SHADED: false,
            },
            vertexShader: /* glsl */ `
                varying vec3 vNormal;
                
                varying vec3 vViewPosition;

                void main() {

                    vNormal = normalMatrix * normal;
                    vNormal = normalize( vNormal );

                    vec4 modelViewPosition = modelViewMatrix * vec4(position, 1.0);
                    gl_Position = projectionMatrix * modelViewPosition;

                    vec3 transformed = vec3( position );

                    vec4 mvPosition = vec4( transformed, 1.0 );
                    
                    mvPosition = modelViewMatrix * mvPosition;

	                vViewPosition = - mvPosition.xyz;

                }`,
            fragmentShader: /* glsl */ `
                varying vec3 vNormal;               
                varying vec3 vViewPosition;

                
                #if NUM_POINT_LIGHTS > 0
                    struct PointLight {
                        vec3 position;
                        vec3 color;
                        float distance;
                        float decay;
                        bool visible;
                    };

                    uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
                #endif

                ${bsdfs_glsl}

                void main() {
                    gl_FragColor = vec4(vec3( 0. ) , 1. );

                    #if NUM_POINT_LIGHTS > 0
                        #ifdef FLAT_SHADED

                            vec3 fdx = dFdx( vViewPosition );
                            vec3 fdy = dFdy( vViewPosition );
                            vec3 normal = normalize( cross( fdx, fdy ) );

                        #else

                            vec3 normal =  vNormal ;
                            normal = normalize( vNormal );

                        #endif

                        vec3 geometryPosition = - vViewPosition;
                        vec3 geometryNormal = normal;
                        vec3 geometryViewDir = normalize( vViewPosition );

                        PointLight pointLight;

                        vec3 directSpecular = vec3(0.);

                        for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
                            pointLight = pointLights[ i ];

                            // 取自 getPointLightInfo
                            vec3 lVector = pointLight.position - geometryPosition;
                    
                            vec3 lightDirection = normalize( lVector );

                            directSpecular += pointLight.visible ? BRDF_BlinnPhong( lightDirection, geometryViewDir, geometryNormal, vec3(1), 30.) : vec3(0.);
                        }
                
                        gl_FragColor = vec4(vec3( directSpecular ) , 1. );
                    #endif
                }
            `,
        };

        const PointLights: PointLightUniforms[] = [];

        const viewMatrix = params!.camera.matrixWorldInverse;

        params!.scene.traverse((obj) => {
            if (obj.type == "PointLight") {
                const light = obj as THREE.PointLight;
                const uniforms = {
                    color: light.color.clone(),
                    decay: light.decay,
                    position: new THREE.Vector3(),
                    distance: light.distance,
                    /** 采集visible信息 不用更新着色器 (新增灯光则需要重新构建着色器) */
                    visible: light.visible,
                };
                // uniforms.color.multiplyScalar(light.intensity);
                uniforms.position.setFromMatrixPosition(light.matrixWorld);
                uniforms.position.applyMatrix4(viewMatrix);
                PointLights.push(uniforms);
            }
        });

        const replaceLightNums = (string: string, parameters: { numPointLights: number }) => {
            return string.replace(/NUM_POINT_LIGHTS/g, "" + parameters.numPointLights);
        };

        original.uniforms.pointLights = { value: PointLights };

        original.fragmentShader = replaceLightNums(original!.fragmentShader!, {
            numPointLights: PointLights.length,
        });

        super(original);
        this.original = original;
    }

    replaceLightNums(string: string, parameters: { numPointLights: number }) {
        return string.replace(/NUM_POINT_LIGHTS/g, "" + parameters.numPointLights);
    }
}

TODO: 新增灯光更新着色器 (threejs也是这么做的 所以动态灯光开销颇大(动态visible不需要重新构建着色器))

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2188613.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

无IDEA不Java:快速掌握Java集成开发环境

IntelliJ IDEA是一种强大的Java集成开发环境&#xff0c;是Java开发人员的首选工具之一。本文将介绍IDEA的基本使用方法和常用功能&#xff0c;以帮助初学者快速上手。 安装和配置 首先&#xff0c;需要下载并安装IntelliJ IDEA。在安装完成后&#xff0c;需要配置JDK&#xff…

OpenAI 再现变革风暴!-- 高管离职潮与营利化转型背后的深层次变动

OpenAI 正处于历史的转折点。作为全球最知名的 AI 公司之一&#xff0c;OpenAI 一直以来以其领先的人工智能技术和开放的研发精神吸引了大量的关注与支持。然而&#xff0c;近期的一系列高管离职以及转型为营利性公司的计划&#xff0c;引发了外界的广泛讨论。本文将深入探讨这…

使用Java调用GeoTools实现全球国家矢量数据入库实战

目录 前言 一、相关数据介绍 1、无空间参考的数据 2、有空间参考的数据 3、空间信息表物理模型 二、全球国家空间数据入库 1、后台实体类图 2、后台实体对象关键代码 三、时空数据入库实践 1、读取无空间参考数据 2、入库成果及注意事项 四、总结 前言 在当今世界&…

【LuBase低代码框架】动态数据源服务介绍

功能介绍&#xff1a; 可以通过配置一个QueryOption对象或者一条select 查询语句&#xff0c;返回当前应用下的数据&#xff0c;避免后端写代码开发。 使用方法&#xff1a; 1. 动态服务需要通过/invoke/datasource和/invoke/datasourceNoRight 地址发起调用 2. 可使用参数…

Gaussian-splatting 项目环境配置笔记(Win11)

如果你是配置别的项目的过程中用到了3D GS相关的内容&#xff0c;然后这部分内容环境一直配不好&#xff0c;也可以跟随这个博客配一下环境&#xff0c;配完后起码3D GS部分就搞定了。 文章目录 概述项目链接&#xff1a;VS2019直接下载链接CUDA不同版本下载链接安装Condasetup…

Java开发每日一课:21世纪最流行的语言,Java为什么这么火?

自从进入21世纪以来&#xff0c;Java在TIOBE语言排行榜一直稳居前2名&#xff0c;占有率一直在12%以上。从国内各大招聘网站的岗位需求和培训班的畅销课程上看&#xff0c;Java一直稳居榜首&#xff0c;可以说Java是21世纪最流行的语言。 作为一个1995年才推出的语言&#xff0…

JVM(HotSpot):字符串常量池(StringTable)

文章目录 一、内存结构图二、案例讲解三、总结 一、内存结构图 JDK1.6 JDK1.8 我们发现&#xff0c;StringTable移入了Heap里面。所以&#xff0c;应该想到&#xff0c;StringTable将受到GC管理。 其实&#xff0c;1.6中&#xff0c;在方法区中的时候&#xff0c;也是受GC管…

01 排列选票

题目&#xff1a; 桶排序&#xff1a; #include<bits/stdc.h> using namespace std; #define M 100005 int a[M];int main() {int n,m;cin>>n>>m;for(int i1;i<m;i){int temp;cin>>temp;a[temp];}for(int i1;i<n;i){for(int j1;j<a[i];j){co…

OpenVINO基本操作流程

环境配置&#xff1a; conda env list:可以查看有哪些环境 conda activate intel:启动某个环境 pip list&#xff1a;可以查看此环境下都下载了哪些软件包 from openvino.inference_engine import IEcore#从OpenVINO推理引擎中导入IECore类 import numpy as np import cv2 1&…

基于GitLab 的持续集成环境

一.技术基础 Gitlab: 是一个用于仓库管理系统的开源项目&#xff0c;使用Git作为代码管理工具&#xff0c;并在此基础上搭建起来的Web服务 GitRunner:用于运行您的作业并将结果发送回GitLab。它与GitLab CI一起使用&#xff0c;GitLab CI是GitLab随附的开源持续集成服务&…

SpringCloud微服务搭建实战

文章目录 前言Nacos配置和项目结构图示数据库和脚本准备seata数据库transaction_database数据库 一、Spring Boot、Spring Cloud、Sping Cloud Alibaba二、seata安装seata配置修改Nacos新建配置文件seata-server.properties 三、创建Microservice-Project项目四、创建api-modul…

【HTML5】html5开篇基础(5)

1.❤️❤️前言~&#x1f973;&#x1f389;&#x1f389;&#x1f389; Hello, Hello~ 亲爱的朋友们&#x1f44b;&#x1f44b;&#xff0c;这里是E绵绵呀✍️✍️。 如果你喜欢这篇文章&#xff0c;请别吝啬你的点赞❤️❤️和收藏&#x1f4d6;&#x1f4d6;。如果你对我的…

使用MTVerseXR SDK实现VR串流

1、概述​ MTVerseXR SDK 是摩尔线程GPU加速的虚拟现实&#xff08;VR&#xff09;流媒体平台&#xff0c;专门用于从远程服务器流式传输基于标准OpenXR的应用程序。MTVerseXR可以通过Wi-Fi和USB流式将VR内容从Windows服务器流式传输到XR客户端设备, 使相对性能低的VR客户端可…

芯片公司产品简介

台湾新唐科技:ARM内核-nuvoTon stc&#xff08;宏晶&#xff09;&#xff1a;STC 8051 系列、STC32 8051系列、STC32 ARM系列 兆易&#xff1a;Arm Cortex-M内核和RISC-V内核 意法&#xff1a; 乐鑫科技&#xff1a; MCU厂家 GPU厂家 MCU与MPU 引用链接&#xff1a; http://…

AutoCAD学习

AutoCAD学习 最基本操作 命令用途说明空格键确认键也可以是重复刚才的命令回车键也是确认键鼠标右键也可以选择确认LINE、L直线命令绘制直线DLI线性尺寸标注DIMLINEAR鼠标滚轮滚动放大缩小视图界面鼠标中键按住移动视图DAL对齐线性标注DIMALIGNED F8 正交模式ORTHOMODE Tab 切换…

漆包线称重系统/自动称重/项目合作

万界星空科技漆包线行业称重系统实现自动称重的方式主要依赖于现代数字电子称重技术、计算机网络技术以及相关的软件系统的集成。以下是对该系统如何实现自动称重的详细解释&#xff1a; 一、硬件基础 称重设备&#xff1a; 系统采用高精度的电子秤作为称重设备&#xff0c;这…

TOGAF框架中的最佳实践与实施技巧:推动企业数字化转型的实战指南

企业的数字化转型已经成为全球商业界的一大趋势&#xff0c;而实现这一转型不仅需要技术的创新&#xff0c;还需要清晰的架构规划和实施策略。TOGAF&#xff08;The Open Group Architecture Framework&#xff09;作为全球广泛应用的企业架构标准&#xff0c;为企业提供了行之…

Pikachu-File Inclusion- 本地文件包含

前端每次挑选篮球明星&#xff0c;都会通过get请求&#xff0c;传了文件名&#xff0c;把页面展示出来&#xff0c;由于文件名时前端传给后台;并且查看源码&#xff0c;没有对参数做限制&#xff1b; 尝试直接从前端修改filename 参数&#xff1b; filename../../../../../../…

24-10-3-读书笔记(二十三)-《一个孤独漫步者的遐想》上([法] 让·雅克·卢梭 [译]陈阳)

文章目录 《一个孤独漫步者的遐想》上&#xff08;[法] 让雅克卢梭 [译]陈阳&#xff09;卢梭生平大事年表总结 《一个孤独漫步者的遐想》上&#xff08;[法] 让雅克卢梭 [译]陈阳&#xff09; 十月第三篇&#xff0c;看书看个爽&#xff0c;今天是法国哲学家卢梭晚年的著作《一…

【C++】—— vector模拟实现

vector 接口预览 namespace HL {template<class T>class vector{//迭代器iteratortypedef T* iterator;typedef const T* const_iterator;public://默认成员函数vector();vector(size_t n, const T& val T());vector(int n, const T& val T());vector(const v…