轻量封装WebGPU渲染系统示例<11>- WebGP实现的简单PBR效果(源码)

news2024/11/29 3:53:20

当前示例源码github地址:

https://github.com/vilyLei/voxwebgpu/blob/main/src/voxgpu/sample/SimplePBRTest.ts

此示例渲染系统实现的特性:

1. 用户态与系统态隔离。

2. 高频调用与低频调用隔离。

3. 面向用户的易用性封装。

4. 渲染数据和渲染机制分离。

5. 用户操作和渲染系统调度并行机制。

当前示例运行效果:

顶点shader:


@group(0) @binding(0) var<uniform> objMat : mat4x4<f32>;
@group(0) @binding(1) var<uniform> viewMat : mat4x4<f32>;
@group(0) @binding(2) var<uniform> projMat : mat4x4<f32>;

struct VertexOutput {
  @builtin(position) Position : vec4<f32>,
  @location(0) pos: vec4<f32>,
  @location(1) uv : vec2<f32>,
  @location(2) normal : vec3<f32>,
  @location(3) camPos : vec3<f32>
}

fn inverseM33(m: mat3x3<f32>)-> mat3x3<f32> {
    let a00 = m[0][0]; let a01 = m[0][1]; let a02 = m[0][2];
    let a10 = m[1][0]; let a11 = m[1][1]; let a12 = m[1][2];
    let a20 = m[2][0]; let a21 = m[2][1]; let a22 = m[2][2];
    let b01 = a22 * a11 - a12 * a21;
    let b11 = -a22 * a10 + a12 * a20;
    let b21 = a21 * a10 - a11 * a20;
    let det = a00 * b01 + a01 * b11 + a02 * b21;
    return mat3x3<f32>(
		vec3<f32>(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11)) / det,
                vec3<f32>(b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10)) / det,
                vec3<f32>(b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det);
}
fn m44ToM33(m: mat4x4<f32>) -> mat3x3<f32> {
	return mat3x3(m[0].xyz, m[1].xyz, m[2].xyz);
}

fn inverseM44(m: mat4x4<f32>)-> mat4x4<f32> {
    let a00 = m[0][0]; let a01 = m[0][1]; let a02 = m[0][2]; let a03 = m[0][3];
    let a10 = m[1][0]; let a11 = m[1][1]; let a12 = m[1][2]; let a13 = m[1][3];
    let a20 = m[2][0]; let a21 = m[2][1]; let a22 = m[2][2]; let a23 = m[2][3];
    let a30 = m[3][0]; let a31 = m[3][1]; let a32 = m[3][2]; let a33 = m[3][3];
    let b00 = a00 * a11 - a01 * a10;
    let b01 = a00 * a12 - a02 * a10;
    let b02 = a00 * a13 - a03 * a10;
    let b03 = a01 * a12 - a02 * a11;
    let b04 = a01 * a13 - a03 * a11;
    let b05 = a02 * a13 - a03 * a12;
    let b06 = a20 * a31 - a21 * a30;
    let b07 = a20 * a32 - a22 * a30;
    let b08 = a20 * a33 - a23 * a30;
    let b09 = a21 * a32 - a22 * a31;
    let b10 = a21 * a33 - a23 * a31;
    let b11 = a22 * a33 - a23 * a32;
    let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
	return mat4x4<f32>(
		vec4<f32>(a11 * b11 - a12 * b10 + a13 * b09,
		a02 * b10 - a01 * b11 - a03 * b09,
		a31 * b05 - a32 * b04 + a33 * b03,
		a22 * b04 - a21 * b05 - a23 * b03) / det,
			vec4<f32>(a12 * b08 - a10 * b11 - a13 * b07,
		a00 * b11 - a02 * b08 + a03 * b07,
		a32 * b02 - a30 * b05 - a33 * b01,
		a20 * b05 - a22 * b02 + a23 * b01) / det,
		vec4<f32>(a10 * b10 - a11 * b08 + a13 * b06,
		a01 * b08 - a00 * b10 - a03 * b06,
		a30 * b04 - a31 * b02 + a33 * b00,
		a21 * b02 - a20 * b04 - a23 * b00) / det,
		vec4<f32>(a11 * b07 - a10 * b09 - a12 * b06,
		a00 * b09 - a01 * b07 + a02 * b06,
		a31 * b01 - a30 * b03 - a32 * b00,
		a20 * b03 - a21 * b01 + a22 * b00) / det);
}
@vertex
fn main(
  @location(0) position : vec3<f32>,
  @location(1) uv : vec2<f32>,
  @location(2) normal : vec3<f32>
) -> VertexOutput {
  let wpos = objMat * vec4(position.xyz, 1.0);
  var output : VertexOutput;
  output.Position = projMat * viewMat * wpos;
  output.uv = uv;

  let invMat33 = inverseM33( m44ToM33( objMat ) );
  output.normal = normalize( normal * invMat33 );
  output.camPos = (inverseM44(viewMat) * vec4<f32>(0.0,0.0,0.0, 1.0)).xyz;
  output.pos = wpos;
  return output;
}

片段shader:

@group(0) @binding(3) var<storage> albedo: vec4f;
@group(0) @binding(4) var<storage> param: vec4f;

const PI = 3.141592653589793;
const PI2 = 6.283185307179586;
const PI_HALF = 1.5707963267948966;
const RECIPROCAL_PI = 0.3183098861837907;
const RECIPROCAL_PI2 = 0.15915494309189535;
const EPSILON = 1e-6;

fn approximationSRGBToLinear(srgbColor: vec3<f32>) -> vec3<f32> {
    return pow(srgbColor, vec3<f32>(2.2));
}
fn approximationLinearToSRCB(linearColor: vec3<f32>) -> vec3<f32> {
    return pow(linearColor, vec3(1.0/2.2));
}

fn accurateSRGBToLinear(srgbColor: vec3<f32>) -> vec3<f32> {
    let linearRGBLo = srgbColor / 12.92;
    let linearRGBHi = pow((srgbColor + vec3(0.055)) / vec3(1.055), vec3(2.4));
	if( all( srgbColor <= vec3(0.04045) ) ) {
		return linearRGBLo;
	}
    return linearRGBHi;
}
fn accurateLinearToSRGB(linearColor: vec3<f32>) -> vec3<f32> {
    let srgbLo = linearColor * 12.92;
    let srgbHi = (pow(abs(linearColor), vec3(1.0 / 2.4)) * 1.055) - 0.055;
    if(all(linearColor <= vec3(0.0031308))) {
		return srgbLo;
	}
    return srgbHi;
}

// Trowbridge-Reitz(Generalized-Trowbridge-Reitz,GTR)
fn DistributionGTR1(NdotH: f32, roughness: f32) -> f32 {
    if (roughness >= 1.0) {
		return 1.0/PI;
	}
    let a2 = roughness * roughness;
    let t = 1.0 + (a2 - 1.0)*NdotH*NdotH;
    return (a2 - 1.0) / (PI * log(a2) *t);
}
fn DistributionGTR2(NdotH: f32, roughness: f32) -> f32 {
    let a2 = roughness * roughness;
    let t = 1.0 + (a2 - 1.0) * NdotH * NdotH;
    return a2 / (PI * t * t);
}


fn DistributionGGX(N: vec3<f32>, H: vec3<f32>, roughness: f32) -> f32 {
    let a = roughness*roughness;
    let a2 = a*a;
    let NdotH = max(dot(N, H), 0.0);
    let NdotH2 = NdotH*NdotH;

    let nom   = a2;
    var denom = (NdotH2 * (a2 - 1.0) + 1.0);
    denom = PI * denom * denom;

    return nom / max(denom, 0.0000001); // prevent divide by zero for roughness=0.0 and NdotH=1.0
}


fn GeometryImplicit(NdotV: f32, NdotL: f32) -> f32 {
    return NdotL * NdotV;
}

