Skip to content

Commit

Permalink
fix pbr shader compile issue
Browse files Browse the repository at this point in the history
  • Loading branch information
NolaDonato committed Jun 13, 2018
1 parent 7e44840 commit 75c0f73
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/
public class GVRShader
{
protected boolean mWriteShadersToDisk = false;
protected boolean mWriteShadersToDisk = true;
protected GLSLESVersion mGLSLVersion = GLSLESVersion.V100;
protected boolean mHasVariants = false;
protected boolean mUsesLights = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class GVRPBRShader extends GVRShaderTemplate
public GVRPBRShader(GVRContext gvrcontext)
{
super("float4 diffuse_color; float4 specular_color; float4 emissive_color; float metallic; float roughness; float specular_exponent; float lightmapStrength; float normalScale; float glossinessFactor",
"sampler2D diffuseTexture; sampler2D metallicRoughnessTexture; sampler2D specularTexture; sampler2D lightmapTexture; sampler2D diffuseTexture1; sampler2D normalTexture; sampler2D emissiveTexture; sampler2D brdfLUTTexture; samplerCube diffuseEnvTex; samplerCube specularEnvTexture",
"sampler2D diffuseTexture; sampler2D metallicRoughnessTexture; sampler2D specularTexture; sampler2D lightmapTexture; sampler2D normalTexture; sampler2D emissiveTexture; sampler2D brdfLUTTexture; samplerCube diffuseEnvTex; samplerCube specularEnvTexture",
"float3 a_position float2 a_texcoord float2 a_texcoord1 float2 a_texcoord2 float2 a_texcoord3 float3 a_normal float4 a_bone_weights int4 a_bone_indices float4 a_tangent float4 a_bitangent",
GLSLESVersion.VULKAN);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ struct Radiance

@FragmentSurface

#ifdef HAS_LIGHTSOURCES
@FragmentAddLight
#endif

@LIGHTSOURCES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ float unpackFloatFromVec4i(const vec4 value)

@FragmentSurface

#ifdef HAS_LIGHTSOURCES
@FragmentAddLight
#endif

@LIGHTSOURCES

Expand Down
10 changes: 2 additions & 8 deletions GVRf/Framework/framework/src/main/res/raw/pbr_addlight.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,8 @@ vec4 AddLight(Surface s, Radiance r)
// Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
vec3 color = NdotL * ((r.diffuse_intensity * kD) + (r.specular_intensity * kS)) + s.emission.xyz;

mat4 view_i;
#ifdef HAS_MULTIVIEW
view_i = u_view_i_[gl_ViewID_OVR];
#else
view_i = u_view_i;
#endif
color += getIBLContribution(s.roughness, NdotV, (view_i * vec4(n, 1.0)).xyz,
(view_i * vec4(reflection, 1.0)).xyz, s.specular, s.diffuse.xyz);
color += getIBLContribution(s.roughness, NdotV, (u_view_i * vec4(n, 1.0)).xyz,
(u_view_i * vec4(reflection, 1.0)).xyz, s.specular, s.diffuse.xyz);

#ifdef HAS_lightmapTexture
float ao = texture(lightmapTexture, lightmap_coord).r;
Expand Down

0 comments on commit 75c0f73

Please sign in to comment.