mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
fix effects
This commit is contained in:
Vendored
+72
File diff suppressed because one or more lines are too long
@@ -183,9 +183,10 @@ export default class LightComponent extends Component {
|
||||
|
||||
set color (val) {
|
||||
this._color = val;
|
||||
this._colorData[0] = val.r * this._intensity;
|
||||
this._colorData[1] = val.g * this._intensity;
|
||||
this._colorData[2] = val.b * this._intensity;
|
||||
const scale = this._intensity / 255;
|
||||
this._colorData[0] = val.r * scale;
|
||||
this._colorData[1] = val.g * scale;
|
||||
this._colorData[2] = val.b * scale;
|
||||
if (this._light) {
|
||||
this._light.color = this._colorData;
|
||||
}
|
||||
@@ -204,9 +205,10 @@ export default class LightComponent extends Component {
|
||||
|
||||
set intensity (val) {
|
||||
this._intensity = val;
|
||||
this._colorData[0] = this._color.r * val;
|
||||
this._colorData[1] = this._color.g * val;
|
||||
this._colorData[2] = this._color.b * val;
|
||||
const scale = val / 255;
|
||||
this._colorData[0] = this._color.r * scale;
|
||||
this._colorData[1] = this._color.g * scale;
|
||||
this._colorData[2] = this._color.b * scale;
|
||||
if (this._light) {
|
||||
this._light.color = this._colorData;
|
||||
}
|
||||
|
||||
@@ -155,12 +155,8 @@ export class Pass {
|
||||
stride: 1, // N/A for blocks
|
||||
usage: GFXBufferUsageBit.UNIFORM,
|
||||
});
|
||||
if (buffer) {
|
||||
this._buffers[u.binding] = buffer;
|
||||
} else {
|
||||
console.error('create buffer failed.');
|
||||
return;
|
||||
}
|
||||
if (buffer) { this._buffers[u.binding] = buffer; }
|
||||
else { console.error('create buffer failed.'); return; }
|
||||
// buffer data processing system
|
||||
const block: IBlock = this._blocks[u.binding] = {
|
||||
buffer: buffer.buffer as ArrayBuffer,
|
||||
@@ -188,13 +184,12 @@ export class Pass {
|
||||
const inf = info.properties && info.properties[u.name];
|
||||
const samplerInfo = Object.assign({ name: u.name }, inf && inf.sampler);
|
||||
const sampler = device.createSampler(samplerInfo);
|
||||
if (sampler) {
|
||||
this._samplers[u.binding] = sampler;
|
||||
} else {
|
||||
console.error('create sampler failed.');
|
||||
}
|
||||
if (sampler) { this._samplers[u.binding] = sampler; }
|
||||
else { console.error('create sampler failed.'); }
|
||||
const texName = inf && inf.value ? inf.value + '-texture' : _type2default[u.type];
|
||||
this._textureViews[u.binding] = builtinResMgr.get<TextureBase>(texName).getGFXTextureView()!;
|
||||
const texture = builtinResMgr.get<TextureBase>(texName);
|
||||
if (texture) { this._textureViews[u.binding] = texture.getGFXTextureView()!; }
|
||||
else { console.warn(`illegal texture default value ${texName}`); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ class ProgramLib {
|
||||
if (program !== undefined) {
|
||||
return program;
|
||||
}
|
||||
defines.CC_NUM_DIR_LIGHTS = 1;
|
||||
|
||||
// get template
|
||||
const tmpl = this._templates[name];
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Light, LightType } from './light';
|
||||
import { RenderScene } from './render-scene';
|
||||
|
||||
export class DirectionalLight extends Light {
|
||||
protected _direction = new Float32Array(4);
|
||||
protected _direction = Float32Array.from([0, 0, 1, 0]);
|
||||
|
||||
set direction (val: Vec3) {
|
||||
vec3.array(this._direction, val);
|
||||
|
||||
@@ -8,7 +8,7 @@ export enum LightType {
|
||||
}
|
||||
|
||||
export class Light {
|
||||
protected _color = new Float32Array(4);
|
||||
protected _color = Float32Array.from([1, 1, 1, 1]);
|
||||
protected _enabled = false;
|
||||
|
||||
set enabled (val) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Light, LightType } from './light';
|
||||
import { RenderScene } from './render-scene';
|
||||
|
||||
export class PointLight extends Light {
|
||||
protected _positionAndRange = new Float32Array(4);
|
||||
protected _positionAndRange = Float32Array.from([0, 0, 0, 10]);
|
||||
|
||||
set position (val: Vec3) {
|
||||
vec3.array(this._positionAndRange, val);
|
||||
|
||||
@@ -4,8 +4,8 @@ import { Light, LightType } from './light';
|
||||
import { RenderScene } from './render-scene';
|
||||
|
||||
export class SpotLight extends Light {
|
||||
protected _direction = new Float32Array(4);
|
||||
protected _positionAndRange = new Float32Array(4);
|
||||
protected _direction = Float32Array.from([0, 0, 1, 0]);
|
||||
protected _positionAndRange = Float32Array.from([0, 0, 0, 10]);
|
||||
|
||||
set position (val: Vec3) {
|
||||
vec3.array(this._positionAndRange, val);
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
const material = new cc.Material();
|
||||
material.setDefines({ USE_COLOR: true });
|
||||
// parsed effect file is embedded in cocos/3d/builtin/effects.js
|
||||
material.effectName = 'builtin-effect-phong';
|
||||
material.effectName = 'builtin-effect-pbr';
|
||||
|
||||
const len = 50;
|
||||
const models = [], passes = [];
|
||||
@@ -84,7 +84,7 @@
|
||||
// material instance initialized here
|
||||
passes.push(modelCom.material.passes[0]);
|
||||
}
|
||||
const handle = passes[0].getHandle('diffuseColor');
|
||||
const handle = passes[0].getHandle('albedo');
|
||||
|
||||
{
|
||||
const material = new cc.Material();
|
||||
|
||||
Reference in New Issue
Block a user