瀏覽代碼

Update shaders_basic_pbr example to work on web (#4516)

* basic pbr example

pbr implementation  includes rpbr.h and few shader files header only file, which self contain everything needed for pbr rendering. Few textures and one model of the car which is under free licence which is included inside basic_pbr.c example file  currently supported shader versions are 120 and 330 , version 100 has small issue which I have to resolve

* Unloading PBRMAterial

I forgot unloading PBRMaterial

* fix small issue with texOffset assigment.

value was Vector4 at first but I found out it would be unclear for and users, so I change to have two Vector2 instead, but forgot to assign offset .

* Changed size of textures and file name changed

Changed size of textures from 2048x2048 to 1024x1024 and file name changed to shaders_basic_pbr.c ,
Added the function PBRModel PBRModelLoadFromMesh(Mesh mesh);
but GenMeshPlane(2, 2.0, 3, 3) culdn't be used because it crash once GenMeshTangents() is used with that plane mesh

* Update to 5.5 version  of eexample and fix to work in web

set GLSL_VERSION            100

set precision highp float;
removed in keyword
fix for loop has to use only constant

* Update shader_basic_pbr example to work on web

changed to GLSL_VERSION            100
update glsl100 shader
set float  precision  to highp
removed keyword  in
change for loop tu use constant value  gives an error

* Update shader_basic_pbr example to work on web

changed to GLSL_VERSION            100
update glsl100 shader
set float  precision  to highp
removed keyword  in
change for loop tu use constant value  gives an error

* removed rpbr.h

removed rpbr.h
pull/4523/head
devdad 4 週之前
committed by GitHub
父節點
當前提交
6af664c04e
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: B5690EEEBB952194
共有 2 個檔案被更改,包括 9 行新增9 行删除
  1. +8
    -8
      examples/shaders/resources/shaders/glsl100/pbr.fs
  2. +1
    -1
      examples/shaders/shaders_basic_pbr.c

+ 8
- 8
examples/shaders/resources/shaders/glsl100/pbr.fs 查看文件

@ -1,6 +1,6 @@
#version 100
precision mediump float;
precision highp float;
#define MAX_LIGHTS 4
#define LIGHT_DIRECTIONAL 0
@ -17,12 +17,12 @@ struct Light {
};
// Input vertex attributes (from vertex shader)
varying in vec3 fragPosition;
varying in vec2 fragTexCoord;
varying in vec4 fragColor;
varying in vec3 fragNormal;
varying in vec4 shadowPos;
varying in mat3 TBN;
varying vec3 fragPosition;
varying vec2 fragTexCoord;
varying vec4 fragColor;
varying vec3 fragNormal;
varying vec4 shadowPos;
varying mat3 TBN;
// Input uniform values
@ -113,7 +113,7 @@ vec3 pbr(){
vec3 baseRefl = mix(vec3(0.04),albedo.rgb,metallic);
vec3 Lo = vec3(0.0); // acumulate lighting lum
for(int i=0;i<err">numOfLights;++i){
for(int i=0;i<mi">4;++i){
vec3 L = normalize(lights[i].position - fragPosition); // calc light vector
vec3 H = normalize(V + L); // calc halfway bisecting vector

+ 1
- 1
examples/shaders/shaders_basic_pbr.c 查看文件

@ -22,7 +22,7 @@
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
#else // PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 120
#define GLSL_VERSION 100
#endif
#include <stdlib.h> // Required for: NULL

Loading…
取消
儲存