1/** 2 * Mandelbulber v2, a 3D fractal generator ,=#MKNmMMKmmßMNWy, 3 * ,B" ]L,,p%%%,,,§;, "K 4 * Copyright (C) 2018-21 Mandelbulber Team §R-==%w["'~5]m%=L.=~5N 5 * ,=mm=§M ]=4 yJKA"/-Nsaj "Bw,==,, 6 * This file is part of Mandelbulber. §R.r= jw",M Km .mM FW ",§=ß., ,TN 7 * ,4R =%["w[N=7]J '"5=],""]]M,w,-; T=]M 8 * Mandelbulber is free software: §R.ß~-Q/M=,=5"v"]=Qf,'§"M= =,M.§ Rz]M"Kw 9 * you can redistribute it and/or §w "xDY.J ' -"m=====WeC=\ ""%""y=%"]"" § 10 * modify it under the terms of the "§M=M =D=4"N #"%==A%p M§ M6 R' #"=~.4M 11 * GNU General Public License as §W =, ][T"]C § § '§ e===~ U !§[Z ]N 12 * published by the 4M",,Jm=,"=e~ § § j]]""N BmM"py=ßM 13 * Free Software Foundation, ]§ T,M=& 'YmMMpM9MMM%=w=,,=MT]M m§;'§, 14 * either version 3 of the License, TWw [.j"5=~N[=§%=%W,T ]R,"=="Y[LFT ]N 15 * or (at your option) TW=,-#"%=;[ =Q:["V"" ],,M.m == ]N 16 * any later version. J§"mr"] ,=,," =="""J]= M"M"]==ß" 17 * §= "=C=4 §"eM "=B:m|4"]#F,§~ 18 * Mandelbulber is distributed in "9w=,,]w em%wJ '"~" ,=,,ß" 19 * the hope that it will be useful, . "K= ,=RMMMßM""" 20 * but WITHOUT ANY WARRANTY; .''' 21 * without even the implied warranty 22 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 * 24 * See the GNU General Public License for more details. 25 * You should have received a copy of the GNU General Public License 26 * along with Mandelbulber. If not, see <http://www.gnu.org/licenses/>. 27 * 28 * ########################################################################### 29 * 30 * Authors: Krzysztof Marczak (buddhi1980@gmail.com) 31 * 32 * calculation of surface shader 33 */ 34 35float3 ObjectShader(__constant sClInConstants *consts, sRenderData *renderData, 36 sShaderInputDataCl *input, sClCalcParams *calcParam, float3 *outSurfaceColor, float3 *outSpecular, 37 float3 *iridescenceOut, float *alphaOut, sClGradientsCollection *gradients) 38{ 39 float3 color = 0.7f; 40 41 float3 shade = 0.0f; 42 float3 specular = 0.0f; 43 float3 shadow = 1.0f; 44 *alphaOut = 1.0f; 45 46 float3 fillLight = consts->params.fillLightColor; 47 48 float3 surfaceColor = SurfaceColor(consts, renderData, input, calcParam, gradients); 49 50#ifdef USE_TEXTURES 51#ifdef USE_COLOR_TEXTURE 52 float texColInt = input->material->colorTextureIntensity; 53 float texColIntN = 1.0f - texColInt; 54 surfaceColor *= input->texColor * texColInt + texColIntN; 55#endif 56#endif 57 58 float3 AO = 0.0f; 59 if (consts->params.ambientOcclusionEnabled) 60 { 61#ifdef AO_MODE_FAST 62 AO = FastAmbientOcclusion(consts, renderData, input, calcParam); 63#endif 64#ifdef AO_MODE_MULTIPLE_RAYS 65 AO = AmbientOcclusion(consts, renderData, input, calcParam); 66#endif 67 AO *= consts->params.ambientOcclusion * consts->params.ambientOcclusionColor; 68 } 69 70 float3 envMapping = 0.0f; 71#ifdef USE_ENV_MAPPING 72 envMapping = EnvMappingShader(consts, renderData, input); 73 envMapping *= input->material->reflectance; 74#ifdef USE_TEXTURES 75#ifdef USE_DIFFUSION_TEXTURE 76 envMapping *= input->texDiffuse; 77#endif 78#endif 79 80#endif 81 82 float3 auxLights = 0.0f; 83 float3 auxSpecular = 0.0f; 84 85#ifdef AUX_LIGHTS 86 auxLights = 87 AuxLightsShader(consts, renderData, input, calcParam, surfaceColor, gradients, &auxSpecular); 88#endif 89 90 float3 fakeLights = 0.0f; 91 float3 fakeLightsSpecular = 0.0f; 92#ifdef FAKE_LIGHTS 93 fakeLights = 94 FakeLightsShader(consts, input, calcParam, surfaceColor, gradients, &fakeLightsSpecular); 95#endif 96 97 float3 iridescence = 1.0f; 98#ifdef USE_IRIDESCENCE 99 if (input->material->iridescenceEnabled) 100 { 101 iridescence = IridescenceShader(consts, renderData, input, calcParam); 102 } 103#endif 104 *iridescenceOut = iridescence; 105 106 float3 totalSpecular = (fakeLightsSpecular + auxSpecular) * iridescence; 107 108 float3 luminosity; 109#ifdef USE_LUMINOSITY_GRADIENT 110 if (input->material->useColorsFromPalette && input->material->luminosityGradientEnable) 111 { 112 luminosity = input->material->luminosity * gradients->luminosity; 113 } 114 else 115#endif 116 { 117 luminosity = input->material->luminosity * input->material->luminosityColor; 118 } 119 120#ifdef USE_TEXTURES 121#ifdef USE_LUMINOSITY_TEXTURE 122 luminosity += input->texLuminosity * input->material->luminosityTextureIntensity; 123#endif 124#endif 125 126 color = surfaceColor * (fillLight + auxLights + fakeLights + AO) + envMapping + totalSpecular 127 + luminosity; 128 *outSpecular = totalSpecular; 129 130 *outSurfaceColor = surfaceColor; 131 return color; 132} 133