Created
December 13, 2012 16:59
-
-
Save Jsewill/4277930 to your computer and use it in GitHub Desktop.
parallax shader patch to blender trunk.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: release/scripts/startup/bl_ui/properties_texture.py | |
=================================================================== | |
--- release/scripts/startup/bl_ui/properties_texture.py (revision 52857) | |
+++ release/scripts/startup/bl_ui/properties_texture.py (working copy) | |
@@ -882,6 +882,7 @@ | |
col = split.column() | |
if tex.texture_coords in {'ORCO', 'UV'}: | |
col.prop(tex, "use_from_dupli") | |
+ col.prop(tex, "use_parallax_uv", text = "Use Parallax UV") | |
if (idblock.type == 'VOLUME' and tex.texture_coords == 'ORCO'): | |
col.prop(tex, "use_map_to_bounds") | |
elif tex.texture_coords == 'OBJECT': | |
@@ -965,7 +966,10 @@ | |
factor_but(col, "use_map_warp", "warp_factor", "Warp") | |
factor_but(col, "use_map_displacement", "displacement_factor", "Displace") | |
- | |
+ col.label(text="Parallax:") | |
+ factor_but(col, "use_parallax_uv", "parallax_uv_shift", "height scale")#angelo parallax | |
+ factor_but(col, "use_map_parallax", "parallax_steps", "Parallax Steps")#angelo parallax | |
+ factor_but(col, "use_map_parallax", "parallax_bump_scale", "Parallax Bump Scale")#angelo parallax | |
#~ sub = col.column() | |
#~ sub.active = tex.use_map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror | |
#~ sub.prop(tex, "default_value", text="Amount", slider=True) | |
Index: source/blender/gpu/shaders/gpu_shader_material.glsl | |
=================================================================== | |
--- source/blender/gpu/shaders/gpu_shader_material.glsl (revision 52857) | |
+++ source/blender/gpu/shaders/gpu_shader_material.glsl (working copy) | |
@@ -2256,4 +2256,151 @@ | |
{ | |
result = surface; | |
} | |
+//angelo parallax | |
+#define MAX_LIGHTS 1//<<MAX_LIGHTS will be a float soon | |
+ | |
+void parallax_out_nl(vec3 texco, vec3 vp, vec4 tangent,vec3 vn, vec3 size, sampler2D ima, float scale, float numSteps, float bumpScale, out vec3 pTexCoord, out float selfShadow) | |
+ | |
+{ | |
+ float bias = scale * 0.005;//from uv shift slider ?odd behavior? does not work as expected// should scale | |
+ /*do our own tbn here */ | |
+ vec3 tang = (tangent.xyz); | |
+ vec3 binormal = cross(-vn, tangent.xyz)*tangent.w; | |
+ vec3 mnormal = -vn; | |
+ vec3 obpos = vp; | |
+ | |
+ vec3 by = obpos; | |
+ vec3 vvec; | |
+ vvec.x = dot(tang, by); | |
+ vvec.y = dot(binormal, by); | |
+ vvec.z = dot(mnormal, by); | |
+ /*do our own tbn here */ | |
+ vec3 vv = normalize(vvec); | |
+ vec2 texUV, srcUV = texco.xy; | |
+ float height = texture2D(ima, srcUV).a; | |
+ /*leaving control of this out of ui wont work without it but doesnt work right when you adjust the scale*/ | |
+ float v = height * bias - scale; | |
+ texUV = srcUV + v; | |
+ float h =1.0; | |
+ float numEyeSteps = mix(numSteps*2.0, numSteps, vv.z); | |
+ float step; | |
+ vec2 delta; | |
+ step = 1.0 / numEyeSteps; | |
+ delta = vec2(-vv.x, vv.y) * bumpScale / (vv.z * numEyeSteps); | |
+ for (int i=0;i<int(numEyeSteps);i++) | |
+ { | |
+ if (height < h) { | |
+ h -= step; | |
+ texUV -= delta; | |
+ height = texture2D(ima, texUV*vec2(size)).a;// *size is to allow tiling :) but normal map is acting funny :( | |
+ } | |
+ } | |
+ h = height;//<<needs to be an out put too | |
+ | |
+ if (texUV.x < 0.0 || texUV.x > 1.0 || texUV.y < 0.0 || texUV.y > 1.0) { | |
+ discard; | |
+ } | |
+ pTexCoord = vec3(texUV*vec2(size), 0.0);//<<uv coords that get sent back to blender // | |
+ selfShadow = 0.0; | |
+} | |
+void parallax_out_wl(vec3 texco, mat4 gpuinvmat, vec3 vp, vec4 tangent,vec3 vn, vec3 lampco, vec3 size, sampler2D ima, float scale, float numSteps, float bumpScale, out vec3 pTexCoord, out float selfShadow) | |
+ | |
+{ | |
+ float bias = scale * 0.005;//f?odd behavior? does not work as expected// should scale | |
+ /*do our own tbn here */ | |
+ vec3 tang = (tangent.xyz); | |
+ vec3 binormal = cross(-vn, tangent.xyz)*tangent.w; | |
+ vec3 mnormal = -vn; | |
+ vec3 obpos = vp; | |
+ vec3 by = obpos; | |
+ vec3 vvec; | |
+ vvec.x = dot(tang, by); | |
+ vvec.y = dot(binormal, by); | |
+ vvec.z = dot(mnormal, by); | |
+ /*do our own tbn here */ | |
+ vec3 vv = normalize(vvec); | |
+ vec2 texUV, srcUV = texco.xy; | |
+ float height = texture2D(ima, srcUV).a; | |
+ /*leaving control of this out of ui wont work without it but doesnt work right when you adjust the scale*/ | |
+ float v = height * bias * scale; | |
+ texUV = srcUV + v; | |
+ float h =1.0; | |
+ float numEyeSteps = mix(numSteps*2.0, numSteps, vv.z); | |
+ float step; | |
+ vec2 delta; | |
+ step = 1.0 / numEyeSteps; | |
+ delta = vec2(-vv.x, vv.y) * bumpScale / (vv.z * numEyeSteps); | |
+ for (int i=0;i<int(numEyeSteps);i++) | |
+ { | |
+ if (height < h) { | |
+ h -= step; | |
+ texUV -= delta; | |
+ height = texture2D(ima, texUV*size.xy).a;// *size is to allow tiling :) but normal map is acting funny :( | |
+ } | |
+ } | |
+ h = height;//<<needs to be an out put too | |
+ | |
+ /*depth correction*/ | |
+//http://inf.ufrgs.br/~oliveira/RTM.html // does coincide with the 2005 paper @chapter 3.5 i read for depth correction!! mathwise any way. | |
+//wayyyy to laggy | |
+//there are artifacts | |
+ | |
+//something to test | |
+//iproj=gl_ModelViewProjectionMatrix * intersection; | |
+//iproj.z /= iproj.w; | |
+//gl_FragDepth=(iproj.z+1.0)/2.0; | |
+//something to test | |
+ | |
+ // vec4 iproj=(gpuinvmat * vec4(h,h,h,h)); | |
+ //iproj.z /= iproj.w; | |
+ //gl_FragDepth=(iproj.z+1.0)/2.0; | |
+ | |
+ //float near = 0.1; | |
+ //float far = 1024.0; | |
+ //float p_eye_z = vvec.z + normalize(vvec.z) * bumpScale * h;//vvec.z + normalize(vvec.z) * bumpScale * h; | |
+ //float p_eye_z = vec4(gpuinvmat).z + normalize(vec4(gpuinvmat).z) * bumpScale * h; | |
+ //gl_FragDepth = ((-far / (far - near)) * -p_eye_z + (-far * near / (far - near))) / p_eye_z; | |
+ //gl_FragDepth = -p_eye_z * (far - near) / (near - far) + 2 * far * near / (near - far) / p_eye_z; //math acording to paper | |
+ | |
+//http://inf.ufrgs.br/~oliveira/RTM.html | |
+ | |
+ | |
+ if (texUV.x < 0.0 || texUV.x > 1.0 || texUV.y < 0.0 || texUV.y > 1.0) { | |
+ discard; | |
+ } | |
+ pTexCoord = vec3(texUV*vec2(size), 0.0);//<<uv coords that get sent back to blender // | |
+ /*self shadow*/ | |
+ for (int i=0;i<MAX_LIGHTS;i++)//<<MAX_LIGHTS will be a float soon | |
+ { | |
+ | |
+ vec3 lightDir = lampco - obpos; | |
+ vec3 lbinormal = cross(vn, tangent.xyz)*tangent.w; | |
+ vec3 lnormal = vn; | |
+ vvec.x = dot(tang, lightDir); | |
+ vvec.y = dot(lbinormal, lightDir); | |
+ vvec.z = dot(lnormal, lightDir); | |
+ vec3 lightVec = normalize (vvec); | |
+ vec3 normaltex = texture2D (ima, texUV).rgb * 2.0 - 1.0; | |
+ vec3 tsN = normaltex.xyz; | |
+ float NdotL = max(0.0, dot(tsN, lightVec)); | |
+ if (NdotL > 0.0) { | |
+ float numShadowSteps = mix(numSteps*2.0, numSteps,lightVec.z); | |
+ step = 1.0 / numShadowSteps; | |
+ delta = vec2(lightVec.x, lightVec.y) * bumpScale / (numShadowSteps * lightVec.z); | |
+ h = height + step * 0.1; | |
+ for (int i=0;i<int(numShadowSteps);i++) | |
+ { | |
+ if ((height < h) && (h < 1.0)) { | |
+ h += step; | |
+ texUV += delta; | |
+ height = texture2D(ima, texUV * size.xy).a; | |
+ } | |
+ } | |
+ selfShadow = float(height < h);//<<shadow | |
+ } | |
+ } | |
+} | |
+void pself_shadow(float ht, vec3 rgb, out vec3 color){ | |
+ color = rgb + (rgb*(ht*2.0)); | |
+ } | |
Index: source/blender/gpu/intern/gpu_material.c | |
=================================================================== | |
--- source/blender/gpu/intern/gpu_material.c (revision 52857) | |
+++ source/blender/gpu/intern/gpu_material.c (working copy) | |
@@ -955,18 +955,37 @@ | |
GPUMaterial *mat= shi->gpumat; | |
MTex *mtex; | |
Tex *tex; | |
- GPUNodeLink *texco, *tin, *trgb, *tnor, *tcol, *stencil, *tnorfac; | |
+ GPUNodeLink *texco, *tin, *trgb, *tnor, *tcol, *stencil, *tnorfac, *tparuv, *tparst, *tparbs;//angelo parallax | |
GPUNodeLink *texco_norm, *texco_orco, *texco_object; | |
GPUNodeLink *texco_global, *texco_uv = NULL; | |
GPUNodeLink *newnor, *orn; | |
+ GPUNodeLink *parco;//angelo parallax | |
/*char *lastuvname = NULL;*/ /*UNUSED*/ | |
float one = 1.0f, norfac, ofs[3]; | |
+ float paruv;//angelo parallax | |
+ float parst;//angelo parallax | |
+ float parbs;//angelo parallax | |
int tex_nr, rgbnor, talpha; | |
int init_done = FALSE, iBumpSpacePrev = 0; /* Not necessary, quiting gcc warning. */ | |
GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude; | |
int iFirstTimeNMap=1; | |
int found_deriv_map = 0; | |
+ //angelo parallax self shadow | |
+ Base *base; | |
+ Object *ob; | |
+ Scene *sce_iter; | |
+ GPULamp *lamp; | |
+ | |
+ for (SETLOOPER(shi->gpumat->scene, sce_iter, base)) { | |
+ ob= base->object; | |
+ if (ob->type==OB_LAMP) { | |
+ lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob, NULL); | |
+ //if (lamp) | |
+ //shade_one_light(shi, shr, lamp); | |
+ } | |
+ } | |
+ //angelo parallax self shadow | |
GPU_link(mat, "set_value", GPU_uniform(&one), &stencil); | |
GPU_link(mat, "texco_norm", GPU_builtin(GPU_VIEW_NORMAL), &texco_norm); | |
@@ -979,10 +998,10 @@ | |
GPU_builtin(GPU_VIEW_POSITION), &texco_global); | |
orn= texco_norm; | |
- | |
- /* go over texture slots */ | |
+/* | |
+ //go over texture slots | |
for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { | |
- /* separate tex switching */ | |
+ //separate tex switching | |
if (ma->septex & (1<<tex_nr)) continue; | |
if (ma->mtex[tex_nr]) { | |
@@ -991,7 +1010,7 @@ | |
tex= mtex->tex; | |
if (tex == NULL) continue; | |
- /* which coords */ | |
+ // which coords | |
if (mtex->texco==TEXCO_ORCO) | |
texco= texco_orco; | |
else if (mtex->texco==TEXCO_OBJECT) | |
@@ -1009,20 +1028,176 @@ | |
else if (mtex->texco==TEXCO_UV) { | |
if (1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) { | |
GPU_link(mat, "texco_uv", GPU_attribute(CD_MTFACE, mtex->uvname), &texco_uv); | |
- /*lastuvname = mtex->uvname;*/ /*UNUSED*/ | |
+ //lastuvname = mtex->uvname;//UNUSED | |
} | |
texco= texco_uv; | |
} | |
else | |
continue; | |
- /* in case of uv, this would just undo a multiplication in texco_uv */ | |
+ // in case of uv, this would just undo a multiplication in texco_uv | |
if (mtex->texco != TEXCO_UV) | |
GPU_link(mat, "mtex_2d_mapping", texco, &texco); | |
if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f) | |
GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(mtex->size), &texco); | |
+*/ | |
+ | |
+ /*find parallax*/ | |
+ for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { | |
+ /* separate tex switching */ | |
+ if (ma->septex & (1<<tex_nr)) continue; | |
+ | |
+ if (ma->mtex[tex_nr]) { | |
+ mtex= ma->mtex[tex_nr]; | |
+ | |
+ tex= mtex->tex; | |
+ if (tex == NULL) continue; | |
+ | |
+ /* which coords */ | |
+ | |
+ if (mtex->texco==TEXCO_ORCO) | |
+ texco= texco_orco; | |
+ else if (mtex->texco==TEXCO_OBJECT) | |
+ texco= texco_object; | |
+ else if (mtex->texco==TEXCO_NORM) | |
+ texco= orn; | |
+ else if (mtex->texco==TEXCO_TANGENT) | |
+ texco= texco_object; | |
+ else if (mtex->texco==TEXCO_GLOB) | |
+ texco= texco_global; | |
+ else if (mtex->texco==TEXCO_REFL) { | |
+ GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref); | |
+ texco= shi->ref; | |
+ } | |
+ else if (mtex->texco==TEXCO_UV) { | |
+ if (1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) { | |
+ GPU_link(mat, "texco_uv", GPU_attribute(CD_MTFACE, mtex->uvname), &texco_uv); | |
+ //lastuvname = mtex->uvname;//UNUSED | |
+ } | |
+ texco= texco_uv; | |
+ } | |
+ else | |
+ continue; | |
+ | |
+ //angelo parallax_out | |
+ if (mtex->mapto & MAP_PARALLAX) { | |
+ paruv = mtex->parallaxuv; | |
+ tparuv = GPU_uniform(&paruv); | |
+ parst = mtex->parallaxsteps; | |
+ tparst = GPU_uniform(&parst); | |
+ parbs = mtex->parallaxbumpsc; | |
+ tparbs = GPU_uniform(&parbs); | |
+ printf("found parallax map\n"); | |
+ if (lamp){ | |
+ printf("lamp\n"); | |
+ GPU_link(mat, "parallax_out_wl", texco, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), | |
+ GPU_builtin(GPU_VIEW_POSITION), GPU_attribute(CD_TANGENT, ""), GPU_builtin(GPU_VIEW_NORMAL), GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), GPU_uniform(mtex->size),GPU_image(tex->ima,&tex->iuser,FALSE),tparuv,tparst,tparbs,&parco,&shi->selfshad); | |
+ } | |
+ else{ | |
+ printf("no lamp\n"); | |
+ GPU_link(mat, "parallax_out_nl", texco, | |
+ GPU_builtin(GPU_VIEW_POSITION), GPU_attribute(CD_TANGENT, ""), GPU_builtin(GPU_VIEW_NORMAL), GPU_uniform(mtex->size),GPU_image(tex->ima,&tex->iuser,FALSE),tparuv,tparst,tparbs,&parco,&shi->selfshad); | |
+ } | |
+ //texco = parco; | |
+ } | |
+ else{ | |
+ parco = NULL; | |
+ continue; | |
+ } | |
+ } | |
+ } | |
+ | |
+ | |
+ | |
+ for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { | |
+ /* separate tex switching */ | |
+ if (ma->septex & (1<<tex_nr)) continue; | |
+ | |
+ if (ma->mtex[tex_nr]) { | |
+ mtex= ma->mtex[tex_nr]; | |
+ | |
+ tex= mtex->tex; | |
+ if (tex == NULL) continue; | |
+ | |
+ /* which coords */ | |
+ /*if parallax has modified uv*/ | |
+ if (mtex->texflag & MTEX_MAPTO_PARUV) { | |
+ if(parco){ | |
+ texco = parco; | |
+ } | |
+ else{ | |
+ if (mtex->texco==TEXCO_ORCO) | |
+ texco= texco_orco; | |
+ else if (mtex->texco==TEXCO_OBJECT) | |
+ texco= texco_object; | |
+ else if (mtex->texco==TEXCO_NORM) | |
+ texco= orn; | |
+ else if (mtex->texco==TEXCO_TANGENT) | |
+ texco= texco_object; | |
+ else if (mtex->texco==TEXCO_GLOB) | |
+ texco= texco_global; | |
+ else if (mtex->texco==TEXCO_REFL) { | |
+ GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref); | |
+ texco= shi->ref; | |
+ } | |
+ else if (mtex->texco==TEXCO_UV) { | |
+ if (1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) { | |
+ GPU_link(mat, "texco_uv", GPU_attribute(CD_MTFACE, mtex->uvname), &texco_uv); | |
+ //lastuvname = mtex->uvname;//UNUSED | |
+ } | |
+ texco= texco_uv; | |
+ } | |
+ else | |
+ continue; | |
+ | |
+ /* in case of uv, this would just undo a multiplication in texco_uv */ | |
+ | |
+ if (mtex->texco != TEXCO_UV) | |
+ GPU_link(mat, "mtex_2d_mapping", texco, &texco); | |
+ if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f)//<<do something about this!!! | |
+ GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(mtex->size), &texco); | |
+ } | |
+ | |
+ } | |
+ /*no modified uv, or we dont want to use them*/ | |
+ else | |
+ { | |
+ if (mtex->texco==TEXCO_ORCO) | |
+ texco= texco_orco; | |
+ else if (mtex->texco==TEXCO_OBJECT) | |
+ texco= texco_object; | |
+ else if (mtex->texco==TEXCO_NORM) | |
+ texco= orn; | |
+ else if (mtex->texco==TEXCO_TANGENT) | |
+ texco= texco_object; | |
+ else if (mtex->texco==TEXCO_GLOB) | |
+ texco= texco_global; | |
+ else if (mtex->texco==TEXCO_REFL) { | |
+ GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref); | |
+ texco= shi->ref; | |
+ } | |
+ else if (mtex->texco==TEXCO_UV) { | |
+ if (1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) { | |
+ GPU_link(mat, "texco_uv", GPU_attribute(CD_MTFACE, mtex->uvname), &texco_uv); | |
+ //lastuvname = mtex->uvname;//UNUSED | |
+ } | |
+ texco= texco_uv; | |
+ } | |
+ else | |
+ continue; | |
+ | |
+ /* in case of uv, this would just undo a multiplication in texco_uv */ | |
+ | |
+ if (mtex->texco != TEXCO_UV) | |
+ GPU_link(mat, "mtex_2d_mapping", texco, &texco); | |
+ if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f)//<<do something about this!!! | |
+ GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(mtex->size), &texco); | |
+ } | |
+ //angelo parallax | |
+ | |
+ | |
ofs[0] = mtex->ofs[0] + 0.5f - 0.5f*mtex->size[0]; | |
ofs[1] = mtex->ofs[1] + 0.5f - 0.5f*mtex->size[1]; | |
ofs[2] = 0.0f; | |
@@ -1420,10 +1595,18 @@ | |
GPU_link(mat, "set_rgb_zero", &shr->spec); | |
+ //material_lights(shi, shr); | |
+ | |
+ //shr->combined = shr->diff; | |
+ if (shi->selfshad){//angelo parallax self shadowing | |
material_lights(shi, shr); | |
- | |
+ GPU_link(mat, "pself_shadow", shi->selfshad, shr->diff, &shr->diff);//angelo parallax self shadowing | |
shr->combined = shr->diff; | |
- | |
+ }//angelo parallax self shadowing | |
+ else {//angelo parallax self shadowing | |
+ material_lights(shi, shr);//angelo parallax self shadowing | |
+ shr->combined = shr->diff;//angelo parallax self shadowing | |
+ }//angelo parallax self shadowing | |
GPU_link(mat, "set_value", shi->alpha, &shr->alpha); | |
if (world) { | |
Index: source/blender/gpu/GPU_material.h | |
=================================================================== | |
--- source/blender/gpu/GPU_material.h (revision 52857) | |
+++ source/blender/gpu/GPU_material.h (working copy) | |
@@ -144,6 +144,7 @@ | |
GPUNodeLink *rgb, *specrgb, *vn, *view, *vcol, *ref; | |
GPUNodeLink *alpha, *refl, *spec, *emit, *har, *amb; | |
+ GPUNodeLink *selfshad;//angelo parallax | |
} GPUShadeInput; | |
typedef struct GPUShadeResult { | |
Index: source/blender/makesrna/intern/rna_material.c | |
=================================================================== | |
--- source/blender/makesrna/intern/rna_material.c (revision 52857) | |
+++ source/blender/makesrna/intern/rna_material.c (working copy) | |
@@ -502,7 +502,19 @@ | |
RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_NORM); | |
RNA_def_property_ui_text(prop, "Normal", "The texture affects the rendered normal"); | |
RNA_def_property_update(prop, 0, "rna_Material_update"); | |
+ | |
+//angelo parallax | |
+ prop = RNA_def_property(srna, "use_map_parallax", PROP_BOOLEAN, PROP_NONE); | |
+ RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_PARALLAX); | |
+ RNA_def_property_ui_text(prop, "Parallax", "The texture affects the releif depth"); | |
+ RNA_def_property_update(prop, 0, "rna_Material_update"); | |
+ prop = RNA_def_property(srna, "use_parallax_uv", PROP_BOOLEAN, PROP_NONE); | |
+ RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_MAPTO_PARUV); | |
+ RNA_def_property_ui_text(prop, "Use Parallax UV","This is necessary for proper use of the parallax mapping"); | |
+ RNA_def_property_update(prop, 0, "rna_Material_update"); | |
+//angelo parallax | |
+ | |
prop = RNA_def_property(srna, "use_map_color_spec", PROP_BOOLEAN, PROP_NONE); | |
RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLSPEC); | |
RNA_def_property_ui_text(prop, "Specular Color", "The texture affects the specularity color"); | |
@@ -610,6 +622,28 @@ | |
RNA_def_property_ui_text(prop, "Warp Factor", "Amount texture affects texture coordinates of next channels"); | |
RNA_def_property_update(prop, 0, "rna_Material_update"); | |
+//angelo parallax | |
+ prop = RNA_def_property(srna, "parallax_uv_shift", PROP_FLOAT, PROP_NONE); | |
+ RNA_def_property_float_sdna(prop, NULL, "parallaxuv"); | |
+ RNA_def_property_ui_range(prop, 0, 1, 10, 3); | |
+ RNA_def_property_ui_text(prop, "UV Shift", "Amount texture is shifted"); | |
+ RNA_def_property_update(prop, 0, "rna_Material_update"); | |
+ | |
+ | |
+ prop = RNA_def_property(srna, "parallax_steps", PROP_FLOAT, PROP_NONE); | |
+ RNA_def_property_float_sdna(prop, NULL, "parallaxsteps"); | |
+ RNA_def_property_ui_range(prop, 0, 20, 10, 3); | |
+ RNA_def_property_ui_text(prop, "Parallax Steps", "Number of steps taken to achieve result"); | |
+ RNA_def_property_update(prop, 0, "rna_Material_update"); | |
+ | |
+ | |
+ prop = RNA_def_property(srna, "parallax_bump_scale", PROP_FLOAT, PROP_NONE); | |
+ RNA_def_property_float_sdna(prop, NULL, "parallaxbumpsc"); | |
+ RNA_def_property_ui_range(prop, 0, 1, 10, 3); | |
+ RNA_def_property_ui_text(prop, "Parallax Bump Scale", "Height of SPOM"); | |
+ RNA_def_property_update(prop, 0, "rna_Material_update"); | |
+//angelo parallax | |
+ | |
prop = RNA_def_property(srna, "specular_color_factor", PROP_FLOAT, PROP_NONE); | |
RNA_def_property_float_sdna(prop, NULL, "colspecfac"); | |
RNA_def_property_ui_range(prop, 0, 1, 10, 3); | |
Index: source/blender/makesrna/intern/rna_texture.c | |
=================================================================== | |
--- source/blender/makesrna/intern/rna_texture.c (revision 52857) | |
+++ source/blender/makesrna/intern/rna_texture.c (working copy) | |
@@ -1322,6 +1322,13 @@ | |
RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_DERIVATIVEMAP); | |
RNA_def_property_ui_text(prop, "Derivative Map", "Use red and green as derivative values"); | |
RNA_def_property_update(prop, 0, "rna_Texture_update"); | |
+ | |
+ /*Parallax*///angelo parallax | |
+ prop = RNA_def_property(srna, "use_parallax_map", PROP_BOOLEAN, PROP_NONE); | |
+ RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_PARALLAXMAP); | |
+ RNA_def_property_ui_text(prop, "Parallax Map", "Use image values for parallax mapping"); | |
+ RNA_def_property_update(prop, 0, "rna_Texture_update"); | |
+ //angelo parallax | |
} | |
static void rna_def_texture_environment_map(BlenderRNA *brna) | |
Index: source/blender/blenloader/intern/versioning_250.c | |
=================================================================== | |
--- source/blender/blenloader/intern/versioning_250.c (revision 52857) | |
+++ source/blender/blenloader/intern/versioning_250.c (working copy) | |
@@ -550,6 +550,7 @@ | |
if (neg & MAP_DISP) mtex->dispfac = -mtex->dispfac; | |
if (neg & MAP_NORM) mtex->norfac = -mtex->norfac; | |
if (neg & MAP_WARP) mtex->warpfac = -mtex->warpfac; | |
+ if (neg & MAP_PARALLAX) mtex->parallaxuv = -mtex->parallaxuv;//angelo parallax | |
mtex->colspecfac = (neg & MAP_COLSPEC)? -colfac: colfac; | |
mtex->mirrfac = (neg & MAP_COLMIR)? -colfac: colfac; | |
Index: source/blender/blenkernel/intern/texture.c | |
=================================================================== | |
--- source/blender/blenkernel/intern/texture.c (revision 52857) | |
+++ source/blender/blenkernel/intern/texture.c (working copy) | |
@@ -581,6 +581,9 @@ | |
mtex->blendtype = MTEX_BLEND; | |
mtex->colfac = 1.0; | |
mtex->norfac = 1.0; | |
+ mtex->parallaxuv = 0.0;//angelo parallax //is NOT in the ui needed dont remove for now. | |
+ mtex->parallaxbumpsc = 0.03;//angelo parallax | |
+ mtex->parallaxsteps = 10.0;//angelo parallax | |
mtex->varfac = 1.0; | |
mtex->dispfac = 0.2; | |
mtex->colspecfac = 1.0f; | |
Index: source/blender/makesdna/DNA_material_types.h | |
=================================================================== | |
--- source/blender/makesdna/DNA_material_types.h (revision 52857) | |
+++ source/blender/makesdna/DNA_material_types.h (working copy) | |
@@ -374,7 +374,7 @@ | |
#define MAP_DISPLACE 4096 | |
#define MAP_WARP 8192 | |
#define MAP_LAYER 16384 /* unused */ | |
- | |
+#define MAP_PARALLAX 32768 //angelo parallax | |
/* volume mapto - reuse definitions for now - a bit naughty! */ | |
#define MAP_DENSITY 128 | |
#define MAP_EMISSION 64 | |
Index: source/blender/makesdna/DNA_texture_types.h | |
=================================================================== | |
--- source/blender/makesdna/DNA_texture_types.h (revision 52857) | |
+++ source/blender/makesdna/DNA_texture_types.h (working copy) | |
@@ -75,6 +75,7 @@ | |
/* material */ | |
float norfac, dispfac, warpfac; | |
+ float parallaxuv, parallaxsteps, parallaxbumpsc, padpfac;//angelo parallax | |
float colspecfac, mirrfac, alphafac; | |
float difffac, specfac, emitfac, hardfac; | |
float raymirrfac, translfac, ambfac; | |
@@ -348,7 +349,8 @@ | |
#define TEX_GAUSS_MIP 4096 | |
#define TEX_FILTER_MIN 8192 | |
#define TEX_DERIVATIVEMAP 16384 | |
- | |
+//angelo parallax | |
+#define TEX_PARALLAXMAP 32768 | |
/* texfilter */ | |
// TXF_BOX -> blender's old texture filtering method | |
#define TXF_BOX 0 | |
@@ -474,7 +476,7 @@ | |
/* #define MTEX_BUMP_FLIPPED 4096 */ /* UNUSED */ | |
#define MTEX_BICUBIC_BUMP 8192 | |
#define MTEX_MAPTO_BOUNDS 16384 | |
- | |
+#define MTEX_MAPTO_PARUV 32768 //angelo parallax | |
/* blendtype */ | |
#define MTEX_BLEND 0 | |
#define MTEX_MUL 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment