ID:1055984
 
(See the best response by NNAAAAHH.)
So I've been trying to get his library to play nice with 64x64 pixels and I can't figure it out. I've changed many parts of the code, generated the correct light icon, etc. The problem that happens is that you need twice as much as 8 states (16 states) to get it to look right but any more states than 8 in the icon generation causes the sides to be flipped improperly. This could also be occurring in the section where the lum number is calculated. I'm not sure which it is, and it is beyond me to know what to do further. I was hoping someone here could help me figure out if the light icon generation is broken, or if the calculations need to be modified in the LUM part.
Best response
Since this isn't a general issue with BYOND, have you tried posting on the library's page? I'm sure F_A could tell you what to do in his library than we can.
In response to NNAAAAHH
NNAAAAHH wrote:
Since this isn't a general issue with BYOND, have you tried posting on the library's page? I'm sure F_A could tell you what to do in his library than we can.

He's been missing from byond ever since his 3d idea was ignored by the staff. There's been several of us telling him what bugs to fix in the library and he has yet to reply.
In response to FIREking
I hadn't really noticed, I might download the library later and try to help you out.
Just wondering if you ever got around to looking into this, I am totally baffled.
In response to FIREking
I'm sorry, it slipped my mind. Been keeping busy lately. I'll download the library now and take a quick look, but I'm tired so I can't promise a response today.
I've checked all of the demos and used 64x64 icons, nothing really wrong with what was there, might you post your implamentation or provide more details on what exactly it is that's wrong?
In response to NNAAAAHH
NNAAAAHH wrote:
I've checked all of the demos and used 64x64 icons, nothing really wrong with what was there, might you post your implamentation or provide more details on what exactly it is that's wrong?

Ok do a 64x64 setup, but with 16 states. Let me know if it works.
In response to FIREking
With the icon generator and run one of the demos with said egnerated icon, right? Seemed to run fine to me. Are you sure the world.icon_size is set to 64x64? I will check how it appears if I set it to 32x32.

[EDIT] They all work fien except the customization demo. But it wasn't like what you described, in a 32x32 enviroment with 64x64 16-state lighting, it works but looks alittle blocky, again not what like you descibed. [END EDIT]
In response to NNAAAAHH
NNAAAAHH wrote:
With the icon generator and run one of the demos with said egnerated icon, right? Seemed to run fine to me. Are you sure the world.icon_size is set to 64x64? I will check how it appears if I set it to 32x32.

[EDIT] They all work fien except the customization demo. But it wasn't like what you described, in a 32x32 enviroment with 64x64 16-state lighting, it works but looks alittle blocky, again not what like you descibed. [END EDIT]

can you send me the light file it created for you?
In response to FIREking
That's not 16 state generated at 64. You have to change the number of states in the generator. Then you have to change the number of states in the light library. Also the light library is hardcoded to be 32x32. The results won't be any different if you just "scale up" the generation.
// File:    icon-generator.dm
// Library: Forum_account.DynamicLighting
// Author: Forum_account
//
// Contents:
// This file contains the code used to generate the icon file
// used to show darkness. You can use the sample icon file that
// comes with the library or generate your own. To generate
// your own:
//
// 1. Include this file in the project (click the check box
// next to this file on the left side of the DM window).
// 2. Change the lighting options (the global vars defined in
// this file).
// 3. Compile and run the project.
// 4. Use the "Generate Icon" verb.
// 5. Save the resulting .dmi file in your project and update
// your code to reference it.

var
icon_width = 64
icon_height = 64

// darkest and lightest are alpha values, a lower alpha value
// means a more transparent icon which means the underlying icon
// will appear brighter.
darkest = 255
lightest = 0

// the number of illumination values to use, the number of icon
// states in the icon file depends on this value:
//
// states = 3: 81 icon states
// states = 4: 256 icon states
// states = 5: 625 icon states
// states = 6: 1296 icon states
//
// having more states will make it look nicer, but can result in
// huge icon files.
states = 16

// you can change these vars to tint the shadows, by default
// they're black but you might want them to be other colors
red = 0
green = 0
blue = 0

proc
generate_icon()

var/icon/master = new()

var/total = states * states * states
var/count = 0

for(var/a = 1 to states)
for(var/b = 1 to states)
for(var/c = 1 to states)
for(var/d = 1 to states)
var/icon/I = generate_state(a, b, c, d)

master.Insert(I, "[a-1][b-1][c-1][d-1]")

count += 1
var/pct = round(100 * count / total)
world << "[pct]%"

sleep(world.tick_lag)

world << ftp(master, "lighting.dmi")

generate_state(a, b, c, d)

var/icon/I = icon('dynamic-lighting-library.dmi', "blank")
I.Scale(icon_width, icon_height)

var/a_val = value(a)
var/b_val = value(b)
var/c_val = value(c)
var/d_val = value(d)

for(var/x = 1 to icon_width)
for(var/y = 1 to icon_height)

// c -- b
// | |
// b -- a

var/i = (x - 1) / (icon_width - 1)
var/j = (y - 1) / (icon_height - 1)

var/a_wgt = ( i) * (1 - j)
var/b_wgt = (1 - i) * (1 - j)
var/c_wgt = (1 - i) * ( j)
var/d_wgt = ( i) * ( j)

var/alpha = round(a_val * a_wgt + b_val * b_wgt + c_val * c_wgt + d_val * d_wgt)

I.DrawBox(rgb(red, green, blue, alpha), x, y)

return I

value(state)
return darkest - (darkest - lightest) * ((state - 1) / (states - 1))

mob
verb
Generate_Icon()
generate_icon()


That's the icon generation code, altered for when I made the icon.
Weird, so I deleted the library and downloaded fresh and it started to work. Seems I had modified something that was causing it to draw in such an awkward way. Now I need to see if I can generate my own icon. I just tried a moment ago and it never asked me to save the file when it reached 100%.

Thanks for the help, none the less.
Cloud Magic wrote:
Yeah, is there a way to have the lighting system, well, lighter? It's just so dark right now with the way I'm using it, that I definitely won't be able to use it for the entire game without the players getting incredibly sick of it ...

Just generate a new icon with the darkest setting lower.
In response to NNAAAAHH
NNAAAAHH wrote:

So yeah, I literally can't get any of my computers to generate an icon from this code. All I changed was the darkness value to 100. Problem I'm having is the generation just stops at 100% and never shows me a dialog of where to save the file. The CPU usage goes down to 0 (memory usage 982 MB). Then it just sits there, does nothing.

Perhaps you could make one with the darkest being 100 instead of 255 for me?
Ok so I couldn't generate another icon, but I was able to take the file you sent and modify it using the built in icon procedures and then save those to new files to get the desired effect I was after. Thanks again for making this!