Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grafhf2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tóth Miklós Tibor
grafhf2
Commits
408bdda9
Verified
Commit
408bdda9
authored
Apr 16, 2021
by
Tóth Miklós Tibor
Browse files
Options
Downloads
Patches
Plain Diff
forgatok is lol
parent
bfb61f8e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Skeleton.cpp
+16
-2
16 additions, 2 deletions
Skeleton.cpp
with
16 additions
and
2 deletions
Skeleton.cpp
+
16
−
2
View file @
408bdda9
...
...
@@ -110,12 +110,17 @@ struct ReflectiveMaterial: Material {
struct
PortalMaterial
:
Material
{
void
trace
(
const
Scene
&
scene
,
const
Hit
&
hit
,
const
Ray
&
ray
,
const
std
::
vector
<
Light
*>&
lights
,
int
depth
,
vec3
&
outRadiance
)
override
;
inline
static
vec3
rodrigues
(
const
vec3
&
v
,
const
vec3
&
normal
,
const
float
&
theta
){
return
v
*
cos
(
theta
)
+
cross
(
normal
,
v
)
*
sin
(
theta
)
+
normal
*
dot
(
normal
,
v
)
*
(
1
-
cos
(
theta
));
}
};
struct
Hit
{
float
t
=
-
1
;
vec3
position
,
normal
;
Material
*
material
=
nullptr
;
vec3
origo
;
};
struct
Ray
{
...
...
@@ -260,6 +265,7 @@ struct Pentagon : public Intersectable {
hit
.
normal
=
n
;
hit
.
material
=
material
;
hit
.
position
=
p
;
hit
.
origo
=
(
r1
+
r2
+
r3
+
r4
+
r5
)
/
5.0
;
if
(
distance
(
r1
,
r2
,
p
)
>
0.1
&&
...
...
@@ -345,7 +351,6 @@ public:
vec3
kappa
(
3.1
,
2.7
,
1.9
);
Material
*
gold
=
new
ReflectiveMaterial
(
n
,
kappa
);
objects
.
push_back
(
new
Chips
(
gold
));
//objects.push_back(new Pentagon(vec3(0.03, -.01, 0), vec3(0, .37, 0), vec3(-.47, .49, 0), vec3(-.73, .08, 0), vec3(-.414, -0.288, 0), dodekaMat));
vec3
kd
(
0.3f
,
0.3f
,
.3f
),
ks
(
2
,
2
,
2
);
Material
*
dodekaMat
=
new
RoughMaterial
(
kd
,
ks
,
50
);
...
...
@@ -440,7 +445,16 @@ void PortalMaterial::trace(const Scene& scene, const Hit& hit, const Ray& ray, c
vec3
reflectedDir
=
ray
.
dir
-
hit
.
normal
*
dot
(
hit
.
normal
,
ray
.
dir
)
*
2.0f
;
auto
theta
=
(
2.0
*
M_PI
)
*
(
72.0
/
360.0
);
outRadiance
=
outRadiance
+
scene
.
trace
(
Ray
(
hit
.
position
+
hit
.
normal
*
epsilon
,
reflectedDir
),
depth
+
1
);
reflectedDir
=
PortalMaterial
::
rodrigues
(
reflectedDir
,
hit
.
normal
,
theta
);
const
vec3
&
mid
=
hit
.
origo
;
vec3
pos
=
hit
.
position
-
mid
;
pos
=
PortalMaterial
::
rodrigues
(
pos
,
hit
.
normal
,
theta
);
pos
=
pos
+
mid
;
outRadiance
=
outRadiance
+
scene
.
trace
(
Ray
(
pos
+
hit
.
normal
*
epsilon
,
reflectedDir
),
depth
+
1
);
}
GPUProgram
gpuProgram
;
// vertex and fragment shaders
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment