DXGL r294 - Code Review
For
DXGL
(
recent comments
|
status changes
|
tags
|
authors
|
states
|
release notes
|
statistics
)
Jump to navigation
Jump to search
Repository:
DXGL
Revision:
<
r293
|
r294
|
r295
>
Date:
16:46, 31 December 2012
Author:
admin
Status:
new
Tags:
Comment:
Add fog equations.
Modified paths:
/ddraw/shadergen.cpp
(modified) (
history
)
Diff
[
purge
]
Index: ddraw/shadergen.cpp
—
—
@@ -270,6 +270,8 @@
271
271
vec3 N;";
272
272
static const char var_color[] = "vec4 color;\n";
273
273
static const char var_xyzw[] = "vec4 xyzw;\n";
274
+static const char var_fogfactorvertex[] = "varying float fogfactor;\n";
275
+static const char var_fogfactorpixel[] = "float fogfactor;\n";
274
276
// Operations
275
277
static const char op_transform[] = "xyzw = vec4(xyz,1);\n\
276
278
vec4 pos = gl_ModelViewProjectionMatrix*xyzw;\n\
—
—
@@ -297,6 +299,16 @@
298
300
static const char op_texpassthru2str[] = "vec4(strX,1);\n";
299
301
static const char op_texpassthru2strq[] = "strqX;\n";
300
302
static const char op_texpassthru2null[] = "vec4(0,0,0,1);\n";
303
+static const char op_fogcoordstandard[] = "gl_FogFragCoord = (gl_ModelViewMatrix*gl_Vertex).z;\n";
304
+static const char op_fogcoordrange[] = "vec4 eyepos = gl_ModelViewMatrix*gl_Vertex;\n\
305
+vec3 eyepos3 = eyepos.xyz / eyepos.w;\n\
306
+gl_FragFogCoord = sqrt((eyepos3.x * eyepos3.x) + (eyepos3.y * eyepos3.y) + (eyepos3.z * eyepos3.z));\n";
307
+static const char op_foglinear[] = "fogfactor = (gl_Fog.end - gl_FogFragCoord) / (gl_Fog.end - glFog.start);\n";
308
+static const char op_fogexp[] = "fogfactor = 1 / exp(gl_FogFragCoord * gl_Fog.density);\n";
309
+static const char op_fogexp2[] = "fogfactor = 1 / exp(gl_FogFragCoord * gl_FogFragCoord *\n\
310
+gl_Fog.density * gl_Fog.density)\n";
311
+static const char op_fogclamp[] = "fogfactor = clamp(fogfactor,0.0,1.0);\n";
312
+static const char op_fogblend[] = "color = mix(color,gl_Fog.color,fogfactor);\n";
301
313
302
314
// Functions
303
315
static const char func_dirlight[] = "void DirLight(in Light light)\n\
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