Threejs-Vray元素组成

时间:2019-04-22 08:46:17

标签: three.js glsl webgl shader fragment-shader

我正在使用Three.js渲染模型,并且我想使用自定义着色器将一些VRay渲染的图像组合在一起。

下面是我在Photoshop中得到的内容

“ *” = Photoshop Multiply

“ +” = Photoshop Linear Dodge添加

此图像=(漫射*全局照明)+(漫射*照明)+高光 Comp

请参见下面的渲染元素

漫射 diffuse 全球照明 GI 灯光 Lighting 高光 Specular

下面是我在三个js中得到的...不是很完美

ThreeJS

这是我的片段着色器


"uniform sampler2D overlay;",       
        "uniform sampler2D VrayRawDiffuseFilter;",
        "uniform sampler2D VrayRawGIFilter;",
        "uniform sampler2D VrayRawLightingFilter;",
        "uniform sampler2D VraySpecularFilter;",
        "uniform sampler2D VRayBackground;",




        "varying vec2 vUv;",


        "void main() {",    

            "vec4 overlay = texture2D(overlay, vUv);",
            "vec4 diffuse = texture2D(VrayRawDiffuseFilter, vUv);",
            "vec4 VrayRawGIFilter = texture2D(VrayRawGIFilter, vUv);",
            "vec4 VrayRawLightingFilter = texture2D(VrayRawLightingFilter, vUv);",
            "vec4 VraySpecularFilter = texture2D(VraySpecularFilter, vUv);",

            "vec4 diffuseGI = diffuse*VrayRawGIFilter;",
            "vec4 diffuseLighting = diffuse*VrayRawLightingFilter;",

            "vec4 comp = diffuseGI+diffuseLighting+VraySpecularFilter;",


            "gl_FragColor = comp;",
            "gl_FragColor.a = 1.0;",

        "}"`

我知道这很形象。 我正在写这篇文章,目的是向那些可能对这种东西有经验/成功的人了解这个问题。

0 个答案:

没有答案