Are soft shadows possible with point light using cubemap ...

文章推薦指數: 80 %
投票人數:10人

Or is there an alternative? Thanks a lot in advance for your help! opengl glsl shader shadow shadow-mapping. 2022DeveloperSurveyisopen!Takesurvey. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore Aresoftshadowspossiblewithpointlightusingcubemap(OpenGL/GLSL)? AskQuestion Asked 7years,7monthsago Modified 7years,7monthsago Viewed 2ktimes 3 Icodeda3Dapplicationmanagingspotlightshadowmapping.TodothisIuseclassicalshadowmappingtechnique(IfilladepthtextureinthefirstrenderpassandinthesecondrenderpassIcomparethedistancefromlighttothefirstoccluderandthedistancefromthelighttothevertexpositiontoknowifmyfragmentisinshadowornot). Here'sascreenshot(spotlight/2Ddepthtextureshadowmapping): InthisexampleIusePCFshadowmappingtechniqueusingthefunction'textureProjOffset'.Here'sapieceofcodefrommyfragmentshader: Samplerused: sampler2DShadowShadow2DSampler[MAX_LIGHTS_COUNT]; ForHARDshadows: shadowFactor=textureProj(Shadow2DSampler[idx],ShadowCoords[idx]); ForPCFSOFTshadows: for(intidy=offset;idy>=-offset;idy--) for(intidx=-offset;idx<=offset;idx++) shadowFactor+=textureProjOffset( Shadow2DSampler[idz],ShadowCoords[idz],ivec2(idx,idy)); Ihavealsomanagedthebasiccubemapshadowmappingtomanageomnidirectionalshadowmappingcurrentlyappliedforpointlights.TodothisinthefirstrenderpassIuseageometryshadertodispatchboththeprojectionandviewmatrixprovidedbythe6shadowfrustrums(allinONEpass!It'sdifferentofthetechniqueconcistingtofill6separatetextureswiththistime6renderstates). Here'sascreenshot(spotlight/Cubedepthtextureshadowmapping): Asyoucansee,it'sonlyHARDshadowmapping.TorecoverthedepthvalueencodedintothecubemapIhavetousethistimethefunction'texture'(textureProjdoesnotexistsfor'samplerCube'and'samplerCubeShadow').NextIhavetocomputethedistancebetweenthelightpositionandthevertexpositioninworldspaceandthenconvertitintoclipspacebecausethedepthvaluecontainedintothetextureisalreadyinclipspace. Here'sapieceofcodefromthefragmentshadertoseetheprocess: Samplerused: samplerCubeShadowShadowCubeSampler[MAX_LIGHTS_COUNT]; ForHARDshadows: floatConvertDistToClipSpace(vec3lightDir_ws) { vec3AbsVec=abs(lightDir_ws); floatLocalZcomp=max(AbsVec.x,max(AbsVec.y,AbsVec.z)); floatNormZComp=(NearFar.y+NearFar.x)/(NearFar.y-NearFar.x) -(2.0f*NearFar.y*NearFar.x)/(LocalZcomp*NearFar.y-NearFar.x); return((NormZComp+1)*0.5f); } floatGetBiased_Cube_Hard_ShadowFactor(vec3vertexPosition_ws,intidx) { vec3lightToVertexDir_ws=vertexPosition_ws-LightPos_ws.xyz; floatLightToVertexClipDist=ConvertDistToClipSpace(lightToVertexDir_ws); floatLightToOccluderClipDist=texture( ShadowCubeSampler[idx],vec4(lightToVertexDir_ws,LightToVertexClipDist)); if(LightToOccluderClipDist



請為這篇文章評分?