qml开发3D车载HMI界面-----LightTest.qml

新建一个LightTest.qml来测试环境,测试效果如下:

qmlscene 2023-08-17 14-51-59

import QtQuick 2.15
import QtGraphicalEffects 1.15

Rectangle{
    id:lightTest
    width:1920
    height:1080
    color:"#575757"

    property color lightColor2:"#ffffff" //白色

    property real brightnessMultiplier:1.0 //亮度倍增器
    property real additionalGlassBloomLuminance:1.0
    property real additionalGlassBlurRadius:30.0

    LightTestView3D{
        id:renderedScene
        visible: true
        anchors.fill: parent
        renderScene:  true
    }

    LightTestView3D{
        id:renderedLights
        visible:true
        renderScene: false
        anchors.fill: parent
    }

    //获取控件快照。是在GPU中进行的
    ShaderEffectSource{
        id:renderedSceneBuffer
        width:960
        height: 540
        visible: true
        hideSource: false //不会阻止鼠标到达sourceItem
        sourceItem: renderedScene //将sourceItem渲染为纹理并在场景中显示
    }

    ShaderEffectSource{
        id:renderedLightsBuffer
        x:960
        y:0
        width:960
        height:540
        visible: true
        hideSource: true
        sourceItem: renderedLights
    }

    /*
    //将自定义的着色器用于矩形
    ShaderEffect{
        id:colorizedLights

        width:960
        height:540
        x:0
        y:540

        property color lightCol:lightTest.lightColor2
        property variant renderedLightStencil:renderedLightsBuffer

        fragmentShader: "
            #version 410
            in highp vec2 qt_TexCoord0;
            out vec4 Color;
            uniform lowp float qt_Opacity;
            uniform highp vec4 lightCol;
            uniform sampler2D renderedLightStencil;

            void main() {
                lowp vec4 emission = texture(renderedLightStencil, qt_TexCoord0);
                emission.xyz *= lightCol.xyz;
                Color = vec4(emission.xyz, 1.0);
            }
        "
    }

    //对一个或多个源项目应用快速模糊效果
    FastBlur{
        id:blurredGlass
        source:colorizedLights

        width:960
        height:540
        visible: true

        x:0
        y:1080
        radius:additionalGlassBlurRadius
    }

    ShaderEffectSource{
        id:blurredGlassEffectSource
        width:960
        height:540
        x:960
        y:540
        hideSource: false
        sourceItem: blurredGlass
    }
*/
}

上述就是进行一个灯光场景的测试。下一节介绍各个3D模块的加载和显示。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_41392061

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值