I have updated a grid like Blender
I have updated the night build.
https://bitbucket.org/JavaSabr/jme3-spaceshift-editor/issues?&version=0.9.2
Iām going to make a release today
I have updated folder with editorās installers.
ver. 0.9.2
-Implemented scene filters editing and provided API to support custom filters.
-Added some build in filters.
-Fixed problems with custom classpath.
-Implemented D&D models from asset tree to model/scene editor.
-Implemented renaming lights in model/scene editor.
-Re-implemented working with scene layers.
-Implemented more user-friendly light editing in scene/model editor.
-Updated API for custom app states.
-Updated file selector dialogs, added some actions to a context menu.
-Updated a grid in scene/model editor.
-Added auto move editorās camera to selected node.
-Implemented D&D materials from asset tree to model/scene editor.
-Implemented D&D textures from asset tree to material editor.
-Added hotkeys(R/G/S) to switch a manipulator mode in scene/model editor.
-Added hotkey(delete) to delete a selected node from scene/model editor.
-Implemented D&D audio files from asset tree to audio data property in model/scene editor.
-Implemented control editing and provided API to support custom controls.
Also Iām going to make a video about these changes today/tomorrow.
I have updated the page:
https://bitbucket.org/JavaSabr/jme3-spaceshift-editor/wiki/J3S%20format%20in%20your%20game
Targeted some tickets for 0.9.3:
https://bitbucket.org/JavaSabr/jme3-spaceshift-editor/issues?status=new&status=open&version=0.9.3
@nehon Can I apply local transforms to mesh like an action in Blender āapply local transformsā using API of jME?
wellā¦ yes, thatās transforming all the vertices position with the local transform (position, rotation and scale), and update the underlying buffer.
Note that you can also do this with the world transforms. But tbhā¦Iām not sur why you would want to do that in JME.
ŃŠµŠ² 04, 2017 9:13:47 PM com.jme3.renderer.opengl.GLRenderer updateShaderSourceData
WARNING: Bad compile of:
1 #version 150 core
2 #define SRGB 1
3 #define FRAGMENT_SHADER 1
4 #define BASECOLORMAP 1
5 #define NORMALMAP 1
6 #define METALLICMAP 1
7 #define ROUGHNESSMAP 1
8 #define LIGHTMAP 1
9 #define SINGLE_PASS_LIGHTING 1
10 #define NB_LIGHTS 15
11 #define INDIRECT_LIGHTING 1
12 #extension GL_ARB_shader_texture_lod : enable
13 // -- begin import Common/ShaderLib/GLSLCompat.glsllib --
14 #if defined GL_ES
15 # define hfloat highp float
16 # define hvec2 highp vec2
17 # define hvec3 highp vec3
18 # define hvec4 highp vec4
19 # define lfloat lowp float
20 # define lvec2 lowp vec2
21 # define lvec3 lowp vec3
22 # define lvec4 lowp vec4
23 #else
24 # define hfloat float
25 # define hvec2 vec2
26 # define hvec3 vec3
27 # define hvec4 vec4
28 # define lfloat float
29 # define lvec2 vec2
30 # define lvec3 vec3
31 # define lvec4 vec4
32 #endif
33
34 #if __VERSION__ >= 130
35 out vec4 outFragColor;
36 # define texture1D texture
37 # define texture2D texture
38 # define texture3D texture
39 # define textureCube texture
40 # define texture2DLod textureLod
41 # define textureCubeLod textureLod
42 # if defined VERTEX_SHADER
43 # define varying out
44 # define attribute in
45 # elif defined FRAGMENT_SHADER
46 # define varying in
47 # define gl_FragColor outFragColor
48 # endif
49 #endif
50 // -- end import Common/ShaderLib/GLSLCompat.glsllib --
51 // -- begin import Common/ShaderLib/PBR.glsllib --
52 #ifndef PI
53 #define PI 3.14159265358979323846264
54 #endif
55
56 //Specular fresnel computation
57 vec3 F_Shlick(float vh, vec3 F0){
58 float fresnelFact = pow(2.0, (-5.55473*vh - 6.98316) * vh);
59 return mix(F0, vec3(1.0, 1.0, 1.0), fresnelFact);
60 }
61
62 void PBR_ComputeDirectLightSpecWF(vec3 normal, vec3 lightDir, vec3 viewDir,
63 vec3 lightColor, vec3 specColor, float roughness, float ndotv,
64 out vec3 outDiffuse, out vec3 outSpecular){
65 // Compute halfway vector.
66 vec3 halfVec = normalize(lightDir + viewDir);
67
68 // Compute ndotl, ndoth, vdoth terms which are needed later.
69 float ndotl = max( dot(normal, lightDir), 0.0);
70 float ndoth = max( dot(normal, halfVec), 0.0);
71 float hdotv = max( dot(viewDir, halfVec), 0.0);
72
73 // Compute diffuse using energy-conserving Lambert.
74 // Alternatively, use Oren-Nayar for really rough
75 // materials or if you have lots of processing power ...
76 outDiffuse = vec3(ndotl) * lightColor;
77
78 //cook-torrence, microfacet BRDF : http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
79
80 float alpha = roughness * roughness;
81
82 //D, GGX normaal Distribution function
83 float alpha2 = alpha * alpha;
84 float sum = ((ndoth * ndoth) * (alpha2 - 1.0) + 1.0);
85 float denom = PI * sum * sum;
86 float D = alpha2 / denom;
87
88 // Compute Fresnel function via Schlick's approximation.
89 vec3 fresnel = F_Shlick(hdotv, specColor);
90
91 //G Shchlick GGX Gometry shadowing term, k = alpha/2
92 float k = alpha * 0.5;
93
94 // UE4 way to optimise shlick GGX Gometry shadowing term
95 //http://graphicrants.blogspot.co.uk/2013/08/specular-brdf-reference.html
96 float G_V = ndotv + sqrt( (ndotv - ndotv * k) * ndotv + k );
97 float G_L = ndotl + sqrt( (ndotl - ndotl * k) * ndotl + k );
98 // the max here is to avoid division by 0 that may cause some small glitches.
99 float G = 1.0/max( G_V * G_L ,0.01);
100
101 float specular = D * G * ndotl;
102
103 outSpecular = fresnel * vec3(specular) * lightColor;
104 }
105
106 void PBR_ComputeDirectLight(vec3 normal, vec3 lightDir, vec3 viewDir,
107 vec3 lightColor, float fZero, float roughness, float ndotv,
108 out vec3 outDiffuse, out vec3 outSpecular){
109 // Compute halfway vector.
110 vec3 halfVec = normalize(lightDir + viewDir);
111
112 // Compute ndotl, ndoth, vdoth terms which are needed later.
113 float ndotl = max( dot(normal, lightDir), 0.0);
114 float ndoth = max( dot(normal, halfVec), 0.0);
115 float hdotv = max( dot(viewDir, halfVec), 0.0);
116
117 // Compute diffuse using energy-conserving Lambert.
118 // Alternatively, use Oren-Nayar for really rough
119 // materials or if you have lots of processing power ...
120 outDiffuse = vec3(ndotl) * lightColor;
121
122 //cook-torrence, microfacet BRDF : http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
123
124 float alpha = roughness * roughness;
125
126 //D, GGX normaal Distribution function
127 float alpha2 = alpha * alpha;
128 float sum = ((ndoth * ndoth) * (alpha2 - 1.0) + 1.0);
129 float denom = PI * sum * sum;
130 float D = alpha2 / denom;
131
132 // Compute Fresnel function via Schlick's approximation.
133 float fresnel = fZero + ( 1.0 - fZero ) * pow( 2.0, (-5.55473 * hdotv - 6.98316) * hdotv);
134
135 //G Shchlick GGX Gometry shadowing term, k = alpha/2
136 float k = alpha * 0.5;
137
138 /*
139 //classic Schlick ggx
140 float G_V = ndotv / (ndotv * (1.0 - k) + k);
141 float G_L = ndotl / (ndotl * (1.0 - k) + k);
142 float G = ( G_V * G_L );
143
144 float specular =(D* fresnel * G) /(4 * ndotv);
145 */
146
147 // UE4 way to optimise shlick GGX Gometry shadowing term
148 //http://graphicrants.blogspot.co.uk/2013/08/specular-brdf-reference.html
149 float G_V = ndotv + sqrt( (ndotv - ndotv * k) * ndotv + k );
150 float G_L = ndotl + sqrt( (ndotl - ndotl * k) * ndotl + k );
151 // the max here is to avoid division by 0 that may cause some small glitches.
152 float G = 1.0/max( G_V * G_L ,0.01);
153
154 float specular = D * fresnel * G * ndotl;
155
156 outSpecular = vec3(specular) * lightColor;
157 }
158
159 //https://knarkowicz.wordpress.com/2014/12/27/analytical-dfg-term-for-ibl/
160 vec3 EnvDFGPolynomial( vec3 specularColor, float roughness, float ndotv ){
161 float x = 1.0 - roughness;
162 float y = ndotv;
163
164 float b1 = -0.1688;
165 float b2 = 1.895;
166 float b3 = 0.9903;
167 float b4 = -4.853;
168 float b5 = 8.404;
169 float b6 = -5.069;
170 float bias = clamp( min( b1 * x + b2 * x * x, b3 + b4 * y + b5 * y * y + b6 * y * y * y ), 0.0, 1.0 );
171
172 float d0 = 0.6045;
173 float d1 = 1.699;
174 float d2 = -0.5228;
175 float d3 = -3.603;
176 float d4 = 1.404;
177 float d5 = 0.1939;
178 float d6 = 2.661;
179 float delta = clamp(( d0 + d1 * x + d2 * y + d3 * x * x + d4 * x * y + d5 * y * y + d6 * x * x * x ), 0.0, 1.0);
180 float scale = delta - bias;
181
182 bias *= clamp( 2.5 / (roughness) * specularColor.y, 0.0, 1.0 );
183 return specularColor * scale + bias;
184 }
185
186 vec3 ApproximateSpecularIBL(samplerCube envMap,sampler2D integrateBRDF, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){
187 //TODO magic values should be replaced by defines.
188 float Lod = log2(Roughness) * 1.1 + 6.0 - 2.0;
189 vec3 PrefilteredColor = textureCubeLod(envMap, refVec.xyz,Lod).rgb;
190 vec2 EnvBRDF = texture2D(integrateBRDF,vec2(Roughness, ndotv)).rg;
191 return PrefilteredColor * ( SpecularColor * EnvBRDF.x+ EnvBRDF.y );
192 }
193
194 vec3 ApproximateSpecularIBLPolynomial(samplerCube envMap, vec3 SpecularColor , float Roughness, float ndotv, vec3 refVec){
195 //TODO magic values should be replaced by defines.
196 float Lod = log2(Roughness) * 1.5 + 6.0 - 1.0;
197 vec3 PrefilteredColor = textureCubeLod(envMap, refVec.xyz, Lod).rgb;
198 return PrefilteredColor * EnvDFGPolynomial(SpecularColor, Roughness, ndotv);
199 }
200
201
202
203
204
205 // -- end import Common/ShaderLib/PBR.glsllib --
206 // -- begin import Common/ShaderLib/Parallax.glsllib --
207 #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING)
208 vec2 steepParallaxOffset(sampler2D parallaxMap, vec3 vViewDir,vec2 texCoord,float parallaxScale){
209 vec2 vParallaxDirection = normalize( vViewDir.xy );
210
211 // The length of this vector determines the furthest amount of displacement: (Ati's comment)
212 float fLength = length( vViewDir );
213 float fParallaxLength = sqrt( fLength * fLength - vViewDir.z * vViewDir.z ) / vViewDir.z;
214
215 // Compute the actual reverse parallax displacement vector: (Ati's comment)
216 vec2 vParallaxOffsetTS = vParallaxDirection * fParallaxLength;
217
218 // Need to scale the amount of displacement to account for different height ranges
219 // in height maps. This is controlled by an artist-editable parameter: (Ati's comment)
220 parallaxScale *=0.3;
221 vParallaxOffsetTS *= parallaxScale;
222
223 vec3 eyeDir = normalize(vViewDir).xyz;
224
225 float nMinSamples = 6.0;
226 float nMaxSamples = 1000.0 * parallaxScale;
227 float nNumSamples = mix( nMinSamples, nMaxSamples, 1.0 - eyeDir.z ); //In reference shader: int nNumSamples = (int)(lerp( nMinSamples, nMaxSamples, dot( eyeDirWS, N ) ));
228 float fStepSize = 1.0 / nNumSamples;
229 float fCurrHeight = 0.0;
230 float fPrevHeight = 1.0;
231 float fNextHeight = 0.0;
232 float nStepIndex = 0.0;
233 vec2 vTexOffsetPerStep = fStepSize * vParallaxOffsetTS;
234 vec2 vTexCurrentOffset = texCoord;
235 float fCurrentBound = 1.0;
236 float fParallaxAmount = 0.0;
237
238 while ( nStepIndex < nNumSamples && fCurrHeight <= fCurrentBound ) {
239 vTexCurrentOffset -= vTexOffsetPerStep;
240 fPrevHeight = fCurrHeight;
241
242
243 #ifdef NORMALMAP_PARALLAX
244 //parallax map is stored in the alpha channel of the normal map
245 fCurrHeight = texture2D( parallaxMap, vTexCurrentOffset).a;
246 #else
247 //parallax map is a texture
248 fCurrHeight = texture2D( parallaxMap, vTexCurrentOffset).r;
249 #endif
250
251 fCurrentBound -= fStepSize;
252 nStepIndex+=1.0;
253 }
254 vec2 pt1 = vec2( fCurrentBound, fCurrHeight );
255 vec2 pt2 = vec2( fCurrentBound + fStepSize, fPrevHeight );
256
257 float fDelta2 = pt2.x - pt2.y;
258 float fDelta1 = pt1.x - pt1.y;
259
260 float fDenominator = fDelta2 - fDelta1;
261
262 fParallaxAmount = (pt1.x * fDelta2 - pt2.x * fDelta1 ) / fDenominator;
263
264 vec2 vParallaxOffset = vParallaxOffsetTS * (1.0 - fParallaxAmount );
265 return texCoord - vParallaxOffset;
266 }
267
268 vec2 classicParallaxOffset(sampler2D parallaxMap, vec3 vViewDir,vec2 texCoord,float parallaxScale){
269 float h;
270 #ifdef NORMALMAP_PARALLAX
271 //parallax map is stored in the alpha channel of the normal map
272 h = texture2D(parallaxMap, texCoord).a;
273 #else
274 //parallax map is a texture
275 h = texture2D(parallaxMap, texCoord).r;
276 #endif
277 float heightScale = parallaxScale;
278 float heightBias = heightScale* -0.6;
279 vec3 normView = normalize(vViewDir);
280 h = (h * heightScale + heightBias) * normView.z;
281 return texCoord + (h * normView.xy);
282 }
283 #endif
284 // -- end import Common/ShaderLib/Parallax.glsllib --
285 // -- begin import Common/ShaderLib/Lighting.glsllib --
286 /*Common function for light calculations*/
287
288
289 /*
290 * Computes light direction
291 * lightType should be 0.0,1.0,2.0, repectively for Directional, point and spot lights.
292 * Outputs the light direction and the light half vector.
293 */
294 void lightComputeDir(in vec3 worldPos, in float lightType, in vec4 position, out vec4 lightDir, out vec3 lightVec){
295 float posLight = step(0.5, lightType);
296 vec3 tempVec = position.xyz * sign(posLight - 0.5) - (worldPos * posLight);
297 lightVec = tempVec;
298 float dist = length(tempVec);
299 #ifdef SRGB
300 lightDir.w = (1.0 - position.w * dist) / (1.0 + position.w * dist * dist);
301 lightDir.w = clamp(lightDir.w, 1.0 - posLight, 1.0);
302 #else
303 lightDir.w = clamp(1.0 - position.w * dist * posLight, 0.0, 1.0);
304 #endif
305 lightDir.xyz = tempVec / vec3(dist);
306 }
307
308 /*
309 * Computes the spot falloff for a spotlight
310 */
311 float computeSpotFalloff(in vec4 lightDirection, in vec3 lightVector){
312 vec3 L=normalize(lightVector);
313 vec3 spotdir = normalize(lightDirection.xyz);
314 float curAngleCos = dot(-L, spotdir);
315 float innerAngleCos = floor(lightDirection.w) * 0.001;
316 float outerAngleCos = fract(lightDirection.w);
317 float innerMinusOuter = innerAngleCos - outerAngleCos;
318 float falloff = clamp((curAngleCos - outerAngleCos) / innerMinusOuter, step(lightDirection.w, 0.001), 1.0);
319
320 #ifdef SRGB
321 // Use quadratic falloff (notice the ^4)
322 return pow(clamp((curAngleCos - outerAngleCos) / innerMinusOuter, 0.0, 1.0), 4.0);
323 #else
324 // Use linear falloff
325 return falloff;
326 #endif
327 }
328
329 // -- end import Common/ShaderLib/Lighting.glsllib --
330
331
332 varying vec2 texCoord;
333 #ifdef SEPARATE_TEXCOORD
334 varying vec2 texCoord2;
335 #endif
336
337 #ifndef BASECOLORMAP
338 varying vec4 Color;
339 #endif
340
341 uniform vec4 g_LightData[NB_LIGHTS];
342
343 uniform vec3 g_CameraPosition;
344
345 uniform float m_Roughness;
346 uniform float m_Metallic;
347
348 varying vec3 wPosition;
349
350
351 #ifdef INDIRECT_LIGHTING
352 // uniform sampler2D m_IntegrateBRDF;
353 uniform samplerCube g_PrefEnvMap;
354 uniform samplerCube g_IrradianceMap;
355 uniform vec4 g_LightProbeData;
356 #endif
357
358 #ifdef BASECOLORMAP
359 uniform sampler2D m_BaseColorMap;
360 #endif
361 #ifdef METALLICMAP
362 uniform sampler2D m_MetallicMap;
363 #endif
364 #ifdef ROUGHNESSMAP
365 uniform sampler2D m_RoughnessMap;
366 #endif
367
368 #ifdef EMISSIVE
369 uniform vec4 m_Emissive;
370 #endif
371 #ifdef EMISSIVEMAP
372 uniform sampler2D m_EmissiveMap;
373 #endif
374 #if defined(EMISSIVE) || defined(EMISSIVEMAP)
375 uniform float m_EmissivePower;
376 uniform float m_EmissiveIntensity;
377 #endif
378
379 #ifdef SPECGLOSSPIPELINE
380 uniform sampler2D m_SpecularMap;
381 uniform sampler2D m_GlossMap;
382 #endif
383
384 #ifdef PARALLAXMAP
385 uniform sampler2D m_ParallaxMap;
386 #endif
387 #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP)))
388 uniform float m_ParallaxHeight;
389 #endif
390
391 #ifdef LIGHTMAP
392 uniform sampler2D m_LightMap;
393 #endif
394
395 #if defined(NORMALMAP) || defined(PARALLAXMAP)
396 uniform sampler2D m_NormalMap;
397 varying vec4 wTangent;
398 #endif
399 varying vec3 wNormal;
400
401 #ifdef DISCARD_ALPHA
402 uniform float m_AlphaDiscardThreshold;
403 #endif
404
405 void main(){
406 vec2 newTexCoord;
407 vec3 viewDir = normalize(g_CameraPosition - wPosition);
408
409 #if defined(NORMALMAP) || defined(PARALLAXMAP)
410 mat3 tbnMat = mat3(wTangent.xyz, wTangent.w * cross( (wNormal), (wTangent.xyz)), wNormal.xyz);
411 #endif
412
413 #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP)))
414 vec3 vViewDir = viewDir * tbnMat;
415 #ifdef STEEP_PARALLAX
416 #ifdef NORMALMAP_PARALLAX
417 //parallax map is stored in the alpha channel of the normal map
418 newTexCoord = steepParallaxOffset(m_NormalMap, vViewDir, texCoord, m_ParallaxHeight);
419 #else
420 //parallax map is a texture
421 newTexCoord = steepParallaxOffset(m_ParallaxMap, vViewDir, texCoord, m_ParallaxHeight);
422 #endif
423 #else
424 #ifdef NORMALMAP_PARALLAX
425 //parallax map is stored in the alpha channel of the normal map
426 newTexCoord = classicParallaxOffset(m_NormalMap, vViewDir, texCoord, m_ParallaxHeight);
427 #else
428 //parallax map is a texture
429 newTexCoord = classicParallaxOffset(m_ParallaxMap, vViewDir, texCoord, m_ParallaxHeight);
430 #endif
431 #endif
432 #else
433 newTexCoord = texCoord;
434 #endif
435
436 #ifdef BASECOLORMAP
437 vec4 albedo = texture2D(m_BaseColorMap, newTexCoord);
438 #else
439 vec4 albedo = Color;
440 #endif
441 #ifdef ROUGHNESSMAP
442 float Roughness = texture2D(m_RoughnessMap, newTexCoord).r * max(m_Roughness, 1e-8);
443 #else
444 float Roughness = max(m_Roughness, 1e-8);
445 #endif
446 #ifdef METALLICMAP
447 float Metallic = texture2D(m_MetallicMap, newTexCoord).r;
448 #else
449 float Metallic = max(m_Metallic, 0.0);
450 #endif
451
452 float alpha = albedo.a;
453
454 #ifdef DISCARD_ALPHA
455 if(alpha < m_AlphaDiscardThreshold){
456 discard;
457 }
458 #endif
459
460 // ***********************
461 // Read from textures
462 // ***********************
463 #if defined(NORMALMAP)
464 vec4 normalHeight = texture2D(m_NormalMap, newTexCoord);
465 //Note the -2.0 and -1.0. We invert the green channel of the normal map,
466 //as it's complient with normal maps generated with blender.
467 //see http://hub.jmonkeyengine.org/forum/topic/parallax-mapping-fundamental-bug/#post-256898
468 //for more explanation.
469 vec3 normal = normalize((normalHeight.xyz * vec3(2.0,-2.0,2.0) - vec3(1.0,-1.0,1.0)));
470 normal = normalize(tbnMat * normal);
471 //normal = normalize(normal * inverse(tbnMat));
472 #else
473 vec3 normal = normalize(wNormal);
474 #endif
475
476
477 #ifdef LIGHTMAP
478 vec3 lightMapColor;
479 #ifdef SEPARATE_TEXCOORD
480 lightMapColor = texture2D(m_LightMap, texCoord2).rgb;
481 #else
482 lightMapColor = texture2D(m_LightMap, texCoord).rgb;
483 #endif
484 specularColor.rgb *= lightMapColor;
485 albedo.rgb *= lightMapColor;
486 #endif
487
488 float specular = 0.5;
489 #ifdef SPECGLOSSPIPELINE
490 vec4 specularColor = texture2D(m_SpecularMap, newTexCoord);
491 vec4 diffuseColor = albedo;
492 Roughness = 1.0 - texture2D(m_GlossMap, newTexCoord).r;
493 #else
494 float nonMetalSpec = 0.08 * specular;
495 vec4 specularColor = (nonMetalSpec - nonMetalSpec * Metallic) + albedo * Metallic;
496 vec4 diffuseColor = albedo - albedo * Metallic;
497 #endif
498
499 gl_FragColor.rgb = vec3(0.0);
500 float ndotv = max( dot( normal, viewDir ),0.0);
501 for( int i = 0;i < NB_LIGHTS; i+=3){
502 vec4 lightColor = g_LightData[i];
503 vec4 lightData1 = g_LightData[i+1];
504 vec4 lightDir;
505 vec3 lightVec;
506 lightComputeDir(wPosition, lightColor.w, lightData1, lightDir, lightVec);
507
508 float fallOff = 1.0;
509 #if __VERSION__ >= 110
510 // allow use of control flow
511 if(lightColor.w > 1.0){
512 #endif
513 fallOff = computeSpotFalloff(g_LightData[i+2], lightVec);
514 #if __VERSION__ >= 110
515 }
516 #endif
517 //point light attenuation
518 fallOff *= lightDir.w;
519
520 lightDir.xyz = normalize(lightDir.xyz);
521 vec3 directDiffuse;
522 vec3 directSpecular;
523
524 PBR_ComputeDirectLight(normal, lightDir.xyz, viewDir,
525 lightColor.rgb,specular, Roughness, ndotv,
526 directDiffuse, directSpecular);
527
528 vec3 directLighting = diffuseColor.rgb *directDiffuse + directSpecular * specularColor.rgb;
529
530 gl_FragColor.rgb += directLighting * fallOff;
531 }
532
533 #ifdef INDIRECT_LIGHTING
534 vec3 rv = reflect(-viewDir.xyz, normal.xyz);
535 //prallax fix for spherical bounds from https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
536 // g_LightProbeData.w is 1/probe radius, g_LightProbeData.xyz is the position of the lightProbe.
537 rv = g_LightProbeData.w * (wPosition - g_LightProbeData.xyz) +rv;
538
539 //horizon fade from http://marmosetco.tumblr.com/post/81245981087
540 float horiz = dot(rv, wNormal.xyz);
541 float horizFadePower= 1.0 - Roughness;
542 horiz = clamp( 1.0 + horizFadePower * horiz, 0.0, 1.0 );
543 horiz *= horiz;
544
545 vec3 indirectDiffuse = vec3(0.0);
546 vec3 indirectSpecular = vec3(0.0);
547 indirectDiffuse = textureCube(g_IrradianceMap, normal.xyz).rgb * diffuseColor.rgb;
548
549 indirectSpecular = ApproximateSpecularIBLPolynomial(g_PrefEnvMap, specularColor.rgb, Roughness, ndotv, rv.xyz);
550 indirectSpecular *= vec3(horiz);
551
552 vec3 indirectLighting = indirectDiffuse + indirectSpecular;
553
554 gl_FragColor.rgb = gl_FragColor.rgb + indirectLighting * step( 0.0, g_LightProbeData.w);
555 #endif
556
557 #if defined(EMISSIVE) || defined (EMISSIVEMAP)
558 #ifdef EMISSIVEMAP
559 vec4 emissive = texture2D(m_EmissiveMap, newTexCoord);
560 #else
561 vec4 emissive = m_Emissive;
562 #endif
563 gl_FragColor += emissive * pow(emissive.a, m_EmissivePower) * m_EmissiveIntensity;
564 #endif
565
566 gl_FragColor.a = alpha;
567
568
569 }
WARNING 21:13:47:543 Editor: com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Light/PBRLighting.frag, defines, type=Fragment, language=GLSL150]
0(484) : error C1008: undefined variable "specularColor"
at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1244)
at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1271)
Iāll look into it. But can I have a bit of context?
How I remember, I just added specular map to a material and specular color at the same time.
I have updated my editor:
ver. 0.9.3
-Added a bullet app state to scene editor.
-Added supporting debug physics to a bullet app state.
-Added supporting editing rigid/vehicle/character controls.
-Added actions to make collision shapes.
-Added supporting creating/editing vehicle wheels.
-Updated working with layers in scene editor.
-Some fixes and improvements.
I fixed this issue in master.
Man, iām so envy with your editorās features and progress of development I have to say it out loud (pun indented)ā¦
Visit this thread everyday looking for something new and never disapointed. Read through the source code also. Officially become your fan today
FYI, I will also release my editor based in JavaFX soon, because this is the spirit we need in Open source world, create new better things! Keep up good work!
Me: āHey javasabr, could you add time travel as part of this editorā
javasabr: āOk let me work on thatā
[37 minutes ago]
javasabr: āOk itās done please testā
thanks, I will include it to the version 0.9.4.