Generate 12-bit color map - help
Page 1 of 1
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Wed, 27th Dec 2017 02:26    Post subject: Generate 12-bit color map - help
Hey guys. It's been a while since I programmed anything in any language. I'm currently looking at getting back into 68K-assembly on Classic Amiga. One thing I need is a tool to generate the following:

A generated data-file with color-values in HEX within a defined X-Y boundary using interpolation to create soft gradients with no dithering.

example:
0111 0222 0333 0444 0555 0666 etc. (a 16-bit word)
(a simple gray-scale). It's 4 bits per channel (R,G,B, the first zero isn't used), ie. nibbles, amounting to 4096 possible colors.

The more difficult part (at least in my case since I've never written an interpolation algorithm) is that I want to be able to put several color points within the X-Y space (beyond the four corner values) that will be used by the interpolation algorithm to create a gradient map.

Any ideas or solutions?


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
paxsali
Banned



Posts: 18352

PostPosted: Wed, 27th Dec 2017 03:37    Post subject:
⁢⁢


Last edited by paxsali on Thu, 4th Jul 2024 23:30; edited 2 times in total
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 27th Dec 2017 04:21    Post subject:
4 point quads or polygons with more points frant?


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Wed, 27th Dec 2017 06:32    Post subject:
paxsali wrote:
I don't understand your task. And neither do you, judging by your ability to convey it...


Pumpy did. Does that say anything about myself or Pumpy? Cool


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais


Last edited by Frant on Wed, 27th Dec 2017 06:48; edited 1 time in total
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Wed, 27th Dec 2017 06:47    Post subject:
PumpAction wrote:
4 point quads or polygons with more points frant?


4 point quads should be enough. I plan on overlapping and manipulating different color maps while also moving/copying color and graphical data (basically masking out colors with negative values and other experiments). I have an idea about a "bubbling" copper-background with 2D- and 3D-elements "shading" the resulting color map. That leaves me 4 bitplanes to mess with graphics on top of that.

The viewscreen will either be 40*256 "copper-pixels" or 80*256 (if I use BPL1 as a 4-pixel layer to increase horizontal resolution beyond the copper-timings).

Example:

Left top corner of the color map set to 0800 (mid-red)
Left bottom corner 0008 (mid blue)
Right top corner 0088 (mid-yellow)
Right bottom corner 0088 (mid-cyan)

Then four point values at X,Y in that defined map that will be used to interpolate gradients between the corners as well as the points to create different color maps that I can then do work on (ie. using one color map to subtract from the second and then blend it with graphical objects that I'll convert to color data and create the final color map).

I suspect there will be some nested loops with fairly advanced math (which is where I fail Sad ).


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Wed, 27th Dec 2017 06:52    Post subject:
If anybody want an example on what you can do with the copper (co-processor) to manipulate color without using drawn graphics that you manipulate:



Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 27th Dec 2017 12:44    Post subject:
But in this example the gradients are pretty easy to calculate, as you only have two colors.

Do you aim for something like this

or this:


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Stige




Posts: 3542
Location: Finland
PostPosted: Wed, 27th Dec 2017 14:04    Post subject:
paxsali wrote:
I don't understand your task. And neither do you, judging by your ability to convey it...


Back to top
Nalo
nothing



Posts: 13437

PostPosted: Wed, 27th Dec 2017 15:30    Post subject:
⁢⁢


Last edited by Nalo on Wed, 3rd Jul 2024 05:57; edited 2 times in total
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 27th Dec 2017 15:35    Post subject:
Can you take a look if this helps you?

Enter the colors into C1, C2, C3, C4 in any format accepted by CSS ("#f00", "#ff0000", "rgb(255,0,0)", "red", ...) and adjust the width and height in W and H.

Your result is in the textarea between the controls and canvas.

https://codepen.io/ftavukcu/pen/MrJROd



If you don't know/remember how to get the right color for the pixel you are looking for take this function (translate it to the language you use)

Code:

function getColor(imageData, x, y, imageWidth){
return imageData[x+y*imageWidth];
}

var imageMap = "0123 0234 ...";
var imageWidth = 80;

var imageData = imageMap.split(" "); //transform to array

var myColor = getColor(imageData, 0, 0, imageWidth);


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
paxsali
Banned



Posts: 18352

PostPosted: Wed, 27th Dec 2017 16:40    Post subject:
⁢⁢


Last edited by paxsali on Thu, 4th Jul 2024 23:30; edited 2 times in total
Back to top
Nalo
nothing



Posts: 13437

PostPosted: Wed, 27th Dec 2017 17:26    Post subject:
⁢⁢


Last edited by Nalo on Wed, 3rd Jul 2024 05:57; edited 2 times in total
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Fri, 29th Dec 2017 03:28    Post subject:
PumpAction wrote:
But in this example the gradients are pretty easy to calculate, as you only have two colors.

Do you aim for something like this

or this:


Def. the first 2D-map (no polygon).


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Fri, 29th Dec 2017 03:34    Post subject:
PumpAction wrote:
Can you take a look if this helps you?

Enter the colors into C1, C2, C3, C4 in any format accepted by CSS ("#f00", "#ff0000", "rgb(255,0,0)", "red", ...) and adjust the width and height in W and H.

Your result is in the textarea between the controls and canvas.

https://codepen.io/ftavukcu/pen/MrJROd



If you don't know/remember how to get the right color for the pixel you are looking for take this function (translate it to the language you use)

Code:

function getColor(imageData, x, y, imageWidth){
return imageData[x+y*imageWidth];
}

var imageMap = "0123 0234 ...";
var imageWidth = 80;

var imageData = imageMap.split(" "); //transform to array

var myColor = getColor(imageData, 0, 0, imageWidth);


That's IT! The only extra thing I'd like is the ability to add a few extra color points inside the color map rectangle used with the original 4 corner points during interpolation (although it's not super-necessary, I can "cheat" by doing small color maps that I stitch together or make huge maps that I then "resize" to get gradients I can manipulate in assembly).


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Fri, 29th Dec 2017 04:10    Post subject:
paxsali wrote:
Hello I'd like to have a data-file that was generated, it cannot be just provided it must have been generated, and it must be in a NTFS filesystem format as well as in binary form.

The bytes in this data-file should be stored as hexadecimal values and in big-endian format.

I would also like to store values in color within some γ-φ range using interpolation, but I don't wanna interpolate it in software, it needs to be interpolated in the binary file using interpolation or the hexadecimal values of the respective colors.

example:
color1 color2 color3 color4 color5 color6 etc... (in binary data of file)

Can help? Thx!

Oh hello Freakness, long time no see. Laughing





Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Frant
King's Bounty



Posts: 24433
Location: Your Mom
PostPosted: Wed, 28th Sep 2022 21:59    Post subject:
Frant wrote:
PumpAction wrote:
Can you take a look if this helps you?

Enter the colors into C1, C2, C3, C4 in any format accepted by CSS ("#f00", "#ff0000", "rgb(255,0,0)", "red", ...) and adjust the width and height in W and H.

Your result is in the textarea between the controls and canvas.

https://codepen.io/ftavukcu/pen/MrJROd

..example image..

If you don't know/remember how to get the right color for the pixel you are looking for take this function (translate it to the language you use)

Code:

function getColor(imageData, x, y, imageWidth){
return imageData[x+y*imageWidth];
}

var imageMap = "0123 0234 ...";
var imageWidth = 80;

var imageData = imageMap.split(" "); //transform to array

var myColor = getColor(imageData, 0, 0, imageWidth);


That's IT! The only extra thing I'd like is the ability to add a few extra color points inside the color map rectangle used with the original 4 corner points during interpolation (although it's not super-necessary, I can "cheat" by doing small color maps that I stitch together or make huge maps that I then "resize" to get gradients I can manipulate in assembly).


OR (and why didn't I think about this until now???) I simply compile the C routine on the Amiga and run it at the init-phase of my app/demo and then use the result for my main code...

Thanks again Pumpy.


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"Thank you to God for making me an Atheist" - Ricky Gervais
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group