Reflection map framework in progress
--HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4055
This commit is contained in:
@@ -43,6 +43,7 @@ KRCamera::KRCamera() {
|
|||||||
bEnableDiffuseMap = true;
|
bEnableDiffuseMap = true;
|
||||||
bEnableNormalMap = true;
|
bEnableNormalMap = true;
|
||||||
bEnableSpecMap = true;
|
bEnableSpecMap = true;
|
||||||
|
bEnableReflectionMap = true;
|
||||||
bDebugPSSM = false;
|
bDebugPSSM = false;
|
||||||
bEnableAmbient = true;
|
bEnableAmbient = true;
|
||||||
bEnableDiffuse = true;
|
bEnableDiffuse = true;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public:
|
|||||||
bool bEnableDiffuseMap;
|
bool bEnableDiffuseMap;
|
||||||
bool bEnableNormalMap;
|
bool bEnableNormalMap;
|
||||||
bool bEnableSpecMap;
|
bool bEnableSpecMap;
|
||||||
|
bool bEnableReflectionMap;
|
||||||
bool bEnableLightMap;
|
bool bEnableLightMap;
|
||||||
bool bDebugPSSM;
|
bool bDebugPSSM;
|
||||||
bool bDebugSuperShiny;
|
bool bDebugSuperShiny;
|
||||||
|
|||||||
@@ -907,12 +907,12 @@ double const PI = 3.141592653589793f;
|
|||||||
|
|
||||||
-(int)getParameterCount
|
-(int)getParameterCount
|
||||||
{
|
{
|
||||||
return 32;
|
return 33;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSString *)getParameterNameWithIndex: (int)i
|
-(NSString *)getParameterNameWithIndex: (int)i
|
||||||
{
|
{
|
||||||
NSString *parameter_names[32] = {
|
NSString *parameter_names[33] = {
|
||||||
@"camera_fov",
|
@"camera_fov",
|
||||||
@"sun_direction",
|
@"sun_direction",
|
||||||
@"sun_attitude",
|
@"sun_attitude",
|
||||||
@@ -921,6 +921,7 @@ double const PI = 3.141592653589793f;
|
|||||||
@"enable_diffuse_map",
|
@"enable_diffuse_map",
|
||||||
@"enable_normal_map",
|
@"enable_normal_map",
|
||||||
@"enable_spec_map",
|
@"enable_spec_map",
|
||||||
|
@"enable_reflection_map",
|
||||||
@"enable_light_map",
|
@"enable_light_map",
|
||||||
@"ambient_r",
|
@"ambient_r",
|
||||||
@"ambient_g",
|
@"ambient_g",
|
||||||
@@ -950,7 +951,7 @@ double const PI = 3.141592653589793f;
|
|||||||
}
|
}
|
||||||
-(NSString *)getParameterLabelWithIndex: (int)i
|
-(NSString *)getParameterLabelWithIndex: (int)i
|
||||||
{
|
{
|
||||||
NSString *parameter_labels[32] = {
|
NSString *parameter_labels[33] = {
|
||||||
@"Camera FOV",
|
@"Camera FOV",
|
||||||
@"Sun Direction",
|
@"Sun Direction",
|
||||||
@"Sun Attitude",
|
@"Sun Attitude",
|
||||||
@@ -959,6 +960,7 @@ double const PI = 3.141592653589793f;
|
|||||||
@"Enable diffuse map",
|
@"Enable diffuse map",
|
||||||
@"Enable normal map",
|
@"Enable normal map",
|
||||||
@"Enable specular map",
|
@"Enable specular map",
|
||||||
|
@"Enable reflection map",
|
||||||
@"Enable light map",
|
@"Enable light map",
|
||||||
@"Ambient light red intensity",
|
@"Ambient light red intensity",
|
||||||
@"Ambient light green intensity",
|
@"Ambient light green intensity",
|
||||||
@@ -988,7 +990,7 @@ double const PI = 3.141592653589793f;
|
|||||||
}
|
}
|
||||||
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
||||||
{
|
{
|
||||||
KREngineParameterType types[32] = {
|
KREngineParameterType types[33] = {
|
||||||
|
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
@@ -999,6 +1001,7 @@ double const PI = 3.141592653589793f;
|
|||||||
KRENGINE_PARAMETER_BOOL,
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_BOOL,
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_BOOL,
|
KRENGINE_PARAMETER_BOOL,
|
||||||
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
@@ -1027,7 +1030,7 @@ double const PI = 3.141592653589793f;
|
|||||||
}
|
}
|
||||||
-(double)getParameterValueWithIndex: (int)i
|
-(double)getParameterValueWithIndex: (int)i
|
||||||
{
|
{
|
||||||
double values[32] = {
|
double values[33] = {
|
||||||
m_camera.perspective_fov,
|
m_camera.perspective_fov,
|
||||||
sun_yaw,
|
sun_yaw,
|
||||||
sun_pitch,
|
sun_pitch,
|
||||||
@@ -1036,6 +1039,7 @@ double const PI = 3.141592653589793f;
|
|||||||
m_camera.bEnableDiffuseMap ? 1.0f : 0.0f,
|
m_camera.bEnableDiffuseMap ? 1.0f : 0.0f,
|
||||||
m_camera.bEnableNormalMap ? 1.0f : 0.0f,
|
m_camera.bEnableNormalMap ? 1.0f : 0.0f,
|
||||||
m_camera.bEnableSpecMap ? 1.0f : 0.0f,
|
m_camera.bEnableSpecMap ? 1.0f : 0.0f,
|
||||||
|
m_camera.bEnableReflectionMap ? 1.0f : 0.0f,
|
||||||
m_camera.bEnableLightMap ? 1.0f : 0.0f,
|
m_camera.bEnableLightMap ? 1.0f : 0.0f,
|
||||||
m_camera.dAmbientR,
|
m_camera.dAmbientR,
|
||||||
m_camera.dAmbientG,
|
m_camera.dAmbientG,
|
||||||
@@ -1099,117 +1103,120 @@ double const PI = 3.141592653589793f;
|
|||||||
m_camera.bEnableSpecMap = bNewBoolVal;
|
m_camera.bEnableSpecMap = bNewBoolVal;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
m_camera.bEnableLightMap = bNewBoolVal;
|
m_camera.bEnableReflectionMap = bNewBoolVal;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
m_camera.dAmbientR = v;
|
m_camera.bEnableLightMap = bNewBoolVal;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
m_camera.dAmbientG = v;
|
m_camera.dAmbientR = v;
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
m_camera.dAmbientB = v;
|
m_camera.dAmbientG = v;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
m_camera.dSunR = v;
|
m_camera.dAmbientB = v;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
m_camera.dSunG = v;
|
m_camera.dSunR = v;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
m_camera.dSunB = v;
|
m_camera.dSunG = v;
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
|
m_camera.dSunB = v;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
if(m_camera.dof_quality != (int)v) {
|
if(m_camera.dof_quality != (int)v) {
|
||||||
m_camera.dof_quality = (int)v;
|
m_camera.dof_quality = (int)v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 17:
|
||||||
if(m_camera.dof_depth != v) {
|
if(m_camera.dof_depth != v) {
|
||||||
m_camera.dof_depth = v;
|
m_camera.dof_depth = v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 17:
|
case 18:
|
||||||
if(m_camera.dof_falloff != v) {
|
if(m_camera.dof_falloff != v) {
|
||||||
m_camera.dof_falloff = v;
|
m_camera.dof_falloff = v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 19:
|
||||||
if(m_camera.bEnableFlash != bNewBoolVal) {
|
if(m_camera.bEnableFlash != bNewBoolVal) {
|
||||||
m_camera.bEnableFlash = bNewBoolVal;
|
m_camera.bEnableFlash = bNewBoolVal;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 19:
|
case 20:
|
||||||
if(m_camera.flash_intensity != v) {
|
if(m_camera.flash_intensity != v) {
|
||||||
m_camera.flash_intensity = v;
|
m_camera.flash_intensity = v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 21:
|
||||||
if(m_camera.flash_depth != v) {
|
if(m_camera.flash_depth != v) {
|
||||||
m_camera.flash_depth = v;
|
m_camera.flash_depth = v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 22:
|
||||||
if(m_camera.flash_falloff != v) {
|
if(m_camera.flash_falloff != v) {
|
||||||
m_camera.flash_falloff = v;
|
m_camera.flash_falloff = v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 23:
|
||||||
if(m_camera.bEnableVignette != bNewBoolVal) {
|
if(m_camera.bEnableVignette != bNewBoolVal) {
|
||||||
m_camera.bEnableVignette = bNewBoolVal;
|
m_camera.bEnableVignette = bNewBoolVal;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 23:
|
case 24:
|
||||||
if(m_camera.vignette_radius != v) {
|
if(m_camera.vignette_radius != v) {
|
||||||
m_camera.vignette_radius = v;
|
m_camera.vignette_radius = v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 25:
|
||||||
if(m_camera.vignette_falloff != v) {
|
if(m_camera.vignette_falloff != v) {
|
||||||
m_camera.vignette_falloff = v;
|
m_camera.vignette_falloff = v;
|
||||||
[self invalidatePostShader];
|
[self invalidatePostShader];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 26:
|
||||||
if(m_camera.bShowShadowBuffer != bNewBoolVal) {
|
if(m_camera.bShowShadowBuffer != bNewBoolVal) {
|
||||||
m_camera.bShowShadowBuffer = bNewBoolVal;
|
m_camera.bShowShadowBuffer = bNewBoolVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 26:
|
case 27:
|
||||||
if(m_camera.bDebugPSSM != bNewBoolVal) {
|
if(m_camera.bDebugPSSM != bNewBoolVal) {
|
||||||
m_camera.bDebugPSSM = bNewBoolVal;
|
m_camera.bDebugPSSM = bNewBoolVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 28:
|
||||||
if(m_camera.bEnableAmbient != bNewBoolVal) {
|
if(m_camera.bEnableAmbient != bNewBoolVal) {
|
||||||
m_camera.bEnableAmbient = bNewBoolVal;
|
m_camera.bEnableAmbient = bNewBoolVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 28:
|
case 29:
|
||||||
if(m_camera.bEnableDiffuse != bNewBoolVal) {
|
if(m_camera.bEnableDiffuse != bNewBoolVal) {
|
||||||
m_camera.bEnableDiffuse = bNewBoolVal;
|
m_camera.bEnableDiffuse = bNewBoolVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 29:
|
case 30:
|
||||||
if(m_camera.bEnableSpecular != bNewBoolVal) {
|
if(m_camera.bEnableSpecular != bNewBoolVal) {
|
||||||
m_camera.bEnableSpecular = bNewBoolVal;
|
m_camera.bEnableSpecular = bNewBoolVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 31:
|
||||||
if(m_camera.bDebugSuperShiny != bNewBoolVal) {
|
if(m_camera.bDebugSuperShiny != bNewBoolVal) {
|
||||||
m_camera.bDebugSuperShiny = bNewBoolVal;
|
m_camera.bDebugSuperShiny = bNewBoolVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 31:
|
case 32:
|
||||||
if(m_camera.bEnableDeferredLighting != bNewBoolVal) {
|
if(m_camera.bEnableDeferredLighting != bNewBoolVal) {
|
||||||
m_camera.bEnableDeferredLighting = bNewBoolVal;
|
m_camera.bEnableDeferredLighting = bNewBoolVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,27 +45,27 @@ KRMaterial::KRMaterial(const char *szName) : KRResource(szName) {
|
|||||||
m_pDiffuseMap = NULL;
|
m_pDiffuseMap = NULL;
|
||||||
m_pSpecularMap = NULL;
|
m_pSpecularMap = NULL;
|
||||||
m_pNormalMap = NULL;
|
m_pNormalMap = NULL;
|
||||||
m_ka_r = (GLfloat)0.0f;
|
m_pReflectionMap = NULL;
|
||||||
m_ka_g = (GLfloat)0.0f;
|
m_ambientColor = KRVector3(0.0f, 0.0f, 0.0f);
|
||||||
m_ka_b = (GLfloat)0.0f;
|
m_diffuseColor = KRVector3(1.0f, 1.0f, 1.0f);
|
||||||
m_kd_r = (GLfloat)1.0f;
|
m_specularColor = KRVector3(1.0f, 1.0f, 1.0f);
|
||||||
m_kd_g = (GLfloat)1.0f;
|
m_reflectionColor = KRVector3(1.0f, 1.0f, 1.0f);
|
||||||
m_kd_b = (GLfloat)1.0f;
|
|
||||||
m_ks_r = (GLfloat)1.0f;
|
|
||||||
m_ks_g = (GLfloat)1.0f;
|
|
||||||
m_ks_b = (GLfloat)1.0f;
|
|
||||||
m_tr = (GLfloat)0.0f;
|
m_tr = (GLfloat)0.0f;
|
||||||
m_ns = (GLfloat)0.0f;
|
m_ns = (GLfloat)0.0f;
|
||||||
m_ambientMap = "";
|
m_ambientMap = "";
|
||||||
m_diffuseMap = "";
|
m_diffuseMap = "";
|
||||||
m_specularMap = "";
|
m_specularMap = "";
|
||||||
m_normalMap = "";
|
m_normalMap = "";
|
||||||
|
m_reflectionMap = "";
|
||||||
m_ambientMapOffset = KRVector2(0.0f, 0.0f);
|
m_ambientMapOffset = KRVector2(0.0f, 0.0f);
|
||||||
m_specularMapOffset = KRVector2(0.0f, 0.0f);
|
m_specularMapOffset = KRVector2(0.0f, 0.0f);
|
||||||
m_diffuseMapOffset = KRVector2(0.0f, 0.0f);
|
m_diffuseMapOffset = KRVector2(0.0f, 0.0f);
|
||||||
m_ambientMapScale = KRVector2(1.0f, 1.0f);
|
m_ambientMapScale = KRVector2(1.0f, 1.0f);
|
||||||
m_specularMapScale = KRVector2(1.0f, 1.0f);
|
m_specularMapScale = KRVector2(1.0f, 1.0f);
|
||||||
m_diffuseMapScale = KRVector2(1.0f, 1.0f);
|
m_diffuseMapScale = KRVector2(1.0f, 1.0f);
|
||||||
|
m_reflectionMapOffset = KRVector2(0.0f, 0.0f);
|
||||||
|
m_reflectionMapScale = KRVector2(1.0f, 1.0f);
|
||||||
|
m_reflectionFactor = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMaterial::~KRMaterial() {
|
KRMaterial::~KRMaterial() {
|
||||||
@@ -82,11 +82,13 @@ bool KRMaterial::save(const std::string& path) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
fprintf(f, "newmtl %s\n", m_szName);
|
fprintf(f, "newmtl %s\n", m_szName);
|
||||||
fprintf(f, "ka %f %f %f\n", m_ka_r, m_ka_g, m_ka_b);
|
fprintf(f, "ka %f %f %f\n", m_ambientColor.x, m_ambientColor.y, m_ambientColor.z);
|
||||||
fprintf(f, "kd %f %f %f\n", m_kd_r, m_kd_g, m_kd_b);
|
fprintf(f, "kd %f %f %f\n", m_diffuseColor.x, m_diffuseColor.y, m_diffuseColor.z);
|
||||||
fprintf(f, "ks %f %f %f\n", m_ks_r, m_ks_g, m_ks_b);
|
fprintf(f, "ks %f %f %f\n", m_specularColor.x, m_specularColor.y, m_specularColor.z);
|
||||||
|
fprintf(f, "kr %f %f %f\n", m_reflectionColor.x, m_reflectionColor.y, m_reflectionColor.z);
|
||||||
fprintf(f, "Tr %f\n", m_tr);
|
fprintf(f, "Tr %f\n", m_tr);
|
||||||
fprintf(f, "Ns %f\n", m_ns);
|
fprintf(f, "Ns %f\n", m_ns);
|
||||||
|
fprintf(f, "reflectionFactor %f\n", m_reflectionFactor);
|
||||||
if(m_ambientMap.size()) {
|
if(m_ambientMap.size()) {
|
||||||
fprintf(f, "map_Ka %s.pvr -s %f %f -o %f %f\n", m_ambientMap.c_str(), m_ambientMapScale.x, m_ambientMapScale.y, m_ambientMapOffset.x, m_ambientMapOffset.y);
|
fprintf(f, "map_Ka %s.pvr -s %f %f -o %f %f\n", m_ambientMap.c_str(), m_ambientMapScale.x, m_ambientMapScale.y, m_ambientMapOffset.x, m_ambientMapOffset.y);
|
||||||
}
|
}
|
||||||
@@ -99,6 +101,9 @@ bool KRMaterial::save(const std::string& path) {
|
|||||||
if(m_normalMap.size()) {
|
if(m_normalMap.size()) {
|
||||||
fprintf(f, "map_Normal %s.pvr -s %f %f -o %f %f\n", m_normalMap.c_str(), m_normalMapScale.x, m_normalMapScale.y, m_normalMapOffset.x, m_normalMapOffset.y);
|
fprintf(f, "map_Normal %s.pvr -s %f %f -o %f %f\n", m_normalMap.c_str(), m_normalMapScale.x, m_normalMapScale.y, m_normalMapOffset.x, m_normalMapOffset.y);
|
||||||
}
|
}
|
||||||
|
if(m_reflectionMap.size()) {
|
||||||
|
fprintf(f, "map_Reflection %s.pvr -s %f %f -o %f %f\n", m_reflectionMap.c_str(), m_reflectionMapScale.x, m_reflectionMapScale.y, m_reflectionMapOffset.x, m_reflectionMapOffset.y);
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -128,22 +133,26 @@ void KRMaterial::setNormalMap(std::string texture_name, KRVector2 texture_scale,
|
|||||||
m_normalMapOffset = texture_offset;
|
m_normalMapOffset = texture_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMaterial::setAmbient(GLfloat r, GLfloat g, GLfloat b) {
|
void KRMaterial::setReflectionMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset) {
|
||||||
m_ka_r = r;
|
m_reflectionMap = texture_name;
|
||||||
m_ka_g = g;
|
m_reflectionMapScale = texture_scale;
|
||||||
m_ka_b = b;
|
m_reflectionMapOffset = texture_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMaterial::setDiffuse(GLfloat r, GLfloat g, GLfloat b) {
|
void KRMaterial::setAmbient(const KRVector3 &c) {
|
||||||
m_kd_r = r;
|
m_ambientColor = c;
|
||||||
m_kd_g = g;
|
|
||||||
m_kd_b = b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMaterial::setSpecular(GLfloat r, GLfloat g, GLfloat b) {
|
void KRMaterial::setDiffuse(const KRVector3 &c) {
|
||||||
m_ks_r = r;
|
m_diffuseColor = c;
|
||||||
m_ks_g = g;
|
}
|
||||||
m_ks_b = b;
|
|
||||||
|
void KRMaterial::setSpecular(const KRVector3 &c) {
|
||||||
|
m_specularColor = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRMaterial::setReflection(const KRVector3 &c) {
|
||||||
|
m_reflectionColor = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMaterial::setTransparency(GLfloat a) {
|
void KRMaterial::setTransparency(GLfloat a) {
|
||||||
@@ -154,6 +163,10 @@ void KRMaterial::setShininess(GLfloat s) {
|
|||||||
m_ns = s;
|
m_ns = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRMaterial::setReflectionFactor(GLfloat r) {
|
||||||
|
m_reflectionFactor = r;
|
||||||
|
}
|
||||||
|
|
||||||
bool KRMaterial::isTransparent() {
|
bool KRMaterial::isTransparent() {
|
||||||
return m_tr != 0.0;
|
return m_tr != 0.0;
|
||||||
}
|
}
|
||||||
@@ -174,10 +187,9 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
if(!m_pSpecularMap && m_specularMap.size()) {
|
if(!m_pSpecularMap && m_specularMap.size()) {
|
||||||
m_pSpecularMap = pContext->getTextureManager()->getTexture(m_specularMap.c_str());
|
m_pSpecularMap = pContext->getTextureManager()->getTexture(m_specularMap.c_str());
|
||||||
}
|
}
|
||||||
|
if(!m_pReflectionMap && m_reflectionMap.size()) {
|
||||||
|
m_pReflectionMap = pContext->getTextureManager()->getTexture(m_reflectionMap.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!bSameMaterial) {
|
if(!bSameMaterial) {
|
||||||
KRVector2 default_scale = KRVector2(1.0f, 1.0f);
|
KRVector2 default_scale = KRVector2(1.0f, 1.0f);
|
||||||
@@ -186,6 +198,7 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
bool bDiffuseMap = m_pDiffuseMap != NULL && pCamera->bEnableDiffuseMap;
|
bool bDiffuseMap = m_pDiffuseMap != NULL && pCamera->bEnableDiffuseMap;
|
||||||
bool bNormalMap = m_pNormalMap != NULL && pCamera->bEnableNormalMap;
|
bool bNormalMap = m_pNormalMap != NULL && pCamera->bEnableNormalMap;
|
||||||
bool bSpecMap = m_pSpecularMap != NULL && pCamera->bEnableSpecMap;
|
bool bSpecMap = m_pSpecularMap != NULL && pCamera->bEnableSpecMap;
|
||||||
|
bool bReflectionMap = m_pReflectionMap != NULL && pCamera->bEnableReflectionMap;
|
||||||
|
|
||||||
KRShader *pShader = pContext->getShaderManager()->getShader("ObjectShader", pCamera, bDiffuseMap, bNormalMap, bSpecMap, cShadowBuffers, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, gBufferPass);
|
KRShader *pShader = pContext->getShaderManager()->getShader("ObjectShader", pCamera, bDiffuseMap, bNormalMap, bSpecMap, cShadowBuffers, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, gBufferPass);
|
||||||
|
|
||||||
@@ -199,35 +212,41 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
bool bSameAmbient = false;
|
bool bSameAmbient = false;
|
||||||
bool bSameDiffuse = false;
|
bool bSameDiffuse = false;
|
||||||
bool bSameSpecular = false;
|
bool bSameSpecular = false;
|
||||||
|
bool bSameReflection = false;
|
||||||
bool bSameAmbientScale = false;
|
bool bSameAmbientScale = false;
|
||||||
bool bSameDiffuseScale = false;
|
bool bSameDiffuseScale = false;
|
||||||
bool bSameSpecularScale = false;
|
bool bSameSpecularScale = false;
|
||||||
|
bool bSameReflectionScale = false;
|
||||||
bool bSameNormalScale = false;
|
bool bSameNormalScale = false;
|
||||||
bool bSameAmbientOffset = false;
|
bool bSameAmbientOffset = false;
|
||||||
bool bSameDiffuseOffset = false;
|
bool bSameDiffuseOffset = false;
|
||||||
bool bSameSpecularOffset = false;
|
bool bSameSpecularOffset = false;
|
||||||
|
bool bSameReflectionOffset = false;
|
||||||
bool bSameNormalOffset = false;
|
bool bSameNormalOffset = false;
|
||||||
|
|
||||||
if(*prevBoundMaterial && bSameShader) {
|
if(*prevBoundMaterial && bSameShader) {
|
||||||
bSameAmbient = (*prevBoundMaterial)->m_ka_r == m_ka_r && (*prevBoundMaterial)->m_ka_g == m_ka_g && (*prevBoundMaterial)->m_ka_b == m_ka_b;
|
bSameAmbient = (*prevBoundMaterial)->m_ambientColor == m_ambientColor;
|
||||||
bSameDiffuse = (*prevBoundMaterial)->m_kd_r == m_kd_r && (*prevBoundMaterial)->m_kd_g == m_kd_g && (*prevBoundMaterial)->m_kd_b == m_kd_b;
|
bSameDiffuse = (*prevBoundMaterial)->m_diffuseColor == m_diffuseColor;
|
||||||
bSameSpecular = (*prevBoundMaterial)->m_ks_r == m_ks_r && (*prevBoundMaterial)->m_ks_g == m_ks_g && (*prevBoundMaterial)->m_ks_b == m_ks_b;
|
bSameSpecular = (*prevBoundMaterial)->m_specularColor == m_specularColor;
|
||||||
|
bSameReflection = (*prevBoundMaterial)->m_reflectionColor == m_reflectionColor;
|
||||||
bSameAmbientScale = (*prevBoundMaterial)->m_ambientMapScale == m_ambientMapScale;
|
bSameAmbientScale = (*prevBoundMaterial)->m_ambientMapScale == m_ambientMapScale;
|
||||||
bSameDiffuseScale = (*prevBoundMaterial)->m_diffuseMapScale == m_diffuseMapScale;
|
bSameDiffuseScale = (*prevBoundMaterial)->m_diffuseMapScale == m_diffuseMapScale;
|
||||||
bSameSpecularScale = (*prevBoundMaterial)->m_specularMapScale == m_specularMapScale;
|
bSameSpecularScale = (*prevBoundMaterial)->m_specularMapScale == m_specularMapScale;
|
||||||
|
bSameReflectionScale = (*prevBoundMaterial)->m_reflectionMapScale == m_reflectionMapScale;
|
||||||
bSameNormalScale = (*prevBoundMaterial)->m_normalMapScale == m_normalMapScale;
|
bSameNormalScale = (*prevBoundMaterial)->m_normalMapScale == m_normalMapScale;
|
||||||
bSameAmbientOffset = (*prevBoundMaterial)->m_ambientMapOffset == m_ambientMapOffset;
|
bSameAmbientOffset = (*prevBoundMaterial)->m_ambientMapOffset == m_ambientMapOffset;
|
||||||
bSameDiffuseOffset = (*prevBoundMaterial)->m_diffuseMapOffset == m_diffuseMapOffset;
|
bSameDiffuseOffset = (*prevBoundMaterial)->m_diffuseMapOffset == m_diffuseMapOffset;
|
||||||
bSameSpecularOffset = (*prevBoundMaterial)->m_specularMapOffset == m_specularMapOffset;
|
bSameSpecularOffset = (*prevBoundMaterial)->m_specularMapOffset == m_specularMapOffset;
|
||||||
|
bSameReflectionOffset = (*prevBoundMaterial)->m_reflectionMapOffset == m_reflectionMapOffset;
|
||||||
bSameNormalOffset = (*prevBoundMaterial)->m_normalMapOffset == m_normalMapOffset;
|
bSameNormalOffset = (*prevBoundMaterial)->m_normalMapOffset == m_normalMapOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bSameAmbient) {
|
if(!bSameAmbient) {
|
||||||
glUniform3f(
|
glUniform3f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_AMBIENT],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_AMBIENT],
|
||||||
m_ka_r + pCamera->dAmbientR,
|
m_ambientColor.x + pCamera->dAmbientR,
|
||||||
m_ka_g + pCamera->dAmbientG,
|
m_ambientColor.y + pCamera->dAmbientG,
|
||||||
m_ka_b + pCamera->dAmbientB
|
m_ambientColor.z + pCamera->dAmbientB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,16 +255,16 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
// We pre-multiply the light color with the material color in the forward renderer
|
// We pre-multiply the light color with the material color in the forward renderer
|
||||||
glUniform3f(
|
glUniform3f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_DIFFUSE],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_DIFFUSE],
|
||||||
m_kd_r * pCamera->dSunR,
|
m_diffuseColor.x * pCamera->dSunR,
|
||||||
m_kd_g * pCamera->dSunG,
|
m_diffuseColor.y * pCamera->dSunG,
|
||||||
m_kd_b * pCamera->dSunB
|
m_diffuseColor.z * pCamera->dSunB
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
glUniform3f(
|
glUniform3f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_DIFFUSE],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_DIFFUSE],
|
||||||
m_kd_r,
|
m_diffuseColor.x,
|
||||||
m_kd_g,
|
m_diffuseColor.y,
|
||||||
m_kd_b
|
m_diffuseColor.z
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,20 +274,29 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
// We pre-multiply the light color with the material color in the forward renderer
|
// We pre-multiply the light color with the material color in the forward renderer
|
||||||
glUniform3f(
|
glUniform3f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_SPECULAR],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_SPECULAR],
|
||||||
m_ks_r * pCamera->dSunR,
|
m_specularColor.x * pCamera->dSunR,
|
||||||
m_ks_g * pCamera->dSunG,
|
m_specularColor.y * pCamera->dSunG,
|
||||||
m_ks_b * pCamera->dSunB
|
m_specularColor.z * pCamera->dSunB
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
glUniform3f(
|
glUniform3f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_SPECULAR],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_SPECULAR],
|
||||||
m_ks_r,
|
m_specularColor.x,
|
||||||
m_ks_g,
|
m_specularColor.y,
|
||||||
m_ks_b
|
m_specularColor.z
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!bSameReflection) {
|
||||||
|
glUniform3f(
|
||||||
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_REFLECTION],
|
||||||
|
m_reflectionColor.x,
|
||||||
|
m_reflectionColor.y,
|
||||||
|
m_reflectionColor.z
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(bDiffuseMap && !bSameDiffuseScale && m_diffuseMapScale != default_scale) {
|
if(bDiffuseMap && !bSameDiffuseScale && m_diffuseMapScale != default_scale) {
|
||||||
glUniform2f(
|
glUniform2f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_DIFFUSETEXTURE_SCALE],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_DIFFUSETEXTURE_SCALE],
|
||||||
@@ -285,6 +313,14 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bReflectionMap && !bSameReflectionScale && m_reflectionMapScale != default_scale) {
|
||||||
|
glUniform2f(
|
||||||
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_REFLECTIONTEXTURE_SCALE],
|
||||||
|
m_reflectionMapScale.x,
|
||||||
|
m_reflectionMapScale.y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(bNormalMap && !bSameNormalScale && m_normalMapScale != default_scale) {
|
if(bNormalMap && !bSameNormalScale && m_normalMapScale != default_scale) {
|
||||||
glUniform2f(
|
glUniform2f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_NORMALTEXTURE_SCALE],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_NORMALTEXTURE_SCALE],
|
||||||
@@ -309,6 +345,14 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bReflectionMap && !bSameReflectionOffset && m_reflectionMapOffset != default_offset) {
|
||||||
|
glUniform2f(
|
||||||
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_REFLECTIONTEXTURE_OFFSET],
|
||||||
|
m_reflectionMapOffset.x,
|
||||||
|
m_reflectionMapOffset.y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(bNormalMap && !bSameNormalOffset && m_normalMapOffset != default_offset) {
|
if(bNormalMap && !bSameNormalOffset && m_normalMapOffset != default_offset) {
|
||||||
glUniform2f(
|
glUniform2f(
|
||||||
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_NORMALTEXTURE_OFFSET],
|
pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_NORMALTEXTURE_OFFSET],
|
||||||
@@ -318,10 +362,12 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
}
|
}
|
||||||
|
|
||||||
glUniform1f(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA], 1.0f - m_tr);
|
glUniform1f(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA], 1.0f - m_tr);
|
||||||
|
glUniform1f(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_REFLECTIVITY], m_reflectionFactor);
|
||||||
|
|
||||||
bool bSameDiffuseMap = false;
|
bool bSameDiffuseMap = false;
|
||||||
bool bSameSpecMap = false;
|
bool bSameSpecMap = false;
|
||||||
bool bSameNormalMap = false;
|
bool bSameNormalMap = false;
|
||||||
|
bool bSameReflectionMap = false;
|
||||||
if(*prevBoundMaterial) {
|
if(*prevBoundMaterial) {
|
||||||
if((*prevBoundMaterial)->m_pDiffuseMap == m_pDiffuseMap) {
|
if((*prevBoundMaterial)->m_pDiffuseMap == m_pDiffuseMap) {
|
||||||
bSameDiffuseMap = true;
|
bSameDiffuseMap = true;
|
||||||
@@ -329,6 +375,9 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
if((*prevBoundMaterial)->m_pSpecularMap == m_pSpecularMap) {
|
if((*prevBoundMaterial)->m_pSpecularMap == m_pSpecularMap) {
|
||||||
bSameSpecMap = true;
|
bSameSpecMap = true;
|
||||||
}
|
}
|
||||||
|
if((*prevBoundMaterial)->m_pReflectionMap == m_pReflectionMap) {
|
||||||
|
bSameReflectionMap = true;
|
||||||
|
}
|
||||||
if((*prevBoundMaterial)->m_pNormalMap == m_pNormalMap) {
|
if((*prevBoundMaterial)->m_pNormalMap == m_pNormalMap) {
|
||||||
bSameNormalMap = true;
|
bSameNormalMap = true;
|
||||||
}
|
}
|
||||||
@@ -361,6 +410,16 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bReflectionMap && !bSameReflectionMap && (gBufferPass == 0 || gBufferPass == 3)) {
|
||||||
|
// GL_TEXTURE7 is used for reading the depth buffer in gBuffer pass 2 and re-used for the reflection map in gBuffer Pass 3 and in forward rendering
|
||||||
|
int iTextureName = m_pReflectionMap->getName();
|
||||||
|
glActiveTexture(GL_TEXTURE7);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
}
|
||||||
|
|
||||||
*prevBoundMaterial = this;
|
*prevBoundMaterial = this;
|
||||||
} // if(!bSameMaterial)
|
} // if(!bSameMaterial)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,12 +64,15 @@ public:
|
|||||||
void setAmbientMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
void setAmbientMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
||||||
void setDiffuseMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
void setDiffuseMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
||||||
void setSpecularMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
void setSpecularMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
||||||
|
void setReflectionMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
||||||
void setNormalMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
void setNormalMap(std::string texture_name, KRVector2 texture_scale, KRVector2 texture_offset);
|
||||||
void setAmbient(GLfloat r, GLfloat g, GLfloat b);
|
void setAmbient(const KRVector3 &c);
|
||||||
void setDiffuse(GLfloat r, GLfloat g, GLfloat b);
|
void setDiffuse(const KRVector3 &c);
|
||||||
void setSpecular(GLfloat r, GLfloat g, GLfloat b);
|
void setSpecular(const KRVector3 &c);
|
||||||
|
void setReflection(const KRVector3 &c);
|
||||||
void setTransparency(GLfloat a);
|
void setTransparency(GLfloat a);
|
||||||
void setShininess(GLfloat s);
|
void setShininess(GLfloat s);
|
||||||
|
void setReflectionFactor(GLfloat r);
|
||||||
|
|
||||||
|
|
||||||
bool isTransparent();
|
bool isTransparent();
|
||||||
@@ -86,10 +89,12 @@ private:
|
|||||||
KRTexture *m_pAmbientMap; // mtl map_Ka value
|
KRTexture *m_pAmbientMap; // mtl map_Ka value
|
||||||
KRTexture *m_pDiffuseMap; // mtl map_Kd value
|
KRTexture *m_pDiffuseMap; // mtl map_Kd value
|
||||||
KRTexture *m_pSpecularMap; // mtl map_Ks value
|
KRTexture *m_pSpecularMap; // mtl map_Ks value
|
||||||
|
KRTexture *m_pReflectionMap; // mtl refl value
|
||||||
KRTexture *m_pNormalMap; // mtl map_Normal value
|
KRTexture *m_pNormalMap; // mtl map_Normal value
|
||||||
std::string m_ambientMap;
|
std::string m_ambientMap;
|
||||||
std::string m_diffuseMap;
|
std::string m_diffuseMap;
|
||||||
std::string m_specularMap;
|
std::string m_specularMap;
|
||||||
|
std::string m_reflectionMap;
|
||||||
std::string m_normalMap;
|
std::string m_normalMap;
|
||||||
|
|
||||||
KRVector2 m_ambientMapScale;
|
KRVector2 m_ambientMapScale;
|
||||||
@@ -98,15 +103,24 @@ private:
|
|||||||
KRVector2 m_diffuseMapOffset;
|
KRVector2 m_diffuseMapOffset;
|
||||||
KRVector2 m_specularMapScale;
|
KRVector2 m_specularMapScale;
|
||||||
KRVector2 m_specularMapOffset;
|
KRVector2 m_specularMapOffset;
|
||||||
|
KRVector2 m_reflectionMapScale;
|
||||||
|
KRVector2 m_reflectionMapOffset;
|
||||||
KRVector2 m_normalMapScale;
|
KRVector2 m_normalMapScale;
|
||||||
KRVector2 m_normalMapOffset;
|
KRVector2 m_normalMapOffset;
|
||||||
|
|
||||||
GLfloat m_ka_r, m_ka_g, m_ka_b; // Ambient rgb
|
KRVector3 m_ambientColor; // Ambient rgb
|
||||||
GLfloat m_kd_r, m_kd_g, m_kd_b; // Diffuse rgb
|
KRVector3 m_diffuseColor; // Diffuse rgb
|
||||||
GLfloat m_ks_r, m_ks_g, m_ks_b; // Specular rgb
|
KRVector3 m_specularColor; // Specular rgb
|
||||||
|
KRVector3 m_reflectionColor; // Reflection rgb
|
||||||
|
|
||||||
|
//GLfloat m_ka_r, m_ka_g, m_ka_b; // Ambient rgb
|
||||||
|
//GLfloat m_kd_r, m_kd_g, m_kd_b; // Diffuse rgb
|
||||||
|
//GLfloat m_ks_r, m_ks_g, m_ks_b; // Specular rgb
|
||||||
|
//GLfloat m_kr_r, m_kr_g, m_kr_b; // Reflection rgb
|
||||||
|
|
||||||
GLfloat m_tr; // Transparency
|
GLfloat m_tr; // Transparency
|
||||||
GLfloat m_ns; // Shininess
|
GLfloat m_ns; // Shininess
|
||||||
|
GLfloat m_reflectionFactor; // Level of reflectivity
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -120,37 +120,49 @@ bool KRMaterialManager::loadFile(const char *szPath) {
|
|||||||
char *pScan2 = szSymbol[1];
|
char *pScan2 = szSymbol[1];
|
||||||
double r = strtof(pScan2, &pScan2);
|
double r = strtof(pScan2, &pScan2);
|
||||||
if(cSymbols == 2) {
|
if(cSymbols == 2) {
|
||||||
pMaterial->setAmbient(r, r, r);
|
pMaterial->setAmbient(KRVector3(r, r, r));
|
||||||
} else if(cSymbols == 4) {
|
} else if(cSymbols == 4) {
|
||||||
pScan2 = szSymbol[2];
|
pScan2 = szSymbol[2];
|
||||||
double g = strtof(pScan2, &pScan2);
|
double g = strtof(pScan2, &pScan2);
|
||||||
pScan2 = szSymbol[3];
|
pScan2 = szSymbol[3];
|
||||||
double b = strtof(pScan2, &pScan2);
|
double b = strtof(pScan2, &pScan2);
|
||||||
pMaterial->setAmbient(r, g, b);
|
pMaterial->setAmbient(KRVector3(r, g, b));
|
||||||
}
|
}
|
||||||
} else if(strcmp(szSymbol[0], "Kd") == 0) {
|
} else if(strcmp(szSymbol[0], "Kd") == 0) {
|
||||||
char *pScan2 = szSymbol[1];
|
char *pScan2 = szSymbol[1];
|
||||||
double r = strtof(pScan2, &pScan2);
|
double r = strtof(pScan2, &pScan2);
|
||||||
if(cSymbols == 2) {
|
if(cSymbols == 2) {
|
||||||
pMaterial->setDiffuse(r, r, r);
|
pMaterial->setDiffuse(KRVector3(r, r, r));
|
||||||
} else if(cSymbols == 4) {
|
} else if(cSymbols == 4) {
|
||||||
pScan2 = szSymbol[2];
|
pScan2 = szSymbol[2];
|
||||||
double g = strtof(pScan2, &pScan2);
|
double g = strtof(pScan2, &pScan2);
|
||||||
pScan2 = szSymbol[3];
|
pScan2 = szSymbol[3];
|
||||||
double b = strtof(pScan2, &pScan2);
|
double b = strtof(pScan2, &pScan2);
|
||||||
pMaterial->setDiffuse(r, g, b);
|
pMaterial->setDiffuse(KRVector3(r, g, b));
|
||||||
}
|
}
|
||||||
} else if(strcmp(szSymbol[0], "Ks") == 0) {
|
} else if(strcmp(szSymbol[0], "Ks") == 0) {
|
||||||
char *pScan2 = szSymbol[1];
|
char *pScan2 = szSymbol[1];
|
||||||
double r = strtof(pScan2, &pScan2);
|
double r = strtof(pScan2, &pScan2);
|
||||||
if(cSymbols == 2) {
|
if(cSymbols == 2) {
|
||||||
pMaterial->setSpecular(r, r, r);
|
pMaterial->setSpecular(KRVector3(r, r, r));
|
||||||
} else if(cSymbols == 4) {
|
} else if(cSymbols == 4) {
|
||||||
pScan2 = szSymbol[2];
|
pScan2 = szSymbol[2];
|
||||||
double g = strtof(pScan2, &pScan2);
|
double g = strtof(pScan2, &pScan2);
|
||||||
pScan2 = szSymbol[3];
|
pScan2 = szSymbol[3];
|
||||||
double b = strtof(pScan2, &pScan2);
|
double b = strtof(pScan2, &pScan2);
|
||||||
pMaterial->setSpecular(r, g, b);
|
pMaterial->setSpecular(KRVector3(r, g, b));
|
||||||
|
}
|
||||||
|
} else if(strcmp(szSymbol[0], "Kr") == 0) {
|
||||||
|
char *pScan2 = szSymbol[1];
|
||||||
|
double r = strtof(pScan2, &pScan2);
|
||||||
|
if(cSymbols == 2) {
|
||||||
|
pMaterial->setReflection(KRVector3(r, r, r));
|
||||||
|
} else if(cSymbols == 4) {
|
||||||
|
pScan2 = szSymbol[2];
|
||||||
|
double g = strtof(pScan2, &pScan2);
|
||||||
|
pScan2 = szSymbol[3];
|
||||||
|
double b = strtof(pScan2, &pScan2);
|
||||||
|
pMaterial->setReflection(KRVector3(r, g, b));
|
||||||
}
|
}
|
||||||
} else if(strcmp(szSymbol[0], "Tr") == 0) {
|
} else if(strcmp(szSymbol[0], "Tr") == 0) {
|
||||||
char *pScan2 = szSymbol[1];
|
char *pScan2 = szSymbol[1];
|
||||||
@@ -217,6 +229,8 @@ bool KRMaterialManager::loadFile(const char *szPath) {
|
|||||||
pMaterial->setSpecularMap(szSymbol[1], texture_scale, texture_offset);
|
pMaterial->setSpecularMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
} else if(strcmp(szSymbol[0], "map_Normal") == 0) {
|
} else if(strcmp(szSymbol[0], "map_Normal") == 0) {
|
||||||
pMaterial->setNormalMap(szSymbol[1], texture_scale, texture_offset);
|
pMaterial->setNormalMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
|
} else if(strcmp(szSymbol[0], "map_Reflection") == 0) {
|
||||||
|
pMaterial->setReflectionMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,12 +454,15 @@ void LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeo
|
|||||||
lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->Shininess;
|
lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->Shininess;
|
||||||
new_material->setShininess(lKFbxDouble1.Get());
|
new_material->setShininess(lKFbxDouble1.Get());
|
||||||
|
|
||||||
// ShininessFactor
|
// Specular Factor
|
||||||
lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->SpecularFactor;
|
lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->SpecularFactor;
|
||||||
double specular_factor = lKFbxDouble1.Get();
|
double specular_factor = lKFbxDouble1.Get();
|
||||||
|
|
||||||
// Display the Reflectivity
|
// Reflection color
|
||||||
//lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->ReflectionFactor;
|
lKFbxDouble3 =((KFbxSurfacePhong *) pMaterial)->Reflection;
|
||||||
|
|
||||||
|
// Reflection factor
|
||||||
|
lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->ReflectionFactor;
|
||||||
} else if(pMaterial->GetClassId().Is(KFbxSurfaceLambert::ClassId) ) {
|
} else if(pMaterial->GetClassId().Is(KFbxSurfaceLambert::ClassId) ) {
|
||||||
// We found a Lambert material.
|
// We found a Lambert material.
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ KRShader::KRShader(char *szKey, std::string options, std::string vertShaderSourc
|
|||||||
m_uniforms[KRENGINE_UNIFORM_MATERIAL_AMBIENT] = glGetUniformLocation(m_iProgram, "material_ambient");
|
m_uniforms[KRENGINE_UNIFORM_MATERIAL_AMBIENT] = glGetUniformLocation(m_iProgram, "material_ambient");
|
||||||
m_uniforms[KRENGINE_UNIFORM_MATERIAL_DIFFUSE] = glGetUniformLocation(m_iProgram, "material_diffuse");
|
m_uniforms[KRENGINE_UNIFORM_MATERIAL_DIFFUSE] = glGetUniformLocation(m_iProgram, "material_diffuse");
|
||||||
m_uniforms[KRENGINE_UNIFORM_MATERIAL_SPECULAR] = glGetUniformLocation(m_iProgram, "material_specular");
|
m_uniforms[KRENGINE_UNIFORM_MATERIAL_SPECULAR] = glGetUniformLocation(m_iProgram, "material_specular");
|
||||||
|
m_uniforms[KRENGINE_UNIFORM_MATERIAL_REFLECTION] = glGetUniformLocation(m_iProgram, "material_reflection");
|
||||||
|
m_uniforms[KRENGINE_UNIFORM_MATERIAL_REFLECTIVITY] = glGetUniformLocation(m_iProgram, "material_reflectivity");
|
||||||
|
|
||||||
m_uniforms[KRENGINE_UNIFORM_LIGHT_POSITION] = glGetUniformLocation(m_iProgram, "light_position");
|
m_uniforms[KRENGINE_UNIFORM_LIGHT_POSITION] = glGetUniformLocation(m_iProgram, "light_position");
|
||||||
m_uniforms[KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE] = glGetUniformLocation(m_iProgram, "view_space_light_position");
|
m_uniforms[KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE] = glGetUniformLocation(m_iProgram, "view_space_light_position");
|
||||||
@@ -134,14 +136,17 @@ KRShader::KRShader(char *szKey, std::string options, std::string vertShaderSourc
|
|||||||
|
|
||||||
m_uniforms[KRENGINE_UNIFORM_DIFFUSETEXTURE] = glGetUniformLocation(m_iProgram, "diffuseTexture");
|
m_uniforms[KRENGINE_UNIFORM_DIFFUSETEXTURE] = glGetUniformLocation(m_iProgram, "diffuseTexture");
|
||||||
m_uniforms[KRENGINE_UNIFORM_SPECULARTEXTURE] = glGetUniformLocation(m_iProgram, "specularTexture");
|
m_uniforms[KRENGINE_UNIFORM_SPECULARTEXTURE] = glGetUniformLocation(m_iProgram, "specularTexture");
|
||||||
|
m_uniforms[KRENGINE_UNIFORM_REFLECTIONTEXTURE] = glGetUniformLocation(m_iProgram, "reflectionTexture");
|
||||||
m_uniforms[KRENGINE_UNIFORM_NORMALTEXTURE] = glGetUniformLocation(m_iProgram, "normalTexture");
|
m_uniforms[KRENGINE_UNIFORM_NORMALTEXTURE] = glGetUniformLocation(m_iProgram, "normalTexture");
|
||||||
|
|
||||||
m_uniforms[KRENGINE_UNIFORM_DIFFUSETEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "diffuseTexture_Scale");
|
m_uniforms[KRENGINE_UNIFORM_DIFFUSETEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "diffuseTexture_Scale");
|
||||||
m_uniforms[KRENGINE_UNIFORM_SPECULARTEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "specularTexture_Scale");
|
m_uniforms[KRENGINE_UNIFORM_SPECULARTEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "specularTexture_Scale");
|
||||||
|
m_uniforms[KRENGINE_UNIFORM_REFLECTIONTEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "reflectionTexture_Scale");
|
||||||
m_uniforms[KRENGINE_UNIFORM_NORMALTEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "normalTexture_Scale");
|
m_uniforms[KRENGINE_UNIFORM_NORMALTEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "normalTexture_Scale");
|
||||||
m_uniforms[KRENGINE_UNIFORM_AMBIENTTEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "ambientTexture_Scale");
|
m_uniforms[KRENGINE_UNIFORM_AMBIENTTEXTURE_SCALE] = glGetUniformLocation(m_iProgram, "ambientTexture_Scale");
|
||||||
m_uniforms[KRENGINE_UNIFORM_DIFFUSETEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "diffuseTexture_Offset");
|
m_uniforms[KRENGINE_UNIFORM_DIFFUSETEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "diffuseTexture_Offset");
|
||||||
m_uniforms[KRENGINE_UNIFORM_SPECULARTEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "specularTexture_Offset");
|
m_uniforms[KRENGINE_UNIFORM_SPECULARTEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "specularTexture_Offset");
|
||||||
|
m_uniforms[KRENGINE_UNIFORM_REFLECTIONTEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "reflectionTexture_Offset");
|
||||||
m_uniforms[KRENGINE_UNIFORM_NORMALTEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "normalTexture_Offset");
|
m_uniforms[KRENGINE_UNIFORM_NORMALTEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "normalTexture_Offset");
|
||||||
m_uniforms[KRENGINE_UNIFORM_AMBIENTTEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "ambientTexture_Offset");
|
m_uniforms[KRENGINE_UNIFORM_AMBIENTTEXTURE_OFFSET] = glGetUniformLocation(m_iProgram, "ambientTexture_Offset");
|
||||||
|
|
||||||
@@ -240,7 +245,9 @@ void KRShader::bind(KRCamera *pCamera, KRMat4 &matModelToView, KRMat4 &mvpMatrix
|
|||||||
glUniform1i(m_uniforms[KRENGINE_UNIFORM_SHADOWTEXTURE3], 5);
|
glUniform1i(m_uniforms[KRENGINE_UNIFORM_SHADOWTEXTURE3], 5);
|
||||||
|
|
||||||
glUniform1i(m_uniforms[KRENGINE_UNIFORM_GBUFFER_FRAME], 6);
|
glUniform1i(m_uniforms[KRENGINE_UNIFORM_GBUFFER_FRAME], 6);
|
||||||
|
|
||||||
glUniform1i(m_uniforms[KRENGINE_UNIFORM_GBUFFER_DEPTH], 7);
|
glUniform1i(m_uniforms[KRENGINE_UNIFORM_GBUFFER_DEPTH], 7);
|
||||||
|
glUniform1i(m_uniforms[KRENGINE_UNIFORM_REFLECTIONTEXTURE], 7);
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
GLint logLength;
|
GLint logLength;
|
||||||
|
|||||||
@@ -70,8 +70,10 @@ public:
|
|||||||
KRENGINE_UNIFORM_MATERIAL_AMBIENT,
|
KRENGINE_UNIFORM_MATERIAL_AMBIENT,
|
||||||
KRENGINE_UNIFORM_MATERIAL_DIFFUSE,
|
KRENGINE_UNIFORM_MATERIAL_DIFFUSE,
|
||||||
KRENGINE_UNIFORM_MATERIAL_SPECULAR,
|
KRENGINE_UNIFORM_MATERIAL_SPECULAR,
|
||||||
|
KRENGINE_UNIFORM_MATERIAL_REFLECTION,
|
||||||
KRENGINE_UNIFORM_MATERIAL_ALPHA,
|
KRENGINE_UNIFORM_MATERIAL_ALPHA,
|
||||||
KRENGINE_UNIFORM_MATERIAL_SHININESS,
|
KRENGINE_UNIFORM_MATERIAL_SHININESS,
|
||||||
|
KRENGINE_UNIFORM_MATERIAL_REFLECTIVITY,
|
||||||
|
|
||||||
KRENGINE_UNIFORM_LIGHT_POSITION,
|
KRENGINE_UNIFORM_LIGHT_POSITION,
|
||||||
KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE,
|
KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE,
|
||||||
@@ -93,13 +95,16 @@ public:
|
|||||||
KRENGINE_UNIFORM_VIEWPORT,
|
KRENGINE_UNIFORM_VIEWPORT,
|
||||||
KRENGINE_UNIFORM_DIFFUSETEXTURE,
|
KRENGINE_UNIFORM_DIFFUSETEXTURE,
|
||||||
KRENGINE_UNIFORM_SPECULARTEXTURE,
|
KRENGINE_UNIFORM_SPECULARTEXTURE,
|
||||||
|
KRENGINE_UNIFORM_REFLECTIONTEXTURE,
|
||||||
KRENGINE_UNIFORM_NORMALTEXTURE,
|
KRENGINE_UNIFORM_NORMALTEXTURE,
|
||||||
KRENGINE_UNIFORM_DIFFUSETEXTURE_SCALE,
|
KRENGINE_UNIFORM_DIFFUSETEXTURE_SCALE,
|
||||||
KRENGINE_UNIFORM_SPECULARTEXTURE_SCALE,
|
KRENGINE_UNIFORM_SPECULARTEXTURE_SCALE,
|
||||||
|
KRENGINE_UNIFORM_REFLECTIONTEXTURE_SCALE,
|
||||||
KRENGINE_UNIFORM_NORMALTEXTURE_SCALE,
|
KRENGINE_UNIFORM_NORMALTEXTURE_SCALE,
|
||||||
KRENGINE_UNIFORM_AMBIENTTEXTURE_SCALE,
|
KRENGINE_UNIFORM_AMBIENTTEXTURE_SCALE,
|
||||||
KRENGINE_UNIFORM_DIFFUSETEXTURE_OFFSET,
|
KRENGINE_UNIFORM_DIFFUSETEXTURE_OFFSET,
|
||||||
KRENGINE_UNIFORM_SPECULARTEXTURE_OFFSET,
|
KRENGINE_UNIFORM_SPECULARTEXTURE_OFFSET,
|
||||||
|
KRENGINE_UNIFORM_REFLECTIONTEXTURE_OFFSET,
|
||||||
KRENGINE_UNIFORM_NORMALTEXTURE_OFFSET,
|
KRENGINE_UNIFORM_NORMALTEXTURE_OFFSET,
|
||||||
KRENGINE_UNIFORM_AMBIENTTEXTURE_OFFSET,
|
KRENGINE_UNIFORM_AMBIENTTEXTURE_OFFSET,
|
||||||
KRENGINE_UNIFORM_SHADOWMVP1,
|
KRENGINE_UNIFORM_SHADOWMVP1,
|
||||||
|
|||||||
@@ -110,6 +110,9 @@
|
|||||||
|
|
||||||
[renderEngine setNearZ: 100.0];
|
[renderEngine setNearZ: 100.0];
|
||||||
[renderEngine setFarZ: 3000.0];
|
[renderEngine setFarZ: 3000.0];
|
||||||
|
//[renderEngine setNearZ: 1.0];
|
||||||
|
//[renderEngine setFarZ: 3000.0];
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user