Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
c109a6e5
Commit
c109a6e5
authored
Aug 31, 2017
by
Rémi Verschelde
Committed by
GitHub
Aug 31, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10401 from maxim-sheronov/fix_particles_spritesheet
Fix UV calculation for spritesheet in particles
parents
82208c1e
e41656c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
material.cpp
scene/resources/material.cpp
+6
-6
material.h
scene/resources/material.h
+2
-2
No files found.
scene/resources/material.cpp
View file @
c109a6e5
...
...
@@ -227,8 +227,8 @@ void SpatialMaterial::init_shaders() {
shader_names
->
uv1_blend_sharpness
=
"uv1_blend_sharpness"
;
shader_names
->
uv2_blend_sharpness
=
"uv2_blend_sharpness"
;
shader_names
->
particle
_h_frames
=
"particle
_h_frames"
;
shader_names
->
particle
_v_frames
=
"particle
_v_frames"
;
shader_names
->
particle
s_anim_h_frames
=
"particles_anim
_h_frames"
;
shader_names
->
particle
s_anim_v_frames
=
"particles_anim
_v_frames"
;
shader_names
->
particles_anim_loop
=
"particles_anim_loop"
;
shader_names
->
depth_min_layers
=
"depth_min_layers"
;
shader_names
->
depth_max_layers
=
"depth_max_layers"
;
...
...
@@ -503,8 +503,8 @@ void SpatialMaterial::_update_shader() {
code
+=
"
\t
int particle_total_frames = particles_anim_h_frames * particles_anim_v_frames;
\n
"
;
code
+=
"
\t
int particle_frame = int(INSTANCE_CUSTOM.y * float(particle_total_frames));
\n
"
;
code
+=
"
\t
if (particles_anim_loop) particle_frame=clamp(particle_frame,0,particle_total_frames-1); else particle_frame=abs(particle_frame)%particle_total_frames;
\n
"
;
//
code += "\tUV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));\n";
//code += "\tUV+= UV * vec2(float(particle_frame % particles_anim_h_frames),float(particle_frame /
particles_anim_v_frames));\n";
code
+=
"
\t
UV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));
\n
"
;
code
+=
"
\t
UV += vec2(float(particle_frame % particles_anim_h_frames) / float(particles_anim_h_frames),float(particle_frame / particles_anim_h_frames) / float(
particles_anim_v_frames));
\n
"
;
//handle rotation
// code += "\tmat4 rotation = mat4("
}
break
;
...
...
@@ -1281,7 +1281,7 @@ SpatialMaterial::BillboardMode SpatialMaterial::get_billboard_mode() const {
void
SpatialMaterial
::
set_particles_anim_h_frames
(
int
p_frames
)
{
particles_anim_h_frames
=
p_frames
;
VS
::
get_singleton
()
->
material_set_param
(
_get_material
(),
shader_names
->
particle_h_frames
,
p_frames
);
VS
::
get_singleton
()
->
material_set_param
(
_get_material
(),
shader_names
->
particle
s_anim
_h_frames
,
p_frames
);
}
int
SpatialMaterial
::
get_particles_anim_h_frames
()
const
{
...
...
@@ -1291,7 +1291,7 @@ int SpatialMaterial::get_particles_anim_h_frames() const {
void
SpatialMaterial
::
set_particles_anim_v_frames
(
int
p_frames
)
{
particles_anim_v_frames
=
p_frames
;
VS
::
get_singleton
()
->
material_set_param
(
_get_material
(),
shader_names
->
particle_v_frames
,
p_frames
);
VS
::
get_singleton
()
->
material_set_param
(
_get_material
(),
shader_names
->
particle
s_anim
_v_frames
,
p_frames
);
}
int
SpatialMaterial
::
get_particles_anim_v_frames
()
const
{
...
...
scene/resources/material.h
View file @
c109a6e5
...
...
@@ -283,8 +283,8 @@ private:
StringName
uv1_offset
;
StringName
uv2_scale
;
StringName
uv2_offset
;
StringName
particle_h_frames
;
StringName
particle_v_frames
;
StringName
particle
s_anim
_h_frames
;
StringName
particle
s_anim
_v_frames
;
StringName
particles_anim_loop
;
StringName
depth_min_layers
;
StringName
depth_max_layers
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment