parent
4c5705c2e6
commit
1f153d3b24
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -477,6 +477,7 @@ function updateProjectResolution() {
|
|||
UVEditor.vue.project_resolution.replace([Project.texture_width, Project.texture_height]);
|
||||
UVEditor.vue.updateSize()
|
||||
}
|
||||
Canvas.uvHelperMaterial.uniforms.DENSITY.value = Project.texture_width / 32;
|
||||
if (Texture.selected) {
|
||||
// Update animated textures
|
||||
Texture.selected.height++;
|
||||
|
|
|
@ -808,10 +808,7 @@ new NodePreviewController(Cube, {
|
|||
this.updateTransform(element);
|
||||
this.updateGeometry(element);
|
||||
this.updateFaces(element);
|
||||
|
||||
if (Project.view_mode === 'textured') {
|
||||
this.updateUV(element);
|
||||
}
|
||||
this.updateUV(element);
|
||||
|
||||
},
|
||||
updateTransform(element) {
|
||||
|
@ -898,6 +895,9 @@ new NodePreviewController(Cube, {
|
|||
|
||||
} else if (Project.view_mode === 'normal') {
|
||||
mesh.material = Canvas.normalHelperMaterial
|
||||
|
||||
} else if (Project.view_mode === 'uv') {
|
||||
mesh.material = Canvas.uvHelperMaterial
|
||||
|
||||
} else if (Format.single_texture && Texture.all.length >= 2 && Texture.all.find(t => t.render_mode == 'layered')) {
|
||||
mesh.material = Canvas.getLayeredMaterial();
|
||||
|
@ -924,7 +924,6 @@ new NodePreviewController(Cube, {
|
|||
if (!mesh.material) mesh.material = Canvas.transparentMaterial;
|
||||
},
|
||||
updateUV(cube, animation = true) {
|
||||
if (Project.view_mode !== 'textured') return;
|
||||
var mesh = cube.mesh
|
||||
if (mesh === undefined || !mesh.geometry) return;
|
||||
|
||||
|
|
|
@ -749,6 +749,9 @@ new NodePreviewController(Mesh, {
|
|||
|
||||
} else if (Project.view_mode === 'normal') {
|
||||
mesh.material = Canvas.normalHelperMaterial
|
||||
|
||||
} else if (Project.view_mode === 'uv') {
|
||||
mesh.material = Canvas.uvHelperMaterial
|
||||
|
||||
} else if (Format.single_texture && Texture.all.length >= 2 && Texture.all.find(t => t.render_mode == 'layered')) {
|
||||
mesh.material = Canvas.getLayeredMaterial();
|
||||
|
|
|
@ -212,6 +212,101 @@ const Canvas = {
|
|||
side: THREE.DoubleSide
|
||||
});
|
||||
})(),
|
||||
uvHelperMaterial: (function() {
|
||||
var img = new Image()
|
||||
img.src = 'assets/uv_preview.png'
|
||||
var tex = new THREE.Texture(img)
|
||||
img.tex = tex;
|
||||
img.tex.magFilter = THREE.NearestFilter
|
||||
img.tex.minFilter = THREE.NearestFilter
|
||||
img.tex.wrapS = img.tex.wrapT = THREE.RepeatWrapping;
|
||||
img.onload = function() {
|
||||
this.tex.needsUpdate = true;
|
||||
}
|
||||
var vertShader = `
|
||||
attribute float highlight;
|
||||
|
||||
uniform bool SHADE;
|
||||
uniform float DENSITY;
|
||||
|
||||
varying vec2 vUv;
|
||||
varying float light;
|
||||
varying float lift;
|
||||
|
||||
float AMBIENT = 0.1;
|
||||
float XFAC = -0.05;
|
||||
float ZFAC = 0.05;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
if (SHADE) {
|
||||
|
||||
vec3 N = normalize( vec3( modelViewMatrix * vec4(normal, 0.0) ) );
|
||||
|
||||
light = (0.2 + abs(N.z) * 0.8) * (1.0-AMBIENT) + N.x*N.x * XFAC + N.y*N.y * ZFAC + AMBIENT;
|
||||
|
||||
} else {
|
||||
|
||||
light = 1.0;
|
||||
|
||||
}
|
||||
|
||||
if (highlight == 2.0) {
|
||||
lift = 0.3;
|
||||
} else if (highlight == 1.0) {
|
||||
lift = 0.12;
|
||||
} else {
|
||||
lift = 0.0;
|
||||
}
|
||||
|
||||
vUv = uv;
|
||||
vUv.x = vUv.x * DENSITY;
|
||||
vUv.y = vUv.y * DENSITY;
|
||||
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
||||
gl_Position = projectionMatrix * mvPosition;
|
||||
}`
|
||||
var fragShader = `
|
||||
#ifdef GL_ES
|
||||
precision ${isApp ? 'highp' : 'mediump'} float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D map;
|
||||
|
||||
uniform bool SHADE;
|
||||
|
||||
varying vec2 vUv;
|
||||
varying float light;
|
||||
varying float lift;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
vec4 color = texture2D(map, vUv);
|
||||
|
||||
if (color.a < 0.01) discard;
|
||||
|
||||
gl_FragColor = vec4(lift + color.rgb * light, color.a);
|
||||
|
||||
|
||||
if (lift > 0.2) {
|
||||
gl_FragColor.r = gl_FragColor.r * 0.6;
|
||||
gl_FragColor.g = gl_FragColor.g * 0.7;
|
||||
}
|
||||
|
||||
}`
|
||||
|
||||
return new THREE.ShaderMaterial({
|
||||
uniforms: {
|
||||
map: {type: 't', value: tex},
|
||||
SHADE: {type: 'bool', value: settings.shading.value},
|
||||
DENSITY: {type: 'float', value: 4}
|
||||
},
|
||||
vertexShader: vertShader,
|
||||
fragmentShader: fragShader,
|
||||
side: THREE.DoubleSide,
|
||||
})
|
||||
})(),
|
||||
emptyMaterials: (function() {
|
||||
var img = new Image()
|
||||
img.src = 'assets/missing.png'
|
||||
|
@ -594,7 +689,7 @@ const Canvas = {
|
|||
}
|
||||
if (used === true) {
|
||||
obj.preview_controller.updateFaces(obj);
|
||||
if (Project.view_mode === 'textured' && obj.preview_controller.updateUV) {
|
||||
if (obj.preview_controller.updateUV) {
|
||||
obj.preview_controller.updateUV(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1974,6 +1974,7 @@ function updateShading() {
|
|||
})
|
||||
Canvas.solidMaterial.uniforms.SHADE.value = settings.shading.value;
|
||||
Canvas.solidMaterial.uniforms.BRIGHTNESS.value = settings.brightness.value / 50;
|
||||
Canvas.uvHelperMaterial.uniforms.SHADE.value = settings.shading.value;
|
||||
Canvas.normalHelperMaterial.uniforms.SHADE.value = settings.shading.value;
|
||||
}
|
||||
function updateCubeHighlights(hover_cube, force_off) {
|
||||
|
@ -2144,6 +2145,7 @@ BARS.defineActions(function() {
|
|||
textured: {name: true, condition: () => (!Toolbox.selected.allowed_view_modes || Toolbox.selected.allowed_view_modes.includes('textured'))},
|
||||
solid: {name: true, condition: () => (!Toolbox.selected.allowed_view_modes || Toolbox.selected.allowed_view_modes.includes('solid'))},
|
||||
wireframe: {name: true, condition: () => (!Toolbox.selected.allowed_view_modes || Toolbox.selected.allowed_view_modes.includes('wireframe'))},
|
||||
uv: {name: true, condition: () => (!Toolbox.selected.allowed_view_modes || Toolbox.selected.allowed_view_modes.includes('uv'))},
|
||||
normal: {name: true, condition: () => ((!Toolbox.selected.allowed_view_modes || Toolbox.selected.allowed_view_modes.includes('normal')) && Mesh.all.length)},
|
||||
},
|
||||
onChange() {
|
||||
|
|
|
@ -1221,7 +1221,7 @@ class Texture {
|
|||
Undo.finishEdit('change texture view mode');
|
||||
}
|
||||
return [
|
||||
{name: 'menu.texture.render_mode.normal', icon: texture.render_mode == 'normal' ? 'radio_button_checked' : 'radio_button_unchecked', click() {setViewMode('normal')}},
|
||||
{name: 'menu.texture.render_mode.default', icon: texture.render_mode == 'default' ? 'radio_button_checked' : 'radio_button_unchecked', click() {setViewMode('default')}},
|
||||
{name: 'menu.texture.render_mode.emissive', icon: texture.render_mode == 'emissive' ? 'radio_button_checked' : 'radio_button_unchecked', click() {setViewMode('emissive')}},
|
||||
{name: 'menu.texture.render_mode.layered', icon: texture.render_mode == 'layered' ? 'radio_button_checked' : 'radio_button_unchecked', click() {setViewMode('layered')}, condition: () => Format.single_texture},
|
||||
]
|
||||
|
@ -1316,7 +1316,7 @@ class Texture {
|
|||
new Property(Texture, 'string', 'namespace')
|
||||
new Property(Texture, 'string', 'id')
|
||||
new Property(Texture, 'boolean', 'particle')
|
||||
new Property(Texture, 'string', 'render_mode', {default: 'normal'})
|
||||
new Property(Texture, 'string', 'render_mode', {default: 'default'})
|
||||
|
||||
Object.defineProperty(Texture, 'all', {
|
||||
get() {
|
||||
|
|
|
@ -1179,9 +1179,7 @@ const UVEditor = {
|
|||
obj.faces[side].reset()
|
||||
})
|
||||
obj.preview_controller.updateFaces(obj);
|
||||
if (Project.view_mode === 'textured') {
|
||||
obj.preview_controller.updateUV(obj);
|
||||
}
|
||||
obj.preview_controller.updateUV(obj);
|
||||
})
|
||||
this.loadData()
|
||||
this.message('uv_editor.reset')
|
||||
|
|
|
@ -1165,6 +1165,7 @@
|
|||
"action.view_mode.textured": "Textured",
|
||||
"action.view_mode.solid": "Solid",
|
||||
"action.view_mode.wireframe": "Wireframe",
|
||||
"action.view_mode.uv": "UV Preview",
|
||||
"action.view_mode.normal": "Face Normal",
|
||||
"action.screenshot_model": "Screenshot Model",
|
||||
"action.screenshot_model.desc": "Take a cropped screenshot of the model from the current angle",
|
||||
|
@ -1408,7 +1409,7 @@
|
|||
"menu.texture.change": "Change File",
|
||||
"menu.texture.folder": "Open in Folder",
|
||||
"menu.texture.render_mode": "Render Mode",
|
||||
"menu.texture.render_mode.normal": "Normal",
|
||||
"menu.texture.render_mode.default": "Default",
|
||||
"menu.texture.render_mode.emissive": "Emissive",
|
||||
"menu.texture.render_mode.layered": "Layered",
|
||||
"menu.texture.merge_onto_texture": "Merge Onto Texture Above",
|
||||
|
|
Loading…
Reference in New Issue