Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
4388fb41
Commit
4388fb41
authored
Apr 30, 2015
by
Matteo Bruni
Committed by
Alexandre Julliard
May 01, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Implement legacy light attenuation behavior in the GLSL vertex ffp.
parent
72722222
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
10 deletions
+42
-10
glsl_shader.c
dlls/wined3d/glsl_shader.c
+42
-10
No files found.
dlls/wined3d/glsl_shader.c
View file @
4388fb41
...
...
@@ -106,6 +106,7 @@ struct shader_glsl_priv {
struct
wine_rb_tree
ffp_vertex_shaders
;
struct
wine_rb_tree
ffp_fragment_shaders
;
BOOL
ffp_proj_control
;
BOOL
legacy_lighting
;
};
struct
glsl_vs_program
...
...
@@ -5404,7 +5405,8 @@ static const char *shader_glsl_ffp_mcs(enum wined3d_material_color_source mcs, c
}
static
void
shader_glsl_ffp_vertex_lighting
(
struct
wined3d_string_buffer
*
buffer
,
const
struct
wined3d_ffp_vs_settings
*
settings
,
const
struct
wined3d_gl_info
*
gl_info
)
const
struct
wined3d_ffp_vs_settings
*
settings
,
const
struct
wined3d_gl_info
*
gl_info
,
BOOL
legacy_lighting
)
{
const
char
*
diffuse
,
*
specular
,
*
emission
,
*
ambient
;
enum
wined3d_light_type
light_type
;
...
...
@@ -5438,24 +5440,36 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
shader_addline
(
buffer
,
"dst.z = dot(dir, dir);
\n
"
);
shader_addline
(
buffer
,
"dst.y = sqrt(dst.z);
\n
"
);
shader_addline
(
buffer
,
"dst.x = 1.0;
\n
"
);
if
(
legacy_lighting
)
{
shader_addline
(
buffer
,
"dst.y = (ffp_light[%u].range - dst.y) / ffp_light[%u].range;
\n
"
,
i
,
i
);
shader_addline
(
buffer
,
"dst.z = dst.y * dst.y;
\n
"
);
}
else
{
shader_addline
(
buffer
,
"if (dst.y <= ffp_light[%u].range)
\n
{
\n
"
,
i
);
}
shader_addline
(
buffer
,
"att = dot(dst.xyz, vec3(ffp_light[%u].c_att,"
" ffp_light[%u].l_att, ffp_light[%u].q_att));
\n
"
,
i
,
i
,
i
);
shader_addline
(
buffer
,
"ambient += ffp_light[%u].ambient.xyz / att;
\n
"
,
i
);
if
(
!
legacy_lighting
)
shader_addline
(
buffer
,
"att = 1.0 / att;"
);
shader_addline
(
buffer
,
"ambient += ffp_light[%u].ambient.xyz * att;
\n
"
,
i
);
if
(
!
settings
->
normal
)
{
if
(
!
legacy_lighting
)
shader_addline
(
buffer
,
"}
\n
"
);
break
;
}
shader_addline
(
buffer
,
"dir = normalize(dir);
\n
"
);
shader_addline
(
buffer
,
"diffuse += (clamp(dot(dir, normal), 0.0, 1.0)"
" * ffp_light[%u].diffuse.xyz)
/
att;
\n
"
,
i
);
" * ffp_light[%u].diffuse.xyz)
*
att;
\n
"
,
i
);
if
(
settings
->
localviewer
)
shader_addline
(
buffer
,
"t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));
\n
"
);
else
shader_addline
(
buffer
,
"t = dot(normal, normalize(dir + vec3(0.0, 0.0, -1.0)));
\n
"
);
shader_addline
(
buffer
,
"if (t > 0.0) specular += (pow(t, ffp_material.shininess)"
" * ffp_light[%u].specular) / att;
\n
"
,
i
);
" * ffp_light[%u].specular) * att;
\n
"
,
i
);
if
(
!
legacy_lighting
)
shader_addline
(
buffer
,
"}
\n
"
);
break
;
...
...
@@ -5464,19 +5478,34 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
shader_addline
(
buffer
,
"dst.z = dot(dir, dir);
\n
"
);
shader_addline
(
buffer
,
"dst.y = sqrt(dst.z);
\n
"
);
shader_addline
(
buffer
,
"dst.x = 1.0;
\n
"
);
if
(
legacy_lighting
)
{
shader_addline
(
buffer
,
"dst.y = (ffp_light[%u].range - dst.y) / ffp_light[%u].range;
\n
"
,
i
,
i
);
shader_addline
(
buffer
,
"dst.z = dst.y * dst.y;
\n
"
);
}
else
{
shader_addline
(
buffer
,
"if (dst.y <= ffp_light[%u].range)
\n
{
\n
"
,
i
);
}
shader_addline
(
buffer
,
"dir = normalize(dir);
\n
"
);
shader_addline
(
buffer
,
"t = dot(-dir, normalize(ffp_light[%u].direction));
\n
"
,
i
);
shader_addline
(
buffer
,
"if (t > ffp_light[%u].cos_htheta) att = 1.0;
\n
"
,
i
);
shader_addline
(
buffer
,
"else if (t <= ffp_light[%u].cos_hphi) att = 0.0;
\n
"
,
i
);
shader_addline
(
buffer
,
"else att = pow((t - ffp_light[%u].cos_hphi)"
" / (ffp_light[%u].cos_htheta - ffp_light[%u].cos_hphi), ffp_light[%u].falloff)"
" / dot(dst.xyz, vec3(ffp_light[%u].c_att,"
" / (ffp_light[%u].cos_htheta - ffp_light[%u].cos_hphi), ffp_light[%u].falloff);
\n
"
,
i
,
i
,
i
,
i
);
if
(
legacy_lighting
)
shader_addline
(
buffer
,
"att *= dot(dst.xyz, vec3(ffp_light[%u].c_att,"
" ffp_light[%u].l_att, ffp_light[%u].q_att));
\n
"
,
i
,
i
,
i
,
i
,
i
,
i
,
i
);
i
,
i
,
i
);
else
shader_addline
(
buffer
,
"att /= dot(dst.xyz, vec3(ffp_light[%u].c_att,"
" ffp_light[%u].l_att, ffp_light[%u].q_att));
\n
"
,
i
,
i
,
i
);
shader_addline
(
buffer
,
"ambient += ffp_light[%u].ambient.xyz * att;
\n
"
,
i
);
if
(
!
settings
->
normal
)
{
if
(
!
legacy_lighting
)
shader_addline
(
buffer
,
"}
\n
"
);
break
;
}
...
...
@@ -5488,6 +5517,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
shader_addline
(
buffer
,
"t = dot(normal, normalize(dir + vec3(0.0, 0.0, -1.0)));
\n
"
);
shader_addline
(
buffer
,
"if (t > 0.0) specular += (pow(t, ffp_material.shininess)"
" * ffp_light[%u].specular) * att;
\n
"
,
i
);
if
(
!
legacy_lighting
)
shader_addline
(
buffer
,
"}
\n
"
);
break
;
...
...
@@ -5523,7 +5553,8 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
/* Context activation is done by the caller. */
static
GLuint
shader_glsl_generate_ffp_vertex_shader
(
struct
wined3d_string_buffer
*
buffer
,
const
struct
wined3d_ffp_vs_settings
*
settings
,
const
struct
wined3d_gl_info
*
gl_info
)
const
struct
wined3d_ffp_vs_settings
*
settings
,
const
struct
wined3d_gl_info
*
gl_info
,
BOOL
legacy_lighting
)
{
GLuint
shader_obj
;
unsigned
int
i
;
...
...
@@ -5588,7 +5619,7 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct wined3d_string_buffe
else
shader_addline
(
buffer
,
"vec3 normal = ffp_normal_matrix * gl_Normal;
\n
"
);
shader_glsl_ffp_vertex_lighting
(
buffer
,
settings
,
gl_info
);
shader_glsl_ffp_vertex_lighting
(
buffer
,
settings
,
gl_info
,
legacy_lighting
);
for
(
i
=
0
;
i
<
MAX_TEXTURES
;
++
i
)
{
...
...
@@ -6292,7 +6323,7 @@ static struct glsl_ffp_vertex_shader *shader_glsl_find_ffp_vertex_shader(struct
return
NULL
;
shader
->
desc
.
settings
=
*
settings
;
shader
->
id
=
shader_glsl_generate_ffp_vertex_shader
(
&
priv
->
shader_buffer
,
settings
,
gl_info
);
shader
->
id
=
shader_glsl_generate_ffp_vertex_shader
(
&
priv
->
shader_buffer
,
settings
,
gl_info
,
priv
->
legacy_lighting
);
list_init
(
&
shader
->
linked_programs
);
if
(
wine_rb_put
(
&
priv
->
ffp_vertex_shaders
,
&
shader
->
desc
.
settings
,
&
shader
->
desc
.
entry
)
==
-
1
)
ERR
(
"Failed to insert ffp vertex shader.
\n
"
);
...
...
@@ -7246,6 +7277,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
priv
->
fragment_pipe
=
fragment_pipe
;
fragment_pipe
->
get_caps
(
gl_info
,
&
fragment_caps
);
priv
->
ffp_proj_control
=
fragment_caps
.
wined3d_caps
&
WINED3D_FRAGMENT_CAP_PROJ_CONTROL
;
priv
->
legacy_lighting
=
device
->
wined3d
->
flags
&
WINED3D_LEGACY_FFP_LIGHTING
;
device
->
vertex_priv
=
vertex_priv
;
device
->
fragment_priv
=
fragment_priv
;
...
...
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