Jump to content

What material to use if even lighting information in the texture is baked ?


BritneyWatch
 Share

Recommended Posts

I understand that in Babylon.js, you have to put lights for shadings and well....3D effect in general.

But say I want to save up all the processing time and do away with having to calculate lights altogether and I already have my scene with all the lighting information baked in the texture.

In Blender such a texture would be called emissive, in 3DS Max, it will be standard material with full illumination.

How or what is the way to implement such a simplistic texture in Babylon.js to save up lighting calculation time ?

Link to comment
Share on other sites

You should be able to make a custom shader material for this purpose, at least that is what I do. I use it when I want the material to appear exactly as is. Something like:

BABYLON.Effect.ShadersStore['noLightFragmentShader'] = `
precision highp float;

uniform float time;
varying vec2 vUV;
uniform sampler2D textureSampler;

void main() {
  vec4 texture_color = texture2D( textureSampler, vUV );
  vec4 final = texture_color;
  gl_FragColor = final;
}

 

BABYLON.Effect.ShadersStore["noLightVertexShader"]= `
precision highp float;
// Attributes
attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;
// Uniforms
uniform mat4 worldViewProjection;
// Varying
varying vec4 vPosition;
varying vec3 vNormal;
varying vec2 vUV;

void main(void) {
  gl_Position = worldViewProjection * vec4(position, 1.0);
  vUV = uv;
}`;

 

    this.babylon = new BABYLON.ShaderMaterial('blah', this.scene, {
      vertex: 'noLight',
      fragment: 'noLight',
    },
    {    attributes: ["position", "normal", "uv"],
    uniforms: [ "world", "worldView", "worldViewProjection", "view", "projection" ],
    });
`;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...