Babylon.js 第19章 体积光散射后期处理

发布于:2022-12-25 ⋅ 阅读:(375) ⋅ 点赞:(0)

一、做一个太阳

	var godrays = new BABYLON.VolumetricLightScatteringPostProcess(
            'godrays',
            1.0,
            camera,
            null,
            100,
            BABYLON.Texture.BILINEAR_SAMPLINGMODE,
            engine,
            false
        );
    //曝光
    godrays.exposure =0.9;
    //衰减
    godrays.decay = 0.9;
    godrays.weight = 0.9;
    //密度
    godrays.density = 0.5;

    godrays.mesh.material.diffuseTexture = new BABYLON.Texture(
        '../img/TEST.png', scene, true, false,
        BABYLON.Texture.BILINEAR_SAMPLINGMODE);
    godrays.mesh.material.diffuseTexture.hasAlpha = true;
	godrays.mesh.position = new BABYLON.Vector3(-150, 150, 150);
	godrays.mesh.scaling = new BABYLON.Vector3(200, 175, 200);

 参数:

  • name {string} - 后处理名称。

  • ratio {any} - 后期处理和/或内部通道的大小(0.5 意味着您的后期处理将具有宽度 = canvas.width * 0.5高度 = canvas.height * 0.5。)

  • camera {BABYLON.Camera} - 后处理将附加到的相机。

  • lightSourceMesh {BABYLON.Mesh} - 用作光源的网格,以创建光散射效果(例如,具有模拟太阳纹理的广告牌。)

  • samplesNum {number} - 后期处理质量。默认值为 100。

  • samplingMode {number} - 后处理过滤模式。

  • engine {BABYLON.Engine} - 巴比伦引擎。

  • reusable {boolean} - 如果后期处理是可重用的。

  • 场景 {BABYLON.Scene} - 如果相机参数为空(在渲染管道中添加后处理),则需要场景来配置内部通道。

 警告:如果自定义灯光位置距离光源太远,结果会失真。

useDiffuseColor 用于强制渲染光源网格的漫反射颜色,而不是其漫反射纹理。

  • 如果 useDiffuseColor 为 true 或 material.diffuseTexture 未定义,则使用漫反射颜色

  • 如果 useDiffuseColor 为 false 且 material.diffuseTexture 未定义,则使用漫反射纹理

  • 如果 useDiffuseColor 为 false 且 material.diffuseTexture 未定义,则使用漫反射颜色

 要自定义光散射,您可以修改光线的垂直方向。如果invert设置为 true,则光线将向下移动。向上,如果 invert 设置为 false。


网站公告

今日签到

点亮在社区的每一天
去签到