Giter VIP home page Giter VIP logo

light2d's People

Contributors

miloyip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

light2d's Issues

Makefile无法正常工作

Manjaro上会报错:
[wurui@computer light2d]$ make
cc basic.c -o basic
/tmp/ccb1Fj9Q.o:在函数‘circleSDF’中:
basic.c:(.text+0x104e):对‘sqrtf’未定义的引用
/tmp/ccb1Fj9Q.o:在函数‘sample’中:
basic.c:(.text+0x1189):对‘sinf’未定义的引用
basic.c:(.text+0x119e):对‘cosf’未定义的引用
/tmp/ccb1Fj9Q.o:在函数‘main’中:
basic.c:(.text+0x1264):对‘fminf’未定义的引用
collect2: 错误:ld 返回 1
make: *** [<内置>:basic] 错误 1

必须要改成这样,才能正常工作:
TARGETS=basic csg
OUTPUTS=$(addsuffix .png, $(TARGETS))

all: $(TARGETS)
test: $(TARGETS) $(OUTPUTS)

%: %.c
gcc -lm -Wall -O3 -o $@ $&lt;

%.png: %
sh -c "time ./$<"

clean:
rm $(TARGETS) *.png

Lack of proper gamma compression for the output

There's a major but common mistake which makes all the images look wrong. The images are naturally calculated using linear light values but saved as 8-bit sRGB values without any correct conversion from linear values to sRGB (gamma compressed) values. Here's how it should look once that problem is fixed:
refraction size 512 N=4096 aa=0 4

This is quite radically different, and you can now see how the beams that cross into the shadows appear as bright as they should. The way to do it is to replace this:
p[0] = p[1] = p[2] = (int)(fminf(sample((float)x / W, (float)y / H) * 255.0f, 255.0f));
with this:
p[0] = p[1] = p[2] = (int)(255. * lsrgb(fminf(sample((float)x / W, (float)y / H), 1.f)));

and add somewhere a function lsrgb that does this:

double lsrgb(double linear)	// converts a [0.0, 1.0] linear value into a [0.0, 1.0] sRGB value
{
	if (linear <= 0.0031308)
		return linear * 12.92;
	else
		return 1.055 * pow(linear, 1.0/2.4) - 0.055;
}

Btw in the image above I also added Gaussian antialiasing which is achieved by adding a Gaussian jitter in the sample() function to x and y independently.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.