// ----------------------------------------------------------------------------
fn GeometrySchlickGGX(NdotV: f32, roughness: f32) -> f32 {
    let r = (roughness + 1.0);
    let k = (r*r) / 8.0;

    let nom   = NdotV;
    let denom = NdotV * (1.0 - k) + k;

    return nom / denom;
}
// ----------------------------------------------------------------------------
fn GeometrySmith(N: vec3<f32>, V: vec3<f32>, L: vec3<f32>, roughness: f32) -> f32 {
    let NdotV = max(dot(N, V), 0.0);
    let NdotL = max(dot(N, L), 0.0);
    let ggx2 = GeometrySchlickGGX(NdotV, roughness);
    let ggx1 = GeometrySchlickGGX(NdotL, roughness);

    return ggx1 * ggx2;
}

// @param cosTheta is clamp(dot(H, V), 0.0, 1.0)
fn fresnelSchlick(cosTheta: f32, F0: vec3<f32>) -> vec3<f32> {
    return F0 + (1.0 - F0) * pow(max(1.0 - cosTheta, 0.0), 5.0);
}
fn fresnelSchlick2(specularColor: vec3<f32>, L: vec3<f32>, H: vec3<f32>) -> vec3<f32> {
   return specularColor + (1.0 - specularColor) * pow(1.0 - saturate(dot(L, H)), 5.0);
}
//fresnelSchlick2(specularColor, L, H) * ((SpecularPower + 2) / 8 ) * pow(saturate(dot(N, H)), SpecularPower) * dotNL;

const OneOnLN2_x6 = 8.656171;// == 1/ln(2) * 6 (6 is SpecularPower of 5 + 1)
// dot -> dot(N,V) or
fn fresnelSchlick3(specularColor: vec3<f32>, dot: f32, glossiness: f32) -> vec3<f32> {
	return specularColor + (max(vec3(glossiness), specularColor) - specularColor) * exp2(-OneOnLN2_x6 * dot);
}
fn fresnelSchlickWithRoughness(specularColor: vec3<f32>, L: vec3<f32>, N: vec3<f32>, gloss: f32) -> vec3<f32> {
   return specularColor + (max(vec3(gloss), specularColor) - specularColor) * pow(1.0 - saturate(dot(L, N)), 5.0);
}

const A = 2.51f;
const B = 0.03f;
const C = 2.43f;
const D = 0.59f;
const E = 0.14f;
fn ACESToneMapping(color: vec3<f32>, adapted_lum: f32) -> vec3<f32> {

	let c = color * adapted_lum;
	return (c * (A * c + B)) / (c * (C * c + D) + E);
}

//color = color / (color + vec3(1.0));
fn reinhard(v: vec3<f32>) -> vec3<f32> {
    return v / (vec3<f32>(1.0) + v);
}
fn reinhard_extended(v: vec3<f32>, max_white: f32) -> vec3<f32> {
    let numerator = v * (1.0f + (v / vec3(max_white * max_white)));
    return numerator / (1.0f + v);
}
fn luminance(v: vec3<f32>) -> f32 {
    return dot(v, vec3<f32>(0.2126f, 0.7152f, 0.0722f));
}

fn change_luminance(c_in: vec3<f32>, l_out: f32) -> vec3<f32> {
    let l_in = luminance(c_in);
    return c_in * (l_out / l_in);
}
fn reinhard_extended_luminance(v: vec3<f32>, max_white_l: f32) -> vec3<f32> {
    let l_old = luminance(v);
    let numerator = l_old * (1.0f + (l_old / (max_white_l * max_white_l)));
    let l_new = numerator / (1.0f + l_old);
    return change_luminance(v, l_new);
}
fn ReinhardToneMapping( color: vec3<f32>, toneMappingExposure: f32 ) -> vec3<f32> {

	let c = color * toneMappingExposure;
	return saturate( c / ( vec3( 1.0 ) + c ) );

}
// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.
// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
const highp_a = 12.9898;
const highp_b = 78.233;
const highp_c = 43758.5453;
fn rand( uv: vec2<f32> ) -> f32 {
	let dt = dot( uv.xy, vec2<f32>( highp_a, highp_b ) );
	let sn = modf( dt / PI ).fract;
	return fract(sin(sn) * highp_c);
}
// // based on https://www.shadertoy.com/view/MslGR8
fn dithering( color: vec3<f32>, fragCoord: vec2<f32> ) -> vec3<f32> {
    //Calculate grid position
    let grid_position = rand( fragCoord );

    //Shift the individual colors differently, thus making it even harder to see the dithering pattern
    var dither_shift_RGB = vec3<f32>( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );

    //modify shift acording to grid position.
    dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );

    //shift the color by dither_shift
    return color + dither_shift_RGB;
}

const dis = 700.0;
const disZ = 400.0;
const u_lightPositions = array<vec3<f32>, 4>(
	vec3<f32>(-dis, dis, disZ),
	vec3<f32>(dis, dis, disZ),
	vec3<f32>(-dis, -dis, disZ),
	vec3<f32>(dis, -dis, disZ)
);
const colorValue = 300.0;
const u_lightColors = array<vec3<f32>, 4>(
	vec3<f32>(colorValue, colorValue, colorValue),
	vec3<f32>(colorValue, colorValue, colorValue),
	vec3<f32>(colorValue, colorValue, colorValue),
	vec3<f32>(colorValue, colorValue, colorValue),
);

fn calcPBRColor3(Normal: vec3<f32>, WorldPos: vec3<f32>, camPos: vec3<f32>) -> vec3<f32> {

	var color = vec3<f32>(0.0);

    var ao = param.x;
    var roughness = param.y;
    var metallic = param.z;

	var N = normalize(Normal);
    var V = normalize(camPos.xyz - WorldPos);
    var dotNV = clamp(dot(N, V), 0.0, 1.0);

    // calculate reflectance at normal incidence; if dia-electric (like plastic) use F0
    // of 0.04 and if it's a metal, use the albedo color as F0 (metallic workflow)
    var F0 = vec3(0.04);
    F0 = mix(F0, albedo.xyz, metallic);

    // reflectance equation
    var Lo = vec3(0.0);
    
	for (var i: i32 = 0; i < 4; i++) {
		// calculate per-light radiance
        let L = normalize(u_lightPositions[i].xyz - WorldPos);
        let H = normalize(V + L);
        let distance = length(u_lightPositions[i].xyz - WorldPos);

        let attenuation = 1.0 / (1.0 + 0.001 * distance + 0.0003 * distance * distance);
        let radiance = u_lightColors[i].xyz * attenuation;

        // Cook-Torrance BRDF
        let NDF = DistributionGGX(N, H, roughness);
        let G   = GeometrySmith(N, V, L, roughness);
        //vec3 F    = fresnelSchlick(clamp(dot(H, V), 0.0, 1.0), F0);
        let F    = fresnelSchlick3(F0,clamp(dot(H, V), 0.0, 1.0), 0.9);
        //vec3 F    = fresnelSchlick3(F0,dotNV, 0.9);

        let nominator    = NDF * G * F;
        let denominator = 4.0 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0);
        let specular = nominator / max(denominator, 0.001); // prevent divide by zero for NdotV=0.0 or NdotL=0.0

        // kS is equal to Fresnel
        let kS = F;
        // for energy conservation, the diffuse and specular light can't
        // be above 1.0 (unless the surface emits light); to preserve this
        // relationship the diffuse component (kD) should equal 1.0 - kS.
        var kD = vec3<f32>(1.0) - kS;
        // multiply kD by the inverse metalness such that only non-metals
        // have diffuse lighting, or a linear blend if partly metal (pure metals
        // have no diffuse light).
        kD *= 1.0 - metallic;

        // scale light by NdotL
        let NdotL = max(dot(N, L), 0.0);

        // add to outgoing radiance Lo
        // note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again
        Lo += (kD * albedo.xyz / PI + specular) * radiance * NdotL;
	}
	// ambient lighting (note that the next IBL tutorial will replace
    // this ambient lighting with environment lighting).
    let ambient = vec3<f32>(0.03) * albedo.xyz * ao;

    color = ambient + Lo;
    // HDR tonemapping
    color = reinhard( color );
    // gamma correct
    color = pow(color, vec3<f32>(1.0/2.2));
	return color;
}

