Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef _BUMP_MAPPING_FRAG_
#define _BUMP_MAPPING_FRAG_

uniform int bumpMapLightId = 0;

float ReliefMapping_RayIntersection(in vec2 A, in vec2 AB){
	const int num_steps_lin = 10;
	const int num_steps_bin = 15;
	float linear_step = 1.0 / (float(num_steps_lin));
    //Current depth position
    float depth = 0.0; 
    //Best match found (starts with last position 1.0)
    float best_depth = 1.0;
    float step = linear_step;
    //Search from front to back for first point inside the object
    for(int i=0; i<num_steps_lin-1; i++){
        depth += step;
        if (depth >= 1.0 - texture(texNormalMap, A+AB*depth).a) {
            best_depth = depth; //Store best depth
            i = num_steps_lin-1;
        }
    }
    //The point of intersection is found between (depth) and (depth-step)
    //so start from (depth - step/2)
    step = linear_step * 0.5;
    depth = best_depth - step;
    // binary search
    for(int i = 0; i < num_steps_bin; ++i){
        step *= 0.5;
        best_depth = depth;
        if (depth >= 1.0 - texture(texNormalMap, A + AB * depth).a) {
            depth -= step;
        }else {
            depth += step;
        }
    }
    return best_depth;
}

vec4 ParallaxMapping(in uint bumpMapLightId, in vec2 uv){
    vec3 lightVecTBN = vec3(0.0);
    switch (dvd_LightSource[bumpMapLightId]._options.x){
        case LIGHT_DIRECTIONAL      : 
            lightVecTBN = -normalize(dvd_LightSource[bumpMapLightId]._position.xyz); 
            break;
        case LIGHT_OMNIDIRECTIONAL  : 
        case LIGHT_SPOT             : 
            lightVecTBN = normalize(_viewDirection + dvd_LightSource[bumpMapLightId]._position.xyz); 
            break;
    };

    vec3 viewVecTBN = normalize(_viewDirection);
    
    //Offset, scale and bias
    vec2 vTexCoord = uv + 
                    ((texture(texNormalMap, uv).a - 0.5) * 
                     dvd_parallaxFactor * 
                     (vec2(viewVecTBN.x, -viewVecTBN.y) / 
                     viewVecTBN.z));

    //Normal mapping in TBN space
    return getPixelColor(vTexCoord, normalize(2.0 * texture(texNormalMap, vTexCoord).xyz - 1.0));
}

vec4 ReliefMapping(in int _light, in vec2 uv){
    vec3 viewVecTBN = normalize(_viewDirection);
    //Size and search starting position in texture space
    vec2 AB = dvd_reliefFactor * vec2(-viewVecTBN.x, viewVecTBN.y)/viewVecTBN.z;

    float h = ReliefMapping_RayIntersection(uv, AB);
    
    vec2 uv_offset = h * AB;
    
    vec3 p = _vertexWV.xyz;
    vec3 v = normalize(p);
    //Compute light direction
    p += v*h*viewVecTBN.z;	
    
    vec2 planes;
    planes.x = -dvd_ZPlanesCombined.y / (dvd_ZPlanesCombined.y - dvd_ZPlanesCombined.x);
    planes.y = -dvd_ZPlanesCombined.y * dvd_ZPlanesCombined.x / (dvd_ZPlanesCombined.y - dvd_ZPlanesCombined.x);

    gl_FragDepth =((planes.x * p.z + planes.y) / -p.z);
    
    return getPixelColor(uv + uv_offset, normalize(2.0 * texture(texNormalMap, uv + uv_offset).xyz - 1.0));
}

#endif //_BUMP_MAPPING_FRAG_

Commits for Divide-Framework/trunk/assets/shaders/GLSL/fragmentAtoms/bumpMapping.frag

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

329 Diff Diff IonutCava picture IonutCava Tue 07 Oct, 2014 12:51:37 +0000

[Ionut]
- Modified material class and shaders to support multiple BRDFs (currently, only Flat, Phong and Blinn-Phong supported with Cook-Torrance and Oren-Nayar in future commits)
- Optimized transform updates and queries
- Fixed an indirect draw command (no buffer was bound to GL_DRAW_INDIRECT_BUFFER, violating a core requirement)

324 Diff Diff IonutCava picture IonutCava Sun 14 Sep, 2014 14:01:39 +0000

[Ionut]
- New memory management system (no custom allocators in this commit)
— Memory tracer to detect memory leaks on shutdown (from: https://www.relisoft.com/book/tech/9new.html)
— SAFE_DELETE_XYZ are now inline template functions not macros
— ASSERTION system now supports logging and message boxes and continue on error configurable for each build type
— Fixed a lot of memory leaks detected by the new system (some still remain)

- Added SRGB support (part 1)
— Albedo textures are loaded as SRGB (make sure resources are SRGB)
— Shaders output gamma corrected colors
— Moved terrain textures back to 2 array system (albedo and normal maps, albedo maps using a SRGB sampler)

- Sky is now loaded via the ResourceCache system
- Added include safeguards in shader atoms

290 Diff Diff IonutCava picture IonutCava Sun 27 Jul, 2014 14:54:01 +0000

[Ionut]
- Small change to the resource loading thread
- Fixed array texture loading in framebuffer
- Temporarily disabled shadows (caused an assert)
- Fixed double close call for LightManager
- Removed unused options from config.xml

278 Diff Diff IonutCava picture IonutCava Thu 19 Jun, 2014 18:09:59 +0000

[Ionut][[BR]]
- Preliminary work on generic shader function selection infrastructure [[BR]]

272 Diff Diff IonutCava picture IonutCava Wed 11 Jun, 2014 11:30:51 +0000

[Ionut] [[BR]]
- Added initial code for Forward+ rendering (grid based light culling) [[BR]]
- Simplified Light class [[BR]]
- Moved more light uniform data to ShaderBuffers [[BR]]
- Double buffered grass rendering [[BR]]
- Added a better attribute interface to GenericVertexData [[BR]]
- Fixed screenshot capture [[BR]]
- Fixed texture double-bind checks [[BR]]

265 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 19:47:56 +0000

[Ionut] [[BR]]
- reworked uniform buffer binding [[BR]]
- modified framebuffer mipmap update [[BR]]

264 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 13:04:38 +0000

[Ionut] [[BR]]
- New camera system: [[BR]]
— Stack based (push/pop active camera) [[BR]]
— Per camera frustum [[BR]]
— Per camera projection [[BR]]
— Shadow mapping now uses the new camera system (each light has a shadow camera) [[BR]]
[[BR]]
- New terrain, water and vegetation system: [[BR]]
— Direct import of terrain from L3DT both as 8-bit grayscale and 16-bit raw formats [[BR]]
— Multiple alpha maps for texture splatting support [[BR]]
— Per texture detail map support [[BR]]
— Transform feedback based visibility culling for vegetation [[BR]]
— Alpha-map based vegetation placing on terrain [[BR]]
— Water now uses a refraction map instead of alpha blending for better refraction effects [[BR]]
[[BR]]
- SceneGraph improvements: [[BR]]
— Better bounding box updates from child to parent [[BR]]
— Better onDraw / postDraw implementation [[BR]]
[[BR]]
- Performance improvements: [[BR]]
— Batch 2D rendering tasks together as much as possible[[BR]]
— Improve renderStateBlock hash generation for better sorting [[BR]]
— Move most state related gfx changes from API implementation to the GFXDevice class [[BR]]
— Move viewport stack to the GFXDevice class [[BR]]
— Added various performance counters (frame duration with round-robin query system, draw call count, etc) [[BR]]
— Fixed and improved clip plane management [[BR]]
— Delete client-side texture data after GPU upload [[BR]]
[[BR]]
- New features: [[BR]]
— Added callback support to the Task class so that a specific task may call a function in the main thread upon completion [[BR]]
— Added mouse-wheel zoom support to Orbit/ThirdPerson cameras [[BR]]
— Added 2D Texture Array support (e.g. used for terrain textures) [[BR]]

260 Diff Diff k1ngp1n picture k1ngp1n Sat 03 May, 2014 19:33:41 +0000

[Ionut] [[BR]]
- More work on CSM. Reverted back to VSM to allow easier blurring and filtering [[BR]]
- Rewrote FrameBuffer classes to fix MSAA and memory leaks that occurred on resize (double creation of textures) [[BR]]
— Removed FBType. FrameBuffer types depend only on attachment types and if it’s MSAA enabled or not [[BR]]
- Rewrote RenderState classes to be API agnostic [[BR]]
- Bug fixes in math classes [[BR]]
- Changed “resolution change” logic [[BR]]
- Simplified some options in config.xml [[BR]]
- Improved per-light shadow options [[BR]]

259 k1ngp1n picture k1ngp1n Sun 27 Apr, 2014 18:24:52 +0000

[Ionut][[BR]]
- Implemented Exponential Stable Cascaded Shadow Maps for directional lights (still buggy, but basically working) [[BR]]
— CSM settings (resolution, number of splits, etc) are part of the scene render state [[BR]]
- SGN can skip rendering for the current frame if they are not ready (e.g. OnDraw can now return false or materials can fail to bind) [[BR]]
- Frustum class is now using the Plane class [[BR]]
- Removed Math SIMD implementation as the compiler generated code will always be faster and safer [[BR]]
- Added a “STUBBED” macro for outputing to the error stream of important messages (instead of using #pragma message) [[BR]]
- Added “freeze time” logic to pause/resume updates with or without freezing the GUI too [[BR]]
- Added “processGUI” method the every Scene class to separate time-sensitive GUI updates from game logic loop [[BR]]
- GLSL <-> Vertex Buffer bind locations are automatically set for every vertex shader [[BR]]
- Added basic support for compute shaders [[BR]]
- Removed most OS define checks to make porting to a new platform easier [[BR]]
- Texture transparency check per-pixel is now using OpenMP [[BR]]
- Texture samplers can now set a border color for CLAMP_TO_BORDER wrap mode [[BR]]
- Removed “Object” suffix from GFX Classes (pixel buffer, vertex buffer, frame buffer, etc) [[BR]]
- Stop processing scene input when application looses focus [[BR]]
- SceneGraphNode class is now responsible for updating SGNComponents on draw and calling its _node’s OnDraw method [[BR]]
- UBOs can now list all of the active uniforms inside a block with info such as type and offset [[BR]]
- Removed deprecated ‘GLCheck’ macro [[BR]]
- A lot of bug fixes and performance improvements in various places [[BR]]