#add shine to sphere

69 messages · Page 1 of 1 (latest)

dawn fossilBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

cobalt aspen
#
#include "rtweekend.h"

#include "camera.h"
#include "color.h"
#include "hittable_list.h"
#include "material.h"
#include "sphere.h"

int main() {
    hittable_list world;

    auto material_ground = make_shared<lambertian>(color(0.8, 0.8, 0.0));// floor colour
    auto material_center = make_shared<lambertian>(color(1.0, 0.0, 0.0));//middle circle colour
    auto material_left = make_shared<metal>(color(0.0, 1.0, 0.0));//left circle colour
    auto material_right = make_shared<metal>(color(0.0, 0.0, 1.0));//right circle colour

    world.add(make_shared<sphere>(point3(0.0, -100.5, -1.0), 100.0, material_ground));
    world.add(make_shared<sphere>(point3(0.0, 0.0, -1.0), 0.5, material_center));
    world.add(make_shared<sphere>(point3(-1.0, 0.0, -1.0), 0.5, material_left));
    world.add(make_shared<sphere>(point3(1.0, 0.0, -1.0), 0.5, material_right));

    camera cam;

    cam.aspect_ratio = 16.0 / 9.0;
    cam.image_width = 400;
    cam.samples_per_pixel = 100;
    cam.max_depth = 50;


    cam.render(world);
}
#

main.cpp

eager knot
#

Learn about Phong shading.

cobalt aspen
#

is it hard?

eager knot
#

No.

cobalt aspen
#

ok. ill try.

#

but im kinda in a hurry. so i hope it doesnt take long

#

also im a beginner so im not sure if im able to implement the math properly

cobalt aspen
#

i still dont know how to do phong shading.

#

was doing something else. sorry

#

could you help with an example?

#

I just want to get this done quick. I’ll understand it later.

brave blaze
#

there's no point in doing this quick and trying to understand it later

#

you either understand it and do it, or you don't

#

i'm also not quite sure what exactly you're looking for

cobalt aspen
#

its getting pretty late and i want it to be done before i go

brave blaze
#

what kind of specular reflection exactly?

cobalt aspen
#

like reflecting light

brave blaze
#

um

cobalt aspen
#

ill show a picture

brave blaze
#

your spheres already look reflective

cobalt aspen
#

kinda like this

#

reflecting light

#

i want them to be shiny

brave blaze
#

isn't that gonna look weird to have a white spot on top of a real reflective surface there?

cobalt aspen
#

no

#

why would it look weird?

brave blaze
#

because it's not how things look in reality

cobalt aspen
#

im not trying to achieve realism right now.

brave blaze
#

well, I mean, the picture up there is almost certainly using phong shading

#

so you'd just implement that then

#

formula's on wikipedia 🤷‍♂️

cobalt aspen
brave blaze
#

yes

cobalt aspen
#

the first one is mine. it doesnt have phong shading i dont think.

brave blaze
#

it doesn't

brave blaze
# cobalt aspen kinda like this

what I'm saying is that if you want your spheres to look like this one, you need to implement phong shading. because that's how you get that result.

cobalt aspen
#

im not sure how to implement it though.

brave blaze
#

well, read up on how it works and then implement it, like you did with your spheres up there 🤷‍♂️

cobalt aspen
#

the thing is i wasnt trying to understand it. i was just copying and pasting

brave blaze
#

well, then you'll have to go and actually understand it first

cobalt aspen
#

do i have to?

brave blaze
#

I mean you don't have to I guess

cobalt aspen
#

could you help me out so it can go quicker?

brave blaze
#

but if you want to implement this thing you want to implement, understanding what you're doing will be necessary

cobalt aspen
#

yeah i know. ill have to understand this if i want to build my own. but thats not what i want to do right now.

brave blaze
#

well, the fact that you want smth isn't gonna change anything about the fact that you still need to go and do it

cobalt aspen
#

fine ill read about it but i dont think im gonna understand it.

brave blaze
#

that probably means you'll have to go further back and catch up with yet more basics that you likely skipped along the way as well

cobalt aspen
#

thats why im asking.

#

but this isnt too important for me right now

brave blaze
#

I cannot just snip my fingers and make you understand stuff. you can only do that yourself, through study and practice.

cobalt aspen
#

im not trying to understand it though.

brave blaze
#

without understanding it, you won't be able to do it though.

cobalt aspen
#

thats what i did for my old code.

brave blaze
#

well, and now you see how far that got you. this is the point where skipping on actually understanding what you're doing has caught up with you, and where you'll just have to go and actually work on understanding what you're doing.

#

not sure what else you want me to tell you

cobalt aspen
#

can you just type it for me so i can go to sleep?

brave blaze
#

no

cobalt aspen
#

ffine ill read.

brave blaze
#

that would be a waste of both our time

cobalt aspen
#

wouldnt even take that long for you.

brave blaze
#

it likely wouldn't. it would still be a waste of time since you're not even trying to actually understand what's going on. what would be the point?

cobalt aspen
#

ill understand it later when i have the time

#

also i havnt learned nothing while building this project

#

thank you for trying to help anyway

dawn fossilBOT
#

@cobalt aspen Has your question been resolved? If so, type !solved :)