DXGL r134 - Code Review
For
DXGL
(
recent comments
|
status changes
|
tags
|
authors
|
states
|
release notes
|
statistics
)
Jump to navigation
Jump to search
Repository:
DXGL
Revision:
<
r133
|
r134
|
r135
>
Date:
19:25, 10 April 2012
Author:
admin
Status:
new
Tags:
Comment:
Add no specular directional lighting function
Modified paths:
/ddraw/shadergen.cpp
(modified) (
history
)
Diff
[
purge
]
Index: ddraw/shadergen.cpp
—
—
@@ -249,6 +249,7 @@
250
250
static const char op_resetcolor[] = "diffuse = specular = vec4(0.0);\n\
251
251
ambient = ambientcolor / 255.0;\n";
252
252
static const char op_dirlight[] = "DirLight(lightX);\n";
253
+static const char op_dirlightnospecular[] = "DirLightNoSpecular(lightX);\n";
253
254
static const char op_spotlight[] = "SpotLight(lightX);\n";
254
255
static const char op_colorout[] = "vec4 color = (material.diffuse * diffuse) + (material.ambient * ambient) + \n\
255
256
(material.specular * specular) + material.emissive;\n\
—
—
@@ -275,6 +276,14 @@
276
277
ambient += light.ambient;\n\
277
278
}\n\
278
279
}\n";
280
+static const char func_dirlightnospecular[] = "void DirLightNoSpecular(in Light light)\n\
281
+{\n\
282
+float NdotHV = 0.0;\n\
283
+vec3 dir = normalize(-light.direction);\n\
284
+ambient += light.ambient;\n\
285
+float NdotL = max(dot(N,dir),0.0);\n\
286
+diffuse += light.diffuse*NdotL;\n\
287
+}\n";
279
288
280
289
void CreateShader(int index, __int64 id, TEXTURESTAGE *texstate, int *texcoords)
281
290
{
—
—
@@ -351,8 +360,13 @@
352
361
else hasdir = true;
353
362
}
354
363
}
364
+ bool hasspecular = (id >> 11) & 1;
355
365
if(hasspot) FIXME("Add spot lights");
356
- if(hasdir) vsrc->append(func_dirlight);
366
+ if(hasdir)
367
+ {
368
+ if(hasspecular) vsrc->append(func_dirlight);
369
+ else vsrc->append(func_dirlightnospecular);
370
+ }
357
371
//Main
358
372
vsrc->append(mainstart);
359
373
if((id>>34)&1) vsrc->append(op_passthru);
—
—
@@ -372,9 +386,18 @@
373
387
}
374
388
else
375
389
{
376
- tmp = op_dirlight;
377
- tmp.replace(14,1,_itoa(i,idstring,10));
378
- vsrc->append(tmp);
390
+ if(hasspecular)
391
+ {
392
+ tmp = op_dirlight;
393
+ tmp.replace(14,1,_itoa(i,idstring,10));
394
+ vsrc->append(tmp);
395
+ }
396
+ else
397
+ {
398
+ tmp = op_dirlightnospecular;
399
+ tmp.replace(24,1,_itoa(i,idstring,10));
400
+ vsrc->append(tmp);
401
+ }
379
402
}
380
403
}
381
404
}
Navigation menu
Personal tools
Log in
Namespaces
Special page
English
expanded
collapsed
Views
More
expanded
collapsed
Search
Navigation
Home
Main page
Recent changes
Random page
MediaWiki help
Introduction
Progress
Downloads
Source code
Build from source
AppDB
Bug reports
Forums
Tools
Special pages
Printable version