惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
Cloudbric
Cloudbric
V
Visual Studio Blog
L
LangChain Blog
A
About on SuperTechFans
B
Blog
T
Tenable Blog
罗磊的独立博客
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
博客园 - 三生石上(FineUI控件)
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Palo Alto Networks Blog
U
Unit 42
WordPress大学
WordPress大学
D
Darknet – Hacking Tools, Hacker News & Cyber Security
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
C
Check Point Blog
Security Latest
Security Latest
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
NISL@THU
NISL@THU
Forbes - Security
Forbes - Security
S
Securelist
Security Archives - TechRepublic
Security Archives - TechRepublic
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
Latest news
Latest news
GbyAI
GbyAI
T
Troy Hunt's Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
V2EX - 技术
V2EX - 技术
小众软件
小众软件
Google DeepMind News
Google DeepMind News
K
Kaspersky official blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
Netflix TechBlog - Medium
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed

博客园 - surfsky

用阿里的 sketch 插件 FusionDesign 来快速设计中后台 用 Sketch 设计和输出响应式网页 百度、高德、腾讯、天地图、谷歌、必应瓦片图地图切图工具 MapCutter(旧名 MapTiler),支持超大图、高清切片、webgl、leaflet、maptalk、openlayers、cesium netcore 下的 Javascript 表达式求值 netcore 下的 C# 表达式求值 中标麒麟安装SQLServer 中标麒麟上开启MySql 在 MAC 下配置 Nginx Color Schema 配色随笔 .Net与 WebAssembly 随笔 关于Xamarin、Qml、数据绑定、MVC、MVVM 相关的散讲 用Nuget部署程序包 Qt3D Qt QML 2D shader LearnOpenGL Qt3D 5.9 and future FineUI 相关 EntityFramwork 七七八八 Qt qml 单例模式
Qt3D Shader
surfsky · 2017-06-08 · via 博客园 - surfsky
---------------------------------------------------
Qt3D ShaderPrograme
Qt3D GLSL 渲染器
Shader示例可参考:
    http://blog.csdn.net/candycat1992/article/details/44039077
    https://www.shadertoy.com/
http://blog.csdn.net/candycat1992/article/details/44039077
faq: shader的输入参数怎么各家都不一样,到底是如何定义的
---------------------------------------------------
概念
    渲染代码可由ShaderProgram对象封装
    参数的传递比ShaderEffect复杂得多,好麻烦
    要求输出的参数是一致的(gl_Position, gl_FragColor)
    

Qt3D默认提供的参数
    attribute highp vec4 vertexPosition;   // 顶点位置
    attribute highp vec3 vertexNormal;     // 顶点法线
    attribute highp vec2 vertexTexCoord;   // 顶点纹理坐标
    uniform highp mat4 mvp;                // ?
    uniform highp mat4 modelMatrix;        // ?
    uniform highp vec3 cameraPosition;     // 相机位置
    uniform mat4 modelView;                // ?
    uniform mat4 modelNormalMatrix;        // ?

常用的方法
   normalize
   dot
   min/mix/max/pow/
   textureCube
    highp vec4 surface = texture2D(surfaceTexture, texCoord);
    highp vec3 reflectedDirection = reflect(viewDirection, normalize(normal));
    textureCube(skyboxTexture, reflectedDirection).rgb

VertexShader
    // Qt 3D默认提供的参数  
    attribute vec3 vertexPosition;  
    attribute vec3 vertexNormal;  
    uniform mat4 modelView;  
    uniform mat4 modelNormalMatrix;  
    uniform mat4 mvp;  
    // 自己提供的参数  
    uniform vec3 lightPosition;  
    varying vec3 reflectVec;  
    varying vec3 viewVec;  
    varying float NdotL;  
    void main( void )  
    {  
        vec3 ecPos = ( modelView * vec4( vertexPosition, 1.0 ) ).xyz;  
        vec3 normal = normalize( modelNormalMatrix * vec4( vertexNormal, 1.0 ) ).xyz;  
        vec3 lightVec = normalize( lightPosition - ecPos );  
        reflectVec = normalize( reflect( -lightVec, normal ) );  
        viewVec = normalize( -ecPos );  
        NdotL = ( dot( lightVec, normal ) + 1.0 ) * 0.5;  
        gl_Position = mvp * vec4( vertexPosition, 1.0 );  
    }  


FragmentShader
    // 自己提供的参数  
    uniform vec3 surfaceColor;  
    uniform vec3 warmColor;  
    uniform vec3 coolColor;  
    uniform float diffuseWarm;  
    uniform float diffuseCool;  
    varying vec3 reflectVec;  
    varying vec3 viewVec;  
    varying float NdotL;  
    void main( void )  
    {  
        vec3 kcool    = min( coolColor + diffuseCool * surfaceColor, 1.0 );  
        vec3 kwarm    = min( warmColor + diffuseWarm * surfaceColor, 1.0 );  
        vec3 kfinal   = mix( kcool, kwarm, NdotL );  
        float spec = max( dot( reflectVec, viewVec ), 0.0 );  
        spec = pow( spec, 32.0 );  
        gl_FragColor = vec4( min( kfinal + spec, 1.0 ), 1.0 );  
    }
    


cinematic3d/BackgroundCubeMap.qml    
    ShaderProgram {
        id: gles2SkyboxShader
        vertexShaderCode: "
            attribute vec3 vertexPosition;
            varying vec3 texCoord0;
            uniform mat4 mvp;
            void main()
            {
                texCoord0 = vertexPosition.xyz;
                gl_Position = vec4(mvp * vec4(vertexPosition, 1.0)).xyww; // Fail depth test always against any rendered pixel
            }
            "
        fragmentShaderCode: "
            varying highp vec3 texCoord0;
            uniform samplerCube skyboxTexture;
            void main()
            {
                gl_FragColor = textureCube(skyboxTexture, texCoord0);
            }
            "
    }
    
// 二维贴图材质
Texture2D {
    property alias source: image.source
    minificationFilter: Texture.LinearMipMapLinear
    magnificationFilter: Texture.Linear
    generateMipMaps: true
    wrapMode {
        x: WrapMode.ClampToEdge
        y: WrapMode.ClampToEdge
    }
    TextureImage {id: image}
}