@fragment
fn main(
  @location(0) pos: vec4<f32>,
  @location(1) uv: vec2<f32>,
  @location(2) normal: vec3<f32>,
  @location(3) camPos: vec3<f32>
) -> @location(0) vec4<f32> {
  var color4 = vec4(calcPBRColor3(normal, pos.xyz, camPos), 1.0);
  return color4;
}

此示例基于此渲染系统实现,当前示例TypeScript源码如下

export class SimplePBRTest {

	private mRscene = new RendererScene();

	geomData = new GeomDataBuilder();

	initialize(): void {
		console.log("SimplePBRTest::initialize() ...");

		const rc = this.mRscene;
		rc.initialize();
		this.initEvent();
		this.initScene();
	}
	private initEvent(): void {
		const rc = this.mRscene;
		rc.addEventListener(MouseEvent.MOUSE_DOWN, this.mouseDown);
		new MouseInteraction().initialize(rc, 0, false).setAutoRunning(true);
	}

	private mouseDown = (evt: MouseEvent): void => {

	}
	private createMaterial(shdSrc: WGRShderSrcType, color?: Color4, arm?: number[]): WGMaterial {

		color = color ? color : new Color4();

		let pipelineDefParam = {
			depthWriteEnabled: true,
			blendModes: [] as string[]
		};

		const material = new WGMaterial({
			shadinguuid: "simple-pbr-materialx",
			shaderCodeSrc: shdSrc,
			pipelineDefParam
		});

		let albedoV = new WGRStorageValue(new Float32Array([color.r, color.g, color.b, 1]));

		// arm[0]: ao, arm[1]: roughness, arm[2]: metallic
		let armV = new WGRStorageValue(new Float32Array([arm[0], arm[1], arm[2], 1]));
		material.uniformValues = [albedoV, armV];

		return material;
	}

	private createGeom(rgd: GeomRDataType, normalEnabled = false): WGGeometry {

		const geometry = new WGGeometry()
			.addAttribute({ position: rgd.vs })
			.addAttribute({ uv: rgd.uvs })
			.setIndices(rgd.ivs);
		if (normalEnabled) {
			geometry.addAttribute({ normal: rgd.nvs });
		}
		return geometry;
	}
	private initScene(): void {

		const rc = this.mRscene;
		const geometry = this.createGeom(this.geomData.createSphere(50), true);

		const shdSrc = {
			vertShaderSrc: { code: vertWGSL, uuid: "vertShdCode" },
			fragShaderSrc: { code: fragWGSL, uuid: "fragShdCode" }
		};

		let tot = 5;
		const size = new Vector3(150, 150, 150);
		const pos = new Vector3().copyFrom(size).scaleBy(-0.5 * (tot - 1));
		let pv = new Vector3();
		for (let i = 0; i < tot; ++i) {
			for (let j = 0; j < tot; ++j) {
				// params[0]: ao, params[1]: roughness, params[2]: metallic
				let params = [1.5, (i / tot) * 0.95 + 0.05, (j / tot) * 0.95 + 0.05];
				let material = this.createMaterial(shdSrc, new Color4(0.5, 0.0, 0.0), params);
				let entity = new Entity3D();
				entity.materials = [material];
				entity.geometry = geometry;
				pv.setXYZ(i * size.x, j * size.y, size.z).addBy(pos);
				entity.transform.setPosition(pv);
				rc.addEntity(entity);
			}
		}
	}

	run(): void {
		this.mRscene.run();
	}
}

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

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

相关文章

【Linux】第九站:make和makefile

文章目录 一、 Linux项目自动化构建工具make/Makefile1.make/makefile工作现象2.依赖关系与依赖方法3.如何清理4.为什么这里我们需要带上clean5.连续的make6.特殊符号 二、Linux下实现一个简单的进度条1.回车换行2.缓冲区3.倒计时的实现 一、 Linux项目自动化构建工具make/Make…

518抽奖软件,数字滚动抽奖,可批量生成数字号码

518抽奖软件简介 518抽奖软件&#xff0c;518我要发&#xff0c;超好用的年会抽奖软件&#xff0c;简约设计风格。 包含文字号码抽奖、照片抽奖两种模式&#xff0c;支持姓名抽奖、号码抽奖、数字抽奖、照片抽奖。(www.518cj.net) 批量生成数字号码 入口&#xff1a;主界面点…

supervisor 配置自动启动服务

一、编写服务 nano /usr/lib/systemd/system/supervisord.service内容开始 [Unit] DescriptionProcess Monitoring and Control Daemon Afterrc-local.service nss-user-lookup.target [Service] Typeforking ExecStart/usr/bin/supervisord -c /etc/supervisord.conf ExecSto…

实在智能携手品牌商家,在活动会面中共谋发展

金秋十月&#xff0c;丰收的季节&#xff0c;也是商家们在双11大展拳脚的时刻。为迎战一年一度的双11大促&#xff0c;品牌商家在10月份卯足劲&#xff0c;制定一系列营销方案&#xff0c;争取为店铺带来更多流量和订单。 其中&#xff0c;舍得、同科医药、梅子熟了、宝洁、维…

软考高级之系统架构师系列之操作系统基础

概念 接口 操作系统为用户提供两类接口&#xff1a;操作一级的接口和程序控制一级的接口。操作一级的接口包括操作控制命令、菜单命令等&#xff1b;程序控制一级的接口包括系统调用。 UMA和NUMA UMA&#xff0c;统一内存访问&#xff0c;Uniform Memory Access&#xff0c…

搞清Lighttpd、webserver、CGI、fastCGI这几个概念

一、webserver&#xff1a; 网页浏览也是网络通信&#xff0c;浏览器相当于TCPclient客户端程序&#xff0c;和浏览器相对应的是机房里运行的网站服务器&#xff0c;里面运行着TCPserver服务端程序&#xff0c;因为网页传输使用的是HTTP协议&#xff08;加密的是HTTPS协议&…

MySQL连接的原理⭐️4种优化连接的手段性能提升240%

MySQL连接的原理⭐️4种优化连接的手段性能提升240%&#x1f680; 前言 上两篇文章我们说到MySQL优化回表的三种方式&#xff1a;索引条件下推ICP、多范围读取MRR与覆盖索引 MySQL的优化利器⭐️索引条件下推&#xff0c;千万数据下性能提升273%&#x1f680; MySQL的优化…

Midjourney保姆级入门教程

文章目录 一、Midjourney注册二、新建自己的服务器三、开通订阅 AI绘画即指人工智能绘画&#xff0c;是一种计算机生成绘画的方式。是AIGC应用领域内的一大分支。 AI绘画主要分为两个部分&#xff0c;一个是对图像的分析与判断&#xff0c;即“学习”&#xff0c;一个是对图像的…

【MySQL进阶之路丨第十四篇】一文带你精通MySQL重复数据及SQL注入

引言 在上一篇中我们介绍了MySQL ALTER命令及序列使用&#xff1b;在开发中&#xff0c;对MySQL重复数据的处理是十分重要的。这一篇我们使用命令行方式来帮助读者掌握MySQL中重复数据的操作。 上一篇链接&#xff1a;【MySQL进阶之路丨第十三篇】一文带你精通MySQL之ALTER命令…

02【保姆级】-GO语言开发注意事项(特色重点)

02【保姆级】-GO语言开发注意事项&#xff08;特色重点&#xff09; 一、Go语言的特性1.1 第一个hello word&#xff08;详解&#xff09;1.2 开发编译。&#xff08;重要点 / 面试题&#xff09;1.3 开发注意事项1.4 GO语言的转义字符1.5 注释1.6 API 文档 一、Go语言的特性 …

Libevent网络库原理及使用方法

目录 1. Libevent简介2. Libevent事件处理流程3. Libevent常用API接口3.1 地基——event_base3.2 事件——event3.3 循环等待事件3.4 自带 buffer 的事件——bufferevent3.5 链接监听器——evconnlistener3.6 基于event的服务器程序3.7 基于 bufferevent 的服务器和客户端实现 …

SpringBoot源码透彻解析—bean生命周期

先跟一段debug再看总结&#xff1a; 1 创建实例 InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation&#xff08;自定义一个对象或者代理对象&#xff09;createBeanInstance&#xff08;创建实例&#xff09;MergedBeanDefinitionPostProcessor.postProcess…

Selenium 常用元素操作

常用浏览器操作 1、初始化浏览器会话 from selenium import webdrive 初始化浏览器会话--谷歌 driverwebdrive.Chrome() 2、浏览器最大化操作 driverwebdriver.Chrome() 3、设置浏览器窗口大小 driver.set_window_size(500,780) 4、关闭浏览器 driver.quit() 常用页面…

Python的网络编程一篇学透,使用Socket打开新世界

目录 1.网络概念 2.网络通信过程 2.1.TCP/IP 2.2.网络协议栈架构 3.TCP/IP介绍 3.1.ip地址 3.2.端口号 3.3.域名 4.Python网络编程 4.1.TCP/IP 4.2.socket的概念 4.3.Socket类型 4.4.Socket函数 4.5.Socket编程思想 5.客户端与服务器 5.1.tcp客户端 6.网络调试…

数据库概论

目录 什么是数据库数据库的概念模型层次模型网状模型关系模型 为什么要使用关系型数据库完整性约束结构化查询语言SQL基本语句 什么是数据库 考虑这些问题&#xff1a;当用户使用软件计算时&#xff0c;如果想要保存计算结果或者想选择不同的题目&#xff0c;是否要保存、读取…

C#高级--IO详解

零、文章目录 IO详解 1、IO是什么 &#xff08;1&#xff09;IO是什么 IO是输入/输出的缩写&#xff0c;即Input/Output。在计算机领域&#xff0c;IO通常指数据在内部存储器和外部存储器或其他周边设备之间的输入和输出。输入和输出是信息处理系统&#xff08;例如计算器&…

Spring Cloud应用- Eureka原理、搭建

初期对Spring Cloud的学习以应用搭建为主&#xff0c;所以内容不会太枯燥。 一直以来&#xff0c;自以为Spring全家桶的学习中&#xff0c;Spring framework是基础中的基础&#xff0c;部分内容也还是必须要读源码去理解底层原理&#xff0c;SpringMVC、SpringBoot&#xff0c…

基于PESdk和EasyModbus实现录波控制逻辑和数据传输

文章目录 0. 概要1. 录波功能简介1.1 功能框架1.2 录波控制逻辑1.3 手动录波数据传输流程1.4 故障录波传输流程 2 C语言应用程序接口&#xff08;API&#xff09;2.1 EasyModbus接口2.2 PESdk 3 录波功能的实现3.1 功能码定义3.1.1 公共功能码3.1.2 用户自定义功能码3.1.3 保留…

维修服务预约小程序的效果如何

生活服务中维修项目绝对是需求量很高的&#xff0c;如常见的保洁、管道疏通、数码维修、安装、便民服务等&#xff0c;可以说每天都有生意&#xff0c;而对相关维修店企业来说&#xff0c;如何获得更多生意很重要。 接下来让我们看看通过【雨科】平台制作维修服务预约小程序能…

XX棋牌架设指南

一、环境要求&#xff1a; 1.服务器要求&#xff1a;WINDOWS2008或更高版本。 2.数据库要求&#xff1a;MS SQL SERVER 2008 R2或更高版本。 3.服务器需要安装IIS。 二、游戏部署步骤&#xff1a; 1.解压文件至服务器数据盘&#xff0c;此处以D盘为例进行说明。 2. 目录说…