allow textured icons to use vertex colours
caveat: some icons aren't meant to do this and will be over-saturated. Some icons are meant to over-saturate, but I don't mind that as much as the one's that aren't. The criteria that allows this is unknown to me.
This commit is contained in:
parent
f22a8118a0
commit
d5ec733b07
2
icon.js
2
icon.js
|
@ -1,7 +1,7 @@
|
||||||
//todo: Make this a module/mjs file. C6 compatibility can stay, if needed.
|
//todo: Make this a module/mjs file. C6 compatibility can stay, if needed.
|
||||||
ICONJS_DEBUG = false;
|
ICONJS_DEBUG = false;
|
||||||
ICONJS_STRICT = true;
|
ICONJS_STRICT = true;
|
||||||
ICONJS_VERSION = "0.4.1";
|
ICONJS_VERSION = "0.4.2";
|
||||||
|
|
||||||
function setDebug(value) {
|
function setDebug(value) {
|
||||||
ICONJS_DEBUG = !!value;
|
ICONJS_DEBUG = !!value;
|
||||||
|
|
47
input.htm
47
input.htm
|
@ -44,7 +44,7 @@
|
||||||
(a_position.x * pos.x) + (a_position.z * pos.y), //transform the x position
|
(a_position.x * pos.x) + (a_position.z * pos.y), //transform the x position
|
||||||
(0.0 - a_position.y) - 2.75, // invert the y position and move down -2.75, which will center the model
|
(0.0 - a_position.y) - 2.75, // invert the y position and move down -2.75, which will center the model
|
||||||
(a_position.x * -pos.y) + (a_position.z * pos.x), //transform the z position
|
(a_position.x * -pos.y) + (a_position.z * pos.x), //transform the z position
|
||||||
3.0
|
3.5
|
||||||
);
|
);
|
||||||
// flip it, scale it
|
// flip it, scale it
|
||||||
v_textureCoords = a_textureCoords;
|
v_textureCoords = a_textureCoords;
|
||||||
|
@ -63,14 +63,21 @@
|
||||||
</script>
|
</script>
|
||||||
<script type="text/plain" id="shader-icon-f2">
|
<script type="text/plain" id="shader-icon-f2">
|
||||||
varying lowp vec2 v_textureCoords;
|
varying lowp vec2 v_textureCoords;
|
||||||
|
varying lowp vec4 v_color;
|
||||||
|
|
||||||
uniform sampler2D u_sampler;
|
uniform sampler2D u_sampler;
|
||||||
uniform highp vec3 u_ambientLight;
|
uniform highp vec3 u_ambientLight;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
mediump vec4 texture = texture2D(u_sampler, v_textureCoords);
|
mediump vec4 texture_c = texture2D(u_sampler, v_textureCoords);
|
||||||
highp vec3 ambientColor = (u_ambientLight * vec3(texture));
|
highp vec3 ambientColorT = (u_ambientLight * vec3(texture_c));
|
||||||
gl_FragColor = vec4(ambientColor, texture.a);
|
highp vec3 ambientColorV = (u_ambientLight * vec3(v_color));
|
||||||
|
//This has issues with oversaturation, but it means blended icons work.
|
||||||
|
if(v_color == vec4(1.0,1.0,1.0,1.0)) {
|
||||||
|
gl_FragColor = vec4((ambientColorT * ambientColorV), texture_c.a);
|
||||||
|
} else {
|
||||||
|
gl_FragColor = vec4((ambientColorT * ambientColorV) * 2.0, texture_c.a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<meta data-comment="WebGL Shader: Background">
|
<meta data-comment="WebGL Shader: Background">
|
||||||
|
@ -106,11 +113,11 @@
|
||||||
<h1 id="title1">No File</h1>
|
<h1 id="title1">No File</h1>
|
||||||
<h1 id="title2">Loaded</h1>
|
<h1 id="title2">Loaded</h1>
|
||||||
</div>
|
</div>
|
||||||
<span>Background/icon preview:</span><br>
|
<span>Background/icon preview (rotate: ←/→ keys):</span><br>
|
||||||
<canvas id="bgcanvas" width="360" height="360"></canvas>
|
<canvas id="bgcanvas" width="360" height="360"></canvas>
|
||||||
<canvas id="iconcanvas" width="360" height="360"></canvas>
|
<canvas id="iconcanvas" width="360" height="360"></canvas>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Normal: <kbd id="iconn">(no file)</kbd> Copying: <kbd id="iconc">(no file)</kbd> Deleting: <kbd id="icond">(no file)</kbd></p>
|
<p>Normal: <kbd id="iconn">(no file)<wbr></kbd> Copying: <kbd id="iconc">(no file)<wbr></kbd> Deleting: <kbd id="icond">(no file)</kbd></p>
|
||||||
<div id="advanced">
|
<div id="advanced">
|
||||||
<hr>
|
<hr>
|
||||||
<label for="input">icon.sys goes here:</label>
|
<label for="input">icon.sys goes here:</label>
|
||||||
|
@ -131,9 +138,9 @@
|
||||||
<input type="file" id="spsinput" name="spsinput" accept=".sps, .xps" />
|
<input type="file" id="spsinput" name="spsinput" accept=".sps, .xps" />
|
||||||
<br>
|
<br>
|
||||||
<p>
|
<p>
|
||||||
<span>Date created: </span><span id="dateCreated">--:--:-- --/--/----</span><span> UTC+09:00</span>
|
<span>Date created: </span><span id="dateCreated">--:--:-- --/--/----</span><span> UTC+09:00</span>
|
||||||
<span> | </span>
|
<wbr><span>–</span>
|
||||||
<span>Date modified: </span><span id="dateModified">--:--:-- --/--/----</span><span> UTC+09:00</span>
|
<span>Date modified: </span><span id="dateModified">--:--:-- --/--/----</span><span> UTC+09:00</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span>File comments: </span><span id="fileCommentGame">(no title)</span></span><span> - </span><span id="fileCommentName">(no description)</span>
|
<span>File comments: </span><span id="fileCommentGame">(no title)</span></span><span> - </span><span id="fileCommentName">(no description)</span>
|
||||||
|
@ -202,7 +209,6 @@
|
||||||
document.getElementById("fileCommentName").textContent = "(no description)";
|
document.getElementById("fileCommentName").textContent = "(no description)";
|
||||||
}
|
}
|
||||||
function renderIcon(iconData, fileMetadata = null) {
|
function renderIcon(iconData, fileMetadata = null) {
|
||||||
console.log("rats", fileMetadata);
|
|
||||||
if(fileMetadata === null) {
|
if(fileMetadata === null) {
|
||||||
fileMetadata = {
|
fileMetadata = {
|
||||||
"lighting": {
|
"lighting": {
|
||||||
|
@ -243,7 +249,8 @@
|
||||||
if(iconData.textureFormat !== "N") {
|
if(iconData.textureFormat !== "N") {
|
||||||
var attributes = {
|
var attributes = {
|
||||||
position: glFgContext.getAttribLocation(iconProgram, "a_position"),
|
position: glFgContext.getAttribLocation(iconProgram, "a_position"),
|
||||||
textureCoords: glFgContext.getAttribLocation(iconProgram, "a_textureCoords")
|
textureCoords: glFgContext.getAttribLocation(iconProgram, "a_textureCoords"),
|
||||||
|
color: glFgContext.getAttribLocation(iconProgram, "a_color"),
|
||||||
};
|
};
|
||||||
var uniforms = {
|
var uniforms = {
|
||||||
rotation: glFgContext.getUniformLocation(iconProgram, "u_rotation"),
|
rotation: glFgContext.getUniformLocation(iconProgram, "u_rotation"),
|
||||||
|
@ -281,14 +288,13 @@
|
||||||
glFgContext.enableVertexAttribArray(attributes.position);
|
glFgContext.enableVertexAttribArray(attributes.position);
|
||||||
glFgContext.bufferData(glFgContext.ARRAY_BUFFER, new Float32Array(verticesArray), glFgContext.STATIC_DRAW);
|
glFgContext.bufferData(glFgContext.ARRAY_BUFFER, new Float32Array(verticesArray), glFgContext.STATIC_DRAW);
|
||||||
glFgContext.vertexAttribPointer(attributes.position, 3, glFgContext.FLOAT, false, 0, 0);
|
glFgContext.vertexAttribPointer(attributes.position, 3, glFgContext.FLOAT, false, 0, 0);
|
||||||
if(iconData.textureFormat === "N") {
|
//.section COLOURS
|
||||||
//.section COLOURS
|
const colorBuffer = glFgContext.createBuffer();
|
||||||
const colorBuffer = glFgContext.createBuffer();
|
glFgContext.bindBuffer(glFgContext.ARRAY_BUFFER, colorBuffer);
|
||||||
glFgContext.bindBuffer(glFgContext.ARRAY_BUFFER, colorBuffer);
|
glFgContext.enableVertexAttribArray(attributes.color);
|
||||||
glFgContext.enableVertexAttribArray(attributes.color);
|
glFgContext.bufferData(glFgContext.ARRAY_BUFFER, new Float32Array(colourArray), glFgContext.STATIC_DRAW);
|
||||||
glFgContext.bufferData(glFgContext.ARRAY_BUFFER, new Float32Array(colourArray), glFgContext.STATIC_DRAW);
|
glFgContext.vertexAttribPointer(attributes.color, 4, glFgContext.FLOAT, false, 0, 0);
|
||||||
glFgContext.vertexAttribPointer(attributes.color, 4, glFgContext.FLOAT, false, 0, 0);
|
if(iconData.textureFormat !== "N") {
|
||||||
} else {
|
|
||||||
//.section UV
|
//.section UV
|
||||||
const uvBuffer = glFgContext.createBuffer();
|
const uvBuffer = glFgContext.createBuffer();
|
||||||
glFgContext.bindBuffer(glFgContext.ARRAY_BUFFER, uvBuffer);
|
glFgContext.bindBuffer(glFgContext.ARRAY_BUFFER, uvBuffer);
|
||||||
|
@ -400,6 +406,7 @@
|
||||||
let output = readPS2D(inputData["icon.sys"]);
|
let output = readPS2D(inputData["icon.sys"]);
|
||||||
updateDisplay(output);
|
updateDisplay(output);
|
||||||
renderIcon(readIconFile(inputData.icons.n), output);
|
renderIcon(readIconFile(inputData.icons.n), output);
|
||||||
|
console.log(readIconFile(inputData.icons.n));
|
||||||
let cTime = inputData.timestamps.created;
|
let cTime = inputData.timestamps.created;
|
||||||
let mTime = inputData.timestamps.modified;
|
let mTime = inputData.timestamps.modified;
|
||||||
//TODO: use Time() to align JST times to user-local timezone
|
//TODO: use Time() to align JST times to user-local timezone
|
||||||
|
@ -520,6 +527,6 @@
|
||||||
</script>
|
</script>
|
||||||
<span id="version">icondumper2 <span id="iconjsVersion">(unknown icon.js version)</span> [C: <span id="clientVersion">Loading...</span>] — © 2023 yellows111</span>
|
<span id="version">icondumper2 <span id="iconjsVersion">(unknown icon.js version)</span> [C: <span id="clientVersion">Loading...</span>] — © 2023 yellows111</span>
|
||||||
<script>document.getElementById("iconjsVersion").textContent = ICONJS_VERSION;</script>
|
<script>document.getElementById("iconjsVersion").textContent = ICONJS_VERSION;</script>
|
||||||
<script>document.getElementById("clientVersion").textContent = "0.6.1";</script>
|
<script>document.getElementById("clientVersion").textContent = "0.6.2";</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue