Official Scratchapixel website's code repo.
scratchapixel-code's Introduction
scratchapixel-code's People
Forkers
icodein vibeymcviberson kjunsong stevehan00 aviralgoel supritsinghlab axactt okaycarter amlli cyskwa raj1179 truejasonfans 0x4d3342 ridiculoshypocrisy hirotong mee-gu ofiongston weiminghan0721 natoutourien csuyanchong patblr raydelto game-challenge ld-laowu andrew108-coder snowwindtdz surya-1729 abhisek-pat ecnu-metaverse-ops l2ggy maxim863 blurrylight leandrodaher raven-pro rintarooo neoql macsummer hamu77 museummage xunshengliuyin infancy grouchochaplin yoreei hologerry youyimou jaypowers chenloki cmpawloumd zk8085454 pedrohasselmann kristopolous timscodebase chuckn408 graphicsenthusiast zhihuihan0211 eliezergensburger aritilescratchapixel-code's Issues
My ppm file is corrupted.
Why my image looks like that? By the way, this is not the first time I encountered situation like that.
I printed out the result (before saving) which is correct.
The above file (I only print first 10 rgb values) indicates that from line 311 to line 341 is constantly with color 59, -84, -42 however in the first screenshot we can see something else in this range.
I also did another expriments: read the ppm file and print them on the console.
I think the codes crashed halfway. Down below, 971547 is the counter of CHARs. I did the math (also we can see from the pic) 971547 is at H:316, W795. If finish well, the counter should be 1024 x 747 x 3 = 2294784.
I will also upload the codes.
// stdafx.cpp : source file that includes just the standard includes
// CPPTEST2.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <string>
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
int main123()
{
std::ifstream infile("out_phong.ppm");
if (!infile.is_open()) {
std::cerr << "ERR\n";
return 1;
}
std::string line;
while (std::getline(infile, line)) {
int char_num = 0;
for (char c : line) {
//if (char_num % (1024 * 3) == 0)
//{
// std::cout << std::endl << (char_num/3072) << std::endl;
//}
if (char_num > 970752)
{
std::cout << (int)c << ' ';
}
else
{
if (char_num % 3072 == 0)
{
std::cout << char_num / 3072 << std::endl;
}
if (char_num % (3072) < 30)
{
std::cout << (int)c << ' ';
//std::cout << std::endl;
}
if (char_num % (3072) == 31)
{
std::cout << std::endl;
}
}
//std::cout << c;
char_num++;
}
std::cout << std::endl << (char_num) << std::endl;
std::cout << std::endl;
}
infile.close();
printf("sdadasds\n");
return 0;
}
interpolation.cpp crashes
There seems to be a number of interesting issues here:
https://github.com/scratchapixel/scratchapixel-code/blob/main/interpolation/interpolation.cpp#L183 which as of this writing is:
#define IX(size, i, j, k) ( i * j * k * size + i * j * size + i )
You're going to overflow your structure with this. Since i,j,k
max is size
, then the loop will stop at size^4 + size^2 + size
in indexing size^3
. You probably want something like this instead:
#define IX1(size, i, j, k) ( k * size * size + j * size + i )
Beyond that, there appears to be a double free error in the trilinear interpolation. This can be fixed as follows:
for (int k = 0; k < numVertices; ++k) {
for (int j = 0; j < numVertices; ++j) {
for (int i = 0; i < numVertices; ++i) {
Finally, the e, f, g
triplet that's computed doesn't go anywhere (here: https://github.com/scratchapixel/scratchapixel-code/blob/main/interpolation/interpolation.cpp#L229), maybe you intended to write it to a file? I understand there's no simple 3D ppm format (which is kind of a crazy oversight) so perhaps just doing the slices. Is the right way. I have that in a PR I'm going to be opening shortly after this comment
Also the code https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/interpolation/bilinear-filtering.html has a syntactic error:
#if 1
float a = c00 * (1 - tx) + c10 * tx;
float b = c01 * (1 - tx) + c11 * tx;
return a * (1) - ty) + b * ty;
#else
That block won't compile. There's a parenthesis missing.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.