The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.1.31 (Linux)
|
lightaccumulate/fragment.glsl shader - Printable Version +- Forums (https://www.vdrift.net/Forum) +-- Forum: Community (https://www.vdrift.net/Forum/forumdisplay.php?fid=3) +--- Forum: Bugs (https://www.vdrift.net/Forum/forumdisplay.php?fid=7) +--- Thread: lightaccumulate/fragment.glsl shader (/showthread.php?tid=1293) |
lightaccumulate/fragment.glsl shader - nomoo - 06-06-2010 win7 x64, gf 8600. code rev 2780, data rev.579 stdout: INFO: Starting VDrift: 2010-02-07-full, Version: , O/S: Windows INFO: Home directory: C:\Users\nomoo INFO: Settings file: C:\Users\nomoo\My Documents\My Games\VDrift/VDrift.config INFO: Data directory: data INFO: Log file: C:\Users\nomoo\My Documents\My Games\VDrift/log.txt INFO: SDL initialization successful INFO: Automatictally setting depth buffer to 24-bit because shadows are enabled INFO: SDL video query was successful INFO: Enabling antialiasing: 4X INFO: Display change was successful: 800x600x32 24z fullscreen=0 INFO: Video card information: Vendor: NVIDIA Corporation Renderer: GeForce 8600 GT/PCI/SSE2 Version: 3.2.0 Maximum texture size: 8192 Maximum varying floats: 60 Using GLEW 1.5.4 INFO: Maximum color attachments: 8 INFO: Maximum draw buffers (1 required): 8 INFO: Texture units: 4 full, 32 partial INFO: Loaded shader package simple INFO: Loaded shader package simple, variant simple_premult INFO: Loaded shader package simple, variant simple_gamma_premult INFO: Loaded shader package simple, variant simple_gamma INFO: Loaded shader package simple, variant simplecar INFO: Loaded shader package logluminance INFO: Loaded shader package logluminance, variant logluminance_tiny INFO: Loaded shader package tonemap INFO: Loaded shader package gbufferfill INFO: Loaded shader package gbufferfill, variant gbufferfillcar INFO: ----- Start Shader Compile Log for data/shaders/lightaccumulate/fragment.glsl ----- INFO: 0(119) : error C1038: declaration of "refmapdir" conflicts with previous declaration at 0(117) INFO: ----- End Shader Compile Log ----- INFO: ----- Start Shader Link Log for data/shaders/lightaccumulate/vertex.glsl and data/shaders/lightaccumulate/fragment.glsl ----- INFO: Fragment info ------------- 0(119) : error C1038: declaration of "refmapdir" conflicts with previous declaration at 0(117) INFO: ----- End Shader Link Log ----- INFO: Maximum anisotropy: 16 INFO: 0 joysticks found. INFO: Loading car controls from: C:\Users\nomoo\My Documents\My Games\VDrift/controls.config INFO: Sound initialization information: INFO: Obtained audio device: Frequency: 44100 Format: 32784 Bits per sample: 16 Channels: 2 Silence: 0 Samples: 2048 Size: 8192 Sound initialization successful INFO: Loaded fonts successfully INFO: Loaded GUI successfully INFO: Shutting down... INFO: Exiting stderr: ERROR: Shader compilation failure: data/shaders/lightaccumulate/vertex.glsl and data/shaders/lightaccumulate/fragment.glsl ERROR: ERROR: Vertex shader: ERROR: 1 : #version 120 ERROR: 2 : #define _INITIAL_ ERROR: 3 : #define _SHADOWSMEDIUM_ ERROR: 4 : #define _CSM2_ ERROR: 5 : #define _SHADOWS_ ERROR: 6 : #define _REFLECTIONDYNAMIC_ ERROR: 7 : #define SCREENRESY 600 ERROR: 8 : #define SCREENRESX 800 ERROR: 9 : varying vec2 tu0coord; ERROR: 10 : varying vec3 eyespace_view_direction; ERROR: 11 : ERROR: 12 : void main() ERROR: 13 : { ERROR: 14 : // Transforming the vertex ERROR: 15 : vec4 pos = gl_ModelViewMatrix * gl_Vertex; ERROR: 16 : gl_Position = gl_ProjectionMatrix * pos; ERROR: 17 : vec3 pos3 = pos.xyz; ERROR: 18 : eyespace_view_direction = pos3; ERROR: 19 : ERROR: 20 : #ifdef _INITIAL_ ERROR: 21 : eyespace_view_direction = vec3(gl_MultiTexCoord1); ERROR: 22 : #endif ERROR: 23 : ERROR: 24 : tu0coord = vec2(gl_MultiTexCoord0); ERROR: 25 : ERROR: 26 : gl_FrontColor = gl_Color; ERROR: 27 : } ERROR: 28 : ERROR: ERROR: Fragment shader: ERROR: 1 : #version 120 ERROR: 2 : #define _INITIAL_ ERROR: 3 : #define _SHADOWSMEDIUM_ ERROR: 4 : #define _CSM2_ ERROR: 5 : #define _SHADOWS_ ERROR: 6 : #define _REFLECTIONDYNAMIC_ ERROR: 7 : #define SCREENRESY 600 ERROR: 8 : #define SCREENRESX 800 ERROR: 9 : varying vec2 tu0coord; ERROR: 10 : varying vec3 eyespace_view_direction; ERROR: 11 : ERROR: 12 : uniform sampler2D tu0_2D; ERROR: 13 : uniform sampler2D tu1_2D; ERROR: 14 : uniform sampler2D tu2_2D; ERROR: 15 : uniform sampler2D tu3_2D; ERROR: 16 : ERROR: 17 : #ifndef _REFLECTIONDISABLED_ ERROR: 18 : uniform samplerCube tu4_cube; //reflection map ERROR: 19 : #endif ERROR: 20 : ERROR: 21 : // shadowed directional light ERROR: 22 : uniform vec3 directlight_eyespace_direction; ERROR: 23 : ERROR: 24 : float unpackFloatFromVec2i(const vec2 value) ERROR: 25 : { ERROR: 26 : const vec2 unpack_constants = vec2(1.0/256.0, 1.0); ERROR: 27 : return dot(unpack_constants,value); ERROR: 28 : } ERROR: 29 : ERROR: 30 : vec3 sphericalToXYZ(const vec2 spherical) ERROR: 31 : { ERROR: 32 : vec3 xyz; ERROR: 33 : float theta = spherical.x*3.14159265358979323846; ERROR: 34 : vec2 sincosTheta = vec2(sin(theta),cos(theta)); ERROR: 35 : vec2 sincosPhi = vec2(sqrt(1.0-spherical.y*spherical.y), spherical.y); ERROR: 36 : xyz.x = sincosTheta.y*sincosPhi.x; ERROR: 37 : xyz.y = sincosTheta.x*sincosPhi.x; ERROR: 38 : xyz.z = spherical.y; ERROR: 39 : return xyz; ERROR: 40 : } ERROR: 41 : ERROR: 42 : #define GAMMA 2.2 ERROR: 43 : vec3 UnGammaCorrect(vec3 color) ERROR: 44 : { ERROR: 45 : return pow(color, vec3(1.0/GAMMA,1.0/GAMMA,1.0/GAMMA)); ERROR: 46 : } ERROR: 47 : vec3 GammaCorrect(vec3 color) ERROR: 48 : { ERROR: 49 : return pow(color, vec3(GAMMA,GAMMA,GAMMA)); ERROR: 50 : } ERROR: 51 : #undef GAMMA ERROR: 52 : ERROR: 53 : #define PI 3.14159265 ERROR: 54 : ERROR: 55 : float cos_clamped(const vec3 V1, const vec3 V2) ERROR: 56 : { ERROR: 57 : return max(0.0,dot(V1,V2)); ERROR: 58 : } ERROR: 59 : ERROR: 60 : vec3 CommonBRDF(const vec3 brdf, const vec3 E_l, const float omega_i) ERROR: 61 : { ERROR: 62 : return brdf * E_l * omega_i; ERROR: 63 : } ERROR: 64 : ERROR: 65 : vec3 FresnelEquation(const vec3 Rf0, const float omega_i) ERROR: 66 : { ERROR: 67 : return Rf0 + (vec3(1.,1.,1.)-Rf0)*pow(1.0-omega_i,5.0); ERROR: 68 : } ERROR: 69 : ERROR: 70 : // equation 7.49, Real-Time Rendering (third edition) by Akenine-Moller, Haines, Hoffman ERROR: 71 : vec3 RealTimeRenderingBRDF(const vec3 cdiff, const float m, const vec3 Rf0, const float alpha_h, const float omega_h) ERROR: 72 : { ERROR: 73 : return cdiff/PI + ((m+8.0)/(8.0*PI))*FresnelEquation(Rf0,alpha_h)*pow(omega_h,m); ERROR: 74 : } ERROR: 75 : ERROR: 76 : void main() ERROR: 77 : { ERROR: 78 : vec2 screen = vec2(SCREENRESX,SCREENRESY); ERROR: 79 : vec2 screencoord = gl_FragCoord.xy/screen; ERROR: 80 : ERROR: 81 : // retrieve g-buffer ERROR: 82 : float gbuf_depth = texture2D(tu3_2D, screencoord).r; ERROR: 83 : ERROR: 84 : // early discard ERROR: 85 : if (gbuf_depth == 1) discard; ERROR: 86 : ERROR: 87 : vec4 gbuf_material_properties = texture2D(tu0_2D, screencoord); ERROR: 88 : vec4 gbuf_normal_xy = texture2D(tu1_2D, screencoord); ERROR: 89 : vec4 gbuf_diffuse_albedo = texture2D(tu2_2D, screencoord); ERROR: 90 : ERROR: 91 : // decode g-buffer ERROR: 92 : vec3 cdiff = GammaCorrect(gbuf_diffuse_albedo.rgb); //diffuse reflectance ERROR: 93 : float notshadow = gbuf_diffuse_albedo.a; //direct light occlusion multiplier ERROR: 94 : vec3 Rf0 = GammaCorrect(gbuf_material_properties.rgb); //fresnel reflectance value at zero degrees ERROR: 95 : float m = gbuf_material_properties.a*256.0+1.0; //micro-scale roughness ERROR: 96 : float mpercent = gbuf_material_properties.a; ERROR: 97 : vec2 normal_spherical = vec2(unpackFloatFromVec2i(gbuf_normal_xy.xy),unpackFloatFromVec2i(gbuf_normal_xy.zw))*2.0-vec2(1.0,1.0); ERROR: 98 : vec3 normal = sphericalToXYZ(normal_spherical); ERROR: 99 : ERROR: 100 : // determine view vector ERROR: 101 : vec3 V = normalize(-eyespace_view_direction); ERROR: 102 : ERROR: 103 : // determine half vector ERROR: 104 : vec3 H = normalize(V+directlight_eyespace_direction); ERROR: 105 : ERROR: 106 : float alpha_h = dot(V,H); //cosine of angle between half vector and view direction ERROR: 107 : float omega_h = cos_clamped(H,normal); //clamped cosine of angle between half vector and normal ERROR: 108 : ERROR: 109 : vec4 final = vec4(0.0,0.0,0.0,1.0); ERROR: 110 : ERROR: 111 : #ifdef _INITIAL_ ERROR: 112 : // determine reflection vector and lookup into reflection texture ERROR: 113 : vec3 R = reflect(-V,normal); ERROR: 114 : vec3 reflection = vec3(0,0,0); ERROR: 115 : vec3 ambient = vec3(0.5,0.5,0.5); ERROR: 116 : float ambient_reflection_lod = 5; ERROR: 117 : vec3 refmapdir = R; ERROR: 118 : #ifdef _REFLECTIONDYNAMIC_ ERROR: 119 : vec3 refmapdir = vec3(-R.z, R.x, -R.y); ERROR: 120 : #endif ERROR: 121 : ERROR: 122 : #ifndef _REFLECTIONDISABLED_ ERROR: 123 : reflection = GammaCorrect(textureCubeLod(tu4_cube, R, mix(ambient_reflection_lod,0.0,mpercent)).rgb); ERROR: 124 : ambient = GammaCorrect(textureCubeLod(tu4_cube, normal, ambient_reflection_lod).rgb); ERROR: 125 : #endif ERROR: 126 : ERROR: 127 : const float reflectionstrength = 0.5; ERROR: 128 : ERROR: 129 : // add reflection light ERROR: 130 : final.rgb += FresnelEquation(vec3(0,0,0),cos_clamped(V,normal))*Rf0*reflection*reflectionstrength; ERROR: 131 : ERROR: 132 : const float ambientstrength = 0.7; ERROR: 133 : ERROR: 134 : // add ambient light ERROR: 135 : final.rgb += ambient*cdiff*ambientstrength; ERROR: 136 : ERROR: 137 : // generate parameters for directional light ERROR: 138 : const float sunstrength = 2.0; ERROR: 139 : vec3 E_l = vec3(1,1,0.8)*notshadow*sunstrength; //incoming light intensity/color ERROR: 140 : float omega_i = cos_clamped(directlight_eyespace_direction,normal); //clamped cosine of angle between incoming light direction and surface normal ERROR: 141 : #endif ERROR: 142 : ERROR: 143 : #ifdef _OMNI_ ERROR: 144 : float eyespace_z = gl_ProjectionMatrix[3].z / (gbuf_depth * -2.0 + 1.0 - gl_ProjectionMatrix[2].z); //http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=277938 ERROR: 145 : vec3 gbuf_eyespace_pos = vec3(eyespace_view_direction.xy/eyespace_view_direction.z*eyespace_z,eyespace_z); //http://lumina.sourceforge.net/Tutorials/Deferred_shading/Point_light.html ERROR: 146 : vec3 light_center = gl_ModelViewMatrix[3].xyz; ERROR: 147 : float attenuation_radius = 1.0; ERROR: 148 : float falloff_radius = 1.0; ERROR: 149 : float dist = max(0.01,distance(gbuf_eyespace_pos,light_center)); ERROR: 150 : float attenuation = max(0.0,(-dist/falloff_radius+1.0)*attenuation_radius/dist); ERROR: 151 : vec3 E_l = gl_Color.rgb*attenuation; ERROR: 152 : vec3 light_direction = -normalize(gbuf_eyespace_pos - light_center); ERROR: 153 : float omega_i = cos_clamped(light_direction,normal); //clamped cosine of angle between incoming light direction and surface normal ERROR: 154 : #endif ERROR: 155 : ERROR: 156 : // add source light ERROR: 157 : final.rgb += CommonBRDF(RealTimeRenderingBRDF(cdiff, m, Rf0, alpha_h, omega_h),E_l,omega_i); ERROR: 158 : ERROR: 159 : gl_FragColor = final; ERROR: 160 : } ERROR: 161 : ERROR: ERROR: Disabling shaders due to shader loading error - joevenzon - 06-06-2010 Oops. I hadn't added back support for dynamic reflections yet and so I hadn't run with the setting on and didn't hit that error. Should be fixed now (and dynamic reflections reimplemented) in latest code + data. - nomoo - 06-06-2010 cool, thanks for fast reaction here is a screenshot for the lastest svn: Stoplights are almost awesome but strange black pixels appeared when i hit the brake. Also when dynamic reflections are on, trees' background is not transparent. - joevenzon - 06-06-2010 The brake light black pixel problem should be fixed. I couldn't reproduce the tree problem, so if you still see it, post a screenshot and let me know which track you see the problem on. - nomoo - 06-07-2010 everything is good with trees, now, another car and another track. TC6,road atlanta and strange reflections: - joevenzon - 06-07-2010 Hmm, good catch, it seems that the instrument cluster panel's normal points directly at the camera in the TC6, and that was exposing a bug in the packing function. See if the latest data rev fixes that for you. - nomoo - 06-08-2010 Awesome. That helped. Thank you. |