mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-08-28 22:30:04 -04:00
Refactor ShaderManager's DRAW_MODE and effect info
Draw modes are now enabled/disabled by bitmask and can be combined. Combining silhouette mode and color mask mode will be useful for color-touching-color, for example. Effect converters are now one field in a larger EFFECT_INFO map, which also contains bitmask values for each effect. Drawable no longer makes any assumptions regarding how ShaderManager will unpack the effect bits. The shader cache is now an array of arrays, where the outer index is the mask of active draw modes and the inner index is the mask of active effects (as it was before). Effects which cannot impact the shape of a Drawable are masked out in silhouette mode in order to avoid compiling redundant shaders.
This commit is contained in:
parent
bb357ba8bc
commit
91cc797c3b
2 changed files with 94 additions and 46 deletions
|
@ -47,7 +47,7 @@ function Drawable(gl) {
|
|||
var numEffects = ShaderManager.EFFECTS.length;
|
||||
for (var index = 0; index < numEffects; ++index) {
|
||||
var effectName = ShaderManager.EFFECTS[index];
|
||||
var converter = ShaderManager.EFFECT_VALUE_CONVERTER[effectName];
|
||||
var converter = ShaderManager.EFFECT_INFO[effectName].converter;
|
||||
this._uniforms['u_' + effectName] = converter(0);
|
||||
}
|
||||
|
||||
|
@ -314,18 +314,18 @@ Drawable.prototype.updateProperties = function (properties) {
|
|||
}
|
||||
var numEffects = ShaderManager.EFFECTS.length;
|
||||
for (var index = 0; index < numEffects; ++index) {
|
||||
var propertyName = ShaderManager.EFFECTS[index];
|
||||
if (propertyName in properties) {
|
||||
var rawValue = properties[propertyName];
|
||||
var mask = 1 << index;
|
||||
var effectName = ShaderManager.EFFECTS[index];
|
||||
if (effectName in properties) {
|
||||
var rawValue = properties[effectName];
|
||||
var effectInfo = ShaderManager.EFFECT_INFO[effectName];
|
||||
if (rawValue != 0) {
|
||||
this._effectBits |= mask;
|
||||
this._effectBits |= effectInfo.mask;
|
||||
}
|
||||
else {
|
||||
this._effectBits &= ~mask;
|
||||
this._effectBits &= ~effectInfo.mask;
|
||||
}
|
||||
var converter = ShaderManager.EFFECT_VALUE_CONVERTER[propertyName];
|
||||
this._uniforms['u_' + propertyName] = converter(rawValue);
|
||||
var converter = effectInfo.converter;
|
||||
this._uniforms['u_' + effectName] = converter(rawValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -334,7 +334,7 @@ Drawable.prototype.updateProperties = function (properties) {
|
|||
* Set the dimensions of this Drawable's skin.
|
||||
* @param {int} width The width of the new skin.
|
||||
* @param {int} height The height of the new skin.
|
||||
* @param {int} costumeResolution The resolution to use for this skin.
|
||||
* @param {int} [costumeResolution] The resolution to use for this skin.
|
||||
* @private
|
||||
*/
|
||||
Drawable.prototype._setSkinSize = function (width, height, costumeResolution) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue