十四,间接漫反射用到球体中

news2024/11/17 10:49:23

间接光照分为间接漫反射和间接镜面反射。

辐照度图是用来适用于间接漫反射的。

直射光也有漫反射,对比下两者。

直接光kD * albedo / PI * radiance * NdotL;其中radiance * NdotL是光照,
间接光:
kD * texture(irradianceMap, N).rgb* albedo* ao
其中texture(irradianceMap, N).rgb是光照,
ao是环境光遮蔽,属于环境光特有,比如熟悉的ssao.间接光本来就是环境光,只是更细化了。
接着看,albedo是颜色,两者共有。
接下来几句是共有的。
kD *= 1.0 - metallic;
这句话可以看出纯金属是没有漫反射的。

    vec3 kS = F;
    vec3 kD = vec3(1.0) - kS;

在这里插入图片描述

   这句话可以看出漫反射率是由菲尼尔公式提供的。

对于直射光来说,菲涅尔公式
vec3 F0 = vec3(0.04);
F0 = mix(F0, albedo, metallic);

vec3 F = fresnelSchlick(max(dot(H, V), 0.0), F0);
vec3 H = normalize(V + L);
看似是只与角度和F0相关(即与金属度相关),但是实际上也是与粗糙度相关的。
如下图所示,微表面半向量与粗糙度相关。
在这里插入图片描述
在间接光漫反射中,模拟菲涅尔方程时,输入参数是视线和法线方向之间的夹角,就要考虑这个粗糙度了。
即vec3 kS = fresnelSchlickRoughness(max(dot(N, V), 0.0), F0,roughness);
“vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness) \n”
“{ \n”
" return F0 + (max(vec3(1.0-roughness),F0 ) -F0) * pow(1.0 - cosTheta, 5.0); \n"
“} \n”
运行结果如下

在这里插入图片描述
代码如下:
//通过Liblas读取.las文件,并在osg中显示出来,用shader,先在片元着色器指定使用绿色
#include
#include

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
#include <osg/CoordinateSystemNode>

#include <osg/Switch>
#include <osg/Types>
#include <osgText/Text>

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>

#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>
#include <osgGA/SphericalManipulator>

#include <osgGA/Device>

#include
#include <osg/Shader>
#include <osg/BlendFunc>
#include <osg/blendColor>
#include <osg/Point>
#include <osg/Shapedrawable>
#include <osgUtil/SmoothingVisitor>

#include <osg/TextureCubeMap>

static const char * vertexShader_PBR =
{
“in vec3 aPos; \n”
“in vec3 aNormal; \n”
“varying vec3 WorldPos; \n”
“varying vec3 Normal; \n”
“uniform mat4 normalMatrix; \n”
“void main() \n”
“{ \n”
" WorldPos = aPos; \n"
" Normal = vec3(normalMatrix * vec4(aNormal,1.0)); \n"
" gl_Position = ftransform(); \n"
“}\n”
};

static const char psShader_PBR =
{
“#version 330 core \n”
“out vec4 FragColor; \n”
“varying vec3 WorldPos; \n”
“varying vec3 Normal; \n”
“uniform vec3 albedo; \n”
“uniform float metallic; \n”
“uniform float roughness; \n”
“uniform float ao; \n”
//IBL
“uniform samplerCube irradianceMap;”
“uniform vec3 lightPositions[4]; \n”
“uniform vec3 lightColors[4]; \n”
“uniform vec3 camPos; \n”
“const float PI = 3.14159265359; \n”
“float DistributionGGX(vec3 N, vec3 H, float roughness) \n”
“{ \n”
" float a = roughness
roughness; \n"
" float a2 = aa; \n"
" float NdotH = max(dot(N, H), 0.0); \n"
" float NdotH2 = NdotH
NdotH; \n"
" float nom = a2; \n"
" float denom = (NdotH2 * (a2 - 1.0) + 1.0); \n"
" denom = PI * denom * denom; \n"
" return nom / denom; \n"
“} \n”
“float GeometrySchlickGGX(float NdotV, float roughness) \n”
“{ \n”
" float r = (roughness + 1.0); \n"
" float k = (r*r) / 8.0; \n"
" float nom = NdotV; \n"
" float denom = NdotV * (1.0 - k) + k; \n"
" return nom / denom; \n"
“} \n”
“float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) \n”
“{ \n”
" float NdotV = max(dot(N, V), 0.0); \n"
" float NdotL = max(dot(N, L), 0.0); \n"
" float ggx2 = GeometrySchlickGGX(NdotV, roughness); \n"
" float ggx1 = GeometrySchlickGGX(NdotL, roughness); \n"
" return ggx1 * ggx2; \n"
“} \n”
“vec3 fresnelSchlick(float cosTheta, vec3 F0) \n”
“{ \n”
" return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0); \n"
“} \n”
“vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness) \n”
“{ \n”
" return F0 + (max(vec3(1.0-roughness),F0 ) -F0) * pow(1.0 - cosTheta, 5.0); \n"
“} \n”
“void main() \n”
“{ \n”
" vec3 N = normalize(Normal); \n"
" vec3 V = normalize(camPos - WorldPos); \n"
" vec3 F0 = vec3(0.04); \n"
" F0 = mix(F0, albedo, metallic); \n"
" vec3 Lo = vec3(0.0); \n"
" for (int i = 0; i < 4; ++i) \n"
" { \n"
" vec3 L = normalize(lightPositions[i] - WorldPos); \n"
" vec3 H = normalize(V + L); \n"
" float distance = length(lightPositions[i] - WorldPos); \n"
" float attenuation = 1.0 / (distance * distance); \n"
" vec3 radiance = lightColors[i] * attenuation; \n"
" float NDF = DistributionGGX(N, H, roughness); \n"
" float G = GeometrySmith(N, V, L, roughness); \n"
" vec3 F = fresnelSchlick(clamp(dot(H, V), 0.0, 1.0), F0); \n"
" vec3 numerator = NDF * G * F; \n"
" float denominator = 4.0 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0) + 0.0001; \n"
" vec3 specular = numerator / denominator; \n"
" vec3 kS = F; \n"
" vec3 kD = vec3(1.0) - kS; \n"
" kD *= 1.0 - metallic; \n"
" float NdotL = max(dot(N, L), 0.0); \n"
" Lo += (kD * albedo / PI + specular) * radiance * NdotL; \n"
" } \n"
" vec3 kS = fresnelSchlickRoughness(max(dot(N, V), 0.0), F0,roughness); \n"
“vec3 kD = 1.0 - kS;”
" kD = 1.0 - metallic; \n"
“vec3 irradiance = texture(irradianceMap, N).rgb;”
“vec3 diffuse = irradiance * albedo;”
" vec3 ambient = (kD * diffuse)
ao; \n"
" vec3 color = ambient + Lo; \n"
" color = color / (color + vec3(1.0)); \n"
" color = pow(color, vec3(1.0 / 2.2)); \n"
" FragColor = vec4(color, 1.0); \n"
//" FragColor = vec4(1.0,0.0,0.0, 1.0); \n"
“} \n”
};

osg::ref_ptrosg::Geode CreateSphereGeode()
{
osg::ref_ptrosg::Geode geode = new osg::Geode;
osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array(6);
(*vertices)[0].set(0.0f, 0.0f, 1.0f);
(*vertices)[1].set(-0.5f, -0.5f, 0.0f);
(*vertices)[2].set(0.5f, -0.5f, 0.0f);
(*vertices)[3].set(0.5f, 0.5f, 0.0f);
(*vertices)[4].set(-0.5f, 0.5f, 0.0f);
(*vertices)[5].set(0.0f, 0.0f, -1.0f);
osg::ref_ptrosg::DrawElementsUInt indices = new osg::DrawElementsUInt(GL_TRIANGLES, 24);
(*indices)[0] = 0; (*indices)[1] = 1; (*indices)[2] = 2;
(*indices)[3] = 0; (*indices)[4] = 2; (*indices)[5] = 3;
(*indices)[6] = 0; (*indices)[7] = 3; (*indices)[8] = 4;
(*indices)[9] = 0; (*indices)[10] = 4; (*indices)[11] = 1;
(*indices)[12] = 5; (*indices)[13] = 2; (*indices)[14] = 1;
(*indices)[15] = 5; (*indices)[16] = 3; (*indices)[17] = 2;
(*indices)[18] = 5; (*indices)[19] = 4; (*indices)[20] = 3;
(*indices)[21] = 5; (*indices)[22] = 1; (*indices)[23] = 4;
osg::ref_ptrosg::Geometry geom = new osg::Geometry;
geom->setVertexArray(vertices.get());
geom->addPrimitiveSet(indices.get());
osgUtil::SmoothingVisitor::smooth(*geom);
geode->addDrawable(geom);
return geode;

}

osg::ref_ptrosg::Geode renderSphere(osg::Vec3f pos)
{
osg::ref_ptrosg::Geode geode = new osg::Geode;
const unsigned int X_SEGMENTS = 64;
const unsigned int Y_SEGMENTS = 64;
const float PI = 3.14159265359f;
osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array;
osg::ref_ptrosg::Vec3Array normalArray = new osg::Vec3Array;
for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
{
for (unsigned int y = 0; y <= Y_SEGMENTS; ++y)
{
float xSegment = (float)x / (float)X_SEGMENTS;
float ySegment = (float)y / (float)Y_SEGMENTS;
float xPos = std::cos(xSegment * 2.0f * PI) * std::sin(ySegment * PI);
float yPos = std::cos(ySegment * PI);
float zPos = std::sin(xSegment * 2.0f * PI) * std::sin(ySegment * PI);

		vertices->push_back(osg::Vec3(xPos, yPos, zPos) + pos);
		normalArray->push_back(osg::Vec3(xPos, yPos, zPos));
	}
}
osg::ref_ptr<osg::DrawElementsUInt> indices = new osg::DrawElementsUInt();
bool oddRow = false;
for (unsigned int y = 0; y < Y_SEGMENTS; ++y)
{
	if (!oddRow) // even rows: y == 0, y == 2; and so on
	{
		for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
		{
			indices->push_back(y       * (X_SEGMENTS + 1) + x);
			indices->push_back((y + 1) * (X_SEGMENTS + 1) + x);
		}
	}
	else
	{
		for (int x = X_SEGMENTS; x >= 0; --x)
		{
			indices->push_back((y + 1) * (X_SEGMENTS + 1) + x);
			indices->push_back(y       * (X_SEGMENTS + 1) + x);
		}
	}
	oddRow = !oddRow;
}
int indexCount = static_cast<unsigned int>(indices->size());
indices->setMode(GL_TRIANGLE_STRIP);

osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
geom->setVertexArray(vertices.get());
geom->addPrimitiveSet(indices.get());
geom->setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX);

geom->setVertexAttribArray(1, vertices, osg::Array::BIND_PER_VERTEX);
geom->setVertexAttribArray(2, normalArray, osg::Array::BIND_PER_VERTEX);

//osgUtil::SmoothingVisitor::smooth(*geom);
geode->addDrawable(geom);
return geode;

}

class EyePointCallback : public osg::UniformCallback
{
public:
EyePointCallback(osg::ref_ptrosg::Camera camera)
{
_camera = camera;
}

virtual void operator() (osg::Uniform* uniform, osg::NodeVisitor* nv)
{
	osg::Vec3 eye, center, up;
	_camera->getViewMatrixAsLookAt(eye, center, up);
	uniform->set(eye);
}

private:
osg::ref_ptrosg::Camera _camera;
};

class ProjectMatrixCallback : public osg::UniformCallback
{
public:
ProjectMatrixCallback(osg::ref_ptrosg::Camera camera)
{
_camera = camera;
}

virtual void operator() (osg::Uniform* uniform, osg::NodeVisitor* nv)
{
	osg::Matrixd projectionMatrix = _camera->getProjectionMatrix();
	uniform->set(projectionMatrix);
}

private:
osg::ref_ptrosg::Camera _camera;
};
class ViewMatrixCallback : public osg::UniformCallback
{
public:
ViewMatrixCallback(osg::ref_ptrosg::Camera camera)
{
_camera = camera;
}

virtual void operator() (osg::Uniform* uniform, osg::NodeVisitor* nv)
{
	osg::Matrixd viewMatrix = _camera->getViewMatrix();
	uniform->set(viewMatrix);
}

private:
osg::ref_ptrosg::Camera _camera;
};
int main()
{
osg::ref_ptrosg::TextureCubeMap tcm = new osg::TextureCubeMap;
tcm->setTextureSize(512, 512);
tcm->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
tcm->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
tcm->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
tcm->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
tcm->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE);

std::string strImagePosX = "D:/irradiance/Right face camera.bmp";
osg::ref_ptr<osg::Image> imagePosX = osgDB::readImageFile(strImagePosX);
tcm->setImage(osg::TextureCubeMap::POSITIVE_X, imagePosX);
std::string strImageNegX = "D:/irradiance/Left face camera.bmp";
osg::ref_ptr<osg::Image> imageNegX = osgDB::readImageFile(strImageNegX);
tcm->setImage(osg::TextureCubeMap::NEGATIVE_X, imageNegX);

std::string strImagePosY = "D:/irradiance/Front face camera.bmp";;
osg::ref_ptr<osg::Image> imagePosY = osgDB::readImageFile(strImagePosY);
tcm->setImage(osg::TextureCubeMap::POSITIVE_Y, imagePosY);
std::string strImageNegY = "D:/irradiance/Back face camera.bmp";;
osg::ref_ptr<osg::Image> imageNegY = osgDB::readImageFile(strImageNegY);
tcm->setImage(osg::TextureCubeMap::NEGATIVE_Y, imageNegY);

std::string strImagePosZ = "D:/irradiance/Top face camera.bmp";
osg::ref_ptr<osg::Image> imagePosZ = osgDB::readImageFile(strImagePosZ);
tcm->setImage(osg::TextureCubeMap::POSITIVE_Z, imagePosZ);
std::string strImageNegZ = "D:/irradiance/Bottom face camera.bmp";
osg::ref_ptr<osg::Image> imageNegZ = osgDB::readImageFile(strImageNegZ);
tcm->setImage(osg::TextureCubeMap::NEGATIVE_Z, imageNegZ);

osg::ref_ptr<osg::Uniform> tex0Uniform = new osg::Uniform("irradianceMap", 0);

osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;

osg::ref_ptr<osg::Camera> camera = viewer->getCamera();
osg::ref_ptr<osg::Uniform> camPosUniform = new osg::Uniform("camPos", osg::Vec3f(0, 0, 0));
camPosUniform->setUpdateCallback(new EyePointCallback(camera));

osg::Matrix viewMatrix = camera->getViewMatrix();
osg::Matrix projMatrix = camera->getProjectionMatrix();
osg::Vec3f eye, center, up;
camera->getViewMatrixAsLookAt(eye, center, up);

//osg::ref_ptr<osg::Uniform> camPosUniform = new osg::Uniform("camPos", eye);
osg::ref_ptr<osg::Uniform> viewMatrixUniform = new osg::Uniform("view", viewMatrix);
viewMatrixUniform->setUpdateCallback(new ViewMatrixCallback(camera));
osg::ref_ptr<osg::Uniform> projMatrixUniform = new osg::Uniform("projection", projMatrix);
projMatrixUniform->setUpdateCallback(new ProjectMatrixCallback(camera));
osg::ref_ptr<osg::Group> grp = new osg::Group;
//漫反射比率
osg::Vec3f albedo(0.5f, 0.0f, 0.0f);
osg::ref_ptr<osg::Uniform> albedoUniform = new osg::Uniform("albedo", albedo);
float ao = 1.0f;
osg::ref_ptr<osg::Uniform> aoUniform = new osg::Uniform("ao", ao);

int nrRows = 7;
int nrColumns = 7;
float spacing = 2.5;
float ballRadius = 1.0f;

osg::ref_ptr<osg::Vec3Array> lightColors = new osg::Vec3Array;
lightColors->push_back(osg::Vec3(300.0f, 300.0f, 300.0f));
lightColors->push_back(osg::Vec3(300.0f, 300.0f, 300.0f));
lightColors->push_back(osg::Vec3(300.0f, 300.0f, 300.0f));
lightColors->push_back(osg::Vec3(300.0f, 300.0f, 300.0f));

osg::ref_ptr<osg::Uniform> lightColorsUniform = new osg::Uniform(osg::Uniform::FLOAT_VEC3, "lightColors", lightColors->size());
for (int i = 0; i < lightColors->size(); i++)
{
	lightColorsUniform->setElement(i, lightColors->at(i));
}
osg::ref_ptr<osg::Vec3Array> lightPositions = new osg::Vec3Array;
lightPositions->push_back(osg::Vec3(-10.0f, 10.0f, 10.0f));
lightPositions->push_back(osg::Vec3(10.0f, 10.0f, 10.0f));
lightPositions->push_back(osg::Vec3(-10.0f, -10.0f, 10.0f));
lightPositions->push_back(osg::Vec3(10.0f, -10.0f, 10.0f));

osg::ref_ptr<osg::Uniform> lightPositionsUniform = new osg::Uniform(osg::Uniform::FLOAT_VEC3, "lightPositions", lightPositions->size());
for (int i = 0; i < lightPositions->size(); i++)
{
	lightPositionsUniform->setElement(i, lightPositions->at(i));
}
for (int row = 0; row < nrRows; row++)
{
	float metallic = row * 1.0 / nrRows;
	for (int col = 0; col < nrColumns; col++)
	{
		float roughness = col * 1.0 / nrColumns;
		if (roughness <0.05)
		{
			roughness = 0.05;
		}
		if (roughness > 1.0)
		{
			roughness = 1.0;
		}
		osg::Vec3 ballCenter(
			(col - (nrColumns / 2)) * spacing,
			(row - (nrRows / 2)) * spacing,
			0.0f);
		osg::Matrix worldMatrix = osg::Matrix::translate(ballCenter);

		osg::Matrix inverse;
		inverse.invert(worldMatrix);
		osg::Matrix transPose;
		transPose.transpose(inverse);
		osg::ref_ptr<osg::Geode> geode = renderSphere(ballCenter);
		{
			osg::ref_ptr<osg::StateSet> stateset = geode->getOrCreateStateSet();
			stateset->setTextureAttributeAndModes(0, tcm, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
			osg::ref_ptr<osg::Shader> vs = new osg::Shader(osg::Shader::VERTEX, vertexShader_PBR);
			osg::ref_ptr<osg::Shader> ps = new osg::Shader(osg::Shader::FRAGMENT, psShader_PBR);
			osg::ref_ptr<osg::Program> program = new osg::Program;
			program->addBindAttribLocation("aPos", 1);
			program->addBindAttribLocation("aNormal", 2);
			program->addShader(vs);
			program->addShader(ps);

			osg::ref_ptr<osg::Uniform> metallicUniform = new osg::Uniform("metallic", metallic);
			osg::ref_ptr<osg::Uniform> roughnessUniform = new osg::Uniform("roughness", roughness);
			//osg::ref_ptr<osg::Uniform> transposeInverseMatrixUniform = new osg::Uniform("normalMatrix", transPose);

			osg::Uniform* transposeInverseMatrixUniform = stateset->getOrCreateUniform("normalMatrix", osg::Uniform::FLOAT_MAT4);
			transposeInverseMatrixUniform->set(transPose);
			stateset->addUniform(albedoUniform);
			stateset->addUniform(metallicUniform);
			stateset->addUniform(roughnessUniform);
			stateset->addUniform(aoUniform);
			stateset->addUniform(lightPositionsUniform);
			stateset->addUniform(lightColorsUniform);
			stateset->addUniform(transposeInverseMatrixUniform);
			stateset->addUniform(viewMatrixUniform);
			stateset->addUniform(projMatrixUniform);
			stateset->addUniform(camPosUniform);
			stateset->addUniform(tex0Uniform);
			stateset->setAttribute(program, osg::StateAttribute::ON);
		}
		grp->addChild(geode);
	}

}
grp->addChild(renderSphere(osg::Vec3(-10.0f, 10.0f, 10.0f)));
grp->addChild(renderSphere(osg::Vec3(10.0f, 10.0f, 10.0f)));
grp->addChild(renderSphere(osg::Vec3(-10.0f, -10.0f, 10.0f)));
grp->addChild(renderSphere(osg::Vec3(10.0f, -10.0f, 10.0f)));

viewer->getCamera()->setClearColor(osg::Vec4(0.1f, 0.1f, 0.1f, 1.0f));
viewer->setSceneData(grp);
viewer->run();

return 0;

}

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

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

相关文章

Linux -- 进程间通信之匿名管道

博客中涉及代码已全部上传至Gitee&#xff0c;有需要请自行下载 目录 前言通信基础管道 匿名管道第一步&#xff1a;创建管道第二步&#xff1a;创建子进程第三步&#xff1a;开始通信第四步&#xff1a;结束通信 匿名管道通信代码实现四种特殊情景 基于匿名管道的多进程控制对…

【Linux】Linux进程控制

​ ​&#x1f4dd;个人主页&#xff1a;Sherry的成长之路 &#x1f3e0;学习社区&#xff1a;Sherry的成长之路&#xff08;个人社区&#xff09; &#x1f4d6;专栏链接&#xff1a;Linux &#x1f3af;长路漫漫浩浩&#xff0c;万事皆有期待 上一篇博客&#xff1a;【Linux】…

Latex写论文时图的设置

我们在写论文&#xff0c;使用官方Latex模板可能经常遇到这种情况&#xff1a; 图和文字间距太大&#xff0c;这是因为排版时图片插入到了一个段的中间导致的。 解决方法是&#xff08;注意控制字符\vspace一定要放在引用图的代码块里面&#xff09;&#xff1a; \begin{figu…

浅谈电气防火保护器在地下商场的应用

摘 要&#xff1a;近年来&#xff0c;我国城市发展速度加速。很多城市大力建造地下建筑设施&#xff0c;比如地铁、地下停车场和地下商场等。地下商场属于人员密集型建筑&#xff0c;其防火设计一直令相关的专家头疼。由于人员密集&#xff0c;防火处理不好将酿成灾难性的后果。…

【数据结构与算法】 - 时间复杂度和空间复杂度、二分查找、线性查找

数据结构与算法 1. 数据结构的定义2. 二分查找2.1 二分查找的定义2.2 二分查找分析2.3 二分查找实现2.4 二分查找算法图解2.5 二分算法引发的问题2.6 二分算法改良版2.7 二分算法改良版解析2.8 二分算法改良版图解2.9 二分算法改良版注意事项 3. 时间复杂度3.1 时间复杂度的概念…

数据计算-第15届蓝桥杯第一次STEMA测评Scratch真题精选

[导读]&#xff1a;超平老师的《Scratch蓝桥杯真题解析100讲》已经全部完成&#xff0c;后续会不定期解读蓝桥杯真题&#xff0c;这是Scratch蓝桥杯真题解析第154讲。 第15届蓝桥杯第1次STEMA测评已于2023年8月20日落下帷幕&#xff0c;编程题一共有6题&#xff0c;分别如下&a…

ThreeJS-3D教学二:基础形状展示

three中提供了22 个基础模型&#xff0c;此案例除了 EdgesGeometry、ExtrudeGeometry、TextGeometry、WireframeGeometry&#xff0c;涵盖 17 个形状。 Fog 雾化设置&#xff0c;这是scene场景效果EdgesGeometry , WireframeGeometry 更多地可能作为辅助功能去查看几何体的边和…

修炼k8s+flink+hdfs+dlink(一:安装flink)

一&#xff1a;standalone的ha环境部署。 创建目录&#xff0c;上传安装包。 mkdir /opt/app/flink 上传安装包到本目录。 tar -zxvf flink-1.13.6-bin-scala_2.12.tgz配置参数。 在flink-conf.yaml中添加zookeeper配置 jobmanager.rpc.address: node01 high-availability: …

论文浅尝 | INGRAM:通过关系图的归纳知识图谱嵌入

笔记整理&#xff1a;郭荣辉&#xff0c;天津大学硕士 链接&#xff1a;https://arxiv.org/abs/2305.19987 动机 归纳知识图谱补全是预测训练期间没有观察到的新实体之间缺失的三元组的任务。虽然大多数归纳知识图谱补全方法假定所有实体都是新的&#xff0c;但它们不允许在推理…

【c语言的malloc函数介绍】

malloc&#xff08;memory allocation的缩写&#xff09;是C语言中的一个函数&#xff0c;用于动态分配内存空间。这个函数允许你在程序运行时请求指定大小的内存块&#xff0c;以供后续使用。malloc函数属于标准库函数&#xff0c;需要包含头文件#include <stdlib.h> 才…

使用Vue、ElementUI实现登录注册,配置axios全局设置,解决CORS跨域问题

目录 引言 什么是ElementUI&#xff1f; 步骤1&#xff1a;创建Vue组件用于用户登录和注册 1. 基于SPA项目完成登录注册 在SPA项目中添加elementui依赖 在main.js中添加elementui模块 创建用户登录注册组件 配置路由 修改项目端口并启动项目 静态页面展示图 步骤2&#x…

搭建qml box2d开发环境

box2d是开源的优秀物理引擎 box2d官网 https://box2d.org/ qml box2d插件工程 https://gitee.com/gao_yao_yao/qml-box2d 1. qml box2d插件工程 下载&#xff0c;解压qml-box2d-master.zip&#xff0c;用qt打开box2d.pro&#xff0c;编译Debug|Release拷贝Box2D.dll|Box2Dd.…

LeetCode算法二叉树—226. 翻转二叉树

目录 226. 翻转二叉树 代码&#xff1a; 运行结果&#xff1a; 给你一棵二叉树的根节点 root &#xff0c;翻转这棵二叉树&#xff0c;并返回其根节点。 示例 1&#xff1a; 输入&#xff1a;root [4,2,7,1,3,6,9] 输出&#xff1a;[4,7,2,9,6,3,1]示例 2&#xff1a; 输入…

easyrecovery好用吗 easyrecovery软件收费吗

EasyRecovery是一款专业的数据恢复软件&#xff0c;它功能强大且性价比高&#xff0c;能够精确找回需要的文件&#xff0c;方便又快捷。那么Easyrecovery好用吗&#xff0c;Easyrecovery软件收费吗。今天我为大家解答一下这两个问题。 一、Easyrecovery好用吗 EasyRcovery可用…

系统接口响应信息通用加密设计

设计目的 出于对一些敏感信息的安全性考虑&#xff0c;接口的响应信息需要进行加密&#xff0c;避免明文传输 使用场景 本系统前端响应信息加密 第三方系统响应信息加密 功能设计思路 配置模式加密 使用场景&#xff1a;本系统前端响应信息加密 在nacos中配置需要加密的…

用于生物分子修饰的Alkyne NHS ester,906564-59-8

产品简介&#xff1a;用于生物分子修饰的炔烃NHS酯。铜催化的化学反应中的炔基几乎从未在天然分子中遇到过。然而&#xff0c;这种NHS酯允许将炔基连接到氨基上&#xff0c;氨基在自然界中普遍存在&#xff0c;存在于蛋白质、肽、合成氨基DNA和许多小分子中。炔基随后可以通过铜…

langchain+gpt+agent

一.agentConversation 通过用户问题&#xff0c;来选择 import json import os import refrom langchain import FAISS, PromptTemplate, LLMChain from langchain.agents import initialize_agent, Tool, AgentType from langchain.chains import RetrievalQA from langchai…

C++ | C++11新特性(下)

前言 前面我们介绍了C11列表初始化、新的类功能以及右值引用等新特性&#xff0c;本文继续介绍关于可变参数模板以及lambda表达式等新语法&#xff1b; 一、可变参数模板 在C11前&#xff0c;我们有普通固定数量模板参数&#xff0c;但对于可变参数&#xff0c;我们无从下手&am…

淘宝电商必备的大数据应用

在日常生活中&#xff0c;大家总能听到“大数据”“人工智能”的说法。现在的大数据技术应用&#xff0c;从大到巨大科学研究、社会信息审查、搜索引擎&#xff0c;小到社交联结、餐厅推荐等等&#xff0c;已经渗透到我们生活中的方方面面。到底大数据在电商行业可以怎么用&…

什么是EventEmitter?它在Node.js中有什么作用?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ 什么是EventEmitter&#xff1f;⭐ 它在Node.js中的作用是什么&#xff1f;⭐ 写在最后 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 欢迎来到前端入门之旅&#xff01;感兴趣的可以订阅本专栏哦&#xff01;这个专栏是为…